本文整理汇总了PHP中Articles::allow_creation方法的典型用法代码示例。如果您正苦于以下问题:PHP Articles::allow_creation方法的具体用法?PHP Articles::allow_creation怎么用?PHP Articles::allow_creation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Articles
的用法示例。
在下文中一共展示了Articles::allow_creation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: urlencode
}
//
// assemble all tabs
//
$context['text'] .= Skin::build_tabs($panels);
// buttons to display previous and next pages, if any
if (isset($neighbours) && $neighbours) {
$context['text'] .= Skin::neighbours($neighbours, 'manual');
}
//
// the extra panel -- most content is cached, except commands specific to current surfer
//
// page tools
//
// commands to add pages
if (Articles::allow_creation($item, $anchor)) {
Skin::define_img('ARTICLES_ADD_IMG', 'articles/add.gif');
$url = 'articles/edit.php?anchor=' . urlencode('section:' . $item['id']);
if (is_object($content_overlay) && ($label = $content_overlay->get_label('new_command', 'articles'))) {
} else {
$label = i18n::s('Add a page');
}
$context['page_tools'][] = Skin::build_link($url, ARTICLES_ADD_IMG . $label, 'basic', i18n::s('Add new content to this section'));
// the command to create a new poll, if no overlay nor template has been defined for content of this section
if ((!isset($item['content_overlay']) || !trim($item['content_overlay'])) && (!isset($item['articles_templates']) || !trim($item['articles_templates'])) && (!is_object($anchor) || !$anchor->get_templates_for('article'))) {
Skin::define_img('ARTICLES_POLL_IMG', 'articles/poll.gif');
$url = 'articles/edit.php?anchor=' . urlencode('section:' . $item['id']) . '&variant=poll';
$context['page_tools'][] = Skin::build_link($url, ARTICLES_POLL_IMG . i18n::s('Add a poll'), 'basic', i18n::s('Add new content to this section'));
}
}
// add a section
示例2: render
/**
* list dates at some anchor
*
* @param string type of replaced items (e.g., 'articles')
* @param string the anchor to consider (e.g., 'section:123')
* @param int page index
* @return string to be inserted in resulting web page, or NULL
*/
function render($type, $anchor, $page = 1)
{
global $context;
// instead of articles
if ($type != 'articles') {
return NULL;
}
// get the containing page
$container = Anchors::get($anchor);
// handle dates
include_once $context['path_to_root'] . 'dates/dates.php';
// the maximum number of articles per page
if (!defined('DATES_PER_PAGE')) {
define('DATES_PER_PAGE', 50);
}
// where we are
$offset = ($page - 1) * DATES_PER_PAGE;
// should we display all dates, or not?
$with_past_dates = FALSE;
if (preg_match('/\\bwith_past_dates\\b/i', $this->attributes['overlay_parameters'])) {
$with_past_dates = TRUE;
}
// menu to be displayed at the top
$menu = array();
// empowered users can contribute
if (Articles::allow_creation(NULL, $container)) {
Skin::define_img('ARTICLES_ADD_IMG', 'articles/add.gif');
$menu[] = '<div style="display: inline">' . Skin::build_link('articles/edit.php?anchor=' . urlencode($anchor), ARTICLES_ADD_IMG . i18n::s('Add an event'), 'span') . '</div>';
}
// ensure access to past dates
if (!$with_past_dates && ($items = Dates::list_past_for_anchor($anchor, $offset, DATES_PER_PAGE, 'compact'))) {
// turn an array to a string
if (is_array($items)) {
$items =& Skin::build_list($items, 'compact');
}
// navigation bar
$bar = array();
// count the number of dates in this section
$stats = Dates::stat_past_for_anchor($anchor);
if ($stats['count'] > DATES_PER_PAGE) {
$bar = array_merge($bar, array('_count' => sprintf(i18n::ns('%d date', '%d dates', $stats['count']), $stats['count'])));
}
// navigation commands for dates
if ($section = Sections::get(str_replace('section:', '', $anchor))) {
$home = Sections::get_permalink($section);
$prefix = Sections::get_url($section['id'], 'navigate', 'articles');
$bar = array_merge($bar, Skin::navigate($home, $prefix, $stats['count'], DATES_PER_PAGE, $page));
}
// display the bar
if (is_array($bar)) {
$items = Skin::build_list($bar, 'menu_bar') . $items;
}
// in a separate box
$menu[] = Skin::build_sliding_box(i18n::s('Past dates'), $items, 'past_dates', TRUE);
}
// menu displayed towards the top of the page
$text = Skin::finalize_list($menu, 'menu_bar');
// build a list of events
if (preg_match('/\\blayout_as_list\\b/i', $this->attributes['overlay_parameters'])) {
// list all dates
if ($with_past_dates) {
// navigation bar
$bar = array();
// count the number of dates in this section
$stats = Dates::stat_for_anchor($anchor);
if ($stats['count'] > DATES_PER_PAGE) {
$bar = array_merge($bar, array('_count' => sprintf(i18n::ns('%d date', '%d dates', $stats['count']), $stats['count'])));
}
// navigation commands for dates
$section = Sections::get($anchor);
$home = Sections::get_permalink($section);
$prefix = Sections::get_url($section['id'], 'navigate', 'articles');
$bar = array_merge($bar, Skin::navigate($home, $prefix, $stats['count'], DATES_PER_PAGE, $page));
// display the bar
if (count($bar)) {
$text .= Skin::build_list($bar, 'menu_bar');
}
// list one page of dates
if ($items = Dates::list_for_anchor($anchor, $offset, DATES_PER_PAGE, 'family')) {
$text .= $items;
}
// display only future dates to regular surfers
} else {
// show future dates on first page
if ($page == 1 && ($items = Dates::list_future_for_anchor($anchor, 0, 500, 'family', TRUE))) {
$text .= $items;
}
}
// deliver a calendar view for current month, plus months around
} else {
// show past dates as well
if ($with_past_dates) {
//.........这里部分代码省略.........