当前位置: 首页>>代码示例>>PHP>>正文


PHP get_ItemCache函数代码示例

本文整理汇总了PHP中get_ItemCache函数的典型用法代码示例。如果您正苦于以下问题:PHP get_ItemCache函数的具体用法?PHP get_ItemCache怎么用?PHP get_ItemCache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_ItemCache函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: CommentFormSent

 /**
  * Event handler: Called before at the beginning, if a comment form gets sent (and received).
  */
 function CommentFormSent(&$params)
 {
     $ItemCache =& get_ItemCache();
     $comment_Item =& $ItemCache->get_by_ID($params['comment_item_ID'], false);
     if (!$comment_Item) {
         // Incorrect item
         return false;
     }
     $item_Blog =& $comment_Item->get_Blog();
     $apply_rendering = $this->get_coll_setting('coll_apply_comment_rendering', $item_Blog);
     if ($item_Blog->get_setting('allow_html_comment') && $this->is_renderer_enabled($apply_rendering, $params['renderers'])) {
         // Do escape html entities only when html is allowed for content and plugin is enabled
         $content =& $params['comment'];
         $content = $this->escape_code($content);
     }
 }
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:19,代码来源:_escapecode.plugin.php

示例2: CommentFormSent

 /**
  * Event handler: Called before at the beginning, if a comment form gets sent (and received).
  */
 function CommentFormSent(&$params)
 {
     $ItemCache =& get_ItemCache();
     $comment_Item =& $ItemCache->get_by_ID($params['comment_item_ID'], false);
     if (!$comment_Item) {
         // Incorrect item
         return false;
     }
     $item_Blog =& $comment_Item->get_Blog();
     $apply_rendering = $this->get_coll_setting('coll_apply_comment_rendering', $item_Blog);
     if ($this->is_renderer_enabled($apply_rendering, $params['renderers'])) {
         // render code blocks in comment
         $params['content'] =& $params['comment'];
         $this->FilterItemContents($params);
     }
 }
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:19,代码来源:_prism.plugin.php

示例3: tool_create_sample_comments

/**
 * Create sample comments and display a process of creating
 *
 * @param integer Blog ID
 * @param integer Number of comments
 * @param integer Number of posts
 */
