本文整理汇总了PHP中Sections::get_handle方法的典型用法代码示例。如果您正苦于以下问题:PHP Sections::get_handle方法的具体用法?PHP Sections::get_handle怎么用?PHP Sections::get_handle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sections
的用法示例。
在下文中一共展示了Sections::get_handle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例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;
// article header
$text = '<article>' . "\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', 'active', 'active_set', 'behaviors', 'canvas', 'create_address', 'create_date', 'create_id', 'create_name', 'description', 'edit_action', 'edit_address', 'edit_date', 'edit_id', 'edit_name', 'expiry_date', 'extra', 'handle', 'hits', 'icon_url', 'introduction', 'language', 'locked', 'meta', 'nick_name', 'options', 'owner_id', 'prefix', 'publish_address', 'publish_date', 'publish_id', 'publish_name', 'rank', 'rating_count', 'rating_sum', 'review_date', 'source', 'suffix', 'tags', '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";
}
// handle of publisher
if (isset($item['publish_id']) && ($user = Users::get($item['publish_id']))) {
$text .= "\t" . '<publish_nick_name>' . $user['nick_name'] . '</publish_nick_name>' . "\n";
}
// the overlay, if any
if (is_object($overlay)) {
$text .= $overlay->export();
}
// article footer
$text .= '</article>' . "\n";
// job done
return $text;
}