本文整理汇总了PHP中Sections::allow_modification方法的典型用法代码示例。如果您正苦于以下问题:PHP Sections::allow_modification方法的具体用法?PHP Sections::allow_modification怎么用?PHP Sections::allow_modification使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sections
的用法示例。
在下文中一共展示了Sections::allow_modification方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: allow_creation
/**
* check if new images can be added
*
* This function returns TRUE if images can be added to some place,
* and FALSE otherwise.
*
* @param object an instance of the Anchor interface, if any
* @param array a set of item attributes, if any
* @param string the type of item, e.g., 'section'
* @return TRUE or FALSE
*/
public static function allow_creation($item = NULL, $anchor = NULL, $variant = NULL)
{
global $context;
// backward compatibility, reverse parameters :
// $anchor is always a object and $item a array
if (is_object($item) || is_array($anchor)) {
$permute = $anchor;
$anchor = $item;
$item = $permute;
}
// guess the variant
if (!$variant) {
// most frequent case
if (isset($item['id'])) {
$variant = 'article';
} elseif (is_object($anchor)) {
$variant = $anchor->get_type();
} else {
return FALSE;
}
}
// only in articles
if ($variant == 'article') {
// 'no images' option
if (Articles::has_option('no_images', $anchor, $item)) {
return FALSE;
}
// other containers
} else {
// in item
if (isset($item['options']) && is_string($item['options']) && preg_match('/\\bno_images\\b/i', $item['options'])) {
return FALSE;
}
// in container
if (is_object($anchor) && $anchor->has_option('no_images', FALSE)) {
return FALSE;
}
}
// surfer is not allowed to upload a file
if (!Surfer::may_upload()) {
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;
}
// only in articles
if ($variant == 'article') {
// surfer is entitled to change content
if (Articles::allow_modification($item, $anchor)) {
return TRUE;
}
// surfer is an editor, and the page is not private
if (isset($item['active']) && $item['active'] != 'N' && Articles::is_assigned($item['id'])) {
return TRUE;
}
if (is_object($anchor) && !$anchor->is_hidden() && $anchor->is_assigned()) {
return TRUE;
}
// only in iles
} elseif ($variant == 'file') {
// surfer owns the anchor
if (is_object($anchor) && $anchor->is_owned()) {
return TRUE;
}
// only in sections
} elseif ($variant == 'section') {
// surfer is entitled to change content
if (Sections::allow_modification($item, $anchor)) {
return TRUE;
}
// only in user profiles
} elseif ($variant == 'user') {
// the item is anchored to the profile of this member
if (Surfer::get_id() && is_object($anchor) && !strcmp($anchor->get_reference(), 'user:' . Surfer::get_id())) {
return TRUE;
}
// should not happen...
if (isset($item['id']) && Surfer::is($item['id'])) {
return TRUE;
}
}
// item has been locked
if (isset($item['locked']) && $item['locked'] == 'Y') {
return FALSE;
//.........这里部分代码省略.........
示例2: urlencode
if (Files::allow_creation($item, $anchor, 'section')) {
Skin::define_img('FILES_UPLOAD_IMG', 'files/upload.gif');
$context['page_tools'][] = Skin::build_link('files/edit.php?anchor=' . urlencode('section:' . $item['id']), FILES_UPLOAD_IMG . i18n::s('Add a file'), 'basic', i18n::s('Attach related files.'));
}
// add a link
if (Links::allow_creation($item, $anchor, 'section')) {
Skin::define_img('LINKS_ADD_IMG', 'links/add.gif');
$context['page_tools'][] = Skin::build_link('links/edit.php?anchor=' . urlencode('section:' . $item['id']), LINKS_ADD_IMG . i18n::s('Add a link'), 'basic', i18n::s('Contribute to the web and link to relevant pages.'));
}
// post an image, if upload is allowed
if (Images::allow_creation($item, $anchor, 'section')) {
Skin::define_img('IMAGES_ADD_IMG', 'images/add.gif');
$context['page_tools'][] = Skin::build_link('images/edit.php?anchor=' . urlencode('section:' . $item['id']), IMAGES_ADD_IMG . i18n::s('Add an image'), 'basic', i18n::s('You can upload a camera shot, a drawing, or another image file.'));
}
// ensure that the surfer can change content
if (Sections::allow_modification($item, $anchor)) {
// modify this page
Skin::define_img('SECTIONS_EDIT_IMG', 'sections/edit.gif');
if (!is_object($overlay) || !($label = $overlay->get_label('edit_command', 'sections'))) {
$label = i18n::s('Edit this section');
}
$context['page_tools'][] = Skin::build_link(Sections::get_url($item['id'], 'edit'), SECTIONS_EDIT_IMG . $label, 'basic', i18n::s('Press [e] to edit'), FALSE, 'e');
}
// commands for section owners
if (Sections::is_owned($item, $anchor) || Surfer::is_associate()) {
// access previous versions, if any
if ($has_versions) {
Skin::define_img('SECTIONS_VERSIONS_IMG', 'sections/versions.gif');
$context['page_tools'][] = Skin::build_link(Versions::get_url('section:' . $item['id'], 'list'), SECTIONS_VERSIONS_IMG . i18n::s('Versions'), 'basic', i18n::s('Restore a previous version if necessary'));
}
// lock the page
示例3: layout
//.........这里部分代码省略.........
if ($count = Articles::count_for_anchor('section:' . $item['id'])) {
if ($count > 20) {
$box['bottom_bar'] += array('_count' => sprintf(i18n::ns('%d page', '%d pages', $count), $count));
}
// navigation commands for articles
$home = Sections::get_permalink($item);
$prefix = Sections::get_url($item['id'], 'navigate', 'articles');
$box['bottom_bar'] += Skin::navigate($home, $prefix, $count, $items_per_page, 1);
}
}
// bottom menu
if ($box['bottom_bar']) {
$box['text'] .= Skin::build_list($box['bottom_bar'], 'menu_bar');
}
// there is some box content
if ($box['text']) {
$text .= $box['text'];
}
}
// layout sub-sections
if (!isset($item['sections_layout']) || $item['sections_layout'] != 'none') {
// select a layout
if (!isset($item['sections_layout']) || !$item['sections_layout']) {
include_once 'layout_sections.php';
$layout = new Layout_sections();
} else {
$layout = Layouts::new_($item['sections_layout'], 'section');
}
// the maximum number of sections per page
if (is_object($layout)) {
$items_per_page = $layout->items_per_page();
} else {
$items_per_page = SECTIONS_PER_PAGE;
}
// build a complete box
$box = array('top_bar' => array(), 'text' => '', 'bottom_bar' => array());
// the command to add a new section
//if(Sections::allow_creation($item, $anchor)) {
if ($anchor->allows('creation', 'section')) {
Skin::define_img('SECTIONS_ADD_IMG', 'sections/add.gif');
$box['top_bar'] += array('sections/edit.php?anchor=' . urlencode('section:' . $item['id']) => SECTIONS_ADD_IMG . i18n::s('Add a section'));
}
// top menu
if ($box['top_bar']) {
$box['text'] .= Skin::build_list($box['top_bar'], 'menu_bar');
}
// list items by family then title
$offset = 0 * $items_per_page;
$items = Sections::list_by_title_for_anchor('section:' . $item['id'], $offset, $items_per_page, $layout, TRUE);
// actually render the html for the section
if (is_array($items) && is_string($item['sections_layout']) && $item['sections_layout'] == 'compact') {
$box['text'] .= Skin::build_list($items, 'compact');
} elseif (is_array($items)) {
$box['text'] .= Skin::build_list($items, 'decorated');
} elseif (is_string($items)) {
$box['text'] .= $items;
}
// count the number of subsections
if ($count = Sections::count_for_anchor('section:' . $item['id'])) {
if ($count > 20) {
$box['bottom_bar'] = array('_count' => sprintf(i18n::ns('%d section', '%d sections', $count), $count));
}
// navigation commands for sections
$home = Sections::get_permalink($item);
$prefix = Sections::get_url($item['id'], 'navigate', 'sections');
$box['bottom_bar'] += Skin::navigate($home, $prefix, $count, $items_per_page, 1);
}
// bottom menu
if ($box['bottom_bar']) {
$box['text'] .= Skin::build_list($box['bottom_bar'], 'menu_bar');
}
// there is some box content
if ($box['text']) {
$text .= $box['text'];
}
}
// ensure that the surfer can change content
if (Sections::allow_modification($item, $anchor)) {
// view or modify this section
$menu = array();
$menu[] = Skin::build_link(Sections::get_permalink($item), i18n::s('View the sub-section'), 'span');
if (!is_object($overlay) || !($label = $overlay->get_label('edit_command', 'sections'))) {
$label = i18n::s('Edit this sub-section');
}
$menu[] = Skin::build_link(Sections::get_url($item['id'], 'edit'), $label, 'span');
$text .= Skin::finalize_list($menu, 'menu_bar');
}
// assemble the full panel
$panels[] = array('stt' . $item['id'], ucfirst(Skin::strip($item['title'], 30)), 'stc' . $item['id'], $text);
}
// format tabs
if ($this->has_variant('as_array')) {
$text = $panels;
} else {
$text = Skin::build_tabs($panels);
}
// end of processing
SQL::free($result);
return $text;
}