コード例 #1
0
    function event_hook($event, &$bag, &$eventData, $addData = null)
    {
        global $serendipity;
        static $is_cache = null;
        static $use_groups = null;
        static $use_users = null;
        static $ext_joins = null;
        $hooks =& $bag->get('event_hooks');
        if ($is_cache === null) {
            $is_cache = serendipity_db_bool($this->get_config('cache', 'true'));
            $use_groups = serendipity_db_bool($this->get_config('use_groups'));
            $use_users = serendipity_db_bool($this->get_config('use_users'));
            $ext_joins = serendipity_db_bool($this->get_config('use_ext_joins'));
        }
        if (isset($hooks[$event])) {
            switch ($event) {
                case 'frontend_entryproperties_query':
                    $eventData['and'] = $this->returnQueryCondition($is_cache);
                    return true;
                    break;
                case 'backend_display':
                    $is_sticky = isset($eventData['properties']['ep_is_sticky']) && serendipity_db_bool($eventData['properties']['ep_is_sticky']) || isset($serendipity['POST']['properties']['is_sticky']) && serendipity_db_bool($serendipity['POST']['properties']['is_sticky']) ? 'checked="checked"' : '';
                    $no_frontpage = isset($eventData['properties']['ep_no_frontpage']) && serendipity_db_bool($eventData['properties']['ep_no_frontpage']) || isset($serendipity['POST']['properties']['no_frontpage']) && serendipity_db_bool($serendipity['POST']['properties']['no_frontpage']) ? 'checked="checked"' : '';
                    $hiderss = isset($eventData['properties']['ep_hiderss']) && serendipity_db_bool($eventData['properties']['ep_hiderss']) || isset($serendipity['POST']['properties']['hiderss']) && serendipity_db_bool($serendipity['POST']['properties']['hiderss']) ? 'checked="checked"' : '';
                    $access_values = array(PLUGIN_EVENT_ENTRYPROPERTIES_ACCESS_PRIVATE => 'private', PLUGIN_EVENT_ENTRYPROPERTIES_ACCESS_PUBLIC => 'public', PLUGIN_EVENT_ENTRYPROPERTIES_ACCESS_MEMBERS => 'member');
                    if (isset($eventData['properties']['ep_access'])) {
                        $access = $eventData['properties']['ep_access'];
                    } elseif (isset($serendipity['POST']['properties']['access'])) {
                        $access = $serendipity['POST']['properties']['access'];
                    } else {
                        $access = $this->get_config('default_read', 'public');
                    }
                    if (isset($eventData['properties']['ep_access_groups'])) {
                        $access_groups = explode(';', $eventData['properties']['ep_access_groups']);
                    } elseif (isset($serendipity['POST']['properties']['access_groups'])) {
                        $access_groups = $serendipity['POST']['properties']['access_groups'];
                    } else {
                        $access_groups = array();
                    }
                    if (isset($eventData['properties']['ep_access_users'])) {
                        $access_users = explode(';', $eventData['properties']['ep_access_users']);
                    } elseif (isset($serendipity['POST']['properties']['access_users'])) {
                        $access_users = $serendipity['POST']['properties']['access_users'];
                    } else {
                        $access_users = array();
                    }
                    if (isset($eventData['properties']['ep_entrypassword'])) {
                        $password = $eventData['properties']['ep_entrypassword'];
                    } elseif (isset($serendipity['POST']['properties']['entrypassword'])) {
                        $password = $serendipity['POST']['properties']['entrypassword'];
                    } else {
                        $password = '';
                    }
                    ?>
                    <div class="entryproperties">
                        <input type="hidden" name="serendipity[propertyform]" value="true" />
                        <h3><?php 
                    echo PLUGIN_EVENT_ENTRYPROPERTIES_TITLE;
                    ?>
</h3>
<?php 
                    $elements = explode(',', $this->get_config('sequence'));
                    foreach ($elements as $element) {
                        $this->showBackend($element, $eventData, $is_sticky, $no_frontpage, $hiderss, $access_values, $access, $password, $use_groups, $access_groups, $use_users, $access_users);
                    }
                    ?>
                    </div>
<?php 
                    return true;
                    break;
                case 'backend_maintenance':
                    if ($is_cache && $serendipity['serendipityUserlevel'] >= USERLEVEL_ADMIN) {
                        echo '<section id="maintenance_buildcache" class="equal_heights quick_list">';
                        echo '<h3>' . PLUGIN_EVENT_ENTRYPROPERTY_BUILDCACHE . '</h3>';
                        echo '<a class="button_link build_cache" href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=buildcache" data-delmsg="' . PLUGIN_EVENT_ENTRYPROPERTIES_CACHE_FETCHNEXT . '">' . PLUGIN_EVENT_ENTRYPROPERTY_BUILDCACHE . '</a></section>';
                    }
                    return true;
                    break;
                case 'backend_import_entry':
                    //TODO: (ph) Maybe handle caching?
                    if (is_array($addData) && !$addData['nl2br']) {
                        $props = array();
                        $props['no_nl2br'] = 'true';
                        $this->addProperties($props, $eventData);
                    }
                    break;
                case 'backend_sidebar_entries_event_display_buildcache':
                    if ($is_cache) {
                        $per_fetch = 25;
                        $page = isset($serendipity['GET']['page']) ? $serendipity['GET']['page'] : 1;
                        $from = ($page - 1) * $per_fetch;
                        $to = $page * $per_fetch;
                        printf('<h2>' . PLUGIN_EVENT_ENTRYPROPERTIES_CACHE_FETCHNO, $from, $to);
                        $entries = serendipity_fetchEntries(null, true, $per_fetch, false, false, 'timestamp DESC', '', true);
                        $total = serendipity_getTotalEntries();
                        printf(PLUGIN_EVENT_ENTRYPROPERTIES_CACHE_TOTAL . '</h2>', $total);
                        if (is_array($entries)) {
                            echo '<ul class="plainList">';
                            foreach ($entries as $idx => $entry) {
                                printf('<li>' . PLUGIN_EVENT_ENTRYPROPERTIES_CACHE_BUILDING, $entry['id'], serendipity_specialchars($entry['title']));
                                $this->updateCache($entry);
                                echo ' ' . PLUGIN_EVENT_ENTRYPROPERTIES_CACHED . '</li>';
                            }
                            echo '</ul>';
                        }
                        if ($to < $total) {
                            ?>
                        <script>
                            if (confirm("<?php 
                            echo serendipity_specialchars(PLUGIN_EVENT_ENTRYPROPERTIES_CACHE_FETCHNEXT);
                            ?>
")) {
                                location.href = "?serendipity[adminModule]=event_display&serendipity[adminAction]=buildcache&serendipity[page]=<?php 
                            echo $page + 1;
                            ?>
";
                            } else {
                                alert("<?php 
                            echo serendipity_specialchars(PLUGIN_EVENT_ENTRYPROPERTIES_CACHE_ABORTED);
                            ?>
");
                            }
                        </script>
<?php 
                        } else {
                            echo '<span class="msg_notice"><span class="icon-info-circled"></span>' . PLUGIN_EVENT_ENTRYPROPERTIES_CACHE_DONE . '</span>';
                        }
                    }
                    return true;
                    break;
                case 'backend_cache_entries':
                    if (!$is_cache) {
                        return true;
                    }
                    $entries = serendipity_fetchEntries(null, true, $serendipity['fetchLimit'], false, false, 'timestamp DESC', '', true);
                    if (is_array($entries) && !empty($entries)) {
                        foreach ($entries as $idx => $entry) {
                            $this->updateCache($entry);
                        }
                    }
                    return true;
                    break;
                case 'backend_cache_purge':
                    serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}entryproperties WHERE property LIKE 'ep_cache_%'");
                    break;
                case 'backend_entry_presave':
                    if (is_array($serendipity['POST']['properties'])) {
                        $this->applyProperties($serendipity['POST']['properties']);
                    }
                    break;
                case 'backend_publish':
                case 'backend_save':
                    if (!isset($eventData['id'])) {
                        return true;
                    }
                    if (!empty($serendipity['POST']['change_author']) && $serendipity['POST']['change_author'] != $eventData['id']) {
                        // Check again if the POSTed value is an author that the current user has "access" to.
                        $avail_users =& $this->getValidAuthors();
                        $new_authorid = (int) $serendipity['POST']['change_author'];
                        foreach ($avail_users as $user) {
                            if ($new_authorid == $user['authorid']) {
                                serendipity_db_query("UPDATE {$serendipity['dbPrefix']}entries SET authorid = " . $new_authorid . " WHERE id = " . (int) $eventData['id']);
                            }
                        }
                    }
                    if ($is_cache) {
                        // Previous calls to frontend_display used the "no_scramble" atteribute to not tinker with the data.
                        // We now need to call those plugins that have not yet operated before.
                        $to_addData = array('from' => 'entryproperties:' . $event);
                        serendipity_plugin_api::hook_event('frontend_display_cache', $eventData, $to_addData);
                        $serendipity['POST']['properties']['cache_body'] = $eventData['body'];
                        $serendipity['POST']['properties']['cache_extended'] = $eventData['extended'];
                    }
                    if (is_array($serendipity['POST']['properties']['access_groups']) && $serendipity['POST']['properties']['access'] != 'member') {
                        unset($serendipity['POST']['properties']['access_groups']);
                    }
                    if (is_array($serendipity['POST']['properties']['access_users']) && $serendipity['POST']['properties']['access'] != 'member') {
                        unset($serendipity['POST']['properties']['access_users']);
                    }
                    $this->addProperties($serendipity['POST']['properties'], $eventData);
                    return true;
                    break;
                case 'frontend_configure':
                    if (isset($serendipity['POST']['id']) && empty($serendipity['GET']['id'])) {
                        $serendipity['GET']['id'] =& $serendipity['POST']['id'];
                        $serendipity['GET']['subpage'] =& $serendipity['POST']['subpage'];
                    }
                    break;
                case 'frontend_entryproperties':
                    $and = $this->returnQueryCondition($is_cache);
                    $q = "SELECT entryid, property, value FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid IN (" . implode(', ', array_keys($addData)) . ") {$and}";
                    $properties = serendipity_db_query($q);
                    if (!is_array($properties)) {
                        return true;
                    }
                    foreach ($properties as $idx => $row) {
                        $eventData[$addData[$row['entryid']]]['properties'][$row['property']] = $row['value'];
                    }
                    return true;
                    break;
                case 'entry_display':
                    // PH: This is done after Garvins suggestion to patchup $eventData in case an entry
                    //     is in the process of being created. This must be done for the extended properties
                    //     to be applied in the preview.
                    if (isset($serendipity['GET']['id']) && isset($eventData[0]['properties']['ep_entrypassword'])) {
                        if ($_SESSION['entrypassword_unlocked'][$serendipity['GET']['id']] == md5($eventData[0]['properties']['ep_entrypassword']) || $eventData[0]['properties']['ep_entrypassword'] == $serendipity['POST']['entrypassword']) {
                            // Do not show login form again, once we have first enabled it.
                            $_SESSION['entrypassword_unlocked'][$serendipity['GET']['id']] = md5($eventData[0]['properties']['ep_entrypassword']);
                        } else {
                            if (is_array($eventData)) {
                                $eventData['clean_page'] = true;
                            } else {
                                $eventData = array('clean_page' => true);
                            }
                            $this->showPasswordForm = true;
                        }
                    }
                    if ($addData['preview'] && is_array($serendipity['POST']['properties']) && count($serendipity['POST']['properties']) > 0) {
                        $parr = array();
                        $supported_properties = serendipity_event_entryproperties::getSupportedProperties();
                        foreach ($supported_properties as $prop_key) {
                            if (isset($serendipity['POST']['properties'][$prop_key])) {
                                $eventData[0]['properties']['ep_' . $prop_key] = $serendipity['POST']['properties'][$prop_key];
                            }
                        }
                    }
                    break;
                case 'entries_header':
                    if ($this->showPasswordForm) {
                        echo $this->showPasswordform();
                    }
                    break;
                case 'frontend_fetchentries':
                case 'frontend_fetchentry':
                    $joins = array();
                    $conds = array();
                    if (!$ext_joins) {
                        return true;
                    }
                    if ($_SESSION['serendipityAuthedUser'] === true) {
                        $conds[] = " (ep_access.property IS NULL OR ep_access.value = 'member' OR ep_access.value = 'public' OR (ep_access.value = 'private' AND e.authorid = " . (int) $serendipity['authorid'] . ")) ";
                        if ($use_groups) {
                            $mygroups = serendipity_checkPermission(null, null, true);
                            $groupcond = array();
                            foreach ((array) $mygroups as $mygroup) {
                                $groupcond[] .= "ep_access_groups.value LIKE '%;{$mygroup};%'";
                            }
                            if (count($groupcond) > 0) {
                                $conds[] = " (ep_access_groups.property IS NULL OR (ep_access.value = 'member' AND (" . implode(' OR ', $groupcond) . ")))";
                            }
                        }
                        if ($use_users) {
                            $conds[] = " (ep_access_users.property IS NULL OR (ep_access.value = 'member' AND (ep_access_users.value LIKE '%;" . (int) $serendipity['authorid'] . ";%' OR e.authorid = " . (int) $serendipity['authorid'] . "))) ";
                        }
                    } else {
                        $conds[] = " (ep_access.property IS NULL OR ep_access.value = 'public')";
                    }
                    if (!isset($serendipity['GET']['viewAuthor']) && !isset($serendipity['plugin_vars']['tag']) && !isset($serendipity['GET']['category']) && !isset($serendipity['GET']['adminModule']) && $event == 'frontend_fetchentries' && $addData['source'] != 'search') {
                        $conds[] = " (ep_no_frontpage.property IS NULL OR ep_no_frontpage.value != 'true') ";
                        $joins[] = " LEFT OUTER JOIN {$serendipity['dbPrefix']}entryproperties ep_no_frontpage\n                                                  ON (e.id = ep_no_frontpage.entryid AND ep_no_frontpage.property = 'ep_no_frontpage')";
                    }
                    if (count($conds) > 0) {
                        $cond = implode(' AND ', $conds);
                        if (empty($eventData['and'])) {
                            $eventData['and'] = " WHERE {$cond} ";
                        } else {
                            $eventData['and'] .= " AND {$cond} ";
                        }
                    }
                    $conds = array();
                    if ((!isset($addData['noSticky']) || $addData['noSticky'] !== true) && !isset($serendipity['skipSticky'])) {
                        $conds[] = 'ep_sticky.value AS orderkey,';
                    } else {
                        $conds[] = 'e.isdraft AS orderkey,';
                    }
                    if ($is_cache && (!isset($addData['noCache']) || !$addData['noCache'])) {
                        $conds[] = 'ep_cache_extended.value AS ep_cache_extended,';
                        $conds[] = 'ep_cache_body.value     AS ep_cache_body,';
                    }
                    $cond = implode("\n", $conds);
                    if (empty($eventData['addkey'])) {
                        $eventData['addkey'] = $cond;
                    } else {
                        $eventData['addkey'] .= $cond;
                    }
                    if ($serendipity['dbType'] == 'postgres') {
                        // PostgreSQL is a bit weird here. Empty columns with NULL or "" content for
                        // orderkey would get sorted on top when using DESC, and only after those
                        // the "true" content would be inserted. Thus we order ASC in postgreSQL,
                        // and silently wonder. Thanks to Nate Johnston for working this out!
                        $cond = 'orderkey ASC';
                    } else {
                        $cond = 'orderkey DESC';
                    }
                    if (empty($eventData['orderby'])) {
                        $eventData['orderby'] = $cond;
                    } else {
                        $eventData['orderby'] = $cond . ', ' . $eventData['orderby'];
                    }
                    if ($is_cache && (!isset($addData['noCache']) || !$addData['noCache'])) {
                        $joins[] = " LEFT OUTER JOIN {$serendipity['dbPrefix']}entryproperties ep_cache_extended\n                                                  ON (e.id = ep_cache_extended.entryid AND ep_cache_extended.property = 'ep_cache_extended')";
                        $joins[] = " LEFT OUTER JOIN {$serendipity['dbPrefix']}entryproperties ep_cache_body\n                                                  ON (e.id = ep_cache_body.entryid AND ep_cache_body.property = 'ep_cache_body')";
                    }
                    $joins[] = " LEFT OUTER JOIN {$serendipity['dbPrefix']}entryproperties ep_access\n                                              ON (e.id = ep_access.entryid AND ep_access.property = 'ep_access')";
                    if ($use_groups) {
                        $joins[] = " LEFT OUTER JOIN {$serendipity['dbPrefix']}entryproperties ep_access_groups\n                                                  ON (e.id = ep_access_groups.entryid AND ep_access_groups.property = 'ep_access_groups')";
                    }
                    if ($use_users) {
                        $joins[] = " LEFT OUTER JOIN {$serendipity['dbPrefix']}entryproperties ep_access_users\n                                                  ON (e.id = ep_access_users.entryid AND ep_access_users.property = 'ep_access_users')";
                    }
                    if ((!isset($addData['noSticky']) || $addData['noSticky'] !== true) && !isset($serendipity['skipSticky'])) {
                        $joins[] = " LEFT JOIN {$serendipity['dbPrefix']}entryproperties ep_sticky\n                                            ON (e.id = ep_sticky.entryid AND ep_sticky.property = 'ep_is_sticky')";
                    }
                    $cond = implode("\n", $joins);
                    if (empty($eventData['joins'])) {
                        $eventData['joins'] = $cond;
                    } else {
                        $eventData['joins'] .= $cond;
                    }
                    return true;
                    break;
                case 'frontend_entries_rss':
                    if (is_array($eventData)) {
                        foreach ($eventData as $idx => $entry) {
                            if (is_array($entry['properties']) && isset($entry['properties']['ep_hiderss']) && $entry['properties']['ep_hiderss']) {
                                unset($eventData[$idx]['body']);
                                unset($eventData[$idx]['extended']);
                                unset($eventData[$idx]['exflag']);
                            }
                        }
                    }
                    return true;
                    break;
                case 'backend_plugins_new_instance':
                    // This hook will always push the entryproperties plugin as last in queue.
                    // Happens always when a new plugin is added.
                    // This is important because of its caching mechanism!
                    // Fetch maximum sort_order value. This will be the new value of our current plugin.
                    $q = "SELECT MAX(sort_order) as sort_order_max FROM {$serendipity['dbPrefix']}plugins WHERE placement = '" . $addData['default_placement'] . "'";
                    $rs = serendipity_db_query($q, true, 'num');
                    // Fetch current sort_order of current plugin.
                    $q = "SELECT sort_order FROM {$serendipity['dbPrefix']}plugins WHERE name = '" . $this->instance . "'";
                    $cur = serendipity_db_query($q, true, 'num');
                    // Decrease sort_order of all plugins after current plugin by one.
                    $q = "UPDATE {$serendipity['dbPrefix']}plugins SET sort_order = sort_order - 1 WHERE placement = '" . $addData['default_placement'] . "' AND sort_order > " . intval($cur[0]);
                    serendipity_db_query($q);
                    // Set current plugin as last plugin in queue.
                    $q = "UPDATE {$serendipity['dbPrefix']}plugins SET sort_order = " . intval($rs[0]) . " WHERE name = '" . $this->instance . "'";
                    serendipity_db_query($q);
                    return true;
                    break;
                default:
                    return false;
                    break;
            }
        } else {
            return false;
        }
    }
コード例 #2
0
ファイル: layout.php プロジェクト: Juuro/Dreamapp-Website
        if ($r === true) {
            echo sprintf(NO_ENTRIES_BLAHBLAH, $serendipity['GET']['searchTerm']);
            break;
        }
        echo sprintf(YOUR_SEARCH_RETURNED_BLAHBLAH, $serendipity["GET"]["searchTerm"], count($r));
        serendipity_printEntries($r);
        break;
        // Show the archive
    // Show the archive
    case "archives":
        serendipity_printArchives();
        break;
        // Welcome screen or whatever
    // Welcome screen or whatever
    default:
        serendipity_printEntries(serendipity_fetchEntries(null, true, $serendipity['fetchLimit']));
}
?>
            <?php 
