Ejemplo n.º 1
0
Archivo: index.php Proyecto: rair/yacs
 // we have an array to format
 if (is_array($text)) {
     $text =& Skin::build_list($text, '2-columns');
 }
 // navigation commands for categories, if necessary
 if ($stats['count'] > CATEGORIES_PER_PAGE) {
     $menu = array('_count' => Skin::build_number($stats['count'], i18n::s('categories')));
     $home = 'categories/';
     if ($context['with_friendly_urls'] == 'Y') {
         $prefix = $home . 'index.php/';
     } elseif ($context['with_friendly_urls'] == 'R') {
         $prefix = $home;
     } else {
         $prefix = $home . '?page=';
     }
     $menu = array_merge($menu, Skin::navigate($home, $prefix, $stats['count'], CATEGORIES_PER_PAGE, $page));
     // add a menu at the bottom
     $text .= Skin::build_list($menu, 'menu_bar');
 }
 // make a box
 if ($text) {
     $text =& Skin::build_box('', $text, 'header1', 'categories');
 }
 // associates may list specific categories as well
 if ($page == 1 && Surfer::is_associate()) {
     // query the database and layout that stuff
     if ($items = Categories::list_inactive_by_title(0, 25)) {
         // we have an array to format
         if (is_array($items)) {
             $items = Skin::build_list($items, '2-columns');
         }
Ejemplo n.º 2
0
Archivo: list.php Proyecto: rair/yacs
 if (is_object($layout)) {
     $items_per_page = $layout->items_per_page();
 } else {
     $items_per_page = FILES_PER_PAGE;
 }
 // the first file to list
 $offset = ($page - 1) * $items_per_page;
 if (is_object($layout) && method_exists($layout, 'set_offset')) {
     $layout->set_offset($offset);
 }
 // a navigation bar for these files
 if ($count = Files::count_for_anchor($anchor->get_reference())) {
     $context['page_menu'] += array('_count' => sprintf(i18n::ns('%d file', '%d files', $count), $count));
     // navigation commands for files
     $prefix = Files::get_url($anchor->get_reference(), 'navigate');
     $context['page_menu'] += Skin::navigate($anchor->get_url('files'), $prefix, $count, $items_per_page, $page, FALSE);
     // list files by date or by title
     if ($anchor->has_option('files_by') == 'title') {
         $items = Files::list_by_title_for_anchor($anchor->get_reference(), $offset, $items_per_page, $anchor->get_reference());
     } else {
         $items = Files::list_by_date_for_anchor($anchor->get_reference(), $offset, $items_per_page, $anchor->get_reference());
     }
     // actually render the html
     if (is_array($items)) {
         $context['text'] .= Skin::build_list($items, 'decorated');
     } elseif (is_string($items)) {
         $context['text'] .= $items;
     }
 }
 // insert anchor suffix
 if (is_object($anchor)) {
Ejemplo n.º 3
0
Archivo: view.php Proyecto: rair/yacs
         $offset = ($zoom_index - 1) * LINKS_PER_PAGE;
         if (Articles::has_option('links_by_title', $anchor, $item)) {
             $items = Links::list_by_title_for_anchor('article:' . $item['id'], $offset, LINKS_PER_PAGE);
         } else {
             $items = Links::list_by_date_for_anchor('article:' . $item['id'], $offset, LINKS_PER_PAGE);
         }
         // actually render the html
         if (is_array($items)) {
             $box['text'] .= Skin::build_list($items, 'decorated');
         } elseif (is_string($items)) {
             $box['text'] .= $items;
         }
         // navigation commands for links
         $home = Articles::get_permalink($item);
         $prefix = Articles::get_url($item['id'], 'navigate', 'links');
         $box['bar'] += Skin::navigate($home, $prefix, $count, LINKS_PER_PAGE, $zoom_index);
         // new links are allowed
         if ($cur_article->allows('creation', 'link')) {
             Skin::define_img('LINKS_ADD_IMG', 'links/add.gif');
             $box['bar'] += array('links/edit.php?anchor=' . urlencode('article:' . $item['id']) => LINKS_ADD_IMG . i18n::s('Add a link'));
         }
     }
     // there is some box content
     if ($box['text']) {
         $canvas['links'] = Skin::build_content('links', i18n::s('Links'), $box['text'], $box['bar']);
     }
     $canvas['links_count'] = $count;
 }
 //
 // trailer information
 //
Ejemplo n.º 4
0
        $offset = ($zoom_index - 1) * LINKS_PER_PAGE;
        if (preg_match('/\\blinks_by_title\\b/i', $item['options'])) {
            $items = Links::list_by_title_for_anchor('section:' . $item['id'], $offset, LINKS_PER_PAGE, 'no_anchor');
        } else {
            $items = Links::list_by_date_for_anchor('section:' . $item['id'], $offset, LINKS_PER_PAGE, 'no_anchor');
        }
        // actually render the html
        if (is_array($items)) {
            $box['text'] .= Skin::build_list($items, 'rows');
        } elseif (is_string($items)) {
            $box['text'] .= $items;
        }
        // navigation commands for links
        $home = Sections::get_permalink($item);
        $prefix = Sections::get_url($item['id'], 'navigate', 'links');
        $box['bar'] = array_merge($box['bar'], Skin::navigate($home, $prefix, $count, LINKS_PER_PAGE, $zoom_index));
    }
    // new links are allowed -- check option 'with_links'
    if (Links::allow_creation($item, $anchor, 'section')) {
        Skin::define_img('LINKS_ADD_IMG', 'links/add.gif');
        $box['bar'] += array('links/edit.php?anchor=' . urlencode('section:' . $item['id']) => LINKS_ADD_IMG . i18n::s('Add a link'));
    }
    // integrate commands
    if (count($box['bar'])) {
        $box['text'] = Skin::build_list($box['bar'], 'menu_bar') . $box['text'];
    }
    // there is some box content
    if (trim($box['text'])) {
        $attachments .= Skin::build_box(i18n::s('Links'), $box['text'], 'header1', 'links');
    }
}
 /**
  * layout the newest articles
  *
  * caution: this function also updates page title directly, and this makes its call non-cacheable
  *
  * @param array the article
  * @return string the rendered text
  **/
 function layout_newest($item)
 {
     global $context;
     // 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);
     // reset the rendering engine between items
     Codes::initialize($url);
     // build a title
     if (is_object($overlay)) {
         $title = Codes::beautify_title($overlay->get_text('title', $item));
     } else {
         $title = Codes::beautify_title($item['title']);
     }
     // title prefix & suffix
     $text = $prefix = $suffix = '';
     // flag articles updated recently
     if ($context['site_revisit_after'] < 1) {
         $context['site_revisit_after'] = 2;
     }
     $context['fresh'] = gmstrftime('%Y-%m-%d %H:%M:%S', mktime(0, 0, 0, date("m"), date("d") - $context['site_revisit_after'], date("Y")));
     // link to permalink
     if (Surfer::is_empowered()) {
         $title = Skin::build_box_title($title, $url, i18n::s('Permalink'));
     }
     // signal articles to be published
     if ($item['publish_date'] <= NULL_DATE) {
         $prefix .= DRAFT_FLAG;
     } else {
         if ($item['publish_date'] > NULL_DATE && $item['publish_date'] > $context['now']) {
             $prefix .= DRAFT_FLAG;
         }
     }
     // signal restricted and private articles
     if ($item['active'] == 'N') {
         $prefix .= PRIVATE_FLAG . ' ';
     } elseif ($item['active'] == 'R') {
         $prefix .= RESTRICTED_FLAG . ' ';
     }
     // signal locked articles
     if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
         $suffix .= LOCKED_FLAG;
     }
     // flag expired article
     if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
         $suffix .= EXPIRED_FLAG;
     }
     // update page title directly
     $text .= Skin::build_block($prefix . $title . $suffix, 'title');
     // if this article has a specific icon, use it
     if ($item['icon_url']) {
         $icon = $item['icon_url'];
     } elseif ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
         $icon = $anchor->get_icon_url();
     }
     // if we have a valid image
     if (preg_match('/(.gif|.jpg|.jpeg|.png)$/i', $icon)) {
         // fix relative path
         if (!preg_match('/^(\\/|http:|https:|ftp:)/', $icon)) {
             $icon = $context['url_to_root'] . $icon;
         }
         // flush the image on the right
         $text .= '<img src="' . $icon . '" class="right_image" alt="" />';
     }
     // article rating, if the anchor allows for it
     if (!is_object($anchor) || !$anchor->has_option('without_rating')) {
         // report on current rating
         $label = '';
         if ($item['rating_count']) {
             $label = Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])) . ' ';
         }
         $label .= i18n::s('Rate this page');
         // allow for rating
         $text .= Skin::build_link(Articles::get_url($item['id'], 'like'), $label, 'basic');
     }
     // the introduction text, if any
     if (is_object($overlay)) {
         $text .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
     } else {
         $text .= Skin::build_block($item['introduction'], 'introduction');
     }
     // insert overlay data, if any
     if (is_object($overlay)) {
         $text .= $overlay->get_text('view', $item);
     }
     // the beautified description, which is the actual page body
     if ($item['description']) {
         // use adequate label
         if (is_object($overlay) && ($label = $overlay->get_label('description'))) {
             $text .= Skin::build_block($label, 'title');
         }
         $text .= Skin::build_block($item['description'], 'description', '', $item['options']);
     }
     //
     // list related files
     //
     // if this surfer is an editor of this article, show hidden files as well
     if (Articles::is_assigned($item['id']) || is_object($anchor) && $anchor->is_assigned()) {
         Surfer::empower();
     }
     // build a complete box
     $box['bar'] = array();
     $box['text'] = '';
     // count the number of files in this article
     if ($count = Files::count_for_anchor('article:' . $item['id'])) {
         if ($count > 20) {
             $box['bar'] += array('_count' => sprintf(i18n::ns('%d file', '%d files', $count), $count));
         }
         // list files by date (default) or by title (option files_by_title)
         if (Articles::has_option('files_by', $anchor, $item) == 'title') {
             $items = Files::list_by_title_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'article:' . $item['id']);
         } else {
             $items = Files::list_by_date_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'article:' . $item['id']);
         }
         if (is_array($items)) {
             $box['text'] .= Skin::build_list($items, 'decorated');
         }
         // navigation commands for files
         $prefix = Articles::get_url($item['id'], 'navigate', 'files');
         $box['bar'] += Skin::navigate($url, $prefix, $count, FILES_PER_PAGE, 0);
         // the command to post a new file, if allowed
         if (Files::allow_creation($item, $anchor, 'article')) {
             $link = 'files/edit.php?anchor=' . urlencode('article:' . $item['id']);
             $box['bar'] += array($link => i18n::s('Add a file'));
         }
         if (is_array($box['bar'])) {
             $box['text'] .= Skin::build_list($box['bar'], 'menu_bar');
         }
     }
     // actually render the html for this box
     if ($box['text']) {
         $text .= Skin::build_box(i18n::s('Files'), $box['text'], 'header1', 'files');
     }
     //
     // bottom page menu
     //
     // discuss this page, if the index page can be commented, and comments are accepted at the article level
     if (Comments::allow_creation($item, $anchor)) {
         $this->menu[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), i18n::s('Post a comment'), 'span');
     }
     // info on related comments
     if ($count = Comments::count_for_anchor('article:' . $item['id'])) {
         $this->menu[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'list'), sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'span');
     }
     // new links are accepted at the index page and at the article level
     if (Links::allow_trackback()) {
         $this->menu[] = Skin::build_link('links/trackback.php?anchor=' . urlencode('article:' . $item['id']), i18n::s('Reference this page'), 'span');
     }
     // info on related links
     if ($count = Links::count_for_anchor('article:' . $item['id'])) {
         $this->menu[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d link', '%d links', $count), $count), 'span');
     }
     // new files are accepted at the index page and at the article level
     if (is_object($anchor) && $anchor->has_option('with_files') && !($anchor->has_option('no_files') || preg_match('/\\bno_files\\b/i', $item['options']))) {
         // add a file
         if (Files::allow_creation($item, $anchor, 'article')) {
             if ($context['with_friendly_urls'] == 'Y') {
                 $link = 'files/edit.php/article/' . $item['id'];
             } else {
                 $link = 'files/edit.php?anchor=' . urlencode('article:' . $item['id']);
             }
             $this->menu[] = Skin::build_link($link, i18n::s('Add a file'), 'span');
         }
     }
     // modify this page
     if (Surfer::is_empowered()) {
         $this->menu[] = Skin::build_link(Articles::get_url($item['id'], 'edit'), i18n::s('Edit'), 'span');
     }
     // view permalink
     if (Surfer::is_empowered()) {
         $this->menu[] = Skin::build_link($url, i18n::s('Permalink'), 'span');
     }
     // insert overlay data, if any
     if (is_object($overlay)) {
         $text .= $overlay->get_text('trailer', $item);
     }
     // add trailer information from this item, if any
     if (isset($item['trailer']) && trim($item['trailer'])) {
         $text .= Codes::beautify($item['trailer']);
     }
     // returned the formatted content
     return $text;
 }
