Beispiel #1
0
 /**
  * list images
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the anchor for this image
         if ($item['anchor']) {
             $anchor = Anchors::get($item['anchor']);
         }
         // url to view the image
         $url = $context['url_to_home'] . $context['url_to_root'] . Images::get_url($item['id']);
         // time of last update
         $time = SQL::strtotime($item['edit_date']);
         // the title as the label
         if ($item['title']) {
             $label = ucfirst($item['title']) . ' (' . $item['image_name'] . ')';
         } else {
             $label = $item['image_name'];
         }
         // the section
         $section = '';
         if (is_object($anchor)) {
             $section = ucfirst($anchor->get_title());
         }
         // the author(s) is an e-mail address, according to rss 2.0 spec
         $author = $item['create_address'] . ' (' . $item['create_name'] . ')';
         if ($item['create_address'] != $item['edit_address']) {
             if ($author) {
                 $author .= ', ';
             }
             $author .= $item['edit_address'] . ' (' . $item['edit_name'] . ')';
         }
         // the description
         $description = Codes::beautify($item['description']);
         // cap the number of words
         $description = Skin::cap($description, 300);
         // fix image references
         $description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description);
         $introduction = $description;
         // other rss fields
         $extensions = array();
         // url for enclosure
         $type = Files::get_mime_type($item['image_name']);
         $extensions[] = '<enclosure url="' . $context['url_to_home'] . $context['url_to_root'] . Files::get_path($item['anchor'], 'images') . '/' . $item['image_name'] . '"' . ' length="' . $item['image_size'] . '"' . ' type="' . $type . '" />';
         // list all components for this item
         $items[$url] = array($time, $label, $author, $section, NULL, $introduction, $description, $extensions);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Beispiel #2
0
 /**
  * list links
  *
  * @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;
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the anchor for this link
         if ($item['anchor']) {
             $anchor = Anchors::get($item['anchor']);
         }
         // url is the link itself
         $url = $item['link_url'];
         // time of last update
         $time = SQL::strtotime($item['edit_date']);
         // the title as the label
         if ($item['title']) {
             $label = $item['title'];
         } else {
             $label = $url;
         }
         // the section
         $section = '';
         if (is_object($anchor)) {
             $section = ucfirst($anchor->get_title());
         }
         // the author(s) is an e-mail address, according to rss 2.0 spec
         $author = $item['edit_address'] . ' (' . $item['edit_name'] . ')';
         // the description
         $description = Codes::beautify($item['description']);
         // cap the number of words
         $description = Skin::cap($description, 300);
         // fix image references
         $description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description);
         $introduction = $description;
         // other rss fields
         $extensions = array();
         // list all components for this item
         $items[$url] = array($time, $label, $author, $section, NULL, $introduction, $description, $extensions);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Beispiel #3
0
 /**
  * list users
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // url to view the user profile
         $url = Users::get_permalink($item);
         // time of last update
         $time = SQL::strtotime($item['edit_date']);
         // item title
         if ($item['full_name']) {
             $label = ucfirst(Skin::strip($item['full_name'], 10));
         } else {
             $label = ucfirst(Skin::strip($item['nick_name'], 10));
         }
         // the section
         $section = '';
         // the author(s) is an e-mail address, according to rss 2.0 spec
         $author .= $item['edit_address'] . ' (' . $item['edit_name'] . ')';
         // introduction
         $introduction = Codes::beautify($item['introduction']);
         // the description
         $description = Codes::beautify($item['description']);
         // cap the number of words
         $description = Skin::cap($description, 300);
         // fix image references
         $description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description);
         // other rss fields
         $extensions = array();
         // list all components for this item
         $items[$url] = array($time, $label, $author, $section, $icon, $introduction, $description, $extensions);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
 /**
  * layout one of the newest articles
  *
  * @param array the article
  * @return string the rendered text
  */
 function layout_newest($item)
 {
     global $context;
     // permalink
     $url = Articles::get_permalink($item);
     // get the related overlay, if any
     $overlay = Overlay::load($item, 'article:' . $item['id']);
     // get the anchor
     $anchor = Anchors::get($item['anchor']);
     // the icon to put aside
     $icon = '';
     if ($item['thumbnail_url']) {
         $icon = $item['thumbnail_url'];
     }
     if ($icon) {
         $icon = '<img src="' . $icon . '" class="left_image" alt="" />';
     }
     // 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']);
     }
     // signal restricted and private articles
     if ($item['active'] == 'N') {
         $title = PRIVATE_FLAG . ' ' . $title;
     } elseif ($item['active'] == 'R') {
         $title = RESTRICTED_FLAG . ' ' . $title;
     }
     // rating
     if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
         $title .= ' ' . Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
     }
     // pack in a block
     $text = '<h3>' . Skin::build_link($url, $icon . $title, 'basic') . '</h3>';
     // display all tags
     if ($item['tags']) {
         $text .= ' <p class="tags" style="margin: 3px 0;">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</p>';
     }
     // the introduction
     $text .= '<div style="margin: 3px 0;">';
     // the introductory text
     if (is_object($overlay)) {
         $text .= Codes::beautify_introduction($overlay->get_text('introduction', $item));
     } elseif ($item['introduction']) {
         $text .= Codes::beautify_introduction($item['introduction']) . ' ' . Skin::build_link($url, i18n::s('More') . MORE_IMG, 'basic');
     } else {
         $text .= Skin::cap(Codes::beautify($item['description'], $item['options']), 25, $url);
     }
     // end of the introduction
     $text .= '</div>' . "\n";
     // insert overlay data, if any
     if (is_object($overlay)) {
         $text .= $overlay->get_text('list', $item);
     }
     // other details
     $details = array();
     // the author
     $author = '';
     if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
         $author = sprintf(i18n::s('by %s'), $item['create_name']) . ' ';
     }
     // date
     $details[] = $author . Skin::build_date($item['publish_date']);
     // info on related files
     if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
         $details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d file', '%d files', $count), $count), 'basic');
     }
     // info on related comments
     $link = Comments::get_url('article:' . $item['id'], 'list');
     if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
         $details[] = Skin::build_link($link, sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'basic');
     }
     // discuss
     if (Comments::allow_creation($item, $anchor)) {
         $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), i18n::s('Discuss'), 'basic');
     }
     // info on related links
     if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
         $details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d link', '%d links', $count), $count), 'basic');
     }
     // append a menu
     $text .= Skin::finalize_list($details, 'menu');
     return $text;
 }
