function introspect_config_item($name, &$propbag) { global $serendipity; switch ($name) { case 'base_category': if (version_compare($serendipity['version'], '0.8', '>=')) { $base_cats = serendipity_fetchCategories(); $base_cats = serendipity_walkRecursive($base_cats, 'categoryid', 'parentid', VIEWMODE_THREADED); $select['none'] = NONE; foreach ($base_cats as $cat) { $select[$cat['categoryid']] = str_repeat('-', $cat['depth']) . ' ' . $cat['category_name']; } $propbag->add('type', 'select'); $propbag->add('name', PLUGIN_EVENT_STARTCAT_CATEGORY_NAME); $propbag->add('description', PLUGIN_EVENT_STARTCAT_CATEGORY_DESC); $propbag->add('select_values', $select); } break; case 'base_categories': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_EVENT_STARTCAT_MULTICATEGORY_NAME); $propbag->add('description', PLUGIN_EVENT_STARTCAT_MULTICATEGORY_DESC); $propbag->add('default', ''); break; case 'remembercat': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_EVENT_STARTCAT_REMEMBERCAT_NAME); $propbag->add('description', PLUGIN_EVENT_STARTCAT_REMEMBERCAT_DESC); $propbag->add('default', false); break; case 'hide_category': if (version_compare($serendipity['version'], '0.8', '>=')) { $base_cats = serendipity_fetchCategories(); $base_cats = serendipity_walkRecursive($base_cats, 'categoryid', 'parentid', VIEWMODE_THREADED); $select['none'] = NONE; foreach ($base_cats as $cat) { $select[$cat['categoryid']] = str_repeat('-', $cat['depth']) . ' ' . $cat['category_name']; } $propbag->add('type', 'select'); $propbag->add('name', PLUGIN_EVENT_STARTCAT_HIDECATEGORY_NAME); $propbag->add('description', PLUGIN_EVENT_STARTCAT_HIDECATEGORY_DESC); $propbag->add('select_values', $select); } break; case 'hide_categories': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_EVENT_STARTCAT_MULTIHIDECATEGORY_NAME); $propbag->add('description', PLUGIN_EVENT_STARTCAT_MULTIHIDECATEGORY_DESC); $propbag->add('default', ''); break; default: return false; } return true; }
function introspect_config_item($name, &$propbag) { switch ($name) { case 'phoneblogz_notifyurl': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_EVENT_PHONEBLOGZ_NOTIFYURL); $propbag->add('description', ''); $propbag->add('default', PLUGIN_EVENT_PHONEBLOGZ_NOTIFYURL_DEFAULT); break; case 'phoneblogz_accesscode': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_EVENT_PHONEBLOGZ_ACCESSCODE); $propbag->add('description', ''); $propbag->add('default', ''); break; case 'phoneblogz_password': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_EVENT_PHONEBLOGZ_PASSWORD); $propbag->add('description', ''); $propbag->add('default', ''); break; case 'phoneblogz_subject': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_EVENT_PHONEBLOGZ_SUBJECT); $propbag->add('description', ''); $propbag->add('default', PLUGIN_EVENT_PHONEBLOGZ_SUBJECT_DEFAULT); break; case 'phoneblogz_text': $propbag->add('type', 'html'); $propbag->add('name', PLUGIN_EVENT_PHONEBLOGZ_TEXT); $propbag->add('description', ''); $propbag->add('default', PLUGIN_EVENT_PHONEBLOGZ_TEXT_DEFAULT); break; case 'categoryid': $base_cats = serendipity_fetchCategories(); $base_cats = serendipity_walkRecursive($base_cats, 'categoryid', 'parentid', VIEWMODE_THREADED); $select['none'] = NONE; foreach ($base_cats as $cat) { $select[$cat['categoryid']] = str_repeat('-', $cat['depth']) . ' ' . $cat['category_name']; } $propbag->add('type', 'select'); $propbag->add('name', CATEGORY); $propbag->add('description', ''); $propbag->add('select_values', $select); break; default: return false; } return true; }
function introspect_config_item($name, &$propbag) { global $serendipity; switch ($name) { case 'category': $raw_cat = serendipity_fetchCategories(); $raw_cat = serendipity_walkRecursive($raw_cat, 'categoryid', 'parentid', VIEWMODE_THREADED); $categories = array('' => NONE); if (is_array($raw_cat)) { foreach ($raw_cat as $cat) { $categories[$cat['categoryid']] = str_repeat('-', $cat['depth']) . $cat['category_name']; } } $propbag->add('type', 'select'); $propbag->add('name', PLUGIN_COMICS_CAT); $propbag->add('description', PLUGIN_COMICS_CAT_DESC); $propbag->add('select_values', $categories); $propbag->add('default', ''); break; case 'show_title': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_COMICS_TITLE); $propbag->add('description', PLUGIN_COMICS_TITLE_DESC); $propbag->add('default', 'true'); break; case 'raw': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_COMICS_RAW); $propbag->add('description', PLUGIN_COMICS_RAW_DESC); $propbag->add('default', 'true'); break; case 'hide': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_COMICS_HIDE); $propbag->add('description', PLUGIN_COMICS_HIDE_DESC); $propbag->add('default', 'true'); break; default: return false; } return true; }
function introspect_config_item($name, &$propbag) { switch ($name) { case 'beginningOfWeek': $options = array(); for ($i = 1; $i <= 7; $i++) { $options[] = serendipity_formatTime('%A', mktime(0, 0, 0, 3, $i - 1, 2004)); } $propbag->add('type', 'select'); $propbag->add('select_values', $options); $propbag->add('name', CALENDAR_BEGINNING_OF_WEEK); $propbag->add('description', CALENDAR_BOW_DESC); $propbag->add('default', 1); break; case 'enableExtEvents': $propbag->add('type', 'boolean'); $propbag->add('name', CALENDAR_ENABLE_EXTERNAL_EVENTS); $propbag->add('description', CALENDAR_EXTEVENT_DESC); $propbag->add('default', false); break; // Event Calendar: Support category! // Event Calendar: Support category! case 'category': $categories = array('all' => ALL_CATEGORIES); $cats = serendipity_fetchCategories(); if (is_array($cats)) { $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED); foreach ($cats as $cat) { $categories[$cat['categoryid']] = str_repeat(' . ', $cat['depth']) . $cat['category_name']; } } $propbag->add('type', 'select'); $propbag->add('name', CATEGORIES_PARENT_BASE); $propbag->add('description', CATEGORIES_PARENT_BASE_DESC); $propbag->add('select_values', $categories); $propbag->add('default', 'all'); break; default: return false; } return true; }
function &makeCategorySelector() { global $serendipity; $selector = ''; // We start in our own, column-spanning row $selector .= '</td></tr>'; $selector .= '<tr><td style="border-bottom: 1px solid #000; vertical-align: top">'; $selector .= '<strong>' . PLUGIN_EVENT_NEWSBOX_NEWSCATS . '</strong><br />'; $selector .= '<span style="color: rgb(94, 122, 148); font-size: 8pt;">'; $selector .= PLUGIN_EVENT_NEWSBOX_NEWSCATS_DESC . '</span><br />'; $selector .= '</td><td style="border-bottom: 1px solid #000">'; $selector .= '<strong>' . CATEGORIES . '</strong><br />'; // $selected_cats is used to set up the selections; // 'news_cats' holds the value when it's set. if (is_array($serendipity['POST']['plugin']['newscats'])) { // Someone has already selected categories $selected_cats = array(); foreach ($serendipity['POST']['plugin']['newscats'] as $idx => $id) { $selected_cats[$id] = true; } $catlist = implode(',', array_keys($selected_cats)); $this->set_config('news_cats', $catlist); } else { // Form is just being displayed; get previously selected categories // Must use default value! 'false' is very fast. $catlist = $this->get_config('news_cats', false); if (!$catlist) { $selected_cats = array(); } else { $cat_ids = explode(',', $catlist); foreach ($cat_ids as $id) { $selected_cats[$id] = true; } } } $selector .= '<select name="serendipity[plugin][newscats][]" multiple="true" size="5">'; if (is_array($cats = serendipity_fetchCategories())) { $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED); foreach ($cats as $cat) { $catid = $cat['categoryid']; $selector .= '<option value="' . $catid . '"' . (isset($selected_cats[$catid]) ? ' selected="selected"' : '') . '>' . str_repeat(' ', $cat['depth']) . $cat['category_name'] . '</option>' . "\n"; } } $selector .= '</select>'; $selector .= '</td></tr>'; return $selector; }
/** * Recursively walks an 1-dimensional array to map parent IDs and depths, depending on the nested array set. * * Used for sorting a list of comments, for example. The list of comment is iterated, and the nesting level is calculated, and the array will be sorted to represent the amount of nesting. * * @access public * @param array Input array to investigate [consecutively sliced for recursive calls] * @param string Array index name to indicate the ID value of an array index * @param string Array index name to indicate the PARENT ID value of an array index, matched against the $child_name value * @param int The parent id to check an element against for recursive nesting * @param int The current depth of the cycled array * @return array The sorted and shiny polished result array */ function serendipity_walkRecursive($ary, $child_name = 'id', $parent_name = 'parent_id', $parentid = 0, $depth = 0) { global $serendipity; static $_resArray; static $_remain; if (!is_array($ary) || sizeof($ary) == 0) { return array(); } if ($parentid === VIEWMODE_THREADED) { $parentid = 0; } if ($depth == 0) { $_resArray = array(); $_remain = $ary; } foreach ($ary as $key => $data) { if ($parentid === VIEWMODE_LINEAR || !isset($data[$parent_name]) || $data[$parent_name] == $parentid) { $data['depth'] = $depth; $_resArray[] = $data; unset($_remain[$key]); if ($data[$child_name] && $parentid !== VIEWMODE_LINEAR) { serendipity_walkRecursive($ary, $child_name, $parent_name, $data[$child_name], $depth + 1); } } } /* We are inside a recusive child, and we need to break out */ if ($depth !== 0) { return true; } if (count($_remain) > 0) { // Remaining items need to be appended foreach ($_remain as $key => $data) { $data['depth'] = 0; $_resArray[] = $data; } } return $_resArray; }
function admin_print_sidebar(&$sidebar, $side, $plugin_list) { global $serendipity; $i = 0; $viewlist = unserialize($this->get_config('view_list')); $category_viewlist = unserialize($this->get_config('category_view_list')); $usergroups_viewlist = unserialize($this->get_config('usergroups_view_list')); $mygroups = serendipity_getGroups($serendipity['authorid']); $enabled = serendipity_db_bool($this->get_config('enable')); foreach ($sidebar as $plugin_data) { $plugin =& serendipity_plugin_api::load_plugin($plugin_data['name'], $plugin_data['authorid'], $plugin_data['path']); if (is_object($plugin)) { $checked = ""; $checked_member = ""; $checked_myself = ""; $checked_everyone = ""; if ($plugin_list[$side] && !$plugin_list[$side][$i]) { $checked = "checked='checked'"; } if ($viewlist[$plugin->instance] == 'member') { $checked_member = "checked='checked'"; } elseif ($viewlist[$plugin->instance] == 'myself' || $viewlist[$plugin->instance] == $serendipity['authorid']) { $checked_myself = "checked='checked'"; } elseif ($viewlist[$plugin->instance] == 'everyone') { $checked_everyone = "checked='checked'"; } else { $checked_everyone = "checked='checked'"; } $title = ''; ob_start(); $show_plugin = $plugin->generate_content($title); $content = ob_get_contents(); ob_end_clean(); if (empty($title)) { $title = $plugin->get_config('backend_title'); } echo "<div class='serendipitySideBarItem' style='margin-top:10px;margin-bottom:20px;'>\n"; echo "<h3 class='serendipitySideBarTitle'>{$title}</h3>\n"; echo "<div class='serendipitySideBarContent'><table>"; if ($enabled) { echo "<tr>\n"; echo "<td>" . PLUGIN_SIDEBAR_HIDER_CONF_HIDDEN . "</td>\n"; echo "<td><input class='input_checkbox' type='checkbox' name='plugin_" . $side . "_" . $i . "' {$checked} /></td>\n"; echo "</tr>"; } //--JAM: 2005-10-18 Added "everyone" value to clear members and myself values echo "<tr>\n"; echo "<td>" . PLUGIN_SIDEBAR_HIDER_CONF_EVERYONE . "</td>\n"; echo "<td><input class='input_radio' type='radio' name='plugin_view[" . base64_encode($plugin->instance) . "]' value='everyone' {$checked_everyone} /></td>\n"; echo "</tr>"; echo "<tr>\n"; echo "<td>" . PLUGIN_SIDEBAR_HIDER_CONF_MEMBERS . "</td>\n"; echo "<td><input class='input_radio' type='radio' name='plugin_view[" . base64_encode($plugin->instance) . "]' value='member' {$checked_member} /></td>\n"; echo "</tr>"; echo "<tr>\n"; echo "<td>" . PLUGIN_SIDEBAR_HIDER_CONF_MYSELF . "</td>\n"; echo "<td><input class='input_radio' type='radio' name='plugin_view[" . base64_encode($plugin->instance) . "]' value='myself' {$checked_myself} /></td>\n"; echo "</tr>"; echo "<tr>\n"; echo "<td colspan='2'>" . GROUP . "<br >\n"; echo "<select name='plugin_usergroups_view[" . base64_encode($plugin->instance) . "][]' multiple='multiple'>\n"; $selected_groups = explode(',', $usergroups_viewlist[$plugin->instance]); foreach ($mygroups as $group) { if ('USERLEVEL_' == substr($group['confvalue'], 0, 10)) { $group['name'] = constant($group['confvalue']); } ?> <option value="<?php echo $group['id']; ?> " <?php echo in_array($group['id'], $selected_groups) ? 'selected="selected"' : ''; ?> ><?php echo function_exists('serendipity_specialchars') ? serendipity_specialchars($group['name']) : htmlspecialchars($group['name'], ENT_COMPAT, LANG_CHARSET); ?> </option> <?php } echo "</select></td>\n"; echo "</tr>"; echo "<tr>\n"; echo "<td colspan='2'>" . PLUGIN_SIDEBAR_HIDER_CONF_CATEGORIES . "<br />\n"; echo "\n"; $selected = explode(',', $category_viewlist[$plugin->instance]); echo "<select name='plugin_category_view[" . base64_encode($plugin->instance) . "][]' multiple='multiple'>\n"; // --JAM: 2005-10-18: The front page selection goes on the top echo '<option value="" ' . (in_array('', $selected) ? 'selected="selected"' : '') . '>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars(ALL_CATEGORIES) : htmlspecialchars(ALL_CATEGORIES, ENT_COMPAT, LANG_CHARSET)) . '</option>' . "\n"; echo '<option value="' . PLUGIN_SIDEBAR_HIDER_FRONTPAGE_ID . '" ' . (in_array(PLUGIN_SIDEBAR_HIDER_FRONTPAGE_ID, $selected) ? 'selected="selected"' : '') . '>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars(PLUGIN_SIDEBAR_HIDER_FRONTPAGE_DESC) : htmlspecialchars(PLUGIN_SIDEBAR_HIDER_FRONTPAGE_DESC, ENT_COMPAT, LANG_CHARSET)) . '</option>' . "\n"; // Now add regular categories to the selection list $cats = serendipity_fetchCategories(); if (is_array($cats)) { $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED); foreach ($cats as $cat) { echo '<option value="' . $cat['categoryid'] . '" ' . (in_array($cat['categoryid'], $selected) ? 'selected="selected"' : '') . '>' . str_repeat(' ', $cat['depth']) . (function_exists('serendipity_specialchars') ? serendipity_specialchars($cat['category_name']) : htmlspecialchars($cat['category_name'], ENT_COMPAT, LANG_CHARSET)) . '</option>' . "\n"; } } echo "</select></td>\n"; echo "</tr>"; echo "</table></div>\n"; echo "</div>\n"; } else { echo ERROR . ': ' . $plugin_data['name'] . '<br />'; } $i++; } }
function &fetchCat($name, $selected = 0) { global $serendipity; $n = "\n"; $cat_list = '<select name="' . $name . '" multiple="multiple" size="4">'; $cat_list .= ' <option value="0"' . (empty($selected) ? ' selected="selected"' : '') . '>[' . NO_CATEGORY . ']</option>' . $n; if (is_array($cats = serendipity_fetchCategories())) { $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED); foreach ($cats as $cat) { $cat_list .= '<option value="' . $cat['categoryid'] . '"' . (in_array($cat['categoryid'], $selected) ? ' selected="selected"' : '') . '>' . str_repeat(' ', $cat['depth']) . $cat['category_name'] . '</option>' . "\n"; } } $cat_list .= '</select>'; return $cat_list; }
$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(); $data['simpleFilters'] = $serendipity['simpleFilters']; if (is_array($entries)) { $data['is_entries'] = true;
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(' ', $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('&', '&', $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; } }
function displayPageList($limit, $parentsonly, $tpl = false) { global $serendipity; $q = 'SELECT id, headline, parent_id, permalink, pagetitle, is_startpage FROM ' . $serendipity['dbPrefix'] . 'staticpages WHERE showonnavi = 1 AND publishstatus = 1 AND (language = \'' . $serendipity['lang'] . '\' OR language = \'\' OR language = \'all\')'; if ($parentsonly) { $q .= ' AND parent_id = 0'; } $q .= ' ORDER BY parent_id, pageorder'; if ($limit) { $q .= ' LIMIT ' . $limit; } $pagelist = serendipity_db_query($q, false, 'assoc'); if (is_array($pagelist)) { serendipity_plugin_staticpage::iteratePageList($pagelist); $pagelist = serendipity_walkRecursive($pagelist, 'id', 'parent_id', VIEWMODE_THREADED); $content = $tpl ? array() : (string) ''; foreach ($pagelist as $page) { if (is_array($content)) { /* smartify the staticpage sidebar plugin */ $content[] = array('id' => $page['id'], 'headline' => !empty($page['headline']) ? function_exists('serendipity_specialchars') ? serendipity_specialchars($page['headline']) : htmlspecialchars($page['headline'], ENT_COMPAT, LANG_CHARSET) : (function_exists('serendipity_specialchars') ? serendipity_specialchars($page['pagetitle']) : htmlspecialchars($page['pagetitle'], ENT_COMPAT, LANG_CHARSET)), 'parent_id' => $page['parent_id'], 'permalink' => !empty($page['permalink']) ? $page['permalink'] : NULL, 'pagetitle' => !empty($page['permalink']) ? function_exists('serendipity_specialchars') ? serendipity_specialchars($page['pagetitle']) : htmlspecialchars($page['pagetitle'], ENT_COMPAT, LANG_CHARSET) : NULL, 'is_startpage' => $page['is_startpage'], 'depth' => $page['depth'] * 10); } elseif (is_string($content)) { $content .= !empty($page['permalink']) ? sprintf("<a href=\"%s\" title=\"%s\" style=\"padding-left: %dpx;\">%s</a><br />\n", $page['permalink'], function_exists('serendipity_specialchars') ? serendipity_specialchars($page['pagetitle']) : htmlspecialchars($page['pagetitle'], ENT_COMPAT, LANG_CHARSET), $page['depth'] * 10, !empty($page['headline']) ? function_exists('serendipity_specialchars') ? serendipity_specialchars($page['headline']) : htmlspecialchars($page['headline'], ENT_COMPAT, LANG_CHARSET) : (function_exists('serendipity_specialchars') ? serendipity_specialchars($page['pagetitle']) : htmlspecialchars($page['pagetitle'], ENT_COMPAT, LANG_CHARSET))) : sprintf("<div style=\"padding-left: %dpx;\">%s</div>", $page['depth'] * 10, !empty($page['headline']) ? function_exists('serendipity_specialchars') ? serendipity_specialchars($page['headline']) : htmlspecialchars($page['headline'], ENT_COMPAT, LANG_CHARSET) : (function_exists('serendipity_specialchars') ? serendipity_specialchars($page['pagetitle']) : htmlspecialchars($page['pagetitle'], ENT_COMPAT, LANG_CHARSET))); } } } return $content; }
function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; $hooks =& $bag->get('event_hooks'); if (isset($hooks[$event])) { switch ($event) { case 'backend_image_addform': if ($serendipity['version'][0] < 2) { if (class_exists('ZipArchive')) { $checkedY = ""; $checkedN = ""; $this->get_config('unzipping') ? $checkedY = ' checked="checked"' : ($checkedN = ' checked="checked"'); ?> <br /> <div> <strong><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES; ?> </strong><br /> <?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES_DESC; ?> <div> <input type="radio" class="input_radio" id="unzip_yes" name="serendipity[unzip_archives]" value="<?php echo YES; ?> "<?php echo $checkedY; ?> ><label for="unzip_yes"><?php echo YES; ?> </label> <input type="radio" class="input_radio" id="unzip_no" name="serendipity[unzip_archives]" value="<?php echo NO; ?> "<?php echo $checkedN; ?> ><label for="unzip_no"><?php echo NO; ?> </label> </div> </div> <?php } ?> <br /> <strong><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_QUICKBLOG; ?> :</strong><br /> <em><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_QUICKBLOG_DESC; ?> </em> <table id="quickblog_table" style="width: 50%"> <tr> <td nowrap="nowrap"><?php echo TITLE; ?> </td> <td><input class="input_textbox" name="serendipity[quickblog][title]" type="text" style="width: 90%" /></td> </tr> <tr> <td nowrap="nowrap"><?php echo ENTRY_BODY; ?> </td> <td><textarea name="serendipity[quickblog][body]" style="width: 90%; height: 200px"></textarea></td> </tr> <tr> <td nowrap="nowrap"><?php echo CATEGORY; ?> </td> <td><select name="serendipity[quickblog][category]"> <option value=""><?php echo NO_CATEGORY; ?> </option> <?php if (is_array($cats = serendipity_fetchCategories())) { $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED); foreach ($cats as $cat) { echo '<option value="' . $cat['categoryid'] . '">' . str_repeat(' ', $cat['depth']) . $cat['category_name'] . '</option>' . "\n"; } } ?> </select></td> </tr> <tr> <td nowrap="nowrap"><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET; ?> </td> <td><select id="select_image_target" name="serendipity[quickblog][target]"> <option value="none"<?php echo serendipity_ifRemember('target', 'none', false, 'selected'); ?> ><?php echo NONE; ?> </option> <option value="js"<?php echo serendipity_ifRemember('target', 'js', false, 'selected'); ?> ><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET_JS; ?> </option> <option value="plugin"<?php echo serendipity_ifRemember('target', 'plugin', false, 'selected'); ?> ><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET_ENTRY; ?> </option> <option value="_blank"<?php echo serendipity_ifRemember('target', '_blank', false, 'selected'); ?> ><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET_BLANK; ?> </option> </select></td> </tr> <tr> <td nowrap="nowrap"><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_ASOBJECT; ?> </td> <td> <input type="radio" class="input_radio" id="image_yes" name="serendipity[quickblog][isobject]" value="<?php echo YES; ?> "><label for="image_yes"><?php echo YES; ?> </label> <input type="radio" class="input_radio" id="image_no" name="serendipity[quickblog][isobject]" value="<?php echo NO; ?> " checked="checked"><label for="image_no"><?php echo NO; ?> </label> </td> </tr> <tr> <td nowrap="nowrap"><?php echo IMAGE_SIZE; ?> </td> <td><input class="input_textbox" name="serendipity[quickblog][size]" value="<?php echo $serendipity['thumbSize']; ?> " type="text" style="width: 50px" /></td> </tr> <tr> <td align="center" colspan="2"><br /></td> </tr> </table> <div> <em><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_IMAGE_SIZE_DESC; ?> </em> </div> <?php } else { ?> <div id="imageselectorplus"> <?php if (class_exists('ZipArchive')) { $checkedY = ""; $checkedN = ""; $this->get_config('unzipping') ? $checkedY = ' checked="checked"' : ($checkedN = ' checked="checked"'); ?> <div class="clearfix radio_field"> <h4><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES; ?> </h4> <?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES_DESC; ?> <div> <input type="radio" class="input_radio" id="unzip_yes" name="serendipity[unzip_archives]" value="<?php echo YES; ?> "<?php echo $checkedY; ?> ><label for="unzip_yes"><?php echo YES; ?> </label> <input type="radio" class="input_radio" id="unzip_no" name="serendipity[unzip_archives]" value="<?php echo NO; ?> "<?php echo $checkedN; ?> ><label for="unzip_no"><?php echo NO; ?> </label> </div> </div> <?php } ?> <h4><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_QUICKBLOG; ?> :</h4> <em><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_QUICKBLOG_DESC; ?> </em> <div id="quickblog_tablefield" class="clearfix"> <div class="quickblog_form_field"> <label for="quickblog_titel"><?php echo TITLE; ?> </label> <input id="quickblog_title" class="input_textbox" name="serendipity[quickblog][title]" type="text"> </div> <div class="quickblog_textarea_field"> <label for="nuggets2"><?php echo ENTRY_BODY; ?> </label> <textarea id="nuggets2" class="quickblog_nugget" data-tarea="nuggets2" name="serendipity[quickblog][body]" rows="10" cols="80"></textarea> <?php if ($serendipity['wysiwyg']) { $plugins = serendipity_plugin_api::enum_plugins('*', false, 'serendipity_event_nl2br'); ?> <input name="serendipity[properties][disable_markups][]" type="hidden" value="<?php echo $plugins[0]['name']; ?> "> <?php if (!class_exists('serendipity_event_ckeditor')) { ?> <script src="<?php echo $serendipity['serendipityHTTPPath']; ?> htmlarea/ckeditor/ckeditor/ckeditor.js"></script> <?php } // just add a simple basic toolbar, since we cannot use embedded plugins here ?> <script> CKEDITOR.replace( 'nuggets2', { toolbar : [['Format'],['Bold','Italic','Underline','Superscript','-','NumberedList','BulletedList','Outdent','Blockquote'],['JustifyBlock','JustifyCenter','JustifyRight'],['Link','Unlink'],['Source']], toolbarGroups: null }); </script> <?php } ?> </div> <div class="quickblog_form_field"> <label for="quickblog_select"><?php echo CATEGORY; ?> </label> <select id="quickblog_select" name="serendipity[quickblog][category]"> <option value=""><?php echo NO_CATEGORY; ?> </option> <?php if (is_array($cats = serendipity_fetchCategories())) { $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED); foreach ($cats as $cat) { echo '<option value="' . $cat['categoryid'] . '">' . str_repeat(' ', $cat['depth']) . $cat['category_name'] . '</option>' . "\n"; } } ?> </select> </div> <div class="quickblog_form_select"> <label for="select_image_target"><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET; ?> </label> <select id="select_image_target" name="serendipity[quickblog][target]"> <option value="none"<?php echo serendipity_ifRemember('target', 'none', false, 'selected'); ?> ><?php echo NONE; ?> </option> <option value="js"<?php echo serendipity_ifRemember('target', 'js', false, 'selected'); ?> ><?php echo MEDIA_TARGET_JS; ?> </option> <option value="plugin"<?php echo serendipity_ifRemember('target', 'plugin', false, 'selected'); ?> ><?php echo MEDIA_ENTRY; ?> </option> <option value="_blank"<?php echo serendipity_ifRemember('target', '_blank', false, 'selected'); ?> ><?php echo MEDIA_TARGET_BLANK; ?> </option> </select> </div> <div class="clearfix radio_field quickblog_radio_field"> <label><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_ASOBJECT; ?> </label> <div> <input type="radio" class="input_radio" id="image_yes" name="serendipity[quickblog][isobject]" value="<?php echo YES; ?> "><label for="image_yes"><?php echo YES; ?> </label> <input type="radio" class="input_radio" id="image_no" name="serendipity[quickblog][isobject]" value="<?php echo NO; ?> " checked="checked"><label for="image_no"><?php echo NO; ?> </label> </div> </div> <div class="quickblog_form_field"> <label for="quickblog_isize"><?php echo IMAGE_SIZE; ?> </label> <input id="quickblog_isize" class="input_textbox" name="serendipity[quickblog][size]" value="<?php echo $serendipity['thumbSize']; ?> " type="text"> </div> </div> <em><?php echo PLUGIN_EVENT_IMAGESELECTORPLUS_IMAGE_SIZE_DESC; ?> </em> </div> <?php } break; case 'backend_image_add': global $new_media; // if file is zip archive and unzipping enabled // unzip file and add all images to database // retrieve file type $target_zip = $eventData; preg_match('@(^.*/)+(.*)\\.+(\\w*)@', $target_zip, $matches); $target_dir = $matches[1]; $basename = $matches[2]; $extension = $matches[3]; $authorid = isset($serendipity['POST']['all_authors']) && $serendipity['POST']['all_authors'] == 'true' ? '0' : $serendipity['authorid']; // only if unzipping function exists, we have archive file and unzipping set to yes if (class_exists('ZipArchive') && $extension == 'zip' && $serendipity['POST']['unzip_archives'] == YES) { // now unzip $zip = new ZipArchive(); $res = $zip->open($target_zip); if ($res === TRUE) { $files_to_unzip = array(); $extracted_images = array(); for ($i = 0; $i < $zip->numFiles; $i++) { $file_to_extract = $zip->getNameIndex($i); if (file_exists($target_dir . $file_to_extract)) { echo '(' . $file_to_extract . ') ' . ERROR_FILE_EXISTS_ALREADY . '<br />'; } else { $files_to_unzip[] = $file_to_extract; $extracted_images[] = $target_dir . $file_to_extract; } } $zip->extractTo($target_dir, $files_to_unzip); $zip->close(); echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_OK; } else { echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FAILED; } // now proceed all unzipped images foreach ($extracted_images as $target) { preg_match('@(^.*/)+(.*)\\.+(\\w*)@', $target, $matches); $real_dir = $matches[1]; $basename = $matches[2]; $extension = $matches[3]; $tfile = $basename . "." . $extension; preg_match('@' . $serendipity['uploadPath'] . '(.*/)@', $target, $matches); $image_directory = $matches[1]; // make thumbnails for new images $thumbs = array(array('thumbSize' => $serendipity['thumbSize'], 'thumb' => $serendipity['thumbSuffix'])); serendipity_plugin_api::hook_event('backend_media_makethumb', $thumbs); foreach ($thumbs as $thumb) { // Create thumbnail if ($created_thumbnail = serendipity_makeThumbnail($tfile, $image_directory, $thumb['thumbSize'], $thumb['thumb'])) { echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_IMAGE_FROM_ARCHIVE . " - " . THUMB_CREATED_DONE . '<br />'; } } // Insert into database $image_id = serendipity_insertImageInDatabase($tfile, $image_directory, $authorid, null, $realname); echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_IMAGE_FROM_ARCHIVE . " ({$tfile}) " . PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_ADD_TO_DB . "<br />"; $new_media[] = array('image_id' => $image_id, 'target' => $target, 'created_thumbnail' => $created_thumbnail); } } case 'backend_image_addHotlink': // Re-Scale thumbnails? $max_scale = array('width' => (int) $this->get_config('thumb_max_width'), 'height' => (int) $this->get_config('thumb_max_height')); if ($max_scale['width'] > 0 || $max_scale['height'] > 0) { $this->resizeThumb($max_scale, $eventData); } if (empty($serendipity['POST']['quickblog']['title'])) { break; } $file = basename($eventData); $directory = str_replace($serendipity['serendipityPath'] . $serendipity['uploadPath'], '', dirname($eventData) . '/'); $size = (int) $serendipity['POST']['quickblog']['size']; // check default Serendipity thumbSize, to make this happen like standard image uploads, and to get one "fullsize" image instance only, // else create another quickblog image "resized" instance, to use as entries thumbnail image if ($serendipity['thumbSize'] != $size) { $oldSuffix = $serendipity['thumbSuffix']; $serendipity['thumbSuffix'] = 'quickblog'; serendipity_makeThumbnail($file, $directory, $size); $serendipity['thumbSuffix'] = $oldSuffix; } // Non-image object link generation if ($serendipity['POST']['quickblog']['isobject'] == YES) { $objfile = serendipity_parseFileName($file); $filename = $objfile[0]; $suffix = $objfile[1]; $obj_mime = serendipity_guessMime($suffix); $objpath = $serendipity['serendipityHTTPPath'] . $serendipity['uploadPath'] . $directory . $filename . '.' . $suffix; // try to know about a working environment for imagemagicks pdf preview generation if ($serendipity['magick'] === true && strtolower($suffix) == 'pdf' && $serendipity['thumbSize'] == $size) { $objpreview = $serendipity['serendipityHTTPPath'] . $serendipity['uploadPath'] . $directory . $filename . '.' . $serendipity['thumbSuffix'] . '.' . $suffix . '.png'; } else { $objpreview = serendipity_getTemplateFile('admin/img/mime_' . preg_replace('@[^0-9a-z_\\-]@i', '-', $obj_mime) . '.png'); } if (!$objpreview || empty($objpreview)) { $objpreview = serendipity_getTemplateFile('admin/img/mime_unknown.png'); } } // New draft post $entry = array(); $entry['isdraft'] = 'false'; $entry['title'] = function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['quickblog']['title']) : htmlspecialchars($serendipity['POST']['quickblog']['title'], ENT_COMPAT, LANG_CHARSET); if (isset($objpath) && !empty($objpath)) { $entry['body'] = '<a href="' . $objpath . '"><img alt="" class="serendipity_image_left serendipity_quickblog_image" src="' . $objpreview . '">' . $filename . '</a> (-' . $obj_mime . '-)<p>' . $serendipity['POST']['quickblog']['body'] . '</p>'; } else { $entry['body'] = '<!--quickblog:' . $serendipity['POST']['quickblog']['target'] . '|' . $eventData . '-->' . $serendipity['POST']['quickblog']['body']; } $entry['authorid'] = $serendipity['authorid']; $entry['exflag'] = false; $entry['categories'][0] = function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['quickblog']['category']) : htmlspecialchars($serendipity['POST']['quickblog']['category'], ENT_COMPAT, LANG_CHARSET); #$entry['allow_comments'] = 'true'; // both disabled #$entry['moderate_comments'] = 'false'; // to take default values $serendipity['POST']['properties']['fake'] = 'fake'; $id = serendipity_updertEntry($entry); break; case 'frontend_display': // auto resizing images based on width and/or height attributes in img tag if (serendipity_db_bool($this->get_config('autoresize'))) { if (!empty($eventData['body'])) { $eventData['body'] = $this->substituteImages($eventData['body']); } if (!empty($eventData['extended'])) { $eventData['extended'] = $this->substituteImages($eventData['extended']); } } if (empty($eventData['body'])) { return; } // displaying quickblog posts if (is_object($serendipity['smarty']) && preg_match('@<!--quickblog:(.+)-->@imsU', $eventData['body'], $filematch)) { $eventData['body'] = $this->parse_quickblog_post($filematch[1], $eventData['body']); } // displaying galleries introduced by markup foreach ($this->markup_elements as $temp) { if (serendipity_db_bool($this->get_config($temp['name'], true)) && isset($eventData[$temp['element']]) && !$eventData['properties']['ep_disable_markup_' . $this->instance] && !isset($serendipity['POST']['properties']['disable_markup_' . $this->instance])) { $element = $temp['element']; $eventData[$element] = $this->media_insert($eventData[$element], $eventData); } } return true; break; case 'backend_entry_presave': if (is_numeric($eventData['id'])) { $eventData['body'] = str_replace('{{s9yisp_entryid}}', $eventData['id'], $eventData['body']); $eventData['extended'] = str_replace('{{s9yisp_entryid}}', $eventData['id'], $eventData['extended']); $this->gotMilk = true; } else { $this->cache['body'] = $eventData['body']; $this->cache['extended'] = $eventData['extended']; } break; case 'backend_publish': case 'backend_save': if ($this->gotMilk === false) { $old = md5($this->cache['body']) . md5($this->cache['extended']); $this->cache['body'] = str_replace('{{s9yisp_entryid}}', $eventData['id'], $this->cache['body']); $this->cache['extended'] = str_replace('{{s9yisp_entryid}}', $eventData['id'], $this->cache['extended']); $new = md5($this->cache['body']) . md5($this->cache['extended']); if ($old != $new) { serendipity_db_query("UPDATE {$serendipity['dbPrefix']}entries\n SET body = '" . serendipity_db_escape_string($this->cache['body']) . "',\n extended = '" . serendipity_db_escape_string($this->cache['extended']) . "'\n WHERE id = " . (int) $eventData['id']); } } break; case 'entry_display': if ($this->selected()) { if (is_array($eventData)) { $eventData['clean_page'] = true; // This is important to not display an entry list! } else { $eventData = array('clean_page' => true); } } break; case 'entries_header': if (!$this->selected()) { return true; } if ($serendipity['version'][0] > 1) { return true; } if (!headers_sent()) { header('HTTP/1.0 200'); header('Status: 200 OK'); } $entry = serendipity_fetchEntry('id', $serendipity['GET']['id']); $imageid = $serendipity['GET']['image']; $imgsrc = ''; if (preg_match('@<a title="([^"]+)" id="s9yisp' . $imageid . '"></a>@imsU', $entry['body'], $imgmatch)) { $imgsrc = $imgmatch[1]; } elseif (preg_match('@<a title="([^"]+)" id="s9yisp' . $imageid . '"></a>@imsU', $entry['extended'], $imgmatch)) { $imgsrc = $imgmatch[1]; } else { return; } $link = '<a href="' . serendipity_archiveURL($serendipity['GET']['id'], $entry['title'], 'baseURL', true, array('timestamp' => $entry['timestamp'])) . '#s9yisp' . $imageid . '">'; echo '<div class="serendipity_Entry_Date"> <h3 class="serendipity_date">' . serendipity_formatTime(DATE_FORMAT_ENTRY, $entry['timestamp']) . '</h3>'; echo '<h4 class="serendipity_title"><a href="#">' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET)) . '</a></h4>'; echo '<div class="serendipity_entry"><div class="serendipity_entry_body">'; echo '<div class="serendipity_center">' . $link . '<!-- s9ymdb:' . $entry['id'] . ' --><img src="' . $imgsrc . '" /></a></div>'; echo '<br />'; echo $link . '<< ' . BACK . '</a>'; echo "</div>\n</div>\n</div>\n"; return true; break; case 'frontend_image_add_unknown': case 'frontend_image_add_filenameonly': case 'frontend_image_selector_submit': case 'frontend_image_selector_more': case 'frontend_image_selector_imagecomment': case 'frontend_image_selector_imagealign': case 'frontend_image_selector_imagesize': case 'frontend_image_selector_hiddenfields': case 'frontend_image_selector_imagelink': return true; break; case 'css_backend': if ($serendipity['version'][0] > 1) { ?> #imageselectorplus .radio_field input { margin: 0 0.5em; } #quickblog_tablefield { display: table-cell; } #uploadform .quickblog_nugget { margin-left: 0; padding: 0; } #quickblog_tablefield .quickblog_form_field { margin: .375em 0; } #quickblog_tablefield .quickblog_radio_field div label, #quickblog_tablefield .radio_field label { padding-left: .5em; } #quickblog_tablefield .quickblog_form_select { margin-top: 0.75em; margin-bottom: 0.75em; } #quickblog_tablefield .quickblog_radio_field label { padding-left: 0; } #quickblog_tablefield .quickblog_radio_field div { display: inline; } #quickblog_tablefield .quickblog_radio_field input { margin-left: 0.5em; } <?php } break; case 'css': ?> #content .serendipity_quickblog_image { border: medium none transparent; } .serendipity_mediainsert_gallery { border: 1px solid #C0C0C0; margin: 0px; overflow: auto; padding: 0.4em; } <?php break; case 'frontend_image_selector': if ($serendipity['version'][0] < 2) { $eventData['finishJSFunction'] = 'serendipity_imageSelectorPlus_done(\'' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['GET']['textarea']) : htmlspecialchars($serendipity['GET']['textarea'], ENT_COMPAT, LANG_CHARSET)) . '\')'; } else { $eventData['finishJSFunction'] = 'serendipity.serendipity_imageSelector_done(\'' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['GET']['textarea']) : htmlspecialchars($serendipity['GET']['textarea'], ENT_COMPAT, LANG_CHARSET)) . '\')'; } return true; break; default: return false; } } else { return false; } }
function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; $hooks =& $bag->get('event_hooks'); if (isset($hooks[$event])) { switch ($event) { case 'backend_delete_entry': $this->deleteTagsForEntry((int) $eventData); return true; case 'frontend_header': if (serendipity_db_bool($this->get_config('use_flash'))) { echo '<script type="text/javascript" src="'; echo $serendipity['serendipityHTTPPath']; echo 'plugins/serendipity_event_freetag/swfobject.js"></script>' . "\n"; echo '<script type="text/javascript">' . "\n"; echo 'swfobject.registerObject("tagcloud", "9.0.0", "expressInstall.swf");' . "\n"; echo '</script>' . "\n"; } $this->displayMetaKeywords($serendipity['GET']['id'], $this->displayTag); return true; case 'frontend_display:rss-2.0:per_entry': case 'frontend_display:rss-0.91:per_entry': $eventData['display_dat'] .= $this->getFeedXmlForTags('category', $eventData['properties']['freetag_tags']); return true; case 'frontend_display:rss-1.0:per_entry': case 'frontend_display:rss-0.91:per_entry': case 'frontend_display:atom-0.3:per_entry': case 'frontend_display:atom-1.0:per_entry': $eventData['display_dat'] .= $this->getFeedXmlForTags('dc:subject', $eventData['properties']['freetag_tags']); return true; case 'external_plugin': $uri_parts = explode('?', str_replace(array('&', '%FF'), array('&', '.'), $eventData)); $taglist = serendipity_db_bool($this->get_config('taglist', false)); $param = $taglist ? explode('/', str_replace('/taglist', '', $uri_parts[0])) : explode('/', $uri_parts[0]); $plugincode = array_shift($param); $tagged_as_list = false; // By option or manually added blogdomain.com/plugin/taglist/Serendipity/Blog/Plums - see below if ($plugincode == "taglist") { $plugincode = "tags"; } if ($plugincode == "tag" || $plugincode == "tags" || $plugincode == "freetag") { // Manually added (last) parameter 'taglist" to view tags by list for certain taglinks eg. blogdomain.com/plugin/tag/Serendipity/Blog/Plums/taglist - both need a modified entries.tpl if ($taglist && in_array('taglist', $serendipity['uriArguments'])) { $param = array_map('urldecode', $param); $param = array_map('urldecode', $param); // for doubled encoded tag umlauts via searchengines backlinks $param = is_array($param) ? array_map('strip_tags', $param) : strip_tags($param); $param = array_filter($param); // empty removed XSS by strip_tags if (!is_object($serendipity['smarty'])) { serendipity_smarty_init(); // to avoid member function assign() on a non-object error, start Smarty templating } if (false === serendipity_db_bool($this->get_config('show_tagcloud', true))) { // Since this is extra stuff, we need to regular assign the subtitle header and not use $serendipity['head_subtitle'] ! if (count($param) > 1) { if (function_exists('serendipity_specialchars')) { $serendipity['smarty']->assign('head_subtitle', sprintf(PLUGIN_EVENT_FREETAG_USING, implode(' + ', array_map('serendipity_specialchars', $param)))); } else { $serendipity['smarty']->assign('head_subtitle', sprintf(PLUGIN_EVENT_FREETAG_USING, implode(' + ', array_map('htmlspecialchars', $param)))); } } else { $serendipity['smarty']->assign('head_subtitle', sprintf(PLUGIN_EVENT_FREETAG_USING, function_exists('serendipity_specialchars') ? serendipity_specialchars($param[0]) : htmlspecialchars($param[0], ENT_COMPAT, LANG_CHARSET))); } } $serendipity['smarty']->assign('taglist', true); foreach ($serendipity['uriArguments'] as $uak => $uav) { if ($uav == 'taglist') { unset($serendipity['uriArguments'][$uak]); } } $tagged_as_list = true; } /* 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]); if ($param[count($param) - 1] == "P{$page}.html") { array_pop($param); // knock it off of the param array as well } } } } if (count($param) == 0 || empty($param[0])) { $serendipity['head_subtitle'] = PLUGIN_EVENT_FREETAG_ALLTAGS; $this->displayTag = true; $param = null; } else { if (count($param) == 1) { $param = urldecode($param[0]); $param = urldecode($param); // for doubled encoded tag umlauts via searchengines backlinks $param = strip_tags($param); $serendipity['head_subtitle'] = sprintf(PLUGIN_EVENT_FREETAG_USING, function_exists('serendipity_specialchars') ? serendipity_specialchars($param) : htmlspecialchars($param, ENT_COMPAT, LANG_CHARSET)); $emit_404 = true; } else { if (!$tagged_as_list) { $param = array_map('urldecode', $param); $param = array_map('urldecode', $param); // for doubled encoded tag umlauts via searchengines backlinks in sprintf } $param = array_map('strip_tags', $param); $param = array_filter($param); // empty removed XSS by strip_tags if (function_exists('serendipity_specialchars')) { $serendipity['head_subtitle'] = sprintf(PLUGIN_EVENT_FREETAG_USING, implode(' + ', array_map('serendipity_specialchars', $param))); } else { $serendipity['head_subtitle'] = sprintf(PLUGIN_EVENT_FREETAG_USING, implode(' + ', array_map('htmlspecialchars', $param))); } $emit_404 = true; } } // for XSS secureness, while using doubled decode $param = is_array($param) ? array_map('strip_tags', $param) : strip_tags($param); if (is_array($param)) { array_filter($param); // empty removed XSS by strip_tags } if (function_exists('serendipity_specialchars')) { $param = is_array($param) ? array_map('serendipity_specialchars', $param) : serendipity_specialchars($param); } else { $param = is_array($param) ? array_map('htmlspecialchars', $param) : htmlspecialchars($param, ENT_COMPAT, LANG_CHARSET); } $this->tags['show'] = $param; $serendipity['plugin_vars']['tag'] = $param; if (is_array($param)) { @define('PLUGIN_VARS_TAG', implode(',', $param)); } else { @define('PLUGIN_VARS_TAG', $param); } $serendipity['GET']['subpage'] = $eventData; unset($serendipity['GET']['category']); // No restriction should be enforced here. include_once S9Y_INCLUDE_PATH . 'include/genpage.inc.php'; if ($emit_404 && $this->TaggedEntries !== null && $this->TaggedEntries < 1) { @header('HTTP/1.0 404 Not found'); @header('Status: 404 Not found'); if (serendipity_db_bool($this->get_config('send_http_header', true))) { @header('X-FreeTag: not found'); } } else { if (serendipity_db_bool($this->get_config('send_http_header', true))) { @header('X-FreeTag: ' . $this->TaggedEntries); } } $raw_data = ob_get_contents(); ob_end_clean(); $serendipity['smarty']->assign('raw_data', $raw_data); serendipity_gzCompression(); $serendipity['smarty']->display(serendipity_getTemplateFile($serendipity['smarty_file'], 'serendipityPath')); @define('NO_EXIT', true); } break; case 'backend_sidebar_entries': if ($serendipity['version'][0] < 2) { ?> <li class="serendipitySideBarMenuLink serendipitySideBarMenuEntryLinks"><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=managetags"><?php echo PLUGIN_EVENT_FREETAG_MANAGETAGS; ?> </a></li> <?php } else { ?> <li><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=managetags"><?php echo PLUGIN_EVENT_FREETAG_MANAGETAGS; ?> </a></li> <?php } return true; break; case 'backend_sidebar_entries_event_display_managetags': $this->eventData = $eventData; $this->displayManageTags($event, $bag, $eventData, $addData); return true; break; case 'backend_publish': case 'backend_save': if (function_exists('mb_internal_encoding')) { mb_internal_encoding(LANG_CHARSET); } if (!isset($eventData['id'])) { return true; } $to_lower = serendipity_db_bool($this->get_config('lowercase_tags')); $keylist = serendipity_db_query("SELECT tag, keywords FROM {$serendipity['dbPrefix']}tagkeywords", false, 'assoc'); $automatted = array(array()); if (is_array($keylist)) { foreach ($keylist as $key) { $keywords = explode(',', $key['keywords']); foreach ($keywords as $keyword) { $automatted[trim($keyword)][$key['tag']] = true; } } } // When this variable is not set, the entry might be saved i.e. by recreating cache or automatted trackback. // Do not loose such tags. :) if (!isset($serendipity['POST']['properties']['freetag_tagList'])) { $serendipity['POST']['properties']['freetag_tagList'] = implode(',', $this->getTagsForEntry($eventData['id'])); } $tags = $this->makeTagsFromTagList($serendipity['POST']['properties']['freetag_tagList']); if (serendipity_db_bool($this->get_config('keyword2tag'))) { $searchtext = strip_tags($eventData['body'] . $eventData['extended']); foreach ($automatted as $keyword => $ktags) { $keyword = trim($keyword); if (empty($keyword)) { continue; } if (!is_array($ktags) || count($ktags) < 1) { continue; } $regex = sprintf("/((\\s+|[\\(\\[-]+)%s([-\\/,\\.\\?!'\";\\)\\]]*+|[\\/-]+))/i", $keyword); if (preg_match($regex, $searchtext) > 0) { foreach ($ktags as $tag => $is_assigned) { if (!is_array($tags) || !in_array(strtolower($tag), $tags) && !in_array($tag, $tags)) { if ($to_lower) { if (function_exists("mb_strtolower")) { $tag = mb_strtolower($tag); } else { $tag = strtolower($tag); } } $tags[] = $tag; printf(PLUGIN_EVENT_FREETAG_KEYWORDS_ADD, function_exists('serendipity_specialchars') ? serendipity_specialchars($keyword) : htmlspecialchars($keyword, ENT_COMPAT, LANG_CHARSET), function_exists('serendipity_specialchars') ? serendipity_specialchars($tag) : htmlspecialchars($tag, ENT_COMPAT, LANG_CHARSET)); } } } } } if (empty($tags)) { $tags = array(); } if (serendipity_db_bool($this->get_config('cat2tag'))) { if (is_array($cats = serendipity_fetchCategories())) { $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED); foreach ($cats as $cat) { if ($to_lower) { if (function_exists("mb_strtolower")) { $cat['category_name'] = mb_strtolower($cat['category_name']); } else { $cat['category_name'] = strtolower($cat['category_name']); } } $names = explode(',', $cat['category_name']); foreach ($names as $name) { $name = trim($name); if (is_array($eventData['categories']) && in_array($cat['categoryid'], $eventData['categories']) && !in_array($name, $tags)) { $tags[] = $name; } } } } } $serendipity['POST']['properties']['freetag_tagList'] = implode(',', $tags); $this->deleteTagsForEntry($eventData['id']); $this->addTagsToEntry($eventData['id'], $tags); if ($serendipity['POST']['properties']['freetag_kill']) { $this->deleteTagsForEntry($eventData['id']); } return true; break; case 'css_backend': if ($serendipity['version'][0] > 1) { ?> .freetagMenu li { display: block; margin: 0 0 .5em; } .freetags_manage { border: 1px solid #aaa; border-bottom: 0 none; width: 100%; } .freetags_manage thead tr { background-color: #eee; } .freetags_manage tr { border-bottom: 1px solid #aaa; } .freetags_manage th, .freetags_manage td { padding: .125em .25em; } .freetags_list li { margin: 0 0 .25em; } @media only screen and (min-width: 768px) { .freetagMenu li { display: inline-block; margin: 0 .25em .5em 0; } } <?php } return true; break; case 'js_backend': // autocomplete with serendipity 2.0 if ($this->get_config('admin_ftayt')) { echo ' function enableAutocomplete() { if (typeof(tags) != "undefined") { $("#properties_freetag_tagList").autocomplete(tags, { minChars: 0, multiple: true, scrollHeight: 200, matchContains: "word", autoFill: false }); } }; addLoadEvent(enableAutocomplete); '; } break; case 'backend_display': if (function_exists('mb_internal_encoding')) { mb_internal_encoding(LANG_CHARSET); } if (!empty($serendipity['POST']['properties']['freetag_tagList'])) { $tagList = $serendipity['POST']['properties']['freetag_tagList']; } else { if (isset($eventData['id'])) { $tagList = implode(',', $this->getTagsForEntry($eventData['id'])); } else { $tagList = ''; } } if (serendipity_db_bool($this->get_config('lowercase_tags', true))) { if (function_exists("mb_strtolower")) { $tagList = mb_strtolower($tagList); } else { $tagList = strtolower($tagList); } } $freetags = $this->makeTagsFromTagList($tagList); if (!empty($freetags)) { $tagList = implode(',', $freetags); } $taglist = (array) $this->getAllTags(); if ($this->get_config('admin_ftayt')) { foreach ($taglist as $k => $v) { $wicktags[] = '\'' . addslashes($k) . '\''; } // jQuery Migrate is used due to $.browser of autocomplete plugin not being available in jquery 1.9+ echo ' ' . ($serendipity['version'][0] < 2 ? '<script src="' . $serendipity['baseURL'] . 'plugins/serendipity_event_freetag/jquery-1.11.1.min.js" type="text/javascript"></script>' : '') . ' <link rel="stylesheet" type="text/css" href="' . $serendipity['baseURL'] . 'plugins/serendipity_event_freetag/jquery.autocomplete.css" /> <script src="' . $serendipity['baseURL'] . 'plugins/serendipity_event_freetag/jquery-migrate-1.2.1.min.js"></script> <script type="text/javascript" src="' . $serendipity['baseURL'] . 'plugins/serendipity_event_freetag/jquery.autocomplete.min.js"></script> <script type="text/javascript"> var tags = [' . implode(',', $wicktags) . ']; ' . ($serendipity['version'][0] < 2 ? ' function enableAutocomplete() { $("#properties_freetag_tagList").autocomplete(tags, { minChars: 0, multiple: true, scrollHeight: 200, matchContains: "word", autoFill: false })}; addLoadEvent(enableAutocomplete); ' : '') . ' </script>'; } if ($this->get_config('admin_show_taglist')) { ?> <script type="text/javascript"> function addTag(addTag) { var freetags = document.getElementById("properties_freetag_tagList").value.split(','); inList = false; for (var freetag = 0; freetag < freetags.length; freetag++) { if (freetags[freetag] && trim(freetags[freetag].toLowerCase()) == addTag.toLowerCase()) { inList = true; } } if (!inList) { if (document.getElementById("properties_freetag_tagList").value.lastIndexOf(',') == (document.getElementById("properties_freetag_tagList").value.length-1)) { sepChar = ''; } else { sepChar = ','; } document.getElementById("properties_freetag_tagList").value = document.getElementById("properties_freetag_tagList").value + sepChar + addTag; } } function trim(str) { if (str) return str.replace(/^\s*|\s*$/g,""); else return ''; } </script> <?php } if ($serendipity['version'][0] < 2) { ?> <fieldset style="margin: 5px"> <legend><?php echo PLUGIN_EVENT_FREETAG_TITLE; ?> </legend> <label for="serendipity[properties][freetag_tagList]" title="<?php echo PLUGIN_EVENT_FREETAG_TITLE; ?> "><?php echo PLUGIN_EVENT_FREETAG_ENTERDESC; ?> :</label><br/> <input type="text" name="serendipity[properties][freetag_tagList]" id="properties_freetag_tagList" class="wickEnabled input_textbox" value="<?php echo function_exists('serendipity_specialchars') ? serendipity_specialchars($tagList) : htmlspecialchars($tagList, ENT_COMPAT, LANG_CHARSET); ?> " style="width: 100%" /> <input type="checkbox" name="serendipity[properties][freetag_kill]" id="properties_freetag_kill" class="input_checkbox" /> <label for="serendipity[properties][freetag_kill]" title="<?php echo PLUGIN_EVENT_FREETAG_KILL; ?> "><?php echo PLUGIN_EVENT_FREETAG_KILL; ?> </label><br/> <?php if ($this->get_config('admin_show_taglist')) { ?> <a name="tagListAnchor"></a> <div id="backend_freetag_list" style="margin: 5px; border: 1px dotted #000; padding: 5px; font-size: 9px;"> <?php } } else { ?> <fieldset id="edit_entry_freetags" class="entryproperties_freetag"> <span class="wrap_legend"><legend><?php echo PLUGIN_EVENT_FREETAG_TITLE; ?> </legend></span> <div class="form_field"> <label for="properties_freetag_tagList" class="block_level"><?php echo PLUGIN_EVENT_FREETAG_ENTERDESC; ?> :</label> <input id="properties_freetag_tagList" type="text" name="serendipity[properties][freetag_tagList]" class="wickEnabled" value="<?php echo function_exists('serendipity_specialchars') ? serendipity_specialchars($tagList) : htmlspecialchars($tagList, ENT_COMPAT, LANG_CHARSET); ?> "> </div> <div class="form_check"> <input id="properties_freetag_kill" type="checkbox" name="serendipity[properties][freetag_kill]"> <label for="properties_freetag_kill"><?php echo PLUGIN_EVENT_FREETAG_KILL; ?> </label> </div> <?php if ($this->get_config('admin_show_taglist')) { ?> <a name="tagListAnchor"></a> <div id="backend_freetag_list"> <?php } } if ($this->get_config('admin_show_taglist')) { $lastletter = ''; foreach ($taglist as $tag => $count) { if (function_exists('mb_strtoupper')) { $upc = mb_strtoupper(mb_substr($tag, 0, 1, LANG_CHARSET), LANG_CHARSET); } else { $upc = strtoupper(substr($tag, 0, 1)); } if ($upc != $lastletter) { if ($serendipity['version'][0] < 2) { echo " <b>|" . $upc . ':</b> '; } } if ($serendipity['version'][0] < 2) { echo "<a href=\"#tagListAnchor\" style=\"text-decoration: none\" onClick=\"addTag('{$tag}')\">{$tag}</a>, "; } else { echo "<a href=\"#tagListAnchor\" onClick=\"addTag('{$tag}')\">{$tag}</a> "; } $lastletter = $upc; } echo "</div>"; } ?> </fieldset> <?php return true; break; case 'frontend_entryproperties': $this->importEntryTagsIntoProperties($eventData, $addData); return true; break; case 'frontend_fetchentries': case 'frontend_fetchentry': if (!empty($this->tags['show'])) { if (is_array($this->tags['show'])) { $showtag = array_map('serendipity_db_escape_string', $this->tags['show']); } else { $showtag = serendipity_db_escape_string($this->tags['show']); } } else { if (!empty($serendipity['GET']['tag'])) { $showtag = serendipity_db_escape_string(urldecode($serendipity['GET']['tag'])); } } if (is_array($showtag)) { $arr_showtag = $showtag; } else { $arr_showtag = explode(';', $showtag); } $multimode = 'and'; if (count($arr_showtag) > 1) { $showtag = $arr_showtag; $multimode = 'or'; } if (!empty($show_tag) && is_string($show_tag) && serendipity_db_bool($this->get_config('lowercase_tags', true))) { if (function_exists("mb_strtolower")) { if (function_exists('mb_internal_encoding')) { mb_internal_encoding(LANG_CHARSET); } $showtag = mb_strtolower($showtag); } else { $showtag = strtolower($showtag); } } $coll_target = $this->get_config('collation', ''); if (empty($coll_target) && stristr($serendipity['dbType'], 'mysql')) { $cd = serendipity_db_query("SHOW FULL COLUMNS FROM {$serendipity['dbPrefix']}entrytags LIKE 'tag'"); if (!empty($cd[0]['Collation'])) { $coll_target = $cd[0]['Collation']; $this->set_config('collation', $coll_target); } } if (!empty($showtag)) { if (LANG_CHARSET == 'UTF-8' && stristr($serendipity['dbType'], 'mysql') && !stristr($coll_target, 'utf8')) { $collate = "COLLATE utf8_general_ci"; $collateP = '_utf8 '; } else { $collate = $collateP = ""; } $cond = $join = ''; if (is_string($showtag)) { $join = "INNER JOIN {$serendipity['dbPrefix']}entrytags AS entrytags ON (e.id = entrytags.entryid) "; $cond = "entrytags.tag = {$collateP} '{$showtag}' {$collate}"; } else { if (is_array($showtag)) { $_taglist = array(); $cond = '(1=2 '; foreach ($showtag as $_showtag) { $_taglist[] = serendipity_db_escape_string($_showtag); $cond .= " OR entrytags.tag = {$collateP} '" . serendipity_db_escape_string($_showtag) . "' {$collate} "; } $cond .= ' ) '; $total = count($showtag); $join = "INNER JOIN {$serendipity['dbPrefix']}entrytags AS entrytags " . "ON e.id = entrytags.entryid "; if ($multimode == 'and') { $eventData['having'] = " HAVING count(entrytags.tag) = {$total}"; } } } if (empty($eventData['and'])) { $eventData['and'] = " WHERE {$cond} "; } else { $eventData['and'] .= " AND {$cond} "; } if (empty($eventData['joins'])) { $eventData['joins'] = $join; } else { $eventData['joins'] .= $join; } $this->displayTag = $showtag; $serendipity['plugin_vars']['displayTag'] = $showtag; @define('PLUGIN_VARS_DISPLAYTAG', $showtag); } return true; break; case 'frontend_rss': if (!empty($this->displayTag)) { $eventData['title'] .= serendipity_utf8_encode(function_exists('serendipity_specialchars') ? serendipity_specialchars(' (' . sprintf(PLUGIN_EVENT_FREETAG_USING, $this->displayTag) . ')') : htmlspecialchars(' (' . sprintf(PLUGIN_EVENT_FREETAG_USING, $this->displayTag) . ')', ENT_COMPAT, LANG_CHARSET)); } return true; break; case 'entries_header': if (isset($eventData['plugin_vars']['tag']) && serendipity_db_bool($this->get_config('show_tagcloud'))) { $this->displayTagCloud($eventData['plugin_vars']['tag']); } return true; break; case 'css': if (strpos($eventData, '.serendipity_freeTag')) { // class exists in CSS, so a user has customized it and we don't need default return true; } $this->addToCSS($eventData); return true; break; case 'entry_display': // Don't display entries if we are getting a full tag list if (is_array($eventData)) { $this->TaggedEntries = count($eventData); if (serendipity_db_bool($this->get_config('send_http_header', true))) { @header('X-FreeTag-Count: Array'); } } else { if (serendipity_db_bool($this->get_config('send_http_header', true))) { @header('X-FreeTag-Count: Empty'); } $this->TaggedEntries = 0; } if ($this->displayTag === true) { $eventData['clean_page'] = true; return true; } $this->displayEntry($eventData, $addData); return true; break; case 'xmlrpc_updertEntry': if (isset($eventData['id']) && isset($eventData['mt_keywords'])) { //XMLRPC call $tags = $this->makeTagsFromTagList($eventData['mt_keywords']); if (!empty($tags)) { $this->deleteTagsForEntry($eventData['id']); $this->addTagsToEntry($eventData['id'], $tags); } } return true; break; case 'xmlrpc_fetchEntry': $eventData['mt_keywords'] = implode(',', $this->getTagsForEntry($eventData['id'])); return true; break; case 'xmlrpc_deleteEntry': if (isset($eventData["id"])) { $this->deleteTagsForEntry($eventData["id"]); } return true; break; default: return false; break; } } else { return false; } }
/** * Prints the form for editing/creating new blog entries * * This is the core file where your edit form appears. The Heart Of Gold, so to say. * * @access public * @param string The URL where the entry form is submitted to * @param array An array of hidden input fields that should be passed on to the HTML FORM * @param array The entry superarray with your entry's contents * @param string Any error messages that might have occured on the last run * @return null */ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = array(), $errMsg = "") { global $serendipity; $draftD = ''; $draftP = ''; $categoryselector_expanded = false; $template_vars = array(); serendipity_plugin_api::hook_event('backend_entryform', $entry); if (isset($entry['isdraft']) && serendipity_db_bool($entry['isdraft']) || !isset($entry['isdraft']) && $serendipity['publishDefault'] == 'draft') { $draftD = ' selected="selected"'; $template_vars['draft_mode'] = 'draft'; } else { $draftP = ' selected="selected"'; $template_vars['draft_mode'] = 'publish'; } if (isset($entry['moderate_comments']) && serendipity_db_bool($entry['moderate_comments'])) { $template_vars['moderate_comments'] = true; $moderate_comments = ' checked="checked"'; } elseif (!isset($entry['moderate_comments']) && ($serendipity['moderateCommentsDefault'] == 'true' || $serendipity['moderateCommentsDefault'] === true)) { // This is the default on creation of a new entry and depends on the "moderateCommentsDefault" variable of the configuration. $moderate_comments = ' checked="checked"'; $template_vars['moderate_comments'] = true; } else { $moderate_comments = ''; $template_vars['moderate_comments'] = false; } if (isset($entry['allow_comments']) && serendipity_db_bool($entry['allow_comments'])) { $template_vars['allow_comments'] = true; $allow_comments = ' checked="checked"'; } elseif ((!isset($entry['allow_comments']) || $entry['allow_comments'] !== 'false') && (!isset($serendipity['allowCommentsDefault']) || $serendipity['allowCommentsDefault'] == 'true' || $serendipity['allowCommentsDefault'] === true)) { // This is the default on creation of a new entry and depends on the "allowCommentsDefault" variable of the configuration. $template_vars['allow_comments'] = true; $allow_comments = ' checked="checked"'; } else { $template_vars['allow_comments'] = false; $allow_comments = ''; } // Fix category list. If the entryForm is displayed after a POST request, the additional category information is lost. if (is_array($entry['categories']) && !is_array($entry['categories'][0])) { $categories = (array) $entry['categories']; $entry['categories'] = array(); foreach ($categories as $catid) { $entry['categories'][] = serendipity_fetchCategoryInfo($catid); } } $selected = array(); if (is_array($entry['categories'])) { if (count($entry['categories']) > 1) { $categoryselector_expanded = true; } foreach ($entry['categories'] as $cat) { $selected[] = $cat['categoryid']; } } if (count($selected) > 1 || isset($serendipity['POST']['categories']) && is_array($serendipity['POST']['categories']) && sizeof($serendipity['POST']['categories']) > 1) { $categoryselector_expanded = true; } if (is_array($cats = serendipity_fetchCategories())) { $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED); foreach ($cats as $cat) { if (in_array($cat['categoryid'], $selected)) { $cat['is_selected'] = true; } $cat['depth_pad'] = str_repeat(' ', $cat['depth']); $template_vars['category_options'][] = $cat; } } if (!empty($serendipity['GET']['title'])) { $entry['title'] = utf8_decode(urldecode($serendipity['GET']['title'])); } if (!empty($serendipity['GET']['body'])) { $entry['body'] = utf8_decode(urldecode($serendipity['GET']['body'])); } if (!empty($serendipity['GET']['url'])) { $entry['body'] .= "\n" . '<a class="block_level" href="' . serendipity_specialchars(utf8_decode(urldecode($serendipity['GET']['url']))) . '">' . $entry['title'] . '</a>'; } $template_vars['formToken'] = serendipity_setFormToken(); if (isset($serendipity['allowDateManipulation']) && $serendipity['allowDateManipulation']) { $template_vars['allowDateManipulation'] = true; } if ((!empty($entry['extended']) || !empty($serendipity['COOKIE']['toggle_extended'])) && !$serendipity['wysiwyg']) { $template_vars['show_wysiwyg'] = true; } $template_vars['wysiwyg_advanced'] = true; $template_vars['timestamp'] = serendipity_serverOffsetHour(isset($entry['timestamp']) && $entry['timestamp'] > 0 ? $entry['timestamp'] : time()); $template_vars['reset_timestamp'] = serendipity_serverOffsetHour(time()); $template_vars['hiddens'] = $hiddens; $template_vars['errMsg'] = $errMsg; $template_vars['entry'] =& $entry; $template_vars['targetURL'] = $targetURL; $template_vars['cat_count'] = count($cats) + 1; $template_vars['wysiwyg'] = $serendipity['wysiwyg']; $template_vars['serendipityRightPublish'] = $_SESSION['serendipityRightPublish']; $template_vars['wysiwyg_blocks'] = array('body' => 'serendipity[body]', 'extended' => 'serendipity[extended]'); $template_vars['entry_template'] = serendipity_getTemplateFile('admin/entries.tpl', 'serendipityPath'); if (!is_object($serendipity['smarty'])) { serendipity_smarty_init(); } $serendipity['smarty']->registerPlugin('modifier', 'emit_htmlarea_code', 'serendipity_emit_htmlarea_code'); $serendipity['smarty']->assign('admin_view', 'entryform'); serendipity_plugin_api::hook_event('backend_entryform_smarty', $template_vars); $serendipity['smarty']->assignByRef('entry_vars', $template_vars); return serendipity_smarty_show('admin/entries.tpl'); }
function output_categoryadmin() { global $serendipity; $display = $this->get_config('display'); $categories = $this->build_categories(); $maintitle = PLUGIN_LINKLIST_ADD_CAT; $button = '<input type="submit" name="ADD" title="' . ADD . '" value="' . ADD . '" class="serendipityPrettyButton input_button" />'; echo '<h3>' . $maintitle . '</h3>'; ?> <form action="?serendipity[adminModule]=event_display&serendipity[adminAction]=linklist&serendipity[manage_category]=1" method="post"> <input type="hidden" name="serendipity[add_link][id]" value="<?php echo $id; ?> "> <table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <td><?php echo PLUGIN_LINKLIST_CAT_NAME; ?> </td> <td><input class="input_textbox" type="text" name="serendipity[add_category][title]" size="30" /></td> </tr> <tr> <td><?php echo PLUGIN_LINKLIST_PARENT_CATEGORY; ?> </td> <td><?php echo $this->category_box('cat', $categories, $cat); ?> </td> </tr> <?php echo ' </table> <div> ' . $button . ' </div> </form> <h3>' . PLUGIN_LINKLIST_ADMINCAT . '</h3> <a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=linklist">' . PLUGIN_LINKLIST_ADMINLINK . '</a>'; ?> <form action="?serendipity[adminModule]=event_display&serendipity[adminAction]=linklist&serendipity[manage_category]=1" method="post"> <table border="0" cellpadding="1" cellspacing="0" width="100%"> <tr> <td></td> <td><strong><?php echo CATEGORY; ?> </strong></td> </tr> <?php $q = 'SELECT s.* FROM ' . $serendipity['dbPrefix'] . 'link_category AS s ORDER BY s.category_name DESC'; $categories = serendipity_db_query($q); $categories = @serendipity_walkRecursive($categories, 'categoryid', 'parentid', VIEWMODE_THREADED); foreach ($categories as $category) { ?> <tr> <td width="16"> <input class="input_checkbox" type="checkbox" name="serendipity[category_to_remove][]" value="<?php echo $category['categoryid']; ?> " /> </td> <td width="300" style="padding-left: <?php echo $category['depth'] * 15 + 20; ?> px"> <img src="<?php echo serendipity_getTemplateFile('admin/img/folder.png'); ?> " style="vertical-align: bottom;"> <?php echo function_exists('serendipity_specialchars') ? serendipity_specialchars($category['category_name']) : htmlspecialchars($category['category_name'], ENT_COMPAT, LANG_CHARSET); ?> </td> </tr> <?php } echo ' </table> <div> <input type="submit" name="REMOVE" title="' . REMOVE . '" value="' . DELETE . '" class="serendipityPrettyButton input_button state_cancel" /> </div> <div style="font-size: smaller;">' . PLUGIN_LINKLIST_DELETE_WARN . '</div> </form>'; }
function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; if ($event == 'frontend_header') { $start_url = $serendipity['baseURL']; $start_title = $serendipity['blogTitle']; echo '<link rel="start" href="' . $start_url . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($start_title) : htmlspecialchars($start_title, ENT_COMPAT, LANG_CHARSET)) . '" />' . "\n"; if ($serendipity['GET']['action'] == 'read' && !empty($serendipity['GET']['id'])) { // Article detail view echo '<link rel="up" href="' . $start_url . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($start_title) : htmlspecialchars($start_title, ENT_COMPAT, LANG_CHARSET)) . '" />' . "\n"; $this->backAndForth($this->showPaging($serendipity['GET']['id'])); // END article detail view echo '<link rel="canonical" href="' . $this->getEntry($serendipity['GET']['id']) . '" />' . "\n"; } elseif ($serendipity['GET']['action'] == 'read' && is_array($serendipity['range'])) { // Specific Date Archives view echo '<link rel="up" href="' . serendipity_rewriteURL(PATH_ARCHIVE) . '" title="' . ARCHIVES . '" />' . "\n"; echo '<link rel="canonical" href="' . $this->getArchiveParameters() . '" />' . "\n"; $links = array(); $add_query = ''; $year = date('Y', $serendipity['range'][0]); $month = date('m', $serendipity['range'][0]); $day = date('d', $serendipity['range'][0]); $pageMonthNext = array('day' => '1', 'month' => $month + 1, 'year' => $year); $pageMonthPrev = array('day' => '1', 'month' => $month - 1, 'year' => $year); $pageDayNext = array('day' => $day + 1, 'month' => $month, 'year' => $year); $pageDayPrev = array('day' => $day - 1, 'month' => $month, 'year' => $year); $diff = $serendipity['range'][1] - $serendipity['range'][0]; if (isset($serendipity['GET']['category'])) { $categoryid = (int) serendipity_db_escape_string($serendipity['GET']['category']); $add_query = '/C' . $categoryid; } if ($diff < 86400) { // Paging day by day $ts = mktime(0, 0, 0, $pageDayPrev['month'], $pageDayPrev['day'], $pageDayPrev['year']); $links['prev'] = array('link' => serendipity_archiveDateUrl(sprintf('%4d/%02d/%02d', date('Y', $ts), date('m', $ts), date('d', $ts))), 'title' => sprintf(ENTRIES_FOR, serendipity_formatTime(DATE_FORMAT_ENTRY, $ts, false))); $ts = mktime(0, 0, 0, $pageDayNext['month'], $pageDayNext['day'], $pageDayNext['year']); $links['next'] = array('link' => serendipity_archiveDateUrl(sprintf('%4d/%02d/%02d', date('Y', $ts), date('m', $ts), date('d', $ts))), 'title' => sprintf(ENTRIES_FOR, serendipity_formatTime(DATE_FORMAT_ENTRY, $ts, false))); } elseif ($diff < 86400 * 28) { // Paging by week // TODO - Don't know :-) } else { // Paging by month $ts = mktime(0, 0, 0, $pageMonthPrev['month'], $pageMonthPrev['day'], $pageMonthPrev['year']); $links['prev'] = array('link' => serendipity_archiveDateUrl(sprintf('%4d/%02d', date('Y', $ts), date('m', $ts))), 'title' => sprintf(ENTRIES_FOR, serendipity_formatTime('%B %Y', $ts, false))); $ts = mktime(0, 0, 0, $pageMonthNext['month'], $pageMonthNext['day'], $pageMonthNext['year']); $links['next'] = array('link' => serendipity_archiveDateUrl(sprintf('%4d/%02d', date('Y', $ts), date('m', $ts))), 'title' => sprintf(ENTRIES_FOR, serendipity_formatTime('%B %Y', $ts, false))); } $this->backAndForth($links); // END Specific Date Archives view } elseif ($serendipity['GET']['action'] == 'archives') { // Full month/year archives overview echo '<link rel="up" href="' . serendipity_rewriteURL(PATH_ARCHIVE) . '" title="' . ARCHIVES . '" />' . "\n"; // END Full month/year archives overview echo '<link rel="canonical" href="' . $this->getArchiveParameters() . '" />' . "\n"; } elseif (!empty($serendipity['GET']['category'])) { // Category based view $cInfo = serendipity_fetchCategoryInfo($serendipity['GET']['category']); if (function_exists('serendipity_categoryURL')) { $categories_url = serendipity_categoryURL($cInfo, 'serendipityHTTPPath'); } else { $categories_url = serendipity_rewriteURL(PATH_CATEGORIES . '/' . serendipity_makePermalink(PERM_CATEGORIES, array('id' => $cInfo['categoryid'], 'title' => $cInfo['category_name'])), 'serendipityHTTPPath'); } echo '<link rel="up" href="' . $categories_url . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($cInfo['category_name']) : htmlspecialchars($cInfo['category_name'], ENT_COMPAT, LANG_CHARSET)) . '" />' . "\n"; echo '<link rel="canonical" href="' . $categories_url . '" />' . "\n"; $categories = serendipity_fetchCategories('all'); $links = array(); if (is_array($categories) && count($categories)) { $categories = serendipity_walkRecursive($categories, 'categoryid', 'parentid', VIEWMODE_THREADED); $capture_next = false; foreach ($categories as $cat) { if ($capture_next) { $links['next'] = $this->getCat($cat); break; } if (is_array($prev_cat) && $cat['categoryid'] == $serendipity['GET']['category']) { $links['prev'] = $this->getCat($prev_cat); $capture_next = true; } $prev_cat = $cat; } } $this->backAndForth($links); // END Category based view } elseif (!empty($serendipity['GET']['viewAuthor'])) { // User view $uInfo = serendipity_fetchUsers(); $links = array(); if (is_array($uInfo)) { $capture_next = false; foreach ($uInfo as $user) { if ($capture_next) { $links['next'] = $this->getUser($user); break; } if ($user['authorid'] == $serendipity['GET']['viewAuthor']) { $authors_url = $this->getUser($user); echo '<link rel="up" href="' . $authors_url['link'] . '" title="' . $authors_url['title'] . '" />' . "\n"; echo '<link rel="canonical" href="' . $authors_url['link'] . '" />' . "\n"; if (is_array($prev_user)) { $links['prev'] = $this->getUser($prev_user); $capture_next = true; } } $prev_user = $user; } $this->backAndForth($links); } // END User view } else { // Frontpage $this->backAndForth(); // END Frontpage if ($serendipity['view'] == 'start') { echo '<link rel="canonical" href="' . $serendipity['baseURL'] . '" />' . "\n"; } } } }
function &getCategories() { global $serendipity; $html = ($serendipity['version'][0] < 2 ? '<strong>' . CATEGORIES . '</strong><br />' : '<span class="wrap_legend"><legend>' . CATEGORIES . '</legend></span>') . "\n"; $all_valid = false; if (is_array($serendipity['POST']['plugin']['enabled_categories'])) { $valid = $this->enabled_categories = array(); foreach ($serendipity['POST']['plugin']['enabled_categories'] as $idx => $id) { $valid[$id] = true; $this->enabled_categories[$id] = true; } } else { $valid =& $this->enabled_categories; if (count($valid) == 0) { $all_valid = true; } } $html .= '<select id="staticblock_enabled_categories" name="serendipity[plugin][enabled_categories][]" multiple="true" size="5">' . "\n"; $html .= ' <option value="-front-" ' . ($all_valid || isset($valid['-front-']) ? "selected='selected'" : '') . '>[' . NO_CATEGORY . ']</option>' . "\n"; if (is_array($cats = serendipity_fetchCategories())) { $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED); foreach ($cats as $cat) { $html .= ' <option value="' . $cat['categoryid'] . '"' . ($all_valid || isset($valid[$cat['categoryid']]) ? ' selected="selected"' : '') . '>' . str_repeat(' ', $cat['depth']) . $cat['category_name'] . '</option>' . "\n"; } } $html .= '</select>' . "\n"; return $html; }
function output_categoryadmin() { global $serendipity; $display = $this->get_config('display'); $categories = $this->build_categories(); $q = "SELECT *\n FROM {$serendipity['dbPrefix']}project_colors\n ORDER BY color_name ASC"; $colors = serendipity_db_query($q); $colortext = '<option value="0" selected="selected">' . USE_DEFAULT . "</option>\n"; foreach ($colors as $color) { $colortext .= '<option value="' . $color['colorid'] . '">' . $color['color_name'] . "</option>\n"; } $maintitle = PLUGIN_EVENT_TODOLIST_ADD_CAT; $button = '<input type="submit" name="ADD" title="' . GO . '" value="' . GO . '" class="serendipityPrettyButton input_button" />'; echo '<h3>' . $maintitle . '</h3>'; ?> <form action="?serendipity[adminModule]=event_display&serendipity[adminAction]=percentagedone&serendipity[manage_category]=1" method="post"> <input type="hidden" name="serendipity[add_project][id]" value="<?php echo $id; ?> "> <table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <td><?php echo PLUGIN_EVENT_TODOLIST_CAT_NAME; ?> </td> <td><input class="input_textbox" type="text" name="serendipity[add_category][title]" size="30" /></td> </tr> <tr> <td><?php echo PLUGIN_EVENT_TODOLIST_PARENT_CATEGORY; ?> </td> <td><?php echo $this->category_box('cat', $categories, $cat); ?> </td> </tr> <tr> <td><?php echo PLUGIN_EVENT_TODOLIST_COLOR; ?> </td> <td><select name="serendipity[add_category][colorid]"><?php echo $colortext; ?> </select></td> </tr> </table> <div><?php echo $button; ?> </div> </form> <?php echo '<h3>' . PLUGIN_EVENT_TODOLIST_ADMINCAT . '</h3>'; ?> <form action="?serendipity[adminModule]=event_display&serendipity[adminAction]=percentagedone&serendipity[manage_category]=1" method="post"> <table border="0" cellpadding="1" cellspacing="0" width="100%"> <tr> <td></td> <td><strong><?php echo CATEGORY; ?> </strong></td> <td><strong><?php echo PLUGIN_EVENT_TODOLIST_COLOR; ?> </strong></td> </tr> <?php $q = "SELECT *\n FROM {$serendipity['dbPrefix']}project_category\n ORDER BY category_name DESC"; $categories = serendipity_db_query($q); $categories = @serendipity_walkRecursive($categories, 'categoryid', 'parentid', VIEWMODE_THREADED); foreach ($categories as $category) { $colortext = '<option value="0" selected="selected">' . USE_DEFAULT . "</option>\n"; foreach ($colors as $color) { if ($color['colorid'] == $category['colorid']) { $colortext .= '<option value="' . $color['colorid'] . '" selected="selected">' . $color['color_name'] . "</option>\n"; } else { $colortext .= '<option value="' . $color['colorid'] . '">' . $color['color_name'] . "</option>\n"; } } ?> <tr> <td width="16"> <input class="input_checkbox" type="checkbox" name="serendipity[category_to_remove][]" value="<?php echo $category['categoryid']; ?> " /> </td> <td width="300" style="padding-left: <?php echo $category['depth'] * 15 + 20; ?> px"><img src="<?php echo serendipity_getTemplateFile('admin/img/folder.png'); ?> " style="vertical-align: bottom;" alt=""> <?php echo function_exists('serendipity_specialchars') ? serendipity_specialchars($category['category_name']) : htmlspecialchars($category['category_name'], ENT_COMPAT, LANG_CHARSET); ?> </td> <td> <select name="serendipity[category_to_recolor][<?php echo $category['categoryid']; ?> ]"><?php echo $colortext; ?> </select> </td> </tr> <?php } ?> </table> <div> <?php echo '<input type="submit" name="SAVE" title="' . SAVE . '" value="' . SAVE . '" class="serendipityPrettyButton input_button" />'; echo ' '; echo '<input type="submit" name="REMOVE" title="' . REMOVE . '" value="' . DELETE . '" class="serendipityPrettyButton input_button" />'; ?> </div> </form> <?php }
function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; $hooks =& $bag->get('event_hooks'); if (isset($hooks[$event])) { switch ($event) { case 'backend_category_showForm': $pages = $this->fetchStaticPages(true); $categorypage = $this->fetchCatProp((int) $eventData); if (debug_staticpage == 'true') { echo "category "; echo (int) $eventData . " "; echo " staticpage "; echo $this->fetchCatProp((int) $eventData); } ?> <tr> <td valign="top"><label for="staticpage_categorypage"><?php echo STATICPAGE_CATEGORYPAGE; ?> </label></td> <td> <select name="serendipity[cat][staticpage_categorypage]"> <option value=""><?php echo NONE; ?> </option> <?php $pages = $this->fetchStaticPages(); if (is_array($pages)) { $pages = serendipity_walkRecursive($pages); foreach ($pages as $page) { if ($this->checkPageUser($page['authorid'])) { echo ' <option value="' . $page['id'] . '" ' . ($page['id'] == $this->fetchCatProp((int) $eventData) ? 'selected="selected"' : '') . '>'; echo str_repeat(' ', $page['depth']) . (function_exists('serendipity_specialchars') ? serendipity_specialchars($page['pagetitle']) : htmlspecialchars($page['pagetitle'], ENT_COMPAT, LANG_CHARSET)) . '</option>'; } } } ?> </select> </td> </tr> <?php return true; break; case 'backend_category_delete': $this->setCatProps($eventData, null, true); /* ** problem: different to backend_category_update and backend_category_addNew, here $eventData did not contain the id of the category, so ** the entry in the table _staticpage_categorypage is not deleted :-( Every time I get "35 AND 36" in the debug-modus. ** GARVIN: Yes, the ID contains a SQL statement for Category ID because the category children are contained as well! */ break; case 'backend_category_update': case 'backend_category_addNew': $val = array('categoryid ' => (int) $eventData, 'staticpage_categorypage' => $serendipity['POST']['cat']['staticpage_categorypage']); $this->setCatProps($eventData, $val); break; case 'frontend_fetchentries': case 'frontend_rss': $this->smarty_init(); break; case 'genpage': $this->setupDB(); $args = implode('/', serendipity_getUriArguments($eventData, true)); if ($serendipity['rewrite'] != 'none') { $nice_url = $serendipity['serendipityHTTPPath'] . $args; } else { $nice_url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/' . $args; } // Manko10 patch: http://board.s9y.org/viewtopic.php?f=3&t=17910&p=10426432#p10426432 // Check if static page exists or if this is an error 404 // // NOTE: as soon as you set a static page to be a 404 handler // from within the backend, you need to add a specific redirect rule // to your .htaccess for each static page generated by other // plugins such as serendipity_event_contactform // This behavior might change in future releases. $this->error_404 = $_SERVER['REDIRECT_STATUS'] == '404'; $pages = $this->fetchStaticPages(true, $nice_url); if (is_array($pages)) { foreach ($pages as $page) { if ($page['permalink'] == $nice_url) { $this->error_404 = FALSE; if ($pages['is_404_page']) { $this->error_404 = TRUE; } break; } } } // Set static page to 404 error document if page not found if ($this->error_404) { $serendipity['GET']['subpage'] = $this->get404Errorpage(); } // Set static page with is_startpage flag set as startpage if ((empty($args) || preg_match('@' . $serendipity['indexFile'] . '\\??$@', trim($args))) && empty($serendipity['GET']['subpage'])) { $serendipity['GET']['subpage'] = $this->getStartpage(); } // Set static page according to requested URL if (empty($serendipity['GET']['subpage'])) { $serendipity['GET']['subpage'] = $nice_url; } if ($this->selected()) { $te = $this->get_static('title_element'); if (!empty($te)) { $serendipity['head_title'] = function_exists('serendipity_specialchars') ? serendipity_specialchars($te) : htmlspecialchars($te, ENT_COMPAT, LANG_CHARSET); $serendipity['head_subtitle'] = ''; } else { $serendipity['head_title'] = $this->get_static('headline'); $serendipity['head_subtitle'] = $serendipity['blogTitle']; } } break; case 'frontend_header': $md = function_exists('serendipity_specialchars') ? serendipity_specialchars($this->get_static('meta_description')) : htmlspecialchars($this->get_static('meta_description'), ENT_COMPAT, LANG_CHARSET); $mk = function_exists('serendipity_specialchars') ? serendipity_specialchars($this->get_static('meta_keywords')) : htmlspecialchars($this->get_static('meta_keywords'), ENT_COMPAT, LANG_CHARSET); if (!empty($md)) { echo ' <meta name="description" content="' . $md . '" />' . "\n"; } if (!empty($mk)) { echo ' <meta name="keywords" content="' . $mk . '" />' . "\n"; } break; case 'frontend_fetchentries': if ($serendipity['GET']['action'] == 'search') { serendipity_smarty_fetch('ENTRIES', 'entries.tpl', true); } break; case 'entry_display': $this->smarty_init(); if ($this->selected()) { if (is_array($eventData)) { $eventData['clean_page'] = true; // This is important to not display an entry list! } else { $eventData = array('clean_page' => true); } } break; case 'backend_sidebar_entries': $this->setupDB(); echo '<li class="serendipitySideBarMenuLink serendipitySideBarMenuEntryLinks"><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=staticpages">' . STATICPAGE_TITLE . '</a></li>'; break; case 'backend_sidebar_entries_event_display_staticpages': $this->showBackend(); break; case 'backend_media_rename': // Only MySQL supported, since I don't know how to use REGEXPs differently. if ($serendipity['dbType'] != 'mysql' && $serendipity['dbType'] != 'mysqli') { echo STATICPAGE_MEDIA_DIRECTORY_MOVE_ENTRY . '<br />'; break; } if (!isset($eventData[0]['oldDir'])) { return true; } if ($eventData[0]['type'] == 'dir') { } elseif ($eventData[0]['type'] == 'filedir') { $eventData[0]['oldDir'] .= $eventData[0]['name']; $eventData[0]['newDir'] .= $eventData[0]['name']; } $q = "SELECT id, content, pre_content\n FROM {$serendipity['dbPrefix']}staticpages\n WHERE content REGEXP '(src=|href=|window.open.)(\\'|\")(" . serendipity_db_escape_String($serendipity['baseURL'] . $serendipity['uploadHTTPPath'] . $eventData[0]['oldDir']) . "|" . serendipity_db_escape_string($serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $eventData[0]['oldDir']) . ")'\n OR pre_content REGEXP '(src=|href=|window.open.)(\\'|\")(" . serendipity_db_escape_String($serendipity['baseURL'] . $serendipity['uploadHTTPPath'] . $eventData[0]['oldDir']) . "|" . serendipity_db_escape_string($serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $eventData[0]['oldDir']) . ")'\n "; $dirs = serendipity_db_query($q); if (is_array($dirs)) { foreach ($dirs as $dir) { $dir['content'] = preg_replace('@(src=|href=|window.open.)(\'|")(' . preg_quote($serendipity['baseURL'] . $serendipity['uploadHTTPPath'] . $eventData[0]['oldDir']) . '|' . preg_quote($serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $eventData[0]['oldDir']) . ')@', '\\1\\2' . $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $eventData[0]['newDir'], $dir['content']); $dir['pre_content'] = preg_replace('@(src=|href=|window.open.)(\'|")(' . preg_quote($serendipity['baseURL'] . $serendipity['uploadHTTPPath'] . $eventData[0]['oldDir']) . '|' . preg_quote($serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $eventData[0]['oldDir']) . ')@', '\\1\\2' . $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $eventData[0]['newDir'], $dir['pre_content']); $uq = "UPDATE {$serendipity['dbPrefix']}staticpages\n SET content = '" . serendipity_db_escape_string($dir['content']) . "' ,\n pre_content = '" . serendipity_db_escape_string($dir['pre_content']) . "'\n WHERE id = " . serendipity_db_escape_string($dir['id']); serendipity_db_query($uq); } printf(STATICPAGE_MEDIA_DIRECTORY_MOVE_ENTRIES . '<br />', count($dirs)); } break; case 'external_plugin': $parts = explode('_', $eventData); if (!empty($parts[1])) { $param = (int) $parts[1]; } else { $param = null; } if ($parts[0] == 'dtree.js') { header('Content-Type: text/javascript'); echo file_get_contents(dirname(__FILE__) . '/dtree.js'); } break; case 'entries_header': if (!$this->isplugin()) { $this->show(); } break; case 'entries_footer': if ($serendipity['GET']['action'] == 'search' && serendipity_db_bool($this->get_config('use_quicksearch'))) { $this->showSearch(); } break; case 'css_backend': if (!strpos($eventData, '#serendipityStaticpagesNav')) { // class exists in CSS, so a user has customized it and we don't need default echo file_get_contents(dirname(__FILE__) . '/style_staticpage_backend.css'); } break; default: return false; } return true; } return false; }
function showFrontend() { global $serendipity; header('Content-Type: text/html; charset=' . LANG_CHARSET); include_once S9Y_INCLUDE_PATH . 'include/genpage.inc.php'; if (is_string($serendipity['uriArguments'][2]) && isset($serendipity['languages'][$serendipity['uriArguments'][2]])) { $faq_language = $serendipity['uriArguments'][2]; $faq_categoryid = $serendipity['uriArguments'][3]; $faq_faqid = $serendipity['uriArguments'][4]; } else { $faq_language = $serendipity['lang']; $faq_categoryid = $serendipity['uriArguments'][2]; $faq_faqid = $serendipity['uriArguments'][3]; } if (is_numeric($faq_categoryid)) { $res['parent_id'] = $faq_categoryid; do { $q = 'SELECT id, category, parent_id FROM ' . $serendipity['dbPrefix'] . 'faq_categorys WHERE id = ' . $res['parent_id']; $res = serendipity_db_query($q, true, 'assoc'); $cat_tree[] = $res; } while ($res['parent_id'] != 0); krsort($cat_tree); $serendipity['smarty']->assign('cat_tree', $cat_tree); if (is_numeric($faq_faqid)) { $q = 'SELECT question, answer, category, faqorder, catorder, parent_id FROM ' . $serendipity['dbPrefix'] . 'faqs, ' . $serendipity['dbPrefix'] . 'faq_categorys WHERE ' . $serendipity['dbPrefix'] . 'faqs.id = ' . $faq_faqid . ' AND ' . $serendipity['dbPrefix'] . 'faqs.cid = ' . $serendipity['dbPrefix'] . 'faq_categorys.id ORDER BY faqorder'; $faq = serendipity_db_query($q, true, 'assoc'); if (is_array($faq)) { $q = 'SELECT ' . $serendipity['dbPrefix'] . 'faqs.id, question, cid, category FROM ' . $serendipity['dbPrefix'] . 'faqs, ' . $serendipity['dbPrefix'] . 'faq_categorys WHERE ' . $serendipity['dbPrefix'] . 'faqs.cid = ' . $faq_categoryid . ' AND ' . $serendipity['dbPrefix'] . 'faqs.faqorder = ' . ($faq['faqorder'] + 1) . ' AND ' . $serendipity['dbPrefix'] . 'faqs.cid = ' . $serendipity['dbPrefix'] . 'faq_categorys.id'; $nfaq = serendipity_db_query($q, true, 'assoc'); if (!is_array($nfaq)) { $q = 'SELECT ' . $serendipity['dbPrefix'] . 'faqs.id, question, cid, category FROM ' . $serendipity['dbPrefix'] . 'faqs, ' . $serendipity['dbPrefix'] . 'faq_categorys WHERE ' . $serendipity['dbPrefix'] . 'faq_categorys.catorder = ' . ($faq['catorder'] + 1) . ' AND ' . $serendipity['dbPrefix'] . 'faq_categorys.parent_id = ' . $faq['parent_id'] . ' AND ' . $serendipity['dbPrefix'] . 'faqs.faqorder = 1 AND ' . $serendipity['dbPrefix'] . 'faqs.cid = ' . $serendipity['dbPrefix'] . 'faq_categorys.id'; $nfaq = serendipity_db_query($q, true, 'assoc'); } $q = 'SELECT ' . $serendipity['dbPrefix'] . 'faqs.id, question, cid, category FROM ' . $serendipity['dbPrefix'] . 'faqs, ' . $serendipity['dbPrefix'] . 'faq_categorys WHERE ' . $serendipity['dbPrefix'] . 'faqs.cid = ' . $faq_categoryid . ' AND ' . $serendipity['dbPrefix'] . 'faqs.faqorder = ' . ($faq['faqorder'] - 1) . ' AND ' . $serendipity['dbPrefix'] . 'faqs.cid = ' . $serendipity['dbPrefix'] . 'faq_categorys.id'; $pfaq = serendipity_db_query($q, true, 'assoc'); if (!is_array($pfaq)) { $q = 'SELECT MAX(faqorder) AS fmax FROM ' . $serendipity['dbPrefix'] . 'faqs, ' . $serendipity['dbPrefix'] . 'faq_categorys WHERE ' . $serendipity['dbPrefix'] . 'faq_categorys.catorder = ' . ($faq['catorder'] - 1) . ' AND ' . $serendipity['dbPrefix'] . 'faq_categorys.parent_id = ' . $faq['parent_id'] . ' AND ' . $serendipity['dbPrefix'] . 'faqs.cid = ' . $serendipity['dbPrefix'] . 'faq_categorys.id'; $max = serendipity_db_query($q, true, 'assoc'); $q = 'SELECT ' . $serendipity['dbPrefix'] . 'faqs.id, question, cid, category FROM ' . $serendipity['dbPrefix'] . 'faqs, ' . $serendipity['dbPrefix'] . 'faq_categorys WHERE ' . $serendipity['dbPrefix'] . 'faq_categorys.catorder = ' . ($faq['catorder'] - 1) . ' AND ' . $serendipity['dbPrefix'] . 'faqs.faqorder = ' . ($max['fmax'] ? $max['fmax'] : 0) . ' AND ' . $serendipity['dbPrefix'] . 'faqs.cid = ' . $serendipity['dbPrefix'] . 'faq_categorys.id'; $pfaq = serendipity_db_query($q, true, 'assoc'); } } if (serendipity_db_bool($this->get_config('markup', true))) { $entry['body'] =& $faq['question']; serendipity_plugin_api::hook_event('frontend_display', $entry); $entry['body'] =& $faq['answer']; serendipity_plugin_api::hook_event('frontend_display', $entry); } $filename = 'plugin_faq_category_faq.tpl'; $serendipity['smarty']->assign('faq_plugin', array('this_faq' => array('faqid' => $faq_faqid, 'question' => $faq['question'], 'answer' => $faq['answer'], 'categoryid' => $faq_categoryid, 'category' => $faq['category']), 'next_faq' => array('faqid' => $nfaq['id'], 'question' => $nfaq['question'], 'categoryid' => $nfaq['cid'], 'category' => $nfaq['category']), 'prev_faq' => array('faqid' => $pfaq['id'], 'question' => $pfaq['question'], 'categoryid' => $pfaq['cid'], 'category' => $pfaq['category']))); } else { $q = 'SELECT id, cid, question, changedate, changetype FROM ' . $serendipity['dbPrefix'] . 'faqs WHERE cid = ' . $faq_categoryid . ' ORDER BY faqorder'; $faqs = serendipity_db_query($q, false, 'assoc'); if (is_array($faqs)) { $now = time(); $days_new = $this->get_config('daysnew') * 86400; $days_upd = $this->get_config('daysupdate') * 86400; for ($i = 0, $ii = count($faqs); $i < $ii; $i++) { switch ($faqs[$i]['changetype']) { case 'new': if ($now - $faqs[$i]['changedate'] <= $days_new) { $faqs[$i]['status'] = FAQ_NEW; } else { $faqs[$i]['status'] = ''; } break; case 'update': if ($now - $faqs[$i]['changedate'] <= $days_upd) { $faqs[$i]['status'] = FAQ_UPDATE; } else { $faqs[$i]['status'] = ''; } break; default: $faqs[$i]['status'] = ''; break; } } } $q = 'SELECT id, category FROM ' . $serendipity['dbPrefix'] . 'faq_categorys WHERE parent_id = ' . $faq_categoryid . ' ORDER BY catorder'; $scat = serendipity_db_query($q, false, 'assoc'); $q = 'SELECT category, introduction FROM ' . $serendipity['dbPrefix'] . 'faq_categorys WHERE id = ' . $faq_categoryid; $cat = serendipity_db_query($q, true, 'assoc'); $filename = 'plugin_faq_category_faqs.tpl'; if (serendipity_db_bool($this->get_config('markup', true))) { $entry['body'] =& $cat['introduction']; serendipity_plugin_api::hook_event('frontend_display', $entry); } $serendipity['smarty']->assign('faq_plugin', array('faqs' => $faqs, 'subcategories' => $scat, 'category' => $cat['category'], 'introduction' => $cat['introduction'], 'catid' => $faq_categoryid)); } } else { $q = "SELECT *\n FROM {$serendipity['dbPrefix']}faq_categorys\n WHERE language = '{$faq_language}'\n ORDER BY catorder"; $cats = serendipity_db_query($q, false, 'assoc'); if (is_array($cats)) { $cats = serendipity_walkRecursive($cats); if (serendipity_db_bool($this->get_config('markup', true))) { for ($i = 0, $ii = count($cats); $i < $ii; $i++) { $entry['body'] =& $cats[$i]['introduction']; serendipity_plugin_api::hook_event('frontend_display', $entry); } } $serendipity['smarty']->assign('faq_plugin', array('categories' => $cats)); } $filename = 'plugin_faq_categories.tpl'; } if ($serendipity['rewrite'] == 'none') { $pluginpath = $serendipity['indexFile'] . '?/' . $serendipity['permalinkPluginPath'] . '/' . $this->get_config('faqurl', 'faqs'); } else { $pluginpath = $serendipity['permalinkPluginPath'] . '/' . $this->get_config('faqurl', 'faqs'); } $serendipity['smarty']->append('faq_plugin', array('plugin_url' => trim($pluginpath)), true); $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('CONTENT', $content); $serendipity['smarty']->display(serendipity_getTemplateFile($serendipity['smarty_file'], 'serendipityPath')); }
/** * Prints the form for editing/creating new blog entries * * This is the core file where your edit form appears. The Heart Of Gold, so to say. * * @access public * @param string The URL where the entry form is submitted to * @param array An array of hidden input fields that should be passed on to the HTML FORM * @param array The entry superarray with your entry's contents * @param string Any error messages that might have occured on the last run * @return null */ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = array(), $errMsg = "") { global $serendipity; $serendipity['EditorBrowsers'] = '@(IE|Mozilla|Opera)@i'; $draftD = ''; $draftP = ''; $categoryselector_expanded = false; $template_vars = array(); serendipity_plugin_api::hook_event('backend_entryform', $entry); if (isset($entry['isdraft']) && serendipity_db_bool($entry['isdraft']) || !isset($entry['isdraft']) && $serendipity['publishDefault'] == 'draft') { $draftD = ' selected="selected"'; $template_vars['draft_mode'] = 'draft'; } else { $draftP = ' selected="selected"'; $template_vars['draft_mode'] = 'publish'; } if (isset($entry['moderate_comments']) && serendipity_db_bool($entry['moderate_comments'])) { $template_vars['moderate_comments'] = true; $moderate_comments = ' checked="checked"'; } elseif (!isset($entry['moderate_comments']) && ($serendipity['moderateCommentsDefault'] == 'true' || $serendipity['moderateCommentsDefault'] === true)) { // This is the default on creation of a new entry and depends on the "moderateCommentsDefault" variable of the configuration. $moderate_comments = ' checked="checked"'; $template_vars['moderate_comments'] = true; } else { $moderate_comments = ''; $template_vars['moderate_comments'] = false; } if (isset($entry['allow_comments']) && serendipity_db_bool($entry['allow_comments'])) { $template_vars['allow_comments'] = true; $allow_comments = ' checked="checked"'; } elseif ((!isset($entry['allow_comments']) || $entry['allow_comments'] !== 'false') && (!isset($serendipity['allowCommentsDefault']) || $serendipity['allowCommentsDefault'] == 'true' || $serendipity['allowCommentsDefault'] === true)) { // This is the default on creation of a new entry and depends on the "allowCommentsDefault" variable of the configuration. $template_vars['allow_comments'] = true; $allow_comments = ' checked="checked"'; } else { $template_vars['allow_comments'] = false; $allow_comments = ''; } // Fix category list. If the entryForm is displayed after a POST request, the additional category information is lost. if (is_array($entry['categories']) && !is_array($entry['categories'][0])) { $categories = (array) $entry['categories']; $entry['categories'] = array(); foreach ($categories as $catid) { $entry['categories'][] = serendipity_fetchCategoryInfo($catid); } } $n = "\n"; $cat_list = '<select id="categoryselector" name="serendipity[categories][]" style="vertical-align: middle;" multiple="multiple">' . $n; $cat_list .= ' <option value="0">[' . NO_CATEGORY . ']</option>' . $n; $selected = array(); if (is_array($entry['categories'])) { if (count($entry['categories']) > 1) { $categoryselector_expanded = true; } foreach ($entry['categories'] as $cat) { $selected[] = $cat['categoryid']; } } if (count($selected) > 1 || isset($serendipity['POST']['categories']) && is_array($serendipity['POST']['categories']) && sizeof($serendipity['POST']['categories']) > 1) { $categoryselector_expanded = true; } if (is_array($cats = serendipity_fetchCategories())) { $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED); foreach ($cats as $cat) { if (in_array($cat['categoryid'], $selected)) { $cat['is_selected'] = true; } $cat['depth_pad'] = str_repeat(' ', $cat['depth']); $template_vars['category_options'][] = $cat; $cat_list .= '<option value="' . $cat['categoryid'] . '"' . ($cat['is_selected'] ? ' selected="selected"' : '') . '>' . $cat['depth_pad'] . $cat['category_name'] . '</option>' . "\n"; } } $cat_list .= '</select>' . $n; if (!empty($serendipity['GET']['title'])) { $entry['title'] = utf8_decode(urldecode($serendipity['GET']['title'])); } if (!empty($serendipity['GET']['body'])) { $entry['body'] = utf8_decode(urldecode($serendipity['GET']['body'])); } if (!empty($serendipity['GET']['url'])) { $entry['body'] .= "\n" . '<br /><a href="' . htmlspecialchars(utf8_decode(urldecode($serendipity['GET']['url']))) . '">' . $entry['title'] . '</a>'; } $hidden = ''; foreach ($hiddens as $key => $value) { $hidden .= ' <input type="hidden" name="' . $key . '" value="' . $value . '" />' . $n; } $hidden .= ' <input type="hidden" id="entryid" name="serendipity[id]" value="' . (isset($entry['id']) ? $entry['id'] : '') . '" />' . $n; $hidden .= ' <input type="hidden" name="serendipity[timestamp]" value="' . (isset($entry['timestamp']) ? serendipity_serverOffsetHour($entry['timestamp']) : serendipity_serverOffsetHour(time())) . '" />' . $n; $hidden .= ' <input type="hidden" name="serendipity[preview]" value="false" />'; $hidden .= ' ' . serendipity_setFormToken(); if (is_object($serendipity['smarty']) || !$_SESSION['no_smarty'] && serendipity_smarty_init()) { $use_smarty = true; } else { $use_smarty = false; } if (is_object($serendipity['smarty'])) { if (isset($serendipity['allowDateManipulation']) && $serendipity['allowDateManipulation']) { $template_vars['allowDateManipulation'] = true; } if ((!empty($entry['extended']) || !empty($serendipity['COOKIE']['toggle_extended'])) && !$serendipity['wysiwyg']) { $template_vars['show_wysiwyg'] = true; } if (preg_match($serendipity['EditorBrowsers'], $_SERVER['HTTP_USER_AGENT'])) { $template_vars['wysiwyg_advanced'] = true; } $template_vars['timestamp'] = serendipity_serverOffsetHour(isset($entry['timestamp']) && $entry['timestamp'] > 0 ? $entry['timestamp'] : time()); $template_vars['reset_timestamp'] = serendipity_serverOffsetHour(time()); $template_vars['hidden'] = $hidden; $template_vars['errMsg'] = $errMsg; $template_vars['entry'] =& $entry; $template_vars['targetURL'] = $targetURL; $template_vars['cat_count'] = count($cats) + 1; $template_vars['cat_state'] = $categoryselector_expanded ? 'on' : 'off'; $template_vars['wysiwyg'] = $serendipity['wysiwyg']; $template_vars['serendipityRightPublish'] = $_SESSION['serendipityRightPublish']; $template_vars['wysiwyg_blocks'] = array('body' => 'serendipity[body]', 'extended' => 'serendipity[extended]'); $template_vars['entry_template'] = serendipity_getTemplateFile('admin/entries.tpl', 'serendipityPath'); $serendipity['smarty']->registerPlugin('modifier', 'emit_htmlarea_code', 'serendipity_emit_htmlarea_code'); $serendipity['smarty']->assign('admin_view', 'entryform'); serendipity_plugin_api::hook_event('backend_entryform_smarty', $template_vars); $serendipity['smarty']->assignByRef('entry_vars', $template_vars); $serendipity['smarty']->display($template_vars['entry_template']); return true; } /* HTML CODE BELOW IS FOR FALLBACK PORTABILITY ONLY - MODIFY CODE IN TEMPLATE ADMIN/ENTRIES.TPL INSTEAD! */ if (!empty($errMsg)) { ?> <div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="<?php echo serendipity_getTemplateFile('admin/img/admin_msg_error.png'); ?> " alt="" /><?php echo $errMsg; ?> </div> <?php } ?> <form <?php echo $entry['entry_form']; ?> action="<?php echo $targetURL; ?> " method="post" id="serendipityEntry" style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px"> <?php echo $hidden; ?> <table class="serendipityEntryEdit" border="0" width="100%"> <tr> <td> <b><?php echo TITLE; ?> :</b> </td> <td colspan="2"> <table width="100%" cellspacing="0" cellpadding="0" border="0"> <tr> <td><input class="input_textbox" type="text" id="entryTitle" name="serendipity[title]" value="<?php echo isset($entry['title']) ? htmlspecialchars($entry['title']) : ''; ?> " size="60" /></td> <td align="right"> <select name="serendipity[isdraft]"> <?php if ($_SESSION['serendipityRightPublish']) { ?> <option value="false" <?php echo $draftP; ?> ><?php echo PUBLISH; ?> </option><?php } ?> <option value="true" <?php echo $draftD; ?> ><?php echo DRAFT; ?> </option> </select> </td> </tr> </table> </td> </tr> <tr> <?php if (isset($serendipity['allowDateManipulation']) && $serendipity['allowDateManipulation']) { ?> <td> <b><?php echo DATE; ?> :</b> </td> <td> <input type="hidden" name="serendipity[chk_timestamp]" value="<?php echo serendipity_serverOffsetHour(isset($entry['timestamp']) && $entry['timestamp'] > 0 ? $entry['timestamp'] : time()); ?> " /> <input class="input_textbox" type="text" name="serendipity[new_timestamp]" id="serendipityNewTimestamp" value="<?php echo date(DATE_FORMAT_2, serendipity_serverOffsetHour(isset($entry['timestamp']) && $entry['timestamp'] > 0 ? $entry['timestamp'] : time())); ?> " /> <a href="#" onclick="document.getElementById('serendipityNewTimestamp').value = '<?php echo date(DATE_FORMAT_2, serendipity_serverOffsetHour(time())); ?> '; return false;" title="<?php echo RESET_DATE_DESC; ?> "><img src="<?php echo serendipity_getTemplateFile('admin/img/clock.png'); ?> " border="0" style="vertical-align: text-top;" alt="<?php echo RESET_DATE; ?> " /></a> </td> <td align="right"> <?php } else { ?> <td align="right" colspan="3"> <?php } ?> <a style="border:0; text-decoration: none" href="#" onclick="showItem('categoryselector'); return false" title="<?php echo TOGGLE_OPTION; ?> "><img src="<?php echo serendipity_getTemplateFile('img/plus.png'); ?> " id="option_categoryselector" style="border: 20px" alt="" border="0" /></a> <b><?php echo CATEGORY; ?> :</b> <?php echo $cat_list; ?> <script type="text/javascript" language="JavaScript"> function toggle_extended(setCookie) { var textarea = document.getElementById('serendipity[extended]'); var button = document.getElementById('option_extended'); var tools = document.getElementById('tools_extended'); if ( textarea.style.display == 'none' ) { textarea.style.display = ''; tools.style.display = ''; button.src = '<?php echo serendipity_getTemplateFile('img/minus.png'); ?> '; if (setCookie == true) { document.cookie = 'serendipity[toggle_extended]=true;'; } } else { textarea.style.display = 'none'; tools.style.display = 'none'; button.src = '<?php echo serendipity_getTemplateFile('img/plus.png'); ?> '; if (setCookie == true) { document.cookie = 'serendipity[toggle_extended]=;'; } } } var selector_toggle = new Array(); var selector_store = new Array(); var selector_restore = new Array(); function showItem(id) { var selected = 0; if (typeof(id) == 'undefined' || typeof(id) == 'object') { id = 'categoryselector'; } if (document.getElementById) { el = document.getElementById(id); if (selector_toggle[id] && selector_toggle[id] == 'off') { selector_restore[id] = new Array(); selector_toggle[id] = 'on'; /* Hack to make sure that when the single dropdown is shown, don't have multiple selections */ last = 0; for (i=0; i < el.options.length; i++) { if (el.options[i].selected == true) { selected++; last = i; selector_restore[id][last] = 'on'; } if (selected > 1) { /* If there is more than one selected, we reset all those to false This is because otherwise the label will say 'No Category', but the categories will still be selected */ for (j=0; j < el.options.length; j++) { /* Save selection in array to later restore them */ if (el.options[j].selected == true) { el.options[j].selected = false; selector_restore[id][j] = 'on'; last = j; } else { selector_restore[id][j] = false; } } break; } } el.selectedIndex = null; if (last > 0) { el.selectedIndex = last; } el.size = 1; /* Show a normal dropdown */ if (el.multiple) { el.multiple = false; } document.getElementById('option_' + id).src = '<?php echo serendipity_getTemplateFile('img/plus.png'); ?> '; } else { selector_store[id] = el.size; if (selector_store[id] == 0) { selector_store[id] = 5; } last = 0; if (el.selectedIndex > 0) { if (!selector_restore[id]) { selector_restore[id] = new Array(); } for (j=0; j < el.options.length; j++) { /* Save selection in array to later restore them */ if (el.options[j].selected == true) { selector_restore[id][j] = 'on'; last = j; } } } el.selectedIndex = -1; el.size = <?php echo count($cats) + 1; ?> ; selector_toggle[id] = 'off'; /* Show multiple items */ el.multiple = true; /* Restore previously selected items? */ last = 0; for (i = 0; i < el.options.length; i++) { if (selector_restore && selector_restore[id] && selector_restore[id][i] && selector_restore[id][i] == 'on') { val = el.options[i].value; if (el.options[i].selected != true) { el.options[i].selected = true; last = i; // [TODO] IE Bug: Don't ask me why, but this restoring only works in Internet Explorer if you put this: // alert('it doesnt matter what, just the alert is important'); } } } document.getElementById('option_' + id).src = '<?php echo serendipity_getTemplateFile('img/minus.png'); ?> '; } } } function checkSave() { <?php $void = null; serendipity_plugin_api::hook_event('backend_entry_checkSave', $void); ?> return true; } selector_toggle['categoryselector'] = '<?php echo $categoryselector_expanded ? 'on' : 'off'; ?> '; addLoadEvent(showItem); </script> </td> </tr> <tr> <?php if (!$serendipity['wysiwyg']) { ?> <td colspan="2"><b><?php echo ENTRY_BODY; ?> </b></td> <td align="right"> <?php /* Since the user has WYSIWYG editor disabled, we want to check if we should use the "better" non-WYSIWYG editor */ if (!$serendipity['wysiwyg'] && preg_match($serendipity['EditorBrowsers'], $_SERVER['HTTP_USER_AGENT'])) { ?> <script type="text/javascript" language="JavaScript"> document.write('<input type="button" class="serendipityPrettyButton input_button" name="insI" value="I" accesskey="i" style="font-style: italic" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'<em>\',\'</em>\')" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insB" value="B" accesskey="b" style="font-weight: bold" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'<strong>\',\'</strong>\')" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insU" value="U" accesskey="u" style="text-decoration: underline;" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'<u>\',\'</u>\')" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insQ" value="<?php echo QUOTE; ?> " accesskey="q" style="font-style: italic" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'<blockquote>\',\'</blockquote>\')" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insJ" value="img" accesskey="j" onclick="wrapInsImage(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insImage" value="<?php echo MEDIA; ?> " style="" onclick="window.open(\'serendipity_admin_image_selector.php?serendipity[textarea]=body\', \'ImageSel\', \'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1\');" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insURL" value="URL" accesskey="l" onclick="wrapSelectionWithLink(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])" />'); </script> <?php /* Do the "old" non-WYSIWYG editor */ } elseif (!$serendipity['wysiwyg']) { ?> <script type="text/javascript" language="JavaScript"> document.write('<input type="button" class="serendipityPrettyButton input_button" value=" B " onclick="serendipity_insBasic(document.forms[\'serendipityEntry\'][\'serendipity[body]\'], \'b\')">'); document.write('<input type="button" class="serendipityPrettyButton input_button" value=" U " onclick="serendipity_insBasic(document.forms[\'serendipityEntry\'][\'serendipity[body]\'], \'u\')">'); document.write('<input type="button" class="serendipityPrettyButton input_button" value=" I " onclick="serendipity_insBasic(document.forms[\'serendipityEntry\'][\'serendipity[body]\'], \'i\')">'); document.write('<input type="button" class="serendipityPrettyButton input_button" value="<img>" onclick="serendipity_insImage(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])">'); document.write('<input type="button" class="serendipityPrettyButton input_button" value="<?php echo MEDIA; ?> " onclick="window.open(\'serendipity_admin_image_selector.php?serendipity[textarea]=body\', \'ImageSel\', \'width=800,height=600,toolbar=no\');">'); document.write('<input type="button" class="serendipityPrettyButton input_button" value="Link" onclick="serendipity_insLink(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])">'); </script> <?php } serendipity_plugin_api::hook_event('backend_entry_toolbar_body', $entry); } else { ?> <td colspan="2"><b><?php echo ENTRY_BODY; ?> </b></td> <td><?php serendipity_plugin_api::hook_event('backend_entry_toolbar_body', $entry); ?> <?php } ?> </td> </tr> <tr> <td colspan="3"> <textarea style="width: 100%" name="serendipity[body]" id="serendipity[body]" cols="80" rows="20"><?php echo isset($entry['body']) ? htmlspecialchars($entry['body']) : ''; ?> </textarea> </td> </tr> <tr> <td colspan="3"> <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td align="left" width="70%"> <input class="input_checkbox" id="checkbox_allow_comments" type="checkbox" name="serendipity[allow_comments]" value="true" <?php echo $allow_comments; ?> /><label for="checkbox_allow_comments"><?php echo COMMENTS_ENABLE; ?> </label><br /> <input class="input_checkbox" id="checkbox_moderate_comments" type="checkbox" name="serendipity[moderate_comments]" value="true" <?php echo $moderate_comments; ?> /><label for="checkbox_moderate_comments"><?php echo COMMENTS_MODERATE; ?> </label> </td> <td align="right" rowspan="2" valign="middle" width="30%"> <input accesskey="p" type="submit" value="- <?php echo PREVIEW; ?> -" class="serendipityPrettyButton input_button" style="width: 150px" onclick="document.forms['serendipityEntry'].elements['serendipity[preview]'].value='true';" /><br /> <input accesskey="s" type="submit" onclick="return checkSave();" value="- <?php echo SAVE; ?> -" class="serendipityPrettyButton input_button" style="width: 150px" /> </td> </tr> </table> <br /> </td> </tr> <tr> <td colspan="2"> <?php if (!$serendipity['wysiwyg']) { ?> <a style="border:0; text-decoration: none" href="#" onclick="toggle_extended(true); return false;" title="<?php echo TOGGLE_OPTION; ?> "><img src="<?php echo serendipity_getTemplateFile('img/plus.png'); ?> " id="option_extended" alt="+/-" border="0" /></a> <?php } ?> <b><?php echo EXTENDED_BODY; ?> </b></td> <td align="right"> <?php if (!$serendipity['wysiwyg']) { ?> <div id="tools_extended" style="display: none"> <?php /* Since the user has WYSIWYG editor disabled, we want to check if we should use the "better" non-WYSIWYG editor */ if (preg_match($serendipity['EditorBrowsers'], $_SERVER['HTTP_USER_AGENT'])) { ?> <input type="button" class="serendipityPrettyButton input_button" name="insI" value="I" accesskey="i" style="font-style: italic" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'],'<em>','</em>')" /> <input type="button" class="serendipityPrettyButton input_button" name="insB" value="B" accesskey="b" style="font-weight: bold" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'],'<strong>','</strong>')" /> <input type="button" class="serendipityPrettyButton input_button" name="insU" value="U" accesskey="u" style="text-decoration: underline;" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'],'<u>','</u>')" /> <input type="button" class="serendipityPrettyButton input_button" name="insQ" value="<?php echo QUOTE; ?> " accesskey="q" style="font-style: italic" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'],'<blockquote>','</blockquote>')" /> <input type="button" class="serendipityPrettyButton input_button" name="insJ" value="img" accesskey="j" onclick="wrapInsImage(document.forms['serendipityEntry']['serendipity[extended]'])" /> <input type="button" class="serendipityPrettyButton input_button" name="insImage" value="<?php echo MEDIA; ?> " onclick="window.open('serendipity_admin_image_selector.php?serendipity[textarea]=extended', 'ImageSel', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1');" /> <input type="button" class="serendipityPrettyButton input_button" name="insURL" value="URL" accesskey="l" onclick="wrapSelectionWithLink(document.forms['serendipityEntry']['serendipity[extended]'])" /> <?php /* Do the "old" non-WYSIWYG editor */ } else { ?> <input type="button" class="serendipityPrettyButton input_button" value=" B " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[extended]'], 'b')"> <input type="button" class="serendipityPrettyButton input_button" value=" U " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[extended]'], 'u')"> <input type="button" class="serendipityPrettyButton input_button" value=" I " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[extended]'], 'i')"> <input type="button" class="serendipityPrettyButton input_button" value="<img>" onclick="serendipity_insImage(document.forms['serendipityEntry']['serendipity[extended]'])"> <input type="button" class="serendipityPrettyButton input_button" value="<?php echo MEDIA; ?> " onclick="window.open('serendipity_admin_image_selector.php?serendipity[textarea]=extended', 'ImageSel', 'width=800,height=600,toolbar=no');"> <input type="button" class="serendipityPrettyButton input_button" value="Link" onclick="serendipity_insLink(document.forms['serendipityEntry']['serendipity[extended]'])"> <?php } serendipity_plugin_api::hook_event('backend_entry_toolbar_extended', $entry); ?> </div> <?php } else { serendipity_plugin_api::hook_event('backend_entry_toolbar_extended', $entry); } ?> </td> </tr> <tr> <td colspan="3"> <textarea style="width: 100%;" name="serendipity[extended]" id="serendipity[extended]" cols="80" rows="20"><?php echo isset($entry['extended']) ? htmlspecialchars($entry['extended']) : ''; ?> </textarea> <?php if (!$serendipity['wysiwyg']) { ?> <script type="text/javascript" language="JavaScript"> toggle_extended(); </script> <?php } ?> </td> </tr> <tr> <td colspan="3"> <br /> <fieldset> <legend><b><?php echo ADVANCED_OPTIONS; ?> </b></legend> <?php serendipity_plugin_api::hook_event('backend_display', $entry); ?> </fieldset> </td> </tr> </table> </form> <?php if ((!empty($entry['extended']) || !empty($serendipity['COOKIE']['toggle_extended'])) && !$serendipity['wysiwyg']) { ?> <script type="text/javascript" language="JavaScript"> toggle_extended(); </script> <?php } if ($serendipity['wysiwyg']) { $fields = array('body' => 'serendipity[body]', 'extended' => 'serendipity[extended]'); foreach ($fields as $f_jsname => $f_item) { serendipity_emit_htmlarea_code($f_item, $f_jsname); } serendipity_plugin_api::hook_event('backend_wysiwyg_finish', $fields); } echo ' <script type="text/javascript" language="JavaScript" src="serendipity_define.js.php"></script>'; echo ' <script type="text/javascript" language="JavaScript" src="serendipity_editor.js"></script>'; }
function generate_content(&$title) { global $serendipity; $title = $this->get_config('title'); $smarty = serendipity_db_bool($this->get_config('smarty', false)); $which_category = $this->get_config('authorid'); $sort = $this->get_config('sort_order'); if ($sort == 'none') { $sort = ''; } else { $sort .= ' ' . $this->get_config('sort_method'); } $is_form = serendipity_db_bool($this->get_config('allow_select')); if ($which_category === "login") { $which_category = (int) $serendipity['authorid']; if ($which_category === 0) { $which_category = -1; // Set to -1 for anonymous authors to get a proper match. } } $categories = serendipity_fetchCategories(empty($which_category) ? 'all' : $which_category, '', $sort, 'read'); $cat_count = array(); if (serendipity_db_bool($this->get_config('show_count'))) { $cat_sql = "SELECT c.categoryid, c.category_name, count(e.id) as postings\n FROM {$serendipity['dbPrefix']}entrycat ec,\n {$serendipity['dbPrefix']}category c,\n {$serendipity['dbPrefix']}entries e\n WHERE ec.categoryid = c.categoryid\n AND ec.entryid = e.id\n AND e.isdraft = 'false'\n " . (!serendipity_db_bool($serendipity['showFutureEntries']) ? " AND e.timestamp <= " . serendipity_db_time() : '') . "\n GROUP BY c.categoryid, c.category_name\n ORDER BY postings DESC"; $category_rows = serendipity_db_query($cat_sql); if (is_array($category_rows)) { foreach ($category_rows as $cat) { $cat_count[$cat['categoryid']] = $cat['postings']; } } } $html = ''; if (!$smarty && $is_form) { $html .= '<form action="' . $serendipity['baseURL'] . $serendipity['indexFile'] . '?frontpage" method="post"> <div id="serendipity_category_form_content">'; } if (!$smarty) { $html .= '<ul id="serendipity_categories_list" style="list-style: none; margin: 0px; padding: 0px">'; } $image = $this->get_config('image', serendipity_getTemplateFile('img/xml.gif')); $image = $image == "'none'" || $image == 'none' ? '' : $image; $use_parent = $this->get_config('parent_base'); $hide_parent = serendipity_db_bool($this->get_config('hide_parent')); $parentdepth = 0; $hide_parallel = serendipity_db_bool($this->get_config('hide_parallel')); $hidedepth = 0; if (is_array($categories) && count($categories)) { $categories = serendipity_walkRecursive($categories, 'categoryid', 'parentid', VIEWMODE_THREADED); foreach ($categories as $cid => $cat) { // Hide parents not wanted if ($use_parent && $use_parent != 'all') { if ($parentdepth == 0 && $cat['parentid'] != $use_parent && $cat['categoryid'] != $use_parent) { unset($categories[$cid]); continue; } else { if ($hide_parent && $cat['categoryid'] == $use_parent) { unset($categories[$cid]); continue; } if ($cat['depth'] < $parentdepth) { $parentdepth = 0; unset($categories[$cid]); continue; } if ($parentdepth == 0) { $parentdepth = $cat['depth']; } } } // Hide parents outside of our tree if ($hide_parallel && $serendipity['GET']['category']) { if ($hidedepth == 0 && $cat['parentid'] != $serendipity['GET']['category'] && $cat['categoryid'] != $serendipity['GET']['category']) { unset($categories[$cid]); continue; } else { if ($cat['depth'] < $hidedepth) { $hidedepth = 0; unset($categories[$cid]); continue; } if ($hidedepth == 0) { $hidedepth = $cat['depth']; } } } $categories[$cid]['feedCategoryURL'] = serendipity_feedCategoryURL($cat, 'serendipityHTTPPath'); $categories[$cid]['categoryURL'] = serendipity_categoryURL($cat, 'serendipityHTTPPath'); $categories[$cid]['paddingPx'] = $cat['depth'] * 6; $categories[$cid]['catdepth'] = $cat['depth']; if (!empty($cat_count[$cat['categoryid']])) { $categories[$cid]['true_category_name'] = $cat['category_name']; $categories[$cid]['category_name'] .= ' (' . $cat_count[$cat['categoryid']] . ')'; $categories[$cid]['article_count'] = $cat_count[$cat['categoryid']]; } if (!$smarty) { $html .= '<li class="category_depth' . $cat['depth'] . ' category_' . $cat['categoryid'] . '" style="display: block;">'; if ($is_form) { $html .= '<input style="width: 15px" type="checkbox" name="serendipity[multiCat][]" value="' . $cat['categoryid'] . '" />'; } if (!empty($image)) { $html .= '<a class="serendipity_xml_icon" href="' . $categories[$cid]['feedCategoryURL'] . '"><img src="' . $image . '" alt="XML" style="border: 0px" /></a> '; } $html .= '<a href="' . $categories[$cid]['categoryURL'] . '" title="' . htmlspecialchars($cat['category_description']) . '" style="padding-left: ' . $categories[$cid]['paddingPx'] . 'px">' . htmlspecialchars($categories[$cid]['category_name']) . '</a>'; $html .= '</li>' . "\n"; } } } if (!$smarty) { $html .= '</ul>'; } if (!$smarty && $is_form) { $html .= '<div class="category_submit"><br /><input type="submit" name="serendipity[isMultiCat]" value="' . GO . '" /></div>'; } if (!$smarty) { $html .= sprintf('<div class="category_link_all"><br /><a href="%s" title="%s">%s</a></div>', $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?frontpage', ALL_CATEGORIES, ALL_CATEGORIES); } if (!$smarty && $is_form) { $html .= '</div></form>'; } if (!$smarty) { echo $html; } else { $plugin_categories_data = array('is_form' => $is_form, 'category_image' => $image, 'form_url' => $serendipity['baseURL'] . $serendipity['indexFile'] . '?frontpage', 'categories' => is_array($categories) ? $categories : array()); $serendipity['smarty']->assign($plugin_categories_data); echo serendipity_smarty_fetch('CATEGORIES', 'plugin_categories.tpl'); } }
/** * 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(' ', $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&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; } $linkPrevious = $qString . '&serendipity[page]=' . ($page - 1); $linkNext = $qString . '&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&serendipity[adminModule]=entries&serendipity[adminAction]=edit&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&serendipity[noSidebar]=true&serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=preview&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&serendipity[adminModule]=entries&serendipity[adminAction]=edit&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'); ?> &serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=delete&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 }
/** * event hook: 'backend_publish' and 'backend_save' * old tags, automated tags, category tags * * CLARIFY STATEMENT: * TAGS are stored to the database entrytags table like they are written by the user or being tagged already: * uppercased, mixed, lowercased, capitalised, etc. To change older tags, use the backend tag administration rename button function. * The 'lowercase_tags' option sets TAGS lowercased in every frontend related output at runtime and is used for comparison matters. * * @param array $eventData as copy */ function backend_fetch_tags_for_saving($eventData) { global $serendipity; if (function_exists('mb_internal_encoding')) { mb_internal_encoding(LANG_CHARSET); } #$to_lower = serendipity_db_bool($this->get_config('lowercase_tags', 'true')); // see clarify statement! $keylist = serendipity_db_query("SELECT tag, keywords FROM {$serendipity['dbPrefix']}tagkeywords", false, 'assoc'); $automated = array(array()); if (is_array($keylist)) { foreach ($keylist as $key) { $keywords = explode(',', $key['keywords']); foreach ($keywords as $keyword) { $automated[trim($keyword)][$key['tag']] = true; } } } $automated = array_filter($automated); // filter out all left BOOL, NULL and EMPTY elements // When this variable is not set, the entry might be saved i.e. by recreating cache or automated trackback. // Do not loose such tags. :) // And do not use it with multiple entry cases, since this would always get the first of multiple IDs!! if (!isset($serendipity['POST']['properties']['freetag_tagList']) && $serendipity['GET']['tagview'] != 'tagupdate' && $serendipity['GET']['tagview'] != 'cat2tag') { $serendipity['POST']['properties']['freetag_tagList'] = implode(',', $this->getTagsForEntry($eventData['id'])); // as STRING } if (!empty($serendipity['POST']['properties']['freetag_tagList'])) { $tags = self::makeTagsFromTagList($serendipity['POST']['properties']['freetag_tagList']); } // check for keyword2tag empty or set cases if (!is_array($tags) && empty($tags)) { $tags = array(); } if (empty($tags) && serendipity_db_bool($this->get_config('keyword2tag', 'false'))) { $searchtext = strip_tags($eventData['body'] . $eventData['extended']); // fetch oldtags AS ARRAY for each entry, valid to be checked for keywords $oldtags = self::makeTagsFromTagList(implode(',', $this->getTagsForEntry($eventData['id']))); // as ARRAY foreach ($automated as $keyword => $ktags) { $keyword = trim($keyword); if (empty($keyword)) { continue; } if (!is_array($ktags) || count($ktags) < 1) { continue; } $keywordtag = array_pop(array_keys($ktags)); // get type key as string if (is_array($oldtags) && in_array($keywordtag, $oldtags)) { continue; // if automated keyword-tag already is in oldtags, do next } // only match check those, which have no keyword-tag yet if (!is_array($key2tagIDs)) { $key2tagIDs = array(); } $regex = sprintf("/((\\s+|[\\(\\[-]+)%s([-\\/,\\.\\?!'\";\\)\\]]*+|[\\/-]+))/i", $keyword); if (preg_match($regex, $searchtext) > 0) { foreach ($ktags as $tag => $is_assigned) { if (!is_array($tags) || !in_array($tag, $tags) && !in_array($tag, $tags)) { if (!is_array($tags) && !empty($tag)) { $tags = array(); // avoid having "[] operator not supported for strings" errors } $tags[] = $tag; printf("\n - " . PLUGIN_EVENT_FREETAG_KEYWORDS_ADD . "\n<br>", self::specialchars_mapper($keyword), self::specialchars_mapper($tag)); if (!empty($tags)) { $key2tagIDs[] = $eventData['id']; // gather ids to updertEntries } } } } else { // get the other entries tags if (is_array($key2tagIDs) && !in_array($eventData['id'], $key2tagIDs)) { unset($key2tagIDs); $tags = $oldtags; } } } } // check for cat2tag empty or set cases if (!is_array($tags) && empty($tags)) { $tags = array(); } // In this case, tags are just added to the tags array if (serendipity_db_bool($this->get_config('cat2tag', 'false'))) { if (is_array($cats = serendipity_fetchCategories())) { $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED); foreach ($cats as $cat) { $names = explode(',', $cat['category_name']); foreach ($names as $name) { $name = trim($name); if (is_array($eventData['categories']) && in_array($cat['categoryid'], $eventData['categories']) && !in_array($name, $tags)) { $tags[] = $name; } } } } } // Merge kept oldtags with automated and/or category tags into tagList - may partly be or look a little redundant, but catches every case if (is_array($tags) && !empty($tags)) { if (!is_array($oldtags) && empty($oldtags)) { $oldtags = self::makeTagsFromTagList(implode(',', $this->getTagsForEntry($eventData['id']))); // as ARRAY } if (!is_array($oldtags)) { $oldtags = array(); } // Condition could be used with checking the given arrays before, with ' && $oldtags !== $tags', // but our tags arrays are so small, that this merge and unique does not really matter for performance if (!empty($oldtags)) { $tags = array_merge($oldtags, $tags); // merge } if (count($tags) > 1) { $tags = $this->array_iunique($tags); // remove (last added) duplicates (and possible strtolowered added tags) } } $key2tagIDs = is_array($key2tagIDs) && !empty($key2tagIDs) ? array_unique($key2tagIDs) : array(); // ACTIONS - Only do this to entries which really changed tags!! if (is_array($tags) && !empty($tags) && $oldtags !== $tags || is_array($key2tagIDs) && in_array($eventData['id'], $key2tagIDs) && $oldtags !== $tags) { $this->deleteTagsForEntry($eventData['id']); $this->addTagsToEntry($eventData['id'], $tags); } if (isset($serendipity['POST']['properties']['freetag_kill'])) { $this->deleteTagsForEntry($eventData['id']); } unset($key2tagIDs); unset($oldtags); unset($tags); }