当前位置: 首页>>代码示例>>PHP>>正文


PHP Surfer::is_empowered方法代码示例

本文整理汇总了PHP中Surfer::is_empowered方法的典型用法代码示例。如果您正苦于以下问题:PHP Surfer::is_empowered方法的具体用法?PHP Surfer::is_empowered怎么用?PHP Surfer::is_empowered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Surfer的用法示例。


在下文中一共展示了Surfer::is_empowered方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: layout

 /**
  * list servers
  *
  * @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;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // initialize variables
         $prefix = $suffix = $icon = '';
         // the url to view this item
         $url = Servers::get_url($item['id']);
         // use the title as a label
         $label = Skin::strip($item['title'], 10);
         // flag files uploaded recently
         if ($item['edit_date'] >= $context['fresh']) {
             $prefix = NEW_FLAG . $prefix;
         }
         // description
         if ($item['description']) {
             $suffix .= ' ' . ucfirst(trim($item['description']));
         }
         // the menu bar for associates and poster
         if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) {
             $menu = array(Servers::get_url($item['id'], 'edit') => i18n::s('Edit'), Servers::get_url($item['id'], 'delete') => i18n::s('Delete'));
             $suffix .= ' ' . Skin::build_list($menu, 'menu');
         }
         // add a separator
         if ($suffix) {
             $suffix = ' - ' . $suffix;
         }
         // append details to the suffix
         $suffix .= BR . '<span class="details">';
         // details
         $details = array();
         // item poster
         if ($item['edit_name']) {
             $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
         }
         // the edition date
         $details[] = Skin::build_date($item['edit_date']);
         // all details
         if (count($details)) {
             $suffix .= ucfirst(implode(', ', $details)) . "\n";
         }
         // end of details
         $suffix .= '</span>';
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'server', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
开发者ID:rair,项目名称:yacs,代码行数:66,代码来源:layout_servers.php

示例2: AND

 /**
  * list alphabetically the sections related to any anchor
  *
  * Actually list sections by rank, then by title, then by date.
  * If you select to not use the ranking system, sections will be ordered by title only.
  * Else sections with a low ranking mark will appear first,
  * and sections with a high ranking mark will be put at the end of the list.
  *
  * Only sections matching following criteria are returned:
  * - section is visible (active='Y')
  * - section is restricted (active='R'), but surfer is a logged user
  * - section is restricted (active='N'), but surfer is an associate
  * - an expiry date has not been defined, or is not yet passed
  *
  * @param the target anchor
  * @param int the offset from the start of the list; usually, 0 or 1
  * @param int the number of items to display
  * @param string the list variant, if any
  * @return NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
  *
  * @see sections/select.php
  */
 public static function &list_sections_by_title_for_anchor($anchor, $offset = 0, $count = 10, $variant = 'compact')
 {
     global $context;
     // display active and restricted items
     $where = "sections.active='Y'";
     if (Surfer::is_logged()) {
         $where .= " OR sections.active='R'";
     }
     if (Surfer::is_empowered('S')) {
         $where .= " OR sections.active='N'";
     }
     $where = '(' . $where . ')';
     // only consider live sections
     $where .= " AND ((sections.expiry_date is NULL)" . "OR (sections.expiry_date <= '" . NULL_DATE . "') OR (sections.expiry_date > '" . $context['now'] . "'))";
     // the list of sections
     $query = "SELECT sections.*" . "\tFROM (" . SQL::table_name('members') . " AS members" . ", " . SQL::table_name('sections') . " AS sections)" . " WHERE (members.anchor LIKE '" . SQL::escape($anchor) . "')" . "\tAND (members.member_type = 'section')" . "\tAND (members.member_id = sections.id)" . "\tAND (" . $where . ")" . " ORDER BY sections.title, sections.edit_date DESC LIMIT " . $offset . ',' . $count;
     // use existing listing facility
     $output =& Sections::list_selected(SQL::query($query), $variant);
     return $output;
 }
开发者ID:rair,项目名称:yacs,代码行数:42,代码来源:members.php