Ejemplo n.º 6
0
Archivo: index.php Proyecto: rair/yacs
// stop hackers
if ($page > 1 && ($page - 1) * $items_per_page > $stats['count']) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
} else {
    // navigation commands for articles, if necessary
    if ($stats['count'] > $items_per_page) {
        $home = 'articles/';
        if ($context['with_friendly_urls'] == 'Y') {
            $prefix = $home . 'index.php/';
        } elseif ($context['with_friendly_urls'] == 'R') {
            $prefix = $home;
        } else {
            $prefix = $home . '?page=';
        }
        $context['page_menu'] += Skin::navigate($home, $prefix, $stats['count'], $items_per_page, $page);
    }
    // page main content
    $cache_id = 'articles/index.php#text#' . $page;
    if (!($text = Cache::get($cache_id))) {
        // query the database and layout that stuff
        $offset = ($page - 1) * $items_per_page;
        if ($text =& Articles::list_by('publication', $offset, $items_per_page)) {
            // we have an array to format
            if (is_array($text)) {
                $text =& Skin::build_list($text, 'decorated');
            }
        }
        // cache this to speed subsequent queries
        Cache::put($cache_id, $text, 'articles');
    }
Ejemplo n.º 7
0
Archivo: event.php Proyecto: rair/yacs
 /**
  * list dates at some anchor
  *
  * @param string type of replaced items (e.g., 'articles')
  * @param string the anchor to consider (e.g., 'section:123')
  * @param int page index
  * @return string to be inserted in resulting web page, or NULL
  */
 function render($type, $anchor, $page = 1)
 {
     global $context;
     // instead of articles
     if ($type != 'articles') {
         return NULL;
     }
     // get the containing page
     $container = Anchors::get($anchor);
     // handle dates
     include_once $context['path_to_root'] . 'dates/dates.php';
     // the maximum number of articles per page
     if (!defined('DATES_PER_PAGE')) {
         define('DATES_PER_PAGE', 50);
     }
     // where we are
     $offset = ($page - 1) * DATES_PER_PAGE;
     // should we display all dates, or not?
     $with_past_dates = FALSE;
     if (preg_match('/\\bwith_past_dates\\b/i', $this->attributes['overlay_parameters'])) {
         $with_past_dates = TRUE;
     }
     // menu to be displayed at the top
     $menu = array();
     // empowered users can contribute
     if (Articles::allow_creation(NULL, $container)) {
         Skin::define_img('ARTICLES_ADD_IMG', 'articles/add.gif');
         $menu[] = '<div style="display: inline">' . Skin::build_link('articles/edit.php?anchor=' . urlencode($anchor), ARTICLES_ADD_IMG . i18n::s('Add an event'), 'span') . '</div>';
     }
     // ensure access to past dates
     if (!$with_past_dates && ($items = Dates::list_past_for_anchor($anchor, $offset, DATES_PER_PAGE, 'compact'))) {
         // turn an array to a string
         if (is_array($items)) {
             $items =& Skin::build_list($items, 'compact');
         }
         // navigation bar
         $bar = array();
         // count the number of dates in this section
         $stats = Dates::stat_past_for_anchor($anchor);
         if ($stats['count'] > DATES_PER_PAGE) {
             $bar = array_merge($bar, array('_count' => sprintf(i18n::ns('%d date', '%d dates', $stats['count']), $stats['count'])));
         }
         // navigation commands for dates
         if ($section = Sections::get(str_replace('section:', '', $anchor))) {
             $home = Sections::get_permalink($section);
             $prefix = Sections::get_url($section['id'], 'navigate', 'articles');
             $bar = array_merge($bar, Skin::navigate($home, $prefix, $stats['count'], DATES_PER_PAGE, $page));
         }
         // display the bar
         if (is_array($bar)) {
             $items = Skin::build_list($bar, 'menu_bar') . $items;
         }
         // in a separate box
         $menu[] = Skin::build_sliding_box(i18n::s('Past dates'), $items, 'past_dates', TRUE);
     }
     // menu displayed towards the top of the page
     $text = Skin::finalize_list($menu, 'menu_bar');
     // build a list of events
     if (preg_match('/\\blayout_as_list\\b/i', $this->attributes['overlay_parameters'])) {
         // list all dates
         if ($with_past_dates) {
             // navigation bar
             $bar = array();
             // count the number of dates in this section
             $stats = Dates::stat_for_anchor($anchor);
             if ($stats['count'] > DATES_PER_PAGE) {
                 $bar = array_merge($bar, array('_count' => sprintf(i18n::ns('%d date', '%d dates', $stats['count']), $stats['count'])));
             }
             // navigation commands for dates
             $section = Sections::get($anchor);
             $home = Sections::get_permalink($section);
             $prefix = Sections::get_url($section['id'], 'navigate', 'articles');
             $bar = array_merge($bar, Skin::navigate($home, $prefix, $stats['count'], DATES_PER_PAGE, $page));
             // display the bar
             if (count($bar)) {
                 $text .= Skin::build_list($bar, 'menu_bar');
             }
             // list one page of dates
             if ($items = Dates::list_for_anchor($anchor, $offset, DATES_PER_PAGE, 'family')) {
                 $text .= $items;
             }
             // display only future dates to regular surfers
         } else {
             // show future dates on first page
             if ($page == 1 && ($items = Dates::list_future_for_anchor($anchor, 0, 500, 'family', TRUE))) {
                 $text .= $items;
             }
         }
         // deliver a calendar view for current month, plus months around
     } else {
         // show past dates as well
         if ($with_past_dates) {
             $items = Dates::list_for_anchor($anchor, 0, 500, 'links');
         } else {
             $items = Dates::list_future_for_anchor($anchor, 0, 500, 'links', TRUE);
         }
         // layout all these dates
         if ($items) {
             $text .= Dates::build_months($items);
         }
     }
     // integrate this into the page
     return $text;
 }
Ejemplo n.º 8
0
    }
    // a navigation bar for these comments
    if ($count = Comments::count_for_anchor('article:' . $item['id'])) {
        $discussion_count = $count;
        $box['bottom'] += array('_count' => sprintf(i18n::ns('%d comment', '%d comments', $count), $count));
        // list comments by date
        $items = Comments::list_by_date_for_anchor('article:' . $item['id'], $offset, $items_per_page, $layout, TRUE);
        // actually render the html
        if (is_array($items)) {
            $box['text'] .= Skin::build_list($items, 'rows');
        } elseif (is_string($items)) {
            $box['text'] .= $items;
        }
        // navigation commands for comments
        $prefix = Comments::get_url('article:' . $item['id'], 'navigate');
        $box['bottom'] += Skin::navigate(NULL, $prefix, $count, $items_per_page, $zoom_index, FALSE, TRUE);
    }
    // build a box
    if ($box['text']) {
        $discussion .= Skin::build_content('comments', '', $box['text'], $box['top'], $box['bottom']);
    }
}
// display in a separate panel
if ($discussion) {
    $label = i18n::s('Discussion');
    if ($discussion_count) {
        $label .= ' (' . $discussion_count . ')';
    }
    $panels[] = array('discussion', $label, 'discussion_panel', $discussion);
}
//
Ejemplo n.º 9
0
Archivo: list.php Proyecto: rair/yacs
 // a navigation bar for these comments
 include_once '../comments/comments.php';
 if ($count = Comments::count_for_anchor($anchor->get_reference())) {
     if ($count > 1) {
         $label = '';
         if (is_object($anchor->overlay)) {
             $label = $anchor->overlay->get_label('list_title', 'comments');
         }
         if (!$label) {
             $label = i18n::s('Comments');
         }
         $box['bar'] += array('_count' => $count . ' ' . strtolower($label));
     }
     // navigation commands for comments
     $prefix = Comments::get_url($anchor->get_reference(), 'navigate');
     $box['bar'] = array_merge($box['bar'], Skin::navigate($anchor->get_url('comments'), $prefix, $count, $items_per_page, $page, FALSE));
     // list comments by date
     $items = Comments::list_by_date_for_anchor($anchor->get_reference(), $offset, $items_per_page, $layout, TRUE);
     // actually render the html
     if (is_array($items)) {
         $box['text'] .= Skin::build_list($items, 'rows');
     } elseif (is_string($items)) {
         $box['text'] .= $items;
     }
 }
 // the command to post a new comment, if this is allowed
 if (Comments::allow_creation($anchor)) {
     Skin::define_img('COMMENTS_ADD_IMG', 'comments/add.gif');
     $label = '';
     if (is_object($anchor->overlay)) {
         $label = $anchor->overlay->get_label('new_command', 'comments');
Ejemplo n.º 10
0
 /**
  * list articles
  *
  * @param resource the SQL result
  * @return a string to be displayed
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // no hovering label
     $href_title = '';
     // we build an array for the skin::build_tabs() function
     $panels = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // panel content
         $text = '';
         // insert anchor prefix
         if (is_object($anchor)) {
             $text .= $anchor->get_prefix();
         }
         // the introduction text, if any
         if (is_object($overlay)) {
             $text .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
         } elseif (isset($item['introduction']) && trim($item['introduction'])) {
             $text .= Skin::build_block($item['introduction'], 'introduction');
         }
         // get text related to the overlay, if any
         if (is_object($overlay)) {
             $text .= $overlay->get_text('view', $item);
         }
         // filter description, if necessary
         if (is_object($overlay)) {
             $description = $overlay->get_text('description', $item);
         } else {
             $description = $item['description'];
         }
         // the beautified description, which is the actual page body
         if ($description) {
             // use adequate label
             if (is_object($overlay) && ($label = $overlay->get_label('description'))) {
                 $text .= Skin::build_block($label, 'title');
             }
             // beautify the target page
             $text .= Skin::build_block($description, 'description', '', $item['options']);
         }
         // list files only to people able to change the page
         if (Articles::allow_modification($item, $anchor)) {
             $embedded = NULL;
         } else {
             $embedded = Codes::list_embedded($item['description']);
         }
         // build a complete box
         $box = array('bar' => array(), 'text' => '');
         // count the number of files in this article
         if ($count = Files::count_for_anchor('article:' . $item['id'], FALSE, $embedded)) {
             if ($count > 20) {
                 $box['bar'] += array('_count' => sprintf(i18n::ns('%d file', '%d files', $count), $count));
             }
             // list files by date (default) or by title (option files_by_title)
             $offset = ($zoom_index - 1) * FILES_PER_PAGE;
             if (Articles::has_option('files_by', $anchor, $item) == 'title') {
                 $items = Files::list_by_title_for_anchor('article:' . $item['id'], 0, 300, 'article:' . $item['id'], $embedded);
             } else {
                 $items = Files::list_by_date_for_anchor('article:' . $item['id'], 0, 300, 'article:' . $item['id'], $embedded);
             }
             // actually render the html
             if (is_array($items)) {
                 $box['text'] .= Skin::build_list($items, 'decorated');
             } elseif (is_string($items)) {
                 $box['text'] .= $items;
             }
             // the command to post a new file
             if (Files::allow_creation($item, $anchor, 'article')) {
                 Skin::define_img('FILES_UPLOAD_IMG', 'files/upload.gif');
                 $box['bar'] += array('files/edit.php?anchor=' . urlencode('article:' . $item['id']) => FILES_UPLOAD_IMG . i18n::s('Add a file'));
             }
         }
         // some files have been attached to this page
         if ($page == 1 && $count > 1) {
             // the command to download all files
             $link = 'files/fetch_all.php?anchor=' . urlencode('article:' . $item['id']);
             if ($count > 20) {
                 $label = i18n::s('Zip 20 first files');
             } else {
                 $label = i18n::s('Zip all files');
             }
             $box['bar'] += array($link => $label);
         }
         // there is some box content
         if ($box['text']) {
             $text .= Skin::build_content('files', i18n::s('Files'), $box['text'], $box['bar']);
         }
         // list of comments
         $title_label = '';
         if (is_object($anchor)) {
             $title_label = ucfirst($overlay->get_label('list_title', 'comments'));
         }
         if (!$title_label) {
             $title_label = i18n::s('Comments');
         }
         // no layout yet
         $layout = NULL;
         // label to create a comment
         $add_label = '';
         if (is_object($overlay)) {
             $add_label = $overlay->get_label('new_command', 'comments');
         }
         if (!$add_label) {
             $add_label = i18n::s('Post a comment');
         }
         // get a layout from anchor
         $layout =& Comments::get_layout($anchor, $item);
         // provide author information to layout
         if (is_object($layout) && isset($item['create_id']) && $item['create_id']) {
             $layout->set_focus('user:'******'create_id']);
         }
         // the maximum number of comments per page
         if (is_object($layout)) {
             $items_per_page = $layout->items_per_page();
         } else {
             $items_per_page = COMMENTS_PER_PAGE;
         }
         // the first comment to list
         $offset = 0;
         if (is_object($layout) && method_exists($layout, 'set_offset')) {
             $layout->set_offset($offset);
         }
         // build a complete box
         $box = array('bar' => array(), 'prefix_bar' => array(), 'text' => '');
         // feed the wall
         if (Comments::allow_creation($item, $anchor)) {
             $box['text'] .= Comments::get_form('article:' . $item['id']);
         }
         // a navigation bar for these comments
         if ($count = Comments::count_for_anchor('article:' . $item['id'])) {
             if ($count > 20) {
                 $box['bar'] += array('_count' => sprintf(i18n::ns('%d comment', '%d comments', $count), $count));
             }
             // list comments by date
             $items = Comments::list_by_date_for_anchor('article:' . $item['id'], $offset, $items_per_page, $layout, TRUE);
             // actually render the html
             if (is_array($items)) {
                 $box['text'] .= Skin::build_list($items, 'rows');
             } elseif (is_string($items)) {
                 $box['text'] .= $items;
             }
             // navigation commands for comments
             $prefix = Comments::get_url('article:' . $item['id'], 'navigate');
             $box['bar'] = array_merge($box['bar'], Skin::navigate(NULL, $prefix, $count, $items_per_page, $zoom_index));
         }
         // ensure that the surfer can change content
         if (Articles::allow_modification($item, $anchor)) {
             // view or modify this section
             $menu = array();
             $box['bar'] += array(Articles::get_permalink($item) => i18n::s('View the page'));
             if (!is_object($overlay) || !($label = $overlay->get_label('edit_command', 'articles'))) {
                 $label = i18n::s('Edit this page');
             }
             $box['bar'] += array(Articles::get_url($item['id'], 'edit') => $label);
         }
         // show commands
         if (count($box['bar'])) {
             // commands before the box
             $box['text'] = Skin::build_list($box['prefix_bar'], 'menu_bar') . $box['text'];
             // append the menu bar at the end
             $box['text'] .= Skin::build_list($box['bar'], 'menu_bar');
         }
         // build a box
         if ($box['text']) {
             // put a title if there are other titles or if more than 2048 chars
             $title = '';
             if (preg_match('/(<h1|<h2|<h3|<table|\\[title|\\[subtitle)/i', $context['text'] . $text) || strlen($context['text'] . $text) > 2048) {
                 $title = $title_label;
             }
             // insert a full box
             $text .= Skin::build_box($title, $box['text'], 'header1', 'comments');
         }
         // assemble the full panel
         $panels[] = array('att' . $item['id'], ucfirst(Skin::strip($item['title'], 30)), 'atc' . $item['id'], $text);
     }
     // there is some box content
     if (trim($box['text'])) {
         $text .= $box['text'];
     }
     // format tabs
     $text = Skin::build_tabs($panels);
     // end of processing
     SQL::free($result);
     return $text;
 }
Ejemplo n.º 11
0
Archivo: list.php Proyecto: rair/yacs
 // count versions in the database
 $stats = Versions::stat_for_anchor($anchor->get_reference());
 $stats['count'] += 1;
 if ($stats['count'] > VERSIONS_PER_PAGE) {
     // total count of versions
     $box['bar'] += array('_count' => sprintf(i18n::ns('%d version', '%d versions', $stats['count']), $stats['count']));
     // navigation commands
     $home = 'versions/list.php';
     if ($context['with_friendly_urls'] == 'Y') {
         $prefix = $home . '/' . str_replace(':', '/', $anchor->get_reference());
     } elseif ($context['with_friendly_urls'] == 'R') {
         $prefix = $home . '/' . str_replace(':', '/', $anchor->get_reference());
     } else {
         $prefix = $home . '?id=' . $anchor->get_reference() . '&page=';
     }
     $box['bar'] += Skin::navigate($home, $prefix, $stats['count'], VERSIONS_PER_PAGE, $page);
 }
 // query the database and layout that stuff
 $offset = ($page - 1) * VERSIONS_PER_PAGE;
 if ($items = Versions::list_by_date_for_anchor($anchor->get_reference(), $offset, VERSIONS_PER_PAGE, 'full')) {
     // we have an array to format
     if (@count($items)) {
         $items = array_merge(array('_' => sprintf(i18n::s('edited by %s %s'), ucfirst($anchor->get_value('edit_name')), Skin::build_date($anchor->get_value('edit_date')))), $items);
         $box['text'] .= Skin::build_list($items, 'decorated');
     }
     // layout everything in a box
     if (count($box['bar'])) {
         $box['text'] = Skin::build_list($box['bar'], 'menu_bar') . "\n" . $box['text'];
     }
     $text =& Skin::build_box($box['title'], $box['text']);
 }
Ejemplo n.º 12
0
Archivo: view.php Proyecto: rair/yacs
     $box['top'] += array('sections/new.php' => SECTIONS_ADD_IMG . i18n::s('Create a new web space'));
 }
 // associates can assign editors and readers
 if (Surfer::is_associate()) {
     Skin::define_img('SECTIONS_SELECT_IMG', 'sections/select.gif');
     $box['top'] += array('sections/select.php?anchor=user:'******'id'] => SECTIONS_SELECT_IMG . i18n::s('Assign sections'));
 }
 // count the number of articles for this user
 $count = Sections::count_for_user($item['id']);
 if ($count) {
     $box['bottom'] += array('_count' => sprintf(i18n::ns('%d section', '%d sections', $count), $count));
 }
 // navigation commands for articles
 $home = Users::get_permalink($item);
 $prefix = Users::get_url($item['id'], 'navigate', 'sections');
 $box['bottom'] = array_merge($box['bottom'], Skin::navigate($home, $prefix, $count, SECTIONS_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) * SECTIONS_PER_PAGE;
 // list assigned by title
 $layout = Layouts::new_('rights', 'section');
 $layout->set_focus($item['id']);
 $items =& Sections::list_by_date_for_user($item['id'], $offset, SECTIONS_PER_PAGE, $layout);
 if (is_array($items)) {
     $box['text'] .= Skin::build_list($items, 'compact');
 } elseif ($items) {
     $box['text'] .= $items;
Ejemplo n.º 13
0
 /**
  * list sections
  *
  * @param resource the SQL result
  * @return a string to be displayed
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // no hovering label
     $href_title = '';
     // we build an array for the skin::build_tabs() function
     $panels = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'section:' . $item['id']);
         // get the overlay for content of this section, if any
         $content_overlay = NULL;
         if (isset($item['content_overlay'])) {
             $content_overlay = Overlay::bind($item['content_overlay']);
         }
         // panel content
         $text = '';
         // insert anchor prefix
         if (is_object($anchor)) {
             $text .= $anchor->get_prefix();
         }
         // the introduction text, if any
         if (is_object($overlay)) {
             $text .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
         } elseif (isset($item['introduction']) && trim($item['introduction'])) {
             $text .= Skin::build_block($item['introduction'], 'introduction');
         }
         // get text related to the overlay, if any
         if (is_object($overlay)) {
             $text .= $overlay->get_text('view', $item);
         }
         // filter description, if necessary
         if (is_object($overlay)) {
             $description = $overlay->get_text('description', $item);
         } else {
             $description = $item['description'];
         }
         // the beautified description, which is the actual page body
         if ($description) {
             // use adequate label
             if (is_object($overlay) && ($label = $overlay->get_label('description'))) {
                 $text .= Skin::build_block($label, 'title');
             }
             // beautify the target page
             $text .= Skin::build_block($description, 'description', '', $item['options']);
         }
         // delegate rendering to the overlay, where applicable
         if (is_object($content_overlay) && ($overlaid = $content_overlay->render('articles', 'section:' . $item['id'], 1))) {
             $text .= $overlaid;
             // regular rendering
         } elseif (!isset($item['articles_layout']) || $item['articles_layout'] != 'none') {
             // select a layout
             if (!isset($item['articles_layout']) || !$item['articles_layout']) {
                 include_once '../articles/layout_articles.php';
                 $layout = new Layout_articles();
             } else {
                 $layout = Layouts::new_($item['articles_layout'], 'article');
             }
             // avoid links to this page
             if (is_object($layout) && is_callable(array($layout, 'set_variant'))) {
                 $layout->set_focus('section:' . $item['id']);
             }
             // the maximum number of articles per page
             if (is_object($layout)) {
                 $items_per_page = $layout->items_per_page();
             } else {
                 $items_per_page = ARTICLES_PER_PAGE;
             }
             // sort and list articles
             $offset = 0;
             if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
                 $order = $matches[1];
             } elseif (is_callable(array($layout, 'items_order'))) {
                 $order = $layout->items_order();
             } else {
                 $order = 'edition';
             }
             // create a box
             $box = array('top_bar' => array(), 'text' => '', 'bottom_bar' => array());
             // the command to post a new page
             //if(Articles::allow_creation($item, $anchor)) {
             if ($anchor->allows('creation', 'article')) {
                 Skin::define_img('ARTICLES_ADD_IMG', 'articles/add.gif');
                 $url = 'articles/edit.php?anchor=' . urlencode('section:' . $item['id']);
                 if (is_object($content_overlay) && ($label = $content_overlay->get_label('new_command', 'articles'))) {
                 } else {
                     $label = ARTICLES_ADD_IMG . i18n::s('Add a page');
                 }
                 $box['top_bar'] += array($url => $label);
             }
             // list pages under preparation
             $this_section = new section();
             $this_section->load_by_content($item, $anchor);
             if ($this_section->is_assigned()) {
                 if ($order == 'publication' && ($items =& Articles::list_for_anchor_by('draft', 'section:' . $item['id'], 0, 20, 'compact'))) {
                     if (is_array($items)) {
                         $items = Skin::build_list($items, 'compact');
                     }
                     $box['top_bar'] += array('_draft' => Skin::build_sliding_box(i18n::s('Draft pages'), $items));
                 }
             }
             // top menu
             if ($box['top_bar']) {
                 $box['text'] .= Skin::build_list($box['top_bar'], 'menu_bar');
             }
             // get pages
             $items =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], $offset, $items_per_page, $layout);
             // items in the middle
             if (is_array($items) && isset($item['articles_layout']) && $item['articles_layout'] == 'compact') {
                 $box['text'] .= Skin::build_list($items, 'compact');
             } elseif (is_array($items)) {
                 $box['text'] .= Skin::build_list($items, 'decorated');
             } elseif (is_string($items)) {
                 $box['text'] .= $items;
             }
             // no navigation bar with alistapart
             if (!isset($item['articles_layout']) || $item['articles_layout'] != 'alistapart') {
                 // count the number of articles in this section
                 if ($count = Articles::count_for_anchor('section:' . $item['id'])) {
                     if ($count > 20) {
                         $box['bottom_bar'] += array('_count' => sprintf(i18n::ns('%d page', '%d pages', $count), $count));
                     }
                     // navigation commands for articles
                     $home = Sections::get_permalink($item);
                     $prefix = Sections::get_url($item['id'], 'navigate', 'articles');
                     $box['bottom_bar'] += Skin::navigate($home, $prefix, $count, $items_per_page, 1);
                 }
             }
             // bottom menu
             if ($box['bottom_bar']) {
                 $box['text'] .= Skin::build_list($box['bottom_bar'], 'menu_bar');
             }
             // there is some box content
             if ($box['text']) {
                 $text .= $box['text'];
             }
         }
         // layout sub-sections
         if (!isset($item['sections_layout']) || $item['sections_layout'] != 'none') {
             // select a layout
             if (!isset($item['sections_layout']) || !$item['sections_layout']) {
                 include_once 'layout_sections.php';
                 $layout = new Layout_sections();
             } else {
                 $layout = Layouts::new_($item['sections_layout'], 'section');
             }
             // the maximum number of sections per page
             if (is_object($layout)) {
                 $items_per_page = $layout->items_per_page();
             } else {
                 $items_per_page = SECTIONS_PER_PAGE;
             }
             // build a complete box
             $box = array('top_bar' => array(), 'text' => '', 'bottom_bar' => array());
             // the command to add a new section
             //if(Sections::allow_creation($item, $anchor)) {
             if ($anchor->allows('creation', 'section')) {
                 Skin::define_img('SECTIONS_ADD_IMG', 'sections/add.gif');
                 $box['top_bar'] += array('sections/edit.php?anchor=' . urlencode('section:' . $item['id']) => SECTIONS_ADD_IMG . i18n::s('Add a section'));
             }
             // top menu
             if ($box['top_bar']) {
                 $box['text'] .= Skin::build_list($box['top_bar'], 'menu_bar');
             }
             // list items by family then title
             $offset = 0 * $items_per_page;
             $items = Sections::list_by_title_for_anchor('section:' . $item['id'], $offset, $items_per_page, $layout, TRUE);
             // actually render the html for the section
             if (is_array($items) && is_string($item['sections_layout']) && $item['sections_layout'] == 'compact') {
                 $box['text'] .= Skin::build_list($items, 'compact');
             } elseif (is_array($items)) {
                 $box['text'] .= Skin::build_list($items, 'decorated');
             } elseif (is_string($items)) {
                 $box['text'] .= $items;
             }
             // count the number of subsections
             if ($count = Sections::count_for_anchor('section:' . $item['id'])) {
                 if ($count > 20) {
                     $box['bottom_bar'] = array('_count' => sprintf(i18n::ns('%d section', '%d sections', $count), $count));
                 }
                 // navigation commands for sections
                 $home = Sections::get_permalink($item);
                 $prefix = Sections::get_url($item['id'], 'navigate', 'sections');
                 $box['bottom_bar'] += Skin::navigate($home, $prefix, $count, $items_per_page, 1);
             }
             // bottom menu
             if ($box['bottom_bar']) {
                 $box['text'] .= Skin::build_list($box['bottom_bar'], 'menu_bar');
             }
             // there is some box content
             if ($box['text']) {
                 $text .= $box['text'];
             }
         }
         // ensure that the surfer can change content
         if (Sections::allow_modification($item, $anchor)) {
             // view or modify this section
             $menu = array();
             $menu[] = Skin::build_link(Sections::get_permalink($item), i18n::s('View the sub-section'), 'span');
             if (!is_object($overlay) || !($label = $overlay->get_label('edit_command', 'sections'))) {
                 $label = i18n::s('Edit this sub-section');
             }
             $menu[] = Skin::build_link(Sections::get_url($item['id'], 'edit'), $label, 'span');
             $text .= Skin::finalize_list($menu, 'menu_bar');
         }
         // assemble the full panel
         $panels[] = array('stt' . $item['id'], ucfirst(Skin::strip($item['title'], 30)), 'stc' . $item['id'], $text);
     }
     // format tabs
     if ($this->has_variant('as_array')) {
         $text = $panels;
     } else {
         $text = Skin::build_tabs($panels);
     }
     // end of processing
     SQL::free($result);
     return $text;
 }
Ejemplo n.º 14
0
Archivo: index.php Proyecto: rair/yacs
 // we have an array to format
 if (is_array($items)) {
     $items =& Skin::build_list($items, '2-columns');
 }
 // navigation commands for sections, if necessary
 if ($count > 20) {
     $menu = array('_count' => Skin::build_number($count, i18n::s('sections')));
     $home = 'sections/';
     if ($context['with_friendly_urls'] == 'Y') {
         $prefix = $home . 'index.php/';
     } elseif ($context['with_friendly_urls'] == 'R') {
         $prefix = $home;
     } else {
         $prefix = $home . '?page=';
     }
     $menu = array_merge($menu, Skin::navigate($home, $prefix, $count, $items_per_page, $page));
     // add a menu at the bottom
     $text .= Skin::build_list($menu, 'menu_bar');
 }
 // make a box
 if ($items) {
     $text .= Skin::build_box('', $items, 'header1', 'sections');
 }
 // associates may list specific sections as well
 if ($page == 1 && Surfer::is_associate()) {
     // load the layout to use
     $layout = Layouts::new_('yahoo', 'section');
     $layout->set_variant(20);
     // show more elements at the site map
     // query the database and layout that stuff
     if ($items = Sections::list_inactive_by_title_for_anchor(NULL, 0, 50, $layout)) {
Ejemplo n.º 15
0
Archivo: view.php Proyecto: rair/yacs
         if (is_array($items) && is_string($item['sections_layout']) && $item['sections_layout'] == 'compact') {
             $box['text'] .= Skin::build_list($items, 'compact');
         } elseif (is_array($items)) {
             $box['text'] .= Skin::build_list($items, 'decorated');
         } elseif (is_string($items)) {
             $box['text'] .= $items;
         }
         // count the number of subsections
         if ($count = Sections::count_for_anchor('section:' . $item['id'])) {
             if ($count > 20) {
                 $box['bottom_bar'] = array('_count' => sprintf(i18n::ns('%d section', '%d sections', $count), $count));
             }
             // navigation commands for sections
             $home = Sections::get_permalink($item);
             $prefix = Sections::get_url($item['id'], 'navigate', 'sections');
             $box['bottom_bar'] += Skin::navigate($home, $prefix, $count, $items_per_page, $zoom_index);
         }
         // bottom menu
         if ($box['bottom_bar']) {
             $box['text'] .= Skin::build_list($box['bottom_bar'], 'menu_bar');
         }
         // there is some box content
         if ($box['text']) {
             $text .= $box['text'];
         }
     }
 }
 //
 // inactive sub sections
 //
 // associates may list special sections as well
Ejemplo n.º 16
0
Archivo: index.php Proyecto: rair/yacs
// stop hackers
if ($page > 1 && ($page - 1) * THREADS_PER_PAGE > $stats['count']) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
} else {
    // navigation commands for comments, if necessary
    if ($stats['count'] > THREADS_PER_PAGE) {
        $home = 'comments/';
        if ($context['with_friendly_urls'] == 'Y') {
            $prefix = $home . 'index.php/';
        } elseif ($context['with_friendly_urls'] == 'R') {
            $prefix = $home;
        } else {
            $prefix = $home . '?page=';
        }
        $context['page_menu'] += Skin::navigate($home, $prefix, $stats['count'], THREADS_PER_PAGE, $page);
    }
    // page main content
    $cache_id = 'comments/index.php#text#' . $page;
    if (!($text = Cache::get($cache_id))) {
        // the first comment to list
        $offset = ($page - 1) * THREADS_PER_PAGE;
        // load the layout to use
        $layout = Layouts::new_('yabb', 'article');
        // query the database and layout that stuff
        if (!($text = Comments::list_threads_by_date($offset, THREADS_PER_PAGE, $layout))) {
            $context['text'] .= '<p>' . i18n::s('No comment has been transmitted.') . '</p>';
        }
        // we have an array to format
        if (is_array($text)) {
            $text =& Skin::build_list($text, 'rows');
Ejemplo n.º 17
0
Archivo: view.php Proyecto: rair/yacs
 }
 // count the number of users in this category
 $count = Members::count_users_for_anchor('category:' . $item['id']);
 // notify members
 if ($count > 1 && Surfer::is_associate()) {
     Skin::define_img('CATEGORIES_EMAIL_IMG', 'categories/email.gif');
     $box['bar'] += array(Categories::get_url($item['id'], 'mail') => CATEGORIES_EMAIL_IMG . i18n::s('Notify members'));
 }
 // spread the list over several pages
 if ($count > USERS_LIST_SIZE) {
     $box['bar'] += array('_count' => sprintf(i18n::ns('%d user', '%d users', $count), $count));
 }
 // navigation commands for users
 $home = Categories::get_permalink($item);
 $prefix = Categories::get_url($item['id'], 'navigate', 'users');
 $box['bar'] = array_merge($box['bar'], Skin::navigate($home, $prefix, $count, USERS_LIST_SIZE, $zoom_index));
 // list items by date (default) or by title (option 'users_by_title')
 $offset = ($zoom_index - 1) * USERS_LIST_SIZE;
 $items =& Members::list_users_by_name_for_anchor('category:' . $item['id'], $offset, USERS_LIST_SIZE, $layout);
 // actually render the html
 if ($box['bar']) {
     $box['text'] .= Skin::build_list($box['bar'], 'menu_bar');
 }
 if (is_array($items)) {
     $box['text'] .= Skin::build_list($items, 'decorated');
 } elseif (is_string($items)) {
     $box['text'] .= $items;
 }
 if ($box['bar'] && $stats['count'] - $offset > 5) {
     $box['text'] .= Skin::build_list($box['bar'], 'menu_bar');
 }