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


PHP Sections::clear方法代码示例

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


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

示例1: transcode

 /**
  * transcode some references
  *
  * @see images/images.php
  *
  * @param array of pairs of strings to be used in preg_replace()
  */
 function transcode($transcoded)
 {
     global $context;
     // no item bound
     if (!isset($this->item['id'])) {
         return;
     }
     // prepare preg_replace()
     $from = array();
     $to = array();
     foreach ($transcoded as $pair) {
         $from[] = $pair[0];
         $to[] = $pair[1];
     }
     // transcode various fields
     $this->item['introduction'] = preg_replace($from, $to, $this->item['introduction']);
     $this->item['description'] = preg_replace($from, $to, $this->item['description']);
     // update the database
     $query = "UPDATE " . SQL::table_name('sections') . " SET " . " introduction = '" . SQL::escape($this->item['introduction']) . "'," . " description = '" . SQL::escape($this->item['description']) . "'" . " WHERE id = " . SQL::escape($this->item['id']);
     SQL::query($query);
     // always clear the cache, even on no update
     Sections::clear($this->item);
 }
开发者ID:rair,项目名称:yacs,代码行数:30,代码来源:section.php

示例2: put_template

 /**
  * change the template of a section
  *
  * This function saves the template as an attribute of the section.
  *
  * Also, it attempts to translate it as a valid YACS skin made
  * of [code]template.php[/code] and [code]skin.php[/code].
  * The theme name is [code]section_<id>[/code].
  *
  * Lastly, it updates the options field to actually use the template for pages of this section.
  *
  * @param int the id of the target section
  * @param string the new or updated template
  * @return string either a null string, or some text describing an error to be inserted into the html response
  *
  * @see services/blog.php
  * @see skins/import.php
  **/
 public static function put_template($id, $template, $directory = NULL)
 {
     global $context;
     // id cannot be empty
     if (!$id || !is_numeric($id)) {
         return i18n::s('No item has the provided id.');
     }
     // load section attributes
     if (!($item = Sections::get($id))) {
         return i18n::s('No item has the provided id.');
     }
     // locate the new skin
     if (!$directory) {
         $directory = 'section_' . $id;
     }
     // make a valid YACS skin
     include_once $context['path_to_root'] . 'skins/import.php';
     if ($error = Import::process($template, $directory)) {
         return $error;
     }
     // change the skin for this section
     $options = preg_replace('/\\bskin_.+\\b/i', '', $item['options']) . ' skin_' . $directory;
     // set default values for this editor
     Surfer::check_default_editor(array());
     // update an existing record
     $query = "UPDATE " . SQL::table_name('sections') . " SET " . "template='" . SQL::escape($template) . "',\n" . "options='" . SQL::escape($options) . "',\n" . "edit_name='" . SQL::escape($fields['edit_name']) . "',\n" . "edit_id=" . SQL::escape($fields['edit_id']) . ",\n" . "edit_address='" . SQL::escape($fields['edit_address']) . "',\n" . "edit_action='section:update',\n" . "edit_date='" . SQL::escape($fields['edit_date']) . "'\n" . "\tWHERE id = " . SQL::escape($id);
     SQL::query($query);
     // clear the cache because of the new rendering
     Sections::clear(array('sections', 'section:' . $id, 'categories'));
 }
开发者ID:rair,项目名称:yacs,代码行数:48,代码来源:sections.php

示例3: foreach

        $count = 0;
        foreach ($_REQUEST['selected_sections'] as $dummy => $id) {
            // an section to lock
            if (($section = Sections::get($id)) && $section['locked'] == 'Y') {
                $attributes = array();
                $attributes['id'] = $section['id'];
                $attributes['locked'] = 'N';
                $attributes['silent'] = 'Y';
                // too minor to be noted
                if (Sections::put_attributes($attributes)) {
                    $count++;
                }
            }
        }
        // clear cache for containing section
        Sections::clear($item);
        // report on results
        $context['text'] .= '<p>' . sprintf(i18n::ns('%d section has been unlocked.', '%d sections have been unlocked.', $count), $count) . '</p>';
        // follow-up commands
        $follow_up = i18n::s('What do you want to do now?');
        $menu = array();
        $menu[] = Skin::build_link(Sections::get_permalink($item), i18n::s('View the section'), 'span');
        $menu[] = Skin::build_link(Sections::get_url($item['id'], 'manage'), i18n::s('Manage it'), 'span');
        $follow_up .= Skin::finalize_list($menu, 'menu_bar');
        $context['text'] .= Skin::build_block($follow_up, 'bottom');
        // nothing to do
    } else {
        Logger::error(i18n::s('No section has been selected.'));
    }
    // which operation?
} else {
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:manage.php


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