示例3: layout

 /**
  * list links
  *
  * Recognize following variants:
  * - 'no_anchor' to list items attached to one particular anchor
  * - 'no_author' to list items attached to one user prolink
  *
  * @param resource the SQL result
  * @return array of resulting items, or NULL
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of ($url => $attributes)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // sanity check
     if (!isset($this->layout_variant)) {
         $this->layout_variant = 'no_anchor';
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // initialize variables
         $prefix = $suffix = $icon = '';
         // make a label
         $label = Links::clean($item['title'], $item['link_url']);
         // flag links uploaded recently
         if ($item['edit_date'] >= $context['fresh']) {
             $prefix = NEW_FLAG . $prefix;
         }
         // the number of clicks
         if ($item['hits'] > 1) {
             $suffix .= ' (' . Skin::build_number($item['hits'], i18n::s('clicks')) . ') ';
         }
         // add a separator
         if ($suffix) {
             $suffix = ' - ' . $suffix;
         }
         // details
         $details = array();
         // item poster
         if ($item['edit_name'] && $this->layout_variant != 'no_author') {
             if (Surfer::is_member() || (!isset($context['content_without_details']) || $context['content_without_details'] != 'Y') || is_object($anchor) && $anchor->has_option('with_details')) {
                 $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
             }
         }
         // show an anchor link
         if ($this->layout_variant != 'no_anchor' && $this->layout_variant != 'no_author' && $item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
             $anchor_url = $anchor->get_url();
             $anchor_label = ucfirst($anchor->get_title());
             $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor_url, $anchor_label, 'article'));
         }
         // the menu bar for associates and poster
         if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) {
             $details[] = Skin::build_link('links/edit.php?id=' . $item['id'], i18n::s('edit'), 'span');
             $details[] = Skin::build_link('links/delete.php?id=' . $item['id'], i18n::s('delete'), 'span');
         }
         // append details to the suffix
         if (count($details)) {
             $suffix .= BR . Skin::finalize_list($details, 'menu');
         }
         // description
         if ($item['description']) {
             $suffix .= BR . Codes::beautify($item['description']);
         }
         // build the actual link to check it
         if ($this->layout_variant == 'review') {
             $icon = $item['link_url'];
         }
         // url is the link itself -- hack for xhtml compliance
         $url = str_replace('&', '&amp;', $item['link_url']);
         // let the rendering engine guess the type of link
         $link_type = NULL;
         // except if we want to stay within this window
         if (isset($item['link_target']) && $item['link_target'] != 'I') {
             $link_type = 'external';
         }
         // hovering title
         $link_title = NULL;
         if (isset($item['link_title']) && $item['link_title']) {
             $link_title = $item['link_title'];
         }
         // pack everything
         $items[$url] = array($prefix, $label, $suffix, $link_type, $icon, $link_title);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
开发者ID:rair,项目名称:yacs,代码行数:96,代码来源:layout_links.php

示例4: is_assigned

 /**
  * check that the surfer is an editor of an anchor
  *
  * This function is used to control the authority delegation from the anchor.
  * For example, if some editor is assigned to a complete section of the
  * web site, he/she should be able to edit all articles in this section.
  * you can use following code to check that:
  * [php]
  * $anchor = Anchors::get($article['anchor']);
  * if($anchor->is_assigned() {
  *	 ...
  * }
  * [/php]
  *
  * A logged member is always considered as an editor if he has created the target item.
  *
  * An anonymous surfer is considered as an editor if he has provided the secret handle.
  *
  * To be overloaded into derived class if field has a different name
  *
  * @param int optional reference to some user profile
  * @param boolean TRUE to climb the list of containers up to the top
  * @return TRUE or FALSE
  */
 function is_assigned($user_id = NULL, $cascade = TRUE)
 {
     global $context;
     // we need some data to proceed
     if (!isset($this->item['id'])) {
         return FALSE;
     }
     // id of requesting user
     if (!$user_id) {
         $user_id = Surfer::get_id();
     }
     // anonymous is allowed
     if (!$user_id) {
         $user_id = 0;
     }
     // create the cache
     if (!isset($this->is_assigned_cache)) {
         $this->is_assigned_cache = array();
     }
     // cache the answer
     if (isset($this->is_assigned_cache[$user_id])) {
         return $this->is_assigned_cache[$user_id];
     }
     // surfer has provided the secret handle
     if (isset($this->item['handle']) && Surfer::may_handle($this->item['handle'])) {
         return $this->is_assigned_cache[$user_id] = TRUE;
     }
     // surfer owns this item
     if ($user_id && isset($this->item['owner_id']) && $user_id == $this->item['owner_id']) {
         return $this->is_assigned_cache[$user_id] = TRUE;
     }
     // anchor has been assigned to this surfer
     if ($user_id && Members::check('user:' . $user_id, $this->get_reference())) {
         return $this->is_assigned_cache[$user_id] = TRUE;
     }
     // anonymous edition is allowed
     if ($this->item['active'] == 'Y' && $this->has_option('anonymous_edit')) {
         return $this->is_assigned_cache[$user_id] = TRUE;
     }
     // members edition is allowed
     if ($this->item['active'] == 'Y' && Surfer::is_empowered('M') && $this->has_option('members_edit')) {
         return $this->is_assigned_cache[$user_id] = TRUE;
     }
     // check parent container
     if ($cascade && isset($this->item['anchor'])) {
         // save requests
         if (!isset($this->anchor) || !$this->anchor) {
             $this->anchor = Anchors::get($this->item['anchor']);
         }
         // check for ownership
         if (is_object($this->anchor)) {
             return $this->is_assigned_cache[$user_id] = $this->anchor->is_assigned($user_id);
         }
     }
     // sorry
     return $this->is_assigned_cache[$user_id] = FALSE;
 }