Beispiel #5
0
    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // describe the article
} else {
    // initialize the rendering engine
    Codes::initialize(Articles::get_permalink($item));
    // compute the url for this article
    $permanent_link = Articles::get_permalink($item);
    // the trackback link
    $trackback_link = $context['url_to_home'] . $context['url_to_root'] . 'links/trackback.php?anchor=article:' . $item['id'];
    // get a description -- render codes
    if (isset($item['introduction']) && $item['introduction']) {
        $description = Codes::beautify($item['introduction'], $item['options']);
    } else {
        $description = Skin::cap(Codes::beautify($item['description'], $item['options']), 50);
    }
    // prepare the response
    $text = '<?xml version="1.0" encoding="' . $context['charset'] . '"?>' . "\n" . '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"' . "\n" . '		   xmlns:dc="http://purl.org/dc/elements/1.1/"' . "\n" . '		   xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">' . "\n" . '	<rdf:Description' . "\n" . '		trackback:ping="' . $trackback_link . '"' . "\n" . '		dc:identifier="' . $permanent_link . '"' . "\n" . '		rdf:about="' . $permanent_link . '">' . "\n" . '		<dc:title>' . encode_field($item['title']) . '</dc:title>' . "\n" . '		<dc:description>' . encode_field(Skin::strip($description)) . '</dc:description>' . "\n" . '		<dc:creator>' . $item['create_name'] . '</dc:creator>' . "\n" . '		<dc:date>' . gmdate('Y-m-d') . '</dc:date>' . "\n" . '		<dc:format>text/html</dc:format>' . "\n";
    if (isset($item['language']) && $item['language'] && $item['language'] != 'none') {
        $text .= '		<dc:language>' . $item['language'] . '</dc:language>' . "\n";
    }
    if (is_object($anchor)) {
        $text .= '	<dc:subject>' . encode_field($anchor->get_title()) . '</dc:subject>' . "\n";
    }
    $text .= '	</rdf:Description>' . "\n" . '</rdf:RDF>';
    //
    // transfer to the user agent
    //
    // handle the output correctly
    render_raw('text/xml; charset=' . $context['charset']);
Beispiel #6
0
 /**
  * get some introductory text from this anchor
  *
  * This function is used to introduce comments, or any sub-item related to an anchor.
  *
  * This basic version does not care about the provided parameter.
  *
  * @param string an optional variant
  * @return string some text or NULL
  */
 function &get_teaser($variant = 'basic')
 {
     // nothing to do
     if (!is_array($this->item)) {
         $text = NULL;
     } elseif ($intro = $this->get_introduction()) {
         $text = Codes::beautify($intro, $this->item['options']);
     } else {
         $text = Skin::cap(Codes::beautify($this->item['description'], $this->item['options']), 70);
     }
     // done
     return $text;
 }
Beispiel #7
0
 /**
  * get some introductory text from an article
  *
  * This function is used to introduce comments, or any sub-item related to an anchor.
  * Compared to the standard anchor implementation, this one adds the ability to handle overlay data.
  *
  * If there is some introductory text, it is used. Else the description text is used instead.
  * The number of words is capped in both cases.
  *
  * Also, the number of remaining words is provided.
  *
  * Following variants may be selected to adapt to various situations:
  * - 'basic' - strip every tag, we want almost plain ASCII - maybe this will be send in a mail message
  * - 'hover' - some text to be displayed while hovering a link
  * - 'quote' - strip most HTML tags
  * - 'teaser' - limit the number of words, tranform YACS codes, and link to permalink
  *
  * @see shared/anchor.php
  *
  * @param string an optional variant, including
  * @return NULL, of some text
  */
 function &get_teaser($variant = 'basic')
 {
     global $context;
     // no item bound
     if (!isset($this->item['id'])) {
         $text = NULL;
         return $text;
     }
     // the text to be returned
     $text = '';
     // use the introduction field, if any
     if ($this->item['introduction']) {
         $text = trim($this->item['introduction']);
         // may be rendered as an empty strings
         if ($variant != 'hover') {
             // remove toc and toq codes
             $text = preg_replace(FORBIDDEN_IN_TEASERS, '', $text);
             // render all codes
             if (is_callable(array('Codes', 'beautify'))) {
                 $text = Codes::beautify($text, $this->item['options']);
             }
         }
         // combine with description
         if ($variant == 'quote') {
             $text .= BR . BR;
         }
     }
     // use overlay data, if any
     if (!$text) {
         if (!isset($this->overlay) && isset($this->item['overlay'])) {
             $this->overlay = Overlay::load($this->item, 'article:' . $this->item['id']);
         }
         if (is_object($this->overlay)) {
             $text .= $this->overlay->get_text('list', $this->item);
         }
     }
     // use the description field, if any
     $in_description = FALSE;
     if (!$text && $variant != 'hover') {
         $text .= trim($this->item['description']);
         $in_description = TRUE;
         // remove toc and toq codes
         $text = preg_replace(FORBIDDEN_IN_TEASERS, '', $text);
         // render all codes
         if ($variant == 'teaser' && is_callable(array('Codes', 'beautify'))) {
             $text = Codes::beautify($text, $this->item['options']);
         }
     }
     // turn html entities to unicode entities
     $text = utf8::transcode($text);
     // now we have to process the provided text
     switch ($variant) {
         // strip everything
         case 'basic':
         default:
             // strip every HTML and limit the size
             if (is_callable(array('Skin', 'strip'))) {
                 $text = Skin::strip($text, 70, NULL, '');
             }
             // done
             return $text;
             // some text for pop-up panels
         // some text for pop-up panels
         case 'hover':
             // strip every HTML and limit the size
             if (is_callable(array('Skin', 'strip'))) {
                 $text = Skin::strip($text, 70, NULL, '');
             }
             // ensure we have some text
             if (!$text) {
                 $text = i18n::s('View the page');
             }
             // mention shortcut to article
             if (Surfer::is_associate()) {
                 $text .= ' [article=' . $this->item['id'] . ']';
             }
             // done
             return $text;
             // quote this
         // quote this
         case 'quote':
             // strip every HTML and limit the size
             if (is_callable(array('Skin', 'strip'))) {
                 $text = Skin::strip($text, 300, NULL, '<a><b><br><i><img><strong><u>');
             }
             // done
             return $text;
             // preserve as much as possible
         // preserve as much as possible
         case 'teaser':
             // lower level of titles
             $text = str_replace(array('<h4', '</h4'), array('<h5', '</h5'), $text);
             $text = str_replace(array('<h3', '</h3'), array('<h4', '</h4'), $text);
             $text = str_replace(array('<h2', '</h2'), array('<h3', '</h3'), $text);
             // limit the number of words
             if (is_callable(array('Skin', 'cap'))) {
                 $text = Skin::cap($text, WORDS_IN_TEASER, $this->get_url());
             }
             // done
             return $text;
     }
 }
Beispiel #8
0
 /**
  * list articles as rows in a table
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // build a list of articles
     $rows = array();
     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
         $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 everything
         $title = $abstract = $author = '';
         // signal articles to be published
         if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
             $title .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $title .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $title .= RESTRICTED_FLAG;
         }
         // indicate the id in the hovering popup
         $hover = i18n::s('View the page');
         if (Surfer::is_member()) {
             $hover .= ' [article=' . $item['id'] . ']';
         }
         // use the title to label the link
         if (is_object($overlay)) {
             $label = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $label = Codes::beautify_title($item['title']);
         }
         // use the title as a link to the page
         $title .= Skin::build_link($url, $label, 'basic', $hover);
         // signal locked articles
         if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
             $title .= ' ' . LOCKED_FLAG;
         }
         // flag articles updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $title .= ' ' . EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $title .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $title .= ' ' . UPDATED_FLAG;
         }
         // the icon
         if ($item['thumbnail_url']) {
             $abstract .= '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $item['thumbnail_url'] . '" class="right_image" alt="" /></a>';
         }
         // the introductory text
         if (is_object($overlay)) {
             $abstract .= Codes::beautify_introduction($overlay->get_text('introduction', $item));
         } elseif ($item['introduction']) {
             $abstract .= Codes::beautify_introduction($item['introduction']);
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $abstract .= $overlay->get_text('list', $item);
         }
         // make some abstract out of main text
         if (!$item['introduction'] && $context['skins_with_details'] == 'Y') {
             $abstract .= Skin::cap(Codes::beautify($item['description'], $item['options']), 50);
         }
         // attachment details
         $details = array();
         // info on related files
         if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
             Skin::define_img('FILES_LIST_IMG', 'files/list.gif');
             $details[] = FILES_LIST_IMG . sprintf(i18n::ns('%d file', '%d files', $count), $count);
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             Skin::define_img('LINKS_LIST_IMG', 'links/list.gif');
             $details[] = LINKS_LIST_IMG . sprintf(i18n::ns('%d link', '%d links', $count), $count);
         }
         // comments
         if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
             Skin::define_img('COMMENTS_LIST_IMG', 'comments/list.gif');
             $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'list'), COMMENTS_LIST_IMG . sprintf(i18n::ns('%d comment', '%d comments', $count), $count));
         }
         // describe attachments
         if (count($details)) {
             $abstract .= '<p style="margin: 3px 0;">' . join(', ', $details) . '</p>';
         }
         // anchors
         $anchors = array();
         if ($members =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) {
             foreach ($members as $category_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)) {
             $abstract .= '<p class="tags" style="margin: 3px 0">' . implode(' ', $anchors) . '</p>';
         }
         // poster name
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             if ($item['create_name']) {
                 $author = Users::get_link($item['create_name'], $item['create_address'], $item['create_id']);
             } else {
                 $author = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']);
             }
         }
         // more details
         $details =& Articles::build_dates($anchor, $item);
         // 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');
         }
         // page details
         if (count($details)) {
             $details = '<p class="details">' . join(', ', $details) . '</p>';
         }
         // this is another row of the output -- title, abstract, (author,) details
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             $cells = array($title, $abstract, $author, $details);
         } else {
             $cells = array($title, $abstract, $details);
         }
         // append this row
         $rows[] = $cells;
     }
     // end of processing
     SQL::free($result);
     // headers
     if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
         $headers = array(i18n::s('Topic'), i18n::s('Abstract'), i18n::s('Poster'), i18n::s('Details'));
     } else {
         $headers = array(i18n::s('Topic'), i18n::s('Abstract'), i18n::s('Details'));
     }
     // return a sortable table
     $text .= Skin::table($headers, $rows, 'grid');
     return $text;
 }
Beispiel #9
0
 /**
  * get some introductory text from a section
  *
  * This function is used to introduce comments, or any sub-item related to an anchor.
  * Compared to the standard anchor implementation, this one adds the ability to handle overlay data.
  *
  * If there is some introductory text, it is used. Else the description text is used instead.
  * The number of words is capped in both cases.
  *
  * Also, the number of remaining words is provided.
  *
  * Following variants may be selected to adapt to various situations:
  * - 'basic' - strip every tag, we want almost plain ASCII - maybe this will be send in a mail message
  * - 'hover' - some text to be displayed while hovering a link
  * - 'quote' - transform YACS codes, then strip most HTML tags
  * - 'teaser' - limit the number of words, tranform YACS codes, and link to permalink
  *
  * @see shared/anchor.php
  *
  * @param string an optional variant
  * @return NULL, of some text
  */
 function &get_teaser($variant = 'basic')
 {
     global $context;
     // nothing to do
     if (!isset($this->item['id'])) {
         $text = NULL;
         return $text;
     }
     // the text to be returned
     $text = '';
     // use the introduction field, if any
     if ($this->item['introduction']) {
         $text = trim($this->item['introduction']);
         // may be rendered as an empty strings
         if ($variant != 'hover') {
             // remove toc and toq codes
             $text = preg_replace(FORBIDDEN_IN_TEASERS, '', $text);
             // render all codes
             if (is_callable(array('Codes', 'beautify'))) {
                 $text =& Codes::beautify($text, $this->item['options']);
             }
         }
         // remove most html
         if ($variant != 'teaser') {
             $text = xml::strip_visible_tags($text);
         }
         // combine with description
         if ($variant == 'quote') {
             $text .= BR . BR;
         }
     }
     // use overlay data, if any
     if (!$text) {
         $overlay = Overlay::load($this->item, 'section:' . $this->item['id']);
         if (is_object($overlay)) {
             $text .= $overlay->get_text('list', $this->item);
         }
     }
     // use the description field, if any
     $in_description = FALSE;
     if (!$text && $variant != 'hover' || $variant == 'quote') {
         $text .= trim($this->item['description']);
         $in_description = TRUE;
         // remove toc and toq codes
         $text = preg_replace(FORBIDDEN_IN_TEASERS, '', $text);
         // render all codes
         if (is_callable(array('Codes', 'beautify'))) {
             $text =& Codes::beautify($text, $this->item['options']);
         }
         // remove most html
         $text = xml::strip_visible_tags($text);
     }
     // turn html entities to unicode entities
     $text =& utf8::transcode($text);
     // now we have to process the provided text
     switch ($variant) {
         // strip everything
         case 'basic':
         default:
             // remove most html
             $text = xml::strip_visible_tags($text);
             // limit the number of words
             $text =& Skin::cap($text, 70);
             // done
             return $text;
             // some text for pop-up panels
         // some text for pop-up panels
         case 'hover':
             // remove most html
             $text = xml::strip_visible_tags($text);
             // limit the number of words
             $text =& Skin::strip($text, 70);
             // ensure we have some text
             if (!$text) {
                 $text = i18n::s('View the page');
             }
             // mention shortcut to section
             if (Surfer::is_associate()) {
                 $text .= ' [section=' . $this->item['id'] . ']';
             }
             // done
             return $text;
             // quote this
         // quote this
         case 'quote':
             // remove most html
             $text = xml::strip_visible_tags($text);
             // limit the number of words
             $text =& Skin::cap($text, 300);
             // done
             return $text;
             // preserve as much as possible
         // preserve as much as possible
         case 'teaser':
             // limit the number of words
             $text =& Skin::cap($text, 12, $this->get_url());
             // done
             return $text;
     }
 }
 /**
  * layout one recent article
  *
  * @param array the article
  * @return an array ($prefix, $label, $suffix)
  **/
 function layout_recent($item)
 {
     global $context;
     // permalink
     $url = Articles::get_permalink($item);
     // get the related overlay, if any
     $overlay = Overlay::load($item, 'article:' . $item['id']);
     // get the anchor
     $anchor = Anchors::get($item['anchor']);
     // 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']);
     }
     // reset everything
     $prefix = $suffix = '';
     // signal restricted and private articles
     if ($item['active'] == 'N') {
         $prefix .= PRIVATE_FLAG;
     } elseif ($item['active'] == 'R') {
         $prefix .= RESTRICTED_FLAG;
     }
     // rating
     if ($item['rating_count']) {
         $suffix .= Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
     }
     // the introductory text
     if (isset($item['introduction']) && $item['introduction']) {
         $suffix .= ' -&nbsp;' . Codes::beautify_introduction($item['introduction']);
     } elseif (isset($item['decription']) && $item['decription']) {
         $suffix .= ' -&nbsp;' . Skin::cap(Codes::beautify($item['description'], $item['options']), 25);
     }
     // the author
     $author = '';
     if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
         $author = sprintf(i18n::s('by %s'), $item['create_name']) . ' ';
     }
     // date
     $suffix .= '<span class="details"> -&nbsp;' . $author . Skin::build_date($item['publish_date']);
     // count comments
     if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
         $suffix .= ' -&nbsp;' . sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
     }
     // end of details
     $suffix .= '</span>';
     // insert an array of links
     return array($prefix, $title, $suffix);
 }
