예제 #1
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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 .= ' -&nbsp;<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'] . '&amp;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);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
예제 #4
0
파일: links.php 프로젝트: rair/yacs
 /**
  * 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
0
 /**
  * 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 .= ' -&nbsp;' . 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);
         }
         // 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'])) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
         }
         // rating
         if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
             $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
         }
         // the main anchor link
         if (is_object($anchor)) {
             $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'section'));
         }
         // display all tags
         if ($item['tags']) {
             $details[] = '<span class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>';
         }
         // combine in-line details
         if (count($details)) {
             $suffix .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>';
         }
         // insert a suffix separator
         if (trim($suffix)) {
             $suffix = ' ' . $suffix;
         }
         // item summary
         $box .= $prefix . Skin::build_link($url, $title, 'article') . $suffix;
         // the icon to put in the left column
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         } elseif (is_callable(array($anchor, 'get_bullet_url'))) {
             $icon = $anchor->get_bullet_url();
         }
         // build the complete HTML element
         if ($icon) {
             $icon = '<img src="' . $icon . '" alt="" title="' . encode_field(strip_tags($title)) . '" />';
             // make it a clickable link
             $icon = Skin::build_link($url, $icon, 'basic');
             // default icon
         } else {
             $icon = DECORATED_IMG;
         }
         // layout this item
         $list = array(array($box, $icon));
         $items[] = array($item['score'], Skin::finalize_list($list, 'decorated'));
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
예제 #6
0
파일: query.php 프로젝트: rair/yacs
 $_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
0
파일: select.php 프로젝트: rair/yacs
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:'******'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
0
파일: sections.php 프로젝트: rair/yacs
 /**
  * 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
0
 /**
  * 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
0
파일: layout_tables.php 프로젝트: rair/yacs
 /**
  * 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
0
파일: dates.php 프로젝트: rair/yacs
 /**
  * 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
0
파일: images.php 프로젝트: rair/yacs
 /**
  * check if new images can be added
  *
  * This function returns TRUE if images can be added to some place,
  * and FALSE otherwise.
  *
  * @param object an instance of the Anchor interface, if any
  * @param array a set of item attributes, if any
  * @param string the type of item, e.g., 'section'
  * @return TRUE or FALSE
  */
 public static function allow_creation($item = NULL, $anchor = NULL, $variant = NULL)
 {
     global $context;
     // backward compatibility, reverse parameters :
     // $anchor is always a object and $item a array
     if (is_object($item) || is_array($anchor)) {
         $permute = $anchor;
         $anchor = $item;
         $item = $permute;
     }
     // guess the variant
     if (!$variant) {
         // most frequent case
         if (isset($item['id'])) {
             $variant = 'article';
         } elseif (is_object($anchor)) {
             $variant = $anchor->get_type();
         } else {
             return FALSE;
         }
     }
     // only in articles
     if ($variant == 'article') {
         // 'no images' option
         if (Articles::has_option('no_images', $anchor, $item)) {
             return FALSE;
         }
         // other containers
     } else {
         // in item
         if (isset($item['options']) && is_string($item['options']) && preg_match('/\\bno_images\\b/i', $item['options'])) {
             return FALSE;
         }
         // in container
         if (is_object($anchor) && $anchor->has_option('no_images', FALSE)) {
             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:'******'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
0
파일: trackback.php 프로젝트: rair/yacs
 $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
0
파일: view_as_chat.php 프로젝트: rair/yacs
            }
            // 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
0
파일: edit.php 프로젝트: rair/yacs
     $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";
예제 #16
0
파일: surfer.php 프로젝트: rair/yacs
 /**
  * remember surfer data
  *
  * This function is used to track anonymous surfers based on what they
  * put in web forms.
  *
  * Following named attributes from the provided array are copied in session storage area:
  * - $fields['edit_name'] - nick name of the logged surfer
  * - $fields['edit_address'] - email address
  *
  * @param array session attributes
  */
 public static function track($fields)
 {
     global $context;
     // preserve permanent settings
     if (Surfer::is_logged()) {
         return;
     }
     // remember one time name
     if (isset($fields['edit_name'])) {
         $_SESSION['surfer_name'] = $fields['edit_name'];
     }
     // remember one time email address
     if (isset($fields['edit_address'])) {
         $_SESSION['surfer_email_address'] = $fields['edit_address'];
     }
 }
예제 #17
0
파일: locations.php 프로젝트: rair/yacs
 /**
  * check if new locations can be added
  *
  * This function returns TRUE if locations can be added to some place,
  * and FALSE otherwise.
  *
  * @param object an instance of the Anchor interface, if any
  * @param array a set of item attributes, if any
  * @param string the type of item, e.g., 'section'
  * @return boolean TRUE or FALSE
  */
 public static function allow_creation($item = NULL, $anchor = NULL, $variant = NULL)
 {
     global $context;
     // backward compatibility, reverse parameters :
     // $anchor is always a object and $item a array
     if (is_object($item) || is_array($anchor)) {
         $permute = $anchor;
         $anchor = $item;
         $item = $permute;
     }
     // guess the variant
     if (!$variant) {
         // most frequent case
         if (isset($item['id'])) {
             $variant = 'article';
         } elseif (is_object($anchor)) {
             $variant = $anchor->get_type();
         } else {
             return FALSE;
         }
     }
     // only in articles
     if ($variant == 'article') {
         // 'no_links' option
         if (Articles::has_option('no_locations', $anchor, $item)) {
             return FALSE;
         }
         // other containers
     } else {
         // locations have to be activated explicitly
         if (isset($item['options']) && is_string($item['options']) && preg_match('/\\bwith_locations\\b/i', $item['options'])) {
         } elseif (is_object($anchor) && $anchor->has_option('with_locations')) {
         } else {
             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 owns this item, or the anchor
         if (Articles::is_owned($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;
         }
         // only in sections
     } elseif ($variant == 'section') {
         // surfer owns this item, or the anchor
         if (Sections::is_owned($item, $anchor, TRUE)) {
             return TRUE;
         }
     }
     // surfer is an editor, and container is not private
     if (isset($item['active']) && $item['active'] != 'N' && is_object($anchor) && $anchor->is_assigned()) {
         return TRUE;
     }
     if (!isset($item['id']) && is_object($anchor) && !$anchor->is_hidden() && $anchor->is_assigned()) {
         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;
     }
     // surfer is an editor (and item has not been locked)
     if ($variant == 'article' && isset($item['id']) && Articles::is_assigned($item['id'])) {
         return TRUE;
     }
     if ($variant == 'section' && isset($item['id']) && Sections::is_assigned($item['id'])) {
         return TRUE;
     }
     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;
     }
     // surfer is a member
     if (Surfer::is_member()) {
         return TRUE;
     }
     // container is restricted
     if (isset($item['active']) && $item['active'] == 'R') {
         return FALSE;
     }
     if (is_object($anchor) && !$anchor->is_public()) {
         return FALSE;
     }
     // authenticated members and subscribers are allowed to add locations
     if (Surfer::is_logged()) {
         return TRUE;
     }
     // 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 locations
     return FALSE;
 }
예제 #18
0
파일: template.php 프로젝트: rair/yacs
Page::side();
// end of the navigation panel
echo '</td></tr></table>' . "\n";
// the footer panel
echo '<div id="footer_panel">' . "\n";
// surfer name and execution time, if known
if (is_callable(array('Surfer', 'get_name')) && is_callable(array('i18n', 's'))) {
    $execution_time = round(get_micro_time() - $context['start_time'], 2);
    echo sprintf(i18n::s('Page prepared in %.2f seconds for %s'), $execution_time, ucwords(Surfer::get_name())) . ' ';
}
// site copyright
if (isset($context['site_copyright'])) {
    echo '<br />Copyright &copy; ' . $context['site_copyright'] . "\n";
}
// a command to authenticate
if (is_callable(array('Surfer', 'is_logged')) && !Surfer::is_logged() && is_callable(array('i18n', 's'))) {
    echo ' - ' . Skin::build_link('users/login.php', i18n::s('login'), 'basic') . ' ';
}
// about this site
if (is_callable(array('i18n', 's')) && is_callable(array('Articles', 'get_url'))) {
    echo ' - ' . Skin::build_link(Articles::get_url('about'), i18n::s('about this site'), 'basic') . ' ';
}
// privacy statement
if (is_callable(array('i18n', 's')) && is_callable(array('Articles', 'get_url'))) {
    echo ' - ' . Skin::build_link(Articles::get_url('privacy'), i18n::s('privacy statement'), 'basic') . ' ';
}
// a reference to YACS
if (is_callable(array('i18n', 's'))) {
    echo BR . sprintf(i18n::s('Powered by %s'), Skin::build_link(i18n::s('http://www.yacs.fr/'), 'Yacs', 'external'));
}
// end of the footer panel
예제 #19
0
파일: view.php 프로젝트: rair/yacs
     $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'));
         // open in Word
         Skin::define_img('ARTICLES_WORD_IMG', 'articles/export_word.gif');
         $lines[] = Skin::build_link(Articles::get_url($item['id'], 'fetch_as_msword'), ARTICLES_WORD_IMG . i18n::s('Copy in MS-Word'), 'basic', i18n::s('Copy in MS-Word'));
     }
 }
 // print this page
 if (Surfer::is_logged() || isset($context['with_anonymous_export_tools']) && $context['with_anonymous_export_tools'] == 'Y') {
     Skin::define_img('TOOLS_PRINT_IMG', 'tools/print.gif');
     $lines[] = Skin::build_link(Articles::get_url($item['id'], 'print'), TOOLS_PRINT_IMG . i18n::s('Print this page'), 'basic', i18n::s('Get a paper copy of this page.'));
 }
 // in a side box
 if (count($lines)) {
     $context['components']['share'] = Skin::build_box(i18n::s('Share'), Skin::finalize_list($lines, 'newlines'), 'share', 'share');
 }
 // 'Information channels' box
 //
 $lines = array();
 // watch command is provided to logged surfers
 if (Surfer::get_id()) {
     $link = Users::get_url('article:' . $item['id'], 'track');
     if ($in_watch_list) {
         $label = i18n::s('Stop notifications');
예제 #20
0
파일: articles.php 프로젝트: rair/yacs
 /**
  * list articles attached to one anchor
  *
  * The ordering method is provided as first parameter:
  * - 'draft' - order by reverse date of modification, but only draft pages
  * - 'edition' - order by rank, then by reverse date of modification
  * - 'hits' - order by reverse number of hits, then by reverse date of publication
  * - 'overlay' - order by overlay_id
  * - 'publication' - order by rank, then by reverse date of publication
  * - 'random' - use random order
  * - 'rating' - order by rank, then by reverse number of points
  * - 'reverse_rank'
  * - 'reverse_title'
  * - 'title' - order by rank, then by titles
  *
  * Only articles matching following criteria are returned:
  * - article is visible (active='Y')
  * - article is restricted (active='R'), but the surfer is an authenticated member,
  * or YACS is allowed to show restricted teasers
  * - article is protected (active='N'), but surfer is an associate, and we are not feeding someone
  * - surfer is anonymous, and article has been officially published
  * - logged surfers are restricted to their own articles, plus published articles
  * - an expiry date has not been defined, or is not yet passed
  *
  * @param string order of resulting set
  * @param mixed, either a string the target anchor, or an array of anchors
  * @param int the offset from the start of the list; usually, 0 or 1
  * @param int the number of items to display
  * @param mixed the layout, if any
  * @param boolean FALSE to include sticky pages, TRUE otherwise
  * @return NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
  */
 public static function &list_for_anchor_by($order, $anchor, $offset = 0, $count = 10, $layout = 'no_anchor', $without_sticky = FALSE)
 {
     global $context;
     // restrict the query to addressable content
     $where = Articles::get_sql_where();
     // avoid sticky articles
     if ($without_sticky) {
         $where .= " AND (articles.rank >= 10000)";
     }
     // list only draft articles
     if ($order == 'draft') {
         $where .= " AND ((articles.publish_date is NULL) OR (articles.publish_date <= '0000-00-00'))";
     } elseif ($order == 'publication') {
         $where .= " AND NOT ((articles.publish_date is NULL) OR (articles.publish_date <= '0000-00-00'))";
     } 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 not empowered are restricted to their own articles, plus published articles
     } elseif (!Surfer::is_member() || !is_callable(array('Surfer', 'is_empowered')) || !Surfer::is_empowered()) {
         $where .= " AND ((articles.owner_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, except for associates and editors
     if (is_callable(array('Surfer', 'is_empowered')) && !Surfer::is_empowered()) {
         $where .= " AND ((articles.expiry_date is NULL) " . "OR (articles.expiry_date <= '" . NULL_DATE . "') OR (articles.expiry_date > '" . $context['now'] . "'))";
     }
     // several anchors
     if (is_array($anchor)) {
         $items = array();
         foreach ($anchor as $token) {
             $items[] = "articles.anchor LIKE '" . SQL::escape($token) . "'";
         }
         $where_anchor = join(' OR ', $items);
         // or only one
     } else {
         $where_anchor = "articles.anchor LIKE '" . SQL::escape($anchor) . "'";
     }
     // order items
     $order = Articles::_get_order($order, is_array($anchor) && count($anchor) > 1);
     // the list of articles
     $query = "SELECT articles.*" . " FROM " . SQL::table_name('articles') . " AS articles" . " WHERE (" . $where_anchor . ") AND (" . $where . ")" . " ORDER BY " . $order . " LIMIT " . $offset . ',' . $count;
     $output =& Articles::list_selected(SQL::query($query), $layout);
     return $output;
 }
예제 #21
0
파일: page.php 프로젝트: rair/yacs
 /**
  * echo the standard footer
  *
  * Note that this one does not echo $context['page_footer'], and you have
  * to do it yourself.
  *
  * @param string footer prefix, if any
  * @param string footer suffix, if any
  */
 public static function footer($prefix = '', $suffix = '')
 {
     global $context;
     // the last paragraph
     echo '<p>';
     // add footer prefix
     echo $prefix;
     $details = array();
     // execution time and surfer name, for logged user only (not for indexing robots!)
     if (is_callable(array('Surfer', 'get_name')) && is_callable(array('i18n', 's'))) {
         $execution_time = round(get_micro_time() - $context['start_time'], 2);
         $details[] = sprintf(i18n::s('page prepared in %.2f seconds for %s'), $execution_time, ucwords(Surfer::get_name()));
     }
     // site copyright
     if (isset($context['site_copyright']) && $context['site_copyright']) {
         $details[] = '&copy; ' . $context['site_copyright'] . "\n";
     }
     // a command to authenticate
     if (is_callable(array('Surfer', 'is_logged')) && !Surfer::is_logged() && is_callable(array('i18n', 's'))) {
         $details[] = Skin::build_link('users/login.php', i18n::s('login'), 'basic');
     }
     // about this site
     if (is_callable(array('i18n', 's')) && is_callable(array('Articles', 'get_url'))) {
         $details[] = Skin::build_link(Articles::get_url('about'), i18n::s('about this site'), 'basic');
     }
     // privacy statement
     if (is_callable(array('i18n', 's')) && is_callable(array('Articles', 'get_url'))) {
         $details[] = Skin::build_link(Articles::get_url('privacy'), i18n::s('privacy statement'), 'basic');
     }
     // a reference to YACS
     if (is_callable(array('i18n', 's')) && $context['host_name'] != 'www.yacs.fr') {
         $details[] = sprintf(i18n::s('powered by %s'), Skin::build_link(i18n::s('http://www.yacs.fr/'), 'Yacs', 'external'));
     }
     // all our feeds
     if (is_callable(array('i18n', 's'))) {
         $details[] = Skin::build_link('feeds/', i18n::s('information channels'), 'basic');
     }
     echo join(' -&nbsp;', $details);
     // add footer suffix
     echo $suffix;
     // end of the last paragraph
     echo '</p>' . "\n";
 }
예제 #22
0
파일: view.php 프로젝트: rair/yacs
             list($link, $title, $description) = $attributes;
             $item['source'] = Skin::build_link($link, $title);
         }
     }
     $details[] = sprintf(i18n::s('Source: %s'), $item['source']) . BR;
 }
 // the file name, if it has not already been used as title
 if (Surfer::is_associate() && $item['title']) {
     $details[] = $item['image_name'];
 }
 // image size
 if (Surfer::is_associate() && $item['image_size'] > 1) {
     $details[] = sprintf(i18n::s('%d bytes'), $item['image_size']);
 }
 // information on uploader
 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']));
 }
 // all details
 if (count($details)) {
     $context['text'] .= '<p class="details">' . ucfirst(implode(', ', $details)) . '</p>';
 }
 // back to the anchor page
 if (is_object($anchor) && $anchor->is_viewable()) {
     $context['text'] .= Skin::build_block(Skin::build_link($anchor->get_url(), i18n::s('Back to main page'), 'button'), 'bottom');
 }
 // page tools
 //
 if ($editable) {
     Skin::define_img('IMAGES_EDIT_IMG', 'images/edit.gif');
     $context['page_tools'][] = Skin::build_link(Images::get_url($item['id'], 'edit'), IMAGES_EDIT_IMG . i18n::s('Update this image'), 'basic', i18n::s('Press [e] to edit'), FALSE, 'e');
예제 #23
0
파일: files.php 프로젝트: rair/yacs
 /**
  * get some statistics for all files
  *
  * @return the resulting ($count, $oldest_date, $newest_date, $total_size) array
  *
  * @see files/index.php
  */
 public static function stat()
 {
     global $context;
     // limit the scope of the request
     $where = "(files.active='Y'";
     if (Surfer::is_logged()) {
         $where .= " OR files.active='R'";
     }
     if (Surfer::is_associate()) {
         $where .= " OR files.active='N'";
     }
     $where .= ")";
     // select among available items
     $query = "SELECT COUNT(*) as count, MIN(files.edit_date) as oldest_date, MAX(files.edit_date) as newest_date" . ", SUM(file_size) as total_size" . " FROM " . SQL::table_name('files') . " AS files WHERE " . $where;
     $output = SQL::query_first($query);
     return $output;
 }
예제 #24
0
파일: comments.php 프로젝트: rair/yacs
 /**
  * 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;
 }
예제 #25
0
 /**
  * list articles
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // the script used to check all pages at once
     Page::insert_script('function cascade_selection_to_all_article_rows(handle) {' . "\n" . '	$("div#articles_panel input[type=\'checkbox\'].row_selector").each(' . "\n" . '		function() { $(this).attr("checked", $(handle).is(":checked"));}' . "\n" . '	);' . "\n" . '}' . "\n");
     // table prefix
     $text .= Skin::table_prefix('yc-grid');
     // table headers
     $main = '<input type="checkbox" class="row_selector" onclick="cascade_selection_to_all_article_rows(this);" />';
     $cells = array($main, i18n::s('Page'), i18n::s('Rank'));
     $text .= Skin::table_row($cells, 'header');
     // process all items in the list
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     $count = 0;
     while ($item = SQL::fetch($result)) {
         $cells = array();
         // 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);
         // column to select the row
         $cells[] = '<input type="checkbox" name="selected_articles[]" id="article_selector_' . $count . '" class="row_selector" value="' . $item['id'] . '" />';
         // 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') {
             $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;
         }
         // the introductory text
         if (is_object($overlay)) {
             $introduction = $overlay->get_text('introduction', $item);
         } else {
             $introduction = $item['introduction'];
         }
         if ($introduction) {
             $suffix .= BR . Codes::beautify_introduction($introduction);
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $suffix .= $overlay->get_text('list', $item);
         }
         // append details to the suffix
         $suffix .= BR . '<span class="details">';
         // details
         $details = array();
         // the author
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             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
         $stats = Files::stat_for_anchor('article:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $stats['count']), $stats['count']);
         }
         // info on related links
         $stats = Links::stat_for_anchor('article:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $stats['count']), $stats['count']);
         }
         // info on related comments
         $stats = Comments::stat_for_anchor('article:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $stats['count']), $stats['count']);
         }
         // rating
         if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
             $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
         }
         // combine in-line details
         if (count($details)) {
             $suffix .= ucfirst(trim(implode(', ', $details)));
         }
         // list up to three categories by title, if any
         $anchors = array();
         if ($members =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) {
             foreach ($members as $id => $attributes) {
                 // add background color to distinguish this category against others
                 if (isset($attributes['background_color']) && $attributes['background_color']) {
                     $attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>';
                 }
                 $anchors[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic');
             }
         }
         if (count($anchors)) {
             $suffix .= BR . sprintf(i18n::s('In %s'), implode(' / ', $anchors));
         }
         // end of details
         $suffix .= '</span>';
         // strip empty details
         $suffix = str_replace(BR . '<span class="details"></span>', '', $suffix);
         $suffix = str_replace('<span class="details"></span>', '', $suffix);
         // the icon to put in the left column
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         }
         // commands
         $commands = array(Skin::build_link(Articles::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic'), Skin::build_link(Articles::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic'));
         // link to this page
         $cells[] = $prefix . Skin::build_link($url, $title, 'article') . ' - ' . Skin::finalize_list($commands, 'menu') . $suffix;
         // ranking
         $cells[] = '<input type="text" size="5" name="article_rank_' . $item['id'] . '" value="' . $item['rank'] . '" onfocus="$(\'#article_selector_' . $count . '\').attr(\'checked\', \'checked\');" onchange="$(\'#act_on_articles\').prop(\'selectedIndex\', 9);" />';
         // append the row
         $text .= Skin::table_row($cells, $count++);
     }
     // select all rows
     $cells = array('<input type="checkbox" class="row_selector" onclick="cascade_selection_to_all_article_rows(this);" />', i18n::s('Select all/none'), '');
     $text .= Skin::table_row($cells, $count++);
     // table suffix
     $text .= Skin::table_suffix();
     // end of processing
     SQL::free($result);
     return $text;
 }
예제 #26
0
파일: fetch_all.php 프로젝트: rair/yacs
}
// get the related anchor, if any
$anchor = NULL;
if (isset($item['anchor']) && $item['anchor']) {
    $anchor = Anchors::get($item['anchor']);
}
// get related behaviors, if any
$behaviors = NULL;
include_once '../behaviors/behaviors.php';
if (isset($item['id'])) {
    $behaviors = new Behaviors($item, $anchor);
}
// public access is allowed
if (isset($item['active']) && $item['active'] == 'Y') {
    $permitted = TRUE;
} elseif (isset($item['active']) && $item['active'] == 'R' && Surfer::is_logged()) {
    $permitted = TRUE;
} elseif (Surfer::is_associate() || is_object($anchor) && $anchor->is_assigned()) {
    $permitted = TRUE;
} else {
    $permitted = FALSE;
}
// load the skin, maybe with a variant
load_skin('files', $anchor);
// clear the tab we are in, if any
if (is_object($anchor)) {
    $context['current_focus'] = $anchor->get_focus();
}
// the path to this page
if (isset($item['id'])) {
    $context['path_bar'] = array(Articles::get_permalink($item) => $item['title']);
예제 #27
0
파일: feed.php 프로젝트: rair/yacs
 */
// common definitions and initial processing
include_once '../shared/global.php';
// ensure we only provide public content through newsfeeds
$context['users_without_teasers'] = 'Y';
// check network credentials, if any -- used by winamp and other media players
if ($user = Users::authenticate()) {
    Surfer::empower($user['capability']);
}
// look for the id
$id = NULL;
if (isset($_REQUEST['id'])) {
    $id = $_REQUEST['id'];
} elseif (isset($context['arguments'][0])) {
    $id = $context['arguments'][0];
} elseif (Surfer::is_logged()) {
    $id = Surfer::get_id();
}
$id = strip_tags($id);
// get the item from the database
$item = Users::get($id);
// associates can do what they want
if (Surfer::is_associate()) {
    $permitted = TRUE;
} elseif ($item['active'] == 'R' && Surfer::is_member()) {
    $permitted = TRUE;
} elseif ($item['active'] == 'Y') {
    $permitted = TRUE;
} else {
    $permitted = FALSE;
}
예제 #28
0
 /**
  * list articles
  *
  * Accept following variants:
  * - 'hits', compact plus the number of hits
  * - 'no_author', for articles in the user page
  * - 'category:xxx', if the list is displayed at categories/view.php
  * - 'section:xxx', if the list is displayed at sections/view.php
  *
  * @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 = 'decorated';
     }
     // 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 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;
         }
         // the compact version
         if ($this->layout_variant == 'compact') {
             $items[$url] = array($prefix, Skin::strip($title, 30), $suffix, 'basic', NULL);
             continue;
         }
         // with hits
         if ($this->layout_variant == 'hits') {
             if ($item['hits'] > 1) {
                 $suffix = ' <span class="details">- ' . Skin::build_number($item['hits'], i18n::s('hits')) . '</span>';
             }
             $items[$url] = array($prefix, Skin::strip($title, 30), $suffix, 'basic', NULL);
             continue;
         }
         // introduction
         $introduction = '';
         if (is_object($overlay)) {
             $introduction = $overlay->get_text('introduction', $item);
         } else {
             $introduction = $item['introduction'];
         }
         // the introductory text
         if ($introduction) {
             $suffix .= ' -&nbsp;' . 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);
         }
         // next line, except if we already are at the beginning of a line
         if ($suffix && !preg_match('/<br\\s*\\/>$/', rtrim($suffix))) {
             $suffix .= BR;
         }
         // append details to the suffix
         $suffix .= '<span class="details">';
         // details
         $details = array();
         // display details only at the main index page, and also at anchor pages
         if (isset($this->focus) && $item['anchor'] != $this->focus) {
             // the author
             if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
                 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);
             }
             // rating
             if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
                 $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
             }
             // unusual ranks are signaled to associates and owners
             if ($item['rank'] != 10000 && Articles::is_owned($item, $anchor)) {
                 $details[] = '{' . $item['rank'] . '}';
             }
         }
         // at the user page
         if ($this->layout_variant == 'no_author' && Surfer::get_id()) {
             if (Members::check('article:' . $item['id'], 'user:'******'Stop notifications');
             } else {
                 $label = i18n::s('Watch this page');
             }
             $menu = array('users/track.php?anchor=' . urlencode('article:' . $item['id']) => $label);
             $details[] = Skin::build_list($menu, 'menu');
         }
         // the main anchor link
         if (is_object($anchor) && (!isset($this->focus) || $item['anchor'] != $this->focus)) {
             $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'section'));
         }
         // combine in-line details
         if (count($details)) {
             $suffix .= ucfirst(trim(implode(', ', $details)));
         }
         // end of details
         $suffix .= '</span>';
         // display all tags
         if ($item['tags']) {
             $suffix .= ' <span class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>';
         }
         // strip empty details
         $suffix = str_replace(BR . '<span class="details"></span>', '', $suffix);
         $suffix = str_replace('<span class="details"></span>', '', $suffix);
         // insert a suffix separator
         if (trim($suffix)) {
             $suffix = ' ' . $suffix;
         }
         // the icon to put in the left column
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         } elseif (is_callable(array($anchor, 'get_bullet_url'))) {
             $icon = $anchor->get_bullet_url();
         }
         // list all components for this item
         $items[$url] = array($prefix, $title, $suffix, 'article', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
예제 #29
0
파일: select.php 프로젝트: rair/yacs
    $context['page_title'] = sprintf(i18n::s('Categories for: %s'), $anchor->get_title());
} else {
    $context['page_title'] = i18n::s('Select categories for this page');
}
// stop crawlers
if (Surfer::is_crawler()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // not found
} elseif (!is_object($anchor)) {
    Safe::header('Status: 404 Not Found', TRUE, 404);
    Logger::error(i18n::s('No item has been found.'));
    // permission denied
} elseif (!$permitted) {
    // 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(Categories::get_url($member, 'select')));
    }
    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // build a form to associates some categories to this item
} else {
    // actual update
    if (isset($_REQUEST['anchor']) && isset($_REQUEST['member'])) {
        // on error display the form again
        if ($error = Members::toggle($_REQUEST['anchor'], $_REQUEST['member'], isset($_REQUEST['father']) ? $_REQUEST['father'] : '')) {
            Logger::error($error);
        }
    }
    // the current list of linked categories
예제 #30
0
파일: members.php 프로젝트: rair/yacs
 /**
  * list users who are editors of some reference
  *
  * @param string reference to the associated item
  * @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
  * @param string an id to avoid, if any
  * @return NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
  *
  * @see users/select.php
  */
 public static function &list_users_by_posts_for_member($member, $offset = 0, $count = 10, $variant = 'compact', $to_avoid = NULL)
 {
     global $context;
     // return by reference
     $output = NULL;
     // list all anchors for this member
     $query = "SELECT anchor FROM " . SQL::table_name('members') . " WHERE (member LIKE '" . SQL::escape($member) . "')" . "\tAND (anchor like 'user:%')" . " GROUP BY anchor ORDER BY anchor LIMIT " . $offset . ',' . $count;
     if (!($result = SQL::query($query))) {
         return $output;
     }
     // empty list
     if (!SQL::count($result)) {
         return $output;
     }
     // build an array of ids
     $ids = array();
     while ($row = SQL::fetch($result)) {
         // avoid this one
         if ($to_avoid && $row['anchor'] == $to_avoid) {
             continue;
         }
         // remember this id
         $ids[] = str_replace('user:'******'', $row['anchor']);
     }
     // ensure each member is represented only once
     $ids = array_unique($ids);
     // sanity check
     if (!count($ids)) {
         return $output;
     }
     // display active and restricted items
     $where = "users.active='Y'";
     if (Surfer::is_logged()) {
         $where .= " OR users.active='R'";
     }
     if (Surfer::is_associate()) {
         $where .= " OR users.active='N'";
     }
     $where = '(' . $where . ')';
     // do not list blocked users
     $where .= " AND (users.capability IN ('S', 'M', 'A'))";
     // only include users who want to receive mail messages
     if ($variant == 'mail') {
         $where .= " AND (without_messages != 'Y')";
     }
     // the list of users
     $query = "SELECT *\tFROM " . SQL::table_name('users') . " AS users" . " WHERE (id = " . join(" OR id = ", $ids) . ")" . "\tAND " . $where . " ORDER BY users.posts DESC, users.nick_name LIMIT " . $offset . ',' . $count;
     // use existing listing facility
     $output =& Users::list_selected(SQL::query($query), $variant);
     return $output;
 }