本文整理汇总了PHP中serendipity_fetchCategories函数的典型用法代码示例。如果您正苦于以下问题:PHP serendipity_fetchCategories函数的具体用法?PHP serendipity_fetchCategories怎么用?PHP serendipity_fetchCategories使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了serendipity_fetchCategories函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: introspect_config_item
function introspect_config_item($name, &$propbag)
{
switch ($name) {
case 'locking':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_EVENT_ENTRYCHECK_LOCKING);
$propbag->add('description', '');
$propbag->add('default', false);
break;
case 'emptyCategories':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_EVENT_ENTRYCHECK_EMPTYCATEGORIES);
$propbag->add('description', PLUGIN_EVENT_ENTRYCHECK_EMPTYCATEGORIES_DESC);
$propbag->add('default', false);
break;
case 'emptyTitle':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_EVENT_ENTRYCHECK_EMPTYTITLE);
$propbag->add('description', PLUGIN_EVENT_ENTRYCHECK_EMPTYTITLE_DESC);
$propbag->add('default', false);
break;
case 'emptyBody':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY);
$propbag->add('description', PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY_DESC);
$propbag->add('default', false);
break;
case 'emptyExtended':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED);
$propbag->add('description', PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED_DESC);
$propbag->add('default', false);
break;
case 'defaultCat':
$cats = serendipity_fetchCategories($serendipity['authorid']);
if (!is_array($cats)) {
return false;
}
$catlist = serendipity_generateCategoryList($cats, array(0), 4);
$tmp_select_cats = explode('@@@', $catlist);
if (!is_array($tmp_select_cats)) {
return false;
}
$select_cats = array();
$select_cats['none'] = NONE;
foreach ($tmp_select_cats as $cidx => $tmp_select_cat) {
$select_cat = explode('|||', $tmp_select_cat);
if (!empty($select_cat[0]) && !empty($select_cat[1])) {
$select_cats[$select_cat[0]] = $select_cat[1];
}
}
$propbag->add('type', 'select');
$propbag->add('select_values', $select_cats);
$propbag->add('name', PLUGIN_EVENT_ENTRYCHECK_DEFAULTCAT);
$propbag->add('description', PLUGIN_EVENT_ENTRYCHECK_DEFAULTCAT_DESC);
$propbag->add('default', 'none');
break;
}
return true;
}
示例2: 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;
}
示例3: _getCategoryList
function _getCategoryList()
{
$res = serendipity_fetchCategories('all');
$ret = array(0 => NO_CATEGORY);
if (is_array($res)) {
foreach ($res as $v) {
$ret[$v['categoryid']] = $v['category_name'];
}
}
return $ret;
}
示例4: 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;
}
示例5: performConfig
function performConfig(&$bag)
{
if (is_object($bag)) {
$conf = $bag->get('configuration');
}
$this->data['categories'] = serendipity_fetchCategories('all');
if (!is_array($this->data['categories'])) {
return false;
}
foreach ($this->data['categories'] as $cat) {
$conf[] = 'category_' . $cat['categoryid'];
$this->data['cat'][$cat['categoryid']] = $cat;
}
if (is_object($bag)) {
$bag->add('configuration', $conf);
}
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: import
function import()
{
global $serendipity;
$max_import = 9999;
$serendipity['noautodiscovery'] = true;
if (!is_dir($this->data['pivot_path']) || !is_readable($this->data['pivot_path'])) {
$check_dir = $serendipity['serendipityPath'] . $this->data['pivot_path'];
if (!is_dir($check_dir) || !is_readable($check_dir)) {
return sprintf(ERROR_NO_DIRECTORY, serendipity_specialchars($this->data['pivot_path']));
}
$this->data['pivot_path'] = $check_dir;
}
printf('<span class="block_level">' . CHECKING_DIRECTORY . ': ', $this->data['pivot_path']) . '</span>';
if ($root = opendir($this->data['pivot_path'])) {
// Fetch category data:
$s9y_categories = serendipity_fetchCategories('all');
$categories = $this->unserialize($this->data['pivot_path'] . '/ser-cats.php');
$pivot_to_s9y = array('categories' => array());
echo '<ul>';
foreach ($categories as $pivot_category_id => $category) {
$found = false;
$pivot_category = trim(stripslashes($category[0]));
foreach ($s9y_categories as $idx => $item) {
if ($pivot_category == $item['category_name']) {
$found = $item['categoryid'];
break;
}
}
if ($found) {
echo '<li>Pivot Category "' . serendipity_specialchars($pivot_category) . '" mapped to Serendipity ID ' . $found . '</li>';
$pivot_to_s9y['categories'][$pivot_category] = $found;
} else {
echo '<li>Created Pivot Category "' . serendipity_specialchars($pivot_category) . '".</li>';
$cat = array('category_name' => $pivot_category, 'category_description' => '', 'parentid' => 0, 'category_left' => 0, 'category_right' => 0);
serendipity_db_insert('category', $cat);
$pivot_to_s9y['categories'][$pivot_category] = serendipity_db_insert_id('category', 'categoryid');
}
}
$i = 0;
while (false !== ($dir = readdir($root))) {
if ($dir[0] == '.') {
continue;
}
if (substr($dir, 0, 8) == 'standard') {
printf('<li>' . CHECKING_DIRECTORY . '...</li>', $dir);
$data = $this->unserialize($this->data['pivot_path'] . '/' . $dir . '/index-' . $dir . '.php');
if (empty($data) || !is_array($data) || count($data) < 1) {
echo '<li><span class="msg_error">FATAL: File <em>' . $dir . '/index-' . $dir . '.php</em> has no data!</span></li>';
flush();
ob_flush();
continue;
}
foreach ($data as $entry) {
$entryid = str_pad($entry['code'], 5, '0', STR_PAD_LEFT);
if ($i >= $max_import) {
echo '<li>Skipping entry data for #' . $entryid . '</li>';
continue;
}
echo '<li>Fetching entry data for #' . $entryid . '</li>';
$entrydata = $this->unserialize($this->data['pivot_path'] . '/' . $dir . '/' . $entryid . '.php');
if (empty($entrydata) || !is_array($entrydata) || count($entrydata) < 1) {
echo '<li><span class="msg_error">FATAL: File <em>' . $dir . '/' . $entryid . '.php</em> has no data!</span></li>';
flush();
ob_flush();
continue;
}
$entry = array();
$entry['title'] = trim(stripslashes($entrydata['title']));
$entry['categories'] = array();
if (is_array($entrydata['category'])) {
foreach ($entrydata['category'] as $pivot_category) {
$entry['categories'][] = $pivot_to_s9y['categories'][$pivot_category];
}
}
$entry['timestamp'] = $this->toTimestamp($entrydata['date']);
$entry['last_modified'] = !empty($entrydata['edit_date']) ? $this->toTimestamp($entrydata['edit_date']) : $entry['timestamp'];
$entry['isdraft'] = $entrydata['status'] == 'publish' ? 'false' : 'true';
$entry['body'] = stripslashes($entrydata['introduction']);
$entry['extended'] = stripslashes($entrydata['body']);
$entry['title'] = stripslashes($entrydata['title']);
$entry['authorid'] = $serendipity['authorid'];
$entry['author'] = $serendipity['serendipityUser'];
$entry['allow_comments'] = $entrydata['allow_comments'] ? 'true' : 'false';
$entry['moderate_comments'] = 'false';
$entry['exflag'] = !empty($entry['extended']) ? 1 : 0;
$entry['trackbacks'] = 0;
$entry['comments'] = isset($entrydata['comments']) ? count($entrydata['comments']) : 0;
serendipity_updertEntry($entry);
$i++;
if (isset($entrydata['comments']) && count($entrydata['comments']) > 0) {
foreach ($entrydata['comments'] as $comment) {
$comment = array('entry_id ' => $entry['id'], 'parent_id' => 0, 'timestamp' => $this->toTimestamp($comment['date']), 'author' => stripslashes($comment['name']), 'email' => stripslashes($comment['email']), 'url' => stripslashes($comment['url']), 'ip' => stripslashes($comment['ip']), 'status' => 'approved', 'body' => stripslashes($comment['comment']), 'subscribed' => $comment['notify'] ? 'true' : 'false', 'type' => 'NORMAL');
serendipity_db_insert('comments', $comment);
}
}
echo '<li><span class="msg_success">Entry #' . $entryid . ' imported</span></li>';
flush();
ob_flush();
}
}
//.........这里部分代码省略.........
示例10: generate_content
/**
* Creates a DHTML menu of serendipity categories.
*
* The menu is echoed out.
*
* @param string $title (Serves as the top level menu item if present)
* @return void
* @see http://pear.php.net/HTML_TreeMenu PEAR::HTML_TreeMenu
*/
function generate_content(&$title)
{
global $serendipity;
$title = $this->get_config('title', $this->title);
// may want to put this in bundled_libs or a sub directory of this directory
$pear = false;
if (@(include_once 'HTML/TreeMenu.php')) {
$pear = true;
} elseif (@(include_once 'HTML_TreeMenu/TreeMenu.php')) {
$pear = true;
}
if ($pear) {
$which_category = $this->get_config('authorid');
// build an accessible array of categories
foreach (serendipity_fetchCategories(empty($which_category) ? 'all' : $which_category) as $cat) {
if (!is_array($cat) || !isset($cat['categoryid'])) {
continue;
}
$categories[$cat['categoryid']] = $cat;
}
// create an array of numbers of entries per category
$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'];
}
}
}
$image = $this->get_config('image', serendipity_getTemplateFile('img/xml.gif'));
$image = $image == "'none'" || $image == 'none' ? '' : $image;
// create nodes
foreach ($categories as $cid => $cat) {
if (function_exists('serendipity_categoryURL')) {
$link = serendipity_categoryURL($cat, 'serendipityHTTPPath');
} else {
$link = serendipity_rewriteURL(PATH_CATEGORIES . '/' . serendipity_makePermalink(PERM_CATEGORIES, array('id' => $cat['categoryid'], 'title' => $cat['category_name'])), 'serendipityHTTPPath');
}
if (!empty($cat_count[$cat['categoryid']])) {
// $categories[$cid]['true_category_name'] = $cat['category_name'];
$cat['category_name'] .= ' (' . $cat_count[$cat['categoryid']] . ')';
// $categories[$cid]['article_count'] = $cat_count[$cat['categoryid']];
}
if (!empty($image)) {
$feedURL = serendipity_feedCategoryURL($cat, 'serendipityHTTPPath');
$feed = '<a class="serendipity_xml_icon" href="' . $feedURL . '"><img src="' . $image . '" alt="XML" style="border: 0px;vertical-align:middle"/></a> ';
$link = '<a href="' . $link . '" target="_self"><span>' . $cat['category_name'] . '</span></a>';
// work around a problem in HTML_TreeNode: when there is a href in 'text', 'link' is not converted to a link.
$cat_nodes[$cat['categoryid']] = new HTML_TreeNode(array('text' => $feed . $link));
} else {
$cat_nodes[$cat['categoryid']] = new HTML_TreeNode(array('text' => $feed . $cat['category_name'], 'link' => $link));
}
}
// create a top level for "all categories"
// this serves as the title
$cat_nodes[0] = new HTML_TreeNode(array('text' => ALL_CATEGORIES, 'link' => $serendipity['baseURL']));
// nest nodes (thanks to PHP references)
foreach ($categories as $category) {
$cat_nodes[$category['parentid']]->addItem($cat_nodes[$category['categoryid']]);
}
// nest the "all categories" category
$menu = new HTML_TreeMenu();
$menu->addItem($cat_nodes[0]);
$tree = new HTML_TreeMenu_DHTML($menu, array('images' => $serendipity['baseURL'] . $this->get_config('image_path')));
// Add heading for block
#$output = '<h2 class="serendipitySideBarTitle" style="font-weight: bold;">'.$title.'</h2><br />';
// Put inside a div with "overflow:hidden" to avoid items of the sidebar plugin running outside the blog
// Maybe we can put a config setting to choose if the block should be displayed with or without overflow setting.
$output .= '<div style="overflow: hidden;">';
$output .= $tree->toHTML();
$output .= '</div>';
echo '<script type="text/javascript" src="' . $serendipity['baseURL'] . $this->get_config('script_path') . '"></script>';
} else {
$output .= "Please install PEAR package HTML_TreeMenu to enable this plugin.";
}
echo $output;
}
示例11: serendipity_drawList
//.........这里部分代码省略.........
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) {
示例12: 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;
$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;
//.........这里部分代码省略.........
示例13: getRelatedCategories
function getRelatedCategories()
{
global $serendipity;
$res = serendipity_fetchCategories($serendipity['authorid']);
$ret[0] = NONE;
if (is_array($res)) {
foreach ($res as $value) {
$ret[$value['categoryid']] = $value['category_name'];
}
}
return $ret;
}
示例14: array
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;
}
示例15: generate_content
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)) {
//.........这里部分代码省略.........