echo $CLOSESHADOW;
?>
        </td>
        <td valign="top" align="left" class="serendipitySideBar">
            <?php 
//              serendipity_plugin_api::generate_plugins('left', 'span');
serendipity_plugin_api::generate_plugins('right', 'span');
?>

        </td>
    </tr>
</table>
コード例 #3
0
function mt_getRecentPostTitles($message)
{
    global $serendipity;
    $val = $message->params[1];
    $username = $val->getval();
    $val = $message->params[2];
    $password = $val->getval();
    $numposts = '10';
    if (count($message->params) > 3) {
        $val = $message->params[3];
        $numposts = $val->getval();
    }
    if (!serendipity_authenticate_author($username, $password)) {
        return new XML_RPC_Response('', XMLRPC_ERR_CODE_AUTHFAILED, XMLRPC_ERR_NAME_AUTHFAILED);
    }
    $entries = serendipity_fetchEntries('', false, $numposts, true);
    $xml_entries_vals = array();
    foreach ((array) $entries as $entry) {
        if ($entry['id']) {
            $xml_entries_vals[] = new XML_RPC_Value(array('postid' => new XML_RPC_Value($entry['id'], 'string'), 'title' => new XML_RPC_Value($entry['title'], 'string'), 'userid' => new XML_RPC_Value($entry['authorid'], 'string'), 'dateCreated' => new XML_RPC_Value(XML_RPC_iso8601_encode($entry['timestamp'], $serendipity['XMLRPC_GMT']) . ($serendipity['XMLRPC_GMT'] ? 'Z' : ''), 'dateTime.iso8601')), 'struct');
        }
    }
    $xml_entries = new XML_RPC_Value($xml_entries_vals, 'array');
    return new XML_RPC_Response($xml_entries);
}
コード例 #4
0
    function showElementEntrylist($filter = array(), $limit = 0)
    {
        global $serendipity;
        $filter_sql = implode(' AND ', $filter);
        $orderby = 'timestamp DESC';
        // Fetch the entries
        $entries = serendipity_fetchEntries(false, false, $limit, true, false, $orderby, $filter_sql);
        $rows = 0;
        if (!is_array($entries)) {
            return;
        }
        foreach ($entries as $entry) {
            $rows++;
            // Find out if the entry has been modified later than 30 minutes after creation
            if ($entry['timestamp'] <= $entry['last_modified'] - 60 * 30) {
                $lm = '<a href="#" title="' . LAST_UPDATED . ': ' . serendipity_formatTime(DATE_FORMAT_SHORT, $entry['last_modified']) . '" onclick="alert(this.title)"><img src="' . serendipity_getTemplateFile('admin/img/clock.png') . '" alt="*" style="border: 0px none ; vertical-align: bottom;" /></a>';
            } else {
                $lm = '';
            }
            if (!$serendipity['showFutureEntries'] && $entry['timestamp'] >= serendipity_serverOffsetHour()) {
                $entry_pre = '<a href="#" title="' . ENTRY_PUBLISHED_FUTURE . '" onclick="alert(this.title)"><img src="' . serendipity_getTemplateFile('admin/img/clock_future.png') . '" alt="*" style="border: 0px none ; vertical-align: bottom;" /></a> ';
            } else {
                $entry_pre = '';
            }
            if (serendipity_db_bool($entry['properties']['ep_is_sticky'])) {
                $entry_pre .= ' ' . STICKY_POSTINGS . ': ';
            }
            if (serendipity_db_bool($entry['isdraft'])) {
                $entry_pre .= ' ' . DRAFT . ': ';
            }
            ?>
            <div class="serendipity_admin_list_item serendipity_admin_list_item_<?php 
            echo $rows % 2 ? 'even' : 'uneven';
            ?>
">

                <table width="100%" cellspacing="0" cellpadding="3">
                    <tr>
                        <td>
                            <strong><?php 
            echo $entry_pre;
            ?>
<a href="?serendipity[action]=admin&amp;serendipity[adminModule]=entries&amp;serendipity[adminAction]=edit&amp;serendipity[id]=<?php 
            echo $entry['id'];
            ?>
" title="#<?php 
            echo $entry['id'];
            ?>
"><?php 
            echo serendipity_truncateString(function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET), 50);
            ?>
</a></strong>
                        </td>
                        <td align="right">
                            <?php 
            echo serendipity_formatTime(DATE_FORMAT_SHORT, $entry['timestamp']) . ' ' . $lm;
            ?>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <?php 
            echo POSTED_BY . ' ' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['author']) : htmlspecialchars($entry['author'], ENT_COMPAT, LANG_CHARSET));
            if (count($entry['categories'])) {
                echo ' ' . IN . ' ';
                $cats = array();
                foreach ($entry['categories'] as $cat) {
                    $caturl = serendipity_categoryURL($cat);
                    $cats[] = '<a href="' . $caturl . '">' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($cat['category_name']) : htmlspecialchars($cat['category_name'], ENT_COMPAT, LANG_CHARSET)) . '</a>';
                }
                echo implode(', ', $cats);
            }
            $entry['link'] = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp']));
            $entry['preview_link'] = '?serendipity[noBanner]=true&amp;serendipity[noSidebar]=true&amp;serendipity[action]=admin&amp;serendipity[adminModule]=entries&amp;serendipity[adminAction]=preview&amp;serendipity[id]=' . $entry['id'];
            ?>

                        </td>
                        <td align="right">
                            <?php 
            if (serendipity_db_bool($entry['isdraft']) || !$serendipity['showFutureEntries'] && $entry['timestamp'] >= serendipity_serverOffsetHour()) {
                ?>
                            <a target="_blank" href="<?php 
                echo $entry['preview_link'];
                ?>
&amp;<?php 
                echo serendipity_setFormToken('url');
                ?>
" title="<?php 
                echo PREVIEW . ' #' . $entry['id'];
                ?>
" class="serendipityIconLink"><img src="<?php 
                echo serendipity_getTemplateFile('admin/img/zoom.png');
                ?>
" alt="<?php 
                echo PREVIEW;
                ?>
" /><?php 
                echo PREVIEW;
                ?>
</a>
                            <?php 
            } else {
                ?>
                            <a target="_blank" href="<?php 
                echo $entry['link'];
                ?>
" title="<?php 
                echo VIEW . ' #' . $entry['id'];
                ?>
" class="serendipityIconLink"><img src="<?php 
                echo serendipity_getTemplateFile('admin/img/zoom.png');
                ?>
" alt="<?php 
                echo VIEW;
                ?>
" /><?php 
                echo VIEW;
                ?>
</a>
                            <?php 
            }
            ?>
                            <a href="?serendipity[action]=admin&amp;serendipity[adminModule]=entries&amp;serendipity[adminAction]=edit&amp;serendipity[id]=<?php 
            echo $entry['id'];
            ?>
" title="<?php 
            echo EDIT . ' #' . $entry['id'];
            ?>
" class="serendipityIconLink"><img src="<?php 
            echo serendipity_getTemplateFile('admin/img/edit.png');
            ?>
" alt="<?php 
            echo EDIT;
            ?>
" /><?php 
            echo EDIT;
            ?>
</a>
                        </td>
                    </tr>
                </table>
            </div>
<?php 
        }
        // end entries output
    }
コード例 #5
0
 function generate_content(&$title)
 {
     global $serendipity;
     $title = $this->get_config('title', $this->title);
     $current_cat = $serendipity['GET']['category'];
     $current_page = $serendipity['GET']['page'];
     $current_auth = $serendipity['GET']['viewAuthor'];
     $current_rng = $serendipity['range'];
     $serendipity['GET']['page'] = 0;
     unset($serendipity['GET']['viewAuthor']);
     unset($serendipity['range']);
     $c = $this->get_config('category');
     if ($c > 0) {
         $serendipity['GET']['category'] = (int) $c;
     }
     $showtitle = serendipity_db_bool($this->get_config('showtitle'));
     $showext = serendipity_db_bool($this->get_config('showext'));
     if (serendipity_db_bool($this->get_config('skip'))) {
         $limit = serendipity_db_limit($serendipity['fetchLimit'], $this->get_config('number'));
     } else {
         $limit = serendipity_db_limit(0, $this->get_config('number'));
     }
     $entries = serendipity_fetchEntries(null, true, $limit, false, false, 'timestamp DESC', '', false, true);
     if (is_array($entries)) {
         foreach ($entries as $i => $entry) {
             serendipity_plugin_api::hook_event('frontend_display', $entry);
             /* Pulled from serendipity_printEntries */
             $entry['link'] = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp']));
             $entry['commURL'] = serendipity_archiveURL($entry['id'], $entry['title'], 'baseURL', false, array('timestamp' => $entry['timestamp']));
             $entry['rdf_ident'] = serendipity_archiveURL($entry['id'], $entry['title'], 'baseURL', true, array('timestamp' => $entry['timestamp']));
             $entry['title'] = function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET);
             $entry['link_allow_comments'] = $serendipity['baseURL'] . 'comment.php?serendipity[switch]=enable&amp;serendipity[entry]=' . $entry['id'];
             $entry['link_deny_comments'] = $serendipity['baseURL'] . 'comment.php?serendipity[switch]=disable&amp;serendipity[entry]=' . $entry['id'];
             $entry['allow_comments'] = serendipity_db_bool($entry['allow_comments']);
             $entry['moderate_comments'] = serendipity_db_bool($entry['moderate_comments']);
             $entry['link_popup_comments'] = $serendipity['serendipityHTTPPath'] . 'comment.php?serendipity[entry_id]=' . $entry['id'] . '&amp;serendipity[type]=comments';
             $entry['link_popup_trackbacks'] = $serendipity['serendipityHTTPPath'] . 'comment.php?serendipity[entry_id]=' . $entry['id'] . '&amp;serendipity[type]=trackbacks';
             $entry['link_edit'] = $serendipity['baseURL'] . 'serendipity_admin.php?serendipity[action]=admin&amp;serendipity[adminModule]=entries&amp;serendipity[adminAction]=edit&amp;serendipity[id]=' . $entry['id'];
             $entry['link_trackback'] = $serendipity['baseURL'] . 'comment.php?type=trackback&amp;entry_id=' . $entry['id'];
             $entry['link_rdf'] = serendipity_rewriteURL(PATH_FEEDS . '/ei_' . $entry['id'] . '.rdf');
             $entry['link_viewmode_threaded'] = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?url=' . $entry['commURL'] . '&amp;serendipity[cview]=' . VIEWMODE_THREADED;
             $entry['link_viewmode_linear'] = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?url=' . $entry['commURL'] . '&amp;serendipity[cview]=' . VIEWMODE_LINEAR;
             if ($_SESSION['serendipityAuthedUser'] === true && ($_SESSION['serendipityAuthorid'] == $entry['authorid'] || serendipity_checkPermission('adminEntriesMaintainOthers'))) {
                 $entry['is_entry_owner'] = true;
             }
             if (is_array($entry['categories'])) {
                 foreach ($entry['categories'] as $k => $v) {
                     $entry['categories'][$k]['category_link'] = serendipity_categoryURL($entry['categories'][$k]);
                 }
             }
             $entries[$i] = $entry;
         }
     }
     $serendipity['smarty']->assign(array('showtitle' => $showtitle, 'showext' => $showext, 'entries' => $entries));
     $tfile = serendipity_getTemplateFile('plugin_showentries.tpl', 'serendipityPath');
     if (!$tfile) {
         $tfile = dirname(__FILE__) . '/plugin_showentries.tpl';
     }
     $inclusion = $serendipity['smarty']->security_settings[INCLUDE_ANY];
     $serendipity['smarty']->security_settings[INCLUDE_ANY] = true;
     $content = $serendipity['smarty']->fetch('file:' . $tfile);
     $serendipity['smarty']->security_settings[INCLUDE_ANY] = $inclusion;
     echo $content;
     $serendipity['GET']['category'] = $current_cat;
     $serendipity['GET']['page'] = $current_page;
     $serendipity['GET']['viewAuthor'] = $current_auth;
     $serendipity['range'] = $current_rng;
 }
