/**
 * 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);
}
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
            $plugin->introspect($bag);
            if ($bag->is_set('configuration')) {
                /* Only play with the plugin if there is something to play with */
                echo '<script type="text/javascript">location.href = \'' . $serendipity['baseurl'] . '?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]=' . $inst . '\';</script>';
                die;
            } else {
                /* If no config is available, redirect to plugin overview, because we do not want that a user can install the plugin a second time via accidental browser refresh */
                echo '<script type="text/javascript">location.href = \'' . $serendipity['baseurl'] . '?serendipity[adminModule]=plugins\';</script>';
                die;
            }
        }
    }
    if (isset($_POST['REMOVE']) && serendipity_checkFormToken()) {
        if (is_array($_POST['serendipity']['plugin_to_remove'])) {
            foreach ($_POST['serendipity']['plugin_to_remove'] as $key) {
                $plugin =& serendipity_plugin_api::load_plugin($key);
                if ($plugin->serendipity_owner == '0' || $plugin->serendipity_owner == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers')) {
                    serendipity_plugin_api::remove_plugin_instance($key);
                }
            }
        }
    }
    ?>

<?php 
    if (isset($_POST['SAVE'])) {
        ?>
    <div class="serendipityAdminMsgSuccess"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="<?php 
        echo serendipity_getTemplateFile('admin/img/admin_msg_success.png');
        ?>
" alt="" /><?php 
/**
 * 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 = '&amp;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 = '&nbsp;';
            } else {
                $moveup = '<a href="?' . serendipity_setFormToken('url') . '&amp;serendipity[adminModule]=plugins&amp;submit=move+up&amp;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 = '&nbsp;';
            } else {
                $movedown = ($moveup != '' ? '&nbsp;' : '') . '<a href="?' . serendipity_setFormToken('url') . '&amp;serendipity[adminModule]=plugins&amp;submit=move+down&amp;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&amp;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&amp;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_print_sidebar(&$sidebar, $side, $plugin_list)
    {
        global $serendipity;
        $i = 0;
        $viewlist = unserialize($this->get_config('view_list'));
        $category_viewlist = unserialize($this->get_config('category_view_list'));
        $usergroups_viewlist = unserialize($this->get_config('usergroups_view_list'));
        $mygroups = serendipity_getGroups($serendipity['authorid']);
        $enabled = serendipity_db_bool($this->get_config('enable'));
        foreach ($sidebar as $plugin_data) {
            $plugin =& serendipity_plugin_api::load_plugin($plugin_data['name'], $plugin_data['authorid'], $plugin_data['path']);
            if (is_object($plugin)) {
                $checked = "";
                $checked_member = "";
                $checked_myself = "";
                $checked_everyone = "";
                if ($plugin_list[$side] && !$plugin_list[$side][$i]) {
                    $checked = "checked='checked'";
                }
                if ($viewlist[$plugin->instance] == 'member') {
                    $checked_member = "checked='checked'";
                } elseif ($viewlist[$plugin->instance] == 'myself' || $viewlist[$plugin->instance] == $serendipity['authorid']) {
                    $checked_myself = "checked='checked'";
                } elseif ($viewlist[$plugin->instance] == 'everyone') {
                    $checked_everyone = "checked='checked'";
                } else {
                    $checked_everyone = "checked='checked'";
                }
                $title = '';
                ob_start();
                $show_plugin = $plugin->generate_content($title);
                $content = ob_get_contents();
                ob_end_clean();
                if (empty($title)) {
                    $title = $plugin->get_config('backend_title');
                }
                echo "<div class='serendipitySideBarItem' style='margin-top:10px;margin-bottom:20px;'>\n";
                echo "<h3 class='serendipitySideBarTitle'>{$title}</h3>\n";
                echo "<div class='serendipitySideBarContent'><table>";
                if ($enabled) {
                    echo "<tr>\n";
                    echo "<td>" . PLUGIN_SIDEBAR_HIDER_CONF_HIDDEN . "</td>\n";
                    echo "<td><input class='input_checkbox' type='checkbox' name='plugin_" . $side . "_" . $i . "' {$checked} /></td>\n";
                    echo "</tr>";
                }
                //--JAM: 2005-10-18 Added "everyone" value to clear members and myself values
                echo "<tr>\n";
                echo "<td>" . PLUGIN_SIDEBAR_HIDER_CONF_EVERYONE . "</td>\n";
                echo "<td><input class='input_radio' type='radio' name='plugin_view[" . base64_encode($plugin->instance) . "]' value='everyone' {$checked_everyone} /></td>\n";
                echo "</tr>";
                echo "<tr>\n";
                echo "<td>" . PLUGIN_SIDEBAR_HIDER_CONF_MEMBERS . "</td>\n";
                echo "<td><input class='input_radio' type='radio' name='plugin_view[" . base64_encode($plugin->instance) . "]' value='member' {$checked_member} /></td>\n";
                echo "</tr>";
                echo "<tr>\n";
                echo "<td>" . PLUGIN_SIDEBAR_HIDER_CONF_MYSELF . "</td>\n";
                echo "<td><input class='input_radio' type='radio' name='plugin_view[" . base64_encode($plugin->instance) . "]' value='myself' {$checked_myself} /></td>\n";
                echo "</tr>";
                echo "<tr>\n";
                echo "<td colspan='2'>" . GROUP . "<br >\n";
                echo "<select name='plugin_usergroups_view[" . base64_encode($plugin->instance) . "][]' multiple='multiple'>\n";
                $selected_groups = explode(',', $usergroups_viewlist[$plugin->instance]);
                foreach ($mygroups 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'], $selected_groups) ? 'selected="selected"' : '';
                    ?>
><?php 
                    echo function_exists('serendipity_specialchars') ? serendipity_specialchars($group['name']) : htmlspecialchars($group['name'], ENT_COMPAT, LANG_CHARSET);
                    ?>
</option>
<?php 
                }
                echo "</select></td>\n";
                echo "</tr>";
                echo "<tr>\n";
                echo "<td colspan='2'>" . PLUGIN_SIDEBAR_HIDER_CONF_CATEGORIES . "<br />\n";
                echo "\n";
                $selected = explode(',', $category_viewlist[$plugin->instance]);
                echo "<select name='plugin_category_view[" . base64_encode($plugin->instance) . "][]' multiple='multiple'>\n";
                // --JAM: 2005-10-18: The front page selection goes on the top
                echo '<option value="" ' . (in_array('', $selected) ? 'selected="selected"' : '') . '>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars(ALL_CATEGORIES) : htmlspecialchars(ALL_CATEGORIES, ENT_COMPAT, LANG_CHARSET)) . '</option>' . "\n";
                echo '<option value="' . PLUGIN_SIDEBAR_HIDER_FRONTPAGE_ID . '" ' . (in_array(PLUGIN_SIDEBAR_HIDER_FRONTPAGE_ID, $selected) ? 'selected="selected"' : '') . '>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars(PLUGIN_SIDEBAR_HIDER_FRONTPAGE_DESC) : htmlspecialchars(PLUGIN_SIDEBAR_HIDER_FRONTPAGE_DESC, ENT_COMPAT, LANG_CHARSET)) . '</option>' . "\n";
                // Now add regular categories to the selection list
                $cats = serendipity_fetchCategories();
                if (is_array($cats)) {
                    $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED);
                    foreach ($cats as $cat) {
                        echo '<option value="' . $cat['categoryid'] . '" ' . (in_array($cat['categoryid'], $selected) ? 'selected="selected"' : '') . '>' . str_repeat('&nbsp;', $cat['depth']) . (function_exists('serendipity_specialchars') ? serendipity_specialchars($cat['category_name']) : htmlspecialchars($cat['category_name'], ENT_COMPAT, LANG_CHARSET)) . '</option>' . "\n";
                    }
                }
                echo "</select></td>\n";
                echo "</tr>";
                echo "</table></div>\n";
                echo "</div>\n";
            } else {
                echo ERROR . ': ' . $plugin_data['name'] . '<br />';
            }
            $i++;
        }
    }
    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&amp;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;
    }
예제 #7
0
    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') {
                if ($_GET['fullFeed'] || $serendipity['GET']['fullFeed']) {
                    $metadata['fullFeed'] = true;
                } else {
                    $metadata['fullFeed'] = false;
                }
 function checkPlugin(&$data, &$plugins, $type)
 {
     $installable = true;
     $upgradeLink = '';
     if (in_array($data['class_name'], $plugins)) {
         $infoplugin =& serendipity_plugin_api::load_plugin($data['class_name']);
         if (is_object($infoplugin)) {
             $bag = new serendipity_property_bag();
             $infoplugin->introspect($bag);
             if ($bag->get('version') == $data['version']) {
                 $installable = false;
             } elseif (version_compare($bag->get('version'), $data['version'], '<')) {
                 $data['upgradable'] = true;
                 $data['upgrade_version'] = $data['version'];
                 $data['version'] = $bag->get('version');
                 $upgradeLink = '&amp;serendipity[spartacus_upgrade]=true';
             }
         }
     }
     $data['installable'] = $installable;
     $data['pluginPath'] = 'online_repository';
     $data['pluginlocation'] = 'Spartacus';
     $data['plugintype'] = $type;
     $data['customURI'] = '&amp;serendipity[spartacus_fetch]=' . $type . $upgradeLink;
     return true;
 }