开发者ID:rair,项目名称:yacs,代码行数:81,代码来源:anchor.php

示例5: elseif

// 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)) {
    $context['current_focus'] = $anchor->get_focus();
}
// current item
if (isset($item['id'])) {
    $context['current_item'] = 'article:' . $item['id'];
}
// path to this page
if ($whole_rendering) {
    $context['path_bar'] = Surfer::get_path_bar($anchor);
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:view.php

示例6: 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'))) {
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:layout_home_articles_as_alistapart.php

示例7: layout

 /**
  * list locations
  *
  * Recognize following variants:
  * - 'no_anchor' to list items attached to one particular anchor
  * - 'no_author' to list items attached to one user prolocation
  *
  * @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;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // initialize variables
         $prefix = $suffix = $icon = '';
         // the url to view this item
         $url = Locations::get_url($item['id']);
         // build a valid label
         if ($item['geo_place_name']) {
             $label = Skin::strip($item['geo_place_name'], 10);
         } else {
             $label = $item['latitude'] . ', ' . $item['longitude'];
         }
         // description
         if ($item['description']) {
             $suffix .= ' ' . ucfirst(trim($item['description']));
         }
         // the menu bar for associates and poster
         if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) {
             $menu = array(Locations::get_url($item['id'], 'edit') => i18n::s('Edit'), Locations::get_url($item['id'], 'delete') => i18n::s('Delete'));
             $suffix .= ' ' . Skin::build_list($menu, 'menu');
         }
         // add a separator
         if ($suffix) {
             $suffix = ' - ' . $suffix;
         }
         // append details to the suffix
         $suffix .= BR . '<span class="details">';
         // details
         $details = array();
         // item poster
         if (isset($this->layout_variant) && $this->layout_variant != 'no_author') {
             if ($item['edit_name']) {
                 $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
             }
         } else {
             $details[] = Anchors::get_action_label($item['edit_action']);
         }
         // show an anchor location
         if (isset($this->layout_variant) && $this->layout_variant != 'no_anchor' && $item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
             $anchor_url = $anchor->get_url();
             $anchor_label = ucfirst($anchor->get_title());
             $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor_url, $anchor_label, 'article'));
         }
         // all details
         if (count($details)) {
             $suffix .= ucfirst(implode(', ', $details)) . "\n";
         }
         // end of details
         $suffix .= '</span>';
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'location', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
开发者ID:rair,项目名称:yacs,代码行数:78,代码来源:layout_locations.php

示例8: array

 // assemble tabs
 //
 if (!$zoom_type) {
     $panels[] = array('followers', i18n::s('Followers'), 'followers_panel', NULL, Users::get_url($item['id'], 'element', 'watch'));
 }
 // let YACS do the hard job
 $context['text'] .= Skin::build_tabs($panels);
 //
 // populate the extra panel
 //
 // page tools
 //
 // tools to maintain my page
 if (Surfer::is_empowered()) {
     // change avatar
     if (Surfer::is_empowered() && isset($item['avatar_url']) && $item['avatar_url']) {
         Skin::define_img('IMAGES_ADD_IMG', 'images/add.gif');
         $label = i18n::s('Change picture');
         $context['page_tools'][] = Skin::build_link(Users::get_url($item['id'], 'select_avatar'), IMAGES_ADD_IMG . $label, 'basic');
     }
     // modify this page
     Skin::define_img('USERS_EDIT_IMG', 'users/edit.gif');
     $context['page_tools'][] = Skin::build_link(Users::get_url($item['id'], 'edit'), USERS_EDIT_IMG . i18n::s('Edit this profile'), 'basic', i18n::s('Press [e] to edit'), FALSE, 'e');
     // change password
     if (!isset($context['users_authenticator']) || !$context['users_authenticator']) {
         Skin::define_img('USERS_PASSWORD_IMG', 'users/password.gif');
         $context['page_tools'][] = Skin::build_link(Users::get_url($item['id'], 'password'), USERS_PASSWORD_IMG . i18n::s('Change password'), 'basic');
     }
     // only associates can delete user profiles; self-deletion may also be allowed
     if (isset($item['id']) && !$zoom_type && $permitted && (Surfer::is_associate() || Surfer::is($item['id']) && (!isset($context['users_without_self_deletion']) || $context['users_without_self_deletion'] != 'Y'))) {
         Skin::define_img('USERS_DELETE_IMG', 'users/delete.gif');
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:view.php

示例9: stat_past_for_anchor

 /**
  * get some statistics for one anchor
  *
  * @param the selected anchor (e.g., 'article:12')
  * @return the resulting ($count, $min_date, $max_date) array
  */
 public static function stat_past_for_anchor($anchor)
 {
     global $context;
     // restrict the query to addressable content
     $where = Articles::get_sql_where();
     // put only published pages in boxes
     if (isset($variant) && $variant == 'boxes') {
         $where .= " AND NOT ((articles.publish_date is NULL) OR (articles.publish_date <= '0000-00-00'))" . " AND (articles.publish_date < '" . $context['now'] . "')";
         // provide published pages to anonymous surfers
     } elseif (!Surfer::is_logged()) {
         $where .= " AND NOT ((articles.publish_date is NULL) OR (articles.publish_date <= '0000-00-00'))" . " AND (articles.publish_date < '" . $context['now'] . "')";
         // logged surfers that are non-associates are restricted to their own articles, plus published articles
     } elseif (!Surfer::is_empowered()) {
         $where .= " AND ((articles.create_id=" . Surfer::get_id() . ") OR (NOT ((articles.publish_date is NULL) OR (articles.publish_date <= '0000-00-00'))" . " AND (articles.publish_date < '" . $context['now'] . "')))";
     }
     // now
     $match = gmstrftime('%Y-%m-%d %H:%M:%S');
     // select among available items
     $query = "SELECT COUNT(*) as count, MIN(articles.edit_date) as oldest_date, MAX(articles.edit_date) as newest_date " . " FROM " . SQL::table_name('dates') . " as dates " . ", " . SQL::table_name('articles') . " AS articles" . " WHERE ((dates.anchor_type LIKE 'article') AND (dates.anchor_id = articles.id))" . "\tAND (dates.date_stamp < '" . SQL::escape($match) . "') AND\t(articles.anchor = '" . SQL::escape($anchor) . "') AND " . $where;
     $output = SQL::query_first($query);
     return $output;
 }
开发者ID:rair,项目名称:yacs,代码行数:28,代码来源:dates.php

示例10: elseif

$id = NULL;
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 (Surfer::is_empowered('M') && (isset($item['id']) && isset($user['id']) && Sections::is_assigned($item['id'], $user['id'])) || is_object($anchor) && $anchor->is_assigned()) {
    Surfer::empower('A');
}
// load a skin, maybe with a variant
load_skin('sections', $anchor, isset($item['options']) ? $item['options'] : '');
// path to this page
$context['path_bar'] = array('sections/' => i18n::s('Site map'));
// page title
$context['page_title'] = i18n::s('RSS feed');
// not found
if (!isset($item['id']) || !$item['id']) {
    include '../error.php';
    // access denied
} elseif (!Sections::allow_access($item, $anchor)) {
    // give anonymous surfers a chance for HTTP authentication
    if (!Surfer::is_logged()) {
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:feed.php

示例11: elseif

 // restricted to logged members
 if ($item['active'] == 'R') {
     $details[] = RESTRICTED_FLAG . i18n::s('Community - Access is granted to any identified surfer');
 } elseif ($item['active'] == 'N') {
     $details[] = PRIVATE_FLAG . i18n::s('Private - Access is restricted to selected persons');
 }
 // rank for this section
 if (intval($item['rank']) != 10000 && Surfer::is_associate()) {
     $details[] = sprintf(i18n::s('Rank: %s'), $item['rank']);
 }
 // signal sections to be activated
 if (Surfer::is_empowered() && $item['activation_date'] > $context['now']) {
     $details[] = DRAFT_FLAG . ' ' . sprintf(i18n::s('Section will be activated %s'), Skin::build_date($item['activation_date']));
 }
 // expired section
 if (Surfer::is_empowered() && $item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
     $details[] = EXPIRED_FLAG . ' ' . sprintf(i18n::s('Section has expired %s'), Skin::build_date($item['expiry_date']));
 }
 // display details, if any
 if (count($details)) {
     $context['text'] .= '<p>' . ucfirst(implode(BR . "\n", $details)) . "</p>\n";
 }
 // insert anchor prefix
 if (is_object($anchor)) {
     $context['text'] .= $anchor->get_prefix();
 }
 // the introduction text, if any
 $context['text'] .= Skin::build_block($item['introduction'], 'introduction');
 // the description, which is the actual page body
 $context['text'] .= Skin::build_block($item['description'], 'description', '', $item['options']);
 //
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:print.php

示例12: one

 /**
  * format just one item
  *
  * This is used within this script, but also to shape sections assigned
  * to the surfer in the web form for new articles.
  *
  * @param array attributes of one item
  * @return array of ($url => array($prefix, $label, $suffix, ...))
  *
  * @see articles/edit.php
  **/
 function one(&$item)
 {
     global $context;
     // this function is invoked directly from articles/edit.php
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     // sanity check
     if (!isset($this->layout_variant)) {
         $this->layout_variant = 'articles/edit.php?anchor=section:';
     }
     // 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;
     } elseif ($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;
     }
     // details
     $details = array();
     // info on related articles
     if ($count = Members::count_articles_for_anchor('section:' . $item['id'])) {
         $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
     }
     // info on related files
     if ($count = Files::count_for_anchor('section:' . $item['id'], TRUE)) {
         $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
     }
     // info on related links
     if ($count = Links::count_for_anchor('section:' . $item['id'], TRUE)) {
         $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
     }
     // info on related comments
     if ($count = Comments::count_for_anchor('section:' . $item['id'], TRUE)) {
         $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
     }
     // append details to the suffix
     if (count($details)) {
         $suffix .= "\n" . '<span class="details">(' . implode(', ', $details) . ')</span>';
     }
     // introduction
     if ($item['introduction']) {
         $suffix .= ' ' . Codes::beautify_introduction(trim($item['introduction']));
     }
     // add a head list of related links
     $subs = array();
     // add sub-sections on index pages
     if ($related =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, 2 * YAHOO_LIST_SIZE, 'raw')) {
         foreach ($related as $id => $attributes) {
             // look for sub-sub-sections
             $leaves = array();
             if ($children =& Sections::list_by_title_for_anchor('section:' . $id, 0, 50, 'raw')) {
                 foreach ($children as $child_id => $child_attributes) {
                     $child_url = $this->layout_variant . $child_id;
                     $leaves[$child_url] = $child_attributes['title'];
                 }
             }
             // link for this sub-section
             $url = $this->layout_variant . $id;
             // expose sub-sub-sections as well
             if (count($leaves) > YAHOO_LIST_SIZE) {
                 $subs[$url] = array('', $attributes['title'], Skin::build_box(i18n::s('More spaces'), Skin::build_list($leaves, 'compact'), 'folded'));
             } elseif (count($leaves)) {
                 $subs[$url] = array('', $attributes['title'], Skin::build_list($leaves, 'compact'));
             } else {
                 $subs[$url] = $attributes['title'];
             }
         }
     }
     // one sub-section per line
     if (count($subs)) {
         $suffix .= Skin::build_list($subs, 'compact');
     }
     // put the actual icon in the left column
     if (isset($item['thumbnail_url'])) {
         $icon = $item['thumbnail_url'];
     }
     // only associates and editors can post to a locked section
     if (isset($item['locked']) && $item['locked'] == 'Y' && !Surfer::is_empowered()) {
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:layout_sections_as_select.php

示例13: layout

 /**
  * list blogmarks
  *
  * @param resource the SQL result
  * @return string resulting text
  **/
 function layout($result)
 {
     global $context;
     // we return a string
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // start in north
     $in_north = TRUE;
     // define allowed HTML tags for the cover page
     define('ALLOWED_HTML_TAGS', '<a><b><br><h1><h2><h3><i><img><li><ol><p><ul>');
     // build a list of articles
     $box = array();
     $box['content'] = '';
     $previous_date = NULL;
     while ($item = SQL::fetch($result)) {
         // not the same date
         $current_date = substr($item['edit_date'], 0, 10);
         if ($previous_date != $current_date) {
             // insert a complete box for the previous date
             if ($box['content']) {
                 if ($in_north) {
                     $text .= '<div class="newest">' . "\n";
                 }
                 $text .= Skin::build_box($box['title'], $box['content']);
                 if ($in_north) {
                     $text .= '</div>' . "\n";
                 }
                 $in_north = FALSE;
             }
             // prepare a box for a new date
             $previous_date = $current_date;
             $box['title'] = Skin::build_date($item['edit_date'], 'no_hour');
             $box['content'] = '';
         }
         $box['content'] .= '<br clear="both" />';
         // time
         $box['content'] .= '<span class="details">' . substr($item['edit_date'], 11, 5) . '</span> ';
         // make a label
         $label = Links::clean($item['title'], $item['link_url']);
         $box['content'] .= Skin::build_link($item['link_url'], $label);
         // flag links updated recently
         if ($item['edit_date'] >= $context['fresh']) {
             $box['content'] .= ' ' . NEW_FLAG;
         }
         // the description
         if (trim($item['description'])) {
             $box['content'] .= "\n<br/>" . Skin::cap(Codes::beautify($item['description']), 500) . "\n";
         }
         // the menu bar for associates and poster
         if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) {
             $menu = array('links/edit.php?id=' . $item['id'] => i18n::s('Edit'), 'links/delete.php?id=' . $item['id'] => i18n::s('Delete'));
             $box['content'] .= ' ' . Skin::build_list($menu, 'menu');
         }
         // append details to the suffix
         $box['content'] .= BR . '<span class="details">';
         // details
         $details = array();
         // item poster
         if (Surfer::is_member()) {
             if ($item['edit_name']) {
                 $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
             }
         } else {
             $details[] = Anchors::get_action_label($item['edit_action']);
         }
         // show an anchor link
         if ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
             $anchor_url = $anchor->get_url();
             $anchor_label = ucfirst($anchor->get_title());
             $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor_url, $anchor_label));
         }
         // all details
         $box['content'] .= ucfirst(trim(implode(' ', $details))) . "\n";
         // end of details
         $box['content'] .= '</span><br/><br/>';
     }
     // close the on-going box
     if ($in_north) {
         $text .= '<div class="newest">' . "\n";
     }
     $text .= Skin::build_box($box['title'], $box['content']);
     if ($in_north) {
         $text .= '</div>' . "\n";
     }
     // end of processing
     SQL::free($result);
     return $text;
 }