コード例 #6
0
 function generate_content(&$title)
 {
     global $serendipity;
     $title = $this->get_config('title', $this->title);
     $intro = $this->get_config('intro');
     $outro = $this->get_config('outro');
     $maxlength = $this->get_config('maxlength');
     $max_entries = $this->get_config('max_entries');
     $min_age = $this->get_config('min_age');
     $max_age = $this->get_config('max_age');
     $specialage = $this->get_config('specialage');
     $displaydate = $this->get_config('displaydate', 'true');
     $dateformat = $this->get_config('dateformat');
     $full = serendipity_db_bool($this->get_config('full'));
     $displayauthor = serendipity_db_bool($this->get_config('displayauthor', false));
     if (!is_numeric($min_age) || $min_age < 0 || $specialage == 'year') {
         $min_age = 365 + date('L', serendipity_serverOffsetHour());
     }
     if (!is_numeric($max_age) || $max_age < 1 || $specialage == 'year') {
         $max_age = 365 + date('L', serendipity_serverOffsetHour());
     }
     if (!is_numeric($max_entries) || $max_entries < 1) {
         $max_entries = 5;
     }
     if (!is_numeric($maxlength) || $maxlength < 0) {
         $maxlength = 30;
     }
     if (strlen($dateformat) < 1) {
         $dateformat = '%a, %d.%m.%Y %H:%M';
     }
     $oldLim = $serendipity['fetchLimit'];
     $nowts = serendipity_serverOffsetHour();
     $maxts = mktime(23, 59, 59, date('m', $nowts), date('d', $nowts), date('Y', $nowts));
     $mints = mktime(0, 0, 0, date('m', $nowts), date('d', $nowts), date('Y', $nowts));
     $e = serendipity_fetchEntries(array($mints - $max_age * 86400, $maxts - $min_age * 86400), $full, $max_entries);
     $serendipity['fetchLimit'] = $oldLim;
     echo empty($intro) ? '' : '<div class="serendipity_history_intro">' . $intro . '</div>' . "\n";
     if (!is_array($e)) {
         return false;
     }
     if (($e_c = count($e)) == 0) {
         return false;
     }
     for ($x = 0; $x < $e_c; $x++) {
         $url = serendipity_archiveURL($e[$x]['id'], $e[$x]['title'], 'serendipityHTTPPath', true, array('timestamp' => $e[$x]['timestamp']));
         $date = $displaydate == '0' ? '' : serendipity_strftime($dateformat, $e[$x]['timestamp']);
         $author = $displayauthor ? $e[$x]['author'] . ': ' : '';
         echo '<div class="serendipity_history_info">';
         if ($displayauthor) {
             echo '<span class="serendipity_history_author">' . $author . ' </span>';
         }
         if ($displaydate) {
             echo '<span class="serendipity_history_date">' . $date . ' </span>';
         }
         $t = $maxlength == 0 || strlen($e[$x]['title']) <= $maxlength ? $e[$x]['title'] : trim(serendipity_mb('substr', $e[$x]['title'], 0, $maxlength - 3)) . ' [...]';
         echo '<a href="' . $url . '" title="' . str_replace("'", "`", serendipity_specialchars($e[$x]['title'])) . '">"' . serendipity_specialchars($t) . '"</a></div>';
         if ($full) {
             echo '<div class="serendipity_history_body">' . strip_tags($e[$x]['body']) . '</div>';
         }
     }
     echo empty($outro) ? '' : '<div class="serendipity_history_outro">' . $outro . '</div>';
 }
コード例 #7
0
/**
 * Smarty Function: Fetch and print a single or multiple entries
 *
 * @access public
 * @param   array       Smarty parameter input array:
 *                      [FETCHING]
 *                          category:        (int)     The category ID (seperate multiple with ";") to fetch entries from
 *                          viewAuthor:      (int)     The author ID (seperate multiple with ";") to fetch entries from
 *                          page:            (int)     The number of the page for paginating entries
 *                          id:              (int)     The ID of an entry. If given, only a single entry will be fetched. If left empty, multiple entries are fetched.
 *                          range:           (mixed)   Restricts fetching entries to a specific timespan. Behaves differently depending on the type:
 *                                           Numeric:
 *                                            YYYYMMDD - Shows all entries from YYYY-MM-DD.
 *                                            If DD is "00", it will show all entries from that month.
 *                                            If DD is any other number, it will show entries of that specific day.
 *                                           2-Dimensional Array:
 *                                            Key #0   - Specifies the start timestamp (unix seconds)
 *                                            Key #1   - Specifies the end timestamp (unix seconds)
 *                                           Other (null, 3-dimensional Array, ...):
 *                                            Entries newer than $modified_since will be fetched
 *                          full             (boolean) Indicates if the full entry will be fetched (body+extended: TRUE), or only the body (FALSE).
 *                          limit            (string)  Holds a "Y" or "X, Y" string that tells which entries to fetch. X is the first entry offset, Y is number of entries. If not set, the global fetchLimit will be applied (15 entries by default)
 *                          fetchDrafts      (boolean) Indicates whether drafts should be fetched (TRUE) or not
 *                          modified_since   (int)     Holds a unix timestamp to be used in conjunction with $range, to fetch all entries newer than this timestamp
 *                          orderby          (string)  Holds the SQL "ORDER BY" statement.
 *                          filter_sql       (string)  Can contain any SQL code to inject into the central SQL statement for fetching the entry
 *                          noCache          (boolean) If set to TRUE, all entries will be fetched from scratch and any caching is ignored
 *                          noSticky         (boolean) If set to TRUE, all sticky entries will NOT be fetched.
 *                          select_key       (string)  Can contain a SQL statement on which keys to select. Plugins can also set this, pay attention!
 *                          group_by         (string)  Can contain a SQL statement on how to group the query. Plugins can also set this, pay attention!
 *                          returncode       (string)  If set to "array", the array of entries will be returned. "flat-array" will only return the articles without their entryproperties. "single" will only return a 1-dimensional array. "query" will only return the used SQL.
 *                          joinauthors      (bool)    Should an SQL-join be made to the AUTHORS DB table?
 *                          joincategories   (bool)    Should an SQL-join be made to the CATEGORIES DB table?
 *                          joinown          (string)  SQL-Parts to add to the "JOIN" query
 *                          entryprops       (string)  Condition list of commaseparated entryproperties that an entry must have to be displayed (example: "ep_CustomField='customVal',ep_CustomField2='customVal2'")
 *
 *                      [PRINTING]
 *                          template:          (string)  Name of the template file to print entries with
 *                          preview:           (boolean) Indicates if this is a preview
 *                          block              (string   The name of the SMARTY block that this gets parsed into
 *                          use_hooks          (boolean  Indicates whether to apply footer/header event hooks
 *                          use_footer         (boolean  Indicates whether the pagination footer should be displayed
 *                          groupmode          (string   Indicates whether the input $entries array is already grouped in preparation for the smarty $entries output array [TRUE], or if it shall be grouped by date [FALSE]
 *                          skip_smarty_hooks  (boolean) If TRUE, no plugins will be executed at all
 *                          skip_smarty_hook   (mixed)   Can be set to an array of plugin hooks to NOT execute
 *                          prevent_reset      (boolean) If set to TRUE, the smarty $entries array will NOT be cleared. (to prevent possible duplicate output of entries)
 * @param   object      Smarty object
 * @return  string      The Smarty HTML response
 */
function serendipity_smarty_fetchPrintEntries($params, &$smarty)
{
    global $serendipity;
    static $entrycount = 0;
    static $restore_var_GET_keys = array('category', 'viewAuthor', 'page', 'hide_category');
    // A counter variable to not assign template files multiple times
    $entrycount++;
    // Default values for function calls
    if (empty($params['template'])) {
        $params['template'] = 'entries.tpl';
    }
    if (empty($params['range'])) {
        $params['range'] = null;
    }
    if (empty($params['full'])) {
        $params['full'] = true;
    }
    if (empty($params['fetchDrafts'])) {
        $params['fetchDrafts'] = false;
    }
    if (!empty($params['entryprops'])) {
        if (preg_match_all('@(.*)(!)?=[\'"]*([^\'"]+)[\'"]*(,|$)@imsU', $params['entryprops'], $m)) {
            foreach ($m[0] as $idx => $p) {
                $params['joinown'] .= "\n JOIN {$serendipity['dbPrefix']}entryproperties \n                                          AS ep" . $idx . " \n                                          ON (ep" . $idx . ".entryid = e.id AND \n                                              ep" . $idx . ".property = '" . serendipity_db_escape_string($m[1][$idx]) . "' AND \n                                              ep" . $idx . ".value " . $m[2][$idx] . "= '" . serendipity_db_escape_string($m[3][$idx]) . "') \n";
            }
        }
    }
    if (empty($params['modified_since'])) {
        $params['modified_since'] = false;
    }
    if (empty($params['orderby'])) {
        $params['orderby'] = 'timestamp DESC';
    }
    if (empty($params['noCache'])) {
        $params['noCache'] = false;
    }
    if (empty($params['noSticky'])) {
        $params['noSticky'] = false;
    }
    if (empty($params['preview'])) {
        $params['preview'] = false;
    }
    if (empty($params['block'])) {
        $params['block'] = 'smarty_entries_' . $entrycount;
    }
    if (empty($params['use_hooks'])) {
        $params['use_hooks'] = false;
    }
    if (empty($params['use_footer'])) {
        $params['use_footer'] = false;
    }
    if (empty($params['groupmode'])) {
        $params['groupmode'] = 'date';
    }
    if (empty($params['skip_smarty_hooks'])) {
        $params['skip_smarty_hooks'] = true;
    }
    if (empty($params['skip_smarty_hook'])) {
        $params['skip_smarty_hook'] = array();
    }
    if (empty($params['prevent_reset'])) {
        $params['prevent_reset'] = false;
    }
    if (empty($params['select_key'])) {
        $params['select_key'] = null;
    }
    if (empty($params['group_by'])) {
        $params['group_by'] = null;
    }
    if (empty($params['returncode'])) {
        $params['returncode'] = 'array';
    }
    if (empty($params['joinauthors'])) {
        $params['joinauthors'] = true;
    }
    if (empty($params['joincategories'])) {
        $params['joincategories'] = true;
    }
    // Some functions deal with the $serendipity array. To modify them, we need to store
    // their original contents.
    $old_var = array();
    if (!empty($params['short_archives'])) {
        $old_var['short_archives'] = $serendipity['short_archives'];
        $serendipity['short_archives'] = $params['short_archives'];
    }
    $old_var['skip_smarty_hooks'] = $serendipity['skip_smarty_hooks'];
    $serendipity['skip_smarty_hooks'] = $params['skip_smarty_hooks'];
    $old_var['skip_smarty_hook'] = $serendipity['skip_smarty_hook'];
    $serendipity['skip_smarty_hook'] = $params['skip_smarty_hook'];
    foreach ($restore_var_GET_keys as $key) {
        if (!empty($params[$key])) {
            $old_var['GET'][$key] = $serendipity['GET'][$key];
            $serendipity['GET'][$key] = $params[$key];
        }
    }
    if (!empty($params['id'])) {
        $entry = serendipity_fetchEntry('id', (int) $params['id'], $params['full'], $params['fetchDrafts']);
    } else {
        $entry = serendipity_fetchEntries($params['range'], $params['full'], $params['limit'], $params['fetchDrafts'], $params['modified_since'], $params['orderby'], $params['filter_sql'], $params['noCache'], $params['noSticky'], $params['select_key'], $params['group_by'], $params['returncode'], $params['joinauthors'], $params['joincategories'], $params['joinown']);
        // Check whether the returned entries shall be grouped specifically
        switch ($params['groupmode']) {
            case 'date':
                // No regrouping required, printEntries() does it for us.
                break;
            case 'category':
                // Regroup by primary category
                $groupdata = array();
                foreach ($entry as $k => $_entry) {
                    if (is_array($entry['categories'])) {
                        $groupkey = $entry['categories'][0];
                    } else {
                        $groupkey = 'none';
                    }
                    $groupdata[$groupkey]['entries'] =& $_entry;
                }
                $entry =& $groupdata;
                break;
        }
    }
    if ($params['returncode'] == 'query') {
        return print_r($entry, true);
    }
    serendipity_printEntries($entry, !empty($params['id']) ? true : false, $params['preview'], 'ENTRIES', false, $params['use_hooks'], $params['use_footer'], $params['groupmode'] == 'date' ? false : true);
    // Restore the $serendipity array after our modifications.
    if (isset($old_var['short_archives'])) {
        $serendipity['short_archives'] = $old_var['short_archives'];
    }
    if (is_array($old_var['GET'])) {
        foreach ($old_var['GET'] as $key => $val) {
            $serendipity['GET'][$key] = $val;
        }
    }
    $out = serendipity_smarty_fetch($params['block'], $params['template']);
    // Reset array list, because we might be in a nested code call.
    if ($params['prevent_reset'] == false) {
        $serendipity['smarty']->assign('entries', array());
    }
    $serendipity['skip_smarty_hook'] = $old_var['skip_smarty_hook'];
    $serendipity['skip_smarty_hooks'] = $old_var['skip_smarty_hooks'];
    return $out;
}
コード例 #8
0
/**
 * Shows the entry panel overview
 *
 * Shows a list of existing entries, with pagination and cookie-remember settings.
 *
 * @access public
 * @return null
 */
