function generate_content(&$title) { $plug = $this->get_config('event_plugin', 'false'); if ($plug == 'false') { return; } $wrap =& serendipity_plugin_api::get_event_plugins($plug); $faketitle = ''; if (is_object($wrap)) { $wrap->generate_content($faketitle); } if ($this->get_config('title') != '') { $title = $this->get_config('title'); } else { $title = $faketitle; } }
/** * Executes a specific Eventhook * * If you want to temporarily block any event plugins, you can set $serendipity['no_events'] before * this method call. * * @access public * @param string The name of the event to hook on to * @param mixed May contain any type of variables that are passed by reference to an event plugin * @param mixed May contain any type of variables that are passed to an event plugin * @return true */ function hook_event($event_name, &$eventData, $addData = null) { global $serendipity; // Can be bypassed globally by setting $serendipity['no_events'] = TRUE; if (isset($serendipity['no_events']) && $serendipity['no_events'] == true) { return false; } if ($serendipity['enablePluginACL'] && !serendipity_hasPluginPermissions($event_name)) { return false; } // We can NOT use a "return by reference" here, because then when // a plugin executes another event_hook, the referenced variable within // that call will overwrite the previous original plugin listing and // skip the execution of any follow-up plugins. $plugins = serendipity_plugin_api::get_event_plugins(); if (function_exists('serendipity_plugin_api_pre_event_hook')) { $apifunc = 'serendipity_plugin_api_pre_event_hook'; $apifunc($event_name, $bag, $eventData, $addData); } if (is_array($plugins)) { // foreach() operates on copies of values, but we want to operate on references, so we use while() @reset($plugins); while (list($plugin, $plugin_data) = each($plugins)) { $bag =& $plugin_data['b']; $phooks =& $bag->get('event_hooks'); if (isset($phooks[$event_name])) { // Check for cachable events. if (isset($eventData['is_cached']) && $eventData['is_cached']) { $chooks =& $bag->get('cachable_events'); if (is_array($chooks) && isset($chooks[$event_name])) { continue; } } if ($serendipity['enablePluginACL'] && !serendipity_hasPluginPermissions($plugin)) { continue; } $plugin_data['p']->event_hook($event_name, $bag, $eventData, $addData); } } if (function_exists('serendipity_plugin_api_event_hook')) { $apifunc = 'serendipity_plugin_api_event_hook'; $apifunc($event_name, $bag, $eventData, $addData); } } return true; }
function showBackend($element, $eventData, $is_sticky, $no_frontpage, $hiderss, $access_values, $access, $password, $use_groups, $access_groups, $use_users, $access_users, $more = array()) { global $serendipity; switch ($element) { case 'sticky': ?> <div class="entryproperties_sticky adv_opts_box form_check"> <input id="properties_is_sticky" name="serendipity[properties][is_sticky]" type="checkbox" value="true" <?php echo $is_sticky; ?> > <label for="properties_is_sticky"><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_STICKYPOSTS; ?> </label> </div> <?php return true; case 'frontpage': ?> <div class="entryproperties_frontpage adv_opts_box form_check"> <input id="properties_no_frontpage" name="serendipity[properties][no_frontpage]" type="checkbox" value="true" <?php echo $no_frontpage; ?> > <label for="properties_no_frontpage"><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_NO_FRONTPAGE; ?> </label> </div> <?php return true; case 'hiderss': ?> <div class="entryproperties_hiderss adv_opts_box form_check"> <input id="properties_hiderss" name="serendipity[properties][hiderss]" type="checkbox" value="true" <?php echo $hiderss; ?> > <label for="properties_hiderss"><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_HIDERSS; ?> </label> </div> <?php return true; case 'access': ?> <fieldset class="entryproperties_access_list adv_opts_box"> <span class="wrap_legend"><legend><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_ACCESS; ?> :</legend></span> <div class="clearfix"> <?php foreach ($access_values as $radio_title => $radio_value) { ?> <div class="form_radio"> <input id="properties_access_<?php echo $radio_value; ?> " name="serendipity[properties][access]" type="radio" value="<?php echo $radio_value; ?> " <?php echo $radio_value == $access ? 'checked="checked"' : ''; ?> > <label for="properties_access_<?php echo $radio_value; ?> "><?php echo $radio_title; ?> </label> </div> <?php } ?> </div> </fieldset> <?php return true; case 'password': ?> <div class="entryproperties_access_pw adv_opts_box adv_opts_box form_field"> <label for="properties_access_pw"><?php echo PASSWORD; ?> :</label> <input type="password" name="ignore_password" value="" style="display:none"> <input id="properties_access_pw" name="serendipity[properties][entrypassword]" type="password" autocomplete="off" value="<?php echo serendipity_specialchars($password); ?> "> </div> <?php return true; case 'groups': if ($use_groups) { $my_groups = serendipity_getGroups($serendipity['authorid']); ?> <div class="entryproperties_access_groups adv_opts_box form_multiselect"> <label for="properties_access_groups"><?php echo PERM_READ . ': ' . GROUP; ?> </label> <select id="properties_access_groups" name="serendipity[properties][access_groups][]" multiple="multiple" size="4" onchange="document.getElementById('properties_access_member').checked = true;"> <?php foreach ($my_groups as $group) { if ('USERLEVEL_' == substr($group['confvalue'], 0, 10)) { $group['name'] = constant($group['confvalue']); } ?> <option value="<?php echo $group['id']; ?> " <?php echo in_array($group['id'], $access_groups) ? 'selected="selected"' : ''; ?> ><?php echo serendipity_specialchars($group['name']); ?> </option> <?php } echo '</select>'; echo '</div>'; } return true; case 'authors': if ($use_users) { ?> <div class="entryproperties_access_users adv_opts_box form_multiselect"> <label for="properties_access_users"><?php echo PERM_READ . ': ' . AUTHOR; ?> </label> <select id="properties_access_users" name="serendipity[properties][access_users][]" multiple="multiple" size="4" onchange="document.getElementById('properties_access_member').checked = true;"> <?php $users = serendipity_fetchUsers('', 'hidden'); foreach ($users as $user) { ?> <option value="<?php echo $user['authorid']; ?> " <?php echo in_array($user['authorid'], $access_users) ? 'selected="selected"' : ''; ?> ><?php echo serendipity_specialchars($user['realname']); ?> </option> <?php } echo '</select>'; echo '</div>'; } return true; case 'author': ?> <div class="entryproperties_access_author adv_opts_box form_select"> <label for="properties_access_author"><?php echo AUTHOR; ?> :</label> <select id="properties_access_author" name="serendipity[change_author]"> <?php if (isset($serendipity['POST']['change_author'])) { $selected_user = $serendipity['POST']['change_author']; } elseif (!empty($eventData['authorid'])) { $selected_user = $eventData['authorid']; } else { $selected_user = $serendipity['authorid']; } $avail_users =& $this->getValidAuthors(); foreach ($avail_users as $user) { echo '<option value="' . $user['authorid'] . '" ' . ($selected_user == $user['authorid'] ? ' selected="selected"' : '') . '>' . serendipity_specialchars($user['realname']) . '</option>' . "\n"; } ?> </select> </div> <?php return true; case 'markup': ?> <div class="entryproperties_markup adv_opts_box form_multiselect"> <label for="properties_markup"><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_DISABLE_MARKUP; ?> </label> <select id="properties_markup" name="serendipity[properties][disable_markups][]" multiple="multiple" size="4"> <?php $plugins = serendipity_plugin_api::get_event_plugins(); if (is_array($plugins)) { // foreach() operates on copies of values, but we want to operate on references, so we use while() @reset($plugins); while (list($plugin, $plugin_data) = each($plugins)) { if (!is_array($plugin_data['p']->markup_elements)) { continue; } if (isset($serendipity['POST']['properties']['disable_markups']) && in_array($plugin_data['p']->instance, $serendipity['POST']['properties']['disable_markups'])) { $selected = true; } elseif (isset($eventData['properties']['ep_disable_markup_' . $plugin_data['p']->instance])) { $selected = true; } else { $selected = false; } // automatically mark nl2br markup parser as disabled, when WYSIWYG is active if (!$selected && $serendipity['wysiwyg'] && $plugin_data['p']->act_pluginPath == 'serendipity_event_nl2br') { $selected = true; } echo '<option ' . ($selected ? 'selected="selected"' : '') . ' value="' . $plugin_data['p']->instance . '">' . serendipity_specialchars($plugin_data['p']->title) . '</option>' . "\n"; } } ?> </select> </div> <?php return true; case 'customfields': ?> <div class="entryproperties_customfields adv_opts_box"> <?php $fields = trim($this->get_config('customfields')); // Capture special characters for "," and ":" $special_from = array('\\,', '\\:'); $special_to = array(chr(0x1), chr(0x2)); $special_read = array(',', ':'); $fields = str_replace($special_from, $special_to, $fields); if (!empty($fields)) { $fields = explode(',', $fields); } if (is_array($fields) && count($fields) > 0) { ?> <h4><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS; ?> </h4> <span><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS_DESC1 . sprintf(PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS_DESC3, 'serendipity_admin.php?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]=' . $this->instance); ?> </span> <div class="serendipity_customfields clearfix"> <?php foreach ($fields as $fieldname) { $fieldparts = explode(':', $fieldname); $fieldname = $fieldparts[0]; $_fieldname = serendipity_specialchars(trim($fieldname)); if (isset($serendipity['POST']['properties'][$_fieldname])) { $value = $serendipity['POST']['properties'][$_fieldname]; } elseif (!empty($eventData['properties']['ep_' . $_fieldname])) { $value = $eventData['properties']['ep_' . $_fieldname]; } else { $value = trim(str_replace($special_to, $special_read, $fieldparts[1])); } ?> <div id="ep_column_<?php echo $_fieldname; ?> " class="clearfix form_area media_choose"> <label for="prop<?php echo $_fieldname; ?> "><?php echo $_fieldname; ?> </label> <textarea id="prop<?php echo $_fieldname; ?> " class="change_preview" name="serendipity[properties][<?php echo $_fieldname; ?> ]" data-configitem="prop<?php echo $_fieldname; ?> "><?php echo serendipity_specialchars($value); ?> </textarea> <button class="customfieldMedia" type="button" name="insImage" title="<?php echo MEDIA; ?> "><span class="icon-picture"></span><span class="visuallyhidden"><?php echo MEDIA; ?> </span></button> <?php if (preg_match('/(\\.jpg|\\.png|\\.bmp)$/', $value)) { ?> <figure id="prop<?php echo $_fieldname; ?> _preview"> <figcaption><?php echo PREVIEW; ?> </figcaption> <img src="<?php echo $value; ?> " alt=""/> </figure> <?php } ?> </div> <?php } ?> </div> <?php } ?> </div> <?php return true; } }
function introspect_config_item($name, &$propbag) { switch ($name) { case 'publishflag': $propbag->add('type', 'radio'); $propbag->add('name', PLUGIN_AGGREGATOR_PUBLISH); $propbag->add('description', ''); $propbag->add('radio', array('value' => array('true', 'false'), 'desc' => array(PUBLISH, DRAFT))); $propbag->add('default', 'true'); break; case 'cronjob': if (class_exists('serendipity_event_cronjob')) { $propbag->add('type', 'select'); $propbag->add('name', PLUGIN_EVENT_CRONJOB_CHOOSE); $propbag->add('description', ''); $propbag->add('default', 'daily'); $propbag->add('select_values', serendipity_event_cronjob::getValues()); } else { $propbag->add('type', 'content'); $propbag->add('default', PLUGIN_AGGREGATOR_CRONJOB); } break; case 'debug': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_AGGREGATOR_DEBUG); $propbag->add('description', PLUGIN_AGGREGATOR_DEBUG_BLAHBLAH); $propbag->add('default', false); break; case 'markup': $plugins = serendipity_plugin_api::get_event_plugins(); $markups = array(); if (is_array($plugins)) { // foreach() operates on copies of values, but we want to operate on references, so we use while() @reset($plugins); while (list($plugin, $plugin_data) = each($plugins)) { if (!is_array($plugin_data['p']->markup_elements)) { continue; } $markups[$plugin_data['p']->instance] = function_exists('serendipity_specialchars') ? serendipity_specialchars($plugin_data['p']->title) : htmlspecialchars($plugin_data['p']->title, ENT_COMPAT, LANG_CHARSET); } } $propbag->add('type', 'multiselect'); $propbag->add('name', PLUGIN_AGGREGATOR_MARKUP_DISABLE); $propbag->add('description', PLUGIN_AGGREGATOR_MARKUP_DISABLE_DESC); $propbag->add('select_values', $markups); $propbag->add('select_size', 6); $propbag->add('default', ''); break; case 'engine': $propbag->add('type', 'radio'); $propbag->add('radio', array('value' => array('onyx', 'magpierss', 'simplepie'), 'desc' => array('Onyx [BSD]', 'MagpieRSS [GPL]', 'SimplePie'))); $propbag->add('name', PLUGIN_AGGREGATOR_CHOOSE_ENGINE); $propbag->add('description', PLUGIN_AGGREGATOR_CHOOSE_ENGINE_DESC); $propbag->add('default', 'onyx'); break; case 'delete_dependencies': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_AGGREGATOR_DELETEDEPENDENCIES); $propbag->add('description', PLUGIN_AGGREGATOR_DELETEDEPENDENCIES_DESC); $propbag->add('default', true); break; case 'expire': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_AGGREGATOR_EXPIRE); $propbag->add('description', PLUGIN_AGGREGATOR_EXPIRE_BLAHBLAH); $propbag->add('default', 2); break; case 'expire_md5': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_AGGREGATOR_EXPIRE_MD5); $propbag->add('description', PLUGIN_AGGREGATOR_EXPIRE_MD5_BLAHBLAH); $propbag->add('default', 90); break; case 'ignore_updates': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_AGGREGATOR_IGNORE_UPDATES); $propbag->add('description', PLUGIN_AGGREGATOR_IGNORE_UPDATES_DESC); $propbag->add('default', false); break; case 'allow_comments': $propbag->add('type', 'boolean'); $propbag->add('name', COMMENTS_ENABLE); $propbag->add('description', ''); $propbag->add('default', false); break; default: return false; } return true; }
function showBackend($element, $eventData, $is_sticky, $no_frontpage, $hiderss, $access_values, $access, $password, $use_groups, $access_groups, $use_users, $access_users, $more = array()) { global $serendipity; switch ($element) { case 'sticky': ?> <div class="entryproperties_sticky"> <input class="input_checkbox" type="checkbox" name="serendipity[properties][is_sticky]" id="properties_is_sticky" value="true" <?php echo $is_sticky; ?> /> <label title="<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_STICKYPOSTS; ?> " for="properties_is_sticky"> <?php echo PLUGIN_EVENT_ENTRYPROPERTIES_STICKYPOSTS; ?> </label> </div> <?php return true; case 'frontpage': ?> <div class="entryproperties_frontpage"> <input class="input_checkbox" type="checkbox" name="serendipity[properties][no_frontpage]" id="properties_no_frontpage" value="true" <?php echo $no_frontpage; ?> /> <label title="<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_NO_FRONTPAGE; ?> " for="properties_no_frontpage"> <?php echo PLUGIN_EVENT_ENTRYPROPERTIES_NO_FRONTPAGE; ?> </label> </div> <?php return true; case 'hiderss': ?> <div class="entryproperties_hiderss"> <input class="input_checkbox" type="checkbox" name="serendipity[properties][hiderss]" id="properties_hiderss" value="true" <?php echo $hiderss; ?> /> <label title="<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_HIDERSS_DESC; ?> " for="properties_hiderss"> <?php echo PLUGIN_EVENT_ENTRYPROPERTIES_HIDERSS; ?> </label> </div> <?php return true; case 'access': ?> <br /><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_ACCESS; ?> :<br /> <div class="entryproperties_access_list" style="margin-left: 10px"> <?php foreach ($access_values as $radio_title => $radio_value) { ?> <input class="input_radio" type="radio" name="serendipity[properties][access]" id="properties_access_<?php echo $radio_value; ?> " value="<?php echo $radio_value; ?> " <?php echo $radio_value == $access ? 'checked="checked"' : ''; ?> /> <label title="<?php echo $radio_title; ?> " for="properties_access_<?php echo $radio_value; ?> "> <?php echo $radio_title; ?> </label> <?php } ?> </div> <?php return true; case 'password': ?> <br /><?php echo PASSWORD; ?> :<br /> <div style="margin-left: 10px" class="entryproperties_access_pw"> <input autocomplete="off" class="input_textbox" type="password" name="serendipity[properties][entrypassword]" value="<?php echo htmlspecialchars($password); ?> " /> </div> <?php return true; case 'groups': if ($use_groups) { $my_groups = serendipity_getGroups($serendipity['authorid']); ?> <br /><?php echo PERM_READ . ': <em>' . GROUP . '</em>'; ?> <br /> <select class="entryproperties_access_groups" onchange="document.getElementById('properties_access_member').checked = true;" style="margin-left: 5px" multiple="multiple" name="serendipity[properties][access_groups][]" size="4"> <?php foreach ($my_groups as $group) { if ('USERLEVEL_' == substr($group['confvalue'], 0, 10)) { $group['name'] = constant($group['confvalue']); } ?> <option value="<?php echo $group['id']; ?> " <?php echo in_array($group['id'], $access_groups) ? 'selected="selected"' : ''; ?> ><?php echo htmlspecialchars($group['name']); ?> </option> <?php } echo '</select><br />'; } return true; case 'authors': if ($use_users) { ?> <br /><?php echo PERM_READ . ': <em>' . AUTHOR . '</em>'; ?> <br /> <select class="entryproperties_access_users" onchange="document.getElementById('properties_access_member').checked = true;" style="margin-left: 5px" multiple="multiple" name="serendipity[properties][access_users][]" size="4"> <?php $users = serendipity_fetchUsers('', 'hidden'); foreach ($users as $user) { ?> <option value="<?php echo $user['authorid']; ?> " <?php echo in_array($user['authorid'], $access_users) ? 'selected="selected"' : ''; ?> ><?php echo htmlspecialchars($user['realname']); ?> </option> <?php } echo '</select><br />'; } return true; case 'author': ?> <br /><?php echo AUTHOR; ?> :<br /> <div class="entryproperties_access_author" style="margin-left: 10px"> <select name="serendipity[change_author]"> <?php if (isset($serendipity['POST']['change_author'])) { $selected_user = $serendipity['POST']['change_author']; } elseif (!empty($eventData['authorid'])) { $selected_user = $eventData['authorid']; } else { $selected_user = $serendipity['authorid']; } $avail_users =& $this->getValidAuthors(); foreach ($avail_users as $user) { echo '<option value="' . $user['authorid'] . '" ' . ($selected_user == $user['authorid'] ? ' selected="selected"' : '') . '>' . htmlspecialchars($user['realname']) . '</option>' . "\n"; } ?> </select> </div> <?php return true; case 'markup': ?> <br /><div class="entryproperties_markup"> <?php echo PLUGIN_EVENT_ENTRYPROPERTIES_DISABLE_MARKUP; ?> <br /> <div style="margin-left: 10px"> <select name="serendipity[properties][disable_markups][]" multiple="multiple" size="4"> <?php $plugins = serendipity_plugin_api::get_event_plugins(); if (is_array($plugins)) { // foreach() operates on copies of values, but we want to operate on references, so we use while() @reset($plugins); while (list($plugin, $plugin_data) = each($plugins)) { if (!is_array($plugin_data['p']->markup_elements)) { continue; } if (isset($serendipity['POST']['properties']['disable_markups']) && in_array($plugin_data['p']->instance, $serendipity['POST']['properties']['disable_markups'])) { $selected = true; } elseif (isset($eventData['properties']['ep_disable_markup_' . $plugin_data['p']->instance])) { $selected = true; } else { $selected = false; } echo '<option ' . ($selected ? 'selected="selected"' : '') . ' value="' . $plugin_data['p']->instance . '">' . htmlspecialchars($plugin_data['p']->title) . '</option>' . "\n"; } } ?> </select> </div> </div> <?php return true; case 'customfields': ?> <br /><div class="entryproperties_customfields"> <?php $fields = trim($this->get_config('customfields')); if (!empty($fields)) { $fields = explode(',', $fields); } if (is_array($fields) && count($fields) > 0) { ?> <br /> <?php echo PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS; ?> :<br /> <em><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS_DESC1 . '<br />' . sprintf(PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS_DESC3, 'serendipity_admin.php?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]=' . $this->instance); ?> </em><br /> <div style="margin-left: 10px"> <table id="serendipity_customfields"> <?php foreach ($fields as $fieldname) { $fieldname = htmlspecialchars(trim($fieldname)); if (isset($serendipity['POST']['properties'][$fieldname])) { $value = $serendipity['POST']['properties'][$fieldname]; } elseif (!empty($eventData['properties']['ep_' . $fieldname])) { $value = $eventData['properties']['ep_' . $fieldname]; } else { $value = ''; } ?> <tr> <td class="customfield_<?php echo $fieldname; ?> customfield_name"><strong><?php echo $fieldname; ?> </strong></td> <td class="customfield_<?php echo $fieldname; ?> customfield_value"><textarea id="prop<?php echo htmlspecialchars($fieldname); ?> " name="serendipity[properties][<?php echo htmlspecialchars($fieldname); ?> ]"><?php echo htmlspecialchars($value); ?> </textarea></td> <td valign="top"><script type="text/javascript" language="JavaScript">document.write('<input class="serendipityPrettyButton input_button" type="button" name="insImage" value="<?php echo MEDIA; ?> " onclick="window.open(\'serendipity_admin_image_selector.php?serendipity[htmltarget]=prop<?php echo htmlspecialchars($fieldname); ?> &serendipity[filename_only]=true\', \'ImageSel\', \'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1\');" class="serendipityPrettyButton" />');</script></td> </tr> <?php } ?> </table> </div> <?php } ?> </div> <?php return true; } }
/** * Executes a specific Eventhook * * If you want to temporarily block any event plugins, you can set $serendipity['no_events'] before * this method call. * * @access public * @param string The name of the event to hook on to * @param mixed May contain any type of variables that are passed by reference to an event plugin * @param mixed May contain any type of variables that are passed to an event plugin * @return true */ static function hook_event($event_name, &$eventData, $addData = null) { global $serendipity; // Can be bypassed globally by setting $serendipity['no_events'] = TRUE; if (isset($serendipity['no_events']) && $serendipity['no_events'] == true) { return false; } if ($serendipity['enablePluginACL'] && !serendipity_hasPluginPermissions($event_name)) { return false; } // We can NOT use a "return by reference" here, because then when // a plugin executes another event_hook, the referenced variable within // that call will overwrite the previous original plugin listing and // skip the execution of any follow-up plugins. $plugins = serendipity_plugin_api::get_event_plugins(); if ($serendipity['core_events'][$event_name]) { foreach ($serendipity['core_events'][$event_name] as $apifunc_key => $apifunc) { $apifunc($event_name, $bag, $eventData, $addData); } } // execute backend needed core hooks serendipity_plugin_api_core_event_hook($event_name, $bag, $eventData, $addData); if (function_exists('serendipity_plugin_api_pre_event_hook')) { $apifunc = 'serendipity_plugin_api_pre_event_hook'; $apifunc($event_name, $bag, $eventData, $addData); } // Function names cannot contain ":" etc, so if we ever have event looks like "backend:js" this // needs to be replaced to "backend_js". The real event name is passed as a function argument // These specific per-hook functions are utilized for theme's config.inc.php files // that act as an engine for other themes. $safe_event_name = preg_replace('@[^a-z0-9_]+@i', '_', $event_name); if (function_exists('serendipity_plugin_api_pre_event_hook_' . $safe_event_name)) { $apifunc = 'serendipity_plugin_api_pre_event_hook_' . $safe_event_name; $apifunc($event_name, $bag, $eventData, $addData); } if (is_array($plugins)) { // foreach() operates on copies of values, but we want to operate on references, so we use while() @reset($plugins); while (list($plugin, $plugin_data) = each($plugins)) { $bag =& $plugin_data['b']; $phooks =& $bag->get('event_hooks'); if (isset($phooks[$event_name])) { // Check for cachable events. if (isset($eventData['is_cached']) && $eventData['is_cached']) { $chooks =& $bag->get('cachable_events'); if (is_array($chooks) && isset($chooks[$event_name])) { continue; } } if ($serendipity['enablePluginACL'] && !serendipity_hasPluginPermissions($plugin)) { continue; } $plugin_data['p']->event_hook($event_name, $bag, $eventData, $addData); } } if (function_exists('serendipity_plugin_api_event_hook')) { $apifunc = 'serendipity_plugin_api_event_hook'; $apifunc($event_name, $bag, $eventData, $addData); } if (function_exists('serendipity_plugin_api_event_hook_' . $safe_event_name)) { $apifunc = 'serendipity_plugin_api_event_hook_' . $safe_event_name; $apifunc($event_name, $bag, $eventData, $addData); } } return true; }
$permname = $perm; } if (!serendipity_checkPermission($perm) && $perm != 'hiddenGroup') { echo "<tr>\n"; echo "<td>{$indent}" . htmlspecialchars($permname) . "</td>\n"; echo '<td>' . $indentB . ' ' . (!empty($selected) ? YES : NO) . '</td>' . "\n"; echo "</tr>\n"; } else { echo "<tr>\n"; echo "<td>{$indent}<label for=\"" . htmlspecialchars($perm) . "\">" . htmlspecialchars($permname) . "</label></td>\n"; echo '<td>' . $indentB . '<input class="input_checkbox" id="' . htmlspecialchars($perm) . '" type="checkbox" name="serendipity[' . htmlspecialchars($perm) . ']" value="true" ' . $selected . ' /></td>' . "\n"; echo "</tr>\n"; } } if ($serendipity['enablePluginACL']) { $allplugins =& serendipity_plugin_api::get_event_plugins(); $allhooks = array(); ?> <tr> <td colspan="2"> </td> </tr> <tr> <td valign="top"><?php echo PERMISSION_FORBIDDEN_PLUGINS; ?> </td> <td> <select name="serendipity[forbidden_plugins][]" multiple="multiple" size="5"> <?php foreach ($allplugins as $plugid => $currentplugin) { foreach ($currentplugin['b']->properties['event_hooks'] as $hook => $set) {
function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; if (!class_exists('serendipity_event_emoticate')) { return false; } $hooks =& $bag->get('event_hooks'); if (isset($hooks[$event])) { switch ($event) { case 'frontend_comment': if (serendipity_db_bool($this->get_config('frontend', false)) === false) { break; } $txtarea = 'serendipity_commentform_comment'; $func = 'comment'; $style = ''; $popcl = ''; case 'backend_entry_toolbar_extended': if (!isset($txtarea)) { $txtarea = 'serendipity[extended]'; $func = 'extended'; } case 'backend_entry_toolbar_body': if (!isset($txtarea)) { if (isset($eventData['backend_entry_toolbar_body:textarea'])) { // event caller has given us the name of the textarea converted // into a wysiwg editor(for example, the staticpages plugin) $txtarea = $eventData['backend_entry_toolbar_body:textarea']; } else { // default value $txtarea = 'serendipity[body]'; } if (isset($eventData['backend_entry_toolbar_body:nugget'])) { $func = $eventData['backend_entry_toolbar_body:nugget']; } else { $func = 'body'; } } // CKEDITOR and plain editor need this little switch if (preg_match('@^nugget@i', $func)) { $cke_txtarea = $func; } else { $cke_txtarea = $txtarea; } if (!isset($popcl)) { $popcl = ' serendipityPrettyButton'; } if (!isset($style)) { $style = 'margin-top: 5px; vertical-align: bottom'; } $popupstyle = ''; $popuplink = ''; if (serendipity_db_bool($this->get_config('popup', false))) { $popupstyle = '; display: none'; $popuplink = serendipity_db_bool($this->get_config('button', false)) ? '<input type="button" onclick="toggle_emoticon_bar_' . $func . '(); return false" href="#" class="serendipity_toggle_emoticon_bar' . $popcl . '" value="' . $this->get_config('popuptext') . '">' : '<a class="serendipity_toggle_emoticon_bar' . $popcl . '" href="#" onclick="toggle_emoticon_bar_' . $func . '(); return false">' . $this->get_config('popuptext') . '</a>'; } $i = 1; // This plugin wants to access serendipity_event_emoticate. Its methods are non-static // and it's not properly working with PHP5 to call. So to perform properly, let's take // the actual plugin: $plugins = serendipity_plugin_api::get_event_plugins(); $emoticate_plugin = null; while (list($plugin, $plugin_data) = each($plugins)) { if (strpos($plugin, 'serendipity_event_emoticate') !== FALSE) { $emoticate_plugin =& $plugin_data['p']; break; } } if ($emoticate_plugin === null) { return; } $emoticons = $emoticate_plugin->getEmoticons(); $unique = array(); foreach ($emoticons as $key => $value) { if (is_callable(array($emoticate_plugin, 'humanReadableEmoticon'))) { $key = $emoticate_plugin->humanReadableEmoticon($key); } $unique[$value] = $key; } // script include has to stick to to backend_header, while using inline onclick (see above) if (IN_serendipity_admin === true) { ?> <div class="serendipity_emoticon_bar"> <script type="text/javascript"> emoticonchooser('<?php echo $func; ?> ', '<?php echo $txtarea; ?> ', '<?php echo $cke_txtarea; ?> '); </script> <?php } else { // in frontend footer ?> <div class="serendipity_emoticon_bar"> <script type="text/javascript"> document.onreadystatechange = function () { if (document.readyState == "interactive") { emoticonchooser('<?php echo $func; ?> ', '<?php echo $txtarea; ?> ', '<?php echo $cke_txtarea; ?> '); } } </script> <?php } echo $popuplink . "\n"; echo ' <div id="serendipity_emoticonchooser_' . $func . '" style="' . $style . $popupstyle . '">' . "\n"; foreach ($unique as $value => $key) { echo ' <a href="javascript:use_emoticon_' . $func . '(\'' . addslashes($key) . '\')" title="' . $key . '"><img src="' . $value . '" style="border: 0px" alt="' . $key . '" /></a> ' . "\n"; if ($i++ % 10 == 0) { echo " <br />\n"; } } echo ' </div>' . "\n"; echo '</div>' . "\n"; return true; break; case 'backend_header': case 'frontend_footer': ?> <script type="text/javascript" src="<?php echo $serendipity['serendipityHTTPPath'] . 'plugins/serendipity_event_emoticonchooser/emoticonchooser.js'; ?> "></script> <?php return true; break; case 'css_backend': ?> .serendipity_toggle_emoticon_bar.serendipityPrettyButton { display: inline-block; margin: 0 auto 1px; } .serendipity_emoticon_bar { margin: 3px auto 0; text-align: right; } <?php break; default: return false; break; } } else { return false; } }