Exemplo n.º 1
0
 /**
  * render a compact list of voted pages
  *
  * @param string the anchor (e.g. 'section:123')
  * @param string layout to use
  * @return string the rendered text
  **/
 public static function render_voted($anchor = '', $layout = 'simple')
 {
     global $context;
     // we return some text;
     $text = '';
     // number of items to display
     $count = COMPACT_LIST_SIZE;
     if (($position = strpos($anchor, ',')) !== FALSE) {
         $count = (int) trim(substr($anchor, $position + 1));
         if (!$count) {
             $count = COMPACT_LIST_SIZE;
         }
         $anchor = trim(substr($anchor, 0, $position));
     }
     // scope is limited to current surfer
     if ($anchor == 'self' && Surfer::get_id()) {
         $anchor = 'user:'******'section:') === 0) {
         // look at this branch of the content tree
         $anchors = Sections::get_branch_at_anchor($anchor);
         // query the database and layout that stuff
         $text =& Articles::list_for_anchor_by('rating', $anchors, 0, $count, $layout);
         // scope is limited to pages of one surfer
     } elseif (strpos($anchor, 'user:'******'rating', substr($anchor, 5), 0, $count, $layout);
     } else {
         $text =& Articles::list_by('rating', 0, $count, $layout);
     }
     // we have an array to format
     if (is_array($text)) {
         $text =& Skin::build_list($text, $layout);
     }
     // job done
     return $text;
 }
Exemplo n.º 2
0
Arquivo: view.php Projeto: rair/yacs
     // load the choosen layout
     $layout = Layouts::new_('last', 'article');
     $layout->set_focus($item['id']);
     // navigation commands for articles
     $home = Users::get_permalink($item);
     $prefix = Users::get_url($item['id'], 'navigate', 'articles');
     $box['bottom'] = array_merge($box['bottom'], Skin::navigate($home, $prefix, $count, $layout->items_per_page(), $zoom_index));
     // append a menu bar before the list
     $box['top'] = array_merge($box['top'], $box['bottom']);
     if (count($box['top'])) {
         $box['text'] .= Skin::build_list($box['top'], 'menu_bar');
     }
     // compute offset from list beginning
     $offset = ($zoom_index - 1) * ARTICLES_PER_PAGE;
     // list watched pages by date, not only pages posted by this user
     $items =& Articles::list_for_user_by('edition', $item['id'], $offset, $layout->items_per_page(), 'last');
     if (is_array($items)) {
         $box['text'] .= Skin::build_list($items, 'compact');
     } elseif ($items) {
         $box['text'] .= $items;
     }
     // append a menu bar below the list
     if (count($box['bottom']) > 1) {
         $box['text'] .= Skin::build_list($box['bottom'], 'menu_bar');
     }
     // a complete box
     if ($box['text']) {
         $stream .= $box['text'];
     }
 }
 // in a separate panel
Exemplo n.º 3
0
Arquivo: print.php Projeto: rair/yacs
    //
    // title
    $section = Skin::build_block(i18n::s('Files'), 'title');
    // list files by date
    $items = Files::list_by_date_for_anchor('user:'******'id'], 0, 50, 'compact');
    // actually render the html for the section
    if ($items) {
        $context['text'] .= $section . Skin::build_list($items, 'compact');
    }
    //
    // the links section
    //
    // title
    $section = Skin::build_block(i18n::s('See also'), 'title');
    // list links by date
    if (preg_match('/\\blinks_by_title\\b/i', $item['options'])) {
        $items = Links::list_by_title_for_anchor('user:'******'id'], 0, 20, 'no_author');
    } else {
        $items = Links::list_by_date_for_anchor('user:'******'id'], 0, 20, 'no_author');
    }
    // actually render the html
    if ($items) {
        $context['text'] .= $section . Skin::build_list($items, 'compact');
    }
    // list pages attached to this user
    if ($items =& Articles::list_for_user_by('edition', $item['id'], 0, 50, 'compact')) {
        $context['text'] .= Skin::build_box(i18n::s('Pages'), Skin::build_list($items, 'compact'));
    }
}
// render the skin
render_skin();
Exemplo n.º 4
0
Arquivo: codes.php Projeto: rair/yacs
 /**
  * render a compact list of recent modifications
  *
  * The provided anchor can reference:
  * - a section 'section:123'
  * - a category 'category:456'
  * - a user 'user:789'
  * - 'self'
  * - nothing
  *
  * @param string the anchor (e.g. 'section:123')
  * @param string layout to use
  * @return string the rendered text
  **/
 public static function render_updated($layout = 'simple', $anchor = '')
 {
     global $context;
     // we return some text;
     $text = '';
     // number of items to display
     $count = COMPACT_LIST_SIZE;
     if (($position = strpos($anchor, ',')) !== FALSE) {
         $count = (int) trim(substr($anchor, $position + 1));
         if (!$count) {
             $count = COMPACT_LIST_SIZE;
         }
         $anchor = trim(substr($anchor, 0, $position));
     }
     // scope is limited to current surfer
     if ($anchor == 'self' && Surfer::get_id()) {
         $anchor = 'user:'******'section:') === 0) {
         // look at this branch of the content tree
         $anchors = Sections::get_branch_at_anchor($anchor);
         // query the database and layout that stuff
         $text = Articles::list_for_anchor_by('edition', $anchors, 0, $count, $layout);
         // scope is limited to one category
     } elseif (strpos($anchor, 'category:') === 0) {
         // first level of depth
         $anchors = array();
         // get sections linked to this category
         if ($topics = Members::list_sections_by_title_for_anchor($anchor, 0, 50, 'raw')) {
             foreach ($topics as $id => $not_used) {
                 $anchors = array_merge($anchors, array('section:' . $id));
             }
         }
         // second level of depth
         if (count($topics) && count($anchors) < 2000) {
             $topics = Sections::get_children_of_anchor($anchors);
             $anchors = array_merge($anchors, $topics);
         }
         // third level of depth
         if (count($topics) && count($anchors) < 2000) {
             $topics = Sections::get_children_of_anchor($anchors);
             $anchors = array_merge($anchors, $topics);
         }
         // fourth level of depth
         if (count($topics) && count($anchors) < 2000) {
             $topics = Sections::get_children_of_anchor($anchors);
             $anchors = array_merge($anchors, $topics);
         }
         // fifth level of depth
         if (count($topics) && count($anchors) < 2000) {
             $topics = Sections::get_children_of_anchor($anchors);
             $anchors = array_merge($anchors, $topics);
         }
         // the category itself is an anchor
         $anchors[] = $anchor;
         // ensure anchors are referenced only once
         $anchors = array_unique($anchors);
         // query the database and layout that stuff
         $text = Members::list_articles_by_date_for_anchor($anchors, 0, $count, $layout);
         // scope is limited to pages of one surfer
     } elseif (strpos($anchor, 'user:'******'edition', substr($anchor, 5), 0, $count, $layout);
     } else {
         $text = Articles::list_by('edition', 0, $count, $layout);
     }
     // we have an array to format
     if (is_array($text)) {
         $text = Skin::build_list($text, $layout);
     }
     // job done
     return $text;
 }