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&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; } }
/** * Creates the Footer below the entries, with pagination options and parses it to Smarty * * The list of total entries is calculated from the serendipity_getTotelEntries() function * * @param string suffix for URLs * @param int Amount of total entries * @access public * @see serendipity_getTotalEntries() * @return null */ function serendipity_printEntryFooter($suffix = '.html', $totalEntries = null) { global $serendipity; if ($totalEntries === null) { $totalEntries = serendipity_getTotalEntries(); } $limits = explode(',', $serendipity['fetchLimit']); if (!empty($limits[1])) { $limit = (int) $limits[1]; } else { $limit = (int) $limits[0]; } $totalPages = ceil($totalEntries / $limit); if (!isset($serendipity['GET']['page'])) { $serendipity['GET']['page'] = 1; } if ($totalPages <= 0) { $totalPages = 1; } if ($serendipity['GET']['page'] > 1) { $uriArguments = $serendipity['uriArguments']; $uriArguments[] = 'P' . ($serendipity['GET']['page'] - 1); $serendipity['smarty']->assign('footer_prev_page', serendipity_rewriteURL(implode('/', $uriArguments) . $suffix)); } $uriArguments = $serendipity['uriArguments']; $uriArguments[] = 'P%s'; $serendipity['smarty']->assign('footer_totalEntries', $totalEntries); $serendipity['smarty']->assign('footer_totalPages', $totalPages); $serendipity['smarty']->assign('footer_currentPage', $serendipity['GET']['page']); $serendipity['smarty']->assign('footer_pageLink', str_replace('%2A', '*', serendipity_rewriteURL(implode('/', $uriArguments) . $suffix))); $serendipity['smarty']->assign('footer_info', sprintf(PAGE_BROWSE_ENTRIES, (int) $serendipity['GET']['page'], $totalPages, $totalEntries)); if ($serendipity['GET']['page'] < $totalPages) { $uriArguments = $serendipity['uriArguments']; $uriArguments[] = 'P' . ($serendipity['GET']['page'] + 1); $serendipity['smarty']->assign('footer_next_page', serendipity_rewriteURL(implode('/', $uriArguments) . $suffix)); } }
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; ?> &serendipity[tagview]=all"><?php echo PLUGIN_EVENT_FREETAG_MANAGE_ALL; ?> </a></li> <li><a class="button_link" href="<?php echo FREETAG_MANAGE_URL; ?> &serendipity[tagview]=leaf"><?php echo PLUGIN_EVENT_FREETAG_MANAGE_LEAF; ?> </a></li> <li><a class="button_link" href="<?php echo FREETAG_MANAGE_URL; ?> &serendipity[tagview]=entryuntagged"><?php echo PLUGIN_EVENT_FREETAG_MANAGE_UNTAGGED; ?> </a></li> <li><a class="button_link" href="<?php echo FREETAG_MANAGE_URL; ?> &serendipity[tagview]=entryleaf"><?php echo PLUGIN_EVENT_FREETAG_MANAGE_LEAFTAGGED; ?> </a></li> <li><a class="button_link" href="<?php echo FREETAG_MANAGE_URL; ?> &serendipity[tagview]=keywords"><?php echo PLUGIN_EVENT_FREETAG_KEYWORDS; ?> </a></li> <li><a class="button_link" href="<?php echo FREETAG_MANAGE_URL; ?> &serendipity[tagview]=cat2tag"><?php echo PLUGIN_EVENT_FREETAG_GLOBALLINKS; ?> </a></li> <li><a class="button_link" href="<?php echo FREETAG_MANAGE_URL; ?> &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; ?> &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; }
$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(); $data['simpleFilters'] = $serendipity['simpleFilters']; if (is_array($entries)) { $data['is_entries'] = true; $data['count'] = count($entries); $qString = '?serendipity[adminModule]=entries&serendipity[adminAction]=editSelect'; foreach ((array) $serendipity['GET']['sort'] as $k => $v) { $qString .= '&serendipity[sort][' . $k . ']=' . $v; } foreach ((array) $serendipity['GET']['filter'] as $k => $v) { $qString .= '&serendipity[filter][' . $k . ']=' . $v; } $data['linkFirst'] = $qString . '&serendipity[page]=' . 0; $data['linkPrevious'] = $qString . '&serendipity[page]=' . ($page - 1); $data['linkNext'] = $qString . '&serendipity[page]=' . ($page + 1); $data['linkLast'] = $qString . '&serendipity[page]=';
/** * 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"; } } }
// User searches // User searches case 'search': $r = serendipity_searchEntries($serendipity['GET']['searchTerm']); if (strlen($serendipity['GET']['searchTerm']) <= 3) { $serendipity['smarty']->assign(array('content_message' => SEARCH_TOO_SHORT, 'searchresult_tooShort' => true)); break; } if (is_string($r) && $r !== true) { $serendipity['smarty']->assign(array('content_message' => sprintf(SEARCH_ERROR, $serendipity['dbPrefix'], $r), 'searchresult_error' => true)); break; } elseif ($r === true) { $serendipity['smarty']->assign(array('content_message' => sprintf(NO_ENTRIES_BLAHBLAH, '<span class="searchterm">' . $serendipity['GET']['searchTerm'] . '</span>'), 'searchresult_noEntries' => true)); break; } $serendipity['smarty']->assign(array('content_message' => sprintf(YOUR_SEARCH_RETURNED_BLAHBLAH, '<span class="searchterm">' . $serendipity['GET']['searchTerm'] . '</span>', '<span class="searchresults">' . serendipity_getTotalEntries() . '</span>'), 'searchresult_results' => true, 'searchresult_fullentry' => $serendipity['GET']['fullentry'])); serendipity_printEntries($r); break; // Show the comments // Show the comments case 'comments': serendipity_printCommentsByAuthor(); // use 'content_message' for pagination? break; // Show the archive // Show the archive case 'archives': $serendipity['head_subtitle'] = ARCHIVES; $serendipity['smarty']->assign('head_subtitle', $serendipity['head_subtitle']); serendipity_printArchives(); break;