本文整理汇总了PHP中Surfer::is_associate方法的典型用法代码示例。如果您正苦于以下问题:PHP Surfer::is_associate方法的具体用法?PHP Surfer::is_associate怎么用?PHP Surfer::is_associate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Surfer
的用法示例。
在下文中一共展示了Surfer::is_associate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_fields
/**
* preserve content across page modification
*
* @see overlays/overlay.php
*
* @param the hosting attributes
* @return a list of ($label, $input, $hint)
*/
function get_fields($host, $field_pos = NULL)
{
global $context;
// form fields
$fields = array();
// item identifier
if (!isset($this->attributes['overlay_id'])) {
$this->attributes['overlay_id'] = '';
}
// only associates can change the overlay id
if (Surfer::is_associate()) {
// isset($host['anchor']) && ($parent =& Anchors::get($host['anchor'])) && $parent->is_assigned()) {
$label = i18n::s('Overlay identifier');
$input = '<input type="text" name="overlay_id" value="' . encode_field($this->attributes['overlay_id']) . '" />';
} else {
$label = 'hidden';
$input = '<input type="hidden" name="overlay_id" value="' . encode_field($this->attributes['overlay_id']) . '" />';
}
// hidden attributes
foreach ($this->attributes as $name => $value) {
if (preg_match('/_content$/', $name)) {
$input .= '<input type="hidden" name="' . encode_field($name) . '" value="' . encode_field($value) . '" />';
}
}
// we do have something to preserve
$fields[] = array($label, $input);
// job done
return $fields;
}
示例2: allow_creation
/**
* Check if surfer is allowed to add sub-categories
*
* @param string $type
* @return boolean
*/
function allow_creation($type = '')
{
// surfer as to be a associate or editor of the category
if ($this->is_assigned() || Surfer::is_associate()) {
return TRUE;
}
return FALSE;
}
示例3: 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;
}
示例4: sprintf
$context['text'] .= $rows;
}
}
// biggest files
if (Surfer::is_associate() && ($rows = Files::list_by_size(0, 25, 'full'))) {
$context['text'] .= Skin::build_block(i18n::s('Biggest files'), 'title');
if (is_array($rows)) {
$context['text'] .= Skin::build_list($rows, 'decorated');
} else {
$context['text'] .= $rows;
}
}
// list files with very few hits
if (Surfer::is_associate() && ($rows = Files::list_unused(0, 25))) {
$context['text'] .= Skin::build_block(i18n::s('Less downloaded files'), 'title');
if (is_array($rows)) {
$context['text'] .= Skin::build_list($rows, 'decorated');
} else {
$context['text'] .= $rows;
}
}
// size of noise words
if (Surfer::is_associate() && is_readable($context['path_to_root'] . 'files/noise_words.php')) {
include_once $context['path_to_root'] . 'files/noise_words.php';
if (@count($noise_words)) {
$context['text'] .= '<p>' . sprintf(i18n::s('%d items in the list of noise words'), count($noise_words)) . '</p>';
}
}
}
// render the skin
render_skin();
示例5: foreach
// news
$context['components']['news'] = $text;
// list extra boxes
$text = '';
if ($anchor = Sections::lookup('extra_boxes')) {
// the maximum number of boxes is a global parameter
if (!isset($context['site_extra_maximum']) || !$context['site_extra_maximum']) {
$context['site_extra_maximum'] = 7;
}
// articles to be displayed as extra boxes
if ($items =& Articles::list_for_anchor_by('publication', $anchor, 0, $context['site_extra_maximum'], 'boxes')) {
foreach ($items as $title => $attributes) {
$text .= Skin::build_box($title, $attributes['content'], 'boxes', $attributes['id']) . "\n";
}
}
}
// boxes
$context['components']['boxes'] = $text;
// referrals, if any
if (Surfer::is_associate() || isset($context['with_referrals']) && $context['with_referrals'] == 'Y') {
$context['components']['referrals'] =& Skin::build_referrals('index.php');
}
//
// compute navigation information -- $context['navigation']
//
// a meta link to a feeding page
$context['page_header'] .= "\n" . '<link rel="alternate" href="' . $context['url_to_root'] . Feeds::get_url('rss') . '" title="RSS" type="application/rss+xml" />';
// a meta link to our blogging interface
$context['page_header'] .= "\n" . '<link rel="EditURI" href="' . $context['url_to_home'] . $context['url_to_root'] . 'services/describe.php" title="RSD" type="application/rsd+xml" />';
// render the skin
render_skin();
示例6: strip_tags
}
$vote = strip_tags($vote);
// next url
$next = '';
if (isset($_REQUEST['next'])) {
$next = $_REQUEST['next'];
}
if (isset($context['arguments'][2])) {
$next = $context['arguments'][2];
}
$next = strip_tags($next);
//
// is this surfer allowed to browse the resulting page?
//
// associates and editors can do what they want
if (Surfer::is_associate() || Articles::is_assigned($id) || is_object($anchor) && $anchor->is_assigned()) {
$permitted = TRUE;
} elseif (Surfer::get_id() && isset($item['create_id']) && $item['create_id'] == Surfer::get_id()) {
$permitted = TRUE;
} elseif (is_object($anchor) && !$anchor->is_viewable()) {
$permitted = FALSE;
} elseif (isset($item['active']) && $item['active'] == 'R' && Surfer::is_member()) {
$permitted = TRUE;
} elseif (isset($item['active']) && $item['active'] == 'Y') {
$permitted = TRUE;
} else {
$permitted = FALSE;
}
// load the skin, maybe with a variant
load_skin('polls', $anchor);
// the path to this page
示例7: stat
/**
* get some statistics
*
* @return the resulting ($count, $min_date, $max_date) array
*
* @see links/index.php
*/
public static function stat()
{
global $context;
// if not associate, restrict to links attached to public published not expired pages
if (!Surfer::is_associate()) {
$where = ", " . SQL::table_name('articles') . " AS articles " . " WHERE ((links.anchor_type LIKE 'article') AND (links.anchor_id = articles.id))" . " AND (articles.active='Y')" . " 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') . "'))" . " AND (links.edit_id > 0)";
} else {
$where = "WHERE (links.edit_id > 0)";
}
// select among available items
$query = "SELECT COUNT(links.link_url) as count, MIN(links.edit_date) as oldest_date, MAX(links.edit_date) as newest_date" . " FROM " . SQL::table_name('links') . " AS links " . $where;
$output = SQL::query_first($query);
return $output;
}
示例8: ucfirst
}
// page details
if (is_array($details)) {
$context['text'] .= '<p class="details">' . ucfirst(implode(', ', $details)) . "</p>\n";
}
// insert anchor suffix
if (is_object($anchor)) {
$context['text'] .= $anchor->get_suffix();
}
// back to the anchor page
if (is_object($anchor) && $anchor->is_viewable()) {
$menu = array(Skin::build_link($anchor->get_url(), i18n::s('Back to main page'), 'button'));
$context['text'] .= Skin::build_block(Skin::finalize_list($menu, 'menu_bar'), 'bottom');
}
//
// populate the extra panel
//
// commands for associates and editors
if (Surfer::is_associate() || is_object($anchor) && $anchor->is_assigned()) {
$context['page_tools'][] = Skin::build_link(Locations::get_url($id, 'edit'), i18n::s('Edit'));
$context['page_tools'][] = Skin::build_link(Locations::get_url($id, 'delete'), i18n::s('Delete'));
// commands for the author
} elseif (Surfer::is($item['edit_id'])) {
$context['page_tools'][] = Skin::build_link(Locations::get_url($item['id'], 'edit'), i18n::s('Edit'));
}
// referrals, if any, in a sidebar
//
$context['components']['referrals'] =& Skin::build_referrals(Locations::get_url($item['id']));
}
// render the skin
render_skin();
示例9: load_skin
// include global declarations
include_once '../shared/global.php';
// load localized strings
i18n::bind('scripts');
// load the skin
load_skin('scripts');
// the path to this page
$context['path_bar'] = array('control/' => i18n::s('Control Panel'));
// the title of the page
$context['page_title'] = i18n::s('Run one-time scripts');
// the list of script to take into account
global $scripts;
$scripts = array();
// if the user table exists, check that the user is an admin
$query = "SELECT count(*) FROM " . SQL::table_name('users');
if (SQL::query($query) !== FALSE && !Surfer::is_associate()) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// open the directory
} elseif (!($dir = Safe::opendir($context['path_to_root'] . 'scripts/run_once'))) {
Logger::error(sprintf(i18n::s('Impossible to read %s.'), $context['path_to_run_once_scripts']));
} else {
while (($item = Safe::readdir($dir)) !== FALSE) {
// script name has to start with a number --actually, a date
if ($item[0] < '0' || $item[0] > '9') {
continue;
}
// we only consider php scripts, of course
if (strlen($item) < 5 || substr($item, -4) != '.php') {
continue;
}
示例10: date
echo '<p>' . i18n::s('Server GMT offset:') . ' UTC ' . ($offset > 0 ? "+" : "") . $offset . ' ' . i18n::s('hour(s)') . ' (' . date('Y-M-d H:i:s') . ")</p>\n";
// run-time information
if (Surfer::is_associate()) {
echo '<p>';
// current directory
if (is_callable('getcwd')) {
echo 'getcwd()=' . getcwd() . BR . "\n";
}
// PHP SAPI name
if (is_callable('php_sapi_name')) {
echo 'php_sapi_name()=' . php_sapi_name() . BR . "\n";
}
echo "</p>\n";
}
// do not reveal names of accounts used on server side
if (Surfer::is_associate() && !file_exists($context['path_to_root'] . 'parameters/demo.flag')) {
// user/group of this script
if (is_callable('getmyuid') && ($uid = getmyuid()) !== FALSE && is_callable('getmygid') && ($gid = getmygid()) !== FALSE) {
// describe user
$ulabel = $uid;
if (is_callable('posix_getpwuid') && ($uinfo = posix_getpwuid($uid)) !== FALSE) {
if (isset($uinfo['name'])) {
$ulabel = $uinfo['name'] . '[' . $uid . ']';
}
}
// describe group and members
$glabel = $gid;
if (is_callable('posix_getgrgid') && ($ginfo = posix_getgrgid($gid)) !== FALSE) {
// group name
if (isset($ginfo['name'])) {
$glabel = $ginfo['name'] . '[' . $gid . ']';
示例11: urlencode
// linked in
Skin::define_img('PAGERS_LINKEDIN_IMG', 'pagers/linkedin.gif');
$lines[] = Skin::build_link('http://www.linkedin.com/shareArticle?mini=true&url=' . $url . '&title=' . urlencode($item['title']) . '&summary=' . urlencode($item['introduction']) . '&source=' . urlencode($anchor->get_title()), PAGERS_LINKEDIN_IMG . i18n::s('Share at LinkedIn'), 'basic', i18n::s('Spread the word'));
}
// invite participants
if (($cur_article->is_owned() || $item['active'] == 'Y') && isset($context['with_email']) && $context['with_email'] == 'Y') {
Skin::define_img('ARTICLES_INVITE_IMG', 'articles/invite.gif');
$lines[] = Skin::build_link(Articles::get_url($item['id'], 'invite'), ARTICLES_INVITE_IMG . i18n::s('Invite participants'), 'basic', i18n::s('Spread the word'));
}
// notify participants
if (($cur_article->is_owned() || Surfer::is_associate()) && isset($context['with_email']) && $context['with_email'] == 'Y') {
Skin::define_img('ARTICLES_EMAIL_IMG', 'articles/email.gif');
$lines[] = Skin::build_link(Articles::get_url($item['id'], 'mail'), ARTICLES_EMAIL_IMG . i18n::s('Notify participants'));
}
// manage editors
if ($cur_article->is_owned() || Surfer::is_associate()) {
Skin::define_img('ARTICLES_ASSIGN_IMG', 'articles/assign.gif');
$lines[] = Skin::build_link(Users::get_url('article:' . $item['id'], 'select'), ARTICLES_ASSIGN_IMG . i18n::s('Manage participants'));
}
// the command to track back
if (Links::allow_trackback()) {
Skin::define_img('TOOLS_TRACKBACK_IMG', 'tools/trackback.gif');
$lines[] = Skin::build_link('links/trackback.php?anchor=' . urlencode('article:' . $item['id']), TOOLS_TRACKBACK_IMG . i18n::s('Reference this page'), 'basic', i18n::s('Various means to link to this page'));
}
// more tools
if (isset($context['with_export_tools']) && $context['with_export_tools'] == 'Y' || is_object($anchor) && $anchor->has_option('with_export_tools')) {
// check tools visibility
if (Surfer::is_member() || isset($context['with_anonymous_export_tools']) && $context['with_anonymous_export_tools'] == 'Y') {
// get a PDF version
Skin::define_img('ARTICLES_PDF_IMG', 'articles/export_pdf.gif');
$lines[] = Skin::build_link(Articles::get_url($item['id'], 'fetch_as_pdf'), ARTICLES_PDF_IMG . i18n::s('Save as PDF'), 'basic', i18n::s('Save as PDF'));
示例12: trim
/**
* get some introductory text from an article
*
* This function is used to introduce comments, or any sub-item related to an anchor.
* Compared to the standard anchor implementation, this one adds the ability to handle overlay data.
*
* If there is some introductory text, it is used. Else the description text is used instead.
* The number of words is capped in both cases.
*
* Also, the number of remaining words is provided.
*
* Following variants may be selected to adapt to various situations:
* - 'basic' - strip every tag, we want almost plain ASCII - maybe this will be send in a mail message
* - 'hover' - some text to be displayed while hovering a link
* - 'quote' - strip most HTML tags
* - 'teaser' - limit the number of words, tranform YACS codes, and link to permalink
*
* @see shared/anchor.php
*
* @param string an optional variant, including
* @return NULL, of some text
*/
function &get_teaser($variant = 'basic')
{
global $context;
// no item bound
if (!isset($this->item['id'])) {
$text = NULL;
return $text;
}
// the text to be returned
$text = '';
// use the introduction field, if any
if ($this->item['introduction']) {
$text = trim($this->item['introduction']);
// may be rendered as an empty strings
if ($variant != 'hover') {
// remove toc and toq codes
$text = preg_replace(FORBIDDEN_IN_TEASERS, '', $text);
// render all codes
if (is_callable(array('Codes', 'beautify'))) {
$text = Codes::beautify($text, $this->item['options']);
}
}
// combine with description
if ($variant == 'quote') {
$text .= BR . BR;
}
}
// use overlay data, if any
if (!$text) {
if (!isset($this->overlay) && isset($this->item['overlay'])) {
$this->overlay = Overlay::load($this->item, 'article:' . $this->item['id']);
}
if (is_object($this->overlay)) {
$text .= $this->overlay->get_text('list', $this->item);
}
}
// use the description field, if any
$in_description = FALSE;
if (!$text && $variant != 'hover') {
$text .= trim($this->item['description']);
$in_description = TRUE;
// remove toc and toq codes
$text = preg_replace(FORBIDDEN_IN_TEASERS, '', $text);
// render all codes
if ($variant == 'teaser' && is_callable(array('Codes', 'beautify'))) {
$text = Codes::beautify($text, $this->item['options']);
}
}
// turn html entities to unicode entities
$text = utf8::transcode($text);
// now we have to process the provided text
switch ($variant) {
// strip everything
case 'basic':
default:
// strip every HTML and limit the size
if (is_callable(array('Skin', 'strip'))) {
$text = Skin::strip($text, 70, NULL, '');
}
// done
return $text;
// some text for pop-up panels
// some text for pop-up panels
case 'hover':
// strip every HTML and limit the size
if (is_callable(array('Skin', 'strip'))) {
$text = Skin::strip($text, 70, NULL, '');
}
// ensure we have some text
if (!$text) {
$text = i18n::s('View the page');
}
// mention shortcut to article
if (Surfer::is_associate()) {
$text .= ' [article=' . $this->item['id'] . ']';
}
// done
return $text;
//.........这里部分代码省略.........
示例13: load_skin
*/
// common definitions and initial processing
include_once '../shared/global.php';
include_once '../scripts/scripts.php';
// load localized strings
i18n::bind('control');
// load the skin
load_skin('control');
// the path to this page
$context['path_bar'] = array('control/' => i18n::s('Control Panel'));
// the title of the page
$context['page_title'] = i18n::s('Update file permissions');
// anonymous users are invited to log in or to register
if (!Surfer::is_logged()) {
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode('control/chmod.php'));
} elseif (!Surfer::is_associate() && !(file_exists($context['path_to_root'] . 'parameters/switch.on') || file_exists($context['path_to_root'] . 'parameters/switch.off'))) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// forward to the index page
$menu = array('control/' => i18n::s('Control Panel'));
$context['text'] .= Skin::build_list($menu, 'menu_bar');
// do the action
} elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'confirm') {
// list running scripts
$context['text'] .= '<p>' . i18n::s('Listing files...') . BR . "\n";
// locate script files starting at root
$scripts = Scripts::list_scripts_at(NULL);
if (is_array($scripts)) {
$context['text'] .= BR . sprintf(i18n::s('%d scripts have been found.'), count($scripts)) . "\n";
}
$context['text'] .= "</p>\n";
示例14: array
$cells = array(i18n::s('Downloads'), 'left=' . Skin::build_number($item['hits'], i18n::s('downloads')));
$context['text'] .= Skin::table_row($cells, $lines++);
}
// the first poster
if ($item['create_name']) {
$cells = array(i18n::s('Posted by'), $item['create_name']);
$context['text'] .= Skin::table_row($cells, $lines++);
}
// the last poster
if ($item['edit_name'] != $item['create_name']) {
$cells = array(i18n::s('Updated by'), $item['edit_name']);
$context['text'] .= Skin::table_row($cells, $lines++);
}
// date of last action
$cells = array(i18n::s('Last action'), Skin::build_date($item['edit_date']));
$context['text'] .= Skin::table_row($cells, $lines++);
// associates may change the active flag: Yes/public, Restricted/logged, No/associates
if (Surfer::is_associate()) {
if ($item['active'] == 'N' && Surfer::is_associate()) {
$context['text'] .= Skin::table_row(array(i18n::s('Access'), 'left=' . i18n::s('Private - Access is restricted to selected persons')), $lines++);
} elseif ($item['active'] == 'R' && Surfer::is_member()) {
$context['text'] .= Skin::table_row(array(i18n::s('Access'), 'left=' . i18n::s('Community -Access is granted to any identified surfer')), $lines++);
}
}
// end of the table
$context['text'] .= Skin::table_suffix();
// count items related to this file
$context['text'] .= Anchors::stat_related_to('file:' . $item['id'], i18n::s('Following items are attached to this record and will be deleted as well.'));
}
// render the skin
render_skin();
示例15: stat
/**
* get some statistics
*
* @return the resulting ($count, $min_date, $max_date) array
*/
public static function stat()
{
global $context;
// select among active and restricted items
$where = "servers.active='Y'";
if (Surfer::is_member()) {
$where .= " OR servers.active='R'";
}
if (Surfer::is_associate()) {
$where .= " OR servers.active='N'";
}
// select among available items
$query = "SELECT COUNT(*) as count, MIN(edit_date) as oldest_date, MAX(edit_date) as newest_date" . ' FROM ' . SQL::table_name('servers') . ' AS servers' . ' WHERE (' . $where . ')';
$output = SQL::query_first($query);
return $output;
}