本文整理汇总了PHP中Surfer::is_logged方法的典型用法代码示例。如果您正苦于以下问题:PHP Surfer::is_logged方法的具体用法?PHP Surfer::is_logged怎么用?PHP Surfer::is_logged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Surfer
的用法示例。
在下文中一共展示了Surfer::is_logged方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: layout
/**
* list users
*
* @param resource the SQL result
* @return array of ($nick_name => $more)
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($nick_name => $more)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// process all items in the list
while ($item = SQL::fetch($result)) {
// unique identifier
$key = $item['nick_name'];
// use the full name, if nick name is not part of it
$more = '';
if ($item['full_name'] && !preg_match('/\\b' . preg_quote($item['nick_name'], '/') . '\\b/', $item['full_name'])) {
$more = ucfirst($item['full_name']) . ' ';
}
// else use e-mail address, if any --but only to authenticated surfer
if ($item['email'] && Surfer::is_logged()) {
if ($more) {
$more .= '<' . $item['email'] . '>';
} else {
$more .= $item['email'];
}
} elseif ($item['introduction']) {
$more .= $item['introduction'];
}
// record this item
$items[$key] = $more;
}
// end of processing
SQL::free($result);
return $items;
}
示例2: add_commands
/**
* extend the page menu
*
* @param string script name
* @param string target anchor, if any
* @param array current menu
* @return array updated menu
*/
function add_commands($script, $anchor, $menu = array())
{
global $context;
// limit the scope of our check to viewed pages
if (!preg_match('/articles\\/view/', $script)) {
return $menu;
}
// surfer has to be authenticated
if (!Surfer::is_logged()) {
return $menu;
}
// sanity checks
if (!$anchor) {
Logger::error(i18n::s('No anchor has been found.'));
} elseif (!($target = Anchors::get($anchor))) {
Logger::error(i18n::s('No anchor has been found.'));
} elseif (!$this->parameters) {
Logger::error(sprintf(i18n::s('No parameter has been provided to %s'), 'behaviors/move_on_article_access'));
} else {
// look at parent container if possible
if (!($origin = Anchors::get($target->get_parent()))) {
$origin = $target;
}
// only container editors can proceed
if ($origin->is_assigned() || Surfer::is_associate()) {
// load target section
$tokens = explode(' ', $this->parameters, 2);
if ($section = Anchors::get('section:' . $tokens[0])) {
// make a label
if (count($tokens) < 2) {
$tokens[1] = sprintf(i18n::s('Move to %s'), $section->get_title());
}
// the target link to move the page
$link = Articles::get_url(str_replace('article:', '', $anchor), 'move', str_replace('section:', '', $section->get_reference()));
// make a sub-menu
$menu = array_merge(array($link => array('', $tokens[1], '', 'button')), $menu);
}
}
}
return $menu;
}
示例3: layout
/**
* list articles for manual review
*
* @param resource the SQL result
* @return string the rendered text
*
* @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;
}
// process all items in the list
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// 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);
// 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 = '';
// flag sticky pages
if ($item['rank'] < 10000) {
$prefix .= STICKY_FLAG;
}
// signal locked articles
if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
$suffix .= ' ' . LOCKED_FLAG;
}
// flag articles that are dead, or created or updated very recently
if ($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 articles to be published
if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
$prefix .= DRAFT_FLAG;
}
// signal restricted and private articles
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// details
$details = array();
// the author(s)
if ($item['create_name'] != $item['edit_name']) {
$details[] = sprintf(i18n::s('by %s, %s'), $item['create_name'], $item['edit_name']);
} else {
$details[] = sprintf(i18n::s('by %s'), $item['create_name']);
}
// the last action
$details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']);
// the number of hits
if (Surfer::is_logged() && $item['hits'] > 1) {
$details[] = Skin::build_number($item['hits'], i18n::s('hits'));
}
// info on related files
if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
}
// info on related links
if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
}
// info on related comments
if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
}
// append details to the suffix
$suffix .= ' - <span class="details">' . ucfirst(trim(implode(', ', $details))) . '</span>';
// commands to review the article
$menu = array();
// read the page
$menu = array_merge($menu, array($url => i18n::s('Read')));
// validate the page
$menu = array_merge($menu, array('articles/stamp.php?id=' . $item['id'] . '&confirm=review' => i18n::s('Validate')));
// add a menu
$suffix .= ' ' . Skin::build_list($menu, 'menu');
// list all components for this item
$items[$url] = array($prefix, $title, $suffix, 'basic', NULL);
}
//.........这里部分代码省略.........
示例4: allow_trackback
/**
* check if trackback is allowed
*
* This function returns TRUE either if the surfer has been authenticated,
* or if the site is visible from the Internet.
*
* @return boolean TRUE or FALSE
*/
public static function allow_trackback()
{
global $context;
// site is visible from the Internet
if (!isset($context['without_internet_visibility']) || $context['without_internet_visibility'] != 'Y') {
return TRUE;
}
// surfer has been authenticated, provide trackback shortcut
if (Surfer::is_logged()) {
return TRUE;
}
}
示例5: layout
/**
* list articles for search requests
*
* @param resource the SQL result
* @return array of resulting items ($score, $summary), or NULL
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of array($score, $summary)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// process all items in the list
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// one box at a time
$box = '';
// get the related overlay, if any
$overlay = Overlay::load($item, 'article:' . $item['id']);
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// the url to view this item
$url = Articles::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 sticky pages
if ($item['rank'] < 10000) {
$prefix .= STICKY_FLAG;
}
// signal locked articles
if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
$suffix .= ' ' . LOCKED_FLAG;
}
// flag articles that are dead, or created or updated very recently
if ($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 articles to be published
if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
$prefix .= DRAFT_FLAG;
}
// signal restricted and private articles
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// introduction
$introduction = '';
if (is_object($overlay)) {
$introduction = $overlay->get_text('introduction', $item);
} else {
$introduction = $item['introduction'];
}
// the introductory text
if ($introduction) {
$suffix .= ' - ' . Codes::beautify_introduction($introduction);
// link to description, if any
if ($item['description']) {
$suffix .= ' ' . Skin::build_link($url, MORE_IMG, 'more', i18n::s('View the page')) . ' ';
}
}
// insert overlay data, if any
if (is_object($overlay)) {
$suffix .= $overlay->get_text('list', $item);
}
// details
$details = array();
// the author
if ($item['create_name'] != $item['edit_name']) {
$details[] = sprintf(i18n::s('by %s, %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']));
} else {
$details[] = sprintf(i18n::s('by %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']));
}
// the last action
$details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']);
// the number of hits
if (Surfer::is_logged() && $item['hits'] > 1) {
$details[] = Skin::build_number($item['hits'], i18n::s('hits'));
}
// info on related files
if ($count = Files::count_for_anchor('article:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
}
//.........这里部分代码省略.........
示例6: gmstrftime
$_REQUEST['create_name'] = $_REQUEST['edit_name'];
if (!$_REQUEST['create_name']) {
$_REQUEST['create_name'] = $_REQUEST['create_address'];
}
if (!$_REQUEST['create_name']) {
$_REQUEST['create_name'] =& i18n::c('(anonymous)');
}
// always auto-publish queries
$_REQUEST['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S');
if (isset($_REQUEST['edit_id'])) {
$_REQUEST['publish_id'] = $_REQUEST['edit_id'];
}
$_REQUEST['publish_address'] = $_REQUEST['edit_address'];
$_REQUEST['publish_name'] = $_REQUEST['edit_name'];
// show e-mail address of anonymous surfer
if ($_REQUEST['edit_address'] && !Surfer::is_logged()) {
$_REQUEST['description'] = '<p>' . sprintf(i18n::c('Sent by %s'), '[email=' . ($_REQUEST['edit_name'] ? $_REQUEST['edit_name'] : i18n::c('e-mail')) . ']' . $_REQUEST['edit_address'] . '[/email]') . "</p>\n" . $_REQUEST['description'];
}
// stop robots
if (Surfer::may_be_a_robot()) {
Logger::error(i18n::s('Please prove you are not a robot.'));
$with_form = TRUE;
// display the form on error
} elseif (!($_REQUEST['id'] = Articles::post($_REQUEST))) {
$with_form = TRUE;
// post-processing
} else {
// do whatever is necessary on page publication
Articles::finalize_publication($anchor, $_REQUEST);
// message to the query poster
$context['page_title'] = i18n::s('Your query has been registered');
示例7: elseif
include_once '../shared/global.php';
// users are assigned to this anchor, passed as member
$anchor = NULL;
if (isset($_REQUEST['member'])) {
$anchor = Anchors::get($_REQUEST['member']);
} elseif (isset($_REQUEST['anchor'])) {
$anchor = Anchors::get($_REQUEST['anchor']);
}
// only looking at watchers
if (isset($_REQUEST['anchor']) && !isset($_REQUEST['action'])) {
$permitted = 'watchers';
} elseif (Surfer::is_associate()) {
$permitted = 'all';
} elseif (is_object($anchor) && Surfer::get_id() && $anchor->get_reference() == 'user:' . Surfer::get_id()) {
$permitted = 'all';
} elseif (Surfer::is_logged() && is_object($anchor) && $anchor->is_owned()) {
$permitted = 'all';
} elseif (is_object($anchor) && $anchor->is_viewable()) {
$permitted = 'editors';
} else {
$permitted = FALSE;
}
// load the skin, maybe with a variant
load_skin('users', $anchor);
// the path to this page
if (is_object($anchor) && $anchor->is_viewable()) {
$context['path_bar'] = $anchor->get_path_bar();
} else {
$context['path_bar'] = array('users/' => i18n::s('People'));
}
// an anchor is mandatory
示例8: stat_for_anchor
/**
* get some statistics for some sections
*
* 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 hidden (active='N'), but surfer is an associate
*
* Non-activated and expired sections are counted as well.
*
* @param string the selected anchor (e.g., 'section:12')
* @return array the resulting ($count, $min_date, $max_date) array
*
* @see sections/delete.php
* @see sections/index.php
* @see sections/layout_sections.php
* @see sections/layout_sections_as_yahoo.php
* @see sections/view.php
*/
public static function stat_for_anchor($anchor = '')
{
global $context;
// limit the query to one level
if ($anchor) {
$where = "(sections.anchor LIKE '" . SQL::escape($anchor) . "')";
} else {
$where = "(sections.anchor='' OR sections.anchor is NULL)";
}
// show everything if we are about to suppress a section
if (!preg_match('/delete\\.php/', $context['script_url'])) {
// display active and restricted items
$where .= "AND (sections.active='Y'";
// list restricted sections to authenticated surfers
if (Surfer::is_logged()) {
$where .= " OR sections.active='R'";
}
// list hidden sections to associates, editors and readers
if (Surfer::is_empowered('S')) {
$where .= " OR sections.active='N'";
}
$where .= ")";
// hide sections removed from index maps
$where .= " AND (sections.index_map = 'Y')";
// non-associates will have only live sections
if ($anchor && !Surfer::is_empowered()) {
$where .= " AND ((sections.activation_date is NULL)" . "\tOR (sections.activation_date <= '" . $context['now'] . "'))" . " AND ((sections.expiry_date is NULL)" . "\tOR (sections.expiry_date <= '" . NULL_DATE . "') OR (sections.expiry_date > '" . $context['now'] . "'))";
}
}
// list sections
$query = "SELECT COUNT(*) as count, MIN(edit_date) as oldest_date, MAX(edit_date) as newest_date" . " FROM " . SQL::table_name('sections') . " AS sections" . " WHERE " . $where;
$output = SQL::query_first($query);
return $output;
}
示例9: layout
/**
* list files
*
* @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 = '';
}
// 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 = '';
// more details
$url = Files::get_permalink($item);
// codes
$codes = array();
// files that can be embedded
if (preg_match('/\\.(3gp|flv|gan|m4v|mm|mov|mp4|swf)$/i', $item['file_name'])) {
$codes[] = '[embed=' . $item['id'] . ']';
}
// link for direct download
$codes[] = '[file=' . $item['id'] . ']';
$codes[] = '[download=' . $item['id'] . ']';
// integrate codes
if (!isset($_SESSION['surfer_editor']) || $_SESSION['surfer_editor'] == 'yacs') {
foreach ($codes as $code) {
$suffix .= '<a onclick="edit_insert(\'\', \' ' . $code . '\');return false;" title="insert" tabindex="2000">' . $code . '</a> ';
}
} else {
$suffix .= join(' ', $codes);
}
$suffix .= BR . '<span class="details">';
// signal restricted and private files
if ($item['active'] == 'N') {
$suffix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$suffix .= RESTRICTED_FLAG;
}
// file title or file name
$label = Codes::beautify_title($item['title']);
if (!$label) {
$label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name']));
}
$suffix .= $label;
// flag files uploaded recently
if ($item['create_date'] >= $context['fresh']) {
$suffix .= NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= UPDATED_FLAG;
}
$suffix .= '</span>';
// details
$details = array();
if (Surfer::is_logged() && $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 menu bar for associates and poster
if (Surfer::is_empowered()) {
$details[] = Skin::build_link($url, i18n::s('details'), 'basic');
$details[] = Skin::build_link(Files::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic');
$details[] = Skin::build_link(Files::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic');
}
// append details
if (count($details)) {
$suffix .= BR . Skin::finalize_list($details, 'menu');
}
// explicit icon
if ($item['thumbnail_url']) {
$icon = $item['thumbnail_url'];
} else {
$icon = $context['url_to_root'] . Files::get_icon_url($item['file_name']);
}
// list all components for this item
$items[$url] = array($prefix, '_', $suffix, 'file', $icon);
}
// end of processing
SQL::free($result);
return $items;
}
示例10: layout
/**
* list tables
*
* Recognize following variants:
* - 'no_anchor' to list items attached to one particular anchor
*
* @param resource the SQL result
* @return array one item per image
*
* @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;
}
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 = '';
// the url to view this item
$url = Tables::get_url($item['id']);
// codes to embed this image
if ($anchor && $this->focus == $anchor->get_reference()) {
// codes
$codes = array();
$codes[] = '[table=' . $item['id'] . ']';
$codes[] = '[table.filter=' . $item['id'] . ']';
$codes[] = '[table.chart=' . $item['id'] . ']';
$codes[] = '[table.bars=' . $item['id'] . ']';
$codes[] = '[table.line=' . $item['id'] . ']';
// integrate codes
if (!isset($_SESSION['surfer_editor']) || $_SESSION['surfer_editor'] == 'yacs') {
foreach ($codes as $code) {
$suffix .= '<a onclick="edit_insert(\'\', \' ' . $code . '\');return false;" title="insert" tabindex="2000">' . $code . '</a> ';
}
} else {
$suffix .= join(' ', $codes);
}
$suffix .= BR;
}
// we are listing tables attached to an chor
if ($anchor && $this->focus == $anchor->get_reference()) {
$label = '_';
// the title
if ($item['title']) {
$suffix .= Skin::strip($item['title'], 10);
}
// an index of tables
} else {
// the title
if ($item['title']) {
$label = Skin::strip($item['title'], 10);
}
}
// flag tables created or updated very recently
if (isset($item['create_date']) && $item['create_date'] >= $context['fresh']) {
$suffix .= NEW_FLAG;
} elseif (isset($item['edit_date']) && $item['edit_date'] >= $context['fresh']) {
$suffix .= UPDATED_FLAG;
}
// details
$details = array();
if (Surfer::is_associate() && $item['nick_name']) {
$details[] = '"' . $item['nick_name'] . '"';
}
if (Surfer::is_logged() && $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 menu bar for associates and poster
if (Surfer::is_empowered()) {
$details[] = Skin::build_link(Tables::get_url($item['id'], 'view'), i18n::s('details'), 'basic');
$details[] = Skin::build_link(Tables::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic');
$details[] = Skin::build_link(Tables::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic');
}
// append details
if (count($details)) {
$suffix .= BR . Skin::finalize_list($details, 'menu');
}
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, 'table', $icon);
}
// end of processing
SQL::free($result);
return $items;
}
示例11: 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;
}
示例12: allow_creation
//.........这里部分代码省略.........
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;
}
// anchor has been locked --only used when there is no item provided
if (!isset($item['id']) && is_object($anchor) && $anchor->has_option('locked')) {
return FALSE;
}
// not for subscribers
if (Surfer::is_member()) {
// surfer is an editor (and item has not been locked)
if ($variant == 'article' && isset($item['id']) && Articles::is_assigned($item['id'])) {
return TRUE;
}
// surfer is assigned to parent container
if (is_object($anchor) && $anchor->is_assigned()) {
return TRUE;
}
}
// container is hidden
if (isset($item['active']) && $item['active'] == 'N') {
return FALSE;
}
if (is_object($anchor) && $anchor->is_hidden()) {
return FALSE;
}
// authenticated members are allowed to add images to pages
if ($variant == 'article' && Surfer::is_logged()) {
return TRUE;
}
// container is restricted
if (isset($item['active']) && $item['active'] == 'R') {
return FALSE;
}
if (is_object($anchor) && !$anchor->is_public()) {
return FALSE;
}
// anonymous contributions are allowed for articles
if ($variant == 'article') {
if (isset($item['options']) && preg_match('/\\banonymous_edit\\b/i', $item['options'])) {
return TRUE;
}
if (is_object($anchor) && $anchor->has_option('anonymous_edit')) {
return TRUE;
}
}
// the default is to not allow for new images
return FALSE;
}
示例13: array
$label = i18n::s('Its title');
$input = '<input type="text" name="title" size="45" maxlength="255" />';
$hint = i18n::s('The title of your page');
$fields[] = array($label, $input, $hint);
// the excerpt
$label = i18n::s('Excerpt or description');
$input = '<textarea name="excerpt" rows="5" cols="50"></textarea>';
$hint = i18n::s('As this field may be searched by surfers, please choose adequate searchable words');
$fields[] = array($label, $input, $hint);
// the blog name
$label = i18n::s('Blog name or section');
$input = '<input type="text" name="blog_name" size="45" value="' . encode_field($blog_name) . '" maxlength="64" />';
$hint = i18n::s('To complement the excerpt');
$fields[] = array($label, $input, $hint);
// random string to stop robots
if (!Surfer::is_logged() && ($field = Surfer::get_robot_stopper())) {
$fields[] = $field;
}
// build the form
$text .= Skin::build_form($fields);
// the submit button
$text .= '<p>' . Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's') . '</p>';
// other hidden fields
$text .= '<input type="hidden" name="anchor" value="' . $anchor->get_reference() . '" />';
// end of the form
$text .= '</div></form>';
// the script used for form handling at the browser
Page::insert_script('func' . 'tion validateDocumentPost(container) {' . "\n" . ' if(!container.url.value) {' . "\n" . ' alert("' . i18n::s('Please type a valid link.') . '");' . "\n" . ' Yacs.stopWorking();' . "\n" . ' return false;' . "\n" . ' }' . "\n" . ' if(!container.title.value) {' . "\n" . ' alert("' . i18n::s('Please provide a meaningful title.') . '");' . "\n" . ' Yacs.stopWorking();' . "\n" . ' return false;' . "\n" . ' }' . "\n" . ' if(!container.exceprt.value) {' . "\n" . ' alert("' . i18n::s('You must type an excerpt of the referencing page.') . '");' . "\n" . ' Yacs.stopWorking();' . "\n" . ' return false;' . "\n" . ' }' . "\n" . ' if(!container.blog_name.value) {' . "\n" . ' alert("' . i18n::s('You must name the originating blog.') . '");' . "\n" . ' Yacs.stopWorking();' . "\n" . ' return false;' . "\n" . ' }' . "\n" . ' return true;' . "\n" . '}' . "\n" . '$("#url").focus();' . "\n");
// trackback link
$label = i18n::s('Trackback address:');
$value = $context['url_to_home'] . $context['url_to_root'] . 'links/trackback.php?anchor=' . $anchor->get_reference();
示例14: function
}
// the submit button
$menu[] = Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's', 'submit');
// go to smileys
// $menu[] = Skin::build_link('smileys/', i18n::s('Smileys'), 'open');
// display all commands
$context['text'] .= Skin::finalize_list($menu, 'menu_bar');
// end the form
$context['text'] .= '</form>' . "\n";
}
// end of the wrapper
$context['text'] .= '</div>' . "\n";
// the AJAX part
$js_script = 'var Comments = {' . "\n" . "\n" . ' url: "' . $context['url_to_home'] . $context['url_to_root'] . Comments::get_url($item['id'], 'thread') . '",' . "\n" . ' timestamp: 0,' . "\n" . "\n" . ' initialize: function() { },' . "\n" . "\n" . ' contribute: function() {' . "\n" . ' Yacs.startWorking();' . "\n" . ' $("#upload_frame").load(Comments.contributed);' . "\n" . ' return true;' . "\n" . ' },' . "\n" . "\n" . ' contributed: function() {' . "\n" . ' $("#upload_frame").unbind("load");' . "\n" . ' $("#comment_upload").slideUp(600);' . "\n" . ' $("#upload_option").slideUp();' . "\n" . ' $("#upload").replaceWith(\'<input type="file" id="upload" name="upload" size="30" />\');' . "\n" . ' $("#description").val("").trigger("change").focus();' . "\n" . ' setTimeout(function() {Comments.subscribe(); Yacs.stopWorking();}, 500);' . "\n" . ' if((typeof OpenTok == "object") && OpenTok.session)' . "\n" . ' OpenTok.signal();' . "\n" . ' },' . "\n" . "\n" . ' keypress: function(event) {' . "\n" . ' if(event.which == 13) {' . "\n" . ' $("#submit").trigger("click");' . "\n" . ' return false;' . "\n" . ' }' . "\n" . ' },' . "\n" . "\n" . ' showMore: function() {' . "\n" . ' var options = {};' . "\n" . ' var newHeight = $("#thread_text_panel").clientHeight + 200;' . "\n" . ' options.height = newHeight + "px";' . "\n" . ' options.maxHeight = newHeight + "px";' . "\n" . ' $("#thread_text_panel").css(options);' . "\n" . ' },' . "\n" . "\n" . ' subscribe: function() {' . "\n" . ' $.ajax(Comments.url, {' . "\n" . ' type: "get",' . "\n" . ' dataType: "json",' . "\n" . ' data: { "timestamp" : Comments.timestamp },' . "\n" . ' success: Comments.updateOnSuccess' . "\n" . ' });' . "\n" . "\n" . ' },' . "\n" . "\n" . ' subscribeToExtraUpdates: function() {' . "\n" . ' $.ajax("' . $context['url_to_home'] . $context['url_to_root'] . Users::get_url($item['id'], 'visit') . '", {' . "\n" . ' type: "get",' . "\n" . ' dataType: "html",' . "\n" . ' success: function(data) { $("#thread_roster_panel").html(data); }' . "\n" . ' });' . "\n" . "\n" . ' $.ajax("' . $context['url_to_home'] . $context['url_to_root'] . Files::get_url($item['id'], 'thread') . '", {' . "\n" . ' type: "get",' . "\n" . ' dataType: "html",' . "\n" . ' success: function(data) { $("#thread_files_panel").html(data); }' . "\n" . ' });' . "\n" . "\n" . ' },' . "\n" . "\n" . ' updateOnSuccess: function(response) {' . "\n" . ' if(!response) return;' . "\n" . ' if(response["status"] != "started")' . "\n" . ' window.location.reload(true);' . "\n" . ' $("#thread_text_panel").html("<div>" + response["items"] + "</div>");' . "\n" . ' var div = $("#thread_text_panel")[0];' . "\n" . ' var scrollHeight = Math.max(div.scrollHeight, div.clientHeight);' . "\n" . ' div.scrollTop = scrollHeight - div.clientHeight;' . "\n" . ' if(typeof Comments.windowOriginalTitle != "string")' . "\n" . ' Comments.windowOriginalTitle = document.title;' . "\n" . ' document.title = "[" + response["name"] + "] " + Comments.windowOriginalTitle;' . "\n" . ' Comments.timestamp = response["timestamp"];' . "\n" . ' }' . "\n" . "\n" . '}' . "\n" . "\n" . '// wait for new comments and for other updates' . "\n" . 'Comments.subscribeTimer = setInterval("Comments.subscribe()", 5000);' . "\n" . 'Comments.subscribeTimer = setInterval("Comments.subscribeToExtraUpdates()", 59999);' . "\n" . "\n" . '// load past contributions asynchronously' . "\n" . '$(function() {' . 'Comments.subscribe();' . 'location.hash="#thread_text_panel";' . '$("#description").tipsy({gravity: "s", fade: true, title: function () {return "' . i18n::s('Contribute here') . '";}, trigger: "manual"});' . '$("#description").tipsy("show");' . 'setTimeout("$(\'#description\').tipsy(\'hide\');", 10000);' . '$("textarea#description").autogrow();' . '});' . "\n";
// only authenticated surfers can contribute
if (Surfer::is_logged() && Comments::allow_creation($item, $anchor)) {
$js_script .= '$(function() {' . '$("#description").focus();' . '});' . "\n" . '$(\'#description\').keypress( Comments.keypress );' . "\n";
}
break;
Page::insert_script($js_script);
case 'excluded':
// surfer is not
$context['text'] .= Skin::build_block(i18n::s('You have not been enrolled into this interactive chat.'), 'caution');
break;
}
//
// trailer information
//
// add trailer information from the overlay, if any --opentok videos come from here
if (is_object($overlay)) {
$context['text'] .= $overlay->get_text('trailer', $item);
示例15: array
$label = i18n::s('Section');
$input = '<select name="anchor">' . Sections::get_options(NULL, 'bookmarks') . '</select>';
$hint = i18n::s('Please carefully select a section for your link');
$fields[] = array($label, $input, $hint);
// allow for section change
} elseif ($item['id'] && preg_match('/section:/', $current = $anchor->get_reference())) {
$label = i18n::s('Section');
$input = '<select name="anchor">' . Sections::get_options($current, NULL) . '</select>';
$hint = i18n::s('Please carefully select a section for your link');
$fields[] = array($label, $input, $hint);
// else preserve the previous anchor
} elseif (is_object($anchor)) {
$context['text'] .= '<input type="hidden" name="anchor" value="' . $anchor->get_reference() . '" />';
}
// additional fields for anonymous surfers
if (!isset($item['id']) && !Surfer::is_logged()) {
// splash
if (isset($item['id'])) {
if (is_object($anchor)) {
$login_url = $context['url_to_root'] . 'users/login.php?url=' . urlencode('links/edit.php?id=' . $item['id'] . '&anchor=' . $anchor->get_reference());
} else {
$login_url = $context['url_to_root'] . 'users/login.php?url=' . urlencode('links/edit.php?id=' . $item['id']);
}
} else {
if (is_object($anchor)) {
$login_url = $context['url_to_root'] . 'users/login.php?url=' . urlencode('links/edit.php?anchor=' . $anchor->get_reference());
} else {
$login_url = $context['url_to_root'] . 'users/login.php?url=' . urlencode('links/edit.php');
}
}
$context['text'] .= '<p>' . sprintf(i18n::s('If you have previously registered to this site, please %s. Then the server will automatically put your name and address in following fields.'), Skin::build_link($login_url, i18n::s('authenticate'))) . "</p>\n";