Example #1
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 main anchor
         $anchor = Anchors::get($item['anchor']);
         // url is the link itself -- hack for xhtml compliance
         $url = str_replace('&', '&', $item['link_url']);
         // initialize variables
         $prefix = $suffix = '';
         // flag links that are dead, or created or updated very recently
         if ($item['edit_date'] >= $context['fresh']) {
             $suffix = NEW_FLAG;
         }
         // make a label
         $label = Links::clean($item['title'], $item['link_url']);
         // the main anchor link
         if (is_object($anchor)) {
             $suffix .= ' - <span class="details">' . sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()))) . '</span>';
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Example #2
0
File: thread.php Project: rair/yacs
 public function get_comment_notification($item)
 {
     global $context;
     // build a tease notification for simple members
     // sanity check
     if (!isset($item['anchor']) || !($anchor = Anchors::get($item['anchor']))) {
         throw new Exception('no anchor for this comment');
     }
     // headline
     $headline = sprintf(i18n::c('%s has replied'), Surfer::get_link());
     $content = BR;
     // shape these
     $tease = Skin::build_mail_content($headline, $content);
     // a set of links
     $menu = array();
     // call for action
     $link = $context['url_to_home'] . $context['url_to_root'] . Comments::get_url($item['id'], 'view');
     $menu[] = Skin::build_mail_button($link, i18n::c('View the reply'), TRUE);
     // link to the container
     $menu[] = Skin::build_mail_button($anchor->get_url(), $anchor->get_title(), FALSE);
     // finalize links
     $tease .= Skin::build_mail_menu($menu);
     // assemble all parts of the mail
     $mail = array();
     $mail['subject'] = sprintf(i18n::c('%s: %s'), i18n::c('Reply in the discussion'), strip_tags($anchor->get_title()));
     $mail['notification'] = Comments::build_notification($item);
     // full notification
     $mail['tease'] = Mailer::build_notification($tease, 1);
     return $mail;
 }
Example #3
0
 /**
  * cascade to children
  *
  * @param string referencing of the changed anchor
  * @param string rights to be cascaded (e.g., 'Y', 'R' or 'N')
  */
 public static function cascade($reference, $active)
 {
     global $context;
     // only sections may have sub-sections
     if (strpos($reference, 'section:') === 0) {
         // cascade to sub-sections
         if ($items = Sections::list_for_anchor($reference, 'raw')) {
             // cascade to each section individually
             foreach ($items as $id => $item) {
                 // limit actual rights
                 $item['active'] = Anchors::ceil_rights($active, $item['active_set']);
                 $query = "UPDATE " . SQL::table_name('sections') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
                 SQL::query($query);
                 // cascade to children
                 Anchors::cascade('section:' . $item['id'], $item['active']);
             }
         }
     }
     // only categories may have sub-categories
     if (strpos($reference, 'category:') === 0) {
         // cascade to sub-categories
         if ($items = Categories::list_for_anchor($reference, 'raw')) {
             // cascade to each section individually
             foreach ($items as $id => $item) {
                 // limit actual rights
                 $item['active'] = Anchors::ceil_rights($active, $item['active_set']);
                 $query = "UPDATE " . SQL::table_name('categories') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
                 SQL::query($query);
                 // cascade to children
                 Anchors::cascade('category:' . $item['id'], $item['active']);
             }
         }
     }
     // only sections may have articles
     if (strpos($reference, 'section:') === 0) {
         // cascade to articles --up to 3000
         if ($items =& Articles::list_for_anchor_by('edition', $reference, 0, 3000, 'raw')) {
             // cascade to each section individually
             foreach ($items as $id => $item) {
                 // limit actual rights
                 $item['active'] = Anchors::ceil_rights($active, $item['active_set']);
                 $query = "UPDATE " . SQL::table_name('articles') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
                 SQL::query($query);
                 // cascade to children
                 Anchors::cascade('article:' . $item['id'], $item['active']);
             }
         }
     }
     // cascade to files --up to 3000
     if ($items = Files::list_by_date_for_anchor($reference, 0, 3000, 'raw')) {
         // cascade to each section individually
         foreach ($items as $id => $item) {
             // limit actual rights
             $item['active'] = Anchors::ceil_rights($active, $item['active_set']);
             $query = "UPDATE " . SQL::table_name('files') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
             SQL::query($query);
         }
     }
 }
Example #4
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;
 }
Example #5
0
 /**
  * list files
  *
  * @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;
     }
     // sanity check
     if (!isset($this->layout_variant)) {
         $this->layout_variant = 'full';
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // download the file directly
         $url = Files::get_url($item['id'], 'fetch', $item['file_name']);
         // initialize variables
         $prefix = $suffix = '';
         // flag files that are dead, or created or updated very recently
         if ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         // signal restricted and private files
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // file title or file name
         $label = Codes::beautify_title($item['title']);
         if (!$label) {
             $label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name']));
         }
         // the main anchor link, except on user profiles
         if (is_object($anchor) && $anchor->get_reference() != $this->focus) {
             $suffix .= ' - <span class="details">' . sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()))) . '</span>';
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Example #6
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;
 }
Example #7
0
 /**
  * delete one server in the database
  *
  * @param int the id of the server to delete
  * @return boolean TRUE on success, FALSE otherwise
  *
  * @see servers/delete.php
  */
 public static function delete($id)
 {
     global $context;
     // id cannot be empty
     if (!$id || !is_numeric($id)) {
         return FALSE;
     }
     // delete related items
     Anchors::delete_related_to('server:' . $id);
     // delete the record in the database
     $query = "DELETE FROM " . SQL::table_name('servers') . " WHERE id = " . $id;
     if (SQL::query($query) === FALSE) {
         return FALSE;
     }
     // job done
     return TRUE;
 }
Example #8
0
 /**
  * extend the page menu
  *
  * @param string script name
  * @param string target anchor, if any
  * @param array current menu
  * @return array updated menu
  */
 function add_commands($script, $anchor, $menu = array())
 {
     global $context;
     // limit the scope of our check to viewed pages
     if (!preg_match('/articles\\/view/', $script)) {
         return $menu;
     }
     // surfer has to be authenticated
     if (!Surfer::is_logged()) {
         return $menu;
     }
     // sanity checks
     if (!$anchor) {
         Logger::error(i18n::s('No anchor has been found.'));
     } elseif (!($target = Anchors::get($anchor))) {
         Logger::error(i18n::s('No anchor has been found.'));
     } elseif (!$this->parameters) {
         Logger::error(sprintf(i18n::s('No parameter has been provided to %s'), 'behaviors/move_on_article_access'));
     } else {
         // look at parent container if possible
         if (!($origin = Anchors::get($target->get_parent()))) {
             $origin = $target;
         }
         // only container editors can proceed
         if ($origin->is_assigned() || Surfer::is_associate()) {
             // load target section
             $tokens = explode(' ', $this->parameters, 2);
             if ($section = Anchors::get('section:' . $tokens[0])) {
                 // make a label
                 if (count($tokens) < 2) {
                     $tokens[1] = sprintf(i18n::s('Move to %s'), $section->get_title());
                 }
                 // the target link to move the page
                 $link = Articles::get_url(str_replace('article:', '', $anchor), 'move', str_replace('section:', '', $section->get_reference()));
                 // make a sub-menu
                 $menu = array_merge(array($link => array('', $tokens[1], '', 'button')), $menu);
             }
         }
     }
     return $menu;
 }
 /**
  * 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
     $introduction = '';
     if (is_object($overlay)) {
         $introduction = $overlay->get_text('introduction', $item);
     } elseif ($item['introduction']) {
         $introduction = $item['introduction'];
     }
     if ($introduction) {
         $suffix .= ' -&nbsp;' . Codes::beautify_introduction($introduction);
     }
     // 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
     $suffix .= Skin::finalize_list($details, 'menu');
     // display all tags
     if ($item['tags']) {
         $suffix .= ' <p class="tags" style="margin-top: 3px;">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</p>';
     }
     // insert an array of links
     return array($prefix, $title, $suffix);
 }
Example #10
0
 /**
  * main function to render layout
  * 
  * @param type $result MySQL object
  * @return string the rendering
  */
 public function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // type of listed object
     $items_type = $this->listed_type;
     // this level root reference
     if (isset($this->focus) && $this->focus) {
         $root_ref = $this->focus;
     } elseif (isset($context['current_item']) && $context['current_item']) {
         $root_ref = $context['current_item'];
     } else {
         $root_ref = $items_type . ':index';
     }
     $this->tree_only = $this->has_variant('tree_only');
     // drag&drop zone
     $text .= '<div class="tm-ddz tm-drop" data-ref="' . $root_ref . '" data-variant="' . $this->layout_variant . '" >' . "\n";
     // root create command
     $text .= $this->btn_create();
     // root ul
     $text .= '<ul class="tm-sub_elems tm-root">' . "\n";
     while ($item = SQL::fetch($result)) {
         // get the object interface, this may load parent and overlay
         $entity = new $items_type($item);
         // title
         $title = '<a class="tm-zoom" href="' . $entity->get_permalink() . '"><span class="tm-folder">' . $entity->get_title() . '</span></a>';
         // sub elements of this entity
         $sub = $this->get_sub_level($entity);
         // command related to this entity
         $cmd = $this->get_interactive_menu();
         // one <li> per entity of this level of the tree
         $text .= '<li class="tm-drag tm-drop" data-ref="' . $entity->get_reference() . '">' . $title . $cmd . $sub . '</li>' . "\n";
     }
     // this level may have childs that are not folders (exept index)
     // do not search in variant tree_only is setted
     if (!preg_match('/index$/', $root_ref) && !$this->tree_only) {
         $thislevel = Anchors::get($root_ref);
         $text .= $this->get_sub_level($thislevel, true);
         // do not search for folders
     }
     // we have bound styles and scripts, but do not provide on ajax requests
     if (!isset($context['AJAX_REQUEST']) || !$context['AJAX_REQUEST']) {
         $this->load_scripts_n_styles();
         // init js depending on user privilege for this level
         if (isset($thislevel)) {
             // get surfer privilege for this level
             $powered = $thislevel->allows('creation');
         } else {
             $powered = Surfer::is_associate();
         }
         $powered = $powered ? 'powered' : '';
         // cast to string
         Page::insert_script('TreeManager.init("' . $powered . '");');
     }
     // end drag drop zone
     $text .= '</ul></div>' . "\n";
     // end of processing
     SQL::free($result);
     return $text;
 }
