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


PHP Sections::list_for_anchor方法代码示例

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


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

示例1: cascade

 /**
  * cascade to children
  *
  * @param string referencing of the changed anchor
  * @param string rights to be cascaded (e.g., 'Y', 'R' or 'N')
  */
 public static function cascade($reference, $active)
 {
     global $context;
     // only sections may have sub-sections
     if (strpos($reference, 'section:') === 0) {
         // cascade to sub-sections
         if ($items = Sections::list_for_anchor($reference, 'raw')) {
             // cascade to each section individually
             foreach ($items as $id => $item) {
                 // limit actual rights
                 $item['active'] = Anchors::ceil_rights($active, $item['active_set']);
                 $query = "UPDATE " . SQL::table_name('sections') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
                 SQL::query($query);
                 // cascade to children
                 Anchors::cascade('section:' . $item['id'], $item['active']);
             }
         }
     }
     // only categories may have sub-categories
     if (strpos($reference, 'category:') === 0) {
         // cascade to sub-categories
         if ($items = Categories::list_for_anchor($reference, 'raw')) {
             // cascade to each section individually
             foreach ($items as $id => $item) {
                 // limit actual rights
                 $item['active'] = Anchors::ceil_rights($active, $item['active_set']);
                 $query = "UPDATE " . SQL::table_name('categories') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
                 SQL::query($query);
                 // cascade to children
                 Anchors::cascade('category:' . $item['id'], $item['active']);
             }
         }
     }
     // only sections may have articles
     if (strpos($reference, 'section:') === 0) {
         // cascade to articles --up to 3000
         if ($items =& Articles::list_for_anchor_by('edition', $reference, 0, 3000, 'raw')) {
             // cascade to each section individually
             foreach ($items as $id => $item) {
                 // limit actual rights
                 $item['active'] = Anchors::ceil_rights($active, $item['active_set']);
                 $query = "UPDATE " . SQL::table_name('articles') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
                 SQL::query($query);
                 // cascade to children
                 Anchors::cascade('article:' . $item['id'], $item['active']);
             }
         }
     }
     // cascade to files --up to 3000
     if ($items = Files::list_by_date_for_anchor($reference, 0, 3000, 'raw')) {
         // cascade to each section individually
         foreach ($items as $id => $item) {
             // limit actual rights
             $item['active'] = Anchors::ceil_rights($active, $item['active_set']);
             $query = "UPDATE " . SQL::table_name('files') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
             SQL::query($query);
         }
     }
 }
开发者ID:rair,项目名称:yacs,代码行数:65,代码来源:anchors.php

示例2: to_xml

 /**
  * encode an item to XML
  *
  * @param array attributes of the item to encode
  * @param object overlay instance of this item, if any
  * @return string the XML encoding of this item
  */
 public static function to_xml($item, $overlay)
 {
     global $context;
     // section header
     $text = '<section>' . "\n";
     // get unique handle of the anchor of this item
     if (isset($item['anchor']) && !strncmp($item['anchor'], 'section:', 8) && ($handle = Sections::get_handle(substr($item['anchor'], 8)))) {
         $text .= "\t" . '<anchor_type>section</anchor_type>' . "\n" . "\t" . '<anchor_handle>' . $handle . '</anchor_handle>' . "\n";
     }
     // fields to be exported
     $labels = array('id', 'activation_date', 'active', 'active_set', 'articles_canvas', 'articles_layout', 'articles_template', 'behaviors', 'content_options', 'content_overlay', 'create_address', 'create_date', 'create_id', 'create_name', 'description', 'edit_action', 'edit_address', 'edit_date', 'edit_id', 'edit_name', 'expiry_date', 'extra', 'family', 'handle', 'hits', 'home_panel', 'icon_url', 'index_map', 'index_news', 'index_news_count', 'index_title', 'introduction', 'language', 'locked', 'maximum_items', 'meta', 'nick_name', 'options', 'owner_id', 'prefix', 'rank', 'section_overlay', 'sections_layout', 'suffix', 'tags', 'template', 'thumbnail_url', 'title', 'trailer');
     // process all fields
     foreach ($labels as $label) {
         // export this field
         if (isset($item[$label]) && $item[$label]) {
             $text .= "\t" . '<' . $label . '>' . encode_field($item[$label]) . '</' . $label . '>' . "\n";
         }
     }
     // handle of item owner
     if (isset($item['owner_id']) && ($user = Users::get($item['owner_id']))) {
         $text .= "\t" . '<owner_nick_name>' . $user['nick_name'] . '</owner_nick_name>' . "\n";
     }
     // handle of item creator
     if (isset($item['create_id']) && ($user = Users::get($item['create_id']))) {
         $text .= "\t" . '<create_nick_name>' . $user['nick_name'] . '</create_nick_name>' . "\n";
     }
     // handle of last editor
     if (isset($item['edit_id']) && ($user = Users::get($item['edit_id']))) {
         $text .= "\t" . '<edit_nick_name>' . $user['nick_name'] . '</edit_nick_name>' . "\n";
     }
     // the overlay, if any
     if (is_object($overlay)) {
         $text .= $overlay->export();
     }
     // section footer
     $text .= '</section>' . "\n";
     // list articles in this section
     $text .= Articles::list_for_anchor('section:' . $item['id'], 0, 500, 'xml');
     // list sub-sections
     $text .= Sections::list_for_anchor('section:' . $item['id'], 'xml');
     // job done
     return $text;
 }
开发者ID:rair,项目名称:yacs,代码行数:50,代码来源:sections.php


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