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


PHP ocp_tempcode::from_assembly方法代码示例

本文整理汇总了PHP中ocp_tempcode::from_assembly方法的典型用法代码示例。如果您正苦于以下问题:PHP ocp_tempcode::from_assembly方法的具体用法?PHP ocp_tempcode::from_assembly怎么用?PHP ocp_tempcode::from_assembly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ocp_tempcode的用法示例。


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

示例1: points_get_transactions

/**
 * Show the point transactions a member has had.
 *
 * @param  ID_TEXT		The type of transactions we are looking for
 * @set    from to
 * @param  MEMBER			Who we are looking at transactions for
 * @param  MEMBER			Who we are looking at transactions using the account of
 * @return tempcode		The UI
 */
function points_get_transactions($type, $member_id_of, $member_id_viewing)
{
    $where = array('gift_' . $type => $member_id_of);
    if ($type == 'from') {
        $where['anonymous'] = 0;
    }
    $start = get_param_integer('gift_start_' . $type, 0);
    $max = get_param_integer('gift_max_' . $type, 10);
    $sortables = array('date_and_time' => do_lang_tempcode('DATE'), 'amount' => do_lang_tempcode('AMOUNT'));
    $test = explode(' ', get_param('gift_sort_' . $type, 'date_and_time DESC'));
    if (count($test) == 1) {
        $test[1] = 'DESC';
    }
    list($sortable, $sort_order) = $test;
    if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) {
        log_hack_attack_and_exit('ORDERBY_HACK');
    }
    global $NON_CANONICAL_PARAMS;
    $NON_CANONICAL_PARAMS[] = 'gift_sort_' . $type;
    $NON_CANONICAL_PARAMS[] = 'gift_start_' . $type;
    $max_rows = $GLOBALS['SITE_DB']->query_value('gifts', 'COUNT(*)', $where);
    $rows = $GLOBALS['SITE_DB']->query_select('gifts g LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND t.id=g.reason', array('*'), $where, 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start);
    $out = new ocp_tempcode();
    $viewing_name = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of);
    if (is_null($viewing_name)) {
        $viewing_name = do_lang('UNKNOWN');
    }
    require_code('templates_results_table');
    $fields_title = results_field_title(array(do_lang_tempcode('DATE'), do_lang_tempcode('AMOUNT'), do_lang_tempcode('FROM'), do_lang_tempcode('TO'), do_lang_tempcode('REASON')), $sortables, 'gift_sort_' . $type, $sortable . ' ' . $sort_order);
    foreach ($rows as $myrow) {
        if ($myrow['anonymous'] == 1 && $type == 'from') {
            continue;
        }
        // Their name
        $fromname = is_guest($myrow['gift_from']) ? get_site_name() : $GLOBALS['FORUM_DRIVER']->get_username($myrow['gift_from']);
        $toname = $GLOBALS['FORUM_DRIVER']->get_username($myrow['gift_to']);
        if (is_null($fromname)) {
            $fromname = do_lang('UNKNOWN');
        }
        if ($myrow['anonymous'] == 1 && !is_guest($myrow['gift_from'])) {
            if (!has_specific_permission($member_id_viewing, 'trace_anonymous_gifts')) {
                $_fromname = do_lang_tempcode('ANON');
            } else {
                $_fromname = hyperlink(build_url(array('page' => 'points', 'type' => 'member', 'id' => $myrow['gift_from']), get_module_zone('points')), do_lang_tempcode('ANON'), false, false, escape_html($fromname));
            }
        } else {
            $_fromname = is_guest($myrow['gift_from']) ? make_string_tempcode(escape_html($fromname)) : hyperlink(build_url(array('page' => 'points', 'type' => 'member', 'id' => $myrow['gift_from']), get_module_zone('points')), escape_html($fromname), false, false, do_lang_tempcode('VIEW_POINTS'));
        }
        $_toname = hyperlink(build_url(array('page' => 'points', 'type' => 'member', 'id' => $myrow['gift_to']), get_module_zone('points')), escape_html($toname), false, false, do_lang_tempcode('VIEW_POINTS'));
        $date = get_timezoned_date($myrow['date_and_time']);
        $amount = $myrow['amount'];
        if (get_page_name() != 'search' && array_key_exists('text_parsed', $myrow) && !is_null($myrow['text_parsed']) && $myrow['text_parsed'] != '' && $myrow['reason'] != 0) {
            $reason = new ocp_tempcode();
            if (!$reason->from_assembly($myrow['text_parsed'], true)) {
                $reason = get_translated_tempcode($myrow['reason']);
            }
        } else {
            $reason = get_translated_tempcode($myrow['reason']);
        }
        $out->attach(results_entry(array(escape_html($date), escape_html(integer_format($amount)), $_fromname, $_toname, $reason)));
    }
    $out = results_table(do_lang_tempcode('_POINTS', escape_html($viewing_name)), $start, 'gift_start_' . $type, $max, 'gift_max_' . $type, $max_rows, $fields_title, $out, $sortables, $sortable, $sort_order, 'gift_sort_' . $type, NULL, NULL, NULL, 8, 'gfhfghtrhhjghgfhfgf', false, 'tab__points');
    if ($type == 'to') {
        $title = do_lang_tempcode('POINTS_TO');
    } else {
        $title = do_lang_tempcode('POINTS_FROM');
    }
    return do_template('POINTS_TRANSACTIONS_WRAP', array('_GUID' => 'f19e3eedeb0b8bf398251b24e8389723', 'CONTENT' => $out, 'TITLE' => $title));
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:78,代码来源:points3.php

