本文整理汇总了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);
}
}
}
示例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;
}