Example #11
0
File: view.php Project: rair/yacs
include_once '../shared/global.php';
include_once 'servers.php';
// look for the id
$id = NULL;
if (isset($_REQUEST['id'])) {
    $id = $_REQUEST['id'];
} elseif (isset($context['arguments'][0])) {
    $id = $context['arguments'][0];
}
$id = strip_tags($id);
// get the item from the database
$item = Servers::get($id);
// get the related anchor, if any
$anchor = NULL;
if (isset($item['anchor']) && $item['anchor']) {
    $anchor = Anchors::get($item['anchor']);
}
// associates can do what they want
if (Surfer::is_associate()) {
    $permitted = TRUE;
} elseif (is_object($anchor) && !$anchor->is_viewable()) {
    $permitted = FALSE;
} elseif ($item['active'] == 'R' && Surfer::is_member()) {
    $permitted = TRUE;
} elseif ($item['active'] == 'Y') {
    $permitted = TRUE;
} else {
    $permitted = FALSE;
}
// load the skin
load_skin('servers');
Example #12
0
File: select.php Project: rair/yacs
 // the current list of linked sections
 $sections =& Members::list_sections_by_title_for_anchor($anchor->get_reference(), 0, SECTIONS_LIST_SIZE, 'raw');
 // the form to link additional sections
 if (!is_array($sections) || count($sections) < SECTIONS_LIST_SIZE) {
     $context['text'] .= '<form method="post" action="' . $context['script_url'] . '"><p>' . i18n::s('To assign a section, look in the content tree below and assign one section at a time') . BR . '<select name="member">' . Sections::get_options(NULL, $sections) . '</select>' . ' ' . Skin::build_submit_button(' >> ') . '<input type="hidden" name="anchor" value="' . encode_field($anchor->get_reference()) . '">' . '<input type="hidden" name="action" value="set">' . '</p></form>' . "\n";
 }
 // splash
 $context['text'] .= '<p style="margin-top: 2em;">' . sprintf(i18n::s('This is the list of sections assigned to %s'), $anchor->get_title()) . '</p>';
 // layout assigned sections
 if ($sections) {
     // browse the list
     foreach ($sections as $id => $section) {
         // get the related overlay, if any
         $overlay = Overlay::load($section, 'section:' . $id);
         // get parent anchor
         $parent = Anchors::get($section['anchor']);
         // the url to view this item
         $url = Sections::get_permalink($section);
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $section));
         } else {
             $title = Codes::beautify_title($section['title']);
         }
         // initialize variables
         $prefix = $suffix = $icon = '';
         // flag sticky pages
         if ($section['rank'] < 10000) {
             $prefix .= STICKY_FLAG;
         }
         // signal restricted and private sections
