Untitled diff

Created Diff never expires
<?php #
<?php #
if (IN_serendipity !== true) {
if (IN_serendipity !== true) {
die ("Don't hack!");
die ("Don't hack!");
}
}
// Probe for a language include with constants. Still include defines later on, if some constants were missing
// Probe for a language include with constants. Still include defines later on, if some constants were missing
$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';
$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';
if (file_exists($probelang)) {
if (file_exists($probelang)) {
include $probelang;
include $probelang;
}
}
include dirname(__FILE__) . '/lang_en.inc.php';
include dirname(__FILE__) . '/lang_en.inc.php';
class serendipity_event_imageselectorplus extends serendipity_event
class serendipity_event_imageselectorplus extends serendipity_event
{
{
var $title = PLUGIN_EVENT_IMAGESELECTORPLUS_NAME;
var $title = PLUGIN_EVENT_IMAGESELECTORPLUS_NAME;
var $gotMilk = false;
var $gotMilk = false;
var $cache = array();
var $cache = array();
function introspect(&$propbag)
function introspect(&$propbag)
{
{
global $serendipity;
global $serendipity;
$propbag->add('name', PLUGIN_EVENT_IMAGESELECTORPLUS_NAME);
$propbag->add('name', PLUGIN_EVENT_IMAGESELECTORPLUS_NAME);
$propbag->add('description', PLUGIN_EVENT_IMAGESELECTORPLUS_DESC);
$propbag->add('description', PLUGIN_EVENT_IMAGESELECTORPLUS_DESC);
$propbag->add('stackable', false);
$propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking, Vladimir Ajgl, Adam Charnock, Ian');
$propbag->add('author', 'Garvin Hicking, Vladimir Ajgl, Adam Charnock, Ian');
$propbag->add('version', '0.41');
$propbag->add('version', '0.41');
$propbag->add('requirements', array(
$propbag->add('requirements', array(
'serendipity' => '1.3',
'serendipity' => '1.3',
'smarty' => '2.6.7',
'smarty' => '2.6.7',
'php' => '4.1.0'
'php' => '4.1.0'
));
));
$propbag->add('groups', array('IMAGES','MARKUP'));
$propbag->add('groups', array('IMAGES','MARKUP'));
$propbag->add('event_hooks', array(
$propbag->add('event_hooks', array(
'entries_header' => true,
'entries_header' => true,
'entry_display' => true,
'entry_display' => true,
'backend_entry_presave' => true,
'backend_entry_presave' => true,
'backend_publish' => true,
'backend_publish' => true,
'backend_save' => true,
'backend_save' => true,
'frontend_image_add_unknown' => true,
'frontend_image_add_unknown' => true,
'frontend_image_add_filenameonly' => true,
'frontend_image_add_filenameonly' => true,
'frontend_image_selector_submit' => true,
'frontend_image_selector_submit' => true,
'frontend_image_selector_more' => true,
'frontend_image_selector_more' => true,
'frontend_image_selector_imagecomment' => true,
'frontend_image_selector_imagecomment' => true,
'frontend_image_selector_imagelink' => true,
'frontend_image_selector_imagelink' => true,
'frontend_image_selector_imagealign' => true,
'frontend_image_selector_imagealign' => true,
'frontend_image_selector_imagesize' => true,
'frontend_image_selector_imagesize' => true,
'frontend_image_selector_hiddenfields' => true,
'frontend_image_selector_hiddenfields' => true,
'frontend_image_selector' => true,
'frontend_image_selector' => true,
'backend_image_add' => true,
'backend_image_add' => true,
'backend_image_addHotlink' => true,
'backend_image_addHotlink' => true,
'backend_image_addform' => true,
'backend_image_addform' => true,
'css_backend' => true,
'css_backend' => true,
'css' => true,
'css' => true,
'frontend_display' => true
'frontend_display' => true
));
));
$this->markup_elements = array(
$this->markup_elements = array(
array(
array(
'name' => 'ENTRY_BODY',
'name' => 'ENTRY_BODY',
'element' => 'body',
'element' => 'body',
),
),
array(
array(
'name' => 'EXTENDED_BODY',
'name' => 'EXTENDED_BODY',
'element' => 'extended',
'element' => 'extended',
)
)
);
);
$conf_array = array('thumb_max_width', 'thumb_max_height','unzipping', 'autoresize', 'force_jhead');
$conf_array = array('thumb_max_width', 'thumb_max_height','unzipping', 'autoresize', 'force_jhead');
foreach($this->markup_elements as $element) {
foreach($this->markup_elements as $element) {
$conf_array[] = $element['name'];
$conf_array[] = $element['name'];
}
}
$propbag->add('configuration', $conf_array);
$propbag->add('configuration', $conf_array);
}
}
function introspect_config_item($name, &$propbag) {
function introspect_config_item($name, &$propbag) {
global $serendipity;
global $serendipity;
switch ($name) {
switch ($name) {
case 'force_jhead':
case 'force_jhead':
$propbag->add('type', 'boolean');
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_EVENT_IMAGESELECTORPLUS_JHEAD);
$propbag->add('name', PLUGIN_EVENT_IMAGESELECTORPLUS_JHEAD);
$propbag->add('description', PLUGIN_EVENT_IMAGESELECTORPLUS_JHEAD_DESC);
$propbag->add('description', PLUGIN_EVENT_IMAGESELECTORPLUS_JHEAD_DESC);
$propbag->add('default', 'false');
$propbag->add('default', 'false');
break;
break;
case 'thumb_max_width':
case 'thumb_max_width':
$propbag->add('type', 'string');
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_IMAGESELECTORPLUS_MAXWIDTH);
$propbag->add('name', PLUGIN_EVENT_IMAGESELECTORPLUS_MAXWIDTH);
$propbag->add('description', '');
$propbag->add('description', '');
$propbag->add('default', '0');
$propbag->add('default', '0');
break;
break;
case 'thumb_max_height':
case 'thumb_max_height':
$propbag->add('type', 'string');
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_IMAGESELECTORPLUS_MAXHEIGHT);
$propbag->add('name', PLUGIN_EVENT_IMAGESELECTORPLUS_MAXHEIGHT);
$propbag->add('description', '');
$propbag->add('description', '');
$propbag->add('default', '0');
$propbag->add('default', '0');
break;
break;
case 'unzipping':
case 'unzipping':
if (class_exists('ZipArchive')) {
if (class_exists('ZipArchive')) {
$propbag->add('type', 'boolean');
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES);
$propbag->add('name', PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES);
$propbag->add('description', PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES_BLABLAH);
$propbag->add('description', PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES_BLABLAH);
$propbag->add('default', 'true');
$propbag->add('default', 'true');
}
}
break;
break;
case 'autoresize':
case 'autoresize':
$propbag->add('type', 'boolean');
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_EVENT_IMAGESELECTORPLUS_AUTORESIZE);
$propbag->add('name', PLUGIN_EVENT_IMAGESELECTORPLUS_AUTORESIZE);
$propbag->add('description', PLUGIN_EVENT_IMAGESELECTORPLUS_AUTORESIZE_DESC);
$propbag->add('description', PLUGIN_EVENT_IMAGESELECTORPLUS_AUTORESIZE_DESC);
$propbag->add('default', 'false');
$propbag->add('default', 'false');
break;
break;
default:
default:
if (class_exists('SimpleXMLElement')) {
if (class_exists('SimpleXMLElement')) {
$propbag->add('type', 'boolean');
$propbag->add('type', 'boolean');
$propbag->add('name', constant($name));
$propbag->add('name', constant($name));
$propbag->add('description', sprintf(APPLY_MARKUP_TO," - ".constant($name)));
$propbag->add('description', sprintf(APPLY_MARKUP_TO," - ".constant($name)));
$propbag->add('default', 'true');
$propbag->add('default', 'true');
}
}
break;
break;
}
}
return true;
return true;
}
}
// to recash all entries after installing the plugin
// to recash all entries after installing the plugin
function install() {
function install() {
serendipity_plugin_api::hook_event('backend_cache_entries', $this->title);
serendipity_plugin_api::hook_event('backend_cache_entries', $this->title);
}
}
// to recash all entries after uninstalling the plugin
// to recash all entries after uninstalling the plugin
function uninstall(&$propbag) {
function uninstall(&$propbag) {
serendipity_plugin_api::hook_event('backend_cache_purge', $this->title);
serendipity_plugin_api::hook_event('backend_cache_purge', $this->title);
serendipity_plugin_api::hook_event('backend_cache_entries', $this->title);
serendipity_plugin_api::hook_event('backend_cache_entries', $this->title);
}
}
function generate_content(&$title) {
function generate_content(&$title) {
$title = $this->title;
$title = $this->title;
}
}
function httpize($path) {
function httpize($path) {
global $serendipity;
global $serendipity;
if (preg_match('@' . $serendipity['uploadPath'] . '(.+)$@imsU', $path, $match)) {
if (preg_match('@' . $serendipity['uploadPath'] . '(.+)$@imsU', $path, $match)) {
return $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $match[1];
return $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $match[1];
}
}
return preg_replace('@^' . preg_quote($_SERVER['DOCUMENT_ROOT']) . '(.*)$@imsU', '\1', $path);
return preg_replace('@^' . preg_quote($_SERVER['DOCUMENT_ROOT']) . '(.*)$@imsU', '\1', $path);
}
}
function selected() {
function selected() {
global $serendipity;
global $serendipity;
if ($serendipity['GET']['subpage'] == 's9yisp') {
if ($serendipity['GET']['subpage'] == 's9yisp') {
return true;
return true;
}
}
return false;
return false;
}
}
function resizeThumb($sizes, $target) {
function resizeThumb($sizes, $target) {
global $serendipity;
global $serendipity;
// Thumbsize: 75
// Thumbsize: 75
// A: 100x300
// A: 100x300
// B: 300x100
// B: 300x100
// s9y A: 25x75
// s9y A: 25x75
// s9y B: 75x25
// s9y B: 75x25
// Max-Height: 0
// Max-Height: 0
// Max-Width : 75
// Max-Width : 75
// s9y A:
// s9y A:
// s9y B:
// s9y B:
// Max-Height: 0
// Max-Height: 0
// Max-Height: 75
// Max-Height: 75
// s9y A: 25x75
// s9y A: 25x75
// s9y B: 225x75
// s9y B: 225x75
$fdim = @serendipity_getimagesize($target, '', '');
$fdim = @serendipity_getimagesize($target, '', '');
if (!isset($serendipity['thumbConstraint'])) {
if (!isset($serendipity['thumbConstraint'])) {
// Original code, for older versions of s9y
// Original code, for older versions of s9y
$s9ysizes = serendipity_calculate_aspect_size($fdim[0], $fdim[1], $serendipity['thumbSize']);
$s9ysizes = serendipity_calculate_aspect_size($fdim[0], $fdim[1], $serendipity['thumbSize']);
if ($fdim[0] >= $fdim[1]) {
if ($fdim[0] >= $fdim[1]) {
$orientation = 'Landscape';
$orientation = 'Landscape';
} else {
} else {
$orientation = 'Portrait';
$orientation = 'Portrait';
}
}
if ($sizes['width'] == 0) {
if ($sizes['width'] == 0) {
if ($orientation == 'Landscape') {
if ($orientation == 'Landscape') {
$_newsizes = serendipity_calculate_aspect_size($fdim[0], $fdim[1], null, $sizes['height']);
$_newsizes = serendipity_calculate_aspect_size($fdim[0], $fdim[1], null, $sizes['height']);
} else {
} else {
$_newsizes = serendipity_calculate_aspect_size($fdim[0], $fdim[1], $sizes['height'], null);
$_newsizes = serendipity_calculate_aspect_size($fdim[0], $fdim[1], $sizes['height'], null);
}
}
$newsizes = array('width' => $_newsizes[0], 'height' => $_newsizes[1]);
$newsizes = array('width' => $_newsizes[0], 'height' => $_newsizes[1]);
} elseif ($sizes['height'] == 0) {
} elseif ($sizes['height'] == 0) {
if ($orientation == 'Landscape') {
if ($orientation == 'Landscape') {
$_newsizes = serendipity_calculate_aspect_size($fdim[0], $fdim[1], $sizes['width'], null);
$_newsizes = serendipity_calculate_aspect_size($fdim[0], $fdim[1], $sizes['width'], null);
} else {
} else {
$_newsizes = serendipity_calculate_aspect_size($fdim[0], $fdim[1], null, $sizes['width']);
$_newsizes = serendipity_calculate_aspect_size($fdim[0], $fdim[1], null, $sizes['width']);
}
}
$newsizes = array('width' => $_newsizes[0], 'height' => $_newsizes[1]);
$newsizes = array('width' => $_newsizes[0], 'height' => $_newsizes[1]);
} else {
} else {
$newsizes = $sizes;
$newsizes = $sizes;
array(
array(
0 => $sizes['width'],
0 => $sizes['width'],
1 => $sizes['height']
1 => $sizes['height']
);
);
}
}
} else {
} else {
// Newer s9y version that understands how to constrain images properly
// Newer s9y version that understands how to constrain images properly
$s9ysizes = serendipity_calculate_aspect_size($fdim[0], $fdim[1], $serendipity['thumbSize'], $serendipity['thumbConstraint']);
$s9ysizes = serendipity_calculate_aspect_size($fdim[0], $fdim[1], $serendipity['thumbSize'], $serendipity['thumbConstraint']);
$orientation = 'size';
$orientation = 'size';
if ($sizes['width'] == 0) {
if ($sizes['width'] == 0) {
$_newsizes = serendipity_calculate_aspect_size($fdim[0], $fdim[1], $sizes['height'], 'height');
$_newsizes = serendipity_calculate_aspect_size($fdim[0], $fdim[1], $sizes['height'], 'height');
} elseif ($sizes['height'] == 0) {
} elseif ($sizes['height'] == 0) {
$_newsizes = serendipity_calculate_aspect_size($fdim[0], $fdim[1], $sizes['width'], 'width');
$_newsizes = serendipity_calculate_aspect_size($fdim[0], $fdim[1], $sizes['width'], 'width');
} else {
} else {
$_newsizes = $sizes;
$_newsizes = $sizes;
}
}
$newsizes = array('width' => $_newsizes[0], 'height' => $_newsizes[1]);
$newsizes = array('width' => $_newsizes[0], 'height' => $_newsizes[1]);
}
}
echo "Resizing thumb of " . $orientation . " " . $fdim[0] . "x" . $fdim[1] . " to " . $_newsizes[0] . "x" . $_newsizes[1] . " instead of " . $s9ysizes[0] . "x" . $s9ysizes[1] . "...<br />\n";
echo "Resizing thumb of " . $orientation . " " . $fdim[0] . "x" . $fdim[1] . " to " . $_newsizes[0] . "x" . $_newsizes[1] . " instead of " . $s9ysizes[0] . "x" . $s9ysizes[1] . "...<br />\n";
$dirname = dirname($target) . '/';
$dirname = dirname($target) . '/';
$dirname = str_replace($serendipity['serendipityPath'] . $serendipity['uploadPath'], '', $dirname);
$dirname = str_replace($serendipity['serendipityPath'] . $serendipity['uploadPath'], '', $dirname);
serendipity_makeThumbnail(basename($target), $dirname, $newsizes, $serendipity['thumbSuffix']);
serendipity_makeThumbnail(basename($target), $dirname, $newsizes, $serendipity['thumbSuffix']);
}
}
function event_hook($event, &$bag, &$eventData, $addData = null) {
function event_hook($event, &$bag, &$eventData, $addData = null) {
global $serendipity;
global $serendipity;
$hooks = &$bag->get('event_hooks');
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
if (isset($hooks[$event])) {
switch($event) {
switch($event) {
case 'backend_image_addform':
case 'backend_image_addform':
if ($serendipity['version'][0] < '2') {
if ($serendipity['version'][0] < '2') {
if (class_exists('ZipArchive')) {
if (class_exists('ZipArchive')) {
$checkedY = "";
$checkedY = "";
$checkedN = "";
$checkedN = "";
$this->get_config('unzipping') ? $checkedY = ' checked="checked"' : $checkedN = ' checked="checked"';
$this->get_config('unzipping') ? $checkedY = ' checked="checked"' : $checkedN = ' checked="checked"';
?>
?>
<br />
<br />
<div>
<div>
<strong><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES;?></strong><br />
<strong><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES;?></strong><br />
<?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES_DESC;?>
<?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES_DESC;?>
<div>
<div>
<input type="radio" class="input_radio" id="unzip_yes" name="serendipity[unzip_archives]" value="<?php echo YES;?>"<?php echo $checkedY;?>><label for="unzip_yes"><?php echo YES;?></label>
<input type="radio" class="input_radio" id="unzip_yes" name="serendipity[unzip_archives]" value="<?php echo YES;?>"<?php echo $checkedY;?>><label for="unzip_yes"><?php echo YES;?></label>
<input type="radio" class="input_radio" id="unzip_no" name="serendipity[unzip_archives]" value="<?php echo NO;?>"<?php echo $checkedN;?>><label for="unzip_no"><?php echo NO;?></label>
<input type="radio" class="input_radio" id="unzip_no" name="serendipity[unzip_archives]" value="<?php echo NO;?>"<?php echo $checkedN;?>><label for="unzip_no"><?php echo NO;?></label>
</div>
</div>
</div>
</div>
<?php
<?php
}
}
?>
?>
<br />
<br />
<strong><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_QUICKBLOG; ?>:</strong><br />
<strong><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_QUICKBLOG; ?>:</strong><br />
<em><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_QUICKBLOG_DESC; ?></em>
<em><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_QUICKBLOG_DESC; ?></em>
<table id="quickblog_table" style="width: 50%">
<table id="quickblog_table" style="width: 50%">
<tr>
<tr>
<td nowrap="nowrap"><?php echo TITLE; ?></td>
<td nowrap="nowrap"><?php echo TITLE; ?></td>
<td><input class="input_textbox" name="serendipity[quickblog][title]" type="text" style="width: 90%" /></td>
<td><input class="input_textbox" name="serendipity[quickblog][title]" type="text" style="width: 90%" /></td>
</tr>
</tr>
<tr>
<tr>
<td nowrap="nowrap"><?php echo ENTRY_BODY; ?></td>
<td nowrap="nowrap"><?php echo ENTRY_BODY; ?></td>
<td><textarea name="serendipity[quickblog][body]" style="width: 90%; height: 200px"></textarea></td>
<td><textarea name="serendipity[quickblog][body]" style="width: 90%; height: 200px"></textarea></td>
</tr>
</tr>
<tr>
<tr>
<td nowrap="nowrap"><?php echo CATEGORY; ?></td>
<td nowrap="nowrap"><?php echo CATEGORY; ?></td>
<td><select name="serendipity[quickblog][category]">
<td><select name="serendipity[quickblog][category]">
<option value=""><?php echo NO_CATEGORY; ?></option>
<option value=""><?php echo NO_CATEGORY; ?></option>
<?php
<?php
if (is_array($cats = serendipity_fetchCategories())) {
if (is_array($cats = serendipity_fetchCategories())) {
$cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED);
$cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED);
foreach ($cats as $cat) {
foreach ($cats as $cat) {
echo '<option value="'. $cat['categoryid'] .'">'. str_repeat('&nbsp;', $cat['depth']) . $cat['category_name'] .'</option>' . "\n";
echo '<option value="'. $cat['categoryid'] .'">'. str_repeat('&nbsp;', $cat['depth']) . $cat['category_name'] .'</option>' . "\n";
}
}
}
}
?>
?>
</select></td>
</select></td>
</tr>
</tr>
<tr>
<tr>
<td nowrap="nowrap"><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET; ?></td>
<td nowrap="nowrap"><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET; ?></td>
<td><select id="select_image_target" name="serendipity[quickblog][target]">
<td><select id="select_image_target" name="serendipity[quickblog][target]">
<option value="none"<?php echo serendipity_ifRemember('target', 'none', false, 'selected'); ?>><?php echo NONE; ?></option>
<option value="none"<?php echo serendipity_ifRemember('target', 'none', false, 'selected'); ?>><?php echo NONE; ?></option>
<option value="js"<?php echo serendipity_ifRemember('target', 'js', false, 'selected'); ?>><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET_JS; ?></option>
<option value="js"<?php echo serendipity_ifRemember('target', 'js', false, 'selected'); ?>><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET_JS; ?></option>
<option value="plugin"<?php echo serendipity_ifRemember('target', 'plugin', false, 'selected'); ?>><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET_ENTRY; ?></option>
<option value="plugin"<?php echo serendipity_ifRemember('target', 'plugin', false, 'selected'); ?>><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET_ENTRY; ?></option>
<option value="_blank"<?php echo serendipity_ifRemember('target', '_blank', false, 'selected'); ?>><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET_BLANK; ?></option>
<option value="_blank"<?php echo serendipity_ifRemember('target', '_blank', false, 'selected'); ?>><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET_BLANK; ?></option>
</select></td>
</select></td>
</tr>
</tr>
<tr>
<tr>
<td nowrap="nowrap"><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_ASOBJECT; ?></td>
<td nowrap="nowrap"><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_ASOBJECT; ?></td>
<td>
<td>
<input type="radio" class="input_radio" id="image_yes" name="serendipity[quickblog][isobject]" value="<?php echo YES;?>"><label for="image_yes"><?php echo YES;?></label>
<input type="radio" class="input_radio" id="image_yes" name="serendipity[quickblog][isobject]" value="<?php echo YES;?>"><label for="image_yes"><?php echo YES;?></label>
<input type="radio" class="input_radio" id="image_no" name="serendipity[quickblog][isobject]" value="<?php echo NO;?>" checked="checked"><label for="image_no"><?php echo NO;?></label>
<input type="radio" class="input_radio" id="image_no" name="serendipity[quickblog][isobject]" value="<?php echo NO;?>" checked="checked"><label for="image_no"><?php echo NO;?></label>
</td>
</td>
</tr>
</tr>
<tr>
<tr>
<td nowrap="nowrap"><?php echo IMAGE_SIZE; ?></td>
<td nowrap="nowrap"><?php echo IMAGE_SIZE; ?></td>
<td><input class="input_textbox" name="serendipity[quickblog][size]" value="<?php echo $serendipity['thumbSize']; ?>" type="text" style="width: 50px" /></td>
<td><input class="input_textbox" name="serendipity[quickblog][size]" value="<?php echo $serendipity['thumbSize']; ?>" type="text" style="width: 50px" /></td>
</tr>
</tr>
<tr>
<tr>
<td align="center" colspan="2"><br /></td>
<td align="center" colspan="2"><br /></td>
</tr>
</tr>
</table>
</table>
<div>
<div>
<em><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_IMAGE_SIZE_DESC; ?></em>
<em><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_IMAGE_SIZE_DESC; ?></em>
</div>
</div>
<?php
<?php
} else {
} else {
?>
?>
<div id="imageselectorplus">
<div id="imageselectorplus">
<?php
<?php
if (class_exists('ZipArchive')) {
if (class_exists('ZipArchive')) {
$checkedY = "";
$checkedY = "";
$checkedN = "";
$checkedN = "";
$this->get_config('unzipping') ? $checkedY = ' checked="checked"' : $checkedN = ' checked="checked"';
$this->get_config('unzipping') ? $checkedY = ' checked="checked"' : $checkedN = ' checked="checked"';
?>
?>
<div class="clearfix radio_field">
<div class="clearfix radio_field">
<h4><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES;?></h4>
<h4><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES;?></h4>
<?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES_DESC;?>
<?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES_DESC;?>
<div>
<div>
<input type="radio" class="input_radio" id="unzip_yes" name="serendipity[unzip_archives]" value="<?php echo YES;?>"<?php echo $checkedY;?>><label for="unzip_yes"><?php echo YES;?></label>
<input type="radio" class="input_radio" id="unzip_yes" name="serendipity[unzip_archives]" value="<?php echo YES;?>"<?php echo $checkedY;?>><label for="unzip_yes"><?php echo YES;?></label>
<input type="radio" class="input_radio" id="unzip_no" name="serendipity[unzip_archives]" value="<?php echo NO;?>"<?php echo $checkedN;?>><label for="unzip_no"><?php echo NO;?></label>
<input type="radio" class="input_radio" id="unzip_no" name="serendipity[unzip_archives]" value="<?php echo NO;?>"<?php echo $checkedN;?>><label for="unzip_no"><?php echo NO;?></label>
</div>
</div>
</div>
</div>
<?php
<?php
}
}
?>
?>
<h4><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_QUICKBLOG; ?>:</h4>
<h4><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_QUICKBLOG; ?>:</h4>
<em><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_QUICKBLOG_DESC; ?></em>
<em><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_QUICKBLOG_DESC; ?></em>
<div id="quickblog_tablefield" class="clearfix">
<div id="quickblog_tablefield" class="clearfix">
<div class="quickblog_form_field">
<div class="quickblog_form_field">
<label for="quickblog_titel"><?php echo TITLE; ?></label>
<label for="quickblog_titel"><?php echo TITLE; ?></label>
<input id="quickblog_title" class="input_textbox" name="serendipity[quickblog][title]" type="text">
<input id="quickblog_title" class="input_textbox" name="serendipity[quickblog][title]" type="text">
</div>
</div>
<div class="quickblog_textarea_field">
<div class="quickblog_textarea_field">
<label for="nuggets2"><?php echo ENTRY_BODY; ?></label>
<label for="nuggets2"><?php echo ENTRY_BODY; ?></label>
<textarea id="nuggets2" class="quickblog_nugget" data-tarea="nuggets2" data-tarea-tbar="min" name="serendipity[quickblog][body]" rows="10" cols="80"></textarea>
<textarea id="nuggets2" class="quickblog_nugget" data-tarea="nuggets2" data-tarea-tbar="min" name="serendipity[quickblog][body]" rows="10" cols="80"></textarea>
<?php
<?php
if ($serendipity['wysiwyg']) {
if ($serendipity['wysiwyg']) {
$plugins = serendipity_plugin_api::enum_plugins('*', false, 'serendipity_event_nl2br');
$plugins = serendipity_plugin_api::enum_plugins('*', false, 'serendipity_event_nl2br');
?>
?>
<input name="serendipity[properties][disable_markups][]" type="hidden" value="<?php echo $plugins[0]['name']; ?>">
<input name="serendipity[properties][disable_markups][]" type="hidden" value="<?php echo $plugins[0]['name']; ?>">
<?php
<?php
if (!class_exists('serendipity_event_ckeditor')) {
if (!class_exists('serendipity_event_ckeditor')) {
?>
?>
<script src="<?php echo $serendipity['serendipityHTTPPath']; ?>htmlarea/ckeditor/ckeditor/ckeditor.js"></script>
<script src="<?php echo $serendipity['serendipityHTTPPath']; ?>htmlarea/ckeditor/ckeditor/ckeditor.js"></script>
<?php
<?php
}
}
?>
?>
<script>
<script>
CKEDITOR.replace( 'nuggets2',
CKEDITOR.replace( 'nuggets2',
{
{
toolbar : [['Bold','Italic','Underline','Superscript','-','NumberedList','BulletedList','Outdent','Blockquote','-','Format',],['JustifyLeft','JustifyCenter','JustifyRight',],['Link','Unlink','Source']],
toolbar : [['Bold','Italic','Underline','Superscript','-','NumberedList','BulletedList','Outdent','Blockquote','-','Format',],['JustifyLeft','JustifyCenter','JustifyRight',],['Link','Unlink','Source']],
toolbarGroups: null
toolbarGroups: null
});
});
</script>
</script>
<?php
<?php
}
}
?>
?>
</div>
</div>
<div class="quickblog_form_field">
<div class="quickblog_form_field">
<label for="quickblog_select"><?php echo CATEGORY; ?></label>
<label for="quickblog_select"><?php echo CATEGORY; ?></label>
<select id="quickblog_select" name="serendipity[quickblog][category]">
<select id="quickblog_select" name="serendipity[quickblog][category]">
<option value=""><?php echo NO_CATEGORY; ?></option>
<option value=""><?php echo NO_CATEGORY; ?></option>
<?php
<?php
if (is_array($cats = serendipity_fetchCategories())) {
if (is_array($cats = serendipity_fetchCategories())) {
$cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED);
$cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED);
foreach ($cats as $cat) {
foreach ($cats as $cat) {
echo '<option value="'. $cat['categoryid'] .'">'. str_repeat('&nbsp;', $cat['depth']) . $cat['category_name'] .'</option>' . "\n";
echo '<option value="'. $cat['categoryid'] .'">'. str_repeat('&nbsp;', $cat['depth']) . $cat['category_name'] .'</option>' . "\n";
}
}
}
}
?>
?>
</select>
</select>
</div>
</div>
<div class="quickblog_form_select">
<div class="quickblog_form_select">
<label for="select_image_target"><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET; ?></label>
<label for="select_image_target"><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET; ?></label>
<select id="select_image_target" name="serendipity[quickblog][target]">
<select id="select_image_target" name="serendipity[quickblog][target]">
<option value="none"<?php echo serendipity_ifRemember('target', 'none', false, 'selected'); ?>><?php echo NONE; ?></option>
<option value="none"<?php echo serendipity_ifRemember('target', 'none', false, 'selected'); ?>><?php echo NONE; ?></option>
<option value="js"<?php echo serendipity_ifRemember('target', 'js', false, 'selected'); ?>><?php echo MEDIA_TARGET_JS; ?></option>
<option value="js"<?php echo serendipity_ifRemember('target', 'js', false, 'selected'); ?>><?php echo MEDIA_TARGET_JS; ?></option>
<option value="plugin"<?php echo serendipity_ifRemember('target', 'plugin', false, 'selected'); ?>><?php echo MEDIA_ENTRY; ?></option>
<option value="plugin"<?php echo serendipity_ifRemember('target', 'plugin', false, 'selected'); ?>><?php echo MEDIA_ENTRY; ?></option>
<option value="_blank"<?php echo serendipity_ifRemember('target', '_blank', false, 'selected'); ?>><?php echo MEDIA_TARGET_BLANK; ?></option>
<option value="_blank"<?php echo serendipity_ifRemember('target', '_blank', false, 'selected'); ?>><?php echo MEDIA_TARGET_BLANK; ?></option>
</select>
</select>
</div>
</div>
<div class="clearfix radio_field quickblog_radio_field">
<div class="clearfix radio_field quickblog_radio_field">
<label><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_ASOBJECT; ?></label>
<label><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_ASOBJECT; ?></label>
<div>
<div>
<input type="radio" class="input_radio" id="image_yes" name="serendipity[quickblog][isobject]" value="<?php echo YES;?>"><label for="image_yes"><?php echo YES;?></label>
<input type="radio" class="input_radio" id="image_yes" name="serendipity[quickblog][isobject]" value="<?php echo YES;?>"><label for="image_yes"><?php echo YES;?></label>
<input type="radio" class="input_radio" id="image_no" name="serendipity[quickblog][isobject]" value="<?php echo NO;?>" checked="checked"><label for="image_no"><?php echo NO;?></label>
<input type="radio" class="input_radio" id="image_no" name="serendipity[quickblog][isobject]" value="<?php echo NO;?>" checked="checked"><label for="image_no"><?php echo NO;?></label>
</div>
</div>
</div>
</div>
<div class="quickblog_form_field">
<div class="quickblog_form_field">
<label for="quickblog_isize"><?php echo IMAGE_SIZE; ?></label>
<label for="quickblog_isize"><?php echo IMAGE_SIZE; ?></label>
<input id="quickblog_isize" class="input_textbox" name="serendipity[quickblog][size]" value="<?php echo $serendipity['thumbSize']; ?>" type="text">
<input id="quickblog_isize" class="input_textbox" name="serendipity[quickblog][size]" value="<?php echo $serendipity['thumbSize']; ?>" type="text">
</div>
</div>
</div>
</div>
<em><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_IMAGE_SIZE_DESC; ?></em>
<em><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_IMAGE_SIZE_DESC; ?></em>
</div>
</div>
<?php
<?php
}
}
break;
break;
case 'backend_image_add':
case 'backend_image_add':
global $new_media;
global $new_media;
// if file is zip archive and unzipping enabled
// if file is zip archive and unzipping enabled
// unzip file and add all images to database
// unzip file and add all images to database
// retrieve file type
// retrieve file type
$target_zip = $eventData;
$target_zip = $eventData;
preg_match('@(^.*/)+(.*)\.+(\w*)@',$target_zip,$matches);
preg_match('@(^.*/)+(.*)\.+(\w*)@',$target_zip,$matches);
$target_dir = $matches[1];
$target_dir = $matches[1];
$basename = $matches[2];
$basename = $matches[2];
$extension = $matches[3];
$extension = $matches[3];
$authorid = (isset($serendipity['POST']['all_authors']) && $serendipity['POST']['all_authors'] == 'true') ? '0' : $serendipity['authorid'];
$authorid = (isset($serendipity['POST']['all_authors']) && $serendipity['POST']['all_authors'] == 'true') ? '0' : $serendipity['authorid'];
// only if unzipping function exists, we have archive file and unzipping set to yes
// only if unzipping function exists, we have archive file and unzipping set to yes
if ((class_exists('ZipArchive')) && ($extension == 'zip') && ($serendipity['POST']['unzip_archives'] == YES)) {
if ((class_exists('ZipArchive')) && ($extension == 'zip') && ($serendipity['POST']['unzip_archives'] == YES)) {
// now unzip
// now unzip
$zip = new ZipArchive;
$zip = new ZipArchive;
$res = $zip->open($target_zip);
$res = $zip->open($target_zip);
if ($res === TRUE) {
if ($res === TRUE) {
$files_to_unzip = array();
$files_to_unzip = array();
$extracted_images = array();
$extracted_images = array();
for($i=0; $i < $zip->numFiles; $i++) {
for($i=0; $i < $zip->numFiles; $i++) {
$file_to_extract = $zip->getNameIndex($i);
$file_to_extract = $zip->getNameIndex($i);
if (file_exists($target_dir.$file_to_extract)) {
if (file_exists($target_dir.$file_to_extract)) {
echo '(' . $file_to_extract . ') ' . ERROR_FILE_EXISTS_ALREADY . '<br />';
echo '(' . $file_to_extract . ') ' . ERROR_FILE_EXISTS_ALREADY . '<br />';
} else {
} else {
$files_to_unzip[] = $file_to_extract;
$files_to_unzip[] = $file_to_extract;
$extracted_images[] = $target_dir.$file_to_extract;
$extracted_images[] = $target_dir.$file_to_extract;
}
}
}
}
$zip->extractTo($target_dir,$files_to_unzip);
$zip->extractTo($target_dir,$files_to_unzip);
$zip->close();
$zip->close();
echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_OK;
echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_OK;
} else {
} else {
echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FAILED;
echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FAILED;
}
}
// now proceed all unzipped images
// now proceed all unzipped images
foreach ($extracted_images as $target) {
foreach ($extracted_images as $target) {
preg_match('@(^.*/)+(.*)\.+(\w*)@',$target,$matches);
preg_match('@(^.*/)+(.*)\.+(\w*)@',$target,$matches);
$real_dir = $matches[1];
$real_dir = $matches[1];
$basename = $matches[2];
$basename = $matches[2];
$extension = $matches[3];
$extension = $matches[3];
$tfile = $basename.".".$extension;
$tfile = $basename.".".$extension;
preg_match('@'.$serendipity['uploadPath'].'(.*/)@',$target,$matches);
preg_match('@'.$serendipity['uploadPath'].'(.*/)@',$target,$matches);
$image_directory = $matches[1];
$image_directory = $matches[1];
// make thumbnails for new images
// make thumbnails for new images
$thumbs = array(array(
$thumbs = array(array(
'thumbSize' => $serendipity['thumbSize'],
'thumbSize' => $serendipity['thumbSize'],
'thumb' => $serendipity['thumbSuffix']
'thumb' => $serendipity['thumbSuffix']
));
));
serendipity_plugin_api::hook_event('backend_media_makethumb', $thumbs);
serendipity_plugin_api::hook_event('backend_media_makethumb', $thumbs);
foreach($thumbs as $thumb) {
foreach($thumbs as $thumb) {
// Create thumbnail
// Create thumbnail
if ( $created_thumbnail = serendipity_makeThumbnail($tfile, $image_directory, $thumb['thumbSize'], $thumb['thumb']) ) {
if ( $created_thumbnail = serendipity_makeThumbnail($tfile, $image_directory, $thumb['thumbSize'], $thumb['thumb']) ) {
echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_IMAGE_FROM_ARCHIVE . " - " . THUMB_CREATED_DONE . '<br />';
echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_IMAGE_FROM_ARCHIVE . " - " . THUMB_CREATED_DONE . '<br />';
}
}
}
}
// Insert into database
// Insert into database
$image_id = serendipity_insertImageInDatabase($tfile, $image_directory, $authorid, null, $realname);
$image_id = serendipity_insertImageInDatabase($tfile, $image_directory, $authorid, null, $realname);
echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_IMAGE_FROM_ARCHIVE." ($tfile) ".PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_ADD_TO_DB."<br />";
echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_IMAGE_FROM_ARCHIVE." ($tfile) ".PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_ADD_TO_DB."<br />";
$new_media[] = array(
$new_media[] = array(
'image_id' => $image_id,
'image_id' => $image_id,
'target' => $target,
'target' => $target,
'created_thumbnail' => $created_thumbnail
'created_thumbnail' => $created_thumbnail
);
);
}
}
}
}
case 'backend_image_addHotlink':
case 'backend_image_addHotlink':
// Re-Scale thumbnails?
// Re-Scale thumbnails?
$max_scale = array(
$max_scale = array(
'width' => (int)$this->get_config('thumb_max_width'),
'width' => (int)$this->get_config('thumb_max_width'),
'height' => (int)$this->get_config('thumb_max_height')
'height' => (int)$this->get_config('thumb_max_height')