function serendipity_drawList()
{
    global $serendipity, $sort_order, $per_page;
    $filter_import = array('author', 'category', 'isdraft');
    $sort_import = array('perPage', 'ordermode', 'order');
    foreach ($filter_import as $f_import) {
        serendipity_restoreVar($serendipity['COOKIE']['entrylist_filter_' . $f_import], $serendipity['GET']['filter'][$f_import]);
        serendipity_JSsetCookie('entrylist_filter_' . $f_import, $serendipity['GET']['filter'][$f_import]);
    }
    foreach ($sort_import as $s_import) {
        serendipity_restoreVar($serendipity['COOKIE']['entrylist_sort_' . $s_import], $serendipity['GET']['sort'][$s_import]);
        serendipity_JSsetCookie('entrylist_sort_' . $s_import, $serendipity['GET']['sort'][$s_import]);
    }
    $perPage = !empty($serendipity['GET']['sort']['perPage']) ? $serendipity['GET']['sort']['perPage'] : $per_page[0];
    $page = (int) $serendipity['GET']['page'];
    $offSet = $perPage * $page;
    if (empty($serendipity['GET']['sort']['ordermode']) || $serendipity['GET']['sort']['ordermode'] != 'ASC') {
        $serendipity['GET']['sort']['ordermode'] = 'DESC';
    }
    if (!empty($serendipity['GET']['sort']['order']) && !empty($sort_order[$serendipity['GET']['sort']['order']])) {
        $orderby = serendipity_db_escape_string($serendipity['GET']['sort']['order'] . ' ' . $serendipity['GET']['sort']['ordermode']);
    } else {
        $orderby = 'timestamp ' . serendipity_db_escape_string($serendipity['GET']['sort']['ordermode']);
    }
    $filter = array();
    if (!empty($serendipity['GET']['filter']['author'])) {
        $filter[] = "e.authorid = '" . serendipity_db_escape_string($serendipity['GET']['filter']['author']) . "'";
    }
    if (!empty($serendipity['GET']['filter']['category'])) {
        $filter[] = "ec.categoryid = '" . serendipity_db_escape_string($serendipity['GET']['filter']['category']) . "'";
    }
    if (!empty($serendipity['GET']['filter']['isdraft'])) {
        if ($serendipity['GET']['filter']['isdraft'] == 'draft') {
            $filter[] = "e.isdraft = 'true'";
        } elseif ($serendipity['GET']['filter']['isdraft'] == 'publish') {
            $filter[] = "e.isdraft = 'false'";
        }
    }
    if (!empty($serendipity['GET']['filter']['body'])) {
        if ($serendipity['dbType'] == 'mysql') {
            $filter[] = "MATCH (title,body,extended) AGAINST ('" . serendipity_db_escape_string($serendipity['GET']['filter']['body']) . "')";
            $full = true;
        }
    }
    $filter_sql = implode(' AND ', $filter);
    // Fetch the entries
    $entries = serendipity_fetchEntries(false, false, serendipity_db_limit($offSet, $perPage + 1), true, false, $orderby, $filter_sql);
    ?>
<div class="serendipity_admin_list">
<form action="?" method="get">
    <input type="hidden" name="serendipity[action]"      value="admin"      />
    <input type="hidden" name="serendipity[adminModule]" value="entries"    />
    <input type="hidden" name="serendipity[adminAction]" value="editSelect" />
    <table width="100%" class="serendipity_admin_filters">
        <tr>
            <td class="serendipity_admin_filters_headline" colspan="6"><strong><?php 
    echo FILTERS;
    ?>
</strong> - <?php 
    echo FIND_ENTRIES;
    ?>
</td>
        </tr>
        <tr>
            <td valign="top" width="80"><?php 
    echo AUTHOR;
    ?>
</td>
            <td valign="top">
                <select name="serendipity[filter][author]">
                    <option value="">--</option>
<?php 
    $users = serendipity_fetchUsers('', null, true);
    if (is_array($users)) {
        foreach ($users as $user) {
            if (isset($user['artcount']) && $user['artcount'] < 1) {
                continue;
            }
            echo '<option value="' . $user['authorid'] . '" ' . (isset($serendipity['GET']['filter']['author']) && $serendipity['GET']['filter']['author'] == $user['authorid'] ? 'selected="selected"' : '') . '>' . htmlspecialchars($user['realname']) . '</option>' . "\n";
        }
    }
    ?>
              </select> <select name="serendipity[filter][isdraft]">
                    <option value="all"><?php 
    echo COMMENTS_FILTER_ALL;
    ?>
</option>
                    <option value="draft"   <?php 
    echo isset($serendipity['GET']['filter']['isdraft']) && $serendipity['GET']['filter']['isdraft'] == 'draft' ? 'selected="selected"' : '';
    ?>
><?php 
    echo DRAFT;
    ?>
</option>
                    <option value="publish" <?php 
    echo isset($serendipity['GET']['filter']['isdraft']) && $serendipity['GET']['filter']['isdraft'] == 'publish' ? 'selected="selected"' : '';
    ?>
><?php 
    echo PUBLISH;
    ?>
</option>
                </select>
            </td>
            <td valign="top" width="80"><?php 
    echo CATEGORY;
    ?>
</td>
            <td valign="top">
                <select name="serendipity[filter][category]">
                    <option value="">--</option>
<?php 
    $categories = serendipity_fetchCategories();
    $categories = serendipity_walkRecursive($categories, 'categoryid', 'parentid', VIEWMODE_THREADED);
    foreach ($categories as $cat) {
        echo '<option value="' . $cat['categoryid'] . '"' . ($serendipity['GET']['filter']['category'] == $cat['categoryid'] ? ' selected="selected"' : '') . '>' . str_repeat('&nbsp;', $cat['depth']) . htmlspecialchars($cat['category_name']) . '</option>' . "\n";
    }
    ?>
              </select>
            </td>
            <td valign="top" width="80"><?php 
    echo CONTENT;
    ?>
</td>
            <td valign="top"><input class="input_textbox" size="10" type="text" name="serendipity[filter][body]" value="<?php 
    echo isset($serendipity['GET']['filter']['body']) ? htmlspecialchars($serendipity['GET']['filter']['body']) : '';
    ?>
" /></td>
        </tr>
        <tr>
            <td class="serendipity_admin_filters_headline" colspan="6"><strong><?php 
    echo SORT_ORDER;
    ?>
</strong></td>
        </tr>
        <tr>
            <td>
                <?php 
    echo SORT_BY;
    ?>
            </td>
            <td>
                <select name="serendipity[sort][order]">
<?php 
    foreach ($sort_order as $so_key => $so_val) {
        echo '<option value="' . $so_key . '" ' . (isset($serendipity['GET']['sort']['order']) && $serendipity['GET']['sort']['order'] == $so_key ? 'selected="selected"' : '') . '>' . $so_val . '</option>' . "\n";
    }
    ?>
              </select>
            </td>
            <td><?php 
    echo SORT_ORDER;
    ?>
</td>
            <td>
                <select name="serendipity[sort][ordermode]">
                    <option value="DESC" <?php 
    echo isset($serendipity['GET']['sort']['ordermode']) && $serendipity['GET']['sort']['ordermode'] == 'DESC' ? 'selected="selected"' : '';
    ?>
><?php 
    echo SORT_ORDER_DESC;
    ?>
</option>
                    <option value="ASC" <?php 
    echo isset($serendipity['GET']['sort']['ordermode']) && $serendipity['GET']['sort']['ordermode'] == 'ASC' ? 'selected="selected"' : '';
    ?>
><?php 
    echo SORT_ORDER_ASC;
    ?>
</option>
                </select>
            </td>
            <td><?php 
    echo ENTRIES_PER_PAGE;
    ?>
</td>
            <td>
                <select name="serendipity[sort][perPage]">
<?php 
    foreach ($per_page as $per_page_nr) {
        echo '<option value="' . $per_page_nr . '"   ' . (isset($serendipity['GET']['sort']['perPage']) && $serendipity['GET']['sort']['perPage'] == $per_page_nr ? 'selected="selected"' : '') . '>' . $per_page_nr . '</option>' . "\n";
    }
    ?>
                </select>
            </td>
        </tr>
        <tr>
            <td align="right" colspan="6"><input type="submit" name="go" value="<?php 
    echo GO;
    ?>
" class="serendipityPrettyButton input_button" /></td>
        </tr>
    </table>
    </form>

    <table class="serendipity_admin_list" cellpadding="5" width="100%">
<?php 
    if (is_array($entries)) {
        $count = count($entries);
        $qString = '?serendipity[adminModule]=entries&amp;serendipity[adminAction]=editSelect';
        foreach ((array) $serendipity['GET']['sort'] as $k => $v) {
            $qString .= '&amp;serendipity[sort][' . $k . ']=' . $v;
        }
        foreach ((array) $serendipity['GET']['filter'] as $k => $v) {
            $qString .= '&amp;serendipity[filter][' . $k . ']=' . $v;
        }
        $linkPrevious = $qString . '&amp;serendipity[page]=' . ($page - 1);
        $linkNext = $qString . '&amp;serendipity[page]=' . ($page + 1);
        ?>
        <tr>
            <td>
                <?php 
        if ($offSet > 0) {
            ?>
                    <a href="<?php 
            echo $linkPrevious;
            ?>
" class="serendipityIconLink"><img src="<?php 
            echo serendipity_getTemplateFile('admin/img/previous.png');
            ?>
" /><?php 
            echo PREVIOUS;
            ?>
</a>
                <?php 
        }
        ?>
            </td>
            <td align="right">
                <?php 
        if ($count > $perPage) {
            ?>
                    <a href="<?php 
            echo $linkNext;
            ?>
" class="serendipityIconLinkRight"><?php 
            echo NEXT;
            ?>
<img src="<?php 
            echo serendipity_getTemplateFile('admin/img/next.png');
            ?>
" /></a>
                <?php 
        }
        ?>
            </td>
        </tr>
    </table>
    <script type="text/javascript">
    function invertSelection() {
        var f = document.formMultiDelete;
        for (var i = 0; i < f.elements.length; i++) {
            if (f.elements[i].type == 'checkbox') {
                f.elements[i].checked = !(f.elements[i].checked);
            }
        }
    }
    </script>
    <form action="?" method="post" name="formMultiDelete" id="formMultiDelete">
        <?php 
        echo serendipity_setFormToken();
        ?>
        <input type="hidden" name="serendipity[action]" value="admin" />
        <input type="hidden" name="serendipity[adminModule]" value="entries" />
        <input type="hidden" name="serendipity[adminAction]" value="multidelete" />
<?php 
        // Print the entries
        $rows = 0;
        foreach ($entries as $entry) {
            $rows++;
            if ($rows > $perPage) {
                continue;
            }
            // Find out if the entry has been modified later than 30 minutes after creation
            if ($entry['timestamp'] <= $entry['last_modified'] - 60 * 30) {
                $lm = '<a href="#" title="' . LAST_UPDATED . ': ' . serendipity_formatTime(DATE_FORMAT_SHORT, $entry['last_modified']) . '" onclick="alert(this.title)"><img src="' . serendipity_getTemplateFile('admin/img/clock.png') . '" alt="*" style="border: 0px none ; vertical-align: bottom;" /></a>';
            } else {
                $lm = '';
            }
            if (!$serendipity['showFutureEntries'] && $entry['timestamp'] >= serendipity_serverOffsetHour()) {
                $entry_pre = '<a href="#" title="' . ENTRY_PUBLISHED_FUTURE . '" onclick="alert(this.title)"><img src="' . serendipity_getTemplateFile('admin/img/clock_future.png') . '" alt="*" style="border: 0px none ; vertical-align: bottom;" /></a> ';
            } else {
                $entry_pre = '';
            }
            if (serendipity_db_bool($entry['properties']['ep_is_sticky'])) {
                $entry_pre .= ' ' . STICKY_POSTINGS . ': ';
            }
            if (serendipity_db_bool($entry['isdraft'])) {
                $entry_pre .= ' ' . DRAFT . ': ';
            }
            ?>
<!--            <div class="serendipity_admin_list_item serendipity_admin_list_item_<?php 
            echo $rows % 2 ? 'even' : 'uneven';
            ?>
"> -->
            <div class="serendipity_admin_list_item serendipity_admin_list_item_<?php 
            echo $rows % 2 ? 'even' : 'uneven';
            ?>
">

                <table width="100%" cellspacing="0" cellpadding="3">
                    <tr>
                        <td>
                            <strong><?php 
            echo $entry_pre;
            ?>
<a href="?serendipity[action]=admin&amp;serendipity[adminModule]=entries&amp;serendipity[adminAction]=edit&amp;serendipity[id]=<?php 
            echo $entry['id'];
            ?>
" title="#<?php 
            echo $entry['id'];
            ?>
"><?php 
            echo serendipity_truncateString(htmlspecialchars($entry['title']), 50);
            ?>
</a></strong>
                        </td>
                        <td align="right">
                            <?php 
            echo serendipity_formatTime(DATE_FORMAT_SHORT, $entry['timestamp']) . ' ' . $lm;
            ?>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <?php 
            echo POSTED_BY . ' ' . htmlspecialchars($entry['author']);
            if (count($entry['categories'])) {
                echo ' ' . IN . ' ';
                $cats = array();
                foreach ($entry['categories'] as $cat) {
                    $caturl = serendipity_categoryURL($cat);
                    $cats[] = '<a href="' . $caturl . '">' . htmlspecialchars($cat['category_name']) . '</a>';
                }
                echo implode(', ', $cats);
            }
            $entry['link'] = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp']));
            $entry['preview_link'] = '?serendipity[noBanner]=true&amp;serendipity[noSidebar]=true&amp;serendipity[action]=admin&amp;serendipity[adminModule]=entries&amp;serendipity[adminAction]=preview&amp;serendipity[id]=' . $entry['id'];
            ?>

                        </td>
                        <td align="right">
                            <?php 
            if (serendipity_db_bool($entry['isdraft']) || !$serendipity['showFutureEntries'] && $entry['timestamp'] >= serendipity_serverOffsetHour()) {
                ?>
                            <a target="_blank" href="<?php 
                echo $entry['preview_link'];
                ?>
" title="<?php 
                echo PREVIEW . ' #' . $entry['id'];
                ?>
" class="serendipityIconLink"><img src="<?php 
                echo serendipity_getTemplateFile('admin/img/zoom.png');
                ?>
" alt="<?php 
                echo PREVIEW;
                ?>
" /><?php 
                echo PREVIEW;
                ?>
</a>
                            <?php 
            } else {
                ?>
                            <a target="_blank" href="<?php 
                echo $entry['link'];
                ?>
" title="<?php 
                echo VIEW . ' #' . $entry['id'];
                ?>
" class="serendipityIconLink"><img src="<?php 
                echo serendipity_getTemplateFile('admin/img/zoom.png');
                ?>
" alt="<?php 
                echo VIEW;
                ?>
" /><?php 
                echo VIEW;
                ?>
</a>
                            <?php 
            }
            ?>
                            <a href="?serendipity[action]=admin&amp;serendipity[adminModule]=entries&amp;serendipity[adminAction]=edit&amp;serendipity[id]=<?php 
            echo $entry['id'];
            ?>
" title="<?php 
            echo EDIT . ' #' . $entry['id'];
            ?>
" class="serendipityIconLink"><img src="<?php 
            echo serendipity_getTemplateFile('admin/img/edit.png');
            ?>
" alt="<?php 
            echo EDIT;
            ?>
" /><?php 
            echo EDIT;
            ?>
</a>
                            <a href="?<?php 
            echo serendipity_setFormToken('url');
            ?>
&amp;serendipity[action]=admin&amp;serendipity[adminModule]=entries&amp;serendipity[adminAction]=delete&amp;serendipity[id]=<?php 
            echo $entry['id'];
            ?>
" title="<?php 
            echo DELETE . ' #' . $entry['id'];
            ?>
" class="serendipityIconLink"><img src="<?php 
            echo serendipity_getTemplateFile('admin/img/delete.png');
            ?>
" alt="<?php 
            echo DELETE;
            ?>
" /><?php 
            echo DELETE;
            ?>
</a>
                            <input class="input_checkbox" type="checkbox" name="serendipity[multiDelete][]" value="<?php 
            echo $entry['id'];
            ?>
" />
                        </td>
                    </tr>
                </table>
            </div>
<?php 
        }
        // end entries output
        ?>
        <table class="serendipity_admin_list" cellpadding="5" width="100%">
            <tr>
                <td>
                    <?php 
        if ($offSet > 0) {
            ?>
                        <a href="<?php 
            echo $linkPrevious;
            ?>
" class="serendipityIconLink"><img src="<?php 
            echo serendipity_getTemplateFile('admin/img/previous.png');
            ?>
" /><?php 
            echo PREVIOUS;
            ?>
</a>
                    <?php 
        }
        ?>
                </td>
                <td align="right">
                    <?php 
        if ($count > $perPage) {
            ?>
                        <a href="<?php 
            echo $linkNext;
            ?>
" class="serendipityIconLinkRight"><?php 
            echo NEXT;
            ?>
<img src="<?php 
            echo serendipity_getTemplateFile('admin/img/next.png');
            ?>
" /></a>
                    <?php 
        }
        ?>
                </td>
            </tr>
        </table>

        <table class="serendipity_admin_list" cellpadding="0" width="100%">
            <tr>
                <td align="right">
                    <input type="button" name="toggle" value="<?php 
        echo INVERT_SELECTIONS;
        ?>
" onclick="invertSelection()" class="serendipityPrettyButton input_button" />
                    <input type="submit" name="toggle" value="<?php 
        echo DELETE_SELECTED_ENTRIES;
        ?>
" class="serendipityPrettyButton input_button" />
                </td>
            </tr>
        </table>
        </form>

        <div class="serendipity_admin_list_item serendipity_admin_list_item_<?php 
        echo ($rows + 1) % 2 ? 'even' : 'uneven';
        ?>
">
            <table width="100%" cellspacing="0" cellpadding="3">
                    <tr>
                        <td>
                            <form action="?" method="get">
                                <input type="hidden" name="serendipity[action]"      value="admin"      />
                                <input type="hidden" name="serendipity[adminModule]" value="entries"    />
                                <input type="hidden" name="serendipity[adminAction]" value="editSelect" />
                            <?php 
        echo EDIT_ENTRY;
        ?>
: #<input class="input_textbox" type="text" size="3" name="serendipity[id]" /> <input type="submit" name="serendipity[editSubmit]" value="<?php 
        echo GO;
        ?>
" class="serendipityPrettyButton input_button" />
                            </form>
                        </td>
                    </tr>
            </table>
        </div>
 <?php 
    } else {
        // We've got nothing
        ?>
        <tr>
            <td align="center" class="serendipityAdminMsgNote">
                <img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="<?php 
        echo serendipity_getTemplateFile('admin/img/admin_msg_note.png');
        ?>
" alt="" />
                <?php 
        echo NO_ENTRIES_TO_PRINT;
        ?>
            </td>
        </tr>
    </table>
<?php 
    }
    ?>
</div>
<?php 
}
コード例 #9
0
         $term = str_replace('*', '%', $term);
         $term = serendipity_mb('strtolower', $term);
         $filter[] = "(lower(title) LIKE '%{$term}%' OR lower(body) LIKE '%{$term}%' OR lower(extended) LIKE '%{$term}%')";
         $full = true;
     } else {
         if (preg_match('@["\\+\\-\\*~<>\\(\\)]+@', $term)) {
             $filter[] = "MATCH (title,body,extended) AGAINST ('" . $term . "' IN BOOLEAN MODE)";
         } else {
             $filter[] = "MATCH (title,body,extended) AGAINST ('" . $term . "')";
         }
         $full = true;
     }
 }
 $filter_sql = implode(' AND ', $filter);
 // Fetch the entries
 $entries = serendipity_fetchEntries(false, false, serendipity_db_limit($offSet, $perPage + 1), true, false, $orderby, $filter_sql);
 $users = serendipity_fetchUsers('', 'hidden', true);
 $categories = serendipity_fetchCategories();
 $categories = serendipity_walkRecursive($categories, 'categoryid', 'parentid', VIEWMODE_THREADED);
 $data['drawList'] = true;
 $data['sort_order'] = $sort_order;
 $data['perPage'] = $perPage;
 $data['per_page'] = $per_page;
 $data['urltoken'] = serendipity_setFormToken('url');
 $data['formtoken'] = serendipity_setFormToken();
 $data['users'] = $users;
 $data['categories'] = $categories;
 $data['offSet'] = $offSet;
 $data['use_iframe'] = $serendipity['use_iframe'];
 $data['page'] = $page;
 $data['totalEntries'] = serendipity_getTotalEntries();