Example #13
0
 /**
  * list articles
  *
  * @param resource the SQL result
  * @return array
  *
  * @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
     include_once $context['path_to_root'] . 'articles/article.php';
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'locations/locations.php';
     while ($item = SQL::fetch($result)) {
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // provide an absolute link
         $url = Articles::get_permalink($item);
         // build a title
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // time of last update
         $time = SQL::strtotime($item['edit_date']);
         // the section
         $section = '';
         if ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
             $section = ucfirst(trim(strip_tags(Codes::beautify_title($anchor->get_title()))));
         }
         // the icon to use
         $icon = '';
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         } elseif ($item['anchor'] && ($anchor = Anchors::get($item['anchor'])) && is_callable($anchor, 'get_bullet_url')) {
             $icon = $anchor->get_bullet_url();
         }
         if ($icon) {
             $icon = $context['url_to_home'] . $context['url_to_root'] . $icon;
         }
         // the author(s) is an e-mail address, according to rss 2.0 spec
         $author = '';
         if (isset($item['create_address'])) {
             $author .= $item['create_address'];
         }
         if (isset($item['create_name']) && trim($item['create_name'])) {
             $author .= ' (' . $item['create_name'] . ')';
         }
         if (isset($item['edit_address']) && trim($item['edit_address']) && $item['create_address'] != $item['edit_address']) {
             if ($author) {
                 $author .= ', ';
             }
             $author .= $item['edit_address'];
             if (isset($item['edit_name']) && trim($item['edit_name'])) {
                 $author .= ' (' . $item['edit_name'] . ')';
             }
         }
         // some introductory text for this article
         $article = new Article();
         $article->load_by_content($item);
         $introduction = $article->get_teaser('teaser');
         // warns on restricted access
         if (isset($item['active']) && $item['active'] != 'Y') {
             $introduction = '[' . i18n::c('Restricted to members') . '] ' . $introduction;
         }
         // fix references
         $introduction = preg_replace('/"\\//', '"' . $context['url_to_home'] . '/', $introduction);
         // the article content
         $description = '';
         // other rss fields
         $extensions = array();
         // the geolocation for this page, if any
         if ($location = Locations::locate_anchor('article:' . $item['id'])) {
             $extensions[] = '<georss:point>' . str_replace(',', ' ', $location) . '</georss:point>';
         }
         // url for comments
         if (is_object($anchor)) {
             $extensions[] = '<comments>' . encode_link($context['url_to_home'] . $context['url_to_root'] . $anchor->get_url('comments')) . '</comments>';
         }
         // count comments
         $comment_count = Comments::count_for_anchor('article:' . $item['id']);
         $extensions[] = '<slash:comments>' . $comment_count . "</slash:comments>";
         // the comment post url
         $extensions[] = '<wfw:comment>' . encode_link($context['url_to_home'] . $context['url_to_root'] . Comments::get_url('article:' . $item['id'], 'service.comment')) . "</wfw:comment>";
         // the comment Rss url
         $extensions[] = '<wfw:commentRss>' . encode_link($context['url_to_home'] . $context['url_to_root'] . Comments::get_url('article:' . $item['id'], 'feed')) . "</wfw:commentRss>";
         // the trackback url
         $extensions[] = '<trackback:ping>' . encode_link($context['url_to_home'] . $context['url_to_root'] . 'links/trackback.php?anchor=' . urlencode('article:' . $item['id'])) . "</trackback:ping>";
         // no trackback:about;
         // list all components for this item
         $items[$url] = array($time, $title, $author, $section, $icon, $introduction, $description, $extensions);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Example #14
0
File: check.php Project: rair/yacs
 $query = "SELECT id, anchor FROM " . SQL::table_name('comments') . " ORDER BY anchor LIMIT 0, 100000";
 if (!($result = SQL::query($query))) {
     return;
 } else {
     // fetch one anchor and the linked member
     $errors_count = 0;
     while ($row = SQL::fetch($result)) {
         // animate user screen and take care of time
         $count++;
         if (!($count % 500)) {
             $context['text'] .= sprintf(i18n::s('%d records have been processed'), $count) . BR . "\n";
             // ensure enough execution time
             Safe::set_time_limit(30);
         }
         // check that the anchor exists, if any
         if ($row['anchor'] && !Anchors::get($row['anchor'])) {
             $context['text'] .= sprintf(i18n::s('Orphan: %s'), 'comment ' . Skin::build_link(Comments::get_url($row['id']), $row['id'])) . BR . "\n";
             if (++$errors_count >= 5) {
                 $context['text'] .= i18n::s('Too many successive errors. Aborted') . BR . "\n";
                 break;
             }
         } else {
             $errors_count = 0;
         }
     }
 }
 // ending message
 $context['text'] .= sprintf(i18n::s('%d records have been processed'), $count) . BR . "\n";
 // display the execution time
 $time = round(get_micro_time() - $context['start_time'], 2);
 $context['text'] .= '<p>' . sprintf(i18n::s('Script terminated in %.2f seconds.'), $time) . '</p>';
Example #15
0
 /**
  * list links
  *
  * Recognize following variants:
  * - 'no_anchor' to list items attached to one particular anchor
  * - 'no_author' to list items attached to one user prolink
  *
  * @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;
     }
     // sanity check
     if (!isset($this->layout_variant)) {
         $this->layout_variant = 'no_anchor';
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // initialize variables
         $prefix = $suffix = $icon = '';
         // make a label
         $label = Links::clean($item['title'], $item['link_url']);
         // flag links uploaded recently
         if ($item['edit_date'] >= $context['fresh']) {
             $prefix = NEW_FLAG . $prefix;
         }
         // the number of clicks
         if ($item['hits'] > 1) {
             $suffix .= ' (' . Skin::build_number($item['hits'], i18n::s('clicks')) . ') ';
         }
         // add a separator
         if ($suffix) {
             $suffix = ' - ' . $suffix;
         }
         // details
         $details = array();
         // item poster
         if ($item['edit_name'] && $this->layout_variant != 'no_author') {
             if (Surfer::is_member() || (!isset($context['content_without_details']) || $context['content_without_details'] != 'Y') || is_object($anchor) && $anchor->has_option('with_details')) {
                 $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']));
             }
         }
         // show an anchor link
         if ($this->layout_variant != 'no_anchor' && $this->layout_variant != 'no_author' && $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, 'article'));
         }
         // the menu bar for associates and poster
         if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) {
             $details[] = Skin::build_link('links/edit.php?id=' . $item['id'], i18n::s('edit'), 'span');
             $details[] = Skin::build_link('links/delete.php?id=' . $item['id'], i18n::s('delete'), 'span');
         }
         // append details to the suffix
         if (count($details)) {
             $suffix .= BR . Skin::finalize_list($details, 'menu');
         }
         // description
         if ($item['description']) {
             $suffix .= BR . Codes::beautify($item['description']);
         }
         // build the actual link to check it
         if ($this->layout_variant == 'review') {
             $icon = $item['link_url'];
         }
         // url is the link itself -- hack for xhtml compliance
         $url = str_replace('&', '&amp;', $item['link_url']);
         // let the rendering engine guess the type of link
         $link_type = NULL;
         // except if we want to stay within this window
         if (isset($item['link_target']) && $item['link_target'] != 'I') {
             $link_type = 'external';
         }
         // hovering title
         $link_title = NULL;
         if (isset($item['link_title']) && $item['link_title']) {
             $link_title = $item['link_title'];
         }
         // pack everything
         $items[$url] = array($prefix, $label, $suffix, $link_type, $icon, $link_title);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Example #16
0
 /**
  * list articles
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // the script used to check all pages at once
     Page::insert_script('function cascade_selection_to_all_article_rows(handle) {' . "\n" . '	$("div#articles_panel input[type=\'checkbox\'].row_selector").each(' . "\n" . '		function() { $(this).attr("checked", $(handle).is(":checked"));}' . "\n" . '	);' . "\n" . '}' . "\n");
     // table prefix
     $text .= Skin::table_prefix('yc-grid');
     // table headers
     $main = '<input type="checkbox" class="row_selector" onclick="cascade_selection_to_all_article_rows(this);" />';
     $cells = array($main, i18n::s('Page'), i18n::s('Rank'));
     $text .= Skin::table_row($cells, 'header');
     // process all items in the list
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     $count = 0;
     while ($item = SQL::fetch($result)) {
         $cells = array();
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // column to select the row
         $cells[] = '<input type="checkbox" name="selected_articles[]" id="article_selector_' . $count . '" class="row_selector" value="' . $item['id'] . '" />';
         // 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 = $icon = '';
         // flag sticky pages
         if ($item['rank'] < 10000) {
             $prefix .= STICKY_FLAG;
         }
         // signal locked articles
         if (isset($item['locked']) && $item['locked'] == 'Y') {
             $suffix .= ' ' . LOCKED_FLAG;
         }
         // flag articles that are dead, or created or updated very recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $prefix .= EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= ' ' . UPDATED_FLAG;
         }
         // signal articles to be published
         if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
             $prefix .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // the introductory text
         if (is_object($overlay)) {
             $introduction = $overlay->get_text('introduction', $item);
         } else {
             $introduction = $item['introduction'];
         }
         if ($introduction) {
             $suffix .= BR . Codes::beautify_introduction($introduction);
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $suffix .= $overlay->get_text('list', $item);
         }
         // append details to the suffix
         $suffix .= BR . '<span class="details">';
         // details
         $details = array();
         // the author
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             if ($item['create_name'] != $item['edit_name']) {
                 $details[] = sprintf(i18n::s('by %s, %s'), $item['create_name'], $item['edit_name']);
             } else {
                 $details[] = sprintf(i18n::s('by %s'), $item['create_name']);
             }
         }
         // the last action
         $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']);
         // the number of hits
         if (Surfer::is_logged() && $item['hits'] > 1) {
             $details[] = Skin::build_number($item['hits'], i18n::s('hits'));
         }
         // info on related files
         $stats = Files::stat_for_anchor('article:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $stats['count']), $stats['count']);
         }
         // info on related links
         $stats = Links::stat_for_anchor('article:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $stats['count']), $stats['count']);
         }
         // info on related comments
         $stats = Comments::stat_for_anchor('article:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $stats['count']), $stats['count']);
         }
         // 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');
         }
         // combine in-line details
         if (count($details)) {
             $suffix .= ucfirst(trim(implode(', ', $details)));
         }
         // list up to three categories by title, if any
         $anchors = array();
         if ($members =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) {
             foreach ($members 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>';
                 }
                 $anchors[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic');
             }
         }
         if (count($anchors)) {
             $suffix .= BR . sprintf(i18n::s('In %s'), implode(' / ', $anchors));
         }
         // end of details
         $suffix .= '</span>';
         // strip empty details
         $suffix = str_replace(BR . '<span class="details"></span>', '', $suffix);
         $suffix = str_replace('<span class="details"></span>', '', $suffix);
         // the icon to put in the left column
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         }
         // commands
         $commands = array(Skin::build_link(Articles::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic'), Skin::build_link(Articles::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic'));
         // link to this page
         $cells[] = $prefix . Skin::build_link($url, $title, 'article') . ' - ' . Skin::finalize_list($commands, 'menu') . $suffix;
         // ranking
         $cells[] = '<input type="text" size="5" name="article_rank_' . $item['id'] . '" value="' . $item['rank'] . '" onfocus="$(\'#article_selector_' . $count . '\').attr(\'checked\', \'checked\');" onchange="$(\'#act_on_articles\').prop(\'selectedIndex\', 9);" />';
         // append the row
         $text .= Skin::table_row($cells, $count++);
     }
     // select all rows
     $cells = array('<input type="checkbox" class="row_selector" onclick="cascade_selection_to_all_article_rows(this);" />', i18n::s('Select all/none'), '');
     $text .= Skin::table_row($cells, $count++);
     // table suffix
     $text .= Skin::table_suffix();
     // end of processing
     SQL::free($result);
     return $text;
 }
 /**
  * list articles as an index
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // referenced items
     $letters = array();
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // build a list of articles
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // 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);
         // 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 = $label = $suffix = $icon = $details = '';
         // 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')) {
             $prefix .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if (isset($item['active']) && $item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif (isset($item['active']) && $item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // flag articles updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $suffix .= ' ' . EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= ' ' . UPDATED_FLAG;
         }
         // make a link
         $label = $prefix . Skin::build_link($url, $title, 'basic') . $suffix;
         // the associated letter
         $letter = strtoupper(ltrim($title[0]));
         if ($letter < 'A' || $letter > 'Z') {
             $letter = '#';
         }
         // a new entry for this letter
         if (!isset($letters[$letter])) {
             $letters[$letter] = array();
         }
         $letters[$letter][] = $label;
     }
     // mention all letters at the top
     $bar = array();
     // all potential letters, in expected order
     $all = '#ABCDEFGHIJKLMNOPQRSTUVWXYZ';
     for ($index = 0; $index < strlen($all); $index++) {
         $letter = $all[$index];
         // some content for this letter
         if (isset($letters[$letter])) {
             // internal link to the right place
             $bar[] = Skin::build_link('#letter' . $letter, $letter, 'span');
             // actual content for this letter
             $content = '<ul class="index"><li>' . join('</li><li>', $letters[$letter]) . '</li></ul>';
             // content displayed in the page
             $text .= Skin::build_header_box($letter, $content, 'letter' . $letter);
             // no content for this letter
         } else {
             $bar[] = $letter;
         }
     }
     // insert local links at the top
     $text = Skin::finalize_list($bar, 'menu_bar') . $text;
     // end of processing
     SQL::free($result);
     return $text;
 }
Example #18
0
 /**
  * list articles
  *
  * @param resource the SQL result
  * @return array
  *
  * @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 related overlay, if any
         $overlay = Overlay::load($item, 'category:' . $item['id']);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // provide an absolute link
         $url = Categories::get_permalink($item);
         // build a title
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // time of last update
         $time = SQL::strtotime($item['edit_date']);
         // the section
         $root = '';
         if ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
             $root = ucfirst(trim(strip_tags(Codes::beautify_title($anchor->get_title()))));
         }
         // the icon to use
         $icon = '';
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         } elseif ($item['anchor'] && ($anchor = Anchors::get($item['anchor'])) && is_callable($anchor, 'get_bullet_url')) {
             $icon = $anchor->get_bullet_url();
         }
         if ($icon) {
             $icon = $context['url_to_home'] . $context['url_to_root'] . $icon;
         }
         // the author(s) is an e-mail address, according to rss 2.0 spec
         $author = '';
         if (isset($item['create_address'])) {
             $author .= $item['create_address'];
         }
         if (isset($item['create_name']) && trim($item['create_name'])) {
             $author .= ' (' . $item['create_name'] . ')';
         }
         if (isset($item['edit_address']) && trim($item['edit_address']) && $item['create_address'] != $item['edit_address']) {
             if ($author) {
                 $author .= ', ';
             }
             $author .= $item['edit_address'];
             if (isset($item['edit_name']) && trim($item['edit_name'])) {
                 $author .= ' (' . $item['edit_name'] . ')';
             }
         }
         // list all components for this item
         $items[$url] = array($time, $title, $author, $root, $icon, '', '', '');
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Example #19
0
 /**
  * list articles for search requests
  *
  * @param resource the SQL result
  * @return array of resulting items ($score, $summary), or NULL
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of array($score, $summary)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // process all items in the list
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // one box at a time
         $box = '';
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // 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 = $icon = '';
         // flag sticky pages
         if ($item['rank'] < 10000) {
             $prefix .= STICKY_FLAG;
         }
         // signal locked articles
         if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
             $suffix .= ' ' . LOCKED_FLAG;
         }
         // flag articles that are dead, or created or updated very recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $prefix .= EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= ' ' . UPDATED_FLAG;
         }
         // signal articles to be published
         if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
             $prefix .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // introduction
         $introduction = '';
         if (is_object($overlay)) {
             $introduction = $overlay->get_text('introduction', $item);
         } else {
             $introduction = $item['introduction'];
         }
         // the introductory text
         if ($introduction) {
             $suffix .= ' -&nbsp;' . Codes::beautify_introduction($introduction);
             // link to description, if any
             if ($item['description']) {
                 $suffix .= ' ' . Skin::build_link($url, MORE_IMG, 'more', i18n::s('View the page')) . ' ';
             }
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $suffix .= $overlay->get_text('list', $item);
         }
         // details
         $details = array();
         // the author
         if ($item['create_name'] != $item['edit_name']) {
             $details[] = sprintf(i18n::s('by %s, %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']));
         } else {
             $details[] = sprintf(i18n::s('by %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']));
         }
         // the last action
         $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']);
         // the number of hits
         if (Surfer::is_logged() && $item['hits'] > 1) {
             $details[] = Skin::build_number($item['hits'], i18n::s('hits'));
         }
         // info on related files
         if ($count = Files::count_for_anchor('article:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
         }
         // info on related comments
         if ($count = Comments::count_for_anchor('article:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
         }
         // 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');
         }
         // the main anchor link
         if (is_object($anchor)) {
             $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'section'));
         }
         // display all tags
         if ($item['tags']) {
             $details[] = '<span class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>';
         }
         // combine in-line details
         if (count($details)) {
             $suffix .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>';
         }
         // insert a suffix separator
         if (trim($suffix)) {
             $suffix = ' ' . $suffix;
         }
         // item summary
         $box .= $prefix . Skin::build_link($url, $title, 'article') . $suffix;
         // the icon to put in the left column
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         } elseif (is_callable(array($anchor, 'get_bullet_url'))) {
             $icon = $anchor->get_bullet_url();
         }
         // build the complete HTML element
         if ($icon) {
             $icon = '<img src="' . $icon . '" alt="" title="' . encode_field(strip_tags($title)) . '" />';
             // make it a clickable link
             $icon = Skin::build_link($url, $icon, 'basic');
             // default icon
         } else {
             $icon = DECORATED_IMG;
         }
         // layout this item
         $list = array(array($box, $icon));
         $items[] = array($item['score'], Skin::finalize_list($list, 'decorated'));
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Example #20
0
File: tables.php Project: rair/yacs
 /**
  * post a new table or an updated table
  *
  * This function populates the error context, where applicable.
  *
  * @param array an array of fields
  * @return the id of the new table, or FALSE on error
  *
  * @see tables/edit.php
  * @see tables/populate.php
  **/
 public static function post(&$fields)
 {
     global $context;
     // no query
     if (!isset($fields['query']) || !trim($fields['query'])) {
         Logger::error(i18n::s('Please add some SQL query.'));
         return FALSE;
     }
     // no anchor reference
     if (!isset($fields['anchor']) || !trim($fields['anchor'])) {
         Logger::error(i18n::s('No anchor has been found.'));
         return FALSE;
     }
     // get the anchor
     if (!isset($fields['anchor']) || !($anchor = Anchors::get($fields['anchor']))) {
         Logger::error(i18n::s('No anchor has been found.'));
         return FALSE;
     }
     // set default values
     if (!isset($fields['with_zoom'])) {
         $fields['with_zoom'] = 'N';
     }
     // set default values for this editor
     Surfer::check_default_editor($fields);
     // maybe we have to modify an existing table
     if (isset($fields['id'])) {
         // id cannot be empty
         if (!isset($fields['id']) || !is_numeric($fields['id'])) {
             Logger::error(i18n::s('No item has the provided id.'));
             return FALSE;
         }
         // update the existing record
         $query = "UPDATE " . SQL::table_name('tables') . " SET " . "nick_name='" . SQL::escape(isset($fields['nick_name']) ? $fields['nick_name'] : '') . "'," . "title='" . SQL::escape(isset($fields['title']) ? $fields['title'] : '') . "'," . "description='" . SQL::escape(isset($fields['description']) ? $fields['description'] : '') . "'," . "source='" . SQL::escape(isset($fields['source']) ? $fields['source'] : '') . "'," . "query='" . SQL::escape($fields['query']) . "'," . "with_zoom='" . SQL::escape(isset($fields['with_zoom']) ? $fields['with_zoom'] : '') . "'," . "edit_name='" . SQL::escape($fields['edit_name']) . "'," . "edit_id=" . SQL::escape($fields['edit_id']) . "," . "edit_address='" . SQL::escape($fields['edit_address']) . "'," . "edit_date='" . SQL::escape($fields['edit_date']) . "'" . " WHERE id = " . SQL::escape($fields['id']);
         // insert a new record
     } else {
         $query = "INSERT INTO " . SQL::table_name('tables') . " SET " . "anchor='" . SQL::escape($fields['anchor']) . "'," . "nick_name='" . SQL::escape(isset($fields['nick_name']) ? $fields['nick_name'] : '') . "'," . "title='" . SQL::escape(isset($fields['title']) ? $fields['title'] : '') . "'," . "description='" . SQL::escape(isset($fields['description']) ? $fields['description'] : '') . "'," . "source='" . SQL::escape(isset($fields['source']) ? $fields['source'] : '') . "'," . "query='" . SQL::escape(isset($fields['query']) ? $fields['query'] : '') . "'," . "with_zoom='" . SQL::escape(isset($fields['with_zoom']) ? $fields['with_zoom'] : '') . "'," . "edit_name='" . $fields['edit_name'] . "'," . "edit_id=" . $fields['edit_id'] . "," . "edit_address='" . $fields['edit_address'] . "'," . "edit_date='" . $fields['edit_date'] . "'";
     }
     // actual insert
     if (SQL::query($query) === FALSE) {
         return FALSE;
     }
     // remember the id of the new item
     if (!isset($fields['id'])) {
         $fields['id'] = SQL::get_last_id($context['connection']);
     }
     // clear the cache for tables
     if (isset($fields['id'])) {
         $topics = array('tables', 'table:' . $fields['id']);
     } else {
         $topics = 'tables';
     }
     Cache::clear($topics);
     // return the id of the new item
     return $fields['id'];
 }
