本文整理汇总了PHP中is_admin_page函数的典型用法代码示例。如果您正苦于以下问题:PHP is_admin_page函数的具体用法?PHP is_admin_page怎么用?PHP is_admin_page使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_admin_page函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SkinBeginHtmlHead
/**
* @see Plugin::SkinBeginHtmlHead()
*/
function SkinBeginHtmlHead(&$params)
{
$relative_to = is_admin_page() ? 'rsc_url' : 'blog';
require_js('#flowplayer#', $relative_to);
add_js_headline('flowplayer.conf = { flashfit: true, embed: false }');
$this->require_skin();
add_css_headline('.flowplayer_block {
margin: 1em auto 0;
background: #000;
}
.flowplayer_block .flowplayer {
display: block;
margin: auto;
}
.flowplayer_text {
font-size: 84%;
text-align: center;
margin: 4px 0;
}');
}
示例2: SkinBeginHtmlHead
/**
* @see Plugin::SkinBeginHtmlHead()
*/
function SkinBeginHtmlHead(&$params)
{
global $Blog;
$relative_to = is_admin_page() ? 'rsc_url' : 'blog';
require_css('#videojs_css#', $relative_to);
require_js('#videojs#', $relative_to);
$this->require_skin();
// Set a video size in css style, because option setting is ignored by some reason
$width = intval($this->get_coll_setting('width', $Blog));
$width = empty($width) ? '100%' : $width . 'px';
$height = intval($this->get_coll_setting('height', $Blog));
add_css_headline('.video-js{ width: ' . $width . ' !important; max-width: 100% !important; height: ' . $height . 'px !important; margin: auto; }
.videojs_block {
margin: 0 auto 1em;
}
.videojs_block .videojs_text {
font-size: 84%;
text-align: center;
margin: 4px 0;
}');
}
示例3: col_thread_delete_action
/**
* Get action icons to delete thread
*
* @param integer Thread ID
* @return string Action icon
*/
function col_thread_delete_action($thread_ID)
{
global $Blog, $samedomain_htsrv_url, $admin_url;
if (is_admin_page()) {
$redirect_to = rawurlencode(regenerate_url('', '', '', '&'));
return action_icon(T_('Delete'), 'delete', $admin_url . '?ctrl=threads&thrd_ID=' . $thread_ID . '&action=delete&' . url_crumb('messaging_threads') . '&redirect_to=' . $redirect_to);
} else {
$redirect_to = get_dispctrl_url('threads');
return action_icon(T_('Delete'), 'delete', $samedomain_htsrv_url . 'action.php?mname=messaging&thrd_ID=' . $thread_ID . '&action=delete&redirect_to=' . $redirect_to . '&' . url_crumb('messaging_threads'));
}
}
示例4: comment_edit_actions
/**
* Get the edit actions for comment
*
* @param object Comment
* @return string The edit actions
*/
function comment_edit_actions($Comment)
{
global $current_User, $admin_url;
$r = '';
if (!is_logged_in()) {
return $r;
}
$user_has_edit_perm = $current_User->check_perm('comment!CURSTATUS', 'edit', false, $Comment);
$user_has_delete_perm = $current_User->check_perm('comment!CURSTATUS', 'delete', false, $Comment);
if ($user_has_edit_perm || $user_has_delete_perm) {
// Display edit and delete button if current user has the rights:
$redirect_to = rawurlencode(regenerate_url('comment_ID,action', 'filter=restore', '', '&'));
if ($user_has_edit_perm) {
// Display edit button only if current user can edit comment with current status
$Comment->get_Item();
$item_Blog =& $Comment->Item->get_Blog();
if ($item_Blog->get_setting('in_skin_editing') && !is_admin_page()) {
$edit_url = url_add_param($item_Blog->gen_blogurl(), 'disp=edit_comment&c=' . $Comment->ID);
} else {
$edit_url = $admin_url . '?ctrl=comments&comment_ID=' . $Comment->ID . '&action=edit&redirect_to=' . $redirect_to;
}
$r .= action_icon(TS_('Edit this comment...'), 'properties', $edit_url);
}
if ($user_has_delete_perm) {
// Display delete/recycle button because current user has permission to delete/recycle this comment
$params = array();
if ($Comment->status == 'trash') {
// Comment is already in the recycle bin, display delete action and add js confirm
$title = T_('Delete this comment!');
$params['onclick'] = "return confirm('" . TS_('You are about to delete this comment!\\nThis cannot be undone!') . "')";
} else {
// Comment will be moved into the recycle bin
$title = T_('Recycle this comment!');
}
$r .= action_icon($title, 'delete', $admin_url . '?ctrl=comments&comment_ID=' . $Comment->ID . '&action=delete&' . url_crumb('comment') . '&redirect_to=' . $redirect_to, NULL, NULL, NULL, $params);
}
}
return $r;
}
示例5: get_media_dir
/**
* Get the blog's media directory (and create it if necessary).
*
* If we're {@link is_admin_page() on an admin page}, it adds status messages.
* @todo These status messages should rather go to a "syslog" and not be displayed to a normal user
*
* @param boolean Create the directory, if it does not exist yet?
* @return string path string on success, false if the dir could not be created
*/
function get_media_dir($create = true)
{
global $media_path, $Messages, $Settings, $Debuglog;
if (!$Settings->get('fm_enable_roots_blog')) {
// User directories are disabled:
$Debuglog->add('Attempt to access blog media dir, but this feature is globally disabled', 'files');
return false;
}
switch ($this->media_location) {
case 'default':
$mediadir = get_canonical_path($media_path . 'blogs/' . $this->urlname . '/');
break;
case 'subdir':
$mediadir = get_canonical_path($media_path . $this->media_subdir);
break;
case 'custom':
$mediadir = get_canonical_path($this->media_fullpath);
break;
case 'none':
default:
$Debuglog->add('Attempt to access blog media dir, but this feature is disabled for this blog', 'files');
return false;
}
// TODO: use a File object here (to access perms, ..) when FileCache::get_by_path() is provided.
if ($create && !is_dir($mediadir)) {
// TODO: Link to some help page(s) with errors!
if (!is_writable(dirname($mediadir))) {
// add error
if (is_admin_page()) {
$Messages->add(sprintf(T_("The blog's media directory «%s» could not be created, because the parent directory is not writable or does not exist."), rel_path_to_base($mediadir)) . get_manual_link('media_file_permission_errors'), 'error');
}
return false;
} elseif (!@mkdir($mediadir)) {
// add error
if (is_admin_page()) {
$Messages->add(sprintf(T_("The blog's media directory «%s» could not be created."), rel_path_to_base($mediadir)) . get_manual_link('directory_creation_error'), 'error');
}
return false;
} else {
// chmod and add note:
$chmod = $Settings->get('fm_default_chmod_dir');
if (!empty($chmod)) {
@chmod($mediadir, octdec($chmod));
}
if (is_admin_page()) {
$Messages->add(sprintf(T_("The blog's media directory «%s» has been created with permissions %s."), rel_path_to_base($mediadir), substr(sprintf('%o', fileperms($mediadir)), -3)), 'success');
}
}
}
return $mediadir;
}
示例6: detect_admin_page
/**
* Detect admin page
*/
function detect_admin_page()
{
global $Debuglog;
if (empty($this->test_mode) || !empty($this->test_mode) && !empty($this->test_admin)) {
if (is_admin_page()) {
// We are inside of admin, this supersedes 'direct' access
// NOTE: this is not really a referer type but more a hit type
// $Debuglog->add( 'Hit: Referer is admin page.', 'request' );
//$this->referer_type = 'admin';
return true;
}
}
return false;
}
示例7: get_ChapterCache
/**
* Get the main Chapter.
*
* @return Chapter
*/
function &get_main_Chapter()
{
if (is_null($this->main_Chapter)) {
$ChapterCache =& get_ChapterCache();
/**
* @var Chapter
*/
$this->main_Chapter =& $ChapterCache->get_by_ID($this->main_cat_ID, false);
if (empty($this->main_Chapter)) {
// If main chapter is broken we should get it from one of extra chapters
$chapters = $this->get_Chapters();
foreach ($chapters as $Chapter) {
if (!empty($Chapter)) {
// We have found a valid Chapter...
$this->main_Chapter =& $Chapter;
$this->main_cat_ID = $Chapter->ID;
break;
}
}
}
if (empty($this->main_Chapter)) {
// If we still don't have a valid Chapter, display clean error and die().
global $admin_url, $Blog, $blog;
if (empty($Blog)) {
if (!empty($blog)) {
$BlogCache =& get_BlogCache();
$Blog =& $BlogCache->get_by_ID($blog, false);
}
}
$url_to_edit_post = $admin_url . '?ctrl=items&action=edit&p=' . $this->ID;
if (!empty($Blog)) {
$url_to_edit_post .= '&blog=' . $Blog->ID;
if (is_admin_page()) {
// Try to set a main category
$default_cat_ID = $Blog->get_setting('default_cat_ID');
if (!empty($default_cat_ID)) {
// If default category is set
$this->main_cat_ID = $default_cat_ID;
$this->main_Chapter =& $ChapterCache->get_by_ID($this->main_cat_ID, false);
} else {
// Set from first chapter of the blog
$ChapterCache->clear();
$ChapterCache->load_subset($Blog->ID);
if ($Chapter =& $ChapterCache->get_next()) {
$this->main_cat_ID = $Chapter->ID;
$this->main_Chapter =& $Chapter;
}
}
}
}
$message = sprintf('Item with ID <a %s>%s</a> has an invalid main category ID %s.', 'href="' . $url_to_edit_post . '"', $this->ID, $this->main_cat_ID);
if (empty($Blog)) {
// No blog defined
$message .= ' In addition we cannot fallback to the default category because no valid blog ID has been specified.';
}
if (empty($this->main_Chapter)) {
// Main chapter is not defined, because blog doesn't have the default cat ID and even blog doesn't have any categories
debug_die($message);
} else {
// Main chapter is defined, we can show the page
global $Messages;
$Messages->add($message);
}
}
}
return $this->main_Chapter;
}
示例8: edit_link
/**
* Provide link to edit a comment if user has edit rights
*
* @param string to display before link
* @param string to display after link
* @param string link text
* @param string link title
* @param string class name
* @param string Glue string for url params
* @param boolean TRUE - to save context(memorized params)
* @param string Redirect url
* @return boolean
*/
function edit_link($before = ' ', $after = ' ', $text = '#', $title = '#', $class = '', $glue = '&', $save_context = true, $redirect_to = NULL)
{
global $current_User, $admin_url;
if (!is_logged_in(false)) {
return false;
}
if (empty($this->ID)) {
// Happens in Preview
return false;
}
if (!$current_User->check_perm('comment!CURSTATUS', 'edit', false, $this)) {
// If User has no permission to edit this comment:
return false;
}
if ($text == '#') {
$text = get_icon('edit') . ' ' . T_('Edit...');
}
if ($title == '#') {
$title = T_('Edit this comment');
}
$this->get_Item();
$item_Blog =& $this->Item->get_Blog();
echo $before;
if ($item_Blog->get_setting('in_skin_editing') && !is_admin_page()) {
echo '<a href="' . url_add_param($item_Blog->gen_blogurl(), 'disp=edit_comment' . $glue . 'c=' . $this->ID);
} else {
echo '<a href="' . $admin_url . '?ctrl=comments' . $glue . 'action=edit' . $glue . 'comment_ID=' . $this->ID;
}
if ($save_context) {
if ($redirect_to != NULL) {
echo $glue . 'redirect_to=' . $redirect_to;
} else {
echo $glue . 'redirect_to=' . rawurlencode(regenerate_url('', 'filter=restore', '', '&'));
}
}
echo '" title="' . $title . '"';
if (!empty($class)) {
echo ' class="' . $class . '"';
}
echo '>' . $text . '</a>';
echo $after;
return true;
}
示例9: record_view
function record_view()
{
if ($this->logged > 0) {
return true;
}
global $wpdb, $posts;
if (!isset($posts) || !is_array($posts) || count($posts) == 0 || is_admin_page()) {
return;
}
$ids = array();
$ak_posts = $posts;
foreach ($ak_posts as $post) {
$ids[] = $post->ID;
}
if (is_feed()) {
$result = mysql_query("\n\t\t\t\tUPDATE {$wpdb->ak_popularity}\n\t\t\t\tSET feed_views = feed_views + 1\n\t\t\t\t, total = total + {$this->feed_value}\n\t\t\t\tWHERE post_id IN (" . implode(',', $ids) . ")\n\t\t\t", $wpdb->dbh) or die(mysql_error() . ' on line: ' . __LINE__);
if (!$result) {
return false;
}
} else {
if (is_archive() && !is_category()) {
$result = mysql_query("\n\t\t\t\tUPDATE {$wpdb->ak_popularity}\n\t\t\t\tSET archive_views = archive_views + 1\n\t\t\t\t, total = total + {$this->archive_value}\n\t\t\t\tWHERE post_id IN (" . implode(',', $ids) . ")\n\t\t\t", $wpdb->dbh) or die(mysql_error() . ' on line: ' . __LINE__);
if (!$result) {
return false;
}
} else {
if (is_category()) {
$result = mysql_query("\n\t\t\t\tUPDATE {$wpdb->ak_popularity}\n\t\t\t\tSET category_views = category_views + 1\n\t\t\t\t, total = total + {$this->category_value}\n\t\t\t\tWHERE post_id IN (" . implode(',', $ids) . ")\n\t\t\t", $wpdb->dbh) or die(mysql_error() . ' on line: ' . __LINE__);
if (!$result) {
return false;
}
} else {
if (is_single()) {
$result = mysql_query("\n\t\t\t\tUPDATE {$wpdb->ak_popularity}\n\t\t\t\tSET single_views = single_views + 1\n\t\t\t\t, total = total + {$this->single_value}\n\t\t\t\tWHERE post_id = '" . $ids[0] . "'\n\t\t\t", $wpdb->dbh) or die(mysql_error() . ' on line: ' . __LINE__);
if (!$result) {
return false;
}
} else {
$result = mysql_query("\n\t\t\t\tUPDATE {$wpdb->ak_popularity}\n\t\t\t\tSET home_views = home_views + 1\n\t\t\t\t, total = total + {$this->home_value}\n\t\t\t\tWHERE post_id IN (" . implode(',', $ids) . ")\n\t\t\t", $wpdb->dbh) or die(mysql_error() . ' on line: ' . __LINE__);
if (!$result) {
return false;
}
}
}
}
}
$this->logged++;
return true;
}
示例10: get_renderer_checkboxes
/**
* Get checkable list of renderers
*
* @param array If given, assume these renderers to be checked.
* @param array params from where to get 'apply_rendering' setting
*/
function get_renderer_checkboxes($current_renderers = NULL, $params)
{
global $inc_path, $admin_url;
load_funcs('plugins/_plugin.funcs.php');
$name_prefix = isset($params['name_prefix']) ? $params['name_prefix'] : '';
$this->restart();
// make sure iterator is at start position
if (!is_array($current_renderers)) {
$current_renderers = explode('.', $current_renderers);
}
$atLeastOneRenderer = false;
$setting_Blog = NULL;
if (isset($params['Comment']) && !empty($params['Comment'])) {
// get Comment apply_rendering setting
$Comment =& $params['Comment'];
$comment_Item =& $Comment->get_Item();
$setting_Blog =& $comment_Item->get_Blog();
$setting_name = 'coll_apply_comment_rendering';
} elseif (isset($params['Item'])) {
// get Post apply_rendering setting
$setting_name = 'coll_apply_rendering';
$Item =& $params['Item'];
$setting_Blog =& $Item->get_Blog();
} elseif (isset($params['Blog']) && isset($params['setting_name'])) {
// get given "apply_rendering" collection setting from the given Blog
$setting_Blog =& $params['Blog'];
$setting_name = $params['setting_name'];
} else {
// Invalid params
return '';
}
if ($setting_name == 'coll_apply_comment_rendering') {
// Get Comment renderer plugins
$RendererPlugins = $this->get_list_by_events(array('FilterCommentContent'));
} else {
// Get Item renderer plugins
$RendererPlugins = $this->get_list_by_events(array('RenderItemAsHtml', 'RenderItemAsXml', 'RenderItemAsText'));
}
$r = '<input type="hidden" name="renderers_displayed" value="1" />';
foreach ($RendererPlugins as $loop_RendererPlugin) {
// Go through whole list of renders
// echo ' ',$loop_RendererPlugin->code;
if (empty($loop_RendererPlugin->code)) {
// No unique code!
continue;
}
if (empty($setting_Blog)) {
// If $setting_Blog is not set we can't get apply_rendering options
continue;
}
// get rendering setting from plugin coll settings
$apply_rendering = $loop_RendererPlugin->get_coll_setting($setting_name, $setting_Blog);
if ($apply_rendering == 'stealth' || $apply_rendering == 'never') {
// This is not an option.
continue;
}
$atLeastOneRenderer = true;
$r .= '<div>';
$r .= '<input type="checkbox" class="checkbox" name="' . $name_prefix . 'renderers[]" value="' . $loop_RendererPlugin->code . '" id="renderer_' . $loop_RendererPlugin->code . '"';
switch ($apply_rendering) {
case 'always':
$r .= ' checked="checked" disabled="disabled"';
break;
case 'opt-out':
if (in_array($loop_RendererPlugin->code, $current_renderers) || in_array('default', $current_renderers)) {
$r .= ' checked="checked"';
}
break;
case 'opt-in':
if (in_array($loop_RendererPlugin->code, $current_renderers)) {
$r .= ' checked="checked"';
}
break;
case 'lazy':
if (in_array($loop_RendererPlugin->code, $current_renderers)) {
$r .= ' checked="checked"';
}
$r .= ' disabled="disabled"';
break;
}
$r .= ' title="' . format_to_output($loop_RendererPlugin->short_desc, 'formvalue') . '" /> <label for="renderer_' . $loop_RendererPlugin->code . '" title="';
$r .= format_to_output($loop_RendererPlugin->short_desc, 'formvalue') . '">';
$r .= format_to_output($loop_RendererPlugin->name) . '</label>';
// fp> TODO: the first thing we want here is a TINY javascript popup with the LONG desc. The links to readme and external help should be inside of the tiny popup.
// fp> a javascript DHTML onhover help would be even better than the JS popup
// external help link:
$r .= ' ' . $loop_RendererPlugin->get_help_link('$help_url');
$r .= "</div>\n";
}
if (!$atLeastOneRenderer) {
if (is_admin_page()) {
// Display info about no renderer plugins only in backoffice
global $admin_url;
$r .= '<a title="' . T_('Configure plugins') . '" href="' . $admin_url . '?ctrl=plugins"' . '>' . T_('No renderer plugins are installed.') . '</a>';
//.........这里部分代码省略.........
示例11: get_UserCache
if ($user_ID > 0) {
// Print info of the registered users
$UserCache =& get_UserCache();
$User =& $UserCache->get_by_ID($user_ID);
$Ajaxlog->add('User: #' . $user_ID . ' ' . $User->login);
echo '<div class="bubbletip_user">';
if ($User->check_status('is_closed')) {
// display only info about closed accounts
echo T_('This account has been closed.');
echo '</div>';
/* end of: <div class="bubbletip_user"> */
break;
}
$avatar_overlay_text = '';
$link_class = '';
if (is_admin_page()) {
// Set avatar size for Back-office
$avatar_size = $Settings->get('bubbletip_size_admin');
} else {
if (is_logged_in()) {
// Set avatar size for logged in users in the Front-office
$avatar_size = $Settings->get('bubbletip_size_front');
} else {
// Set avatar size for Anonymous users
$avatar_size = $Settings->get('bubbletip_size_anonymous');
$avatar_overlay_text = $Settings->get('bubbletip_overlay');
$link_class = 'overlay_link';
}
}
$width = $thumbnail_sizes[$avatar_size][1];
$height = $thumbnail_sizes[$avatar_size][2];
示例12: task_title_link
/**
* Get a link with task title
*
* @param object Item
* @param boolean Display country flag
* @param boolean Display status banner
* @return string Link
*/
function task_title_link($Item, $display_flag = true, $display_status = false)
{
global $current_User, $admin_url;
$col = '';
if ($display_status && is_logged_in()) {
// Display status
$col .= $Item->get_status(array('format' => 'styled'));
}
if ($display_flag) {
// Display country flag
$col .= locale_flag($Item->locale, 'w16px', 'flag', '', false) . ' ';
}
$Item->get_Blog();
if (is_admin_page()) {
// Url to item page in backoffice
$item_url = $admin_url . '?ctrl=items&blog=' . $Item->get_blog_ID() . '&p=' . $Item->ID;
} else {
// Url to item page in frontoffice
$item_url = $Item->get_permanent_url();
}
if ($Item->Blog->get_setting('allow_comments') != 'never') {
// The current blog can have comments:
$nb_comments = generic_ctp_number($Item->ID, 'feedback');
$comments_url = is_admin_page() ? $item_url : url_add_tail($item_url, '#comments');
$col .= '<a href="' . $comments_url . '" title="' . sprintf(T_('%d feedbacks'), $nb_comments) . '" class="">';
if ($nb_comments) {
$col .= get_icon('comments');
} else {
$col .= get_icon('nocomment');
}
$col .= '</a> ';
}
$col .= '<a href="' . $item_url . '" class="" title="' . T_('View this post...') . '">' . $Item->dget('title') . '</a></strong>';
return $col;
}
示例13: query_init
/**
* Initialize sql query
*
* @todo count?
*
* @param boolean
*/
function query_init($force_init = false)
{
global $DB;
if (!$force_init && !empty($this->query_is_initialized)) {
// Don't initialize query because it was already done
return;
}
// Save to know the query init was done
$this->query_is_initialized = true;
if (empty($this->filters)) {
// Filters have not been set before, we'll use the default filterset:
// If there is a preset filter, we need to activate its specific defaults:
$this->filters['filter_preset'] = param($this->param_prefix . 'filter_preset', 'string', $this->default_filters['filter_preset'], true);
$this->activate_preset_filters();
// Use the default filters:
$this->set_filters($this->default_filters);
}
// GENERATE THE QUERY:
/*
* Resrict to selected blog
*/
// If we dont have specific comment or post ids, we have to restric to blog
if (!is_null($this->Blog) && ($this->filters['post_ID'] == NULL || !empty($this->filters['post_ID']) && substr($this->filters['post_ID'], 0, 1) == '-') && ($this->filters['comment_ID'] == NULL || !empty($this->filters['comment_ID']) && substr($this->filters['comment_ID'], 0, 1) == '-') && ($this->filters['comment_ID_list'] == NULL || !empty($this->filters['comment_ID_list']) && substr($this->filters['comment_ID_list'], 0, 1) == '-')) {
// restriction for blog
$this->ItemQuery->where_chapter($this->Blog->ID);
}
/*
* filtering stuff:
*/
$this->CommentQuery->where_author($this->filters['author_IDs']);
$this->CommentQuery->where_author_email($this->filters['author_email']);
$this->CommentQuery->where_author_url($this->filters['author_url'], $this->filters['url_match'], $this->filters['include_emptyurl']);
$this->CommentQuery->where_author_IP($this->filters['author_IP']);
$this->ItemQuery->where_ID($this->filters['post_ID']);
$this->CommentQuery->where_ID($this->filters['comment_ID'], $this->filters['author']);
$this->CommentQuery->where_ID_list($this->filters['comment_ID_list']);
$this->CommentQuery->where_rating($this->filters['rating_toshow'], $this->filters['rating_turn'], $this->filters['rating_limit']);
$this->CommentQuery->where_keywords($this->filters['keywords'], $this->filters['phrase'], $this->filters['exact']);
$this->CommentQuery->where_statuses($this->filters['statuses']);
$this->CommentQuery->where_types($this->filters['types']);
$this->ItemQuery->where_datestart('', '', '', '', $this->filters['timestamp_min'], $this->filters['timestamp_max']);
if (!is_null($this->Blog) && isset($this->filters['user_perm'])) {
// If Blog and required user permission is set, add the corresponding restriction
$this->CommentQuery->user_perm_restrict($this->filters['user_perm'], $this->Blog->ID);
}
/*
* ORDER BY stuff:
*/
$available_sort_options = array('date', 'type', 'author', 'author_url', 'author_email', 'author_IP', 'spam_karma', 'status', 'item_ID');
$order_by = gen_order_clause($this->filters['orderby'], $this->filters['order'], $this->Cache->dbprefix, $this->Cache->dbIDname, $available_sort_options);
if ($this->filters['threaded_comments']) {
// In mode "Threaded comments" we should get all replies in the begining of the list
$order_by = $this->Cache->dbprefix . 'in_reply_to_cmt_ID DESC, ' . $order_by;
}
$this->CommentQuery->order_by($order_by);
// GET Item IDs, this way we don't have to JOIN two times the items and the categories table into the comment query
if (isset($this->filters['post_statuses'])) {
// Set post statuses by filters
$post_show_statuses = $this->filters['post_statuses'];
} elseif (is_admin_page()) {
// Allow all kind of post status ( This statuses will be filtered later by user perms )
$post_show_statuses = get_visibility_statuses('keys');
} else {
// Allow only inskin statuses for posts
$post_show_statuses = get_inskin_statuses(isset($this->Blog) ? $this->Blog->ID : NULL, 'post');
}
// Restrict post filters to available statuses. When blog = 0 we will check visibility statuses for each blog separately ( on the same query ).
$this->ItemQuery->where_visibility($post_show_statuses);
$sql_item_IDs = 'SELECT DISTINCT post_ID' . $this->ItemQuery->get_from();
if (strpos($this->ItemQuery->get_from(), 'T_categories') === false && strpos($this->ItemQuery->get_where(), 'cat_blog_ID') !== false) {
// Join categories table because it is required here for the field "cat_blog_ID"
$sql_item_IDs .= ' INNER JOIN T_categories ON post_main_cat_ID = cat_ID ';
}
$sql_item_IDs .= $this->ItemQuery->get_where();
$item_IDs = $DB->get_col($sql_item_IDs, 0, 'Get CommentQuery Item IDs');
if (empty($item_IDs)) {
// There is no item which belongs to the given blog and user may view it, so there are no comments either
parent::count_total_rows(0);
$this->CommentQuery->WHERE_and('FALSE');
return;
}
$this->CommentQuery->where_post_ID(implode(',', $item_IDs));
/*
* Restrict to active comments by default, show expired comments only if it was requested
* Note: This condition makes the CommentQuery a lot slower!
*/
$this->CommentQuery->expiry_restrict($this->filters['expiry_statuses']);
/*
* GET TOTAL ROW COUNT:
*/
$sql_count = '
SELECT COUNT( ' . $this->Cache->dbIDname . ') ' . $this->CommentQuery->get_from() . $this->CommentQuery->get_where();
parent::count_total_rows($sql_count);
//.........这里部分代码省略.........
示例14: get_write_item_url
/**
* Get url to write a new Post
*
* @param integer Category ID
* @param string Post title
* @param string Post urltitle
* @param string Post type
* @return string Url to write a new Post
*/
function get_write_item_url($cat_ID = 0, $post_title = '', $post_urltitle = '', $post_type = '')
{
$url = '';
if (is_logged_in(false)) {
// Only logged in and activated users can write a Post
global $current_User;
$ChapterCache =& get_ChapterCache();
$selected_Chapter = $ChapterCache->get_by_ID($cat_ID, false, false);
if ($selected_Chapter && $selected_Chapter->lock) {
// This category is locked, don't allow to create new post with this cat
return '';
}
if ($current_User->check_perm('blog_post_statuses', 'edit', false, $this->ID)) {
// We have permission to add a post with at least one status:
if ($this->get_setting('in_skin_editing') && !is_admin_page()) {
// We have a mode 'In-skin editing' for the current Blog
// User must have a permission to publish a post in this blog
$cat_url_param = '';
if ($cat_ID > 0) {
// Link to create a Item with predefined category
$cat_url_param = '&cat=' . $cat_ID;
}
$url = url_add_param($this->get('url'), 'disp=edit' . $cat_url_param);
} elseif ($current_User->check_perm('admin', 'restricted')) {
// Edit a post from Back-office
global $admin_url;
$url = $admin_url . '?ctrl=items&action=new&blog=' . $this->ID;
if (!empty($cat_ID)) {
// Add category param to preselect category on the form
$url = url_add_param($url, 'cat=' . $cat_ID);
}
}
if (!empty($post_title)) {
// Append a post title
$url = url_add_param($url, 'post_title=' . $post_title);
}
if (!empty($post_urltitle)) {
// Append a post urltitle
$url = url_add_param($url, 'post_urltitle=' . $post_urltitle);
}
if (!empty($post_type)) {
// Append a post type
$url = url_add_param($url, 'post_type=' . $post_type);
}
}
}
return $url;
}
示例15: get_reputation_posts
/**
* Get number of posts and percent of published posts by this user
*
* @param array Params
* @return string Result
*/
function get_reputation_posts($params = array())
{
// Make sure we are not missing any param:
$params = array_merge(array('text' => T_('%s (%s%% are public)')), $params);
$total_num_posts = $this->get_num_posts();
$public_num_posts = $this->get_num_posts('published');
if ($total_num_posts > 0) {
// Calc percent of published posts
$public_percent = floor($public_num_posts / $total_num_posts * 100);
} else {
// To avoid devision by zero
$public_percent = 0;
}
if ($total_num_posts > 0) {
// Make a link to page with user's posts:
global $current_User;
if (is_admin_page() && is_logged_in() && ($this->ID == $current_User->ID || $current_User->check_perm('users', 'view'))) {
// For back-office
global $admin_url;
$total_num_posts_url = $admin_url . '?ctrl=user&user_tab=activity&user_ID=' . $this->ID;
} else {
// For front-office
global $Blog;
if (!empty($Blog)) {
// Only if blog is defined
$total_num_posts_url = url_add_param($Blog->gen_blogurl(), 'disp=useritems&user_ID=' . $this->ID);
}
}
}
if (empty($total_num_posts_url)) {
// No link to view posts
$total_num_posts = '<b>' . $total_num_posts . '</b>';
} else {
// Set a posts number as link if it is allowed:
$total_num_posts = '<a href="' . $total_num_posts_url . '"><b>' . $total_num_posts . '</b></a>';
}
return sprintf($params['text'], $total_num_posts, $public_percent);
}