本文整理汇总了PHP中Sections::has_option方法的典型用法代码示例。如果您正苦于以下问题:PHP Sections::has_option方法的具体用法?PHP Sections::has_option怎么用?PHP Sections::has_option使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sections
的用法示例。
在下文中一共展示了Sections::has_option方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: allow_modification
/**
* check if a section can be modified
*
* This function returns TRUE if the section can be modified,
* and FALSE otherwise.
*
* @param array a set of item attributes, aka, the target section
* @param object an instance of the Anchor interface
* @return TRUE or FALSE
*/
public static function allow_modification($item, $anchor = NULL)
{
global $context;
// sanity check
if (!isset($item['id']) && !$anchor) {
return FALSE;
}
// surfer is an associate
if (Surfer::is_associate()) {
return TRUE;
}
// submissions have been disallowed
if (isset($context['users_without_submission']) && $context['users_without_submission'] == 'Y') {
return FALSE;
}
// surfer owns the container or the section
if (Sections::is_owned($item, $anchor, TRUE)) {
return TRUE;
}
// allow editor of parent section, if not subscriber, to manage content, except on private sections
if (Surfer::is_member() && is_object($anchor) && !$anchor->is_hidden() && $anchor->is_assigned()) {
return TRUE;
}
// section has been locked
if (isset($item['locked']) && $item['locked'] == 'Y') {
return FALSE;
}
// maybe this anonymous surfer is allowed to handle this item
if (isset($item['handle']) && Surfer::may_handle($item['handle'])) {
return TRUE;
}
// community wiki
if (Surfer::is_logged() && Sections::has_option('members_edit', $anchor, $item)) {
return TRUE;
}
// public wiki
if (Sections::has_option('anonymous_edit', $anchor, $item)) {
return TRUE;
}
// default case
return FALSE;
}
示例2: layout
/**
* list sections
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// the maximum number of items per section
if (!defined('MAXIMUM_ITEMS_PER_SECTION')) {
define('MAXIMUM_ITEMS_PER_SECTION', 100);
}
// we return plain text
$text = '';
// process all items in the list
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
$family = '';
while ($item = SQL::fetch($result)) {
// change the family
if ($item['family'] != $family) {
$family = $item['family'];
// show the family
$text .= '<h2><span>' . $family . ' </span></h2>' . "\n";
}
// get the related overlay, if any
$overlay = Overlay::load($item, 'section:' . $item['id']);
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// one box per section
$box = array('title' => '', 'text' => '');
// box content
$elements = array();
// use the title to label the link
if (is_object($overlay)) {
$box['title'] .= Codes::beautify_title($overlay->get_text('title', $item));
} else {
$box['title'] .= Codes::beautify_title($item['title']);
}
$details = array();
// info on related articles
if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
$order = $matches[1];
} else {
$order = 'edition';
}
$items =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact');
if (@count($items)) {
// mention the number of items in folded title
$details[] = sprintf(i18n::ns('%d page', '%d pages', count($items)), count($items));
// add one link per item
foreach ($items as $url => $label) {
$prefix = $suffix = '';
if (is_array($label)) {
$prefix = $label[0];
$suffix = $label[2];
$label = $label[1];
}
$elements[] = $prefix . Skin::build_link($url, $label, 'article') . $suffix;
}
}
// info on related files
if (Sections::has_option('files_by', $anchor, $item) == 'title') {
$items = Files::list_by_title_for_anchor('section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact');
} else {
$items = Files::list_by_date_for_anchor('section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact');
}
if ($items) {
// mention the number of sections in folded title
$details[] = sprintf(i18n::ns('%d file', '%d files', count($items)), count($items));
// add one link per item
foreach ($items as $url => $label) {
if (is_array($label)) {
$prefix = $label[0];
$suffix = $label[2];
$label = $label[1];
}
$elements[] = $prefix . Skin::build_link($url, $label, 'file') . $suffix;
}
}
// info on related comments
if ($items = Comments::list_by_date_for_anchor('section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact', TRUE)) {
// mention the number of sections in folded title
$details[] = sprintf(i18n::ns('%d comment', '%d comments', count($items)), count($items));
// add one link per item
foreach ($items as $url => $label) {
$prefix = $suffix = '';
if (is_array($label)) {
$prefix = $label[0];
$suffix = $label[2];
$label = $label[1];
}
//.........这里部分代码省略.........
示例3: elseif
$context['page_menu'] = $behaviors->add_commands('sections/view.php', 'section:' . $item['id'], $context['page_menu']);
}
// remember surfer visit
Surfer::is_visiting(Sections::get_permalink($item), Codes::beautify_title($item['title']), 'section:' . $item['id'], $item['active']);
// increment silently the hits counter if not robot, nor associate, nor owner, nor at follow-up page
if (Surfer::is_crawler() || Surfer::is_associate()) {
} elseif (isset($item['owner_id']) && Surfer::is($item['owner_id'])) {
} elseif (!$zoom_type) {
$item['hits'] = isset($item['hits']) ? $item['hits'] + 1 : 1;
Sections::increment_hits($item['id']);
}
// initialize the rendering engine
Codes::initialize($cur_section->get_permalink());
// neighbours information
$neighbours = NULL;
if (Sections::has_option('with_neighbours', $anchor, $item) && is_object($anchor)) {
$neighbours = $anchor->get_neighbours('section', $item);
}
//
// set page image -- $context['page_image']
//
// the section or the anchor icon, if any
if (isset($item['icon_url']) && $item['icon_url']) {
$context['page_image'] = $item['icon_url'];
} elseif (is_object($anchor)) {
$context['page_image'] = $anchor->get_icon_url();
}
//
// set page meta_information -- $context['page_header'], etc.
//
// add meta information, if any
示例4: layout
/**
* list sections
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// the maximum number of items per section
if (!defined('MAXIMUM_ITEMS_PER_SECTION')) {
define('MAXIMUM_ITEMS_PER_SECTION', 50);
}
// we return plain text
$text = '';
// process all items in the list
include_once $context['path_to_root'] . 'comments/comments.php';
while ($item = SQL::fetch($result)) {
// get the related overlay, if any
$overlay = Overlay::load($item, 'section:' . $item['id']);
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// the url to view this item
$url = Sections::get_permalink($item);
// use the title to label the link
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$title = Codes::beautify_title($item['title']);
}
// initialize variables
$prefix = $suffix = $icon = '';
// flag sections that are draft, dead, or created or updated very recently
if ($item['activation_date'] >= $context['now']) {
$prefix .= DRAFT_FLAG;
} elseif ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$prefix .= EXPIRED_FLAG;
}
if ($item['create_date'] >= $context['fresh']) {
$suffix .= NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= UPDATED_FLAG;
}
// signal restricted and private sections
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// one box per section
$box = array('title' => '', 'text' => '');
// add a direct link to the section
$box['title'] = $prefix . Skin::build_link($url, $title, 'basic') . $suffix;
// box content
$elements = array();
// info on related articles
if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
$order = $matches[1];
} else {
$order = 'edition';
}
$items =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact');
if (@count($items)) {
foreach ($items as $url => $label) {
$prefix = $suffix = '';
if (is_array($label)) {
$prefix = $label[0];
$suffix = $label[2];
$label = $label[1];
}
$elements[] = $prefix . Skin::build_link($url, $label, 'article') . $suffix;
}
}
// info on related files
if (Sections::has_option('files_by', $anchor, $item) == 'title') {
$items = Files::list_by_title_for_anchor('section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact');
} else {
$items = Files::list_by_date_for_anchor('section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact');
}
if ($items) {
foreach ($items as $url => $label) {
if (is_array($label)) {
$prefix = $label[0];
$suffix = $label[2];
$label = $label[1];
}
$elements[] = $prefix . Skin::build_link($url, $label, 'file') . $suffix;
}
}
// info on related comments
if ($items = Comments::list_by_date_for_anchor('section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact', TRUE)) {
foreach ($items as $url => $label) {
$prefix = $suffix = '';
//.........这里部分代码省略.........