Example #21
0
 /**
  * list articles
  *
  * @param resource the SQL result
  * @return string
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // sanity check
     if (!isset($this->focus)) {
         $this->focus = NULL;
     }
     // process all items in the list
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     $odd = TRUE;
     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);
         // build a title
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // initialize variables
         $prefix = $suffix = $icon = '';
         // flag articles that are dead, or created or updated very recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $prefix .= EXPIRED_FLAG;
         }
         // signal articles to be published
         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;
         }
         // some details
         $details = array();
         // info on related files --optional
         if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
         }
         // info on related comments --mandatory
         if ($count = Comments::count_for_anchor('article:' . $item['id'], FALSE)) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
         }
         // info on related links --optional
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
         }
         // details
         if (count($details)) {
             $suffix .= ' <span class="details">(' . ucfirst(implode(', ', $details)) . ')</span>';
         }
         // flag popular pages
         if ($item['hits'] > 300) {
             $suffix .= POPULAR_FLAG;
         }
         // last contribution
         if ($item['edit_action']) {
             $action = Anchors::get_action_label($item['edit_action']) . ' ';
         } else {
             $action = i18n::s('edited');
         }
         if ($item['edit_name']) {
             $suffix .= '<br /><span class="details">' . sprintf(i18n::s('%s by %s %s'), $action, Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date'])) . '</span>';
         } else {
             $suffix .= '<br /><span class="details">' . $action . ' ' . Skin::build_date($item['edit_date']) . '</span>';
         }
         // flag articles updated recently
         if ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $suffix .= $overlay->get_text('list', $item, $this->focus);
         }
         // the hovering title
         if ($item['introduction'] && $context['skins_with_details'] == 'Y') {
             $hover = strip_tags(Codes::beautify_introduction($item['introduction']));
         } else {
             $hover = i18n::s('View the page');
         }
         // help members to reference this page
         if (Surfer::is_member()) {
             $hover .= ' [article=' . $item['id'] . ']';
         }
         // add an image if available
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         } elseif (is_callable(array($anchor, 'get_bullet_url'))) {
             $icon = $anchor->get_bullet_url();
         }
         // format the image
         if ($icon) {
             $icon = Skin::build_link($url, '<img src="' . $icon . '" />', 'basic', $hover);
         }
         // list all components for this item
         if ($odd = !$odd) {
             $class = ' class="odd"';
         } else {
             $class = ' class="even"';
         }
         // use a table to layout the image properly
         if ($icon) {
             $text .= '<div' . $class . '><table class="decorated"><tr><td class="image" style="text-align: center">' . $icon . '</td><td class="content">' . $prefix . Skin::build_link($url, Skin::strip($title, 30), 'basic', $hover) . $suffix . '</td></tr></table></div>';
         } else {
             $text .= '<div' . $class . '>' . $prefix . Skin::build_link($url, Skin::strip($title, 30), 'basic', $hover) . $suffix . '</div>';
         }
     }
     // end of processing
     SQL::free($result);
     return $text;
 }
Example #22
0
 /**
  * remember the last action for this category
  *
  * @param string the description of the last action
  * @param string the id of the item related to this update
  * @param boolean TRUE to not change the edit date of this anchor, default is FALSE
  *
  * @see shared/anchor.php
  */
 function touch($action, $origin = NULL, $silently = FALSE)
 {
     global $context;
     // don't go further on import
     if (preg_match('/import$/i', $action)) {
         return;
     }
     // no category bound
     if (!isset($this->item['id'])) {
         return;
     }
     // sanity check
     if (!$origin) {
         logger::remember('categories/category.php: unexpected NULL origin at touch()');
         return;
     }
     // components of the query
     $query = array();
     // append a reference to a new image to the description
     if ($action == 'image:create') {
         if (!Codes::check_embedded($this->item['description'], 'image', $origin)) {
             // the overlay may prevent embedding
             if (is_object($this->overlay) && !$this->overlay->should_embed_files()) {
             } else {
                 // list has already started
                 if (preg_match('/\\[image=[^\\]]+?\\]\\s*$/', $this->item['description'])) {
                     $query[] = "description = '" . SQL::escape($this->item['description'] . ' [image=' . $origin . ']') . "'";
                 } else {
                     $query[] = "description = '" . SQL::escape($this->item['description'] . "\n\n" . '[image=' . $origin . ']') . "'";
                 }
             }
         }
         // also use it as thumnail if none has been defined yet
         if (!isset($this->item['thumbnail_url']) || !trim($this->item['thumbnail_url'])) {
             include_once $context['path_to_root'] . 'images/images.php';
             if (($image = Images::get($origin)) && ($url = Images::get_thumbnail_href($image))) {
                 $query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
             }
         }
         // refresh stamp only if image update occurs within 6 hours after last edition
         if (SQL::strtotime($this->item['edit_date']) + 6 * 60 * 60 < time()) {
             $silently = TRUE;
         }
         // suppress a reference to an image that has been deleted
     } elseif ($action == 'image:delete') {
         // suppress reference in main description field
         $query[] = "description = '" . SQL::escape(Codes::delete_embedded($this->item['description'], 'image', $origin)) . "'";
         // suppress references as icon and thumbnail as well
         include_once $context['path_to_root'] . 'images/images.php';
         if ($image = Images::get($origin)) {
             if ($url = Images::get_icon_href($image)) {
                 if ($this->item['icon_url'] == $url) {
                     $query[] = "icon_url = ''";
                 }
                 if ($this->item['thumbnail_url'] == $url) {
                     $query[] = "thumbnail_url = ''";
                 }
             }
             if ($url = Images::get_thumbnail_href($image)) {
                 if ($this->item['icon_url'] == $url) {
                     $query[] = "icon_url = ''";
                 }
                 if ($this->item['thumbnail_url'] == $url) {
                     $query[] = "thumbnail_url = ''";
                 }
             }
         }
         // set an existing image as the category icon
     } elseif ($action == 'image:set_as_icon') {
         include_once $context['path_to_root'] . 'images/images.php';
         if ($image = Images::get($origin)) {
             if ($url = Images::get_icon_href($image)) {
                 $query[] = "icon_url = '" . SQL::escape($url) . "'";
             }
             // also use it as thumnail if none has been defined yet
             if (!(isset($this->item['thumbnail_url']) && trim($this->item['thumbnail_url'])) && ($url = Images::get_thumbnail_href($image))) {
                 $query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
             }
         }
         $silently = TRUE;
         // set an existing image as the category thumbnail
     } elseif ($action == 'image:set_as_thumbnail') {
         include_once $context['path_to_root'] . 'images/images.php';
         if ($image = Images::get($origin)) {
             if ($url = Images::get_thumbnail_href($image)) {
                 $query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
             }
         }
         $silently = TRUE;
         // append a new image, and set it as the article thumbnail
     } elseif ($action == 'image:set_as_both') {
         if (!Codes::check_embedded($this->item['description'], 'image', $origin)) {
             $query[] = "description = '" . SQL::escape($this->item['description'] . ' [image=' . $origin . ']') . "'";
         }
         include_once $context['path_to_root'] . 'images/images.php';
         if ($image = Images::get($origin)) {
             if ($url = Images::get_thumbnail_href($image)) {
                 $query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
             }
         } elseif ($origin) {
             $query[] = "thumbnail_url = '" . SQL::escape($origin) . "'";
         }
         // do not remember minor changes
         $silently = TRUE;
         // add a reference to a new table in the category description
     } elseif ($action == 'table:create') {
         if (!Codes::check_embedded($this->item['description'], 'table', $origin)) {
             $query[] = "description = '" . SQL::escape($this->item['description'] . ' [table=' . $origin . ']') . "'";
         }
         // suppress a reference to a table that has been deleted
     } elseif ($action == 'table:delete') {
         $query[] = "description = '" . SQL::escape(Codes::delete_embedded($this->item['description'], 'table', $origin)) . "'";
     }
     // stamp the update
     if (!$silently) {
         $query[] = "edit_name='" . Surfer::get_name() . "'," . "edit_id=" . Surfer::get_id() . "," . "edit_address='" . Surfer::get_email_address() . "'," . "edit_action='{$action}'," . "edit_date='" . strftime('%Y-%m-%d %H:%M:%S') . "'";
     }
     // ensure we have a valid update query
     if (!@count($query)) {
         return;
     }
     // update the anchor category
     $query = "UPDATE " . SQL::table_name('categories') . " SET " . implode(', ', $query) . " WHERE id = " . SQL::escape($this->item['id']);
     if (SQL::query($query) === FALSE) {
         return;
     }
     // always clear the cache, even on no update
     Categories::clear($this->item);
     // get the parent
     if (!$this->anchor) {
         $this->anchor = Anchors::get($this->item['anchor']);
     }
     // propagate the touch upwards silently -- we only want to purge the cache
     if (is_object($this->anchor)) {
         $this->anchor->touch('category:update', $this->item['id'], TRUE);
     }
 }
