/** * Show the list of plugins * * Shows a HTML list of all installed plugins, complete with config/delete/sort order options * * @access public * @param boolean Indicates if event plugins (TRUE) or sidebar plugins (FALSE) shall be shown * @return null */ function show_plugins($event_only = false, $sidebars = null) { global $serendipity; $sql_filter = ''; if (is_array($sidebars)) { foreach ($sidebars as $sidebar) { $up = strtoupper($sidebar); if ($sidebar == 'hide') { $opts[$sidebar] = HIDDEN; } elseif (defined('SIDEBAR_' . $up)) { $opts[$sidebar] = constant('SIDEBAR_' . $up); } elseif (defined($up)) { $opts[$sidebar] = constant($up); } else { $opts[$sidebar] = $up; } $sql_filter .= "AND placement != '" . serendipity_db_escape_string($sidebar) . "' "; } } if (!$event_only) { $sql = "SELECT * from {$serendipity['dbPrefix']}plugins\n WHERE placement != 'event'\n AND placement != 'eventh'\n " . $sql_filter; $invisible_plugins = serendipity_db_query($sql); if (is_array($invisible_plugins)) { $sidebars[] = 'NONE'; $opts['NONE'] = NONE; } } $opts['event'] = PLUGIN_ACTIVE; $opts['eventh'] = PLUGIN_INACTIVE; $data['event_only'] = $event_only; if (!$event_only) { $data['is_first'] = true; } $data['serendipity_setFormToken'] = serendipity_setFormToken(); $data['serendipity_setFormTokenUrl'] = serendipity_setFormToken('url'); /* Block display the plugins per placement location. */ if ($event_only) { $plugin_placements = array('event', 'eventh'); } else { $plugin_placements = $sidebars; } $data['plugin_placements'] = $plugin_placements; static $users = array(); if (empty($users)) { $users = serendipity_fetchUsers('', 'hidden'); } $data['users'] = $users; $i = 0; foreach ($plugin_placements as $plugin_placement) { if (!$event_only && $plugin_placement == 'NONE') { $is_invisible = true; } else { $is_invisible = false; } $data['placement'][$plugin_placement]['ptitle'] = $ptitle = $opts[$plugin_placement]; $data['placement'][$plugin_placement]['pid'] = $pid = $plugin_placement; if ($is_invisible) { $plugins = $invisible_plugins; } else { $plugins = serendipity_plugin_api::enum_plugins($plugin_placement); } if (!is_array($plugins)) { continue; } $sort_idx = 0; foreach ($plugins as $plugin_data) { $i++; $plugin =& serendipity_plugin_api::load_plugin($plugin_data['name'], $plugin_data['authorid']); $key = urlencode($plugin_data['name']); $css_key = 's9ycid' . str_replace('%', '-', $key); $is_plugin_owner = $plugin_data['authorid'] == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers'); $is_plugin_editable = $is_plugin_owner || $plugin_data['authorid'] == '0'; $cname = explode(':', $plugin_data['name']); if (!is_object($plugin)) { $name = $title = ERROR . '!'; $desc = ERROR . ': ' . $plugin_data['name']; $can_configure = false; } else { /* query for its name, description and configuration data */ $bag = new serendipity_property_bag(); $plugin->introspect($bag); $name = serendipity_specialchars($bag->get('name')); $desc = '<details class="plugin_data">'; $desc .= '<summary><var class="perm_name">' . $cname[0] . '</var></summary>'; $desc .= '<div class="plugin_desc clearfix">' . serendipity_specialchars($bag->get('description')) . '</div>'; $desc .= '<span class="block_level">' . VERSION . ': ' . $bag->get('version') . '</span>'; $desc .= '</details>'; $title = serendipity_plugin_api::get_plugin_title($plugin, '[' . $name . ']'); if ($bag->is_set('configuration') && ($plugin->protected === FALSE || $plugin_data['authorid'] == '0' || $plugin_data['authorid'] == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers'))) { $can_configure = true; } else { $can_configure = false; } } if ($opts === null) { $opts = array('left' => LEFT, 'right' => RIGHT, 'hide' => HIDDEN); } $event_opts = array('event' => PLUGIN_ACTIVE, 'eventh' => PLUGIN_INACTIVE); if ($event_only) { $gopts = $event_opts; } else { $gopts = $opts; } $data['placement'][$plugin_placement]['plugin_data'][$i]['sort_idx'] = $sort_idx; $data['placement'][$plugin_placement]['plugin_data'][$i]['css_key'] = $css_key; $data['placement'][$plugin_placement]['plugin_data'][$i]['is_plugin_editable'] = $is_plugin_editable; $data['placement'][$plugin_placement]['plugin_data'][$i]['is_plugin_owner'] = $is_plugin_owner; $data['placement'][$plugin_placement]['plugin_data'][$i]['name'] = $plugin_data['name']; $data['placement'][$plugin_placement]['plugin_data'][$i]['authorid'] = $plugin_data['authorid']; $data['placement'][$plugin_placement]['plugin_data'][$i]['can_configure'] = $can_configure; $data['placement'][$plugin_placement]['plugin_data'][$i]['key'] = $key; $data['placement'][$plugin_placement]['plugin_data'][$i]['title'] = $title; $data['placement'][$plugin_placement]['plugin_data'][$i]['desc'] = $desc; $data['placement'][$plugin_placement]['plugin_data'][$i]['placement'] = $plugin_data['placement']; $data['placement'][$plugin_placement]['plugin_data'][$i]['gopts'] = $gopts; $sort_idx++; } } $data['total'] = $i; return serendipity_smarty_show('admin/show_plugins.fnc.tpl', $data); }
/** * Prepares a cache of all event plugins and load them in queue so that they can be fetched * * @access public * @param mixed If set to a string, a certain event plugin cache object will be returned by this function * @param boolean If set to true, the list of cached event plugins will be refreshed * @return mixed Either returns the whole list of event plugins, or only a specific instance */ function &get_event_plugins($getInstance = false, $refresh = false) { static $event_plugins; static $false = false; if (!$refresh && isset($event_plugins) && is_array($event_plugins)) { if ($getInstance) { if (isset($event_plugins[$getInstance]['p'])) { return $event_plugins[$getInstance]['p']; } return $false; } return $event_plugins; } $plugins = serendipity_plugin_api::enum_plugins('event'); if (!is_array($plugins)) { return $false; } $event_plugins = array(); foreach ($plugins as $plugin_data) { if ($event_plugins[$plugin_data['name']]['p'] =& serendipity_plugin_api::load_plugin($plugin_data['name'], $plugin_data['authorid'], $plugin_data['path'])) { /* query for its name, description and configuration data */ $event_plugins[$plugin_data['name']]['b'] = new serendipity_property_bag(); $event_plugins[$plugin_data['name']]['p']->introspect($event_plugins[$plugin_data['name']]['b']); $event_plugins[$plugin_data['name']]['t'] = serendipity_plugin_api::get_plugin_title($event_plugins[$plugin_data['name']]['p']); } else { unset($event_plugins[$plugin_data['name']]); // Unset failed plugins } } if ($getInstance) { if (isset($event_plugins[$getInstance]['p'])) { return $event_plugins[$getInstance]['p']; } return $false; } return $event_plugins; }
# All rights reserved. See LICENSE file for licensing details if (IN_serendipity !== true) { die('Don\'t hack!'); } if (!serendipity_checkPermission('adminPlugins')) { return; } include_once S9Y_INCLUDE_PATH . 'include/plugin_api.inc.php'; include_once S9Y_INCLUDE_PATH . 'include/plugin_internal.inc.php'; include_once S9Y_INCLUDE_PATH . 'include/functions_entries_admin.inc.php'; include_once S9Y_INCLUDE_PATH . 'include/functions_plugins_admin.inc.php'; if (isset($_GET['serendipity']['plugin_to_move']) && isset($_GET['submit']) && serendipity_checkFormToken()) { if (isset($_GET['serendipity']['event_plugin'])) { $plugins = serendipity_plugin_api::enum_plugins('event', false); } else { $plugins = serendipity_plugin_api::enum_plugins('event', true); } /* Renumber the sort order to be certain that one actually exists Also look for the one we're going to move */ $idx_to_move = -1; for ($idx = 0; $idx < count($plugins); $idx++) { $plugins[$idx]['sort_order'] = $idx; if ($plugins[$idx]['name'] == $_GET['serendipity']['plugin_to_move']) { $idx_to_move = $idx; } } /* If idx_to_move is still -1 then we never found it (shouldn't happen under normal conditions) Also make sure the swaping idx is around */ if ($idx_to_move >= 0 && ($_GET['submit'] == 'move down' && $idx_to_move < count($plugins) - 1 || $_GET['submit'] == 'move up' && $idx_to_move > 0)) { /* Swap the one were moving with the one that's in the spot we're moving to */ $tmp = $plugins[$idx_to_move]['sort_order'];
/** * check if sidebar plugin is available for install */ function sb_plugin_status() { $plugins = serendipity_plugin_api::enum_plugins('*', false, 'serendipity_plugin_staticpage'); if (is_array($plugins) && !empty($plugins[0]['name'])) { return true; } return false; }
function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; $hooks =& $bag->get('event_hooks'); if (isset($hooks[$event])) { switch ($event) { case 'backend_image_addform': if ($serendipity['version'][0] < 2) { if (class_exists('ZipArchive')) { $checkedY = ""; $checkedN = ""; $this->get_config('unzipping') ? $checkedY = ' checked="checked"' : ($checkedN = ' checked="checked"'); ?> <br /> <div> <strong><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES; ?> </strong><br /> <?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES_DESC; ?> <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_no" name="serendipity[unzip_archives]" value="<?php echo NO; ?> "<?php echo $checkedN; ?> ><label for="unzip_no"><?php echo NO; ?> </label> </div> </div> <?php } ?> <br /> <strong><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_QUICKBLOG; ?> :</strong><br /> <em><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_QUICKBLOG_DESC; ?> </em> <table id="quickblog_table" style="width: 50%"> <tr> <td nowrap="nowrap"><?php echo TITLE; ?> </td> <td><input class="input_textbox" name="serendipity[quickblog][title]" type="text" style="width: 90%" /></td> </tr> <tr> <td nowrap="nowrap"><?php echo ENTRY_BODY; ?> </td> <td><textarea name="serendipity[quickblog][body]" style="width: 90%; height: 200px"></textarea></td> </tr> <tr> <td nowrap="nowrap"><?php echo CATEGORY; ?> </td> <td><select name="serendipity[quickblog][category]"> <option value=""><?php echo NO_CATEGORY; ?> </option> <?php if (is_array($cats = serendipity_fetchCategories())) { $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED); foreach ($cats as $cat) { echo '<option value="' . $cat['categoryid'] . '">' . str_repeat(' ', $cat['depth']) . $cat['category_name'] . '</option>' . "\n"; } } ?> </select></td> </tr> <tr> <td nowrap="nowrap"><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET; ?> </td> <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="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="_blank"<?php echo serendipity_ifRemember('target', '_blank', false, 'selected'); ?> ><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET_BLANK; ?> </option> </select></td> </tr> <tr> <td nowrap="nowrap"><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_ASOBJECT; ?> </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_no" name="serendipity[quickblog][isobject]" value="<?php echo NO; ?> " checked="checked"><label for="image_no"><?php echo NO; ?> </label> </td> </tr> <tr> <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> </tr> <tr> <td align="center" colspan="2"><br /></td> </tr> </table> <div> <em><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_IMAGE_SIZE_DESC; ?> </em> </div> <?php } else { ?> <div id="imageselectorplus"> <?php if (class_exists('ZipArchive')) { $checkedY = ""; $checkedN = ""; $this->get_config('unzipping') ? $checkedY = ' checked="checked"' : ($checkedN = ' checked="checked"'); ?> <div class="clearfix radio_field"> <h4><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES; ?> </h4> <?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES_DESC; ?> <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_no" name="serendipity[unzip_archives]" value="<?php echo NO; ?> "<?php echo $checkedN; ?> ><label for="unzip_no"><?php echo NO; ?> </label> </div> </div> <?php } ?> <h4><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_QUICKBLOG; ?> :</h4> <em><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_QUICKBLOG_DESC; ?> </em> <div id="quickblog_tablefield" class="clearfix"> <div class="quickblog_form_field"> <label for="quickblog_titel"><?php echo TITLE; ?> </label> <input id="quickblog_title" class="input_textbox" name="serendipity[quickblog][title]" type="text"> </div> <div class="quickblog_textarea_field"> <label for="nuggets2"><?php echo ENTRY_BODY; ?> </label> <textarea id="nuggets2" class="quickblog_nugget" data-tarea="nuggets2" name="serendipity[quickblog][body]" rows="10" cols="80"></textarea> <?php if ($serendipity['wysiwyg']) { $plugins = serendipity_plugin_api::enum_plugins('*', false, 'serendipity_event_nl2br'); ?> <input name="serendipity[properties][disable_markups][]" type="hidden" value="<?php echo $plugins[0]['name']; ?> "> <?php if (!class_exists('serendipity_event_ckeditor')) { ?> <script src="<?php echo $serendipity['serendipityHTTPPath']; ?> htmlarea/ckeditor/ckeditor/ckeditor.js"></script> <?php } // just add a simple basic toolbar, since we cannot use embedded plugins here ?> <script> CKEDITOR.replace( 'nuggets2', { toolbar : [['Format'],['Bold','Italic','Underline','Superscript','-','NumberedList','BulletedList','Outdent','Blockquote'],['JustifyBlock','JustifyCenter','JustifyRight'],['Link','Unlink'],['Source']], toolbarGroups: null }); </script> <?php } ?> </div> <div class="quickblog_form_field"> <label for="quickblog_select"><?php echo CATEGORY; ?> </label> <select id="quickblog_select" name="serendipity[quickblog][category]"> <option value=""><?php echo NO_CATEGORY; ?> </option> <?php if (is_array($cats = serendipity_fetchCategories())) { $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED); foreach ($cats as $cat) { echo '<option value="' . $cat['categoryid'] . '">' . str_repeat(' ', $cat['depth']) . $cat['category_name'] . '</option>' . "\n"; } } ?> </select> </div> <div class="quickblog_form_select"> <label for="select_image_target"><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET; ?> </label> <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="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="_blank"<?php echo serendipity_ifRemember('target', '_blank', false, 'selected'); ?> ><?php echo MEDIA_TARGET_BLANK; ?> </option> </select> </div> <div class="clearfix radio_field quickblog_radio_field"> <label><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_ASOBJECT; ?> </label> <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_no" name="serendipity[quickblog][isobject]" value="<?php echo NO; ?> " checked="checked"><label for="image_no"><?php echo NO; ?> </label> </div> </div> <div class="quickblog_form_field"> <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"> </div> </div> <em><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_IMAGE_SIZE_DESC; ?> </em> </div> <?php } break; case 'backend_image_add': global $new_media; // if file is zip archive and unzipping enabled // unzip file and add all images to database // retrieve file type $target_zip = $eventData; preg_match('@(^.*/)+(.*)\\.+(\\w*)@', $target_zip, $matches); $target_dir = $matches[1]; $basename = $matches[2]; $extension = $matches[3]; $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 if (class_exists('ZipArchive') && $extension == 'zip' && $serendipity['POST']['unzip_archives'] == YES) { // now unzip $zip = new ZipArchive(); $res = $zip->open($target_zip); if ($res === TRUE) { $files_to_unzip = array(); $extracted_images = array(); for ($i = 0; $i < $zip->numFiles; $i++) { $file_to_extract = $zip->getNameIndex($i); if (file_exists($target_dir . $file_to_extract)) { echo '(' . $file_to_extract . ') ' . ERROR_FILE_EXISTS_ALREADY . '<br />'; } else { $files_to_unzip[] = $file_to_extract; $extracted_images[] = $target_dir . $file_to_extract; } } $zip->extractTo($target_dir, $files_to_unzip); $zip->close(); echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_OK; } else { echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FAILED; } // now proceed all unzipped images foreach ($extracted_images as $target) { preg_match('@(^.*/)+(.*)\\.+(\\w*)@', $target, $matches); $real_dir = $matches[1]; $basename = $matches[2]; $extension = $matches[3]; $tfile = $basename . "." . $extension; preg_match('@' . $serendipity['uploadPath'] . '(.*/)@', $target, $matches); $image_directory = $matches[1]; // make thumbnails for new images $thumbs = array(array('thumbSize' => $serendipity['thumbSize'], 'thumb' => $serendipity['thumbSuffix'])); serendipity_plugin_api::hook_event('backend_media_makethumb', $thumbs); foreach ($thumbs as $thumb) { // Create thumbnail if ($created_thumbnail = serendipity_makeThumbnail($tfile, $image_directory, $thumb['thumbSize'], $thumb['thumb'])) { echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_IMAGE_FROM_ARCHIVE . " - " . THUMB_CREATED_DONE . '<br />'; } } // Insert into database $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 />"; $new_media[] = array('image_id' => $image_id, 'target' => $target, 'created_thumbnail' => $created_thumbnail); } } case 'backend_image_addHotlink': // Re-Scale thumbnails? $max_scale = array('width' => (int) $this->get_config('thumb_max_width'), 'height' => (int) $this->get_config('thumb_max_height')); if ($max_scale['width'] > 0 || $max_scale['height'] > 0) { $this->resizeThumb($max_scale, $eventData); } if (empty($serendipity['POST']['quickblog']['title'])) { break; } $file = basename($eventData); $directory = str_replace($serendipity['serendipityPath'] . $serendipity['uploadPath'], '', dirname($eventData) . '/'); $size = (int) $serendipity['POST']['quickblog']['size']; // check default Serendipity thumbSize, to make this happen like standard image uploads, and to get one "fullsize" image instance only, // else create another quickblog image "resized" instance, to use as entries thumbnail image if ($serendipity['thumbSize'] != $size) { $oldSuffix = $serendipity['thumbSuffix']; $serendipity['thumbSuffix'] = 'quickblog'; serendipity_makeThumbnail($file, $directory, $size); $serendipity['thumbSuffix'] = $oldSuffix; } // Non-image object link generation if ($serendipity['POST']['quickblog']['isobject'] == YES) { $objfile = serendipity_parseFileName($file); $filename = $objfile[0]; $suffix = $objfile[1]; $obj_mime = serendipity_guessMime($suffix); $objpath = $serendipity['serendipityHTTPPath'] . $serendipity['uploadPath'] . $directory . $filename . '.' . $suffix; // try to know about a working environment for imagemagicks pdf preview generation if ($serendipity['magick'] === true && strtolower($suffix) == 'pdf' && $serendipity['thumbSize'] == $size) { $objpreview = $serendipity['serendipityHTTPPath'] . $serendipity['uploadPath'] . $directory . $filename . '.' . $serendipity['thumbSuffix'] . '.' . $suffix . '.png'; } else { $objpreview = serendipity_getTemplateFile('admin/img/mime_' . preg_replace('@[^0-9a-z_\\-]@i', '-', $obj_mime) . '.png'); } if (!$objpreview || empty($objpreview)) { $objpreview = serendipity_getTemplateFile('admin/img/mime_unknown.png'); } } // New draft post $entry = array(); $entry['isdraft'] = 'false'; $entry['title'] = function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['quickblog']['title']) : htmlspecialchars($serendipity['POST']['quickblog']['title'], ENT_COMPAT, LANG_CHARSET); if (isset($objpath) && !empty($objpath)) { $entry['body'] = '<a href="' . $objpath . '"><img alt="" class="serendipity_image_left serendipity_quickblog_image" src="' . $objpreview . '">' . $filename . '</a> (-' . $obj_mime . '-)<p>' . $serendipity['POST']['quickblog']['body'] . '</p>'; } else { $entry['body'] = '<!--quickblog:' . $serendipity['POST']['quickblog']['target'] . '|' . $eventData . '-->' . $serendipity['POST']['quickblog']['body']; } $entry['authorid'] = $serendipity['authorid']; $entry['exflag'] = false; $entry['categories'][0] = function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['quickblog']['category']) : htmlspecialchars($serendipity['POST']['quickblog']['category'], ENT_COMPAT, LANG_CHARSET); #$entry['allow_comments'] = 'true'; // both disabled #$entry['moderate_comments'] = 'false'; // to take default values $serendipity['POST']['properties']['fake'] = 'fake'; $id = serendipity_updertEntry($entry); break; case 'frontend_display': // auto resizing images based on width and/or height attributes in img tag if (serendipity_db_bool($this->get_config('autoresize'))) { if (!empty($eventData['body'])) { $eventData['body'] = $this->substituteImages($eventData['body']); } if (!empty($eventData['extended'])) { $eventData['extended'] = $this->substituteImages($eventData['extended']); } } if (empty($eventData['body'])) { return; } // displaying quickblog posts if (is_object($serendipity['smarty']) && preg_match('@<!--quickblog:(.+)-->@imsU', $eventData['body'], $filematch)) { $eventData['body'] = $this->parse_quickblog_post($filematch[1], $eventData['body']); } // displaying galleries introduced by markup foreach ($this->markup_elements as $temp) { if (serendipity_db_bool($this->get_config($temp['name'], true)) && isset($eventData[$temp['element']]) && !$eventData['properties']['ep_disable_markup_' . $this->instance] && !isset($serendipity['POST']['properties']['disable_markup_' . $this->instance])) { $element = $temp['element']; $eventData[$element] = $this->media_insert($eventData[$element], $eventData); } } return true; break; case 'backend_entry_presave': if (is_numeric($eventData['id'])) { $eventData['body'] = str_replace('{{s9yisp_entryid}}', $eventData['id'], $eventData['body']); $eventData['extended'] = str_replace('{{s9yisp_entryid}}', $eventData['id'], $eventData['extended']); $this->gotMilk = true; } else { $this->cache['body'] = $eventData['body']; $this->cache['extended'] = $eventData['extended']; } break; case 'backend_publish': case 'backend_save': if ($this->gotMilk === false) { $old = md5($this->cache['body']) . md5($this->cache['extended']); $this->cache['body'] = str_replace('{{s9yisp_entryid}}', $eventData['id'], $this->cache['body']); $this->cache['extended'] = str_replace('{{s9yisp_entryid}}', $eventData['id'], $this->cache['extended']); $new = md5($this->cache['body']) . md5($this->cache['extended']); if ($old != $new) { serendipity_db_query("UPDATE {$serendipity['dbPrefix']}entries\n SET body = '" . serendipity_db_escape_string($this->cache['body']) . "',\n extended = '" . serendipity_db_escape_string($this->cache['extended']) . "'\n WHERE id = " . (int) $eventData['id']); } } break; case 'entry_display': if ($this->selected()) { if (is_array($eventData)) { $eventData['clean_page'] = true; // This is important to not display an entry list! } else { $eventData = array('clean_page' => true); } } break; case 'entries_header': if (!$this->selected()) { return true; } if ($serendipity['version'][0] > 1) { return true; } if (!headers_sent()) { header('HTTP/1.0 200'); header('Status: 200 OK'); } $entry = serendipity_fetchEntry('id', $serendipity['GET']['id']); $imageid = $serendipity['GET']['image']; $imgsrc = ''; if (preg_match('@<a title="([^"]+)" id="s9yisp' . $imageid . '"></a>@imsU', $entry['body'], $imgmatch)) { $imgsrc = $imgmatch[1]; } elseif (preg_match('@<a title="([^"]+)" id="s9yisp' . $imageid . '"></a>@imsU', $entry['extended'], $imgmatch)) { $imgsrc = $imgmatch[1]; } else { return; } $link = '<a href="' . serendipity_archiveURL($serendipity['GET']['id'], $entry['title'], 'baseURL', true, array('timestamp' => $entry['timestamp'])) . '#s9yisp' . $imageid . '">'; echo '<div class="serendipity_Entry_Date"> <h3 class="serendipity_date">' . serendipity_formatTime(DATE_FORMAT_ENTRY, $entry['timestamp']) . '</h3>'; echo '<h4 class="serendipity_title"><a href="#">' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET)) . '</a></h4>'; echo '<div class="serendipity_entry"><div class="serendipity_entry_body">'; echo '<div class="serendipity_center">' . $link . '<!-- s9ymdb:' . $entry['id'] . ' --><img src="' . $imgsrc . '" /></a></div>'; echo '<br />'; echo $link . '<< ' . BACK . '</a>'; echo "</div>\n</div>\n</div>\n"; return true; break; case 'frontend_image_add_unknown': case 'frontend_image_add_filenameonly': case 'frontend_image_selector_submit': case 'frontend_image_selector_more': case 'frontend_image_selector_imagecomment': case 'frontend_image_selector_imagealign': case 'frontend_image_selector_imagesize': case 'frontend_image_selector_hiddenfields': case 'frontend_image_selector_imagelink': return true; break; case 'css_backend': if ($serendipity['version'][0] > 1) { ?> #imageselectorplus .radio_field input { margin: 0 0.5em; } #quickblog_tablefield { display: table-cell; } #uploadform .quickblog_nugget { margin-left: 0; padding: 0; } #quickblog_tablefield .quickblog_form_field { margin: .375em 0; } #quickblog_tablefield .quickblog_radio_field div label, #quickblog_tablefield .radio_field label { padding-left: .5em; } #quickblog_tablefield .quickblog_form_select { margin-top: 0.75em; margin-bottom: 0.75em; } #quickblog_tablefield .quickblog_radio_field label { padding-left: 0; } #quickblog_tablefield .quickblog_radio_field div { display: inline; } #quickblog_tablefield .quickblog_radio_field input { margin-left: 0.5em; } <?php } break; case 'css': ?> #content .serendipity_quickblog_image { border: medium none transparent; } .serendipity_mediainsert_gallery { border: 1px solid #C0C0C0; margin: 0px; overflow: auto; padding: 0.4em; } <?php break; case 'frontend_image_selector': if ($serendipity['version'][0] < 2) { $eventData['finishJSFunction'] = 'serendipity_imageSelectorPlus_done(\'' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['GET']['textarea']) : htmlspecialchars($serendipity['GET']['textarea'], ENT_COMPAT, LANG_CHARSET)) . '\')'; } else { $eventData['finishJSFunction'] = 'serendipity.serendipity_imageSelector_done(\'' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['GET']['textarea']) : htmlspecialchars($serendipity['GET']['textarea'], ENT_COMPAT, LANG_CHARSET)) . '\')'; } return true; break; default: return false; } } else { return false; } }
/** * Show the list of plugins * * Shows a HTML list of all installed plugins, complete with config/delete/sort order options * * @access public * @param boolean Indicates if event plugins (TRUE) or sidebar plugins (FALSE) shall be shown * @return null */ function show_plugins($event_only = false, $sidebars = null) { static $opts = array('event' => PLUGIN_ACTIVE, 'eventh' => PLUGIN_INACTIVE); global $serendipity; $sql_filter = ''; if (is_array($sidebars)) { foreach ($sidebars as $sidebar) { $up = strtoupper($sidebar); if ($sidebar == 'hide') { $opts[$sidebar] = HIDDEN; } elseif (defined('SIDEBAR_' . $up)) { $opts[$sidebar] = constant('SIDEBAR_' . $up); } elseif (defined($up)) { $opts[$sidebar] = constant($up); } else { $opts[$sidebar] = $up; } $sql_filter .= "AND placement != '" . serendipity_db_escape_string($sidebar) . "' "; } } if (!$event_only) { $sql = "SELECT * from {$serendipity['dbPrefix']}plugins\n WHERE placement != 'event'\n AND placement != 'eventh'\n " . $sql_filter; $invisible_plugins = serendipity_db_query($sql); if (is_array($invisible_plugins)) { $sidebars[] = 'NONE'; $opts['NONE'] = NONE; } } $eyecandy = !isset($serendipity['eyecandy']) || serendipity_db_bool($serendipity['eyecandy']); if (!$eyecandy) { echo ' <form action="?serendipity[adminModule]=plugins" method="post">'; } elseif (!$event_only) { echo '<script type="text/javascript"> function templatePluginMoverInit() { '; $is_first = true; foreach ($sidebars as $sidebar) { ?> <?php echo $is_first ? 'var ' : ''; ?> list = document.getElementById("<?php echo $sidebar; ?> _col"); DragDrop.makeListContainer(list, 'g1'); list.onDragOver = function() { this.style["border"] = "1px solid #4d759b"; }; list.onDragOut = function() { this.style["border"] = "none"; }; <?php $is_first = false; } echo ' } addLoadEvent(templatePluginMoverInit);</script>'; echo ' <form action="?serendipity[adminModule]=plugins" method="post" onsubmit="pluginMovergetSort(); return true">'; echo ' <input type="hidden" name="serendipity[pluginorder]" id="order" value="" />'; } else { echo '<script type="text/javascript">addLoadEvent(pluginMoverInitEvent);</script>'; echo ' <form action="?serendipity[adminModule]=plugins" method="post" onsubmit="pluginMovergetSortEvent(); return true">'; echo ' <input type="hidden" name="serendipity[pluginorder]" id="eventorder" value="" />'; } echo serendipity_setFormToken(); ?> <table class="pluginmanager" border="0" cellpadding="5" cellspacing="3" width="100%"> <tr> <?php $errors = array(); /* Block display the plugins per placement location. */ if ($event_only) { $plugin_placements = array('event', 'eventh'); } else { $plugin_placements = $sidebars; } $total = 0; foreach ($plugin_placements as $plugin_placement) { if (!$event_only && $plugin_placement == 'NONE') { $is_invisible = true; } else { $is_invisible = false; } $ptitle = $opts[$plugin_placement]; $pid = $plugin_placement; echo '<td class="pluginmanager_side pluginmanager_' . ($event_only ? 'event' : 'sidebar') . '">'; echo '<div class="heading">' . $ptitle . '</div>'; echo '<ol id="' . $pid . '_col" class="pluginmanager_container">'; if ($is_invisible) { $plugins = $invisible_plugins; } else { $plugins = serendipity_plugin_api::enum_plugins($plugin_placement); } if (!is_array($plugins)) { continue; } $sort_idx = 0; foreach ($plugins as $plugin_data) { $total++; $plugin =& serendipity_plugin_api::load_plugin($plugin_data['name'], $plugin_data['authorid']); $key = urlencode($plugin_data['name']); $css_key = 's9ycid' . str_replace('%', '-', $key); $is_plugin_owner = $plugin_data['authorid'] == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers'); $is_plugin_editable = $is_plugin_owner || $plugin_data['authorid'] == '0'; if (!is_object($plugin)) { $name = $title = ERROR . '!'; $desc = ERROR . ': ' . $plugin_data['name']; $can_configure = false; } else { /* query for its name, description and configuration data */ $bag = new serendipity_property_bag(); $plugin->introspect($bag); $name = htmlspecialchars($bag->get('name')); $desc = htmlspecialchars($bag->get('description')); $desc .= '<br />' . VERSION . ': <em>' . $bag->get('version') . '</em>'; $title = serendipity_plugin_api::get_plugin_title($plugin, '[' . $name . ']'); if ($bag->is_set('configuration') && ($plugin->protected === FALSE || $plugin_data['authorid'] == '0' || $plugin_data['authorid'] == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers'))) { $can_configure = true; } else { $can_configure = false; } } if ($event_only) { $place = placement_box('serendipity[placement][' . $plugin_data['name'] . ']', $plugin_data['placement'], $is_plugin_editable, true, $opts); $event_only_uri = '&serendipity[event_plugin]=true'; } else { $place = placement_box('serendipity[placement][' . $plugin_data['name'] . ']', $plugin_data['placement'], $is_plugin_editable, false, $opts); $event_only_uri = ''; } /* Only display UP/DOWN links if there's somewhere for the plugin to go */ if ($sort_idx == 0) { $moveup = ' '; } else { $moveup = '<a href="?' . serendipity_setFormToken('url') . '&serendipity[adminModule]=plugins&submit=move+up&serendipity[plugin_to_move]=' . $key . $event_only_uri . '" style="border: 0"><img src="' . serendipity_getTemplateFile('admin/img/uparrow.png') . '" height="16" width="16" border="0" alt="' . UP . '" /></a>'; } if ($sort_idx == count($plugins) - 1) { $movedown = ' '; } else { $movedown = ($moveup != '' ? ' ' : '') . '<a href="?' . serendipity_setFormToken('url') . '&serendipity[adminModule]=plugins&submit=move+down&serendipity[plugin_to_move]=' . $key . $event_only_uri . '" style="border: 0"><img src="' . serendipity_getTemplateFile('admin/img/downarrow.png') . '" height="16" width="16" alt="' . DOWN . '" border="0" /></a>'; } ?> <li class="pluginmanager_item_<?php echo $sort_idx % 2 ? 'even' : 'uneven'; ?> " id="<?php echo $css_key; ?> "> <div id="g<?php echo $css_key; ?> " class="pluginmanager_grablet"> <a href="#" id="grab<?php echo $css_key; ?> "></a> </div> <?php if ($is_plugin_editable) { ?> <input class="input_checkbox" type="checkbox" name="serendipity[plugin_to_remove][]" value="<?php echo $plugin_data['name']; ?> " /> <?php } ?> <?php if ($can_configure) { ?> <a class="pluginmanager_configure" href="?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]=<?php echo $key; ?> "><img src="<?php echo serendipity_getTemplateFile('admin/img/configure.png'); ?> " style="border: 0; vertical-align: bottom;" alt="[C]" /></a> <?php } ?> <span class="pluginmanager_title"> <?php if ($can_configure) { ?> <a title="<?php echo $plugin_data['name']; ?> " href="?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]=<?php echo $key; ?> "><?php echo $title; ?> </a> <?php } else { ?> <?php echo $title; ?> <?php } ?> </span><br /> <div class="pluginmanager_description" style="font-size: 8pt"><?php echo $desc; ?> </div> <div class="pluginmanager_ownership"><?php ownership($plugin_data['authorid'], $plugin_data['name'], $is_plugin_owner); ?> </div> <?php echo $eyecandy ? '<noscript>' : ''; ?> <div class="pluginmanager_place"><?php echo $place; ?> </div> <div class="pluginmanager_move"><?php echo $moveup; ?> <?php echo $movedown; ?> </div> <?php echo $eyecandy ? '</noscript>' : ''; ?> </li> <?php $sort_idx++; } echo '</ol></td>'; } ?> </tr> <tr> <td colspan="3" align="right"><?php printf(PLUGIN_AVAILABLE_COUNT, $total); ?> </td> </tr> </table> <br /> <div> <input type="submit" name="REMOVE" title="<?php echo DELETE; ?> " value="<?php echo REMOVE_TICKED_PLUGINS; ?> " class="serendipityPrettyButton input_button" /> <input type="submit" name="SAVE" title="<?php echo SAVE_CHANGES_TO_LAYOUT; ?> " value="<?php echo SAVE; ?> " class="serendipityPrettyButton input_button" /> </div> </form> <?php }
function admin_save() { global $serendipity; global $template_vars; serendipity_smarty_init(); if (isset($template_vars['sidebars'])) { $sidebars = explode(',', $template_vars['sidebars']); } elseif (isset($serendipity['sidebars'])) { $sidebars = $serendipity['sidebars']; } else { $sidebars = array('left', 'hide', 'right'); } $plugin_list = array(); $view_list = array(); $category_view_list = array(); $usergroups_view_list = array(); foreach ($sidebars as $sidebar) { $plugins = serendipity_plugin_api::enum_plugins($sidebar); $i = 0; if (is_array($plugins)) { if ($sidebar == 'left') { $pside = 0; } elseif ($sidebar == 'right') { $pside = 1; } else { $pside = $sidebar; } foreach ($plugins as $plugin) { if (isset($_REQUEST['plugin_' . $pside . '_' . $i])) { $plugin_list[$pside][$i] = 0; } else { $plugin_list[$pside][$i] = 1; } $i++; } } } $this->set_config('plugin_list', serialize($plugin_list)); foreach ((array) $_REQUEST['plugin_view'] as $instance => $prop) { if ($prop == 'myself') { $view_list[base64_decode($instance)] = $serendipity['authorid']; } elseif ($prop == 'member') { $view_list[base64_decode($instance)] = 'member'; } elseif ($prop == 'everyone') { //--JAM: 2005-10-18 $view_list[base64_decode($instance)] = 'everyone'; } } $this->set_config('view_list', serialize($view_list)); foreach ((array) $_REQUEST['plugin_category_view'] as $instance => $prop) { $category_view_list[base64_decode($instance)] = implode(',', $prop); } $this->set_config('category_view_list', serialize($category_view_list)); foreach ((array) $_REQUEST['plugin_usergroups_view'] as $instance => $prop) { $usergroups_view_list[base64_decode($instance)] = implode(',', $prop); } $this->set_config('usergroups_view_list', serialize($usergroups_view_list)); echo '<div class="serendipityAdminMsgSuccess"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%T')) . "<br /><br />\n</div>"; }
function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; $hooks =& $bag->get('event_hooks'); if (isset($hooks[$event])) { switch ($event) { case 'backend_sidebar_entries': ?> <li class="serendipitySideBarMenuLink serendipitySideBarMenuEntryLinks"><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=mycalendar"><?php echo PLUGIN_MYCALENDAR_TITLE; ?> </a></li> <?php break; case 'backend_sidebar_entries_event_display_mycalendar': $this->showevents(); break; case 'external_plugin': if ($eventData == 'mycalendar.rss') { $plugins = serendipity_plugin_api::enum_plugins('*', false, 'serendipity_plugin_mycalendar', null); if (!is_array($plugins)) { return; } foreach ($plugins as $plugin_data) { $plugin =& serendipity_plugin_api::load_plugin($plugin_data['name'], $plugin_data['authorid'], $plugin_data['path']); } if (!is_object($plugin)) { return; } $items = $plugin->generate_content($eventData, true); header('Content-Type: text/xml; charset=UTF-8'); echo '<?xml version="1.0" encoding="utf-8" ?>' . "\n"; ?> <rss version="2.0" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:admin="http://webns.net/mvcb/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:content="http://purl.org/rss/1.0/modules/content/" > <channel> <title><?php echo $serendipity['blogTitle'] . ' - ' . PLUGIN_MYCALENDAR_TITLE; ?> </title> <link><?php echo $serendipity['baseURL']; ?> </link> <description><?php echo PLUGIN_MYCALENDAR_SIDE_NAME; ?> </description> <generator>Serendipity - http://www.s9y.org/</generator> <?php foreach ($items as $item) { ?> <item> <title><?php echo serendipity_utf8_encode(function_exists('serendipity_specialchars') ? serendipity_specialchars($item['title']) : htmlspecialchars($item['title'], ENT_COMPAT, LANG_CHARSET)); ?> </title> <link><?php echo serendipity_utf8_encode(function_exists('serendipity_specialchars') ? serendipity_specialchars($item['url']) : htmlspecialchars($item['url'], ENT_COMPAT, LANG_CHARSET)); ?> </link> <author><?php echo $serendipity['blogTitle']; ?> </author> <content:encoded> <?php echo serendipity_utf8_encode(function_exists('serendipity_specialchars') ? serendipity_specialchars($item['content']) : htmlspecialchars($item['content'], ENT_COMPAT, LANG_CHARSET)); ?> </content:encoded> <pubDate><?php echo $item['date']; ?> </pubDate> <guid isPermaLink="false"><?php echo serendipity_utf8_encode(function_exists('serendipity_specialchars') ? serendipity_specialchars($item['url']) : htmlspecialchars($item['url'], ENT_COMPAT, LANG_CHARSET)); ?> </guid> </item> <?php } ?> </channel> </rss> <?php } break; case 'frontend_calendar': $this->get_month_events($eventData, $addData); break; } } return true; }
} if (!empty($serendipity['GET']['category'])) { $cInfo = serendipity_fetchCategoryInfo((int) $serendipity['GET']['category']); $title = serendipity_utf8_encode(htmlspecialchars($title . ' - ' . $cInfo['category_name'])); } elseif (!empty($serendipity['GET']['viewAuthor'])) { list($aInfo) = serendipity_fetchAuthor((int) $serendipity['GET']['viewAuthor']); $title = serendipity_utf8_encode(htmlspecialchars($aInfo['realname'] . ' - ' . $title)); } else { $title = serendipity_utf8_encode(htmlspecialchars($title)); } $description = serendipity_utf8_encode(htmlspecialchars($description)); $metadata = array('title' => $title, 'description' => $description, 'language' => $serendipity['lang'], 'additional_fields' => array(), 'link' => $serendipity['baseURL'], 'email' => $serendipity['blogMail'], 'fullFeed' => false, 'showMail' => false, 'version' => $version); if (!defined('S9Y_FRAMEWORK_PLUGIN_API')) { include S9Y_INCLUDE_PATH . 'include/plugin_api.inc.php'; } $plugins = serendipity_plugin_api::enum_plugins(); if (is_array($plugins)) { // load each plugin to make some introspection foreach ($plugins as $plugin_data) { if (preg_match('|@serendipity_syndication_plugin|', $plugin_data['name'])) { $plugin =& serendipity_plugin_api::load_plugin($plugin_data['name'], $plugin_data['authorid']); $metadata['additional_fields'] = $plugin->generate_rss_fields($metadata['title'], $metadata['description'], $entries); if (is_array($metadata['additional_fields'])) { // Fix up array keys, because "." are not allowed when wanting to output using Smarty foreach ($metadata['additional_fields'] as $_aid => $af) { $aid = str_replace('.', '', $_aid); $metadata['additional_fields'][$aid] = $af; } } $metadata['fullFeed'] = $plugin->get_config('fullfeed', false); if ($metadata['fullFeed'] === 'client') {
function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; static $regex = null; static $sub = null; static $navigate = null; static $pluginDir = null; static $type = null; $hooks =& $bag->get('event_hooks'); if (isset($hooks[$event])) { if ($pluginDir === null) { $pluginDir = $this->get_config('path'); } if ($type === null) { $type = $this->get_config('type'); #$new = array('colorbox', 'lightbox2jq', 'magnific', 'prettyPhoto'); /*$removed = array('lightbox2', 'lightbox', 'lightbox_plus', 'thickbox', 'greybox'); if (in_array($type, $removed)) { $type = 'lightbox2jq'; // force and set new default for upgraders $this->set_config('type', $type); }*/ } if ($navigate === null) { $navigate = $this->get_config('navigate_one_entry_only'); } if ($regex == null) { if ($type == 'lightbox2jq') { $regex = '/<a([^>]+)(href=(["\'])[^"\']*\\.(jpe?g|gif|png)["\'])/i'; $sub = '<a $1 rel=$3lightbox$3 $2'; } elseif ($type == 'prettyPhoto') { $regex = '/<a([^>]+)(href=(["\'])[^"\']*\\.(jpe?g|gif|png)["\'])/i'; $sub = '<a rel=$3prettyPhoto$3 $1 $2'; } elseif ($type == 'colorbox') { $regex = '/<a([^>]+)(href=(["\'])[^"\']*\\.(jpe?g|gif|png)["\'])/i'; $sub = '<a $1 rel=$3singlebox$3 $2'; } elseif ($type == 'magnific') { $regex = '/<a([^>]+)(href=(["\'])[^"\']*\\.(jpe?g|gif|png)["\'])/i'; $sub = '<a rel=$3onemagnificPopup$3 $1 $2'; } else { // force new lib to prevent empty regular expression errors in preg_replace() $type = 'lightbox2jq'; $this->set_config('type', $type); $regex = '/<a([^>]+)(href=(["\'])[^"\']*\\.(jpe?g|gif|png)["\'])/i'; $sub = '<a $1 rel=$3lightbox$3 $2'; } } switch ($event) { case 'frontend_header': $headcss = true; case 'frontend_footer': // case plugin imagesidebar on eg staticpages. We need the libs then! $check_imagesidebar = serendipity_plugin_api::enum_plugins('*', false, 'serendipity_plugin_imagesidebar'); $cisb = $check_imagesidebar['placement'] != 'hide' ? $check_imagesidebar : null; // If no imagelink was processed, don't add css or js files to the header! (configurable optimization) if (serendipity_db_bool($this->get_config('header_optimization', false)) && !$this->foundImageLink && empty($cisb)) { return true; } echo "\n"; // ColorBox code (https://github.com/jackmoore/colorbox) - init with :visible to ensure to not show hidden elements via hideafter function in imageselectorplus ranges if ($type == 'colorbox') { if ($headcss) { echo ' <link rel="stylesheet" type="text/css" href="' . $pluginDir . '/fixchrome.css" />' . "\n"; echo ' <link rel="stylesheet" type="text/css" href="' . $pluginDir . '/colorbox/colorboxScreens.css" />' . "\n"; echo ' <link rel="stylesheet" type="text/css" href="' . $pluginDir . '/colorbox/colorbox.css" />' . "\n"; } else { if (!class_exists('serendipity_event_jquery') && !$serendipity['capabilities']['jquery']) { echo ' <script type="text/javascript" src="' . $pluginDir . '/jquery-1.11.3.min.js" charset="utf-8"></script>' . "\n"; } echo ' <script type="text/javascript" src="' . $pluginDir . '/colorbox/jquery.colorbox-min.js" charset="utf-8"></script>' . "\n"; echo ' <script type="text/javascript" src="' . $pluginDir . '/colorbox/jquery.colorbox.init.js" charset="utf-8"></script>' . "\n"; } } elseif ($type == 'lightbox2jq') { if ($headcss) { echo ' <link rel="stylesheet" type="text/css" href="' . $pluginDir . '/lightbox2-jquery/css/lightbox.css" />' . "\n"; } else { if (!class_exists('serendipity_event_jquery') && !$serendipity['capabilities']['jquery']) { echo ' <script type="text/javascript" src="' . $pluginDir . '/jquery-1.11.3.min.js" charset="utf-8"></script>' . "\n"; } // remove anchors possible onclick handler echo ' <script type="text/javascript"> jQuery(document).ready(function(){ jQuery(\'a[rel^="lightbox"]\').removeAttr("onclick"); }); </script>' . "\n"; echo ' <script type="text/javascript" src="' . $pluginDir . '/lightbox2-jquery/js/lightbox.min.js" charset="utf-8"></script>' . "\n"; } } elseif ($type == 'magnific') { if ($headcss) { echo ' <link rel="stylesheet" type="text/css" href="' . $pluginDir . '/fixchrome.css" />' . "\n"; echo ' <link rel="stylesheet" type="text/css" href="' . $pluginDir . '/magnific-popup/magnific-popup.css" />' . "\n"; } else { if (!class_exists('serendipity_event_jquery') && !$serendipity['capabilities']['jquery']) { echo ' <script type="text/javascript" src="' . $pluginDir . '/jquery-1.11.3.min.js" charset="utf-8"></script>' . "\n"; } echo ' <script type="text/javascript" src="' . $pluginDir . '/magnific-popup/jquery.magnific-popup.min.js" charset="utf-8"></script>' . "\n"; echo ' <script type="text/javascript" src="' . $pluginDir . '/magnific-popup/jquery.magnific-popup.init.js" charset="utf-8"></script>' . "\n"; } } elseif ($type == 'prettyPhoto') { if ($headcss) { echo ' <link rel="stylesheet" type="text/css" href="' . $pluginDir . '/fixchrome.css" />' . "\n"; echo ' <link rel="stylesheet" type="text/css" href="' . $pluginDir . '/prettyphoto/css/prettyPhoto.css" />' . "\n"; echo ' <link rel="stylesheet" type="text/css" href="' . $pluginDir . '/prettyphoto/css/prettyPhotoScreens.css" />' . "\n"; } else { if (!class_exists('serendipity_event_jquery') && !$serendipity['capabilities']['jquery']) { echo ' <script type="text/javascript" src="' . $pluginDir . '/jquery-1.11.3.min.js" charset="utf-8"></script>' . "\n"; } // remove anchors possible onclick handler echo ' <script type="text/javascript">jQuery(document).ready(function(){ jQuery(\'a[rel^="prettyPhoto"]\').removeAttr("onclick"); }); </script>' . "\n"; echo ' <script type="text/javascript" src="' . $pluginDir . '/prettyphoto/js/jquery.prettyPhoto.min.js" charset="utf-8"></script>' . "\n"; echo ' <script type="text/javascript">jQuery(document).ready(function(){ jQuery(\'a:visible[rel^="prettyPhoto"]\').prettyPhoto(' . $this->get_config('init_js') . '); }); </script>' . "\n"; } } return true; break; case 'frontend_display': if ($type == 'lightbox2jq') { if ($navigate == 'entry') { $sub = '<a $1 rel=$3lightbox[' . $eventData['id'] . ']$3 $2'; } elseif ($navigate == 'page') { $sub = '<a $1 rel=$3lightbox[]$3 $2'; } } elseif ($type == 'prettyPhoto') { if ($navigate == 'entry') { $sub = '<a rel=$3prettyPhoto[' . $eventData['id'] . ']$3 $1 $2'; } elseif ($navigate == 'page') { $sub = '<a rel=$3prettyPhoto[]$3 $1 $2'; } } elseif ($type == 'colorbox') { if ($navigate == 'entry') { $sub = '<a rel=$3colorbox[' . $eventData['id'] . ']$3 $1 $2'; } elseif ($navigate == 'page') { $sub = '<a rel=$3colorbox[]$3 $1 $2'; } } elseif ($type == 'magnific') { if ($navigate == 'entry') { $sub = '<a rel=$3magnificPopup[' . $eventData['id'] . ']$3 $1 $2'; } elseif ($navigate == 'page') { $sub = '<a rel=$3magnificPopup[]$3 $1 $2'; } } foreach ($this->markup_elements as $temp) { if (isset($eventData[$temp['element']]) && serendipity_db_bool($this->get_config($temp['name'], true)) && !$eventData['properties']['ep_disable_markup_' . $this->instance] && !isset($serendipity['POST']['properties']['disable_markup_' . $this->instance])) { $element = $temp['element']; $replacement_count = 0; $eventData[$element] = preg_replace($regex, $sub, $eventData[$element], -1, $replacement_count); // Remember if an image link was found if ($replacement_count > 0) { $this->foundImageLink = true; } } } return true; break; default: return false; } } else { return false; } }