コード例 #10
0
 function smarty_customArchive($params, &$smarty)
 {
     global $serendipity;
     if (isset($serendipity['GET']['filter'])) {
         $params['filter'] = $serendipity['GET']['filter'];
     }
     if (isset($serendipity['POST']['filter'])) {
         $params['filter'] = $serendipity['POST']['filter'];
     }
     if (isset($serendipity['GET']['mode'])) {
         $params['mode'] = $serendipity['GET']['mode'];
     }
     if (isset($serendipity['POST']['mode'])) {
         $params['mode'] = $serendipity['POST']['mode'];
     }
     if (strtolower($params['mode']) != 'asc' && strtolower($params['mode'] != 'desc')) {
         $params['mode'] = 'asc';
     }
     if (empty($params['template'])) {
         $params['template'] = 'customarchive.tpl';
     }
     $_key_props = explode(',', $params['entryprops']);
     $key_props = array();
     $add_props = array();
     $valid_filter = false;
     foreach ($_key_props as $prop) {
         $propparts = explode(':', trim($prop));
         $prop = $propparts[0];
         if (isset($propparts[1])) {
             $add_props['ep_' . $prop] = $propparts[1];
         }
         $key_props[] = 'ep_' . $prop;
         if (empty($params['filter'])) {
             $params['filter'] = $prop;
         }
         if ($prop == $params['filter']) {
             $valid_filter = true;
         }
     }
     $props = explode(',', $params['sortfields']);
     $name_props = array();
     foreach ($props as $prop) {
         $propparts = explode(':', trim($prop));
         if (isset($propparts[1])) {
             $name_props['ep_' . $propparts[0]] = $propparts[1];
         } else {
             $name_props['ep_' . $propparts[0]] = $propparts[0];
         }
     }
     $props = explode(',', $params['searchfields']);
     $search_props = array();
     foreach ($props as $prop) {
         $propparts = explode(':', trim($prop));
         $sfields = explode('+', $propparts[0]);
         foreach ($sfields as $sfield) {
             $search_props[$propparts[2]]['fields']['ep_' . $sfield] = true;
         }
         $search_props[$propparts[2]]['type'] = strtolower($propparts[1]);
         $search_props[$propparts[2]]['key'] = md5($propparts[0]);
     }
     $searchdata = $serendipity['POST']['search'];
     if (!is_array($searchdata)) {
         $searchdata = array();
     }
     $props = explode(',', $params['valuelimit']);
     $values_props = array();
     foreach ($props as $prop) {
         $propparts = explode(':', trim($prop));
         $sfields = explode('-', $propparts[1]);
         $values_props['ep_' . $propparts[0]]['from'] = $sfields[0];
         $values_props['ep_' . $propparts[0]]['to'] = $sfields[1];
     }
     $serendipity['smarty']->assign('customarchive_props', $name_props);
     $serendipity['smarty']->assign('customarchive_keyprops', $key_props);
     $serendipity['smarty']->assign('customarchive_infoprops', $add_props);
     $serendipity['smarty']->assign('customarchive_filter', $params['filter']);
     $serendipity['smarty']->assign('customarchive_teaser', 'ep_' . $params['teaser']);
     $serendipity['smarty']->assign('customarchive_subpage', $serendipity['GET']['subpage']);
     $serendipity['smarty']->assign('customarchive_picture', 'ep_' . $params['picture']);
     $serendipity['smarty']->assign('customarchive_nextmode', strtolower($params['mode']) == 'desc' ? 'asc' : 'desc');
     $serendipity['smarty']->assign('customarchive_mode', strtolower($params['mode']));
     $serendipity['smarty']->assign('customarchive_search', $search_props);
     $serendipity['smarty']->assign('customarchive_searchdata', $searchdata);
     $lookup = array();
     foreach ($key_props as $idx => $prop) {
         $and = '';
         $lookup[$prop] = 'ep' . $idx;
         if ($prop == 'ep_' . $params['filter'] && $valid_filter) {
             $filteridx = $idx;
             $params['joinown'] .= "\n JOIN {$serendipity['dbPrefix']}entryproperties\n                                          AS ep" . $idx . "\n                                          ON (ep" . $idx . ".entryid = e.id AND\n                                              ep" . $idx . ".property = '" . serendipity_db_escape_string($prop) . "' {$and}) \n";
         } else {
             $params['joinown'] .= "\n LEFT OUTER JOIN {$serendipity['dbPrefix']}entryproperties\n                                          AS ep" . $idx . "\n                                          ON (ep" . $idx . ".entryid = e.id AND\n                                              ep" . $idx . ".property = '" . serendipity_db_escape_string($prop) . "' {$and}) \n";
         }
     }
     $sql_where = '';
     $sql_where_parts = array();
     $searchdata_from = $searchdata_to = array();
     if (is_array($serendipity['POST']['search'])) {
         foreach ($serendipity['POST']['search'] as $skey => $sdata) {
             if (!is_array($sdata)) {
                 $sdata = trim($sdata);
             }
             if (empty($sdata)) {
                 continue;
             }
             foreach ($search_props as $sdesc => $sdata2) {
                 if ($sdata2['key'] == $skey) {
                     if ($sdata2['type'] == 'text') {
                         $parts = array();
                         foreach ($sdata2['fields'] as $fieldkey => $fieldval) {
                             $parts[] = $lookup[$fieldkey] . '.value LIKE "%' . serendipity_db_escape_string($sdata) . '%"';
                         }
                         $sql_where_parts[] .= "\n(" . implode(' OR ', $parts) . ")\n";
                     } elseif ($sdata2['type'] == 'int') {
                         $parts = array();
                         foreach ($sdata2['fields'] as $fieldkey => $fieldval) {
                             if (!empty($sdata['from'])) {
                                 $parts[] = 'CAST(' . $lookup[$fieldkey] . '.value AS unsigned) >= ' . serendipity_db_escape_string($sdata['from']);
                             }
                             if (!empty($sdata['to'])) {
                                 $parts[] = 'CAST(' . $lookup[$fieldkey] . '.value AS unsigned) <= ' . serendipity_db_escape_string($sdata['to']);
                             }
                             $searchdata_from[$sdata2['key']] = $sdata['from'];
                             $searchdata_to[$sdata2['key']] = $sdata['to'];
                         }
                         if (count($parts) > 0) {
                             $sql_where_parts[] .= "\n(" . implode(' AND ', $parts) . ")\n";
                         }
                     }
                 }
             }
         }
         $sql_where = implode(" AND ", $sql_where_parts);
     } elseif (count($values_props) > 0) {
         $sql_where_parts = array();
         foreach ($values_props as $vfieldname => $vfieldvals) {
             $sql_where_parts[] = '(CAST(' . $lookup[$vfieldname] . '.value AS unsigned) >= ' . $vfieldvals['from'] . ' 
                                    AND CAST(' . $lookup[$vfieldname] . '.value AS unsigned) <= ' . $vfieldvals['to'] . ')' . "\n";
         }
         $sql_where .= implode(" AND ", $sql_where_parts);
     }
     $serendipity['smarty']->assign('customarchive_searchdata_from', $searchdata_from);
     $serendipity['smarty']->assign('customarchive_searchdata_to', $searchdata_to);
     if (empty($filteridx)) {
         $filteridx = 0;
     }
     $cat = $serendipity['GET']['category'];
     unset($serendipity['GET']['category']);
     #if ($sql_where != '') $GLOBALS['Dbdie'] = true;
     $entries = serendipity_fetchEntries(null, true, $params['limit'], false, false, 'CAST(ep' . $filteridx . '.value AS UNSIGNED) ' . $params['mode'], $sql_where, false, false, null, null, 'array', true, true, $params['joinown']);
     $dategroup = array(0 => array('entries' => $entries, 'timestamp' => time()));
     $GLOBALS['DBTEST'] = true;
     $entries = serendipity_printEntries($dategroup, true, false, 'CUSTOMARCHIVE_ENTRIES', 'return', false, false, true);
     if (!empty($cat)) {
         $serendipity['GET']['category'] = $cat;
     }
     $serendipity['smarty']->assign('customarchive_entries', $entries);
     $filename = basename($params['template']);
     $tfile = serendipity_getTemplateFile($filename, 'serendipityPath');
     if (!$tfile || $tfile == $filename) {
         $tfile = dirname(__FILE__) . '/' . $filename;
     }
     $inclusion = $serendipity['smarty']->security_settings[INCLUDE_ANY];
     $serendipity['smarty']->security_settings[INCLUDE_ANY] = true;
     $content = $serendipity['smarty']->fetch('file:' . $tfile);
     $serendipity['smarty']->security_settings[INCLUDE_ANY] = $inclusion;
     $serendipity['smarty']->assign('ENTRIES', 'xxx');
     return $content;
 }