Example #23
0
File: vote.php Project: rair/yacs
 list($label, $count) = $overlay->attributes['answers'][$vote];
 $overlay->attributes['answers'][$vote] = array($label, $count + 1);
 // supports up to two levels arrays
 foreach ($overlay->attributes as $name => $value) {
     if (is_array($value)) {
         foreach ($value as $sub_name => $sub_value) {
             $overlay->attributes[$name][$sub_name] = str_replace('\\', '\\\\', $sub_value);
         }
     } else {
         $overlay->attributes[$name] = str_replace('\\', '\\\\', $value);
     }
 }
 // update the record
 $item['overlay'] = serialize($overlay->attributes);
 // touch the related anchor
 if ($article = Anchors::get('article:' . $item['id'])) {
     $article->touch('vote', $item['id'], isset($_REQUEST['silent']) && $_REQUEST['silent'] == 'Y');
 }
 // update the database
 if (!Articles::put($item)) {
 } elseif ($next && !headers_sent()) {
     Safe::redirect($next);
     // ask for manual click
 } else {
     $context['text'] .= '<p>' . i18n::s('Thank you for your contribution') . "</p>\n";
     // link to the poll, depending on access rights
     $menu = array();
     if ($permitted) {
         $menu = array_merge($menu, array(Articles::get_permalink($item) => i18n::s('View poll results')));
     }
     // back to the front page
Example #24
0
 /**
  * list files
  *
  * Recognize following variants:
  * - 'section:123' to list items attached to one particular anchor
  * - 'no_author' to list items attached to one user profile
  *
  * @param resource the SQL result
  * @return string HTML text to be displayed, or NULL
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // sanity check
     if (!isset($this->focus)) {
         $this->focus = '';
     }
     // process all items in the list
     $items = array();
     while ($item = SQL::fetch($result)) {
         // one box at a time
         $box = '';
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // we feature only the head of the list, if we are at the origin page
         if (!count($items) && $anchor && is_string($this->focus) && $this->focus == $anchor->get_reference()) {
             $box .= Codes::render_object('file', $item['id']);
             // no side icon
             $icon = '';
             // we are listing various files from various places
         } else {
             $prefix = $suffix = '';
             // stream the file
             if (Files::is_stream($item['file_name'])) {
                 $url = Files::get_url($item['id'], 'stream', $item['file_name']);
             } else {
                 $url = Files::get_url($item['id'], 'fetch', $item['file_name']);
             }
             // absolute url
             $url = $context['url_to_home'] . $context['url_to_root'] . $url;
             // signal restricted and private files
             if ($item['active'] == 'N') {
                 $prefix .= PRIVATE_FLAG;
             } elseif ($item['active'] == 'R') {
                 $prefix .= RESTRICTED_FLAG;
             }
             // file title or file name
             $label = Codes::beautify_title($item['title']);
             if (!$label) {
                 $label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name']));
             }
             // show a reference to the file for members
             $hover = i18n::s('Get the file');
             if (Surfer::is_member()) {
                 $hover .= ' [file=' . $item['id'] . ']';
             }
             // flag files uploaded recently
             if ($item['create_date'] >= $context['fresh']) {
                 $suffix .= NEW_FLAG;
             } elseif ($item['edit_date'] >= $context['fresh']) {
                 $suffix .= UPDATED_FLAG;
             }
             // one line of text
             $box .= $prefix . Skin::build_link($url, $label, 'basic', $hover) . $suffix;
             // side icon
             if ($item['thumbnail_url']) {
                 $icon = $item['thumbnail_url'];
             } else {
                 $icon = $context['url_to_root'] . Files::get_icon_url($item['file_name']);
             }
             // build the complete HTML element
             $icon = '<img src="' . $icon . '" alt="" title="' . encode_field(strip_tags($label)) . '" />';
             // make it a clickable link
             $icon = Skin::build_link($url, $icon, 'basic');
         }
         // first line of details
         $details = array();
         // file poster and last action
         if ($this->layout_variant != 'no_author') {
             $details[] = sprintf(i18n::s('shared by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
         } else {
             $details[] = Skin::build_date($item['edit_date']);
         }
         // downloads
         if ($item['hits'] > 1) {
             $details[] = Skin::build_number($item['hits'], i18n::s('downloads'));
         }
         // file size
         if ($item['file_size'] > 1) {
             $details[] = Skin::build_number($item['file_size'], i18n::s('bytes'));
         }
         // anchor link
         if ($anchor && is_string($this->focus) && $this->focus != $anchor->get_reference()) {
             $anchor_url = $anchor->get_url();
             $anchor_label = ucfirst($anchor->get_title());
             $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor_url, $anchor_label, 'article'));
         }
         $box .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>';
         // append details
         $details = array();
         // view the file
         $details[] = Skin::build_link(Files::get_permalink($item), i18n::s('details'), 'basic');
         // file has been detached
         if (isset($item['assign_id']) && $item['assign_id']) {
             // who has been assigned?
             if (Surfer::is($item['assign_id'])) {
                 $details[] = DRAFT_FLAG . sprintf(i18n::s('reserved by you %s'), Skin::build_date($item['assign_date']));
             } else {
                 $details[] = DRAFT_FLAG . sprintf(i18n::s('reserved by %s %s'), Users::get_link($item['assign_name'], $item['assign_address'], $item['assign_id']), Skin::build_date($item['assign_date']));
             }
         }
         // detach or edit the file
         if (Files::allow_modification($item, $anchor)) {
             if (!isset($item['assign_id']) || !$item['assign_id']) {
                 $details[] = Skin::build_link(Files::get_url($item['id'], 'reserve'), i18n::s('reserve'), 'basic', i18n::s('Prevent other persons from changing this file until you update it'));
             }
             // release reservation
             if (isset($item['assign_id']) && $item['assign_id'] && (Surfer::is($item['assign_id']) || is_object($anchor) && $anchor->is_owned())) {
                 $details[] = Skin::build_link(Files::get_url($item['id'], 'release'), i18n::s('release reservation'), 'basic', i18n::s('Allow other persons to update this file'));
             }
             if (!isset($item['assign_id']) || !$item['assign_id'] || Surfer::is($item['assign_id']) || is_object($anchor) && $anchor->is_owned()) {
                 $details[] = Skin::build_link(Files::get_url($item['id'], 'edit'), i18n::s('update'), 'basic', i18n::s('Share a new version of this file, or change details'));
             }
         }
         // delete the file
         if (Files::allow_deletion($item, $anchor)) {
             $details[] = Skin::build_link(Files::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic');
         }
         // append details
         if (count($details)) {
             $box .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>';
         }
         // insert item icon
         if ($icon) {
             $list = array(array($box, $icon));
             $items[] = Skin::finalize_list($list, 'decorated');
             // put the item in a division
         } else {
             $items[] = '<div style="margin: 0 0 1em 0">' . $box . '</div>';
         }
     }
     // stack all items in a single column
     $text = Skin::finalize_list($items, 'rows');
     // end of processing
     SQL::free($result);
     return $text;
 }
Example #25
0
File: agree.php Project: rair/yacs
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// common definitions and initial processing
include_once '../../shared/global.php';
// look for the id
$id = NULL;
if (isset($_REQUEST['id'])) {
    $id = $_REQUEST['id'];
} elseif (isset($context['arguments'][0])) {
    $id = $context['arguments'][0];
}
$id = strip_tags($id);
// get the related anchor, if any
$anchor = NULL;
if (isset($id)) {
    $anchor = Anchors::get($id);
}
// load localized strings
i18n::bind('behaviors');
// load the skin, maybe with a variant
load_skin('agreements', $anchor);
// no subject
if (!is_object($anchor)) {
    Logger::error(i18n::s('No item has the provided id.'));
} else {
    // initialize the list of agreements
    if (!isset($_SESSION['agreements']) || !is_array($_SESSION['agreements'])) {
        $_SESSION['agreements'] = array();
    }
    // append the new agreement
    $_SESSION['agreements'][] = $anchor->get_reference();
 /**
  * list articles as digg do
  *
  * @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)) {
         $label = i18n::s('No page to display.');
         if (Surfer::is_associate()) {
             $label .= ' ' . sprintf(i18n::s('Use the %s to populate this server.'), Skin::build_link('help/populate.php', i18n::s('Content Assistant'), 'shortcut'));
         }
         $output = '<p>' . $label . '</p>';
         return $output;
     }
     // build a list of articles
     $text = '';
     $item_count = 0;
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // permalink
         $url = Articles::get_permalink($item);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // next item
         $item_count += 1;
         // section opening
         if ($item_count == 1) {
             $text .= '<div class="newest">' . "\n";
         }
         // reset everything
         $content = $prefix = $label = $suffix = $icon = '';
         // the icon to put aside
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         } elseif (is_callable(array($anchor, 'get_bullet_url'))) {
             $icon = $anchor->get_bullet_url();
         }
         if ($icon) {
             $icon = '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $icon . '" class="right_image" alt="' . encode_field(i18n::s('View the page')) . '" title="' . encode_field(i18n::s('View the page')) . '" /></a>';
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // flag articles updated recently
         if ($item['create_date'] >= $context['fresh']) {
             $suffix .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= ' ' . UPDATED_FLAG;
         }
         // add details
         $details = array();
         // the author
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             if ($item['edit_name'] == $item['create_name']) {
                 $details[] = sprintf(i18n::s('by %s'), ucfirst($item['create_name']));
             } else {
                 $details[] = sprintf(i18n::s('by %s, %s'), ucfirst($item['create_name']), ucfirst($item['edit_name']));
             }
         }
         // the publish date
         $details[] = Skin::build_date($item['publish_date']);
         // rating
         $rating_label = '';
         if ($item['rating_count']) {
             $rating_label = Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])) . ' ' . sprintf(i18n::ns('%d rating', '%d ratings', $item['rating_count']), $item['rating_count']) . ' ';
         }
         // add a link to let surfer rate this item
         if (is_object($anchor) && !$anchor->has_option('without_rating')) {
             if (!$item['rating_count']) {
                 $rating_label .= i18n::s('Rate this page');
             }
             $rating_label = Skin::build_link(Articles::get_url($item['id'], 'like'), $rating_label, 'basic', i18n::s('Rate this page'));
         }
         // display current rating, and allow for rating
         $details[] = $rating_label;
         // details
         if (count($details)) {
             $content .= '<p class="details">' . ucfirst(implode(', ', $details)) . '</p>';
         }
         // the full introductory text
         if ($item['introduction']) {
             $content .= Codes::beautify($item['introduction'], $item['options']);
         } elseif (!is_object($overlay)) {
             include_once $context['path_to_root'] . 'articles/article.php';
             $article = new Article();
             $article->load_by_content($item);
             $content .= $article->get_teaser('teaser');
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $content .= $overlay->get_text('list', $item);
         }
         // an array of links
         $menu = array();
         // rate the article
         $menu = array_merge($menu, array(Articles::get_url($item['id'], 'like') => i18n::s('Rate this page')));
         // read the article
         $menu = array_merge($menu, array($url => i18n::s('Read more')));
         // 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
         if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
             $link = Comments::get_url('article:' . $item['id'], 'list');
             $menu = array_merge($menu, array($link => sprintf(i18n::ns('%d comment', '%d comments', $count), $count)));
         }
         // discuss
         if (Comments::allow_creation($item, $anchor)) {
             $menu = array_merge($menu, array(Comments::get_url('article:' . $item['id'], 'comment') => i18n::s('Discuss')));
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             $menu = array_merge($menu, array($url . '#_attachments' => sprintf(i18n::ns('%d link', '%d links', $count), $count)));
         }
         // trackback
         if (Links::allow_trackback()) {
             $menu = array_merge($menu, array('links/trackback.php?anchor=' . urlencode('article:' . $item['id']) => i18n::s('Reference this page')));
         }
         // link to the anchor page
         if (is_object($anchor)) {
             $menu = array_merge($menu, array($anchor->get_url() => $anchor->get_title()));
         }
         // list up to three categories by title, if any
         if ($items = Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 3, 'raw')) {
             foreach ($items as $id => $attributes) {
                 $menu = array_merge($menu, array(Categories::get_permalink($attributes) => $attributes['title']));
             }
         }
         // append a menu
         $content .= Skin::build_list($menu, 'menu_bar');
         // insert a complete box
         $text .= Skin::build_box($icon . $prefix . Codes::beautify_title($item['title']) . $suffix, $content, 'header1', 'article_' . $item['id']);
         // section closing
         if ($item_count == 1) {
             $text .= '</div>' . "\n";
         }
     }
     // end of processing
     SQL::free($result);
     // add links to archives
     $anchor = Categories::get(i18n::c('monthly'));
     if (isset($anchor['id']) && ($items = Categories::list_by_date_for_anchor('category:' . $anchor['id'], 0, COMPACT_LIST_SIZE, 'compact'))) {
         $text .= Skin::build_box(i18n::s('Previous pages'), Skin::build_list($items, 'menu_bar'));
     }
     return $text;
 }
Example #27
0
File: links.php Project: rair/yacs
 /**
  * ping back links referenced in some text
  *
  * This is the client implementation of
  * [link=trackback]http://www.movabletype.org/docs/mttrackback.html[/link]
  * and [link=pingback]http://www.hixie.ch/specs/pingback/pingback[/link] specifications.
  *
  * This function is triggered by publishing scripts, either [script]articles/publish.php[/script],
  * [script]services/blog.php[/script], [script]agents/messages.php[/script] or [script]agents/uploads.php[/script].
  *
  * @see articles/publish.php
  * @see services/blog.php
  * @see agents/messages.php
  * @see agents/uploads.php
  *
  * It is used to efficiently link pages across a set of web sites according to the following mechanism:
  * - The list of external links is built for this page
  * - Only the 7 first links are kept from the list; others are stripped
  * - If links do not exist, create additional records in the table used for links
  * - Each link (actually, only the 7 most recent) is checked, to see if it's trackback- or pingback-enabled or not
  * - Each trackback-/pingback-enabled link is activated, providing the full URL of the anchor page
  *
  * We are claiming to support most of the trackback client interface here, as described in the [link=trackback]http://www.movabletype.org/docs/mttrackback.html[/link] specification.
  * A foreign page is considered as being trackback-enabled if it has a special RDF section
  * linking its reference (i.e., URL) to a Trackback Ping URL.
  *
  * Note that YACS also implements the server part of the trackback specification in [script]links/trackback.php[/script],
  * which supports POST REST calls.
  *
  * @see links/trackback.php
  *
  * We are claiming to fully support the pingback client interface here, as described in the [link=pingback]http://www.hixie.ch/specs/pingback/pingback[/link] specification.
  * A foreign page is considered to be pingback-enabled if it has a meta link to a Pingback Ping URL.
  *
  * Note that YACS also implements the server part of the pingback specification in [script]services/ping.php[/script],
  * which supports XML-RPC calls.
  *
  * @see services/ping.php
  *
  * This function transforms every YACS codes into HTML before extracting links,
  * and before submitting the excerpt to remote site.
  *
  * @param string the referencing text that has to be scanned
  * @param string the local anchor of the referencing text (e.g., 'article:124')
  * @return array list($links, $advertised, $skipped)
  *
  * @link http://www.movabletype.org/docs/mttrackback.html TrackBack Technical Specification
  * @link http://www.hixie.ch/specs/pingback/pingback Pingback specification
  */
 public static function ping($text, $anchor)
 {
     global $context;
     // render all codes
     if (is_callable(array('Codes', 'beautify'))) {
         $text = Codes::beautify($text);
     }
     // suppress all links not coming from anchors (eg, <img src=...)
     $text = strip_tags($text, '<a>');
     // extract all links from the text, including those that have been encoded by YACS
     preg_match_all('/((http:\\/\\/|http%3A%2F%2F)[^ <"]+)/i', $text, $links);
     // nothing to do
     if (!@count($links[1])) {
         return;
     }
     // process each link only once
     $unique_links = array();
     foreach ($links[1] as $url) {
         // decode raw url encoding, if any
         $url = rawurldecode($url);
         // strip the clicking indirection, if any
         $url = rawurldecode(preg_replace('/^' . preg_quote($context['url_to_home'] . $context['url_to_root'] . 'links/click.php?url=', '/') . '/i', '', $url));
         $unique_links[$url] = 1;
     }
     // analyze found links
     $links_processed = array();
     $links_advertised = array();
     $links_skipped = array();
     foreach ($unique_links as $url => $dummy) {
         // analyze no more than 7 links
         if (@count($links_processed) >= 7) {
             break;
         }
         // skip links that point to ourself, and not to an article
         if (preg_match('/^' . preg_quote($context['url_to_home'], '/') . '\\b/i', $url) && !preg_match('/\\/article(-|s\\/view.php)/i', $url)) {
             $links_skipped[] = $url;
             continue;
         }
         // skip invalid links
         if (($content = http::proceed($url)) === FALSE) {
             $links_skipped[] = $url;
             continue;
         }
         // we will use the content to locate pingback and trackback interfaces
         $pages[$url] = $content;
         // ensure enough execution time
         Safe::set_time_limit(30);
         // stats
         $links_processed[] = $url;
     }
     // locate the anchor object for this text, we need its url
     $anchor = Anchors::get($anchor);
     if (!is_object($anchor)) {
         return;
     }
     // build an excerpt from anchor
     $excerpt = $anchor->get_teaser('basic');
     // find blog name for anchor
     if ($parent = $anchor->get_value('anchor')) {
         $blog = Anchors::get($parent);
         if (is_object($blog)) {
             $blog_name = $blog->get_title();
         }
     }
     // build an absolute URL for the source
     $source = $context['url_to_home'] . $context['url_to_root'] . $anchor->get_url();
     // process each link
     if (@count($pages)) {
         foreach ($pages as $target => $content) {
             // try trackback, if implemented
             if (Links::ping_as_trackback($content, $source, $target, $anchor->get_title(), $excerpt, $blog_name)) {
                 $links_advertised[] = $target;
             } elseif (Links::ping_as_pingback($content, $source, $target)) {
                 $links_advertised[] = $target;
             }
         }
     }
     return array($links_processed, $links_advertised, $links_skipped);
 }
 /**
  * list articles
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // sanity check
     if (!isset($this->focus)) {
         $this->focus = 'map';
     }
     // put in cache
     $cache_id = Cache::hash('articles/layout_articles_as_carrousel:' . $this->focus) . '.xml';
     // save for one minute
     if (!file_exists($context['path_to_root'] . $cache_id) || filemtime($context['path_to_root'] . $cache_id) + 60 < time()) {
         // content of the slideshow
         $content = '<?xml version="1.0" encoding="utf-8"?><!-- fhShow Carousel 2.0 configuration file Please visit http://www.flshow.net/ -->' . "\n" . '<slide_show>' . "\n" . '	<options>' . "\n" . '		<debug>false</debug>				  <!-- true, false -->' . "\n" . '		<background>transparent</background>	  <!-- #RRGGBB, transparent -->' . "\n" . '		<friction>5</friction>			  <!-- [1,100] -->' . "\n" . '		<fullscreen>false</fullscreen>	  <!-- true, false -->' . "\n" . '		<margins>' . "\n" . '			<top>0</top>								  <!-- [-1000,1000] pixels -->' . "\n" . '			<left>0</left>							  <!-- [-1000,1000] pixels -->' . "\n" . '			<bottom>0</bottom>						  <!-- [-1000,1000] pixels -->' . "\n" . '			<right>0</right>							  <!-- [-1000,1000] pixels -->' . "\n" . '			<horizontal_ratio>20%</horizontal_ratio>	  <!-- [1,50] a photo may occupy at most horizontalRatio percent of the Carousel width -->' . "\n" . '			<vertical_ratio>90%</vertical_ratio>		  <!-- [1,100] a photo may occupy at most verticalRatio percent of the Carousel height -->' . "\n" . '		</margins>' . "\n" . '		<interaction>' . "\n" . '			<rotation>mouse</rotation>			<!-- auto, mouse, keyboard -->' . "\n" . '			<view_point>none</view_point>		   <!-- none, mouse, keyboard -->' . "\n" . '			<speed>15</speed>						<!-- [-360,360] degrees per second -->' . "\n" . '			<default_speed>15</default_speed>				<!-- [-360,360] degrees per second -->' . "\n" . '			<default_view_point>20%</default_view_point>	<!-- [0,100] percentage -->' . "\n" . '			<reset_delay>20</reset_delay>					<!-- [0,600] seconds, 0 means never reset -->' . "\n" . '		</interaction>' . "\n" . '		<far_photos>' . "\n" . '			<size>50%</size>					<!-- [0,100] percentage -->' . "\n" . '			<amount>50%</amount>				<!-- [0,100] percentage -->' . "\n" . '			<blur>10</blur>					<!-- [0,100] amount -->' . "\n" . '			<blur_quality>3</blur_quality>	<!-- [1,3] 1=low - 3=high -->' . "\n" . '		</far_photos>' . "\n" . '		<reflection>' . "\n" . '			<amount>25</amount>	   <!-- [0,1000] pixels -->' . "\n" . '			<blur>2</blur>			<!-- [0,100] blur amount -->' . "\n" . '			<distance>0</distance>	<!-- [-1000,1000] pixels -->' . "\n" . '			<alpha>40%</alpha>		<!-- [0,100] percentage -->' . "\n" . '		</reflection>' . "\n" . '		<titles>' . "\n" . '			<style>font-size: 14px; font-family: Verdana, _serif; color: #000000;</style>' . "\n" . '			<position>above center</position>			  <!-- [above, below] [left,center,right]-->' . "\n" . '			<background>' . $context['url_to_home'] . $context['url_to_root'] . 'skins/_reference/layouts/carrousel_bubble.png</background>	   <!-- image url -->' . "\n" . '			<scale9>35 35 35 35</scale9>				 <!-- [0,1000] pixels -->' . "\n" . '			<padding>8 15 10 15</padding>					<!-- [-1000,1000] pixels -->' . "\n" . '		</titles>' . "\n" . '	</options>' . "\n";
         // get a default image
         if (Safe::GetImageSize($context['path_to_root'] . $context['skin'] . '/layouts/map.gif')) {
             $default_href = $context['url_to_root'] . $context['skin'] . '/layouts/map.gif';
         } elseif ($size = Safe::GetImageSize($context['path_to_root'] . 'skins/_reference/layouts/map.gif')) {
             $default_href = $context['url_to_root'] . 'skins/_reference/layouts/map.gif';
         } else {
             $default_href = NULL;
         }
         // process all items in the list
         while ($item = SQL::fetch($result)) {
             // get the related overlay
             $overlay = Overlay::load($item, 'article:' . $item['id']);
             // get the anchor
             $anchor = Anchors::get($item['anchor']);
             // this is visual
             if (isset($item['icon_url']) && $item['icon_url']) {
                 $image = $item['icon_url'];
             } elseif (isset($item['thumbnail_url']) && $item['thumbnail_url']) {
                 $image = $item['thumbnail_url'];
             } elseif (is_callable(array($anchor, 'get_bullet_url')) && ($image = $anchor->get_bullet_url())) {
             } elseif ($default_href) {
                 $image = $default_href;
             } else {
                 continue;
             }
             // fix relative path
             if (!preg_match('/^(\\/|http:|https:|ftp:)/', $image)) {
                 $image = $context['url_to_home'] . $context['url_to_root'] . $image;
             }
             // build a title
             if (is_object($overlay)) {
                 $title = Codes::beautify_title($overlay->get_text('title', $item));
             } else {
                 $title = Codes::beautify_title($item['title']);
             }
             // the url to view this item
             $url = Articles::get_permalink($item);
             // add to the list
             $content .= '	<photo>' . "\n" . '		<title>' . $title . '</title>' . "\n" . '		<src>' . $image . '</src>' . "\n" . '		<href>' . $url . '</href>' . "\n" . '		<target>_self</target>' . "\n" . '	</photo>' . "\n";
         }
         // finalize slideshow content
         $content .= '</slide_show>';
         // put in cache
         Safe::file_put_contents($cache_id, $content);
     }
     // allow multiple instances
     static $count;
     if (!isset($count)) {
         $count = 1;
     } else {
         $count++;
     }
     // load the right file
     $text = '<div id="articles_as_carrousel_' . $count . '"></div>' . "\n";
     Page::insert_script('swfobject.embedSWF("' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/carrousel.swf",' . "\n" . '"articles_as_carrousel_' . $count . '",' . "\n" . '"100%",' . "\n" . '"150",' . "\n" . '"9.0.0",' . "\n" . 'false,' . "\n" . '{xmlfile:"' . $context['url_to_home'] . $context['url_to_root'] . $cache_id . '", loaderColor:"0x666666"},' . "\n" . '{wmode: "transparent"},' . "\n" . '{});' . "\n");
     // end of processing
     SQL::free($result);
     return $text;
 }
Example #29
0
File: select.php Project: rair/yacs
 */
// common definitions and initial processing
include_once '../shared/global.php';
include_once 'categories.php';
// the anchor associated with a category
$member = NULL;
if (isset($_REQUEST['member'])) {
    $member = $_REQUEST['member'];
} elseif (isset($_REQUEST['anchor']) && isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'GET') {
    $member = $_REQUEST['anchor'];
}
$member = strip_tags($member);
// get the member object, which is supposed to be a container
$anchor = NULL;
if ($member) {
    $anchor = Anchors::get($member);
}
// do we have the permission to add new categories?
if (Categories::allow_assign(NULL, $anchor)) {
    $permitted = TRUE;
} else {
    $permitted = FALSE;
}
// load the skin
load_skin('categories');
// the path to this page
if (is_object($anchor) && $anchor->is_viewable()) {
    $context['path_bar'] = $anchor->get_path_bar();
} else {
    $context['path_bar'] = array('categories/' => i18n::s('Categories'));
}
Example #30
0
 /**
  * list sections as topics in a forum
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // layout in a table
     $text = Skin::table_prefix('wide');
     // 'even' is used for title rows, 'odd' for detail rows
     $class_title = 'odd';
     $class_detail = 'even';
     // build a list of sections
     $family = '';
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // change the family
         if ($item['family'] != $family) {
             $family = $item['family'];
             // show the family
             $text .= Skin::table_suffix() . '<h2><span>' . $family . '&nbsp;</span></h2>' . "\n" . Skin::table_prefix('wide');
         }
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'section:' . $item['id']);
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // reset everything
         $prefix = $label = $suffix = $icon = '';
         // signal restricted and private sections
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // indicate the id in the hovering popup
         $hover = i18n::s('View the section');
         if (Surfer::is_member()) {
             $hover .= ' [section=' . $item['id'] . ']';
         }
         // the url to view this item
         $url = Sections::get_permalink($item);
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // use the title as a link to the page
         $title =& Skin::build_link($url, $title, 'basic', $hover);
         // flag sections updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $suffix = EXPIRED_FLAG . ' ';
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix = NEW_FLAG . ' ';
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix = UPDATED_FLAG . ' ';
         }
         // this is another row of the output
         $text .= '<tr class="' . $class_title . '"><th>' . $prefix . $title . $suffix . '</th><th>' . i18n::s('Poster') . '</th><th>' . i18n::s('Messages') . '</th><th>' . i18n::s('Last active') . '</th></tr>' . "\n";
         $count = 1;
         // get last posts for this board --avoid sticky pages
         if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
             $order = $matches[1];
         } else {
             $order = 'edition';
         }
         if ($articles =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], 0, 5, 'raw', TRUE)) {
             foreach ($articles as $id => $article) {
                 // get the related overlay, if any
                 $article_overlay = Overlay::load($article, 'article:' . $id);
                 // flag articles updated recently
                 if ($article['expiry_date'] > NULL_DATE && $article['expiry_date'] <= $context['now']) {
                     $flag = EXPIRED_FLAG . ' ';
                 } elseif ($article['create_date'] >= $context['fresh']) {
                     $flag = NEW_FLAG . ' ';
                 } elseif ($article['edit_date'] >= $context['fresh']) {
                     $flag = UPDATED_FLAG . ' ';
                 } else {
                     $flag = '';
                 }
                 // use the title to label the link
                 if (is_object($article_overlay)) {
                     $title = Codes::beautify_title($article_overlay->get_text('title', $article));
                 } else {
                     $title = Codes::beautify_title($article['title']);
                 }
                 // title
                 $title = Skin::build_link(Articles::get_permalink($article), $title, 'article');
                 // poster
                 $poster = Users::get_link($article['create_name'], $article['create_address'], $article['create_id']);
                 // comments
                 $comments = Comments::count_for_anchor('article:' . $article['id']);
                 // last editor
                 $action = '';
                 if ($article['edit_date']) {
                     // label the action
                     if (isset($article['edit_action'])) {
                         $action = Anchors::get_action_label($article['edit_action']);
                     } else {
                         $action = i18n::s('edited');
                     }
                     $action = '<span class="details">' . $action . ' ' . Skin::build_date($article['edit_date']) . '</span>';
                 }
                 // this is another row of the output
                 $text .= '<tr class="' . $class_detail . '"><td>' . $title . $flag . '</td><td>' . $poster . '</td><td style="text-align: center;">' . $comments . '</td><td>' . $action . '</td></tr>' . "\n";
             }
         }
         // more details
         $details = array();
         // board introduction
         if ($item['introduction']) {
             $details[] = Codes::beautify_introduction($item['introduction']);
         }
         // indicate the total number of threads here
         if (($count = Articles::count_for_anchor('section:' . $item['id'])) && $count >= 5) {
             $details[] = sprintf(i18n::s('%d threads'), $count) . '&nbsp;&raquo;';
         }
         // link to the section index page
         if ($details) {
             $details = Skin::build_link(Sections::get_permalink($item), join(' -&nbsp;', $details), 'basic');
         } else {
             $details = '';
         }
         // add a command for new post
         $poster = '';
         if (Surfer::is_empowered()) {
             $poster = Skin::build_link('articles/edit.php?anchor=' . urlencode('section:' . $item['id']), i18n::s('Add a page') . '&nbsp;&raquo;', 'basic');
         }
         // insert details in a separate row
         if ($details || $poster) {
             $text .= '<tr class="' . $class_detail . '"><td colspan="3">' . $details . '</td><td>' . $poster . '</td></tr>' . "\n";
         }
         // more details
         $more = array();
         // board moderators
         if ($moderators = Sections::list_editors_by_name($item, 0, 7, 'comma5')) {
             $more[] = sprintf(i18n::ns('Moderator: %s', 'Moderators: %s', count($moderators)), $moderators);
         }
         // children boards
         if ($children =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, COMPACT_LIST_SIZE, 'compact')) {
             $more[] = sprintf(i18n::ns('Child board: %s', 'Child boards: %s', count($children)), Skin::build_list($children, 'comma'));
         }
         // as a compact list
         if (count($more)) {
             $content = '<ul class="compact">';
             foreach ($more as $list_item) {
                 $content .= '<li>' . $list_item . '</li>' . "\n";
             }
             $content .= '</ul>' . "\n";
             // insert details in a separate row
             $text .= '<tr class="' . $class_detail . '"><td colspan="4">' . $content . '</td></tr>' . "\n";
         }
     }
     // end of processing
     SQL::free($result);
     $text .= Skin::table_suffix();
     return $text;
 }