Beispiel #11
0
 /**
  * list blogmarks
  *
  * @param resource the SQL result
  * @return string resulting text
  **/
 function layout($result)
 {
     global $context;
     // we return a string
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // start in north
     $in_north = TRUE;
     // define allowed HTML tags for the cover page
     define('ALLOWED_HTML_TAGS', '<a><b><br><h1><h2><h3><i><img><li><ol><p><ul>');
     // build a list of articles
     $box = array();
     $box['content'] = '';
     $previous_date = NULL;
     while ($item = SQL::fetch($result)) {
         // not the same date
         $current_date = substr($item['edit_date'], 0, 10);
         if ($previous_date != $current_date) {
             // insert a complete box for the previous date
             if ($box['content']) {
                 if ($in_north) {
                     $text .= '<div class="newest">' . "\n";
                 }
                 $text .= Skin::build_box($box['title'], $box['content']);
                 if ($in_north) {
                     $text .= '</div>' . "\n";
                 }
                 $in_north = FALSE;
             }
             // prepare a box for a new date
             $previous_date = $current_date;
             $box['title'] = Skin::build_date($item['edit_date'], 'no_hour');
             $box['content'] = '';
         }
         $box['content'] .= '<br clear="both" />';
         // time
         $box['content'] .= '<span class="details">' . substr($item['edit_date'], 11, 5) . '</span> ';
         // make a label
         $label = Links::clean($item['title'], $item['link_url']);
         $box['content'] .= Skin::build_link($item['link_url'], $label);
         // flag links updated recently
         if ($item['edit_date'] >= $context['fresh']) {
             $box['content'] .= ' ' . NEW_FLAG;
         }
         // the description
         if (trim($item['description'])) {
             $box['content'] .= "\n<br/>" . Skin::cap(Codes::beautify($item['description']), 500) . "\n";
         }
         // the menu bar for associates and poster
         if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) {
             $menu = array('links/edit.php?id=' . $item['id'] => i18n::s('Edit'), 'links/delete.php?id=' . $item['id'] => i18n::s('Delete'));
             $box['content'] .= ' ' . Skin::build_list($menu, 'menu');
         }
         // append details to the suffix
         $box['content'] .= BR . '<span class="details">';
         // details
         $details = array();
         // item poster
         if (Surfer::is_member()) {
             if ($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']));
             }
         } else {
             $details[] = Anchors::get_action_label($item['edit_action']);
         }
         // show an anchor link
         if ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
             $anchor_url = $anchor->get_url();
             $anchor_label = ucfirst($anchor->get_title());
             $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor_url, $anchor_label));
         }
         // all details
         $box['content'] .= ucfirst(trim(implode(' ', $details))) . "\n";
         // end of details
         $box['content'] .= '</span><br/><br/>';
     }
     // close the on-going box
     if ($in_north) {
         $text .= '<div class="newest">' . "\n";
     }
     $text .= Skin::build_box($box['title'], $box['content']);
     if ($in_north) {
         $text .= '</div>' . "\n";
     }
     // end of processing
     SQL::free($result);
     return $text;
 }
 /**
  * layout one of the newest articles
  *
  * @param array the article
  * @param object the anchor of this article, if any
  * @return string the rendered text
  **/
 function layout_newest($item, $anchor)
 {
     global $context;
     // get the related overlay, if any
     $overlay = Overlay::load($item, 'article:' . $item['id']);
     // 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 = $text = '';
     // help to jump here
     $prefix .= '<a id="article_' . $item['id'] . '"></a>';
     // signal restricted and private articles
     if ($item['active'] == 'N') {
         $prefix .= PRIVATE_FLAG;
     } elseif ($item['active'] == 'R') {
         $prefix .= RESTRICTED_FLAG;
     }
     // rating
     if ($item['rating_count']) {
         $suffix .= Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic', i18n::s('Rate this page'));
     }
     // use the title as a link to the page
     $text .= '<h3><span>' . $prefix . Skin::build_link($url, $title, 'basic', i18n::s('View the page')) . $suffix . '</span></h3>';
     // details
     $details = array();
     // the creator and editor of this article
     if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
         if ($item['edit_name'] != $item['create_name']) {
             $label = sprintf(i18n::s('by %s, %s'), ucfirst($item['create_name']), ucfirst($item['edit_name']));
         } else {
             $label = sprintf(i18n::s('by %s'), ucfirst($item['create_name']));
         }
         $details[] = $label;
     }
     // poster details
     if (count($details)) {
         $text .= BR . '<span class="details">' . ucfirst(implode(', ', $details)) . "</span>\n";
     }
     // the introductory text
     $introduction = '';
     if (is_object($overlay)) {
         $introduction .= Codes::beautify_introduction($overlay->get_text('introduction', $item));
     } elseif ($item['introduction']) {
         $introduction .= Codes::beautify_introduction($item['introduction']);
     } else {
         $introduction .= Skin::cap(Codes::beautify($item['description'], $item['options']), 70);
     }
     if ($introduction) {
         $text .= '<p>' . $introduction . '</p>' . "\n";
     }
     // insert overlay data, if any
     if (is_object($overlay)) {
         $text .= $overlay->get_text('list', $item);
     }
     // read this article
     $text .= '<p class="details">' . Skin::build_link($url, i18n::s('View the page'), 'basic');
     // info on related files
     if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
         $text .= ' (' . Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d file', '%d files', $count), $count), 'basic') . ')';
     }
     // list up to three categories by title, if any
     if ($items =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 5, 'raw')) {
         $text .= BR;
         $first_category = TRUE;
         foreach ($items 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>';
             }
             if (!$first_category) {
                 $text .= ',';
             }
             $text .= ' ' . Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic', i18n::s('More pages'));
             $first_category = FALSE;
         }
     }
     $text .= '</p>';
     return $text;
 }
Beispiel #13
0
     $context['page_details'] .= '</p>';
 }
 //
 // main panel -- $context['text']
 //
 $text = '';
 // display very few things if we are on a follow-up page
 if ($zoom_type) {
     // insert anchor prefix
     if (is_object($anchor)) {
         $context['text'] .= $anchor->get_prefix();
     }
     if ($item['introduction']) {
         $context['text'] .= Codes::beautify($item['introduction']) . "<p> </p>\n";
     } else {
         $context['text'] .= Skin::cap(Codes::beautify($item['description']), 50) . "<p> </p>\n";
     }
     // else expose full details
 } else {
     // insert anchor prefix
     if (is_object($anchor)) {
         $text .= $anchor->get_prefix();
     }
     // the introduction text, if any
     $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);
     }
     // the description, which is the actual page body
     $text .= Skin::build_block($item['description'], 'description');