本文整理汇总了PHP中Surfer::empower方法的典型用法代码示例。如果您正苦于以下问题:PHP Surfer::empower方法的具体用法?PHP Surfer::empower怎么用?PHP Surfer::empower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Surfer
的用法示例。
在下文中一共展示了Surfer::empower方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: elseif
*
* @link http://blogs.law.harvard.edu/tech/rss RSS 2.0 Specification
*
* @author Bernard Paques
* @author GnapZ
* @tester Pat
* @reference
* @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
*/
// common definitions and initial processing
include_once '../shared/global.php';
// ensure we only provide public content through newsfeeds
$context['users_without_teasers'] = 'Y';
// check network credentials, if any -- used by winamp and other media players
if ($user = Users::authenticate()) {
Surfer::empower($user['capability']);
}
// look for the id
$id = NULL;
if (isset($_REQUEST['id'])) {
$id = $_REQUEST['id'];
} elseif (isset($context['arguments'][0])) {
$id = $context['arguments'][0];
} elseif (Surfer::is_logged()) {
$id = Surfer::get_id();
}
$id = strip_tags($id);
// get the item from the database
$item = Users::get($id);
// associates can do what they want
if (Surfer::is_associate()) {
示例2: elseif
if (isset($_REQUEST['id'])) {
$id = $_REQUEST['id'];
} elseif (isset($context['arguments'][0])) {
$id = $context['arguments'][0];
}
$id = strip_tags($id);
// get the item from the database
$item = Sections::get($id);
// get the related anchor, if any
$anchor = NULL;
if (isset($item['anchor']) && $item['anchor']) {
$anchor = Anchors::get($item['anchor']);
}
// editors have associate-like capabilities
if (isset($item['id']) && Sections::is_assigned($item['id']) || is_object($anchor) && $anchor->is_assigned()) {
Surfer::empower();
}
// load the skin, maybe with a variant
load_skin('sections', $anchor, isset($item['options']) ? $item['options'] : '');
// stop crawlers
if (Surfer::is_crawler()) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
die(i18n::s('You are not allowed to perform this operation.'));
}
// page title
if (isset($item['title'])) {
$context['page_title'] = $item['title'];
}
// not found
if (!$item['id']) {
include '../error.php';
示例3: layout_newest
/**
* layout the newest articles
*
* caution: this function also updates page title directly, and this makes its call non-cacheable
*
* @param array the article
* @return string the rendered text
**/
function layout_newest($item)
{
global $context;
// get the related overlay, if any
$overlay = Overlay::load($item, 'article:' . $item['id']);
// get the anchor
$anchor = Anchors::get($item['anchor']);
// the url to view this item
$url = Articles::get_permalink($item);
// reset the rendering engine between items
Codes::initialize($url);
// build a title
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$title = Codes::beautify_title($item['title']);
}
// title prefix & suffix
$text = $prefix = $suffix = '';
// flag articles updated recently
if ($context['site_revisit_after'] < 1) {
$context['site_revisit_after'] = 2;
}
$context['fresh'] = gmstrftime('%Y-%m-%d %H:%M:%S', mktime(0, 0, 0, date("m"), date("d") - $context['site_revisit_after'], date("Y")));
// link to permalink
if (Surfer::is_empowered()) {
$title = Skin::build_box_title($title, $url, i18n::s('Permalink'));
}
// signal articles to be published
if ($item['publish_date'] <= NULL_DATE) {
$prefix .= DRAFT_FLAG;
} else {
if ($item['publish_date'] > NULL_DATE && $item['publish_date'] > $context['now']) {
$prefix .= DRAFT_FLAG;
}
}
// signal restricted and private articles
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG . ' ';
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG . ' ';
}
// signal locked articles
if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
$suffix .= LOCKED_FLAG;
}
// flag expired article
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$suffix .= EXPIRED_FLAG;
}
// update page title directly
$text .= Skin::build_block($prefix . $title . $suffix, 'title');
// if this article has a specific icon, use it
if ($item['icon_url']) {
$icon = $item['icon_url'];
} elseif ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
$icon = $anchor->get_icon_url();
}
// if we have a valid image
if (preg_match('/(.gif|.jpg|.jpeg|.png)$/i', $icon)) {
// fix relative path
if (!preg_match('/^(\\/|http:|https:|ftp:)/', $icon)) {
$icon = $context['url_to_root'] . $icon;
}
// flush the image on the right
$text .= '<img src="' . $icon . '" class="right_image" alt="" />';
}
// article rating, if the anchor allows for it
if (!is_object($anchor) || !$anchor->has_option('without_rating')) {
// report on current rating
$label = '';
if ($item['rating_count']) {
$label = Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])) . ' ';
}
$label .= i18n::s('Rate this page');
// allow for rating
$text .= Skin::build_link(Articles::get_url($item['id'], 'like'), $label, 'basic');
}
// the introduction text, if any
if (is_object($overlay)) {
$text .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
} else {
$text .= Skin::build_block($item['introduction'], 'introduction');
}
// insert overlay data, if any
if (is_object($overlay)) {
$text .= $overlay->get_text('view', $item);
}
// the beautified description, which is the actual page body
if ($item['description']) {
// use adequate label
if (is_object($overlay) && ($label = $overlay->get_label('description'))) {
//.........这里部分代码省略.........
示例4: elseif
}
// change default behavior
if (isset($item['id']) && is_object($behaviors) && !$behaviors->allow('articles/view.php', 'article:' . $item['id'])) {
$permitted = FALSE;
} elseif ($cur_article->allows('access')) {
$permitted = TRUE;
} else {
$permitted = FALSE;
}
// owners can do what they want
if ($cur_article->allows('modification')) {
Surfer::empower();
} elseif (Surfer::is_logged() && is_object($anchor) && $anchor->is_assigned()) {
Surfer::empower('S');
} elseif (isset($item['id']) && $cur_article->is_assigned() && Surfer::is_logged()) {
Surfer::empower('S');
}
// is the article on user watch list?
$in_watch_list = FALSE;
if (isset($item['id']) && Surfer::get_id()) {
$in_watch_list = Members::check('article:' . $item['id'], 'user:' . Surfer::get_id());
}
// has this page some versions?
$has_versions = FALSE;
if (isset($item['id']) && !$zoom_type && Surfer::is_empowered() && Versions::count_for_anchor('article:' . $item['id'])) {
$has_versions = TRUE;
}
// load the skin, maybe with a variant
load_skin('article', $anchor, isset($item['options']) ? $item['options'] : '');
// clear the tab we are in
if (is_object($anchor)) {