コード例 #11
0
ファイル: rss.php プロジェクト: Juuro/Dreamapp-Website
        $entries = serendipity_fetchComments(isset($_GET['cid']) ? $_GET['cid'] : null, $serendipity['RSSfetchLimit'], 'desc', false, $_GET['type']);
        $description = $title . ' - ' . $description;
        if (isset($_GET['cid'])) {
            $title = $title . ' - ' . COMMENTS_FROM . ' "' . $latest_entry[0]['title'] . '"';
        } else {
            $title = $title . ' - ' . COMMENTS;
        }
        $comments = TRUE;
        break;
    case 'content':
    default:
        if (isset($_GET['all']) && $_GET['all']) {
            // Fetch all entries in reverse order for later importing. Fetch sticky entries as normal entries.
            $entries = serendipity_fetchEntries(null, true, '', false, false, 'id ASC', '', false, true);
        } else {
            $entries = serendipity_fetchEntries(null, true, $serendipity['RSSfetchLimit'], false, isset($modified_since) ? $modified_since : false, 'timestamp DESC', '', false, true);
        }
        break;
}
if (isset($serendipity['serendipityRealname'])) {
    $title .= ' (' . LOGIN . ': ' . $serendipity['serendipityRealname'] . ')';
}
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));
}
コード例 #12
0
    /**
     * Backend Administration Method (7): Rebuild entry auto-keyword tags
     *
     * @see     displayManageTags() case 7
     */
    function displayTagUpdate()
    {
        global $serendipity;
        $limit = 25;
        $page = isset($serendipity['GET']['page']) ? $serendipity['GET']['page'] : 1;
        $from = ($page - 1) * $limit;
        $to = $page * $limit;
        if ($serendipity['version'][0] > 1) {
            echo '<h3>';
        }
        printf(PLUGIN_EVENT_FREETAG_REBUILD_FETCHNO, $from, $to);
        $entries = serendipity_fetchEntries(null, true, $limit, false, false, 'timestamp DESC', '', true);
        $total = serendipity_getTotalEntries();
        if ($serendipity['version'][0] < 2) {
            printf(PLUGIN_EVENT_FREETAG_REBUILD_TOTAL . '<br />', $total);
        } else {
            printf(PLUGIN_EVENT_FREETAG_REBUILD_TOTAL, $total);
            echo '</h3>';
        }
        if (is_array($entries)) {
            if ($serendipity['version'][0] > 1) {
                echo '<ul class="plainList">' . "\n";
            }
            foreach ($entries as $entry) {
                unset($entry['orderkey']);
                unset($entry['loginname']);
                unset($entry['email']);
                if ($serendipity['version'][0] < 2) {
                    printf('%d - "%s"<br />', $entry['id'], self::specialchars_mapper($entry['title']));
                } else {
                    printf('    <li>%d - "%s"', $entry['id'], self::specialchars_mapper($entry['title']));
                }
                $serendipity['POST']['properties']['fake'] = 'fake';
                $current_cat = $entry['categories'];
                $entry['categories'] = array();
                foreach ($current_cat as $categoryidx => $category_data) {
                    $entry['categories'][$category_data['categoryid']] = $category_data['categoryid'];
                }
                $up = serendipity_updertEntry($entry);
                if (is_string($up)) {
                    echo "<div>{$up}</div>\n";
                }
                if ($serendipity['version'][0] < 2) {
                    echo DONE . "<br />\n";
                } else {
                    echo ' ... ' . DONE . "</li>\n";
                }
            }
            if ($serendipity['version'][0] > 1) {
                echo "</ul>\n";
            }
        }
        if ($serendipity['version'][0] < 2) {
            echo '<br />';
        }
        if ($to < $total) {
            ?>

            <script type="text/javascript">
                if (confirm("<?php 
            echo htmlspecialchars(PLUGIN_EVENT_FREETAG_REBUILD_FETCHNEXT, ENT_COMPAT, LANG_CHARSET);
            ?>
")) {
                    location.href = "?serendipity[adminModule]=event_display&serendipity[adminAction]=managetags&serendipity[tagview]=tagupdate&serendipity[page]=<?php 
            echo (int) ($page + 1);
            ?>
";
                } else {
                    alert("<?php 
            echo DONE;
            ?>
");
                }
            </script>

<?php 
        } else {
            if ($serendipity['version'][0] < 2) {
                echo '<div class="serendipity_msg_notice">' . DONE . '</div>';
            } else {
                echo '<span class="msg_notice"><span class="icon-info-circled"></span>' . DONE . "</span>\n";
            }
        }
    }
コード例 #13
0
 function event_hook($event, &$bag, &$eventData, $addData = null)
 {
     global $serendipity;
     $hooks =& $bag->get('event_hooks');
     if (isset($hooks[$event])) {
         switch ($event) {
             case 'external_plugin':
                 $uri_parts = explode('&', str_replace(array('&amp;', '?'), array('&', '&'), $eventData));
                 // Try to get request parameters from eventData name
                 if (!empty($uri_parts[1])) {
                     $reqs = explode('&', $uri_parts[1]);
                     foreach ($reqs as $id => $req) {
                         $val = explode('=', $req);
                         if (empty($_REQUEST[$val[0]])) {
                             $_REQUEST[$val[0]] = $val[1];
                         }
                     }
                 }
                 $req = trim($uri_parts[0]);
                 switch ($req) {
                     case $this->get_config('backendurl'):
                         if (!headers_sent()) {
                             header('HTTP/1.0 200');
                             header('Status: 200 OK');
                         }
                         if (isset($_REQUEST['category']) && !empty($_REQUEST['category'])) {
                             $category = trim(urldecode($_REQUEST['category']));
                         } else {
                             $category = '';
                         }
                         if (!empty($_REQUEST['authorid'])) {
                             $serendipity['GET']['viewAuthor'] = $_REQUEST['authorid'];
                         }
                         if (!empty($_REQUEST['categoryid'])) {
                             $serendipity['GET']['category'] = $_REQUEST['categoryid'];
                         }
                         if (isset($_REQUEST['num']) && !empty($_REQUEST['num'])) {
                             $num = intval(trim(urldecode($_REQUEST['num'])));
                         } else {
                             $num = 10;
                         }
                         $order = strtolower(trim(urldecode($_REQUEST['order']))) == 'asc' || strtolower(trim(urldecode($_REQUEST['order']))) == 'desc' ? trim(urldecode($_REQUEST['order'])) : "DESC";
                         $showdate = intval(trim(urldecode($_REQUEST['date']))) >= 1 ? 1 : 0;
                         $dateformat = trim(urldecode($_REQUEST['dateformat'])) != '' ? trim(urldecode($_REQUEST['dateformat'])) : "Y-m-d";
                         $showtime = intval(trim(urldecode($_REQUEST['time']))) >= 1 ? 1 : 0;
                         $timeformat = trim(urldecode($_REQUEST['timeformat'])) != '' ? trim(urldecode($_REQUEST['timeformat'])) : "g:ia";
                         $point = trim(urldecode($_REQUEST['point'])) != '' ? trim(urldecode($_REQUEST['point'])) : "";
                         $details = intval(trim(urldecode($_REQUEST['details']))) >= 1 ? 1 : 0;
                         if ($category == "") {
                             $entries = serendipity_fetchEntries(null, true, $num, false, false, 'timestamp ' . $order, '', false, true);
                         } else {
                             $entries = serendipity_fetchEntries(null, true, $num, false, false, 'timestamp ' . $order, 'c.category_name = \'' . serendipity_db_escape_string($category) . '\'', false, true);
                         }
                         for ($a = 0, $maxa = count($entries); $a < $maxa; $a++) {
                             if ($showtime == 1 && $showdate == 1) {
                                 $date = date($dateformat . " " . $timeformat, $entries[$a]['timestamp']);
                             } elseif ($showtime == 1) {
                                 $date = date($timeformat, $entries[$a]['timestamp']);
                             } elseif ($showdate == 1) {
                                 $date = date($dateformat, $entries[$a]['timestamp']);
                             } else {
                                 $date = "";
                             }
                             $entryurl = serendipity_archiveURL($entries[$a]['id'], $entries[$a]['title']);
                             if ($details <= 0) {
                                 if ($date != "") {
                                     $date = "[" . addslashes(function_exists('serendipity_specialchars') ? serendipity_specialchars($date) : htmlspecialchars($date, ENT_COMPAT, LANG_CHARSET)) . "] ";
                                 }
                                 echo "    document.write('<span class=\"blog_point\">" . (trim($point) != "" ? addslashes(function_exists('serendipity_specialchars') ? serendipity_specialchars(trim($point)) : htmlspecialchars(trim($point), ENT_COMPAT, LANG_CHARSET)) . " " : "") . "</span><span class=\"blog_date\">" . $date . "</span><a class=\"blog_link\" href=\"" . $entryurl . "\">" . addslashes($entries[$a]['title']) . "</a><br />');\n";
                             } else {
                                 echo "    document.write('<span class=\"blog_title\">" . addslashes($entries[$a]['title']) . "</span>');\n";
                                 echo "    document.write('<hr class=\"blog_hr\" />');\n";
                                 serendipity_plugin_api::hook_event('frontend_display', $entries[$a]);
                                 $entries[$a]['body'] = preg_replace('@(href|src)=("|\')(' . preg_quote($serendipity['serendipityHTTPPath']) . ')(.*)("|\')(.*)>@imsU', '\\1=\\2' . $serendipity['baseURL'] . '\\4\\2\\6>', $entries[$a]['body']);
                                 $body = str_replace("\n", "", str_replace("\r\n", "", trim($entries[$a]['body'])));
                                 if (substr($body, strlen($body) - 5, strlen($body)) == "<br />") {
                                     $body = substr($body, 0, strlen($body) - 5);
                                 }
                                 if ($date != "") {
                                     $date = ", " . addslashes(function_exists('serendipity_specialchars') ? serendipity_specialchars($date) : htmlspecialchars($date, ENT_COMPAT, LANG_CHARSET));
                                 }
                                 $body = str_replace("'", "\\'", $body);
                                 echo "    document.write('<span class=\"blog_body\">" . $body . "</span>');\n";
                                 echo "    document.write('<hr class=\"blog_hr\" />');\n";
                                 echo "    document.write('<span class=\"blog_author\">" . addslashes($entries[$a]['author']) . "</span><span class=\"blog_date\">" . $date . " <span class=\"blog_link\">[<a class=\"blog_link\" href=\"" . $entryurl . "\">&raquo;</a>]</span><br /><br />');\n";
                             }
                         }
                         break;
                 }
                 return true;
                 break;
         }
     }
     return true;
 }
コード例 #14
0
 function generate_content(&$title)
 {
     global $serendipity;
     $title = $this->get_config('title', $this->title);
     $ts = mktime(0, 0, 0, date('m'), 1);
     $add_query = '';
     $category_set = isset($serendipity['GET']['category']);
     if ($category_set) {
         $base_query = 'C' . (int) $serendipity['GET']['category'];
         $add_query = '/' . $base_query;
     }
     $max_x = $this->get_config('count', 3);
     $show_count = serendipity_db_bool($this->get_config('show_count', false));
     $hide_zero_count = serendipity_db_bool($this->get_config('hide_zero_count', false));
     $freq = $this->get_config('frequency', 'months');
     echo '<ul class="plainList">' . "\n";
     if ($serendipity['dbType'] == 'sqlite' || $serendipity['dbType'] == 'sqlite3' || $serendipity['dbType'] == 'sqlite3oo') {
         $dist_sql = 'count(e.id) AS orderkey';
     } else {
         $dist_sql = 'count(DISTINCT e.id) AS orderkey';
     }
     for ($x = 0; $x < $max_x; $x++) {
         $current_ts = $ts;
         switch ($freq) {
             case 'months':
                 switch ($serendipity['calendar']) {
                     default:
                     case 'gregorian':
                         $linkStamp = date('Y/m', $ts);
                         $ts_title = serendipity_formatTime("%B %Y", $ts, false);
                         $ts = mktime(0, 0, 0, date('m', $ts) - 1, 1, date('Y', $ts));
                         // Must be last in 'case' statement
                         break;
                     case 'persian-utf8':
                         require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php';
                         $linkStamp = persian_date_utf('Y/m', $ts);
                         $ts_title = serendipity_formatTime("%B %Y", $ts, false);
                         $ts = persian_mktime(0, 0, 0, persian_date_utf('m', $ts) - 1, 1, persian_date_utf('Y', $ts));
                         // Must be last in 'case' statement
                         break;
                 }
                 break;
             case 'weeks':
                 switch ($serendipity['calendar']) {
                     default:
                     case 'gregorian':
                         $linkStamp = date('Y/\\WW', $ts);
                         $ts_title = WEEK . ' ' . date('W, Y', $ts);
                         $ts = mktime(0, 0, 0, date('m', $ts), date('d', $ts) - 7, date('Y', $ts));
                         break;
                     case 'persian-utf8':
                         require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php';
                         $linkStamp = persian_date_utf('Y/\\WW', $ts);
                         $ts_title = WEEK . ' ' . persian_date_utf('W، Y', $ts);
                         $ts = persian_mktime(0, 0, 0, persian_date_utf('m', $ts), persian_date_utf('d', $ts) - 7, persian_date_utf('Y', $ts));
                         break;
                 }
                 break;
             case 'days':
                 switch ($serendipity['calendar']) {
                     default:
                     case 'gregorian':
                         $linkStamp = date('Y/m/d', $ts);
                         $ts_title = serendipity_formatTime("%B %e. %Y", $ts, false);
                         $ts = mktime(0, 0, 0, date('m', $ts), date('d', $ts) - 1, date('Y', $ts));
                         // Must be last in 'case' statement
                         break;
                     case 'persian-utf8':
                         require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php';
                         $linkStamp = persian_date_utf('Y/m/d', $ts);
                         $ts_title = serendipity_formatTime("%e %B %Y", $ts, false);
                         $ts = persian_mktime(0, 0, 0, persian_date_utf('m', $ts), persian_date_utf('d', $ts) - 1, persian_date_utf('Y', $ts));
                         // Must be last in 'case' statement
                         break;
                 }
                 break;
         }
         $link = serendipity_rewriteURL(PATH_ARCHIVES . '/' . $linkStamp . $add_query . '.html', 'serendipityHTTPPath');
         $html_count = '';
         $hidden_by_zero_count = false;
         if ($show_count) {
             switch ($freq) {
                 case 'months':
                     $end_ts = $current_ts + date('t', $current_ts) * 24 * 60 * 60 - 1;
                     break;
                 case 'weeks':
                     $end_ts = $current_ts + 7 * 24 * 60 * 60 - 1;
                     break;
                 case 'days':
                     $end_ts = $current_ts + 24 * 60 * 60 - 1;
                     break;
             }
             $ec = serendipity_fetchEntries(array($current_ts, $end_ts), false, '', false, false, null, '', false, true, $dist_sql, '', 'single', false, $category_set);
             if (is_array($ec)) {
                 if (empty($ec['orderkey'])) {
                     $ec['orderkey'] = '0';
                 }
                 $hidden_by_zero_count = $hide_zero_count && $ec['orderkey'] == '0';
                 $html_count .= ' (' . $ec['orderkey'] . ')';
             }
         }
         if (!$hidden_by_zero_count) {
             echo '<li><a href="' . $link . '" title="' . $ts_title . '">' . $ts_title . $html_count . '</a></li>' . "\n";
         }
     }
     echo '<li><a href="' . $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?frontpage">' . RECENT . '</a></li>' . "\n";
     echo '<li><a href="' . serendipity_rewriteURL(PATH_ARCHIVE . $add_query) . '">' . OLDER . '</a></li>' . "\n";
     echo '</ul>' . "\n";
 }
コード例 #15
0
    function event_hook($event, &$bag, &$eventData, $addlData = null)
    {
        global $serendipity;
        $hooks =& $bag->get('event_hooks');
        // I'm not really certain why this is here (since we only get called
        // for the events we hooked), but Garvin uses it, so it must be
        // important.
        if (isset($hooks[$event])) {
            $content_type = $this->get_config('content_type', 'categories');
            $placement = $this->get_config('placement', 'entry top');
            $news_cats = $this->get_config('news_cats');
            switch ($event) {
                case 'genpage':
                    // Is this the frontpage? (Garvin's algorythm; works
                    // for all cases except index.html, on my server)
                    if ($addlData['startpage']) {
                        $this->isFrontPage = true;
                    } else {
                        $this->isFrontPage = false;
                        return true;
                    }
                    // Get this newsbox's entries
                    //
                    // Hidden newsboxes don't need to waste time doing this.
                    if ($placement == 'hidden') {
                        return true;
                    }
                    // If I don't contain categories, I don't generate HTML from categories.
                    if ($content_type != 'categories') {
                        return true;
                    }
                    // If this newsbox is empty, we'd get an SQL error.
                    if (empty($news_cats)) {
                        $this->html = '<div class="newsbox"><i>No ' . $this->get_config('title', PLUGIN_EVENT_NEWSBOX_DEFAULT_TITLE) . ' today.</i></div>';
                        return true;
                    }
                    // Smarty isn't initialized yet.
                    serendipity_smarty_init();
                    // Create the SQL to fetch my entries
                    $sql = "\n" . ' e.id IN ' . "\n" . '(SELECT entryid FROM ' . $serendipity['dbPrefix'] . 'entrycat' . "\n" . ' WHERE categoryid IN (' . $news_cats . ')' . "\n" . ')';
                    // We don't want our exclusion logic to execute on *this*
                    // fetchEntries call!
                    $serendipity['newsbox'] = 'no_exclude';
                    //--JAM: yeah, it looks like a bug to me.  I wonder what else gets accidentally overwritten?
                    $oldLimit = $serendipity['fetchLimit'];
                    // We want the number of entries configurable
                    $max_entries = $this->get_config('max_entries', 5);
                    if (!is_numeric($max_entries)) {
                        $max_entries = 5;
                    }
                    $entries = serendipity_fetchEntries(null, true, $max_entries, false, false, 'timestamp DESC', $sql);
                    $serendipity['fetchLimit'] = $oldLimit;
                    unset($serendipity['newsbox']);
                    // Process our input data with new printEntries:
                    // $entries, no extended, no preview, block NEWSBOX, no smarty fetch, no hooks, footer
                    serendipity_printEntries($entries, 0, false, 'NEWSBOX', false, false, false);
                    $newsbox_data = array();
                    $newsbox_data['title'] = $this->get_config('title', PLUGIN_EVENT_NEWSBOX_DEFAULT_TITLE);
                    $newsbox_data['cats'] = explode(',', $news_cats);
                    $newsbox_data['content_type'] = $content_type;
                    $newsbox_data['isContainer'] = $content_type != 'categories';
                    $newsbox_data['multicat_action'] = $serendipity['baseURL'] . $serendipity['indexFile'];
                    $serendipity['smarty']->assign('newsbox_data', $newsbox_data);
                    $nb = serendipity_getTemplateFile('newsbox.tpl');
                    if ($nb && $nb != 'newsbox.tpl') {
                        // Template is obviously newsbox-aware
                        $this->html = serendipity_smarty_fetch('NEWSBOX', 'newsbox.tpl', false);
                    } else {
                        // Set the newsbox variable for the template, in case it's newsbox-aware
                        $serendipity['smarty']->assign('isNewsbox', true);
                        // Modify the footer link
                        $more = '<form style="display:inline;" action="' . $serendipity['baseURL'] . $serendipity['indexFile'] . '" method="post">';
                        foreach (explode(',', $news_cats) as $cat) {
                            $more .= '<input type="hidden" name="serendipity[multiCat][]" value="' . $cat . '">';
                        }
                        $more .= '<input class="serendipityPrettyButton input_button" type="submit" name="serendipity[isMultiCat]" value="More ' . $this->get_config('title', PLUGIN_EVENT_NEWSBOX_DEFAULT_TITLE) . '"></form>';
                        $serendipity['smarty']->assign('footer_info', $more);
                        // Get the HTML
                        $serendipity['skip_smarty_hooks'] = true;
                        // Don't call entries_header from the template!
                        $this->html = serendipity_smarty_fetch('NEWSBOX', 'entries.tpl', false);
                        unset($serendipity['skip_smarty_hooks']);
                        // Don't leave the newsbox variable set for the regular fetch
                        $serendipity['smarty']->clear_assign('isNewsbox');
                        // Check if the template supports newsboxes
                        // Matches class = "whatever_newsbox_whatever", taking care to allow
                        // whitespace where legal and match quote types (I don't think you
                        // can use a quote in a class name, but hey...)
                        if (preg_match('/class\\s*=\\s*(["\'])[^\\1]*newsbox/', $this->html) == 0) {
                            // Add the div; give it the default class "newsbox" and a title
                            $title = $this->get_config('title');
                            $this->html = "\n<div class=\"newsbox\"><h3 class=\"newsbox_title\">{$title}</h3>\n" . $this->html . "\n</div><!--newsbox-->\n";
                        }
                    }
                    // Done processing the newsbox
                    break;
                case 'frontend_fetchentries':
                    // Only on the frontpage
                    if (!$this->isFrontPage) {
                        return true;
                    }
                    // Don't even call this hook if we're already in this hook
                    if (isset($serendipity['newsbox']) && $serendipity['newsbox'] == 'no_exclude') {
                        return true;
                    }
                    // If we don't contain categories, we don't want to
                    // exclude categories accidentally
                    if ($content_type != 'categories') {
                        return true;
                    }
                    // Don't restrict the calendar, etc; only the main listing
                    $source = $addlData['source'];
                    if ($source != 'entries') {
                        return true;
                    }
                    // No joins required!
                    // $joins = array();
                    $conds = array();
                    if (isset($news_cats) && !empty($news_cats)) {
                        // Exclude entries in the newbox
                        $conds[] = ' (e.id NOT IN (SELECT entryid from ' . $serendipity['dbPrefix'] . 'entrycat' . ' WHERE categoryid IN (' . $news_cats . ')))';
                    }
                    if (count($conds) > 0) {
                        $cond = implode(' AND ', $conds);
                        if (empty($eventData['and'])) {
                            $eventData['and'] = " WHERE {$cond} ";
                        } else {
                            $eventData['and'] .= " AND {$cond} ";
                        }
                    }
                    return true;
                    break;
                case 'css':
                    // Can't tell if this is the fronpage or not.  Better
                    // generate the CSS, just in case.
                    if (strpos($eventData, 'newsbox') !== false) {
                        // This CSS is already newsbox-aware.
                        return true;
                    }
                    $eventData = $eventData . '
.newsbox
{
  border: 1px solid black;
  padding: 2px;
  margin-bottom: 4px;
}
.newsbox_title
{
  font-style: italic;
}
.newsbox_container
{
  border: 1px solid black;
  padding: 2px;
  margin-bottom: 4px;
  text-align: center;
  margin: 2px auto;
}
.newsbox_container .newsbox
{
  border: none;
  width: 48%;
  float: left;
  text-align: left;
  margin: 2px;
  display: inline;
}
                    ';
                    return true;
                    break;
                    // Placement cases: if configured placement equals the hook,
                    // print my HTML.  Hidden takes care of itself: there is no
                    // matching hook, so it never gets printed.  Contained
                    // newsboxes will also never match a hook; their HTML is
                    // requested by the containing newsbox.
                // Placement cases: if configured placement equals the hook,
                // print my HTML.  Hidden takes care of itself: there is no
                // matching hook, so it never gets printed.  Contained
                // newsboxes will also never match a hook; their HTML is
                // requested by the containing newsbox.
                case 'frontend_header':
                    if ($this->isFrontPage && $placement == 'page header') {
                        echo $this->getHTML();
                    }
                    return true;
                    break;
                case 'entries_header':
                    if ($this->isFrontPage && $placement == 'entry top') {
                        echo $this->getHTML();
                    }
                    return true;
                    break;
                case 'entries_footer':
                    if ($this->isFrontPage && $placement == 'entry bottom') {
                        // Entry footer markup is ugly.  Close the div.
                        echo '</div>';
                        echo $this->getHTML();
                        // Reopen the div we closed to avoid bad markup.
                        echo '<div>';
                    }
                    return true;
                    break;
                case 'frontend_footer':
                    if ($this->isFrontPage && $placement == 'page footer') {
                        echo $this->getHTML();
                    }
                    return true;
                    break;
                case 'newsbox:get_content':
                    // Custom hook to retrieve data for contained newsboxes.
                    // If the container asking for content is my container,
                    // add my content to the data array.
                    if ($addlData['id'] == $placement) {
                        // 1. Avoid recursion.
                        // 2. Go to step 1.
                        if (!$this->got_content[$addlData['id']]) {
                            $this->got_content[$addlData['id']] = true;
                            $eventData[] = $this->getHTML();
                        }
                        return true;
                    }
                    break;
                case 'newsbox:get_containers':
                    // Custom hook to find newsbox containers.  If I'm a newsbox
                    // container, return my instance ID.
                    if ($addlData['id'] != $this->instance && $this->get_config('content_type', 'categories') == 'newsboxes') {
                        $eventData[] = array('id' => $this->instance, 'name' => 'Newsbox: ' . $this->get_config('title', PLUGIN_EVENT_NEWSBOX_DEFAULT_TITLE));
                        return true;
                    }
                    break;
                default:
                    return false;
                    break;
            }
        } else {
            return false;
        }
        return true;
    }
コード例 #16
0
        $comment['fullBody'] = $comment['body'];
        $comment['summary'] = serendipity_mb('substr', $comment['body'], 0, 100);
        if (strlen($comment['fullBody']) > strlen($comment['summary'])) {
            $comment['excerpt'] = true;
            // When summary is not the full body, strip HTML tags from summary, as it might break and leave unclosed HTML.
            $comment['fullBody'] = nl2br(serendipity_specialchars($comment['fullBody']));
            $comment['summary'] = nl2br(strip_tags($comment['summary']));
        }
    }
}
$data['comments'] = $comments;
$entries = serendipity_fetchEntries(false, false, (int) $serendipity['dashboardLimit'], true, false, 'timestamp DESC', 'e.timestamp >= ' . serendipity_serverOffsetHour());
$entriesAmount = count($entries);
if ($entriesAmount < (int) $serendipity['dashboardDraftLimit']) {
    // there is still space for drafts
    $drafts = serendipity_fetchEntries(false, false, (int) $serendipity['dashboardDraftLimit'] - $entriesAmount, true, false, 'timestamp DESC', "isdraft = 'true' AND e.timestamp <= " . serendipity_serverOffsetHour());
    if (is_array($entries) && is_array($drafts)) {
        $entries = array_merge($entries, $drafts);
    } else {
        if (is_array($drafts)) {
            // $entries is not an array, thus empty
            $entries = $drafts;
        }
    }
}
$data['entries'] = $entries;
$data['urltoken'] = serendipity_setFormToken('url');
$data['token'] = serendipity_setFormToken();
$data['no_create'] = $serendipity['no_create'];
echo serendipity_smarty_show('admin/overview.inc.tpl', $data);
/* vim: set sts=4 ts=4 expandtab : */
コード例 #17
0
    function displayManageTags($event, &$bag, &$eventData, $addData)
    {
        global $serendipity;
        if ($this->get_config('dbversion', 1) != 2) {
            $this->install();
            $this->set_config('dbversion', 2);
        }
        if ($serendipity['version'][0] < 2) {
            ?>
            <div style="border: 1px solid #000;" class="freetagMenu">
            <ul>
<?php 
        } else {
            ?>
            <h2><?php 
            echo PLUGIN_EVENT_FREETAG_MANAGETAGS;
            ?>
</h2>

            <div class="freetagMenu">
            <ul class="plainList clearfix">
<?php 
        }
        ?>
                <li><a class="button_link" href="<?php 
        echo FREETAG_MANAGE_URL;
        ?>
&amp;serendipity[tagview]=all"><?php 
        echo PLUGIN_EVENT_FREETAG_MANAGE_ALL;
        ?>
</a></li>
                <li><a class="button_link" href="<?php 
        echo FREETAG_MANAGE_URL;
        ?>
&amp;serendipity[tagview]=leaf"><?php 
        echo PLUGIN_EVENT_FREETAG_MANAGE_LEAF;
        ?>
</a></li>
                <li><a class="button_link" href="<?php 
        echo FREETAG_MANAGE_URL;
        ?>
&amp;serendipity[tagview]=entryuntagged"><?php 
        echo PLUGIN_EVENT_FREETAG_MANAGE_UNTAGGED;
        ?>
</a></li>
                <li><a class="button_link" href="<?php 
        echo FREETAG_MANAGE_URL;
        ?>
&amp;serendipity[tagview]=entryleaf"><?php 
        echo PLUGIN_EVENT_FREETAG_MANAGE_LEAFTAGGED;
        ?>
</a></li>
                <li><a class="button_link" href="<?php 
        echo FREETAG_MANAGE_URL;
        ?>
&amp;serendipity[tagview]=keywords"><?php 
        echo PLUGIN_EVENT_FREETAG_KEYWORDS;
        ?>
</a></li>
                <li><a class="button_link" href="<?php 
        echo FREETAG_MANAGE_URL;
        ?>
&amp;serendipity[tagview]=cat2tag"><?php 
        echo PLUGIN_EVENT_FREETAG_GLOBALLINKS;
        ?>
</a></li>
                <li><a class="button_link" href="<?php 
        echo FREETAG_MANAGE_URL;
        ?>
&amp;serendipity[tagview]=tagupdate" onclick="return confirm('<?php 
        echo function_exists('serendipity_specialchars') ? serendipity_specialchars(PLUGIN_EVENT_FREETAG_REBUILD_DESC) : htmlspecialchars(PLUGIN_EVENT_FREETAG_REBUILD_DESC, ENT_COMPAT, LANG_CHARSET);
        ?>
');" ><?php 
        echo PLUGIN_EVENT_FREETAG_REBUILD;
        ?>
</a></li>
                <li><a class="button_link" href="<?php 
        echo FREETAG_MANAGE_URL;
        ?>
&amp;serendipity[tagview]=cleanupmappings"><?php 
        echo PLUGIN_EVENT_FREETAG_MANAGE_CLEANUP;
        ?>
</a></li>
            </ul>
            </div>
        <?php 
        if (isset($this->eventData['GET']['tagaction']) && !empty($this->eventData['GET']['tagaction'])) {
            $this->displayTagAction();
        }
        if (isset($this->eventData['GET']['tagview'])) {
            switch ($this->eventData['GET']['tagview']) {
                case "entryuntagged":
                    $this->displayUntaggedEntries();
                    break;
                case "entryleaf":
                    $this->displayLeafTaggedEntries();
                    break;
                case "all":
                    $tags = (array) $this->getAllTags();
                    $this->displayEditTags($tags);
                    break;
                case "leaf":
                    $tags = $this->getLeafTags();
                    $this->displayEditTags($tags);
                    break;
                case 'keywords':
                    $tags = (array) $this->getAllTags();
                    $this->displayKeywordAssignment($tags);
                    break;
                case 'tagupdate':
                    $per_fetch = 25;
                    $page = isset($serendipity['GET']['page']) ? $serendipity['GET']['page'] : 1;
                    $from = ($page - 1) * $per_fetch;
                    $to = $page * $per_fetch;
                    if ($serendipity['version'][0] > 1) {
                        echo '<h3>';
                    }
                    printf(PLUGIN_EVENT_FREETAG_REBUILD_FETCHNO, $from, $to);
                    $entries = serendipity_fetchEntries(null, true, $per_fetch, false, false, 'timestamp DESC', '', true);
                    $total = serendipity_getTotalEntries();
                    if ($serendipity['version'][0] < 2) {
                        printf(PLUGIN_EVENT_FREETAG_REBUILD_TOTAL . '<br />', $total);
                    } else {
                        printf(PLUGIN_EVENT_FREETAG_REBUILD_TOTAL, $total);
                        echo '</h3>';
                    }
                    if (is_array($entries)) {
                        if ($serendipity['version'][0] > 1) {
                            echo '<ul class="plainList">';
                        }
                        foreach ($entries as $entry) {
                            unset($entry['orderkey']);
                            unset($entry['loginname']);
                            unset($entry['email']);
                            if ($serendipity['version'][0] < 2) {
                                printf('%d - "%s"<br />', $entry['id'], function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET));
                            } else {
                                printf('<li>%d - "%s"', $entry['id'], function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET));
                            }
                            $serendipity['POST']['properties']['fake'] = 'fake';
                            $current_cat = $entry['categories'];
                            $entry['categories'] = array();
                            foreach ($current_cat as $categoryidx => $category_data) {
                                $entry['categories'][$category_data['categoryid']] = $category_data['categoryid'];
                            }
                            $up = serendipity_updertEntry($entry);
                            if (is_string($up)) {
                                echo "<div>{$up}</div>\n";
                            }
                            if ($serendipity['version'][0] < 2) {
                                echo DONE . "<br />\n";
                            } else {
                                echo ' ... ' . DONE . "</li>\n";
                            }
                        }
                        if ($serendipity['version'][0] > 1) {
                            echo '</ul>';
                        }
                    }
                    if ($serendipity['version'][0] < 2) {
                        echo '<br />';
                    }
                    if ($to < $total) {
                        ?>
                        <script type="text/javascript">
                            if (confirm("<?php 
                        echo function_exists('serendipity_specialchars') ? serendipity_specialchars(PLUGIN_EVENT_FREETAG_REBUILD_FETCHNEXT) : htmlspecialchars(PLUGIN_EVENT_FREETAG_REBUILD_FETCHNEXT, ENT_COMPAT, LANG_CHARSET);
                        ?>
")) {
                                location.href = "?serendipity[adminModule]=event_display&serendipity[adminAction]=managetags&serendipity[tagview]=tagupdate&serendipity[page]=<?php 
                        echo $page + 1;
                        ?>
";
                            } else {
                                alert("<?php 
                        echo function_exists('serendipity_specialchars') ? serendipity_specialchars(DONE) : htmlspecialchars(DONE, ENT_COMPAT, LANG_CHARSET);
                        ?>
");
                            }
                        </script>
                    <?php 
                    } else {
                        if ($serendipity['version'][0] < 2) {
                            echo '<div class="serendipity_msg_notice">' . DONE . '</div>';
                        } else {
                            echo '<span class="msg_notice"><span class="icon-info-circled"></span>' . DONE . '</span>';
                        }
                    }
                    break;
                case 'cat2tag':
                    $e = serendipity_db_query("SELECT e.id, e.title, c.category_name, et.tag\n                                        FROM {$serendipity['dbPrefix']}entries AS e\n                             LEFT OUTER JOIN {$serendipity['dbPrefix']}entrycat AS ec\n                                          ON e.id = ec.entryid\n                             LEFT OUTER JOIN {$serendipity['dbPrefix']}category AS c\n                                          ON ec.categoryid = c.categoryid\n                             LEFT OUTER JOIN {$serendipity['dbPrefix']}entrytags AS et\n                                          ON e.id = et.entryid", false, 'assoc');
                    // Get all categories and tags of all entries
                    $entries = array();
                    foreach ($e as $row) {
                        $entries[$row['id']]['title'] = $row['title'];
                        $entries[$row['id']]['categories'][$row['category_name']] = $row['category_name'];
                        $entries[$row['id']]['tags'][$row['tag']] = $row['tag'];
                    }
                    // Cycle all entries
                    if ($serendipity['version'][0] > 1) {
                        echo '<ul class="plainList">';
                    }
                    foreach ($entries as $id => $props) {
                        $newtags = array();
                        // Fetch all tags that should be added
                        foreach ($props['categories'] as $tag) {
                            if (empty($tag)) {
                                continue;
                            }
                            $newtags[$tag] = $tag;
                        }
                        // Subtract all tags that already exist
                        foreach ($props['tags'] as $tag) {
                            unset($newtags[$tag]);
                        }
                        if (count($newtags) < 1) {
                            continue;
                        }
                        $this->addTagsToEntry($id, $newtags);
                        if ($serendipity['version'][0] < 2) {
                            printf(PLUGIN_EVENT_FREETAG_GLOBALCAT2TAG_ENTRY . '<br />', $id, function_exists('serendipity_specialchars') ? serendipity_specialchars($props['title']) : htmlspecialchars($props['title'], ENT_COMPAT, LANG_CHARSET), function_exists('serendipity_specialchars') ? serendipity_specialchars(implode(', ', $newtags)) : htmlspecialchars(implode(', ', $newtags), ENT_COMPAT, LANG_CHARSET));
                        } else {
                            echo '<li>';
                            printf(PLUGIN_EVENT_FREETAG_GLOBALCAT2TAG_ENTRY, $id, function_exists('serendipity_specialchars') ? serendipity_specialchars($props['title']) : htmlspecialchars($props['title'], ENT_COMPAT, LANG_CHARSET), function_exists('serendipity_specialchars') ? serendipity_specialchars(implode(', ', $newtags)) : htmlspecialchars(implode(', ', $newtags), ENT_COMPAT, LANG_CHARSET));
                            echo '</li>';
                        }
                    }
                    if ($serendipity['version'][0] > 1) {
                        echo '</ul>';
                    }
                    if ($serendipity['version'][0] < 2) {
                        echo PLUGIN_EVENT_FREETAG_GLOBALCAT2TAG . '<br />';
                    } else {
                        echo '<span class="msg_notice"><span class="icon-info-circled"></span>' . PLUGIN_EVENT_FREETAG_GLOBALCAT2TAG . '</span>';
                    }
                    break;
                case 'cleanupmappings':
                    $this->cleanupTagAssignments();
                    break;
                default:
                    if (!empty($this->eventData['GET']['tagview'])) {
                        echo "Can't execute tagview";
                    }
                    break;
            }
        }
        return true;
    }
コード例 #18
0
 function event_hook($event, &$bag, &$eventData, $addData = null)
 {
     global $serendipity;
     $hooks =& $bag->get('event_hooks');
     $links = array();
     $article_show = false;
     if (isset($hooks[$event])) {
         switch ($event) {
             case 'frontend_display':
                 if (isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id'])) {
                     $article_show = true;
                     $year = date('Y', serendipity_serverOffsetHour($eventData['timestamp']));
                     $month = date('m', serendipity_serverOffsetHour($eventData['timestamp']));
                 } else {
                     break;
                 }
             case 'entries_footer':
                 if (isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id'])) {
                     $links[] = '<a href="' . $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'plugin/articlepdf_' . $serendipity['GET']['id'] . '">' . PLUGIN_EVENT_BLOGPDF_VIEW_ENTRY . '</a>';
                 }
                 if (isset($serendipity['GET']['category'])) {
                     $cid = explode('_', $serendipity['GET']['category']);
                     if (is_numeric($cid[0])) {
                         $cat = serendipity_fetchCategoryInfo($cid[0]);
                         $links[] = '<a href="' . $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'plugin/categorypdf_' . $cid[0] . '">' . sprintf(PLUGIN_EVENT_BLOGPDF_VIEW_CATEGORY, $cat['category_name']) . '</a>';
                     }
                 }
                 if (empty($year) && empty($month) && isset($serendipity['GET']['range']) && is_numeric($serendipity['GET']['range'])) {
                     $year = substr($serendipity['GET']['range'], 0, 4);
                     $month = substr($serendipity['GET']['range'], 4, 2);
                 }
                 if (empty($year)) {
                     $year = date('Y', serendipity_serverOffsetHour());
                 }
                 if (empty($month)) {
                     $month = date('m', serendipity_serverOffsetHour());
                 }
                 $links[] = '<a href="' . $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'plugin/monthpdf_' . $year . $month . '">' . PLUGIN_EVENT_BLOGPDF_VIEW_MONTH . '</a>';
                 $links[] = '<a href="' . $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'plugin/blogpdf">' . PLUGIN_EVENT_BLOGPDF_VIEW_FULL . '</a>';
                 if ($article_show) {
                     $eventData['add_footer'] .= '<div class="serendipity_blogpdf">' . PLUGIN_EVENT_BLOGPDF_VIEW . implode(' | ', $links) . '</div>';
                 } else {
                     echo '<div class="serendipity_blogpdf">' . PLUGIN_EVENT_BLOGPDF_VIEW . implode(' | ', $links) . '</div>';
                 }
                 return true;
                 break;
             case 'external_plugin':
                 if (serendipity_db_bool($this->get_config('html2pdf'))) {
                     include_once dirname(__FILE__) . '/html2fpdf.php';
                 } elseif (serendipity_db_bool($this->get_config('updf'))) {
                     include_once dirname(__FILE__) . '/serendipity_blogupdf.inc.php';
                 } else {
                     include_once dirname(__FILE__) . '/serendipity_blogpdf.inc.php';
                 }
                 $cachetime = 60 * 60 * 24;
                 // one day
                 $parts = explode('_', $eventData);
                 if (!empty($parts[1])) {
                     $param = (int) $parts[1];
                 } else {
                     $param = null;
                 }
                 $methods = array('blogpdf', 'articlepdf', 'monthpdf', 'categorypdf');
                 if (!in_array($parts[0], $methods)) {
                     return;
                 }
                 if (serendipity_db_bool($this->get_config('html2pdf'))) {
                     $this->pdf = new HTML2FPDF();
                 } else {
                     $this->pdf = new PDF();
                 }
                 $this->pdf->AliasNbPages();
                 switch ($parts[0]) {
                     case 'blogpdf':
                         $feedcache = $serendipity['serendipityPath'] . 'archives/blog.pdf';
                         $entries = serendipity_fetchEntries();
                         $this->process($feedcache, $entries);
                         break;
                     case 'articlepdf':
                         $feedcache = $serendipity['serendipityPath'] . 'archives/article' . $param . '.pdf';
                         $this->single = true;
                         $entry = serendipity_fetchEntry('id', $param);
                         $this->process($feedcache, $entry);
                         break;
                     case 'monthpdf':
                         $feedcache = $serendipity['serendipityPath'] . 'archives/month' . $param . '.pdf';
                         $entries = serendipity_fetchEntries($param);
                         $this->process($feedcache, $entries);
                         break;
                     case 'categorypdf':
                         $feedcache = $serendipity['serendipityPath'] . 'archives/category' . $param . '.pdf';
                         $serendipity['GET']['category'] = $param . '_category';
                         $entries = serendipity_fetchEntries();
                         $this->process($feedcache, $entries);
                         break;
                 }
                 $this->pdf->Output();
                 return true;
                 break;
             default:
                 return false;
                 break;
         }
     } else {
         return false;
     }
 }
コード例 #19
0
    function event_hook($event, &$bag, &$eventData, $addData = null)
    {
        global $serendipity;
        $hooks =& $bag->get('event_hooks');
        $links = array();
        if (isset($hooks[$event])) {
            $sort_order = array('timestamp' => DATE, 'isdraft' => PUBLISH . '/' . DRAFT, 'a.realname' => AUTHOR, 'category_name' => CATEGORY, 'last_modified' => LAST_UPDATED, 'title' => TITLE);
            $per_page_max = 50;
            $per_page = array('12', '16', '25', $per_page_max);
            switch ($event) {
                case 'frontend_fetchentries':
                    if ($this->fetchLimit > 0) {
                        $serendipity['fetchLimit'] = $this->fetchLimit;
                    }
                    break;
                case 'frontend_configure':
                    $_SERVER['REQUEST_URI'] = str_replace('%2Fplugin%2Ffilter%2F', '/plugin/filter/', $_SERVER['REQUEST_URI']);
                    break;
                case 'entries_footer':
                    $link = $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'plugin/filter/';
                    ?>
<div id="filter_entries_container">
    <br />
    <hr />
    <form action="<?php 
                    echo $link;
                    ?>
" method="get">

    <?php 
                    if ($serendipity['rewrite'] == 'none') {
                        ?>
    <input type="hidden" name="/plugin/filter/" value="" />
    <?php 
                    }
                    ?>
    <table width="100%">
        <tr>
            <td colspan="6" style="text-align: left"><strong><?php 
                    echo FILTERS;
                    ?>
</strong> - <?php 
                    echo FIND_ENTRIES;
                    ?>
</td>
        </tr>
        <tr>
            <td width="80"><?php 
                    echo AUTHOR;
                    ?>
</td>
            <td>
                <select name="filter[author]">
                    <option value="">--</option>
<?php 
                    $users = serendipity_fetchUsers();
                    if (is_array($users)) {
                        foreach ($users as $user) {
                            echo '<option value="' . $user['authorid'] . '" ' . (isset($_SESSION['filter']['author']) && $_SESSION['filter']['author'] == $user['authorid'] ? 'selected="selected"' : '') . '>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($user['realname']) : htmlspecialchars($user['realname'], ENT_COMPAT, LANG_CHARSET)) . '</option>' . "\n";
                        }
                    }
                    ?>
              </select>
            </td>
            <td width="80"><?php 
                    echo CATEGORY;
                    ?>
</td>
            <td>
                <select name="filter[category]">
                    <option value="">--</option>
<?php 
                    $categories = serendipity_fetchCategories();
                    $categories = serendipity_walkRecursive($categories, 'categoryid', 'parentid', VIEWMODE_THREADED);
                    foreach ($categories as $cat) {
                        echo '<option value="' . $cat['categoryid'] . '"' . ($_SESSION['filter']['category'] == $cat['categoryid'] ? ' selected="selected"' : '') . '>' . str_repeat('&nbsp;', $cat['depth']) . $cat['category_name'] . '</option>' . "\n";
                    }
                    ?>
              </select>
            </td>
            <td width="80"><?php 
                    echo CONTENT;
                    ?>
</td>
            <td><input size="10" type="text" name="filter[body]" value="<?php 
                    echo isset($_SESSION['filter']['body']) ? function_exists('serendipity_specialchars') ? serendipity_specialchars($_SESSION['filter']['body']) : htmlspecialchars($_SESSION['filter']['body'], ENT_COMPAT, LANG_CHARSET) : '';
                    ?>
" /></td>
        </tr>
        <tr>
            <td colspan="6" style="text-align: left"><strong><?php 
                    echo SORT_ORDER;
                    ?>
</strong></td>
        </tr>
        <tr>
            <td><?php 
                    echo SORT_BY;
                    ?>
</td>
            <td>
                <select name="sort[order]">
<?php 
                    foreach ($sort_order as $so_key => $so_val) {
                        echo '<option value="' . $so_key . '" ' . (isset($_SESSION['sort']['order']) && $_SESSION['sort']['order'] == $so_key ? 'selected="selected"' : '') . '>' . $so_val . '</option>' . "\n";
                    }
                    ?>
              </select>
            </td>
            <td><?php 
                    echo SORT_ORDER;
                    ?>
</td>
            <td>
                <select name="sort[ordermode]">
                    <option value="DESC" <?php 
                    echo isset($_SESSION['sort']['ordermode']) && $_SESSION['sort']['ordermode'] == 'DESC' ? 'selected="selected"' : '';
                    ?>
><?php 
                    echo SORT_ORDER_DESC;
                    ?>
</option>
                    <option value="ASC" <?php 
                    echo isset($_SESSION['sort']['ordermode']) && $_SESSION['sort']['ordermode'] == 'ASC' ? 'selected="selected"' : '';
                    ?>
><?php 
                    echo SORT_ORDER_ASC;
                    ?>
</option>
                </select>
            </td>
            <td><?php 
                    echo ENTRIES_PER_PAGE;
                    ?>
</td>
            <td>
                <select name="sort[perPage]">
<?php 
                    foreach ($per_page as $per_page_nr) {
                        echo '<option value="' . $per_page_nr . '"   ' . (isset($_SESSION['sort']['perPage']) && $_SESSION['sort']['perPage'] == $per_page_nr ? 'selected="selected"' : '') . '>' . $per_page_nr . '</option>' . "\n";
                    }
                    ?>
                </select>
            </td>
        </tr>
        <tr>
            <td align="right" colspan="6"><input type="submit" name="go" value="<?php 
                    echo GO;
                    ?>
" class="serendipityPrettyButton" /></td>
        </tr>
    </table>
</form>
</div>
<?php 
                    return true;
                    break;
                case 'external_plugin':
                    $uri_parts = explode('?', str_replace('&amp;', '&', $eventData));
                    $parts = explode('/', $uri_parts[0]);
                    $plugincode = $parts[0];
                    unset($parts[0]);
                    $uri = $_SERVER['REQUEST_URI'];
                    $puri = parse_url($uri);
                    $queries = explode('&', str_replace(array('%5B', '%5D'), array('[', ']'), $puri['query']));
                    foreach ($queries as $query_part) {
                        $query = explode('=', $query_part);
                        switch ($query[0]) {
                            case 'filter[author]':
                                $_GET['filter']['author'] = urldecode($query[1]);
                                break;
                            case 'filter[category]':
                                $_GET['filter']['category'] = urldecode($query[1]);
                                break;
                            case 'filter[body]':
                                $_GET['filter']['body'] = urldecode($query[1]);
                                break;
                            case 'sort[order]':
                                $_GET['sort']['order'] = urldecode($query[1]);
                                break;
                            case 'sort[ordermode]':
                                $_GET['sort']['ordermode'] = urldecode($query[1]);
                                break;
                            case 'sort[perPage]':
                                $_GET['sort']['perPage'] = urldecode($query[1]);
                                break;
                        }
                    }
                    if (is_array($_GET['filter'])) {
                        $_SESSION['filter'] = $_GET['filter'];
                    }
                    if (is_array($_GET['sort'])) {
                        $_SESSION['sort'] = $_GET['sort'];
                    }
                    /* Attempt to locate hidden variables within the URI */
                    foreach ($serendipity['uriArguments'] as $k => $v) {
                        if ($v[0] == 'P') {
                            /* Page */
                            $page = substr($v, 1);
                            if (is_numeric($page)) {
                                $serendipity['GET']['page'] = $page;
                                unset($serendipity['uriArguments'][$k]);
                            }
                        }
                    }
                    switch ($plugincode) {
                        case 'filter':
                            $perPage = (int) (!empty($_SESSION['sort']['perPage']) ? $_SESSION['sort']['perPage'] : $per_page[0]);
                            if ($perPage > $per_page_max) {
                                $perPage = $per_page_max;
                            }
                            $serendipity['fetchLimit'] = $perPage;
                            $this->fetchLimit = $perPage;
                            $page = (int) $serendipity['GET']['page'];
                            if ($page == 0) {
                                $page = 1;
                            }
                            $offSet = $perPage * ($page - 1);
                            if (empty($_SESSION['sort']['ordermode']) || $_SESSION['sort']['ordermode'] != 'ASC') {
                                $_SESSION['sort']['ordermode'] = 'DESC';
                            }
                            if (!empty($_SESSION['sort']['order']) && !empty($sort_order[$_SESSION['sort']['order']])) {
                                $orderby = serendipity_db_escape_string($_SESSION['sort']['order'] . ' ' . $_SESSION['sort']['ordermode']);
                            } else {
                                $orderby = 'timestamp ' . serendipity_db_escape_string($_SESSION['sort']['ordermode']);
                            }
                            $filter = array();
                            if (!empty($_SESSION['filter']['author'])) {
                                $filter[] = "e.authorid = '" . serendipity_db_escape_string($_SESSION['filter']['author']) . "'";
                            }
                            if (!empty($_SESSION['filter']['category'])) {
                                $filter[] = "ec.categoryid = '" . serendipity_db_escape_string($_SESSION['filter']['category']) . "'";
                            }
                            if (!empty($_SESSION['filter']['body'])) {
                                if ($serendipity['dbType'] == 'mysql') {
                                    $filter[] = "MATCH (title,body,extended) AGAINST ('" . serendipity_db_escape_string($_SESSION['filter']['body']) . "')";
                                    $full = true;
                                }
                            }
                            $filter_sql = implode(' AND ', $filter);
                            // Fetch the entries
                            $entries = serendipity_fetchEntries(false, false, serendipity_db_limit($offSet, $perPage), true, false, $orderby, $filter_sql);
                            $serendipity['smarty_raw_mode'] = true;
                            include_once S9Y_INCLUDE_PATH . 'include/genpage.inc.php';
                            serendipity_printEntries($entries);
                            $raw_data = ob_get_contents();
                            ob_end_clean();
                            $serendipity['smarty']->assign('CONTENT', $raw_data);
                            $serendipity['smarty']->assign('is_raw_mode', false);
                            serendipity_gzCompression();
                            $serendipity['smarty']->display(serendipity_getTemplateFile($serendipity['smarty_file'], 'serendipityPath'));
                            break;
                    }
                    return true;
                    break;
                default:
                    return false;
                    break;
            }
        } else {
            return false;
        }
    }