开发者ID:rair,项目名称:yacs,代码行数:97,代码来源:layout_links_as_daily.php

示例14: elseif

} elseif (Surfer::is_logged() && is_object($anchor) && $anchor->is_assigned()) {
    Surfer::empower('S');
} elseif (isset($item['id']) && Articles::is_assigned($item['id']) && Surfer::is_logged()) {
    Surfer::empower('S');
} elseif (isset($item['options']) && $item['options'] && preg_match('/\\banonymous_edit\\b/i', $item['options'])) {
    Surfer::empower();
} elseif (Surfer::is_member() && isset($item['options']) && $item['options'] && preg_match('/\\bmembers_edit\\b/i', $item['options'])) {
    Surfer::empower();
} elseif (isset($item['handle']) && Surfer::may_handle($item['handle'])) {
    Surfer::empower();
}
//
// is this surfer allowed to browse the page?
//
// associates, editors and readers can read this page
if (Surfer::is_empowered('S')) {
    $permitted = TRUE;
} elseif (isset($item['create_id']) && Surfer::is($item['create_id'])) {
    $permitted = TRUE;
} elseif (is_object($anchor) && !$anchor->is_viewable()) {
    $permitted = FALSE;
} elseif (isset($item['active']) && $item['active'] == 'R' && Surfer::is_logged()) {
    $permitted = TRUE;
} elseif (isset($item['active']) && $item['active'] == 'Y') {
    $permitted = TRUE;
} else {
    $permitted = FALSE;
}
// load localized strings
i18n::bind('overlays');
// load the skin, maybe with a variant
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:fetch_as_csv.php

