Esempio n. 1
0
 /**
  * list sections as topics in a forum
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // layout in a table
     $text = Skin::table_prefix('wide');
     // 'even' is used for title rows, 'odd' for detail rows
     $class_title = 'odd';
     $class_detail = 'even';
     // build a list of sections
     $family = '';
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // change the family
         if ($item['family'] != $family) {
             $family = $item['family'];
             // show the family
             $text .= Skin::table_suffix() . '<h2><span>' . $family . '&nbsp;</span></h2>' . "\n" . Skin::table_prefix('wide');
         }
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'section:' . $item['id']);
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // reset everything
         $prefix = $label = $suffix = $icon = '';
         // signal restricted and private sections
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // indicate the id in the hovering popup
         $hover = i18n::s('View the section');
         if (Surfer::is_member()) {
             $hover .= ' [section=' . $item['id'] . ']';
         }
         // the url to view this item
         $url = Sections::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']);
         }
         // use the title as a link to the page
         $title =& Skin::build_link($url, $title, 'basic', $hover);
         // flag sections updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $suffix = EXPIRED_FLAG . ' ';
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix = NEW_FLAG . ' ';
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix = UPDATED_FLAG . ' ';
         }
         // this is another row of the output
         $text .= '<tr class="' . $class_title . '"><th>' . $prefix . $title . $suffix . '</th><th>' . i18n::s('Poster') . '</th><th>' . i18n::s('Messages') . '</th><th>' . i18n::s('Last active') . '</th></tr>' . "\n";
         $count = 1;
         // get last posts for this board --avoid sticky pages
         if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
             $order = $matches[1];
         } else {
             $order = 'edition';
         }
         if ($articles =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], 0, 5, 'raw', TRUE)) {
             foreach ($articles as $id => $article) {
                 // get the related overlay, if any
                 $article_overlay = Overlay::load($article, 'article:' . $id);
                 // flag articles updated recently
                 if ($article['expiry_date'] > NULL_DATE && $article['expiry_date'] <= $context['now']) {
                     $flag = EXPIRED_FLAG . ' ';
                 } elseif ($article['create_date'] >= $context['fresh']) {
                     $flag = NEW_FLAG . ' ';
                 } elseif ($article['edit_date'] >= $context['fresh']) {
                     $flag = UPDATED_FLAG . ' ';
                 } else {
                     $flag = '';
                 }
                 // use the title to label the link
                 if (is_object($article_overlay)) {
                     $title = Codes::beautify_title($article_overlay->get_text('title', $article));
                 } else {
                     $title = Codes::beautify_title($article['title']);
                 }
                 // title
                 $title = Skin::build_link(Articles::get_permalink($article), $title, 'article');
                 // poster
                 $poster = Users::get_link($article['create_name'], $article['create_address'], $article['create_id']);
                 // comments
                 $comments = Comments::count_for_anchor('article:' . $article['id']);
                 // last editor
                 $action = '';
                 if ($article['edit_date']) {
                     // label the action
                     if (isset($article['edit_action'])) {
                         $action = Anchors::get_action_label($article['edit_action']);
                     } else {
                         $action = i18n::s('edited');
                     }
                     $action = '<span class="details">' . $action . ' ' . Skin::build_date($article['edit_date']) . '</span>';
                 }
                 // this is another row of the output
                 $text .= '<tr class="' . $class_detail . '"><td>' . $title . $flag . '</td><td>' . $poster . '</td><td style="text-align: center;">' . $comments . '</td><td>' . $action . '</td></tr>' . "\n";
             }
         }
         // more details
         $details = array();
         // board introduction
         if ($item['introduction']) {
             $details[] = Codes::beautify_introduction($item['introduction']);
         }
         // indicate the total number of threads here
         if (($count = Articles::count_for_anchor('section:' . $item['id'])) && $count >= 5) {
             $details[] = sprintf(i18n::s('%d threads'), $count) . '&nbsp;&raquo;';
         }
         // link to the section index page
         if ($details) {
             $details = Skin::build_link(Sections::get_permalink($item), join(' -&nbsp;', $details), 'basic');
         } else {
             $details = '';
         }
         // add a command for new post
         $poster = '';
         if (Surfer::is_empowered()) {
             $poster = Skin::build_link('articles/edit.php?anchor=' . urlencode('section:' . $item['id']), i18n::s('Add a page') . '&nbsp;&raquo;', 'basic');
         }
         // insert details in a separate row
         if ($details || $poster) {
             $text .= '<tr class="' . $class_detail . '"><td colspan="3">' . $details . '</td><td>' . $poster . '</td></tr>' . "\n";
         }
         // more details
         $more = array();
         // board moderators
         if ($moderators = Sections::list_editors_by_name($item, 0, 7, 'comma5')) {
             $more[] = sprintf(i18n::ns('Moderator: %s', 'Moderators: %s', count($moderators)), $moderators);
         }
         // children boards
         if ($children =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, COMPACT_LIST_SIZE, 'compact')) {
             $more[] = sprintf(i18n::ns('Child board: %s', 'Child boards: %s', count($children)), Skin::build_list($children, 'comma'));
         }
         // as a compact list
         if (count($more)) {
             $content = '<ul class="compact">';
             foreach ($more as $list_item) {
                 $content .= '<li>' . $list_item . '</li>' . "\n";
             }
             $content .= '</ul>' . "\n";
             // insert details in a separate row
             $text .= '<tr class="' . $class_detail . '"><td colspan="4">' . $content . '</td></tr>' . "\n";
         }
     }
     // end of processing
     SQL::free($result);
     $text .= Skin::table_suffix();
     return $text;
 }
Esempio n. 2
0
}
//
// users
//
$users = '';
$users_count = 0;
// the list of related users if not at another follow-up page
if (!$zoom_type || $zoom_type == 'users') {
    // build a complete box
    $box = array('bar' => array(), 'text' => '');
    // list participants
    $rows = array();
    Skin::define_img('CHECKED_IMG', 'ajax/accept.png', '*');
    $offset = ($zoom_index - 1) * USERS_LIST_SIZE;
    // list editors of this section, and of parent sections
    if ($items = Sections::list_editors_by_name($item, 0, 1000, 'watch')) {
        foreach ($items as $user_id => $user_label) {
            $owner_state = '';
            if ($user_id == $item['owner_id']) {
                $owner_state = CHECKED_IMG;
            }
            $editor_state = CHECKED_IMG;
            $watcher_state = '';
            if (Members::check($anchors, 'user:'******'watch')) {
Esempio n. 3
0
 /**
  * list sections as topics in a forum
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // output as a string
     $text = '';
     // build a list of sections
     $family = '';
     $first = TRUE;
     while ($item = SQL::fetch($result)) {
         // change the family
         if ($item['family'] != $family) {
             $family = $item['family'];
             // close last table only if a section has been already listed
             if (!$first) {
                 $text .= Skin::table_suffix();
             }
             // show the family
             $text .= '<h2><span>' . $family . '&nbsp;</span></h2>' . "\n" . Skin::table_prefix('yabb') . Skin::table_row(array(i18n::s('Board'), 'center=' . i18n::s('Topics'), i18n::s('Last post')), 'header');
         } elseif ($first) {
             $text .= Skin::table_prefix('yabb');
             $text .= Skin::table_row(array(i18n::s('Board'), 'center=' . i18n::s('Topics'), i18n::s('Last post')), 'header');
         }
         // done with this case
         $first = FALSE;
         // reset everything
         $prefix = $label = $suffix = $icon = '';
         // signal restricted and private sections
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // indicate the id in the hovering popup
         $hover = i18n::s('View the section');
         if (Surfer::is_member()) {
             $hover .= ' [section=' . $item['id'] . ']';
         }
         // the url to view this item
         $url = Sections::get_permalink($item);
         // use the title as a link to the page
         $title =& Skin::build_link($url, Codes::beautify_title($item['title']), 'basic', $hover);
         // also use a clickable thumbnail, if any
         if ($item['thumbnail_url']) {
             $prefix = Skin::build_link($url, '<img src="' . $item['thumbnail_url'] . '" alt="" title="' . encode_field($hover) . '" class="left_image" />', 'basic', $hover) . $prefix;
         }
         // flag sections updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $suffix = EXPIRED_FLAG . ' ';
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix = NEW_FLAG . ' ';
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix = UPDATED_FLAG . ' ';
         }
         // board introduction
         if ($item['introduction']) {
             $suffix .= '<br style="clear: none;" />' . Codes::beautify_introduction($item['introduction']);
         }
         // more details
         $details = '';
         $more = array();
         // board moderators
         if ($moderators = Sections::list_editors_by_name($item, 0, 7, 'comma5')) {
             $more[] = sprintf(i18n::ns('Moderator: %s', 'Moderators: %s', count($moderators)), $moderators);
         }
         // children boards
         if ($children =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, COMPACT_LIST_SIZE, 'comma')) {
             $more[] = sprintf(i18n::ns('Child board: %s', 'Child boards: %s', count($children)), Skin::build_list($children, 'comma'));
         }
         // as a compact list
         if (count($more)) {
             $details .= '<ul class="compact">';
             foreach ($more as $list_item) {
                 $details .= '<li>' . $list_item . '</li>' . "\n";
             }
             $details .= '</ul>' . "\n";
         }
         // all details
         if ($details) {
             $details = BR . '<span class="details">' . $details . "</span>\n";
         }
         // count posts here, and in children sections
         $anchors = Sections::get_branch_at_anchor('section:' . $item['id']);
         if (!($count = Articles::count_for_anchor($anchors))) {
             $count = 0;
         }
         // get last post
         $last_post = '--';
         $article =& Articles::get_newest_for_anchor($anchors, TRUE);
         if ($article['id']) {
             // flag articles updated recently
             if ($article['expiry_date'] > NULL_DATE && $article['expiry_date'] <= $context['now']) {
                 $flag = EXPIRED_FLAG . ' ';
             } elseif ($article['create_date'] >= $context['fresh']) {
                 $flag = NEW_FLAG . ' ';
             } elseif ($article['edit_date'] >= $context['fresh']) {
                 $flag = UPDATED_FLAG . ' ';
             } else {
                 $flag = '';
             }
             // title
             $last_post = Skin::build_link(Articles::get_permalink($article), Codes::beautify_title($article['title']), 'article');
             // last editor
             if ($article['edit_date']) {
                 // find a name, if any
                 if ($article['edit_name']) {
                     // label the action
                     if (isset($article['edit_action'])) {
                         $action = Anchors::get_action_label($article['edit_action']);
                     } else {
                         $action = i18n::s('edited');
                     }
                     // name of last editor
                     $user = sprintf(i18n::s('%s by %s'), $action, Users::get_link($article['edit_name'], $article['edit_address'], $article['edit_id']));
                 }
                 $last_post .= $flag . BR . '<span class="tiny">' . $user . ' ' . Skin::build_date($article['edit_date']) . '</span>';
             }
         }
         // this is another row of the output
         $text .= Skin::table_row(array($prefix . $title . $suffix . $details, 'center=' . $count, $last_post));
     }
     // end of processing
     SQL::free($result);
     $text .= Skin::table_suffix();
     return $text;
 }
Esempio n. 4
0
File: view.php Progetto: rair/yacs
 // signal sections to be activated
 if (Surfer::is_empowered() && Surfer::is_logged() && $item['activation_date'] > $context['now']) {
     $details[] = DRAFT_FLAG . ' ' . sprintf(i18n::s('Section will be activated %s'), Skin::build_date($item['activation_date']));
 }
 // expired section
 if (Surfer::is_empowered() && Surfer::is_logged() && $item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
     $details[] = EXPIRED_FLAG . ' ' . sprintf(i18n::s('Section has expired %s'), Skin::build_date($item['expiry_date']));
 }
 // provide more details to authenticated surfers
 if (Surfer::is_logged()) {
     // section owner
     if (isset($item['owner_id']) && ($owner = Users::get($item['owner_id']))) {
         $details[] = sprintf(i18n::s('%s: %s'), i18n::s('Owner'), Users::get_link($owner['full_name'], $owner['email'], $owner['id']));
     }
     // section editors
     if ($items = Sections::list_editors_by_name($item, 0, 7, 'comma5')) {
         $details[] = sprintf(i18n::s('%s: %s'), Skin::build_link(Users::get_url('section:' . $item['id'], 'select'), i18n::s('Editors')), $items);
     }
     // section watchers
     if ($items = Sections::list_watchers_by_posts($item, 0, 7, 'comma5')) {
         $details[] = sprintf(i18n::s('%s: %s'), Skin::build_link(Users::get_url('section:' . $item['id'], 'watch'), i18n::s('Watchers')), $items);
     }
 }
 // display details, if any
 if (count($details)) {
     $text .= ucfirst(implode(BR . "\n", $details)) . BR . "\n";
 }
 // additional details for associates and editors
 if (Surfer::is_empowered()) {
     // other details
     $details =& Sections::build_dates($anchor, $item);