function tool_create_sample_comments($blog_ID, $num_comments, $num_posts)
{
    global $DB, $posttypes_specialtypes, $localtimenow, $Hit, $Messages, $Debuglog;
    $BlogCache =& get_BlogCache();
    $selected_Blog = $BlogCache->get_by_ID($blog_ID, false, false);
    if ($selected_Blog == NULL) {
        // Incorrect blog ID, Exit here
        return;
    }
    echo T_('Creating of the sample comments...');
    evo_flush();
    /**
     * Disable log queries because it increases the memory and stops the process with error "Allowed memory size of X bytes exhausted..."
     */
    $DB->log_queries = false;
    $curr_orderby = $selected_Blog->get_setting('orderby');
    if ($curr_orderby == 'RAND') {
        $curr_orderby .= '()';
    } else {
        $curr_orderby = 'post_' . $curr_orderby;
    }
    $curr_orderdir = $selected_Blog->get_setting('orderdir');
    // find the $num_posts latest posts in blog
    $SQL = new SQL();
    $SQL->SELECT('post_ID');
    $SQL->FROM('T_items__item');
    $SQL->FROM_add('INNER JOIN T_categories ON post_main_cat_ID = cat_ID');
    $SQL->WHERE('cat_blog_ID = ' . $DB->quote($blog_ID));
    $SQL->WHERE_and('post_status = ' . $DB->quote('published'));
    // Set condition to not create sample comments for special posts
    $SQL->WHERE_and('post_ptyp_ID NOT IN ( ' . $DB->quote($posttypes_specialtypes) . ' )');
    $SQL->ORDER_BY($curr_orderby . ' ' . $curr_orderdir . ', post_ID ' . $curr_orderdir);
    $SQL->LIMIT($num_posts);
    $items_result = $DB->get_results($SQL->get(), ARRAY_A, 'Find the x latest posts in blog');
    $count = 1;
    $fix_content = 'This is an auto generated comment for testing the moderation features.
					http://www.test.com/test_comment_';
    // go through on selected items
    foreach ($items_result as $row) {
        $item_ID = $row['post_ID'];
        $ItemCache =& get_ItemCache();
        $commented_Item =& $ItemCache->get_by_ID($item_ID);
        // create $num_comments comments for each item
        for ($i = 0; $i < $num_comments; $i++) {
            $author = 'Test ' . $count;
            $email = 'test_' . $count . '@test.com';
            $url = 'http://www.test-' . rand(1, 3) . '.com/test_comment_' . $count;
            $content = $fix_content . $count;
            for ($j = 0; $j < 50; $j++) {
                // create 50 random word
                $length = rand(1, 15);
                $word = generate_random_key($length, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
                $content = $content . ' ' . $word;
            }
            // create and save a new comment
            $Comment = new Comment();
            $Comment->set_Item($commented_Item);
            $Comment->set('status', 'draft');
            $Comment->set('author', $author);
            $Comment->set('author_email', $email);
            $Comment->set('author_url', $url);
            $Comment->set('content', $content);
            $Comment->set('date', date('Y-m-d H:i:s', $localtimenow));
            $Comment->set('author_IP', $Hit->IP);
            $Comment->dbsave();
            $count++;
            if ($count % 100 == 0) {
                // Display a process of creating by one dot for 100 comments
                echo ' .';
                evo_flush();
            }
            // Clear all debug messages, To avoid an error about full memory
            $Debuglog->clear('all');
        }
    }
    echo ' OK.';
    $Messages->add(sprintf(T_('Created %d comments.'), $count - 1), 'success');
}
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:85,代码来源:_tool.funcs.php

示例4: param

        } else {
            // not confirmed, Check for restrictions:
            if (!$edited_ItemTag->check_delete(sprintf(T_('Cannot delete tag "%s"'), '<b>' . $edited_ItemTag->dget('name') . '</b>'), array(), true)) {
                // There are restrictions:
                $action = 'list';
            }
        }
        break;
    case 'unlink':
        // Unlink tag from the post:
        // Check that this action request is not a CSRF hacked request:
        $Session->assert_received_crumb('tag');
        // Check that current user has permission to edit tags:
        $current_User->check_perm('options', 'edit', true);
        $item_ID = param('item_ID', 'integer', 0, true);
        $ItemCache =& get_ItemCache();
        $edited_Item =& $ItemCache->get_by_ID($item_ID);
        // Check permission based on DB status:
        $current_User->check_perm('item_post!CURSTATUS', 'edit', true, $edited_Item);
        $result = $DB->query('DELETE FROM T_items__itemtag
			WHERE itag_itm_ID = ' . $DB->quote($edited_Item->ID) . '
			  AND itag_tag_ID = ' . $DB->quote($edited_ItemTag->ID));
        if ($result) {
            $Messages->add(sprintf(T_('Tag "%s" has been unlinked from the post "%s".'), '<b>' . $edited_ItemTag->dget('name') . '</b>', '<b>' . $edited_Item->dget('title') . '</b>'), 'success');
        }
        // Redirect so that a reload doesn't write to the DB twice:
        header_redirect($admin_url . '?ctrl=itemtags&tag_ID=' . $edited_ItemTag->ID . '&action=edit', 303);
        // Will EXIT
        // We have EXITed already at this point!!
        break;
    case 'merge_confirm':
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:31,代码来源:item_tags.ctrl.php

示例5: shutdown

/**
 * Shutdown function: save HIT and update session!
 *
 * This is registered in _main.inc.php with register_shutdown_function()
 * This is called by PHP at the end of the script.
 *
 * NOTE: before PHP 4.1 nothing can be echoed here any more, but the minimum PHP requirement for b2evo is PHP 4.3
 */
function shutdown()
{
    /**
     * @var Hit
     */
    global $Hit;
    /**
     * @var Session
     */
    global $Session;
    global $Settings;
    global $Debuglog;
    global $Timer;
    global $shutdown_count_item_views;
    // Try forking a background process and let the parent return as fast as possbile.
    if (is_callable('pcntl_fork') && function_exists('posix_kill') && defined('STDIN')) {
        if ($pid = pcntl_fork()) {
            return;
        }
        // Parent
        function shutdown_kill()
        {
            posix_kill(posix_getpid(), SIGHUP);
        }
        if (ob_get_level()) {
            // Discard the output buffer and close
            ob_end_clean();
        }
        fclose(STDIN);
        // Close all of the standard
        fclose(STDOUT);
        // file descriptors as we
        fclose(STDERR);
        // are running as a daemon.
        register_shutdown_function('shutdown_kill');
        if (posix_setsid() < 0) {
            return;
        }
        if ($pid = pcntl_fork()) {
            return;
        }
        // Parent
        // Now running as a daemon. This process will even survive
        // an apachectl stop.
    }
    $Timer->resume('shutdown');
    // echo '*** SHUTDOWN FUNC KICKING IN ***';
    // fp> do we need special processing if we are in CLI mode?  probably earlier actually
    // if( ! $is_cli )
    // Note: it might be useful at some point to do special processing if the script has been aborted or has timed out
    // connection_aborted()
    // connection_status()
    if (!empty($shutdown_count_item_views)) {
        // Increment view counts for Items:
        $ItemCache =& get_ItemCache();
        foreach ($shutdown_count_item_views as $item_ID) {
            // asimo> Inserted the $item_ID != 0 check, because another way comes unexpected error on preview page
            if (!empty($item_ID) && ($Item = $ItemCache->get_by_ID($item_ID, false))) {
                $Item->count_view(array('allow_multiple_counts_per_page' => false));
            }
        }
    }
    // Save the current HIT:
    $Hit->log();
    // Update the SESSION:
    $Session->dbsave();
    // Get updates here instead of slowing down normal display of the dashboard
    load_funcs('dashboard/model/_dashboard.funcs.php');
    b2evonet_get_updates();
    // Auto pruning of old HITS, old SESSIONS and potentially MORE analytics data:
    if ($Settings->get('auto_prune_stats_mode') == 'page') {
        // Autopruning is requested
        load_class('sessions/model/_hitlist.class.php', 'Hitlist');
        Hitlist::dbprune();
        // will prune once per day, according to Settings
    }
    // Calling debug_info() here will produce complete data but it will be after </html> hence invalid.
    // Then again, it's for debug only, so it shouldn't matter that much.
    debug_info();
    // Update the SESSION again, at the very end:
    // (e.g. "Debuglogs" may have been removed in debug_info())
    $Session->dbsave();
    $Timer->pause('shutdown');
}
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:92,代码来源:_misc.funcs.php

示例6: dbupdate

    /**
     * Trigger event AfterCommentUpdate after calling parent method.
     *
     * @return boolean true on success
     */
    function dbupdate()
    {
        global $Plugins, $DB;
        $dbchanges = $this->dbchanges;
        if (count($dbchanges)) {
            $this->set_last_touched_date();
        }
        $DB->begin();
        if (($r = parent::dbupdate()) !== false) {
            $update_item_last_touched_date = false;
            if (isset($dbchanges['comment_content']) || isset($dbchanges['comment_renderers'])) {
                // Content is updated
                $this->delete_prerendered_content();
                $update_item_last_touched_date = true;
            }
            if ($this->check_publish_status_changed()) {
                // Comment is updated into/out some public status
                $update_item_last_touched_date = true;
            }
            if (!empty($this->previous_item_ID)) {
                // Comment is moved from another post
                $ItemCache =& get_ItemCache();
                $ItemCache->clear();
                if ($previous_Item =& $ItemCache->get_by_ID($this->previous_item_ID, false, false)) {
                    // Update last touched date of previous item
                    $previous_Item->update_last_touched_date(false);
                }
                // Also update new post
                $update_item_last_touched_date = true;
                // Also move all child comments to new post
                $child_comment_IDs = $this->get_child_comment_IDs();
                if (count($child_comment_IDs)) {
                    $DB->query('UPDATE T_comments
						  SET comment_item_ID = ' . $DB->quote($this->item_ID) . '
						WHERE comment_ID IN ( ' . $DB->quote($child_comment_IDs) . ' )');
                }
            }
            $this->update_last_touched_date($update_item_last_touched_date);
            $DB->commit();
            $Plugins->trigger_event('AfterCommentUpdate', $params = array('Comment' => &$this, 'dbchanges' => $dbchanges));
        } else {
            $DB->rollback();
        }
        return $r;
    }
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:50,代码来源:_comment.class.php

示例7: items_edited_results_block

/**
 * Display the edited items results table
 *
 * @param array Params
 */
function items_edited_results_block($params = array())
{
    // Make sure we are not missing any param:
    $params = array_merge(array('edited_User' => NULL, 'results_param_prefix' => 'actv_postedit_', 'results_title' => T_('Posts edited by the user'), 'results_no_text' => T_('User has not edited any posts')), $params);
    if (!is_logged_in()) {
        // Only logged in users can access to this function
        return;
    }
    global $current_User;
    if (!$current_User->check_perm('users', 'edit')) {
        // Check minimum permission:
        return;
    }
    $edited_User = $params['edited_User'];
    if (!$edited_User) {
        // No defined User, probably the function is calling from AJAX request
        $user_ID = param('user_ID', 'integer', 0);
        if (empty($user_ID)) {
            // Bad request, Exit here
            return;
        }
        $UserCache =& get_UserCache();
        if (($edited_User =& $UserCache->get_by_ID($user_ID, false)) === false) {
            // Bad request, Exit here
            return;
        }
    }
    global $DB;
    param('user_tab', 'string', '', true);
    param('user_ID', 'integer', 0, true);
    $edited_versions_SQL = new SQL();
    $edited_versions_SQL->SELECT('DISTINCT( iver_itm_ID )');
    $edited_versions_SQL->FROM('T_items__version');
    $edited_versions_SQL->WHERE('iver_edit_user_ID = ' . $DB->quote($edited_User->ID));
    $SQL = new SQL();
    $SQL->SELECT('*');
    $SQL->FROM('T_items__item ');
    $SQL->WHERE('( ( post_lastedit_user_ID = ' . $DB->quote($edited_User->ID) . ' ) OR ( post_ID IN ( ' . $edited_versions_SQL->get() . ' ) ) )');
    $SQL->WHERE_and('post_creator_user_ID != ' . $DB->quote($edited_User->ID));
    // Create result set:
    $edited_items_Results = new Results($SQL->get(), $params['results_param_prefix'], 'D');
    $edited_items_Results->Cache =& get_ItemCache();
    $edited_items_Results->title = $params['results_title'];
    $edited_items_Results->no_results_text = $params['results_no_text'];
    // Get a count of the post which current user can delete
    $deleted_posts_edited_count = count($edited_User->get_deleted_posts('edited'));
    if ($edited_items_Results->total_rows > 0 && $deleted_posts_edited_count > 0) {
        // Display actino icon to delete all records if at least one record exists & current user can delete at least one item created by user
        $edited_items_Results->global_icon(sprintf(T_('Delete all post edited by %s'), $edited_User->login), 'delete', '?ctrl=user&amp;user_tab=activity&amp;action=delete_all_posts_edited&amp;user_ID=' . $edited_User->ID . '&amp;' . url_crumb('user'), ' ' . T_('Delete all'), 3, 4);
    }
    // Initialize Results object
    items_results($edited_items_Results, array('field_prefix' => 'post_', 'display_ord' => false, 'display_history' => false));
    if (is_ajax_content()) {
        // init results param by template name
        if (!isset($params['skin_type']) || !isset($params['skin_name'])) {
            debug_die('Invalid ajax results request!');
        }
        $edited_items_Results->init_params_by_skin($params['skin_type'], $params['skin_name']);
    }
    $display_params = array('before' => '<div class="results" style="margin-top:25px" id="edited_posts_result">');
    $edited_items_Results->display($display_params);
    if (!is_ajax_content()) {
        // Create this hidden div to get a function name for AJAX request
        echo '<div id="' . $params['results_param_prefix'] . 'ajax_callback" style="display:none">' . __FUNCTION__ . '</div>';
    }
}
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:71,代码来源:_item.funcs.php

示例8: get_file_links

/**
 * Get all links where file is used
 *
 * @param integer File ID
 * @param array Params
 * @return string The links to that posts, comments and users where the file is used
 */
function get_file_links($file_ID, $params = array())
{
    global $DB, $current_User, $baseurl, $admin_url;
    $params = array_merge(array('separator' => '<br />', 'post_prefix' => T_('Post') . ' - ', 'comment_prefix' => T_('Comment on') . ' - ', 'user_prefix' => T_('Profile picture') . ' - '), $params);
    // Create result array
    $attached_to = array();
    // Get all links with posts and comments
    $links_SQL = new SQL();
    $links_SQL->SELECT('link_itm_ID, link_cmt_ID');
    $links_SQL->FROM('T_links');
    $links_SQL->WHERE('link_file_ID = ' . $DB->quote($file_ID));
    $links = $DB->get_results($links_SQL->get());
    if (!empty($links)) {
        // File is linked with some posts or comments
        $ItemCache =& get_ItemCache();
        $CommentCache =& get_CommentCache();
        foreach ($links as $link) {
            if (!empty($link->link_itm_ID)) {
                // File is linked to a post
                if ($Item =& $ItemCache->get_by_ID($link->link_itm_ID, false)) {
                    $Blog = $Item->get_Blog();
                    if ($current_User->check_perm('item_post!CURSTATUS', 'view', false, $Item)) {
                        // Current user can edit the linked post
                        $attached_to[] = $params['post_prefix'] . '<a href="' . url_add_param($admin_url, 'ctrl=items&amp;blog=' . $Blog->ID . '&amp;p=' . $link->link_itm_ID) . '">' . $Item->get('title') . '</a>';
                    } else {
                        // No access to edit the linked post
                        $attached_to[] = $params['post_prefix'] . $Item->get('title');
                    }
                }
            }
            if (!empty($link->link_cmt_ID)) {
                // File is linked to a comment
                if ($Comment =& $CommentCache->get_by_ID($link->link_cmt_ID, false)) {
                    $Item = $Comment->get_Item();
                    if ($current_User->check_perm('comment!CURSTATUS', 'moderate', false, $Comment)) {
                        // Current user can edit the linked Comment
                        $attached_to[] = $params['comment_prefix'] . '<a href="' . url_add_param($admin_url, 'ctrl=comments&amp;action=edit&amp;comment_ID=' . $link->link_cmt_ID) . '">' . $Item->get('title') . '</a>';
                    } else {
                        // No access to edit the linked Comment
                        $attached_to[] = $params['comment_prefix'] . $Item->get('title');
                    }
                }
            }
        }
    }
    // Get all links with profile pictures
    $profile_links_SQL = new SQL();
    $profile_links_SQL->SELECT('user_ID, user_login');
    $profile_links_SQL->FROM('T_users');
    $profile_links_SQL->WHERE('user_avatar_file_ID = ' . $DB->quote($file_ID));
    $profile_links = $DB->get_results($profile_links_SQL->get());
    if (!empty($profile_links)) {
        foreach ($profile_links as $link) {
            if ($current_User->ID != $link->user_ID && !$current_User->check_perm('users', 'view')) {
                // No permission to view other users in admin form
                $attached_to[] = $params['user_prefix'] . '<a href="' . url_add_param($baseurl, 'disp=user&amp;user_ID=' . $link->user_ID) . '">' . $link->user_login . '</a>';
            } else {
                // Build a link to display a user in admin form
                $attached_to[] = $params['user_prefix'] . '<a href="?ctrl=user&amp;user_tab=profile&amp;user_ID=' . $link->user_ID . '">' . $link->user_login . '</a>';
            }
        }
    }
    return implode($params['separator'], $attached_to);
}
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:71,代码来源:_link.funcs.php

示例9: dbm_recreate_itemslugs

/**
 * Recreate all item slugs (change title-[0-9] canonical slugs to a slug generated from current title). Old slugs will still work, but redirect to the new one.
 */
function dbm_recreate_itemslugs()
{
    global $Messages;
    $ItemCache = get_ItemCache();
    $ItemCache->load_where('( post_title != "" ) AND ( post_urltitle = "title" OR post_urltitle LIKE "title-%" )');
    $items = $ItemCache->get_ID_array();
    $count_slugs = 0;
    foreach ($items as $item_ID) {
        $Item = $ItemCache->get_by_ID($item_ID);
        $prev_urltitle = $Item->get('urltitle');
        $item_title = $Item->get('title');
        // check if post title is not empty and urltitle was auto generated ( equals title or title-[0-9]+ )
        // Note: urltitle will be auto generated on this form (title-[0-9]+), if post title wass empty and, urltitle was not set
        // Note: Even if a post title was set to 'title' on purpose it's possible, that this tool will change the post urltitle
        if (!empty($item_title) && ($prev_urltitle == 'title' || preg_match('#^title-[0-9]+$#', $prev_urltitle))) {
            // set urltitle empty, so the item update function will regenerate the item slug
            $Item->set('urltitle', '');
            $result = $Item->dbupdate(false, true, false);
            if ($result && $prev_urltitle != $Item->get('urltitle')) {
                // update was successful, and item urltitle was changed
                $count_slugs++;
            }
        }
    }
    $Messages->add(sprintf('Created %d new URL slugs.', $count_slugs), 'success');
}
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:29,代码来源:_dbmaintenance.funcs.php

示例10: get_deleted_posts

 /**
  * Get the posts of this user which current user can delete
  *
  * @param string Type of the deleted posts
  *               'created'        - the posts created by this user
  *               'edited'         - the posts edited by this user
  *               'created|edited' - the posts created OR edited by this user
  * @return array Items
  */
 function get_deleted_posts($type)
 {
     global $DB, $current_User;
     $ItemCache =& get_ItemCache();
     $ItemCache->ID_array = array();
     switch ($type) {
         case 'created':
             $user_Items = $ItemCache->load_where('post_creator_user_ID = ' . $DB->quote($this->ID));
             break;
         case 'edited':
             $user_Items = $ItemCache->load_where('post_lastedit_user_ID = ' . $DB->quote($this->ID));
             break;
         case 'created|edited':
             $user_Items = $ItemCache->load_where('post_lastedit_user_ID = ' . $DB->quote($this->ID) . ' OR post_creator_user_ID = ' . $DB->quote($this->ID));
             break;
     }
     $deleted_Items = array();
     foreach ($user_Items as $user_Item) {
         if ($current_User->check_perm('item_post!CURSTATUS', 'delete', false, $user_Item)) {
             // Current user has a permission to delete this item
             $deleted_Items[] = $user_Item;
         }
     }
     return $deleted_Items;
 }
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:34,代码来源:_user.class.php

示例11: display


//.........这里部分代码省略.........
             $text = T_('Edit profile');
             // Is this the current display?  (Edit my Profile)
             if (in_array($disp, array('profile', 'avatar', 'pwdchange', 'userprefs', 'subs'))) {
                 // Let's display the link as selected
                 $link_class = $this->disp_params['link_selected_class'];
             }
             break;
         case 'avatar':
             if (!is_logged_in()) {
                 return false;
             }
             $url = get_user_avatar_url();
             $text = T_('Profile picture');
             // Note: we never highlight this, it will always highlight 'profile' instead
             break;
         case 'users':
             global $Settings;
             if (!is_logged_in() && !$Settings->get('allow_anonymous_user_list')) {
                 // Don't allow anonymous users to see users list
                 return false;
             }
             $url = $Blog->get('usersurl');
             $text = T_('User directory');
             // Is this the current display?
             // Note: If $user_ID is not set, it means we are viewing "My Profile" instead
             global $user_ID;
             if ($disp == 'users' || $disp == 'user' && !empty($user_ID)) {
                 // Let's display the link as selected
                 // Note: we also highlight this for any user profile that is displayed
                 $link_class = $this->disp_params['link_selected_class'];
             }
             break;
         case 'item':
             $ItemCache =& get_ItemCache();
             /**
              * @var Item
              */
             $item_ID = (int) $this->disp_params['item_ID'];
             $disp_Item =& $ItemCache->get_by_ID($item_ID, false, false);
             if (empty($disp_Item)) {
                 // Item not found
                 return false;
             }
             $url = $disp_Item->get_permanent_url();
             $text = $disp_Item->title;
             // Is this the current item?
             global $Item;
             if (!empty($Item) && $disp_Item->ID == $Item->ID) {
                 // The current page is currently displaying the Item this link is pointing to
                 // Let's display it as selected
                 $link_class = $this->disp_params['link_selected_class'];
             }
             break;
         case 'url':
             $url = $this->disp_params['link_href'];
             $text = '[URL]';
             // should normally be overriden below...
             // Note: we never highlight this link
             break;
         case 'postnew':
             if (!check_item_perm_create()) {
                 // Don't allow users to create a new post
                 return false;
             }
             $url = url_add_param($Blog->get('url'), 'disp=edit');
             $text = T_('Write a new post');
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:67,代码来源:_menu_link.widget.php

示例12: T_

$Form->hiddens_by_key(get_memorized('action' . ($creating ? ',tag_ID' : '')));
$Form->text_input('tag_name', $edited_ItemTag->get('name'), 50, T_('Tag'), '', array('maxlength' => 255, 'required' => true));
$Form->end_form(array(array('submit', 'submit', $creating ? T_('Record') : T_('Save Changes!'), 'SaveButton')));
// Item list with this tag:
if ($edited_ItemTag->ID > 0) {
    $SQL = new SQL();
    $SQL->SELECT('T_items__item.*, blog_shortname');
    $SQL->FROM('T_items__itemtag');
    $SQL->FROM_add('INNER JOIN T_items__item ON itag_itm_ID = post_ID');
    $SQL->FROM_add('INNER JOIN T_categories ON post_main_cat_ID = cat_ID');
    $SQL->FROM_add('INNER JOIN T_blogs ON cat_blog_ID = blog_ID');
    $SQL->WHERE('itag_tag_ID = ' . $DB->quote($edited_ItemTag->ID));
    // Create result set:
    $Results = new Results($SQL->get(), 'tagitem_', 'A');
    $Results->title = T_('Posts that have this tag') . ' (' . $Results->get_total_rows() . ')';
    $Results->Cache = get_ItemCache();
    $Results->cols[] = array('th' => T_('Post ID'), 'th_class' => 'shrinkwrap', 'td_class' => 'shrinkwrap', 'order' => 'post_ID', 'td' => '$post_ID$');
    $Results->cols[] = array('th' => T_('Collection'), 'order' => 'blog_shortname', 'td' => '$blog_shortname$');
    $Results->cols[] = array('th' => T_('Post title'), 'order' => 'post_title', 'td' => '<a href="@get_permanent_url()@">$post_title$</a>');
    function tagitem_edit_actions($Item)
    {
        global $current_User, $edited_ItemTag;
        // Display the edit icon if current user has the rights:
        $r = $Item->get_edit_link(array('before' => '', 'after' => ' ', 'text' => get_icon('edit'), 'title' => '#', 'class' => ''));
        if ($current_User->check_perm('item_post!CURSTATUS', 'edit', false, $Item)) {
            // Display the unlink icon if current user has the rights:
            $r .= action_icon(T_('Unlink this tag from post!'), 'unlink', regenerate_url('tag_ID,action,tag_filter', 'tag_ID=' . $edited_ItemTag->ID . '&amp;item_ID=' . $Item->ID . '&amp;action=unlink&amp;' . url_crumb('tag')), NULL, NULL, NULL, array('onclick' => 'return confirm(\'' . format_to_output(sprintf(TS_('Are you sure you want to remove the tag "%s" from "%s"?'), $edited_ItemTag->dget('name'), $Item->dget('title')) . '\');', 'htmlattr')));
        }
        return $r;
    }
    $Results->cols[] = array('th' => T_('Actions'), 'th_class' => 'shrinkwrap', 'td_class' => 'shrinkwrap', 'td' => '%tagitem_edit_actions( {Obj} )%');
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:31,代码来源:_itemtag.form.php

示例13: dbupdate

 /**
  * Update the DB based on previously recorded changes.
  *
  * @todo dh> this is very Item specific, and should get fixed probably.
  *
  * @return boolean true on success
  */
 function dbupdate()
 {
     global $DB, $Messages;
     $ItemCache =& get_ItemCache();
     $Item =& $ItemCache->get_by_id($this->itm_ID);
     $DB->begin();
     if ($Item->get('canonical_slug_ID') == $this->ID) {
         $Item->set('urltitle', $this->title);
         if (!$Item->dbupdate(true, false, false)) {
             $DB->rollback();
             return false;
         }
         $Messages->add(sprintf(T_('Warning: this change also changed the canonical slug of the post! (%s)'), $this->get_link_to_object()), 'warning');
     }
     parent::dbupdate();
     $DB->commit();
     return true;
 }
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:25,代码来源:_slug.class.php

示例14: stats_goal_hit_extra_params

/**
 * Parse extra params of goal hit (E.g. 'item_ID=123')
 *
 * @param string Value of extra params
 * @param string
 */
function stats_goal_hit_extra_params($ghit_params)
{
    if (preg_match('/^item_ID=([0-9]+)$/i', $ghit_params, $matches)) {
        // Parse item ID
        $ItemCache =& get_ItemCache();
        if ($Item =& $ItemCache->get_by_ID(intval($matches[1]), false, false)) {
            // Display a link to view with current item title
            global $current_User;
            if ($current_User->check_perm('item_post!CURSTATUS', 'edit', false, $Item)) {
                // Link to admin view
                return $Item->get_title(array('link_type' => 'admin_view'));
            } else {
                // Link to permament url (it is allowed for current post type)
                return $Item->get_title();
            }
        }
    }
    return htmlspecialchars($ghit_params);
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:25,代码来源:_hitlog.funcs.php

示例15: display

    /**
     * Display the widget!
     *
     * @param array MUST contain at least the basic display params
     */
    function display($params)
    {
        global $localtimenow, $DB, $Blog;
        $this->init_display($params);
        $blog_ID = intval($this->disp_params['blog_ID']);
        if (empty($blog_ID)) {
            // Use current blog by default
            $blog_ID = $Blog->ID;
        }
        $BlogCache =& get_BlogCache();
        if (!$BlogCache->get_by_ID($blog_ID, false, false)) {
            // No blog exists
            return;
        }
        // Display photos:
        // TODO: permissions, complete statuses...
        // TODO: A FileList object based on ItemListLight but adding File data into the query?
        //          overriding ItemListLigth::query() for starters ;)
        // Init caches
        $FileCache =& get_FileCache();
        $ItemCache =& get_ItemCache();
        // Query list of files and posts fields:
        // Note: We use ItemQuery to get attachments from all posts which should be visible ( even in case of aggregate blogs )
        $ItemQuery = new ItemQuery($ItemCache->dbtablename, $ItemCache->dbprefix, $ItemCache->dbIDname);
        $ItemQuery->SELECT('post_ID, post_datestart, post_datemodified, post_main_cat_ID, post_urltitle, post_canonical_slug_ID,
									post_tiny_slug_ID, post_ityp_ID, post_title, post_excerpt, post_url, file_ID, file_type,
									file_title, file_root_type, file_root_ID, file_path, file_alt, file_desc, file_path_hash');
        $ItemQuery->FROM_add('INNER JOIN T_links ON post_ID = link_itm_ID');
        $ItemQuery->FROM_add('INNER JOIN T_files ON link_file_ID = file_ID');
        $ItemQuery->where_chapter($blog_ID);
        if ($this->disp_params['item_visibility'] == 'public') {
            // Get images only of the public items
            $ItemQuery->where_visibility(array('published'));
        } else {
            // Get image of all available posts for current user
            $ItemQuery->where_visibility(NULL);
        }
        $ItemQuery->WHERE_and('( file_type = "image" ) OR ( file_type IS NULL )');
        $ItemQuery->WHERE_and('post_datestart <= \'' . remove_seconds($localtimenow) . '\'');
        $ItemQuery->WHERE_and('link_position != "cover"');
        if (!empty($this->disp_params['item_type'])) {
            // Get items only with specified type
            $ItemQuery->WHERE_and('post_ityp_ID = ' . intval($this->disp_params['item_type']));
        }
        $ItemQuery->GROUP_BY('link_ID');
        // fp> TODO: because no way of getting images only, we get 4 times more data than requested and hope that 25% at least will be images :/
        // asimo> This was updated and we get images and those files where we don't know the file type yet. Now we get 2 times more data than requested.
        // Maybe it would be good to get only the requested amount of files, because after a very short period the file types will be set for all images.
        $ItemQuery->LIMIT(intval($this->disp_params['limit']) * 2);
        $ItemQuery->ORDER_BY(gen_order_clause($this->disp_params['order_by'], $this->disp_params['order_dir'], 'post_', 'post_ID ' . $this->disp_params['order_dir'] . ', link_ID'));
        // Init FileList with the above defined query
        $FileList = new DataObjectList2($FileCache);
        $FileList->sql = $ItemQuery->get();
        $FileList->query(false, false, false, 'Media index widget');
        $layout = $this->disp_params['thumb_layout'];
        $nb_cols = $this->disp_params['grid_nb_cols'];
        $count = 0;
        $r = '';
        /**
         * @var File
         */
        while ($File =& $FileList->get_next()) {
            if ($count >= $this->disp_params['limit']) {
                // We have enough images already!
                break;
            }
            if (!$File->is_image()) {
                // Skip anything that is not an image
                // Only images are selected or those files where we don't know the file type yet.
                // This check is only for those files where we don't know the filte type. The file type will be set during the check.
                continue;
            }
            if ($layout == 'grid') {
                // Grid layout
                if ($count % $nb_cols == 0) {
                    $r .= $this->disp_params['grid_colstart'];
                }
                $r .= $this->disp_params['grid_cellstart'];
            } elseif ($layout == 'flow') {
                // Flow block layout
                $r .= $this->disp_params['flow_block_start'];
            } else {
                // List layout
                $r .= $this->disp_params['item_start'];
            }
            // 1/ Hack a dirty permalink( will redirect to canonical):
            // $link = url_add_param( $Blog->get('url'), 'p='.$post_ID );
            // 2/ Hack a link to the right "page". Very daring!!
            // $link = url_add_param( $Blog->get('url'), 'paged='.$count );
            // 3/ Instantiate a light object in order to get permamnent url:
            $ItemLight = new ItemLight($FileList->get_row_by_idx($FileList->current_idx - 1));
            // index had already been incremented
            $r .= '<a href="' . $ItemLight->get_permanent_url() . '">';
            // Generate the IMG THUMBNAIL tag with all the alt, title and desc if available
            $r .= $File->get_thumb_imgtag($this->disp_params['thumb_size'], '', '', $ItemLight->title);
//.........这里部分代码省略.........
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:101,代码来源:_coll_media_index.widget.php


注:本文中的get_ItemCache函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。