示例15: NOT

 /**
  * thread newest comments
  *
  * Result of this query should be processed with a layout adapted to articles
  *
  * @param int the offset from the start of the list; usually, 0 or 1
  * @param int the number of items to display
  * @param string the list variant, if any
  * @return NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
  *
  * @see comments/index.php
  */
 public static function &list_threads_by_date_for_anchor($anchor, $offset = 0, $count = 10, $variant = 'date')
 {
     global $context;
     // restrict the query to addressable content
     $where = Articles::get_sql_where();
     // provide published pages to anonymous surfers
     if (!Surfer::is_logged()) {
         $where .= " AND NOT ((articles.publish_date is NULL) OR (articles.publish_date <= '0000-00-00'))" . " AND (articles.publish_date < '" . $context['now'] . "')";
         // logged surfers that are non-associates are restricted to their own articles, plus published articles
     } elseif (!Surfer::is_empowered()) {
         $where .= " AND ((articles.create_id=" . Surfer::get_id() . ") OR (NOT ((articles.publish_date is NULL) OR (articles.publish_date <= '0000-00-00'))" . " AND (articles.publish_date < '" . $context['now'] . "')))";
     }
     // only consider live articles for non-associates
     if (!Surfer::is_empowered()) {
         $where .= " AND ((articles.expiry_date is NULL) " . "OR (articles.expiry_date <= '" . NULL_DATE . "') OR (articles.expiry_date > '" . $context['now'] . "'))";
     }
     // if not associate, restrict to comments at public published not expired pages
     if (!Surfer::is_associate()) {
         $where = " AND NOT ((articles.publish_date is NULL) OR (articles.publish_date <= '0000-00-00'))" . " AND ((articles.expiry_date is NULL)" . "\tOR (articles.expiry_date <= '" . NULL_DATE . "') OR (articles.expiry_date > '" . gmstrftime('%Y-%m-%d %H:%M:%S') . "'))";
     }
     // avoid blank records on join
     $where .= ' AND (articles.id > 0)';
     // several anchors
     if (is_array($anchor)) {
         $items = array();
         foreach ($anchor as $token) {
             $items[] = "articles.anchor LIKE '" . SQL::escape($token) . "'";
         }
         $where_anchor = join(' OR ', $items);
     } else {
         $where_anchor = "articles.anchor LIKE '" . SQL::escape($anchor) . "'";
     }
     // the list of comments
     $query = "SELECT articles.* FROM " . SQL::table_name('comments') . " AS comments" . ", " . SQL::table_name('articles') . " AS articles" . " WHERE ((comments.anchor_type LIKE 'article') AND (comments.anchor_id = articles.id))" . "\tAND (" . $where_anchor . ") AND " . $where . " GROUP BY articles.id" . " ORDER BY articles.edit_date DESC LIMIT " . $offset . ',' . $count;
     // return a list of articles
     $output =& Articles::list_selected(SQL::query($query), $variant);
     return $output;
 }
开发者ID:rair,项目名称:yacs,代码行数:50,代码来源:comments.php


注:本文中的Surfer::is_empowered方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。