示例2: ocf_show_isolated_post

/**
 * Show a post, isolated of the other posts in it's topic.
 *
 * @param  array		The post row.
 * @param  boolean	Whether to use the post title, as opposed to the post's topic's title.
 * @return tempcode  The isolated post.
 */
function ocf_show_isolated_post($row, $use_post_title = false)
{
    require_code('ocf_groups');
    require_css('ocf');
    // Poster title
    $primary_group = $GLOBALS['FORUM_DRIVER']->get_member_row_field($row['p_poster'], 'm_primary_group');
    if (!is_null($primary_group)) {
        if (addon_installed('ocf_member_titles')) {
            $poster_title = $GLOBALS['OCF_DRIVER']->get_member_row_field($row['p_poster'], 'm_title');
            if ($poster_title == '') {
                $poster_title = get_translated_text(ocf_get_group_property($primary_group, 'title'), $GLOBALS['FORUM_DB']);
            }
        } else {
            $poster_title = '';
        }
        $avatar = $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($row['p_poster']);
        $posters_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($row['p_poster'], true);
    } else {
        $poster_title = '';
        $avatar = '';
        $posters_groups = array();
    }
    // Avatar
    if (is_guest($row['p_poster'])) {
        if ($row['p_poster_name_if_guest'] == do_lang('SYSTEM')) {
            $avatar = find_theme_image('ocf_default_avatars/default_set/ocp_fanatic', true);
        }
    }
    if ($avatar != '') {
        $post_avatar = do_template('OCF_TOPIC_POST_AVATAR', array('AVATAR' => $avatar));
    } else {
        $post_avatar = new ocp_tempcode();
    }
    // Rank images
    $rank_images = new ocp_tempcode();
    foreach ($posters_groups as $group) {
        $rank_image = ocf_get_group_property($group, 'rank_image');
        $group_leader = ocf_get_group_property($group, 'group_leader');
        $group_name = ocf_get_group_name($group);
        $rank_image_pri_only = ocf_get_group_property($group, 'rank_image_pri_only');
        if ($rank_image != '' && ($rank_image_pri_only == 0 || $group == $primary_group)) {
            $rank_images->attach(do_template('OCF_RANK_IMAGE', array('GROUP_NAME' => $group_name, 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($row['p_poster']), 'IMG' => $rank_image, 'IS_LEADER' => $group_leader == $row['p_poster'])));
        }
    }
    // Poster details
    if (!is_guest($row['p_poster']) && !is_null($primary_group)) {
        require_code('ocf_members2');
        $poster_details = ocf_show_member_box($row['p_poster'], false, NULL, NULL, false);
    } else {
        $custom_fields = new ocp_tempcode();
        $poster_details = new ocp_tempcode();
    }
    if (!is_guest($row['p_poster']) && !is_null($primary_group)) {
        $poster = do_template('OCF_POSTER_MEMBER', array('ONLINE' => member_is_online($row['p_poster']), 'ID' => strval($row['p_poster']), 'POSTER_DETAILS' => $poster_details, 'PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($row['p_poster'], false, true), 'POSTER_USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($row['p_poster']), 'HIGHLIGHT_NAME' => NULL));
    } else {
        $poster = do_template('OCF_POSTER_GUEST', array('IP_LINK' => '', 'POSTER_DETAILS' => $poster_details, 'POSTER_USERNAME' => $row['p_poster_name_if_guest'] != '' ? $row['p_poster_name_if_guest'] : do_lang('GUEST')));
    }
    // Last edited
    if (!is_null($row['p_last_edit_time'])) {
        $last_edited = do_template('OCF_TOPIC_POST_LAST_EDITED', array('LAST_EDIT_DATE_RAW' => is_null($row['p_last_edit_time']) ? '' : strval($row['p_last_edit_time']), 'LAST_EDIT_DATE' => get_timezoned_date($row['p_last_edit_time']), 'LAST_EDIT_PROFILE_URL' => is_null($row['p_last_edit_by']) ? '' : $GLOBALS['FORUM_DRIVER']->member_profile_url($row['p_last_edit_by'], false, true), 'LAST_EDIT_USERNAME' => is_null($row['p_last_edit_by']) ? '' : $GLOBALS['FORUM_DRIVER']->get_username($row['p_last_edit_by'])));
    } else {
        $last_edited = new ocp_tempcode();
    }
    $last_edited_raw = is_null($row['p_last_edit_time']) ? '' : strval($row['p_last_edit_time']);
    // Misc stuff
    $poster_id = $row['p_poster'];
    $tree = ocf_forum_breadcrumbs($row['p_cache_forum_id']);
    $post_url = build_url(array('page' => 'topicview', 'type' => 'findpost', 'id' => $row['id']), get_module_zone('topicview'));
    $post_url->attach('#post_' . strval($row['id']));
    if (get_page_name() != 'search' && array_key_exists('text_parsed', $row) && !is_null($row['text_parsed']) && $row['text_parsed'] != '' && $row['p_post'] != 0) {
        $post = new ocp_tempcode();
        if (!$post->from_assembly($row['text_parsed'], true)) {
            $post = get_translated_tempcode($row['p_post'], $GLOBALS['FORUM_DB']);
        }
    } else {
        $post = get_translated_tempcode($row['p_post'], $GLOBALS['FORUM_DB']);
    }
    $post_date = get_timezoned_date($row['p_time']);
    $post_date_raw = $row['p_time'];
    if ($use_post_title) {
        $post_title = $row['p_title'];
    } else {
        $post_title = $GLOBALS['FORUM_DB']->query_value('f_topics', 't_cache_first_title', array('id' => $row['p_topic_id']));
        if ($row['p_title'] != $post_title) {
            $post_title .= ': ' . $row['p_title'];
        }
    }
    //if ($post_title=='') $post_title=do_lang_tempcode('ISOLATED_POST_TITLE',strval($row['id']));
    $emphasis = new ocp_tempcode();
    if ($row['p_is_emphasised'] == 1) {
        $emphasis = do_lang_tempcode('IMPORTANT');
    } elseif (!is_null($row['p_intended_solely_for'])) {
        $pp_to_username = $GLOBALS['FORUM_DRIVER']->get_username($row['p_intended_solely_for']);
//.........这里部分代码省略.........
开发者ID:erico-deh,项目名称:ocPortal,代码行数:101,代码来源:ocf_posts2.php

示例3: do_template

/**
 * Get a tempcoded version of a normal XHTML template. It is perhaps the most common ocPortal function to load up templates using do_template, and then attach them together either as parameters to each other, or via the tempcode attach method.
 *
 * @param  ID_TEXT			The codename of the template being loaded
 * @param  ?array				A map of parameters for the template (key to value) (NULL: no parameters)
 * @param  ?LANGUAGE_NAME 	The language to load the template in (templates can embed language references) (NULL: users own language)
 * @param  boolean			Whether to not produce a stack dump if the template is missing
 * @param  ?ID_TEXT			Alternate template to use if the primary one does not exist (NULL: none)
 * @param  string				File type suffix of template file (e.g. .tpl)
 * @param  string				Subdirectory type to look in
 * @set    templates css
 * @param  ID_TEXT			Theme to use
 * @return tempcode			The tempcode for this template
 */
function do_template($codename, $parameters = NULL, $lang = NULL, $light_error = false, $fallback = NULL, $suffix = '.tpl', $type = 'templates', $theme = NULL)
{
    if (is_null($lang) || $lang == '') {
        global $USER_LANG_CACHED;
        $lang = isset($USER_LANG_CACHED) ? $USER_LANG_CACHED : (function_exists('user_lang') ? user_lang() : 'EN');
    }
    if ($GLOBALS['SEMI_DEBUG_MODE']) {
        if ($codename != 'tempcode_test' && $codename != 'handle_conflict_resolution' && strtoupper($codename) != strtoupper($codename)) {
            fatal_exit('Template names should be in upper case, and the files should be stored in upper case.');
        }
        if (substr($codename, -7) == '_SCREEN' || $codename == 'POOR_XHTML_WRAPPER' || $codename == 'OCF_WRAPPER') {
            $GLOBALS['SCREEN_TEMPLATE_CALLED'] = $codename;
        }
    }
    if (is_null($parameters)) {
        $parameters = array();
    }
    global $RECORD_TEMPLATES_USED, $FILE_ARRAY, $MEM_CACHE, $CACHE_TEMPLATES, $KEEP_MARKERS, $SHOW_EDIT_LINKS, $XHTML_SPIT_OUT, $TEMPLATE_CACHE, $MOBILE, $FORUM_DRIVER;
    $special_treatment = ($KEEP_MARKERS || $SHOW_EDIT_LINKS) && is_null($XHTML_SPIT_OUT);
    // Is it already loaded?
    if ($RECORD_TEMPLATES_USED) {
        global $RECORDED_TEMPLATES_USED;
        $RECORDED_TEMPLATES_USED[] = $codename;
    }
    // Variables we'll need
    if (!isset($theme)) {
        $theme = isset($FORUM_DRIVER) && is_object($FORUM_DRIVER) && method_exists($FORUM_DRIVER, 'get_theme') ? filter_naughty($FORUM_DRIVER->get_theme()) : 'default';
    }
    $_codename = $MOBILE ? $codename . '_mobile' : $codename;
    if (isset($TEMPLATE_CACHE[$theme][$codename][$lang])) {
        $_data = $TEMPLATE_CACHE[$theme][$codename][$lang]->bind($parameters, $codename);
        // Copy and pasted to remove need for an function call
        if ($special_treatment) {
            if ($KEEP_MARKERS) {
                $__data = make_string_tempcode('<!-- START-TEMPLATE=' . $codename . ' -->');
                $__data->attach($_data);
                $__data->attach('<!-- END-TEMPLATE=' . $codename . ' -->');
                $_data = $__data;
            }
            if ($SHOW_EDIT_LINKS) {
                $edit_url = build_url(array('page' => 'admin_themes', 'theme' => $FORUM_DRIVER->get_theme(), 'template' => $codename), 'adminzone');
                $_data->attach('<br /><a href="' . escape_html($edit_url->evaluate()) . '">' . do_lang('EDIT') . ' ' . $codename . '</a>');
            }
        }
        return $_data;
    }
    // Is it structurally cached on disk yet?
    $data = mixed();
    if ($CACHE_TEMPLATES) {
        if (!is_null($MEM_CACHE)) {
            $data = persistant_cache_get(array('TEMPLATE', $theme, $lang, $_codename));
            if (!is_null($data)) {
                $_data = new ocp_tempcode();
                $_data->from_assembly($data);
                if ($_data->bits == array()) {
                    $data = false;
                }
                // Corrupt somehow
            } else {
                $data = false;
            }
        } elseif (is_null($data)) {
            $_data = new ocp_tempcode();
            $tcp_path = get_custom_file_base() . '/themes/' . $theme . '/templates_cached/' . $lang . '/' . $_codename . $suffix . '.tcd';
            $data = @file_get_contents($tcp_path, FILE_BINARY);
            if ($data === '') {
                $data = false;
            }
            // '' needed for PHP4 - weird
            if ($data !== false) {
                $_data->from_assembly($data);
                if ($_data->bits == array()) {
                    $data = false;
                }
                // Corrupt somehow
            }
        }
    } else {
        $data = false;
    }
    if ($data === false) {
        if (!isset($FILE_ARRAY)) {
            $_data = NULL;
            $prefix_default = get_file_base() . '/themes/';
            $prefix = $theme == 'default' ? $prefix_default : get_custom_file_base() . '/themes/';
            if (file_exists($prefix . $theme . '/' . $type . '_custom/' . $_codename . $suffix)) {
//.........这里部分代码省略.........
开发者ID:erico-deh,项目名称:ocPortal,代码行数:101,代码来源:tempcode__runtime.php

示例4: _helper_show_forum_topics


//.........这里部分代码省略.........
        if ($id_list == '') {
            return NULL;
        }
    }
    if ($hot) {
        $hot_topic_definition = intval(get_option('hot_topic_definition'));
        $topic_filter_sup = ' AND t_cache_num_posts/((t_cache_last_time-t_cache_first_time)/60/60/24+1)>' . strval($hot_topic_definition);
    } else {
        $topic_filter_sup = '';
    }
    global $SITE_INFO;
    if (!(isset($SITE_INFO['mysql_old']) && $SITE_INFO['mysql_old'] == '1' || !isset($SITE_INFO['mysql_old']) && is_file(get_file_base() . '/mysql_old'))) {
        if ($filter_topic_title == '' && $filter_topic_description == '') {
            $query = 'SELECT * FROM ' . $this_ref->connection->get_table_prefix() . 'f_topics top WHERE (' . $id_list . ')' . $topic_filter_sup;
        } else {
            $query = '';
            $topic_filters = array();
            if ($filter_topic_title != '') {
                $topic_filters[] = 't_cache_first_title LIKE \'' . db_encode_like($filter_topic_title) . '\'';
            }
            if ($filter_topic_description != '') {
                $topic_filters[] = 't_description LIKE \'' . db_encode_like($filter_topic_description) . '\'';
            }
            foreach ($topic_filters as $topic_filter) {
                if ($query != '') {
                    $query .= ' UNION ';
                }
                $query .= 'SELECT * FROM ' . $this_ref->connection->get_table_prefix() . 'f_topics top WHERE (' . $id_list . ') AND ' . $topic_filter . $topic_filter_sup;
            }
        }
    } else {
        $topic_filter = '';
        if ($filter_topic_title != '') {
            $topic_filter .= 't_cache_first_title LIKE \'' . db_encode_like($filter_topic_title) . '\'';
        }
        if ($filter_topic_description != '') {
            $topic_filter .= ' OR t_description LIKE \'' . db_encode_like($filter_topic_description) . '\'';
        }
        if ($topic_filter != '') {
            $topic_filter = ' AND (' . $topic_filter . ')';
        }
        $query = 'SELECT * FROM ' . $this_ref->connection->get_table_prefix() . 'f_topics top WHERE (' . $id_list . ') ' . $topic_filter . $topic_filter_sup;
    }
    $post_query_select = 'p.p_title,t.text_parsed,t.id,p.p_poster,p.p_poster_name_if_guest';
    $post_query_where = 'p_validated=1 AND p_topic_id=top.id ' . not_like_spacer_posts('t.text_original');
    $post_query_sql = 'SELECT ' . $post_query_select . ' FROM ' . $this_ref->connection->get_table_prefix() . 'f_posts p ';
    if (strpos(get_db_type(), 'mysql') !== false) {
        $post_query_sql .= 'USE INDEX(in_topic) ';
    }
    $post_query_sql .= 'LEFT JOIN ' . $this_ref->connection->get_table_prefix() . 'translate t ON t.id=p.p_post WHERE ' . $post_query_where . ' ORDER BY p_time,p.id';
    if (strpos(get_db_type(), 'mysql') !== false) {
        // So topics with no validated posts, or only spacer posts, are not drawn out only to then be filtered layer (meaning we don't get enough result)
        $query .= ' AND EXISTS(' . $post_query_sql . ')';
    }
    $max_rows = $this_ref->connection->query_value_null_ok_full(preg_replace('#(^| UNION )SELECT \\* #', '${1}SELECT COUNT(*) ', $query), false, true);
    if ($limit == 0) {
        return array();
    }
    $rows = $this_ref->connection->query($query . ' ORDER BY ' . ($date_key == 'lasttime' ? 't_cache_last_time' : 't_cache_first_time') . ' DESC', $limit, $start, false, true);
    $out = array();
    foreach ($rows as $i => $r) {
        $out[$i] = array();
        $out[$i]['id'] = $r['id'];
        $out[$i]['num'] = $r['t_cache_num_posts'];
        $out[$i]['title'] = $r['t_cache_first_title'];
        $out[$i]['description'] = $r['t_description'];
        $out[$i]['firstusername'] = $r['t_cache_first_username'];
        $out[$i]['lastusername'] = $r['t_cache_last_username'];
        $out[$i]['firstmemberid'] = $r['t_cache_first_member_id'];
        $out[$i]['lastmemberid'] = $r['t_cache_last_member_id'];
        $out[$i]['firsttime'] = $r['t_cache_first_time'];
        $out[$i]['lasttime'] = $r['t_cache_last_time'];
        $out[$i]['closed'] = 1 - $r['t_is_open'];
        $out[$i]['forum_id'] = $r['t_forum_id'];
        $post_query_sql = str_replace('top.id', strval($out[$i]['id']), $post_query_sql);
        $fp_rows = $this_ref->connection->query($post_query_sql, 1);
        if (!array_key_exists(0, $fp_rows)) {
            unset($out[$i]);
            continue;
        }
        $out[$i]['firstusername'] = $fp_rows[0]['p_poster_name_if_guest'];
        $out[$i]['firstmemberid'] = $fp_rows[0]['p_poster'];
        $out[$i]['firsttitle'] = $fp_rows[0]['p_title'];
        if ($show_first_posts) {
            $message = new ocp_tempcode();
            if (get_page_name() != 'search' && !is_null($fp_rows[0]['text_parsed']) && $fp_rows[0]['text_parsed'] != '' && $fp_rows[0]['id'] != 0) {
                if (!$message->from_assembly($fp_rows[0]['text_parsed'], true)) {
                    $message = get_translated_tempcode($fp_rows[0]['id'], $GLOBALS['FORUM_DB']);
                }
            } else {
                $message = get_translated_tempcode($fp_rows[0]['id'], $GLOBALS['FORUM_DB']);
            }
            $out[$i]['firstpost'] = $message;
        }
    }
    if (count($out) != 0) {
        return $out;
    }
    return NULL;
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:101,代码来源:ocf_forum_driver_helper.php

示例5: ocf_wrapper

/**
 * Do the wrapper that fits around OCF module output.
 *
 * @param  tempcode		The title for the module output that we are wrapping.
 * @param  tempcode		The module output that we are wrapping.
 * @param  boolean		Whether to include the personal bar in the wrap.
 * @param  boolean		Whether to include statistics in the wrap.
 * @param  ?AUTO_LINK	The forum to make the search link search under (NULL: Users own PT forum/unknown).
 * @return tempcode		The wrapped output.
 */
function ocf_wrapper($title, $content, $show_personal_bar = true, $show_stats = true, $forum_id = NULL)
{
    global $ZONE;
    $wide = is_wide();
    if ($wide == 0 && get_value('force_forum_bar') !== '1') {
        $show_personal_bar = false;
        $show_stats = false;
    }
    // Notifications
    if (!is_guest() && (get_page_name() == 'forumview' || get_page_name() == 'topicview' || get_page_name() == 'vforums')) {
        $cache_identifier = serialize(array(get_member()));
        $_notifications = NULL;
        if ((get_option('is_on_block_cache') == '1' || get_param_integer('keep_cache', 0) == 1 || get_param_integer('cache', 0) == 1) && (get_param_integer('keep_cache', NULL) !== 0 && get_param_integer('cache', NULL) !== 0)) {
            $_notifications = get_cache_entry('_new_pp', $cache_identifier, 10000);
        }
        if (is_null($_notifications)) {
            require_code('ocf_notifications');
            list($notifications, $num_unread_pps) = generate_notifications($cache_identifier);
        } else {
            list($__notifications, $num_unread_pps) = $_notifications;
            $notifications = new ocp_tempcode();
            if (!$notifications->from_assembly($__notifications, true)) {
                require_code('ocf_notifications');
                list($notifications, $num_unread_pps) = generate_notifications($cache_identifier);
            }
            if (!$notifications->is_empty()) {
                require_javascript('javascript_ajax');
            }
        }
    } else {
        $notifications = new ocp_tempcode();
        $num_unread_pps = 0;
    }
    if ($show_personal_bar) {
        if (get_member() != $GLOBALS['OCF_DRIVER']->get_guest_id()) {
            $member_info = ocf_read_in_member_profile(get_member(), true);
            $profile_url = $GLOBALS['OCF_DRIVER']->member_profile_url(get_member(), true, true);
            $_new_topics = $GLOBALS['FORUM_DB']->query('SELECT COUNT(*) AS mycnt FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics WHERE NOT t_forum_id IS NULL AND t_cache_first_time>' . strval((int) $member_info['last_visit_time']));
            $new_topics = $_new_topics[0]['mycnt'];
            $_new_posts = $GLOBALS['FORUM_DB']->query('SELECT COUNT(*) AS mycnt FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE NOT p_cache_forum_id IS NULL AND p_time>' . strval((int) $member_info['last_visit_time']));
            $new_posts = $_new_posts[0]['mycnt'];
            $max_avatar_height = ocf_get_member_best_group_property(get_member(), 'max_avatar_height');
            // Any unread PT-PPs?
            $pt_extra = $num_unread_pps == 0 ? new ocp_tempcode() : do_lang_tempcode('NUM_UNREAD', integer_format($num_unread_pps));
            $personal_topic_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => get_member()), get_module_zone('members'), NULL, true, false, false, 'tab__pts');
            $head = do_template('OCF_MEMBER_BAR', array('_GUID' => 's3kdsadf0p3wsjlcfksdj', 'AVATAR' => array_key_exists('avatar', $member_info) ? $member_info['avatar'] : '', 'PROFILE_URL' => $profile_url, 'USERNAME' => $member_info['username'], 'LOGOUT_URL' => build_url(array('page' => 'login', 'type' => 'logout'), get_module_zone('login')), 'NUM_POINTS_ADVANCE' => array_key_exists('num_points_advance', $member_info) ? make_string_tempcode(integer_format($member_info['num_points_advance'])) : do_lang('NA'), 'NUM_POINTS' => array_key_exists('points', $member_info) ? integer_format($member_info['points']) : '', 'NUM_POSTS' => integer_format($member_info['posts']), 'PRIMARY_GROUP' => $member_info['primary_group_name'], 'LAST_VISIT_DATE_RAW' => strval($member_info['last_visit_time']), 'LAST_VISIT_DATE' => $member_info['last_visit_time_string'], 'PERSONAL_TOPIC_URL' => $personal_topic_url, 'NEW_POSTS_URL' => build_url(array('page' => 'vforums', 'type' => 'misc'), get_module_zone('vforums')), 'UNREAD_TOPICS_URL' => build_url(array('page' => 'vforums', 'type' => 'unread'), get_module_zone('vforums')), 'RECENTLY_READ_URL' => build_url(array('page' => 'vforums', 'type' => 'recently_read'), get_module_zone('vforums')), 'INLINE_PERSONAL_POSTS_URL' => build_url(array('page' => 'topicview'), get_module_zone('topicview')), 'PT_EXTRA' => $pt_extra, 'NEW_TOPICS' => integer_format($new_topics), 'NEW_POSTS' => integer_format($new_posts), 'MAX_AVATAR_HEIGHT' => strval($max_avatar_height)));
        } else {
            if (count($_POST) > 0) {
                $_this_url = build_url(array('page' => 'forumview'), 'forum', array('keep_session' => 1));
            } else {
                $_this_url = build_url(array('page' => '_SELF'), '_SELF', array('keep_session' => 1), true);
            }
            $this_url = $_this_url->evaluate();
            $login_url = build_url(array('page' => 'login', 'type' => 'login', 'redirect' => $this_url), get_module_zone('login'));
            $full_link = build_url(array('page' => 'login', 'type' => 'misc', 'redirect' => $this_url), get_module_zone('login'));
            $join_url = build_url(array('page' => 'join', 'redirect' => $this_url), get_module_zone('join'));
            $head = do_template('OCF_GUEST_BAR', array('NAVIGATION' => '', 'LOGIN_URL' => $login_url, 'JOIN_LINK' => $join_url, 'FULL_LINK' => $full_link));
        }
    } else {
        $head = new ocp_tempcode();
    }
    if ($show_stats) {
        $stats = ocf_get_forums_stats();
        // Users online
        $users_online = new ocp_tempcode();
        $count = 0;
        $members = get_online_members(false, NULL, $count);
        $groups_seen = array();
        if (!is_null($members)) {
            //$members=collapse_2d_complexity('the_user','cache_username',$members);
            $guests = 0;
            foreach ($members as $bits) {
                $member = $bits['the_user'];
                $username = $bits['cache_username'];
                if ($member == $GLOBALS['OCF_DRIVER']->get_guest_id()) {
                    $guests++;
                    continue;
                }
                if (is_null($username)) {
                    continue;
                }
                $url = $GLOBALS['OCF_DRIVER']->member_profile_url($member, false, true);
                if (!array_key_exists('m_primary_group', $bits)) {
                    $bits['m_primary_group'] = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member, 'm_primary_group');
                }
                $pgid = $bits['m_primary_group'];
                //$GLOBALS['FORUM_DRIVER']->get_member_row_field($member,'m_primary_group');
                if (is_null($pgid)) {
                    continue;
                }
//.........这里部分代码省略.........
开发者ID:erico-deh,项目名称:ocPortal,代码行数:101,代码来源:ocf_general.php

示例6: get_cache_entry

/**
 * Find the cached result of what is named by codename and the further constraints.
 *
 * @param  ID_TEXT		The codename to check for cacheing
 * @param  LONG_TEXT		The further restraints (a serialized map)
 * @param  integer		The TTL for the cache entry
 * @param  boolean		Whether we are cacheing Tempcode (needs special care)
 * @param  boolean		Whether to defer caching to CRON. Note that this option only works if the block's defined cache signature depends only on $map (timezone, bot-type, in-panel and interlock are automatically considered)
 * @param  ?array			Parameters to call up block with if we have to defer caching (NULL: none)
 * @return ?mixed			The cached result (NULL: no cached result)
 */
function get_cache_entry($codename, $cache_identifier, $ttl = 10000, $tempcode = false, $caching_via_cron = false, $map = NULL)
{
    if ($GLOBALS['MEM_CACHE'] !== NULL) {
        $pcache = persistant_cache_get(array('CACHE', $codename));
        if ($pcache === NULL) {
            return NULL;
        }
        $theme = $GLOBALS['FORUM_DRIVER']->get_theme();
        $lang = user_lang();
        $pcache = isset($pcache[$cache_identifier][$lang][$theme]) ? $pcache[$cache_identifier][$lang][$theme] : NULL;
        if ($pcache === NULL) {
            if ($caching_via_cron) {
                request_via_cron($codename, $map, $tempcode);
                return paragraph(do_lang_tempcode('CACHE_NOT_READY_YET'), '', 'nothing_here');
            }
            return NULL;
        }
        $cache_rows = array($pcache);
    } else {
        $cache_rows = $GLOBALS['SITE_DB']->query_select('cache', array('*'), array('lang' => user_lang(), 'cached_for' => $codename, 'the_theme' => $GLOBALS['FORUM_DRIVER']->get_theme(), 'identifier' => md5($cache_identifier)), '', 1);
        if (!isset($cache_rows[0])) {
            if ($caching_via_cron) {
                request_via_cron($codename, $map, $tempcode);
                return paragraph(do_lang_tempcode('CACHE_NOT_READY_YET'), '', 'nothing_here');
            }
            return NULL;
        }
        if ($tempcode) {
            $ob = new ocp_tempcode();
            if (!$ob->from_assembly($cache_rows[0]['the_value'], true)) {
                return NULL;
            }
            $cache_rows[0]['the_value'] = $ob;
        } else {
            $cache_rows[0]['the_value'] = unserialize($cache_rows[0]['the_value']);
        }
    }
    $stale = $ttl != -1 && time() > $cache_rows[0]['date_and_time'] + $ttl * 60;
    if (!$caching_via_cron && $stale) {
        return NULL;
    } else {
        if ($stale) {
            request_via_cron($codename, $map, $tempcode);
        }
        $cache = $cache_rows[0]['the_value'];
        if ($cache_rows[0]['langs_required'] != '') {
            $bits = explode('!', $cache_rows[0]['langs_required']);
            $langs_required = explode(':', $bits[0]);
            // Sometimes lang has got intertwinded with non cacheable stuff (and thus was itself not cached), so we need the lang files
            foreach ($langs_required as $lang) {
                if ($lang != '') {
                    require_lang($lang, NULL, NULL, true);
                }
            }
            if (isset($bits[1])) {
                $javascripts_required = explode(':', $bits[1]);
                foreach ($javascripts_required as $javascript) {
                    if ($javascript != '') {
                        require_javascript($javascript);
                    }
                }
            }
            if (isset($bits[2])) {
                $csss_required = explode(':', $bits[2]);
                foreach ($csss_required as $css) {
                    if ($css != '') {
                        require_css($css);
                    }
                }
            }
        }
        return $cache;
    }
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:85,代码来源:caches.php

示例7: get_translated_tempcode

/**
 * This function is an offshoot of get_translated_text, it instead returns parsed comcode that is linked to the specified language id.
 *
 * @param  integer			The id
 * @param  ?object			The database connection to use (NULL: standard site connection)
 * @param  ?LANGUAGE_NAME	The language (NULL: uses the current language)
 * @param  boolean			Whether to force it to the specified language
 * @param  boolean			Whether to force as_admin, even if the lang string isn't stored against an admin (designed for comcode page cacheing)
 * @param  boolean			Whether to remove from the Tempcode cache when we're done, for performance reasons (normally don't bother with this, but some code knows it won't be needed again -- esp Comcode cache layer -- and saves RAM by removing it)
 * @return ?tempcode			The parsed comcode (NULL: the text couldn't be looked up)
 */
function get_translated_tempcode($entry, $connection = NULL, $lang = NULL, $force = false, $as_admin = false, $clear_away_from_cache = false)
{
    if ($entry == 0) {
        return paragraph(do_lang_tempcode('FAILED_ENTRY'), 'rtgtedgrgd');
    }
    if ($connection === NULL) {
        $connection = $GLOBALS['SITE_DB'];
    }
    global $RECORD_LANG_STRINGS_CONTENT;
    if ($RECORD_LANG_STRINGS_CONTENT) {
        global $RECORDED_LANG_STRINGS_CONTENT;
        $RECORDED_LANG_STRINGS_CONTENT[$entry] = $connection->connection_write != $GLOBALS['SITE_DB']->connection_write;
    }
    if ($lang === NULL) {
        $lang = user_lang();
    }
    if ($lang == 'xxx') {
        return make_string_tempcode('!!!');
    }
    // Helpful for testing language compliancy. We don't expect to see non x's/!'s if we're running this language
    if (isset($connection->text_lookup_cache[$entry]) && $lang == user_lang()) {
        $ret = $connection->text_lookup_cache[$entry];
        if ($ret !== '') {
            if (is_string($ret)) {
                $connection->text_lookup_cache[$entry] = new ocp_tempcode();
                $connection->text_lookup_cache[$entry]->from_assembly($ret);
                $ret = $connection->text_lookup_cache[$entry];
            }
            if ($clear_away_from_cache) {
                unset($connection->text_lookup_cache[$entry]);
                unset($connection->text_lookup_original_cache[$entry]);
            }
            return $ret;
        }
    }
    global $SEARCH__CONTENT_BITS;
    if ($SEARCH__CONTENT_BITS !== NULL) {
        $_result = $connection->query_select('translate', array('text_original', 'source_user'), array('id' => $entry, 'language' => $lang), '', 1);
        if (array_key_exists(0, $_result)) {
            global $LAX_COMCODE;
            $temp = $LAX_COMCODE;
            $LAX_COMCODE = true;
            $result = $_result[0];
            $ret = comcode_to_tempcode($result['text_original'], $result['source_user'], $as_admin, 60, NULL, $connection, false, false, false, false, false, $SEARCH__CONTENT_BITS);
            $LAX_COMCODE = $temp;
            return $ret;
        }
    }
    $_result = $connection->query_select('translate', array('text_parsed', 'text_original'), array('id' => $entry, 'language' => $lang), '', 1);
    $result = isset($_result[0]) ? $_result[0]['text_parsed'] : NULL;
    if (isset($_result[0])) {
        if ($lang == user_lang()) {
            $connection->text_lookup_original_cache[$entry] = $_result[0]['text_original'];
        }
    }
    if ($result === NULL || $result == '' || is_browser_decacheing()) {
        require_code('lang3');
        return parse_translated_text($entry, $connection, $lang, $force, $as_admin);
    }
    $parsed = new ocp_tempcode();
    if (!$parsed->from_assembly($result, true)) {
        require_code('lang3');
        return parse_translated_text($entry, $connection, $lang, $force, $as_admin);
    }
    if ($lang == user_lang()) {
        $connection->text_lookup_cache[$entry] = $parsed;
    }
    return $parsed;
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:80,代码来源:lang.php

示例8: _comcode_lang_string

/**
 * Convert a language string that is Comcode to tempcode, with potential cacheing in the db.
 *
 * @param  ID_TEXT		The language string ID
 * @return tempcode		The parsed Comcode
 */
function _comcode_lang_string($lang_code)
{
    global $COMCODE_LANG_STRING_CACHE;
    if (array_key_exists($lang_code, $COMCODE_LANG_STRING_CACHE)) {
        return $COMCODE_LANG_STRING_CACHE[$lang_code];
    }
    $comcode_page = $GLOBALS['SITE_DB']->query_select('cached_comcode_pages p LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'translate t ON t.id=string_index AND ' . db_string_equal_to('t.language', user_lang()), array('string_index', 'text_parsed'), array('the_page' => $lang_code, 'the_zone' => '!'), '', 1);
    if (array_key_exists(0, $comcode_page) && !is_browser_decacheing()) {
        if (!is_null($comcode_page[0]['text_parsed']) && $comcode_page[0]['text_parsed'] != '') {
            $parsed = new ocp_tempcode();
            if (!$parsed->from_assembly($comcode_page[0]['text_parsed'], true)) {
                $ret = get_translated_tempcode($comcode_page[0]['string_index']);
                unset($GLOBALS['RECORDED_LANG_STRINGS_CONTENT'][$comcode_page[0]['string_index']]);
            }
        } else {
            $ret = get_translated_tempcode($comcode_page[0]['string_index'], NULL, NULL, true);
            if (is_null($ret)) {
                $looked_up = do_lang($lang_code, NULL, NULL, NULL, NULL, false);
                $GLOBALS['SITE_DB']->query_insert('translate', array('id' => $comcode_page[0]['string_index'], 'source_user' => get_member(), 'broken' => 0, 'importance_level' => 1, 'text_original' => $looked_up, 'text_parsed' => '', 'language' => user_lang()), true, false, true);
                $ret = get_translated_tempcode($comcode_page[0]['string_index']);
            }
            unset($GLOBALS['RECORDED_LANG_STRINGS_CONTENT'][$comcode_page[0]['string_index']]);
            return $ret;
        }
        $COMCODE_LANG_STRING_CACHE[$lang_code] = $parsed;
        return $parsed;
    } elseif (array_key_exists(0, $comcode_page)) {
        $GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_page' => $lang_code, 'the_zone' => '!'));
        delete_lang($comcode_page[0]['string_index']);
    }
    $nql_backup = $GLOBALS['NO_QUERY_LIMIT'];
    $GLOBALS['NO_QUERY_LIMIT'] = true;
    $looked_up = do_lang($lang_code, NULL, NULL, NULL, NULL, false);
    if (is_null($looked_up)) {
        return make_string_tempcode(escape_html('{!' . $lang_code . '}'));
    }
    $index = insert_lang_comcode($looked_up, 4, NULL, true, NULL, 60, false, true);
    $GLOBALS['SITE_DB']->query_insert('cached_comcode_pages', array('the_zone' => '!', 'the_page' => $lang_code, 'string_index' => $index, 'the_theme' => $GLOBALS['FORUM_DRIVER']->get_theme(), 'cc_page_title' => NULL), false, true);
    // Race conditions
    $parsed = get_translated_tempcode($index);
    $COMCODE_LANG_STRING_CACHE[$lang_code] = $parsed;
    $GLOBALS['NO_QUERY_LIMIT'] = $nql_backup;
    return $parsed;
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:50,代码来源:lang3.php


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