本文整理汇总了PHP中serendipity_walkRecursive函数的典型用法代码示例。如果您正苦于以下问题:PHP serendipity_walkRecursive函数的具体用法?PHP serendipity_walkRecursive怎么用?PHP serendipity_walkRecursive使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了serendipity_walkRecursive函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: introspect_config_item
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;
}
示例2: introspect_config_item
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;
}
示例3: introspect_config_item
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;
}
示例4: introspect_config_item
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;
}
示例5: rgb
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;
}
示例6: serendipity_walkRecursive
/**
* 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;
}
示例7: admin_print_sidebar
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";
//.........这里部分代码省略.........
示例8: serendipity_walkRecursive
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;
}
示例9: AGAINST
$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;
示例10: event_hook
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>
//.........这里部分代码省略.........
示例11: displayPageList
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;
}
示例12: event_hook
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>
//.........这里部分代码省略.........
示例13: event_hook
//.........这里部分代码省略.........
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;
示例14: serendipity_printEntryForm
/**
* 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;
//.........这里部分代码省略.........
示例15: output_categoryadmin
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>';
}