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


PHP ocp_tempcode::evaluate方法代码示例

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


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

示例1: testNoMissingParams

 function testNoMissingParams()
 {
     global $ATTACHED_MESSAGES, $ATTACHED_MESSAGES_RAW;
     $lists = find_all_previews__by_screen();
     foreach ($lists as $function => $tpls) {
         $template = $tpls[0];
         $hook = NULL;
         if (is_file(get_file_base() . '/_tests/screens_tested/nonemissing__' . $function)) {
             continue;
         }
         // To make easier to debug through
         if (function_exists('set_time_limit')) {
             @set_time_limit(0);
         }
         $ATTACHED_MESSAGES = new ocp_tempcode();
         $ATTACHED_MESSAGES_RAW = array();
         $out1 = render_screen_preview($template, $hook, $function);
         $put_out = !$ATTACHED_MESSAGES->is_empty() || count($ATTACHED_MESSAGES_RAW) > 0;
         $this->assertFalse($put_out, 'Messages put out by ' . $function . '  (' . strip_tags($ATTACHED_MESSAGES->evaluate()) . ')');
         if (!$put_out) {
             fclose(fopen(get_file_base() . '/_tests/screens_tested/nonemissing__' . $function, 'wb'));
             sync_file(get_file_base() . '/_tests/screens_tested/nonemissing__' . $function);
             fix_permissions(get_file_base() . '/_tests/screens_tested/nonemissing__' . $function);
         }
         unset($out1);
     }
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:27,代码来源:template_previews.php

示例2: foreach

 /**
  * Get a preview(s) of a (group of) template(s), as a full standalone piece of HTML in Tempcode format.
  * Uses sources/lorem.php functions to place appropriate stock-text. Should not hard-code things, as the code is intended to be declaritive.
  * Assumptions: You can assume all Lang/CSS/Javascript files in this addon have been pre-required.
  *
  * @return array			Array of previews, each is Tempcode. Normally we have just one preview, but occasionally it is good to test templates are flexible (e.g. if they use IF_EMPTY, we can test with and without blank data).
  */
 function tpl_preview__administrative__form_screen_input_permission()
 {
     require_lang('permissions');
     $permission_rows = new ocp_tempcode();
     foreach (placeholder_array() as $k => $v) {
         $overrides = new ocp_tempcode();
         $all_global = true;
         foreach (placeholder_array() as $k => $v) {
             $overrides->attach(do_lorem_template('FORM_SCREEN_INPUT_PERMISSION_OVERRIDE', array('FORCE_PRESETS' => false, 'GROUP_NAME' => lorem_phrase(), 'VIEW_ACCESS' => '', 'TABINDEX' => placeholder_number(), 'GROUP_ID' => placeholder_random_id(), 'SP' => strval($k), 'ALL_GLOBAL' => true, 'TITLE' => lorem_phrase(), 'DEFAULT_ACCESS' => '', 'CODE' => '-1')));
         }
         $permission_rows->attach(do_lorem_template('FORM_SCREEN_INPUT_PERMISSION', array('FORCE_PRESETS' => false, 'GROUP_NAME' => lorem_phrase(), 'OVERRIDES' => $overrides->evaluate(), 'ALL_GLOBAL' => true, 'VIEW_ACCESS' => '', 'TABINDEX' => placeholder_number(), 'GROUP_ID' => placeholder_random_id(), 'PINTERFACE_VIEW' => '')));
     }
     $permission_rows->attach(do_lorem_template('FORM_SCREEN_INPUT_PERMISSION_MATRIX_OUTER', array('INNER' => lorem_word())));
     $permission_rows->attach(do_lorem_template('FORM_SCREEN_INPUT_PERMISSION_ADMIN', array('PINTERFACE_VIEW' => lorem_word(), 'GROUP_ID' => placeholder_random_id(), 'GROUP_NAME' => lorem_phrase(), 'FORCE_PRESETS' => false, 'OVERRIDES' => placeholder_array())));
     $field = do_lorem_template('FORM_SCREEN_INPUT_PERMISSION_MATRIX', array('TITLE' => lorem_phrase(), 'SERVER_ID' => placeholder_id(), 'COLOR' => lorem_word(), 'OVERRIDES' => placeholder_array(), 'PERMISSION_ROWS' => $permission_rows));
     return array(lorem_globalise(do_lorem_template('FORM_GROUPED', array('URL' => '#', 'FIELD_GROUPS' => $field, 'TEXT' => '', 'SUBMIT_NAME' => lorem_word_2())), NULL, '', true));
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:24,代码来源:core_form_interfaces.php

示例3: mixed

 /**
  * The UI to send a newsletter.
  *
  * @param  LONG_TEXT		Default newsletter to put in
  * @return tempcode		The UI
  */
 function send_gui($_existing = '')
 {
     // If this is a periodic newsletter, we make some changes to the regular
     // language strings.
     $periodic_action_raw = post_param('periodic_choice', '');
     $periodic_subject = '';
     $defaults = mixed();
     switch (preg_replace('#\\_\\d+$#', '', $periodic_action_raw)) {
         case 'remove_existing':
             // Remove whatever is already set. We don't need any changes for
             // this, but we do need a hidden form field.
             $periodic_action = 'remove';
             break;
         case 'replace_existing':
             // Make the current newsletter periodic. This requires language
             // fiddling.
             $periodic_action = 'replace';
             $periodic_subject = do_lang('PERIODIC_SUBJECT_HELP');
             $periodic_id = intval(preg_replace('#^[^\\d]+#', '', $periodic_action_raw));
             $_defaults = $GLOBALS['SITE_DB']->query_select('newsletter_periodic', array('*'), array('id' => $periodic_id), '', 1);
             if (!array_key_exists(0, $_defaults)) {
                 warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
             }
             $defaults = $_defaults[0];
             break;
         case 'make_periodic':
             // Make the current newsletter periodic. This requires language
             // fiddling.
             $periodic_action = 'make';
             $periodic_subject = do_lang('PERIODIC_SUBJECT_HELP');
             break;
         case 'no_change':
         default:
             // The default action is to leave the current settings as-is.
             $periodic_action = 'none';
             break;
     }
     $title = get_page_title('NEWSLETTER_SEND');
     $lang = choose_language($title);
     if (is_object($lang)) {
         return $lang;
     }
     $comcode_given = $_existing != '' && strpos($_existing, '<html') !== false;
     $_existing = post_param('message', $_existing);
     if ($_existing == '') {
         $from_news = get_param_integer('from_news', -1);
         if ($from_news != -1 && addon_installed('news')) {
             $rows = $GLOBALS['SITE_DB']->query_select('news', array('*'), array('id' => $from_news), 'ORDER BY id DESC', 1);
             if (!array_key_exists(0, $rows)) {
                 require_lang('news');
                 return warn_screen(get_page_title('NEWS'), do_lang_tempcode('MISSING_RESOURCE'));
             }
             $myrow = $rows[0];
             $_existing = get_translated_text($myrow['news_article'], NULL, $lang);
             if ($_existing == '') {
                 $_existing = get_translated_text($myrow['news'], NULL, $lang);
             }
         }
         $existing = do_template('NEWSLETTER_DEFAULT', array('_GUID' => '53c02947915806e519fe14c318813f42', 'CONTENT' => $_existing, 'LANG' => $lang));
     } else {
         $default = do_template('NEWSLETTER_DEFAULT', array('_GUID' => '53c02947915806e519fe14c318813f44', 'CONTENT' => $_existing, 'LANG' => $lang));
         if (strpos($default->evaluate(), '<html') !== false) {
             if ($comcode_given) {
                 $default = do_template('NEWSLETTER_DEFAULT', array('_GUID' => '53c02947915806e519fe14c318813f46', 'CONTENT' => comcode_to_tempcode($_existing), 'LANG' => $lang));
             }
             $existing = $default;
         } else {
             $existing = make_string_tempcode($_existing);
         }
     }
     $post_url = build_url(array('page' => '_SELF', 'type' => 'confirm', 'old_type' => get_param('type', '')), '_SELF');
     $submit_name = do_lang_tempcode('PREVIEW');
     $hidden = new ocp_tempcode();
     $hidden->attach(form_input_hidden('lang', $lang));
     // Build up form
     $fields = new ocp_tempcode();
     require_code('form_templates');
     $default_subject = get_option('newsletter_title');
     if (!is_null($defaults)) {
         $default_subject = $defaults['np_subject'];
     }
     if ($periodic_action != 'make' && $periodic_action != 'replace') {
         $default_subject .= ' - ' . get_timezoned_date(time(), false, false, false, true);
     }
     $default_subject = post_param('subject', $default_subject);
     $fields->attach(form_input_line_comcode(do_lang_tempcode('SUBJECT'), do_lang_tempcode('NEWSLETTER_DESCRIPTION_TITLE', $periodic_subject), 'subject', $default_subject, true));
     $in_full = post_param_integer('in_full', 0);
     $chosen_categories = post_param('chosen_categories', '');
     if ($periodic_action == 'make' || $periodic_action == 'replace') {
         // We are making a periodic newsletter. This means we need to pass
         // through the chosen categories
         if (!is_null($defaults)) {
             $chosen_categories = $defaults['np_message'];
             $in_full = $defaults['np_in_full'];
//.........这里部分代码省略.........
开发者ID:erico-deh,项目名称:ocPortal,代码行数:101,代码来源:admin_newsletter.php

示例4: array

 /**
  * Standard modular UI to edit an entry.
  *
  * @return tempcode	The UI
  */
 function _ed()
 {
     $doing = 'EDIT_' . $this->lang_type;
     if ($this->catalogue && get_param('catalogue_name', '') != '') {
         $catalogue_title = get_translated_text($GLOBALS['SITE_DB']->query_value('catalogues', 'c_title', array('c_name' => get_param('catalogue_name'))));
         if ($this->type_code == 'd') {
             $doing = do_lang('CATALOGUE_GENERIC_EDIT', escape_html($catalogue_title));
         } elseif ($this->type_code == 'c') {
             $doing = do_lang('CATALOGUE_GENERIC_EDIT_CATEGORY', escape_html($catalogue_title));
         }
     }
     $title = get_page_title($doing);
     //$submit_name=(strpos($doing,' ')!==false)?protect_from_escaping($doing):do_lang($doing);
     //if (!is_null($this->edit_submit_name)) $submit_name=$this->edit_submit_name;
     $submit_name = do_lang_tempcode('SAVE');
     //$test=$this->choose_catalogue($title);
     //if (!is_null($test)) return $test;
     $id = mixed();
     // Define type as mixed
     $id = $this->non_integer_id ? get_param('id', false, true) : strval(get_param_integer('id'));
     $map = array('page' => '_SELF', 'type' => '__e' . $this->type_code, 'id' => $id);
     if (get_param('catalogue_name', '') != '') {
         $map['catalogue_name'] = get_param('catalogue_name');
     }
     if (!is_null(get_param('redirect', NULL))) {
         $map['redirect'] = get_param('redirect');
     }
     if (!is_null(get_param('continue', NULL))) {
         $map['continue'] = get_param('continue');
     }
     if (!is_null($this->upload) || $this->possibly_some_kind_of_upload) {
         $map['uploading'] = 1;
     }
     $post_url = build_url($map, '_SELF');
     if (multi_lang() && has_actual_page_access(get_member(), 'admin_lang') && user_lang() != get_site_default_lang()) {
         require_code('lang2');
         $switch_url = get_self_url(false, false, array('keep_lang' => get_site_default_lang()));
         attach_message(do_lang_tempcode('lang:EDITING_CONTENT_IN_LANGUAGE_STAFF', escape_html(lookup_language_full_name(user_lang())), escape_html(lookup_language_full_name(get_site_default_lang())), escape_html($switch_url->evaluate())), 'warn');
     }
     if (method_exists($this, 'get_submitter')) {
         list($submitter, $date_and_time) = $this->get_submitter($id);
     } else {
         $submitter = NULL;
         $date_and_time = NULL;
     }
     if (!is_null($this->permissions_require)) {
         check_edit_permission($this->permissions_require, $submitter, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? NULL : $this->get_cat($id), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? NULL : $this->get_cat_b($id)), $this->permission_page_name);
     }
     if (!is_null($this->permissions_cat_require) && !has_category_access(get_member(), $this->permissions_cat_require, $this->get_cat($id))) {
         access_denied('CATEGORY_ACCESS');
     }
     if (!is_null($this->permissions_cat_require_b) && !has_category_access(get_member(), $this->permissions_cat_require_b, $this->get_cat_b($id))) {
         access_denied('CATEGORY_ACCESS');
     }
     $bits = $this->fill_in_edit_form($id);
     $delete_fields = new ocp_tempcode();
     $all_delete_fields_given = false;
     $fields2 = new ocp_tempcode();
     if (is_array($bits)) {
         $fields = $bits[0];
         $hidden = $bits[1];
         if (array_key_exists(2, $bits) && !is_null($bits[2])) {
             $delete_fields = $bits[2];
         }
         if (array_key_exists(3, $bits) && !is_null($bits[3])) {
             $this->edit_text = $bits[3];
         }
         if (array_key_exists(4, $bits) && $bits[4]) {
             $all_delete_fields_given = true;
         }
         if (array_key_exists(5, $bits) && !is_null($bits[5])) {
             $this->posting_form_text = $bits[5];
         }
         if (array_key_exists(6, $bits) && !is_null($bits[6])) {
             $fields2 = $bits[6];
         }
         if (array_key_exists(7, $bits)) {
             $this->posting_form_text_parsed = $bits[7];
         }
     } else {
         $fields = $bits;
         $hidden = new ocp_tempcode();
     }
     // Add in custom fields
     if ($this->has_tied_catalogue()) {
         require_code('fields');
         $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('MORE'))));
         append_form_custom_fields($this->award_type, $id, $fields, $hidden);
     }
     // SEO?
     if (!is_null($this->seo_type)) {
         require_code('seo2');
         $fields2->attach(seo_get_fields($this->seo_type, $id));
     }
     // Awards?
//.........这里部分代码省略.........
开发者ID:erico-deh,项目名称:ocPortal,代码行数:101,代码来源:aed_module.php

示例5: get_permissions_matrix

/**
 * Create a form field input matrix for permission setting.
 *
 * @param  ID_TEXT		Permission ID (pagelink style) for the resource being set
 * @param  array			An inverted list showing what view permissions are set for what we're setting permissions for
 * @param  array			List of overridable privilege codes for what we're setting permissions for
 * @param  array			List of privilege settings relating to what we're setting permissions for, from the database
 * @param  array			Multi-dimensional array showing what the inherited defaults for this permission would be
 * @param  boolean		Whether to not include the stuff to make it fit alongside other form fields in a normal form table
 * @param  ?tempcode		Label for view permissions (NULL: default)
 * @return tempcode		The form field matrix
 */
function get_permissions_matrix($server_id, $access, $overridables, $specific_permissions, $default_access, $no_outer = false, $pinterface_view = NULL)
{
    require_lang('permissions');
    require_javascript('javascript_permissions');
    $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups();
    $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true, true);
    if (is_null($pinterface_view)) {
        $pinterface_view = do_lang_tempcode('PINTERFACE_VIEW');
    }
    // Permission rows for matrix
    $permission_rows = new ocp_tempcode();
    $all_groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true);
    foreach (array_keys($access) as $id) {
        if (!array_key_exists($id, $groups) && array_key_exists($id, $all_groups)) {
            $groups[$id] = $all_groups[$id];
        }
    }
    foreach ($groups as $id => $group_name) {
        if (!in_array($id, $admin_groups)) {
            $perhaps = count($access) == 0 ? 1 : $access[$id];
            $view_access = $perhaps == 1;
            $tabindex = get_form_field_tabindex(NULL);
            $overrides = new ocp_tempcode();
            $all_global = true;
            foreach (array_keys($overridables) as $override) {
                if (isset($specific_permissions[$override][$id])) {
                    $all_global = false;
                }
            }
            foreach ($overridables as $override => $cat_support) {
                $lang_string = do_lang_tempcode('PT_' . $override);
                if (is_array($cat_support)) {
                    $lang_string = do_lang_tempcode($cat_support[1]);
                }
                if (is_array($cat_support)) {
                    $cat_support = $cat_support[0];
                }
                if ($cat_support == 0) {
                    continue;
                }
                $overrides->attach(do_template('FORM_SCREEN_INPUT_PERMISSION_OVERRIDE', array('FORCE_PRESETS' => $no_outer, 'GROUP_NAME' => $group_name, 'VIEW_ACCESS' => $view_access, 'TABINDEX' => strval($tabindex), 'GROUP_ID' => strval($id), 'SP' => $override, 'ALL_GLOBAL' => $all_global, 'TITLE' => $lang_string, 'DEFAULT_ACCESS' => $default_access[$id][$override], 'CODE' => isset($specific_permissions[$override][$id]) ? $specific_permissions[$override][$id] : '-1')));
            }
            $permission_rows->attach(do_template('FORM_SCREEN_INPUT_PERMISSION', array('_GUID' => 'e2c4459ae995d33376c07e498f1d973a', 'FORCE_PRESETS' => $no_outer, 'GROUP_NAME' => $group_name, 'OVERRIDES' => $overrides->evaluate(), 'ALL_GLOBAL' => $all_global, 'VIEW_ACCESS' => $view_access, 'TABINDEX' => strval($tabindex), 'GROUP_ID' => strval($id), 'PINTERFACE_VIEW' => $pinterface_view)));
        } else {
            $overridables_filtered = array();
            foreach ($overridables as $override => $cat_support) {
                if (is_array($cat_support)) {
                    $cat_support = $cat_support[0];
                }
                if ($cat_support == 1) {
                    $overridables_filtered[$override] = 1;
                }
            }
            $permission_rows->attach(do_template('FORM_SCREEN_INPUT_PERMISSION_ADMIN', array('FORCE_PRESETS' => $no_outer, 'OVERRIDES' => $overridables_filtered, 'GROUP_NAME' => $group_name, 'GROUP_ID' => strval($id), 'PINTERFACE_VIEW' => $pinterface_view)));
        }
    }
    if (count($overridables) == 0 && !$no_outer) {
        return $permission_rows;
    }
    // Find out colour for our vertical text image headings (CSS can't rotate text), using the CSS as a basis
    $tmp_file = @file_get_contents(get_custom_file_base() . '/themes/' . $GLOBALS['FORUM_DRIVER']->get_theme() . '/templates_cached/' . user_lang() . '/global.css');
    $color = 'FF00FF';
    $matches = array();
    if ($tmp_file !== false) {
        if (preg_match('#\\nth.*\\sbackground-color:\\s*\\#([\\dA-Fa-f]*);.*\\}#sU', $tmp_file, $matches) != 0) {
            $color = $matches[1];
        }
    }
    // For heading up the table matrix
    $overrides_array = array();
    foreach ($overridables as $override => $cat_support) {
        $lang_string = do_lang_tempcode('PT_' . $override);
        if (is_array($cat_support)) {
            $lang_string = do_lang_tempcode($cat_support[1]);
        }
        if (is_array($cat_support)) {
            $cat_support = $cat_support[0];
        }
        if ($cat_support == 0) {
            continue;
        }
        $overrides_array[$override] = array('TITLE' => $lang_string);
    }
    // Finish off the matrix and return
    $inner = do_template('FORM_SCREEN_INPUT_PERMISSION_MATRIX', array('_GUID' => '0f019c7e60366fa04058097ee6f3829a', 'SERVER_ID' => $server_id, 'COLOR' => $color, 'OVERRIDES' => $overrides_array, 'PERMISSION_ROWS' => $permission_rows));
    if ($no_outer) {
        return make_string_tempcode(static_evaluate_tempcode($inner));
    }
//.........这里部分代码省略.........
开发者ID:erico-deh,项目名称:ocPortal,代码行数:101,代码来源:permissions2.php

示例6: run


//.........这里部分代码省略.........
                     } else {
                         $entrypoints = array('!');
                     }
                     if (!is_array($entrypoints)) {
                         $entrypoints = array('!');
                     }
                     if ($entrypoints == array('!')) {
                         $url = build_url(array('page' => $page), $zone, NULL, false, false, true);
                         $title = ucwords(str_replace('_', ' ', $page));
                         if (substr($page_type, 0, 7) == 'comcode') {
                             foreach ($comcode_page_rows as $page_row) {
                                 if ($page_row['p_validated'] == 0 && $page_row['the_page'] == $page && $page_row['the_zone'] == $zone) {
                                     continue 2;
                                 }
                             }
                             $path = zone_black_magic_filterer((strpos($page_type, '_custom') !== false ? get_custom_file_base() : get_file_base()) . '/' . filter_naughty($zone) . '/pages/' . filter_naughty($page_type) . '/' . $page . '.txt');
                             if (!is_file($path)) {
                                 $path = zone_black_magic_filterer(get_file_base() . '/' . filter_naughty($zone) . '/pages/' . filter_naughty($page_type) . '/' . $page . '.txt');
                             }
                             $page_contents = file_get_contents($path);
                             $matches = array();
                             if (preg_match('#\\[title[^\\]]*\\]#', $page_contents, $matches) != 0) {
                                 $start = strpos($page_contents, $matches[0]) + strlen($matches[0]);
                                 $end = strpos($page_contents, '[/title]', $start);
                                 $matches = array();
                                 $title_portion = str_replace('{$SITE_NAME}', get_site_name(), substr($page_contents, $start, $end - $start));
                                 if (preg_match('#\\{\\!([\\w:]+)\\}#', $title_portion, $matches) != 0) {
                                     $title_portion = str_replace($matches[0], do_lang($matches[1]), $title_portion);
                                 }
                                 if (preg_match('#^[^<>\\[\\{\\&]*$#', $title_portion, $matches) != 0) {
                                     $title = $matches[0];
                                 } elseif (!$low_memory) {
                                     $_title = comcode_to_tempcode($title_portion);
                                     $title = strip_tags(@html_entity_decode($_title->evaluate(), ENT_QUOTES, get_charset()));
                                 }
                             }
                         } elseif (substr($page_type, 0, 4) == 'html') {
                             $path = zone_black_magic_filterer((strpos($page_type, '_custom') !== false ? get_custom_file_base() : get_file_base()) . '/' . filter_naughty($zone) . '/pages/' . filter_naughty($page_type) . '/' . $page . '.htm');
                             $page_contents = file_get_contents($path);
                             $matches = array();
                             if (preg_match('#\\<title[^\\>]*\\>#', $page_contents, $matches) != 0) {
                                 $start = strpos($page_contents, $matches[0]) + strlen($matches[0]);
                                 $end = strpos($page_contents, '</title>', $start);
                                 $title = strip_tags(@html_entity_decode(substr($page_contents, $start, $end - $start), ENT_QUOTES, get_charset()));
                             }
                         }
                         $temp = do_template('BLOCK_MAIN_SITEMAP_NEST', array('_GUID' => '92e657f8b9a3642df053f54e724e66f6', 'URL' => $url, 'NAME' => $title, 'CHILDREN' => array()));
                         $_pages[$title] = $temp->evaluate();
                         // FUDGEFUDGE
                     } elseif (count($entrypoints) != 0) {
                         foreach ($entrypoints as $entrypoint => $title) {
                             if (($entrypoint == 'concede' || $entrypoint == 'invisible' || $entrypoint == 'logout') && is_guest()) {
                                 continue;
                             }
                             if ($entrypoint == '!') {
                                 $url = build_url(array('page' => $page), $zone, NULL, false, false, true);
                             } else {
                                 $url = build_url(array('page' => $page, 'type' => $entrypoint), $zone, NULL, false, false, true);
                             }
                             $_entrypoints[$title] = do_template('BLOCK_MAIN_SITEMAP_NEST', array('_GUID' => 'ae2ed2549644a8e699e0938b3ab98ddb', 'URL' => $url, 'NAME' => do_lang_tempcode($title), 'CHILDREN' => array()));
                         }
                         //ksort($_entrypoints);
                         $title = do_lang('MODULE_TRANS_NAME_' . $page, NULL, NULL, NULL, NULL, false);
                         if (is_null($title)) {
                             $title = ucwords(str_replace('_', ' ', preg_replace('#^ocf\\_#', '', preg_replace('#^' . str_replace('#', '\\#', preg_quote($zone)) . '_#', '', preg_replace('#^' . str_replace('#', '\\#', preg_quote(str_replace('zone', '', $zone))) . '_#', '', $page)))));
                         }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:67,代码来源:main_sitemap.php

示例7: array


//.........这里部分代码省略.........
                 $dist = $for_this - $should_be_this;
                 $wrongness += $dist * $dist;
                 if ($should_be_this == 1) {
                     if (!$correct_answer->is_empty()) {
                         $correct_answer->attach(do_lang_tempcode('LIST_SEP'));
                     }
                     $correct_answer->attach(escape_html(get_translated_text($a['q_answer_text'])));
                     $correct_explanation = $a['q_explanation'];
                 }
                 if ($for_this == 1) {
                     if (!$accum->is_empty()) {
                         $accum->attach(do_lang_tempcode('LIST_SEP'));
                     }
                     $accum->attach(escape_html(get_translated_text($a['q_answer_text'])));
                     $GLOBALS['SITE_DB']->query_insert('quiz_entry_answer', array('q_entry' => $entry_id, 'q_question' => $question['id'], 'q_answer' => strval($a['id'])));
                 }
             }
             $wrongness = sqrt($wrongness);
             // Normalise it
             $wrongness /= count($question['answers']);
             // And get our complement
             $correctness = 1.0 - $wrongness;
             $marks += $correctness;
             if ($correctness != 1.0) {
                 $correction = array($question['id'], get_translated_text($question['q_question_text']), $correct_answer, $accum);
                 if (!is_null($correct_explanation)) {
                     $explanation = get_translated_text($correct_explanation);
                     if ($explanation != '') {
                         $correction[] = $explanation;
                     }
                 }
                 $corrections[] = $correction;
             }
             $results[$i] = $accum->evaluate();
         } else {
             $was_right = false;
             $correct_answer = new ocp_tempcode();
             $correct_explanation = NULL;
             foreach ($question['answers'] as $a) {
                 if ($a['q_is_correct'] == 1) {
                     $correct_answer = make_string_tempcode(escape_html(get_translated_text($a['q_answer_text'])));
                 }
                 if (post_param_integer($name, -1) == $a['id']) {
                     $results[$i] = get_translated_text($a['q_answer_text']);
                     if ($a['q_is_correct'] == 1) {
                         $was_right = true;
                         $marks++;
                         break;
                     }
                     $correct_explanation = $a['q_explanation'];
                 }
             }
             $GLOBALS['SITE_DB']->query_insert('quiz_entry_answer', array('q_entry' => $entry_id, 'q_question' => $question['id'], 'q_answer' => post_param($name, '')));
             if (!array_key_exists($i, $results)) {
                 $results[$i] = '/';
             }
             if (!$was_right) {
                 $correction = array($question['id'], get_translated_text($question['q_question_text']), $correct_answer, $results[$i]);
                 if (!is_null($correct_explanation)) {
                     $explanation = get_translated_text($correct_explanation);
                     if ($explanation != '') {
                         $correction[] = $explanation;
                     }
                 }
                 $corrections[] = $correction;
             }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:67,代码来源:quiz.php

示例8: trim

 /**
  * Actualise ticket creation/reply, then show the ticket again.
  *
  * @return tempcode		The UI
  */
 function do_update_ticket()
 {
     $title = get_page_title('SUPPORT_TICKETS');
     $id = get_param('id');
     $_title = post_param('title');
     $post = post_param('post');
     if ($post == '') {
         warn_exit(do_lang_tempcode('NO_PARAMETER_SENT', 'post'));
     }
     $ticket_type = post_param_integer('ticket_type', -1);
     $this->check_id($id);
     $staff_only = post_param_integer('staff_only', 0) == 1;
     // Update
     $_home_url = build_url(array('page' => '_SELF', 'type' => 'ticket', 'id' => $id, 'redirect' => NULL), '_SELF', NULL, false, true, true);
     $home_url = $_home_url->evaluate();
     $email = '';
     if ($ticket_type != -1) {
         $type_string = get_translated_text($ticket_type);
         $ticket_type_details = get_ticket_type($ticket_type);
         //$_title=$type_string.' ('.$_title.')';
         if (!has_category_access(get_member(), 'tickets', $type_string)) {
             access_denied('I_ERROR');
         }
         // Check FAQ search results first
         if ($ticket_type_details['search_faq'] && post_param_integer('faq_searched', 0) == 0) {
             $results = $this->do_search($title, $id, $post);
             if (!is_null($results)) {
                 return $results;
             }
         }
         $new_post = new ocp_tempcode();
         $new_post->attach(do_lang('THIS_WITH_COMCODE', do_lang('TICKET_TYPE'), $type_string) . "\n\n");
         $email = trim(post_param('email', ''));
         if ($email != '') {
             $body = '> ' . str_replace(chr(10), chr(10) . '> ', $post);
             if (substr($body, -2) == '> ') {
                 $body = substr($body, 0, strlen($body) - 2);
             }
             $new_post->attach('[email subject="Re: ' . comcode_escape(post_param('title')) . ' [' . get_site_name() . ']" body="' . comcode_escape($body) . '"]' . $email . '[/email]' . "\n\n");
         } elseif (is_guest() && $ticket_type_details['guest_emails_mandatory']) {
             // Error if the e-mail address is required for this ticket type
             warn_exit(do_lang_tempcode('ERROR_GUEST_EMAILS_MANDATORY'));
         }
         $new_post->attach($post);
         $post = $new_post->evaluate();
     }
     if (addon_installed('captcha')) {
         if (get_option('captcha_on_feedback') == '1') {
             require_code('captcha');
             enforce_captcha();
         }
     }
     ticket_add_post(get_member(), $id, $ticket_type, $_title, $post, $home_url, $staff_only);
     // Find true ticket title
     $_forum = 1;
     $_topic_id = 1;
     $_ticket_type = 1;
     // These will be returned by reference
     $posts = get_ticket_posts($id, $_forum, $_topic_id, $_ticket_type);
     if (!is_array($posts)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $__title = $_title;
     foreach ($posts as $ticket_post) {
         $__title = $ticket_post['title'];
         if ($__title != '') {
             break;
         }
     }
     // Send email
     if (!$staff_only) {
         if ($email == '') {
             $email = $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member());
         }
         send_ticket_email($id, $__title, $post, $home_url, $email, $ticket_type);
     }
     $url = build_url(array('page' => '_SELF', 'type' => 'ticket', 'id' => $id), '_SELF');
     if (is_guest()) {
         $url = build_url(array('page' => '_SELF'), '_SELF');
     }
     if (get_param('redirect', '') != '') {
         $url = make_string_tempcode(get_param('redirect'));
     }
     return redirect_screen($title, $url, do_lang_tempcode('TICKET_STARTED'));
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:90,代码来源:tickets.php

示例9: breadcrumbs

/**
 * Get the tempcode for the breadcrumbs.
 *
 * @return tempcode		The breadcrumbs
 */
function breadcrumbs()
{
    global $BREADCRUMB_SET_PARENTS, $BREADCRUMBS, $BREADCRUMB_EXTRA_SEGMENTS;
    $show_top = get_param_integer('wide_high', get_param_integer('keep_wide_high', 0)) != 1;
    if (!$show_top) {
        return new ocp_tempcode();
    }
    if ($BREADCRUMBS === NULL) {
        $BREADCRUMBS = breadcrumbs_get_default_stub($BREADCRUMB_EXTRA_SEGMENTS->is_empty());
    }
    $out = new ocp_tempcode();
    $out->attach($BREADCRUMBS);
    if (!$BREADCRUMB_EXTRA_SEGMENTS->is_empty()) {
        if (!$out->is_empty()) {
            $out->attach(do_template('BREADCRUMB_ESCAPED'));
        }
        $out->attach($BREADCRUMB_EXTRA_SEGMENTS);
    }
    // Substitutions (deprecated hardcoding example)
    $segment_substitutions = array();
    $root = get_param('keep_catalogue_root_page', NULL);
    if ($root !== NULL) {
        $page_name = get_param('keep_catalogue_root_page_name');
        $target_url = build_url(array('page' => $root), '_SEARCH');
        $breadcrumb_tpl = do_template('BREADCRUMB_ESCAPED');
        $from = '\\<a title="[^"]*" href="[^"]*/site/index.php\\?page=catalogues&amp;type=misc[^"]*"\\>Catalogues\\</a\\>' . $breadcrumb_tpl->evaluate();
        $to = '<a title="' . do_lang('GO_BACKWARDS_TO', escape_html(strip_tags($page_name))) . '" href="' . escape_html($target_url->evaluate()) . '">' . escape_html($page_name) . '</a>' . $breadcrumb_tpl->evaluate();
        $segment_substitutions[$from] = $to;
    }
    // Substitutions (XML)
    if (addon_installed('breadcrumbs') && function_exists('xml_parser_create')) {
        $data = @file_get_contents(get_custom_file_base() . '/data_custom/breadcrumbs.xml', FILE_TEXT);
        if ($data === false && get_custom_file_base() != get_file_base()) {
            $data = @file_get_contents(get_file_base() . '/data_custom/breadcrumbs.xml', FILE_TEXT);
        }
        if (trim($data) != '') {
            require_code('breadcrumbs');
            $segment_substitutions = array_merge($segment_substitutions, load_breadcrumb_substitutions($out->evaluate(), $data));
        }
    }
    if (count($segment_substitutions) != 0) {
        $_out = $out->evaluate();
        foreach ($segment_substitutions as $from => $to) {
            $_out = preg_replace('~' . str_replace('~', '\\~', $from) . '~Us', $to, $_out, 1);
        }
        return make_string_tempcode($_out);
    }
    return $out;
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:54,代码来源:site.php

示例10: list

 /**
  * Get tempcode for a news adding/editing form.
  *
  * @param  ?AUTO_LINK		The primary category for the news (NULL: personal)
  * @param  ?array				A list of categories the news is in (NULL: not known)
  * @param  SHORT_TEXT		The news title
  * @param  LONG_TEXT			The news summary
  * @param  SHORT_TEXT		The name of the author
  * @param  BINARY				Whether the news is validated
  * @param  ?BINARY			Whether rating is allowed (NULL: decide statistically, based on existing choices)
  * @param  ?SHORT_INTEGER	Whether comments are allowed (0=no, 1=yes, 2=review style) (NULL: decide statistically, based on existing choices)
  * @param  ?BINARY			Whether trackbacks are allowed (NULL: decide statistically, based on existing choices)
  * @param  BINARY				Whether to show the "send trackback" field
  * @param  LONG_TEXT			Notes for the video
  * @param  URLPATH			URL to the image for the news entry (blank: use cat image)
  * @param  ?array				Scheduled go-live time (NULL: N/A)
  * @return array				A tuple of lots of info (fields, hidden fields, trailing fields)
  */
 function get_form_fields($main_news_category = NULL, $news_category = NULL, $title = '', $news = '', $author = '', $validated = 1, $allow_rating = NULL, $allow_comments = NULL, $allow_trackbacks = NULL, $send_trackbacks = 1, $notes = '', $image = '', $scheduled = NULL)
 {
     list($allow_rating, $allow_comments, $allow_trackbacks) = $this->choose_feedback_fields_statistically($allow_rating, $allow_comments, $allow_trackbacks);
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'validated';
     if (is_null($main_news_category)) {
         $NON_CANONICAL_PARAMS[] = 'cat';
         $param_cat = get_param('cat', '');
         if ($param_cat == '') {
             $news_category = array();
             $main_news_category = NULL;
         } elseif (strpos($param_cat, ',') === false) {
             $news_category = array();
             $main_news_category = intval($param_cat);
         } else {
             require_code('ocfiltering');
             $news_category = ocfilter_to_idlist_using_db($param_cat, 'id', 'news_categories', 'news_categories', NULL, 'id', 'id');
             $main_news_category = NULL;
         }
         $author = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
     }
     $cats1 = nice_get_news_categories($main_news_category, false, true, false, true);
     $cats2 = nice_get_news_categories(is_null($news_category) || count($news_category) == 0 ? array(get_param_integer('cat', NULL)) : $news_category, false, true, true, false);
     $fields = new ocp_tempcode();
     $fields2 = new ocp_tempcode();
     $hidden = new ocp_tempcode();
     require_code('form_templates');
     $fields->attach(form_input_line_comcode(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, true));
     if ($validated == 0) {
         $validated = get_param_integer('validated', 0);
         if ($validated == 1) {
             attach_message(do_lang_tempcode('WILL_BE_VALIDATED_WHEN_SAVING'));
         }
     }
     if (has_some_cat_specific_permission(get_member(), 'bypass_validation_' . $this->permissions_require . 'range_content', 'cms_news', $this->permissions_cat_require)) {
         if (addon_installed('unvalidated')) {
             $fields2->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED'), 'validated', $validated == 1));
         }
     }
     if ($cats1->is_empty()) {
         warn_exit(do_lang_tempcode('NO_CATEGORIES'));
     }
     if (addon_installed('authors')) {
         $hidden->attach(form_input_hidden('author', $author));
     }
     $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => (is_null($news_category) || count($news_category) == 0) && $image == '' && (is_null($news_category) || $news_category == array()), 'TITLE' => do_lang_tempcode('ADVANCED'))));
     $fields2->attach(form_input_text_comcode(do_lang_tempcode('BLOG_NEWS_SUMMARY'), do_lang_tempcode('DESCRIPTION_NEWS_SUMMARY'), 'news', $news, false));
     if (get_value('disable_secondary_news') !== '1') {
         $fields2->attach(form_input_list(do_lang_tempcode('MAIN_CATEGORY'), do_lang_tempcode('DESCRIPTION_MAIN_CATEGORY'), 'main_news_category', $cats1));
     } else {
         $fields2->attach(form_input_hidden('main_news_category', is_null($main_news_category) ? 'personal' : strval($main_news_category)));
     }
     if (get_value('disable_secondary_news') !== '1') {
         $fields2->attach(form_input_multi_list(do_lang_tempcode('SECONDARY_CATEGORIES'), do_lang_tempcode('DESCRIPTION_SECONDARY_CATEGORIES'), 'news_category', $cats2));
     }
     $fields2->attach(form_input_upload(do_lang_tempcode('IMAGE'), do_lang_tempcode('DESCRIPTION_NEWS_IMAGE_OVERRIDE'), 'file', false, $image, NULL, true, str_replace(' ', '', get_option('valid_images'))));
     //handle_max_file_size($hidden,'image'); Attachments will add this
     if (addon_installed('calendar') && has_specific_permission(get_member(), 'scheduled_publication_times')) {
         $fields2->attach(form_input_date__scheduler(do_lang_tempcode('PUBLICATION_TIME'), do_lang_tempcode('DESCRIPTION_PUBLICATION_TIME'), 'schedule', true, true, true, $scheduled, intval(date('Y')) - 1970 + 2, 1970));
     }
     require_code('feedback2');
     $fields2->attach(feedback_fields($allow_rating == 1, $allow_comments == 1, $allow_trackbacks == 1, $send_trackbacks == 1, $notes, $allow_comments == 2));
     $fields2->attach(get_syndication_option_fields());
     return array($fields, $hidden, NULL, NULL, NULL, NULL, make_string_tempcode($fields2->evaluate()));
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:83,代码来源:cms_blogs.php

示例11: bind

 /**
  * Bind the parameter bits, or recursively bind children (doesn't change self, returns a bound tempcode object)
  *
  * @param  array			Map of parameters to bind parameter bits to
  * @param  ID_TEXT		The codename of the template this tempcode is from
  * @return tempcode		The new bound tempcode object
  */
 function bind(&$parameters, $codename)
 {
     if (!isset($parameters['_GUID'])) {
         $parameters['_GUID'] = '';
         static $dbt = NULL;
         if ($dbt === NULL) {
             $dbt = function_exists('debug_backtrace');
         }
         if ($dbt) {
             $trace = debug_backtrace();
             $parameters['_GUID'] = isset($trace[3]) ? $trace[3]['function'] . '/' . $trace[2]['function'] : (isset($trace[2]) ? $trace[2]['function'] : $trace[1]['function']);
         }
     }
     $out = new ocp_tempcode();
     $out->codename = $codename;
     $out->code_to_preexecute = $this->code_to_preexecute;
     $out->preprocessable_bits = array();
     foreach ($this->preprocessable_bits as $preprocessable_bit) {
         foreach ($preprocessable_bit[3] as $i => $param) {
             if (($preprocessable_bit[2] != 'SET' || $i == 1) && is_object($param)) {
                 $preprocessable_bit[3][$i] = $param->bind($parameters, '');
             }
         }
         $out->preprocessable_bits[] = $preprocessable_bit;
     }
     if ($GLOBALS['RECORD_TEMPLATES_TREE']) {
         $out->children = isset($this->children) ? $this->children : array();
         foreach ($parameters as $key => $parameter) {
             if (is_object($parameter)) {
                 if (count($parameter->preprocessable_bits) != 0) {
                     $parameter->handle_symbol_preprocessing();
                 }
                 // Needed to force children to be populated. Otherwise it is possible but not definite that evaluation will result in children being pushed down (SHIFT_ENCODING in a template can cause them to be misappropriated, as it causes a runtime cache string in the Tempcode tree).
                 $out->children[] = array($parameter->codename, isset($parameter->children) ? $parameter->children : array(), isset($parameter->fresh) ? $parameter->fresh : false);
             } elseif (is_string($parameter) && $key == '_GUID') {
                 $out->children[] = array(':guid', array(array(':' . $parameter, array(), true)), true);
             }
         }
     }
     foreach ($parameters as $key => $parameter) {
         $p_type = gettype($parameter);
         if ($p_type == 'string') {
             // Performance, this is most likely
         } elseif ($p_type == 'object') {
             if (isset($parameter->preprocessable_bits[0])) {
                 $out->preprocessable_bits = array_merge($out->preprocessable_bits, $parameter->preprocessable_bits);
             } elseif (!isset($parameter->seq_parts[0])) {
                 $parameters[$key] = '';
             }
             // Little optimisation to save memory
         } elseif ($p_type == 'boolean') {
             $parameters[$key] = $parameter ? '1' : '0';
         } elseif ($p_type != 'array' && $p_type != 'NULL') {
             warn_exit(do_lang_tempcode('NO_INTEGERS_TEMPLATE', escape_html($key)));
         }
     }
     foreach ($this->seq_parts as $bit) {
         if (($bit[0][0] != 's' || substr($bit[0], 0, 14) != 'string_attach_') && $bit[2] != TC_LANGUAGE_REFERENCE) {
             $bit[1] =& $parameters;
         }
         // & is to preserve memory
         $out->seq_parts[] = $bit;
     }
     // Force pre-execution, so shift encoding handled. This is prior to pre-processing (it needs to be for validity in interaction with what is in itself preprocessed), so you could consider it pre-pre-processing
     if (strpos($out->code_to_preexecute, 'SHIFT_ENCODE') !== false) {
         $out->evaluate();
     }
     return $out;
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:76,代码来源:tempcode.php

示例12: inform_about_addon_uninstall

/**
 * Get information for the user relating to an addon that they are intending to uninstall.
 *
 * @param  string			Name of the addon
 * @param  ?array			List of addons that we're currently uninstalling (so dependencies from these are irrelevant). (NULL: none)
 * @param  ?array			Addon details. (NULL: load in function)
 * @return array			Pair: warnings, files
 */
function inform_about_addon_uninstall($name, $also_uninstalling = NULL, $addon_row = NULL)
{
    if (is_null($also_uninstalling)) {
        $also_uninstalling = array();
    }
    // Read/show info
    if (is_null($addon_row)) {
        $addon_row = read_addon_info($name);
    }
    $files = new ocp_tempcode();
    // The files can come in as either a newline-separated string or an array.
    // If its an array then we use it as-is, if it's a string then we explode it first.
    if (is_array($addon_row['addon_files'])) {
        $loopable = $addon_row['addon_files'];
    } else {
        $loopable = explode(chr(10), $addon_row['addon_files']);
    }
    foreach ($loopable as $i => $filename) {
        $files->attach(do_template('ADDON_INSTALL_FILES', array('I' => strval($i), 'DISABLED' => true, 'PATH' => $filename)));
    }
    // Check dependencies
    $dependencies = $addon_row['addon_dependencies_on_this'];
    foreach ($also_uninstalling as $d) {
        if (in_array($d, $dependencies)) {
            unset($dependencies[array_search($d, $dependencies)]);
        }
    }
    $warnings = new ocp_tempcode();
    $_dependencies_str = new ocp_tempcode();
    foreach ($dependencies as $in) {
        if (!$_dependencies_str->is_empty()) {
            $_dependencies_str->attach(do_lang_tempcode('LIST_SEP'));
        }
        $_dependencies_str->attach(escape_html($in));
    }
    if (count($dependencies) != 0) {
        if ($addon_row['addon_author'] == 'Core Team') {
            $post_fields = build_keep_post_fields();
            foreach ($dependencies as $in) {
                $post_fields->attach(form_input_hidden('uninstall_' . $in, $in));
            }
            if (get_param('type', 'misc') == 'addon_uninstall') {
                $post_fields->attach(form_input_hidden('uninstall_' . $name, $name));
                $url = static_evaluate_tempcode(build_url(array('page' => '_SELF', 'type' => 'multi_action'), '_SELF'));
            } else {
                $url = get_self_url(true);
            }
            warn_exit(do_lang_tempcode('_ADDON_WARNING_PRESENT_DEPENDENCIES', $_dependencies_str->evaluate(), escape_html($name), array(escape_html($url), $post_fields)));
        } else {
            $warnings->attach(do_template('ADDON_INSTALL_WARNING', array('WARNING' => do_lang_tempcode('ADDON_WARNING_PRESENT_DEPENDENCIES', $_dependencies_str, escape_html($name)))));
        }
    }
    return array($warnings, $files);
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:62,代码来源:addons.php

示例13: ecv

/**
 * Evaluate a conventional tempcode variable, handling escaping
 *
 * @param  LANGUAGE_NAME	The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array				Array of escaping operations
 * @param  integer			The type of symbol this is (TC_SYMBOL, TC_LANGUAGE_REFERENCE)
 * @set    0 2
 * @param  ID_TEXT			The name of the symbol
 * @param  array				Parameters to the symbol. For all but directive it is an array of strings. For directives it is an array of Tempcode objects. Actually there may be template-style parameters in here, as an influence of singular_bind and these may be Tempcode, but we ignore them.
 * @return mixed				The result. Either tempcode, or a string.
 */
function ecv($lang, $escaped, $type, $name, $param)
{
    global $TEMPCODE_SETGET, $CYCLES, $PREPROCESSABLE_SYMBOLS, $DISPLAYED_TITLE;
    //echo '<!--'.$name.'-->'."\n";
    if ($type == TC_SYMBOL) {
        $escaped_codes = $name . ($escaped == array() ? '' : serialize($escaped));
        $cacheable = $param == array() && !isset($GLOBALS['NON_CACHEABLE_SYMBOLS'][$name]);
        if ($cacheable) {
            global $SYMBOL_CACHE;
            if (isset($SYMBOL_CACHE[$escaped_codes])) {
                return $SYMBOL_CACHE[$escaped_codes];
            }
        }
        $value = '';
        if ($GLOBALS['XSS_DETECT']) {
            ocp_mark_as_escaped($value);
        }
        $temp_array = array();
        if (isset($PREPROCESSABLE_SYMBOLS[$name]) && $name != 'PAGE_LINK') {
            handle_symbol_preprocessing(array($escaped, $type, $name, $param), $temp_array);
        }
        // Late preprocessing. Should not be needed in case of full screen output (as this was properly preprocessed), but is in other cases
        switch ($name) {
            case 'PAGE_LINK':
                if (isset($param[0])) {
                    list($zone, $map, $hash) = page_link_decode(is_object($param[0]) ? $param[0]->evaluate() : $param[0]);
                    $skip = NULL;
                    if (isset($param[4])) {
                        $skip = array_flip(explode('|', $param[4]));
                    }
                    $avoid_remap = isset($param[1]) && $param[1] == '1';
                    $skip_keep = isset($param[2]) && $param[2] == '1';
                    $keep_all = isset($param[3]) && $param[3] == '1';
                    foreach ($map as $key => $val) {
                        if (is_object($val)) {
                            $map[$key] = $val->evaluate();
                        }
                    }
                    $value = _build_url($map, $zone, $skip, $keep_all, $avoid_remap, $skip_keep, $hash);
                } else {
                    $value = get_zone_name() . ':' . get_page_name();
                    foreach ($_GET as $key => $val) {
                        if ($key == 'page') {
                            continue;
                        }
                        if (is_array($val)) {
                            continue;
                        }
                        if (substr($key, 0, 5) == 'keep_' && !skippable_keep($key, $val)) {
                            continue;
                        }
                        $value .= ':' . $key . '=' . $val;
                    }
                }
                break;
            case 'SET':
                if (isset($param[1])) {
                    if (isset($param[1]) && is_object($param[1])) {
                        $TEMPCODE_SETGET[$param[0]] = $param[1];
                    } else {
                        $param_copy = $param;
                        unset($param_copy[0]);
                        $TEMPCODE_SETGET[$param[0]] = implode(',', $param_copy);
                    }
                }
                break;
            case 'GET':
                if (isset($param[0])) {
                    if (isset($TEMPCODE_SETGET[$param[0]])) {
                        if (is_object($TEMPCODE_SETGET[$param[0]])) {
                            $TEMPCODE_SETGET[$param[0]] = $TEMPCODE_SETGET[$param[0]]->evaluate();
                        }
                        $value = $TEMPCODE_SETGET[$param[0]];
                    }
                }
                break;
            case 'EQ':
                if (isset($param[1])) {
                    $first = array_shift($param);
                    $count = 0;
                    foreach ($param as $test) {
                        if ($first == $test) {
                            $count++;
                            break;
                        }
                    }
                    $value = $count != 0 ? '1' : '0';
                }
                break;
//.........这里部分代码省略.........
开发者ID:erico-deh,项目名称:ocPortal,代码行数:101,代码来源:symbols.php

示例14: display_validation_results

/**
 * Show results of running a validation function.
 *
 * @param  string			The data validated
 * @param  array			Error information
 * @param  boolean		Whether we are opening up an XHTML-fragment in a preview box
 * @param  boolean		Whether to return Tempcode
 * @return string			Returned result (won't return it $ret is false)
 */
function display_validation_results($out, $error, $preview_mode = false, $ret = false)
{
    global $KEEP_MARKERS, $SHOW_EDIT_LINKS;
    $KEEP_MARKERS = false;
    $SHOW_EDIT_LINKS = false;
    global $XHTML_SPIT_OUT;
    $XHTML_SPIT_OUT = 1;
    if (function_exists('set_time_limit')) {
        @set_time_limit(280);
    }
    require_css('adminzone');
    if (!$ret) {
        $echo = do_header($preview_mode);
        $echo->evaluate_echo();
    } else {
        ob_start();
    }
    $title = get_page_title('VALIDATION_ERROR');
    // Escape and colourfy
    $i = 0;
    // Output header
    if (count($_POST) == 0) {
        $messy_url = get_param_integer('keep_markers', 0) == 1 ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'special_page_type' => 'code', 'keep_markers' => 1), '_SELF', NULL, true);
        $ignore_url = build_url(array('page' => '_SELF', 'keep_novalidate' => 1), '_SELF', NULL, true);
        $ignore_url_2 = build_url(array('page' => '_SELF', 'novalidate' => 1), '_SELF', NULL, true);
    } else {
        $messy_url = new ocp_tempcode();
        $ignore_url = new ocp_tempcode();
        $ignore_url_2 = new ocp_tempcode();
    }
    $error_lines = array();
    $return_url = new ocp_tempcode();
    if (count($error['errors']) != 0) {
        $errorst = new ocp_tempcode();
        foreach ($error['errors'] as $j => $_error) {
            $errorst->attach(do_template('VALIDATE_ERROR', array('_GUID' => '2239470f4b9bd38fcb570689cecaedd2', 'I' => strval($j), 'LINE' => integer_format($_error['line']), 'POS' => integer_format($_error['pos']), 'ERROR' => $_error['error'])));
            $error_lines[$_error['line']] = 1;
        }
        $errors = $errorst->evaluate();
        $echo = do_template('VALIDATE_ERROR_SCREEN', array('_GUID' => 'db6c362632471e7c856380d32da91054', 'MSG' => do_lang_tempcode('_NEXT_ITEM_BACK'), 'RETURN_URL' => $return_url, 'TITLE' => $title, 'IGNORE_URL_2' => $ignore_url_2, 'IGNORE_URL' => $ignore_url, 'MESSY_URL' => $messy_url, 'ERRORS' => $errorst, 'RET' => $ret));
        unset($errorst);
        $echo->evaluate_echo();
    } else {
        $echo = do_template('VALIDATE_SCREEN', array('_GUID' => 'd8de848803287e4c592418d57450b7db', 'MSG' => do_lang_tempcode('_NEXT_ITEM_BACK'), 'RETURN_URL' => $return_url, 'TITLE' => get_page_title('VIEWING_SOURCE'), 'MESSY_URL' => $messy_url, 'RET' => $ret));
        $echo->evaluate_echo();
    }
    $level_ranges = $error['level_ranges'];
    $tag_ranges = $error['tag_ranges'];
    $value_ranges = $error['value_ranges'];
    $current_range = 0;
    $current_tag = 0;
    $current_value = 0;
    $number = 1;
    $in_at = false;
    for ($i = 0; $i < strlen($out); ++$i) {
        if (isset($level_ranges[$current_range])) {
            $level = $level_ranges[$current_range][0];
            $start = $level_ranges[$current_range][1];
            if ($start == 0) {
                $start = 1;
            }
            // Hack for when error starts before a line, messing up our output
            if ($i == $start) {
                $x = 8;
                if ($level % $x == 0) {
                    $colour = 'teal';
                }
                if ($level % $x == 1) {
                    $colour = 'blue';
                }
                if ($level % $x == 2) {
                    $colour = 'purple';
                }
                if ($level % $x == 3) {
                    $colour = 'gray';
                }
                if ($level % $x == 4) {
                    $colour = 'red';
                }
                if ($level % $x == 5) {
                    $colour = 'maroon';
                }
                if ($level % $x == 6) {
                    $colour = 'navy';
                }
                if ($level % $x == 7) {
                    $colour = 'olive';
                }
                $previous = $i == 0 ? '' : $out[$i - 1];
                $string = new ocp_tempcode();
                if ($previous == ' ' || $previous == chr(10) || $previous == chr(13)) {
//.........这里部分代码省略.........
开发者ID:erico-deh,项目名称:ocPortal,代码行数:101,代码来源:view_modes.php

示例15: nice_get_field_type

/**
 * Get a list of all field types to choose from.
 *
 * @param  ID_TEXT		Field type to select
 * @param  boolean		Whether to only show options in the same storage set as $type
 * @return tempcode		List of field types
 */
function nice_get_field_type($type = '', $limit_to_storage_set = false)
{
    require_lang('fields');
    $all_types = find_all_hooks('systems', 'fields');
    if ($limit_to_storage_set) {
        $ob = get_fields_hook($type);
        $types = array();
        list(, , $db_type) = $ob->get_field_value_row_bits(NULL);
        foreach ($all_types as $this_type => $hook_type) {
            $ob = get_fields_hook($this_type);
            list(, , $this_db_type) = $ob->get_field_value_row_bits(NULL);
            if ($this_db_type == $db_type) {
                $types[$this_type] = $hook_type;
            }
        }
    } else {
        $types = $all_types;
    }
    $orderings = array(do_lang_tempcode('FIELD_TYPES__TEXT'), 'short_trans', 'short_trans_multi', 'short_text', 'short_text_multi', 'long_trans', 'long_text', 'posting_field', 'codename', 'password', 'email', do_lang_tempcode('FIELD_TYPES__NUMBERS'), 'integer', 'float', do_lang_tempcode('FIELD_TYPES__CHOICES'), 'list', 'radiolist', 'tick', 'multilist', 'tick_multi', do_lang_tempcode('FIELD_TYPES__UPLOADSANDURLS'), 'upload', 'picture', 'video', 'url', 'page_link', 'theme_image', 'theme_image_multi', do_lang_tempcode('FIELD_TYPES__MAGIC'), 'auto_increment', 'random', 'guid', do_lang_tempcode('FIELD_TYPES__REFERENCES'), 'isbn', 'reference', 'content_link', 'content_link_multi', 'user', 'user_multi', 'author');
    $_types = array();
    $done_one_in_section = true;
    foreach ($orderings as $o) {
        if (is_object($o)) {
            if (!$done_one_in_section) {
                array_pop($_types);
            }
            $_types[] = $o;
            $done_one_in_section = false;
        } else {
            if (array_key_exists($o, $types)) {
                $_types[] = $o;
                unset($types[$o]);
                $done_one_in_section = true;
            }
        }
    }
    if (!$done_one_in_section) {
        array_pop($_types);
    }
    if (count($types) != 0) {
        $types = array_merge($_types, array(do_lang_tempcode('FIELD_TYPES__OTHER')), array_keys($types));
    } else {
        $types = $_types;
    }
    $type_list = new ocp_tempcode();
    foreach ($types as $_type) {
        if (is_object($_type)) {
            if (!$type_list->is_empty()) {
                $type_list->attach(form_input_list_entry('', false, escape_html(''), false, true));
            }
            $type_list->attach(form_input_list_entry('', false, $_type, false, true));
        } else {
            $ob = get_fields_hook($_type);
            if (method_exists($ob, 'get_field_types')) {
                $sub_types = $ob->get_field_types();
            } else {
                $sub_types = array($_type => do_lang_tempcode('FIELD_TYPE_' . $_type));
            }
            foreach ($sub_types as $__type => $_title) {
                $type_list->attach(form_input_list_entry($__type, $__type == $type, $_title));
            }
        }
    }
    return make_string_tempcode($type_list->evaluate());
    // XHTMLXHTML
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:73,代码来源:fields.php


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