Exemple #1
0
 if (!($text = Cache::get($cache_id))) {
     // loads feeding parameters
     Safe::load('parameters/feeds.include.php');
     // structured data
     $values = array();
     $values['channel'] = array();
     // set channel information
     $values['channel']['title'] = $item['full_name'] ? $item['full_name'] : $item['nick_name'];
     $values['channel']['link'] = Users::get_permalink($item);
     $values['channel']['description'] = $item['introduction'];
     // the image for this channel
     if (isset($context['powered_by_image']) && $context['powered_by_image']) {
         $values['channel']['image'] = $context['url_to_home'] . $context['url_to_root'] . $context['powered_by_image'];
     }
     // the list of newest pages
     $values['items'] = (array) Articles::list_for_author_by('publication', $item['id'], 0, 50, 'feed');
     // make a text
     include_once '../services/codec.php';
     include_once '../services/rss_codec.php';
     $result = rss_Codec::encode($values);
     $status = @$result[0];
     $text = @$result[1];
     // save in cache for the next request
     Cache::put($cache_id, $text, 'articles');
 }
 //
 // transfer to the user agent
 //
 // handle the output correctly
 render_raw('text/xml; charset=' . $context['charset']);
 // suggest a name on download
Exemple #2
0
 /**
  * select a random page
  *
  * 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_random($anchor = '', $layout = '')
 {
     global $context;
     // we return some text;
     $text = '';
     // label is explicit
     $label = '';
     if ($position = strrpos($anchor, ',')) {
         $label = trim(substr($anchor, $position + 1));
         $anchor = trim(substr($anchor, 0, $position));
     }
     // scope is limited to current surfer
     if ($anchor == 'self' && Surfer::get_id()) {
         $anchor = 'user:'******'section:', 8)) {
         // look at this branch of the content tree
         $anchors = Sections::get_branch_at_anchor($anchor);
         // query the database and layout that stuff
         $items =& Articles::list_for_anchor_by('random', $anchors, 0, 1, 'raw');
         // scope is limited to one author
     } elseif (!strncmp($anchor, 'user:'******'random', str_replace('user:'******'', $anchor), 0, 1, 'raw');
     } else {
         $items =& Articles::list_by('random', 0, 1, 'raw');
     }
     // we have an array to format
     if ($items) {
         foreach ($items as $id => $item) {
             // make a link to the target page
             $link = Articles::get_permalink($item);
             if (!$label) {
                 $label = Skin::strip($item['title']);
             }
             $text =& Skin::build_link($link, $label, 'article');
             if ($layout == 'description') {
                 // the introduction text, if any
                 $text .= BR . Codes::beautify($item['introduction']);
                 // load overlay, if any
                 if (isset($item['overlay']) && $item['overlay']) {
                     $overlay = Overlay::load($item, 'article:' . $item['id']);
                     // get text related to the overlay, if any
                     if (is_object($overlay)) {
                         $text .= $overlay->get_text('view', $item);
                     }
                 }
                 // the description, which is the actual page body
                 $text .= '<div>' . Codes::beautify($item['description']) . '</div>';
             }
             // we take only one item
             break;
         }
     }
     // job done
     return $text;
 }