/**
  * list comments
  *
  * @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
     include_once $context['path_to_root'] . 'comments/comments.php';
     while ($item = SQL::fetch($result)) {
         // url to view the comment
         $url = Comments::get_url($item['id']);
         // initialize variables
         $prefix = $label = $suffix = $icon = '';
         // the title as the label
         if ($item['create_name']) {
             $label .= ucfirst($item['create_name']) . ' ';
         }
         // time of creation
         $label .= Skin::build_date($item['create_date']);
         // text beginning
         if ($text = Skin::strip($item['description'], 10, NULL, NULL)) {
             $suffix = ' - ' . $text;
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'comment', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Beispiel #2
0
 /**
  * list tables
  *
  * Recognize following variants:
  * - 'no_anchor' to list items attached to one particular anchor
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @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)) {
         // initialize variables
         $prefix = $suffix = $icon = '';
         // the url to view this item
         $url = Tables::get_url($item['id']);
         // flag tables created or updated very recently
         if ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         $label = Skin::strip($item['title'], 10);
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'table', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
 /**
  * list sections
  *
  * @param resource the SQL result
  * @return an array of $url => (NULL, $title, NULL, 'section_123', NULL, 'visit this section')
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // no hovering label
     $href_title = '';
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // the url to view this item
         $url = Sections::get_permalink($item);
         // initialize variables
         $prefix = $suffix = '';
         // list all components for this item
         $items[$url] = array($prefix, ucfirst(Skin::strip($item['index_title'], 30)), $suffix, 'section_' . $item['id'], NULL, $href_title);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Beispiel #4
0
 /**
  * list users
  *
  * @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 (!($delta = SQL::count($result))) {
         return $text;
     }
     // flag idle users
     $idle = gmstrftime('%Y-%m-%d %H:%M:%S', time() - 600);
     // process all items in the list
     $count = 0;
     $items = array();
     while ($item = SQL::fetch($result)) {
         // url to view the user
         $url = Users::get_permalink($item);
         // initialize variables
         $prefix = $suffix = '';
         // signal restricted and private users
         if (isset($item['active']) && $item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif (isset($item['active']) && $item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // signal locked profiles
         if (isset($item['capability']) && $item['capability'] == '?') {
             $prefix .= EXPIRED_FLAG;
         }
         // item title
         if (isset($item['full_name']) && $item['full_name']) {
             $label = ucfirst(Skin::strip($item['full_name'], 10));
             $hover = $item['nick_name'];
         } else {
             $label = ucfirst(Skin::strip($item['nick_name'], 10));
             $hover = $item['full_name'];
         }
         // flag idle users
         if (!isset($item['click_date']) || $item['click_date'] < $idle) {
             $class = 'idle user';
         } else {
             $class = 'user';
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, $class, NULL, $hover);
         // provide only some results
         if (++$count >= 5) {
             break;
         }
     }
     // end of processing
     SQL::free($result);
     // turn this to some text
     $text = Skin::build_list($items, 'comma');
     // some indications on the number of connections
     if ($delta -= $count) {
         $text .= ', ...';
     }
     return $text;
 }
 /**
  * list servers
  *
  * @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)) {
         // initialize variables
         $prefix = $suffix = $icon = '';
         // the url to view this item
         $url = Servers::get_url($item['id']);
         // use the title as a label
         $label = Skin::strip($item['title'], 10);
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'server', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Beispiel #6
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)) {
         // url to view the image
         $url = Images::get_url($item['id']);
         // initialize variables
         $prefix = $suffix = '';
         // flag new images
         if ($item['edit_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         }
         // image title or image name
         $label = Skin::strip($item['title'], 10);
         if (!$label) {
             $name_as_title = TRUE;
             $label = ucfirst($item['image_name']);
         }
         $label = str_replace('_', ' ', str_replace('%20', ' ', $label));
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Beispiel #7
0
 /**
  * list servers
  *
  * @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)) {
         // initialize variables
         $prefix = $suffix = $icon = '';
         // the url to view this item
         $url = Servers::get_url($item['id']);
         // use the title as a label
         $label = Skin::strip($item['title'], 10);
         // flag files uploaded recently
         if ($item['edit_date'] >= $context['fresh']) {
             $prefix = NEW_FLAG . $prefix;
         }
         // description
         if ($item['description']) {
             $suffix .= ' ' . ucfirst(trim($item['description']));
         }
         // the menu bar for associates and poster
         if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) {
             $menu = array(Servers::get_url($item['id'], 'edit') => i18n::s('Edit'), Servers::get_url($item['id'], 'delete') => i18n::s('Delete'));
             $suffix .= ' ' . Skin::build_list($menu, 'menu');
         }
         // add a separator
         if ($suffix) {
             $suffix = ' - ' . $suffix;
         }
         // append details to the suffix
         $suffix .= BR . '<span class="details">';
         // details
         $details = array();
         // item poster
         if ($item['edit_name']) {
             $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
         }
         // the edition date
         $details[] = Skin::build_date($item['edit_date']);
         // all details
         if (count($details)) {
             $suffix .= ucfirst(implode(', ', $details)) . "\n";
         }
         // end of details
         $suffix .= '</span>';
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'server', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Beispiel #8
0
 /**
  * list users
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // url to view the user profile
         $url = Users::get_permalink($item);
         // time of last update
         $time = SQL::strtotime($item['edit_date']);
         // item title
         if ($item['full_name']) {
             $label = ucfirst(Skin::strip($item['full_name'], 10));
         } else {
             $label = ucfirst(Skin::strip($item['nick_name'], 10));
         }
         // the section
         $section = '';
         // the author(s) is an e-mail address, according to rss 2.0 spec
         $author .= $item['edit_address'] . ' (' . $item['edit_name'] . ')';
         // introduction
         $introduction = Codes::beautify($item['introduction']);
         // the description
         $description = Codes::beautify($item['description']);
         // cap the number of words
         $description = Skin::cap($description, 300);
         // fix image references
         $description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description);
         // other rss fields
         $extensions = array();
         // list all components for this item
         $items[$url] = array($time, $label, $author, $section, $icon, $introduction, $description, $extensions);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
 /**
  * list categories
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // url to view the comment
         $url = Categories::get_permalink($item);
         // use the title to label the link
         $label = ucfirst(Skin::strip($item['title'], 20));
         // number of items for this category
         $count = 0;
         // count sections for this category
         if ($scount = Members::count_sections_for_anchor('category:' . $item['id'])) {
             $count += $scount;
         }
         // count articles for this category
         if ($acount = Members::count_articles_for_anchor('category:' . $item['id'])) {
             $count += $acount;
         }
         // format total count of items
         if ($count) {
             $count = ' (' . $count . ')';
         } else {
             $count = '';
         }
         // list all components for this item
         $items[$url] = array('', $label, $count, 'basic', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
 /**
  * list locations
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // url to view the location
         $url = Locations::get_url($item['id']);
         // initialize variables
         $prefix = $suffix = '';
         // flag new locations
         if ($item['edit_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         }
         // build a valid label
         if ($item['geo_place_name']) {
             $label = Skin::strip($item['geo_place_name'], 10);
         } else {
             $label = $item['latitude'] . ', ' . $item['longitude'];
         }
         // the distance, if any
         $distance = '';
         if ($item['distance']) {
             $distance = ' ' . round($item['distance'], -1) . '&nbsp;km';
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Beispiel #11
0
 /**
  * list servers
  *
  * @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)) {
         // the url to view this item
         $url = Servers::get_url($item['id']);
         // use the title as a label
         $label = Skin::strip($item['title'], 10);
         // list all components for this item
         $items[$url] = array('', $label, ' ' . Skin::build_date($item['edit_date']), 'server', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
 /**
  * list categories
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // url to view the comment
         $url = Categories::get_permalink($item);
         // use the title to label the link
         $label = ucfirst(Skin::strip($item['title'], 20));
         // list all components for this item
         $items[$url] = array('', $label, NULL, 'basic', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
 /**
  * list sections
  *
  * @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 related overlay, if any
         $overlay = Overlay::load($item, 'section:' . $item['id']);
         // the url to view this item
         $url = Sections::get_permalink($item);
         // initialize variables
         $prefix = $label = $suffix = '';
         // flag sections that are draft or dead
         if ($item['activation_date'] >= $context['now']) {
             $prefix .= DRAFT_FLAG;
         } elseif ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $prefix .= EXPIRED_FLAG;
         }
         // signal restricted and private sections
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // flag items updated recently
         if ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         //			// start the label with family, if any
         //			if($item['family'])
         //				$label = ucfirst(Skin::strip($item['family'], 30)).' - ';
         // use the title to label the link
         if (is_object($overlay)) {
             $label = ucfirst(Codes::beautify_title($overlay->get_text('title', $item)));
         } else {
             $label .= ucfirst(Skin::strip($item['index_title'], 30));
         }
         // 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 section');
         }
         // help members to reference this page
         if (Surfer::is_member()) {
             $hover .= ' [section=' . $item['id'] . ']';
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'basic', NULL, $hover);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Beispiel #14
0
     $description = Skin::strip(Codes::beautify($item['description']), 50);
 }
 // prepare the response
 $text = '<?xml version="1.0" encoding="' . $context['charset'] . '"?>' . "\n" . '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">' . "\n" . '	<rdf:Description rdf:about="' . $url . '">' . "\n" . '		<dc:title>' . encode_field($item['title']) . '</dc:title>' . "\n" . '		<dc:description>' . encode_field(Skin::strip($description)) . '</dc:description>' . "\n" . '		<dc:date>' . gmdate('Y-m-d') . '</dc:date>' . "\n" . '		<dc:format>text/html</dc:format>' . "\n";
 if (isset($item['language']) && $item['language'] && $item['language'] != 'none') {
     $text .= '		<dc:language>' . $item['language'] . '</dc:language>' . "\n";
 }
 $text .= '	</rdf:Description>' . "\n" . '</rdf:RDF>';
 //
 // transfer to the user agent
 //
 // handle the output correctly
 render_raw('text/xml; charset=' . $context['charset']);
 // suggest a name on download
 if (!headers_sent()) {
     $file_name = utf8::to_ascii(Skin::strip($context['page_title']) . '.opml.xml');
     Safe::header('Content-Disposition: inline; filename="' . str_replace('"', '', $file_name) . '"');
 }
 // enable 30-minute caching (30*60 = 1800), even through https, to help IE6 on download
 http::expire(1800);
 // strong validator
 $etag = '"' . md5($text) . '"';
 // manage web cache
 if (http::validate(NULL, $etag)) {
     return;
 }
 // actual transmission except on a HEAD request
 if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
     echo $text;
 }
 // the post-processing hook, then exit
 /**
  * list categories
  *
  * @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 plain text
     $text = '';
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // one box per category
         $box['title'] = '';
         $box['text'] = '';
         // use the title to label the link
         $box['title'] = Skin::strip($item['title'], 50);
         // list related categories, if any
         if ($items = Categories::list_by_date_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE, 'compact')) {
             foreach ($items as $url => $label) {
                 if (is_array($label)) {
                     $label = $label[1];
                 }
                 $box['text'] .= '<li>' . Skin::build_link($url, $label, 'category') . '</li>' . "\n";
             }
         }
         // info on related sections
         $items =& Members::list_sections_by_title_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE);
         if ($items) {
             foreach ($items as $url => $label) {
                 if (is_array($label)) {
                     $label = $label[1];
                 }
                 $box['text'] .= '<li>' . Skin::build_link($url, $label, 'section') . '</li>' . "\n";
             }
         }
         // info on related articles
         if (isset($item['options']) && preg_match('/\\barticles_by_title\\b/i', $item['options'])) {
             $items =& Members::list_articles_by_title_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE);
         } else {
             $items =& Members::list_articles_by_date_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE);
         }
         if ($items) {
             foreach ($items as $url => $label) {
                 if (is_array($label)) {
                     $label = $label[1];
                 }
                 $box['text'] .= '<li>' . Skin::build_link($url, $label, 'article') . '</li>' . "\n";
             }
         }
         // info on related files
         if (isset($item['options']) && preg_match('/\\bfiles_by_title\\b/i', $item['options'])) {
             $items = Files::list_by_title_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE, 'category:' . $item['id']);
         } else {
             $items = Files::list_by_date_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE, 'category:' . $item['id']);
         }
         if ($items) {
             foreach ($items as $url => $label) {
                 if (is_array($label)) {
                     $label = $label[1];
                 }
                 $box['text'] .= '<li>' . Skin::build_link($url, $label, 'file') . '</li>' . "\n";
             }
         }
         // info on related comments
         include_once $context['path_to_root'] . 'comments/comments.php';
         if ($items = Comments::list_by_date_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE, 'compact')) {
             foreach ($items as $url => $label) {
                 if (is_array($label)) {
                     $label = $label[1];
                 }
                 $box['text'] .= '<li>' . Skin::build_link($url, $label, 'comment') . '</li>' . "\n";
             }
         }
         // info on related links
         include_once $context['path_to_root'] . 'links/links.php';
         if (isset($item['options']) && preg_match('/\\blinks_by_title\\b/i', $item['options'])) {
             $items = Links::list_by_title_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE);
         } else {
             $items = Links::list_by_date_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE);
         }
         if ($items) {
             foreach ($items as $url => $label) {
                 if (is_array($label)) {
                     $label = $label[1];
                 }
                 $box['text'] .= '<li>' . Skin::build_link($url, $label) . '</li>' . "\n";
             }
         }
         // add a direct link to the category
         if (Surfer::is_associate()) {
             $box['title'] .= '&nbsp;' . Skin::build_link(Categories::get_permalink($item), MORE_IMG, 'basic');
         }
         // make a full list
         if ($box['text']) {
             $box['text'] = '<ul>' . $box['text'] . '</ul>' . "\n";
         }
         // always make a box, to let associates visit the category
         $text .= Skin::build_box($box['title'], $box['text']);
     }
     // end of processing
     SQL::free($result);
     return $text;
 }
Beispiel #16
0
 /**
  * list users
  *
  * @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;
     }
     // flag idle users
     $idle = gmstrftime('%Y-%m-%d %H:%M:%S', time() - 600);
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // one box at a time
         $box = '';
         // initialize variables
         $prefix = $suffix = $icon = '';
         // the url to view this item
         $url = Users::get_permalink($item);
         // flag profiles updated recently
         if ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // signal locked profiles
         if ($item['capability'] == '?') {
             $prefix .= EXPIRED_FLAG;
         }
         // item title
         if ($item['full_name']) {
             $title = ucfirst(Skin::strip($item['full_name'], 10));
             $hover = $item['nick_name'];
         } else {
             $title = ucfirst(Skin::strip($item['nick_name'], 10));
             $hover = $item['full_name'];
         }
         // show contact information
         if (Surfer::may_contact()) {
             $suffix .= Users::build_presence($item);
         }
         // the introduction
         if ($item['introduction']) {
             if (is_callable(array('codes', 'beautify'))) {
                 $suffix .= ' -&nbsp;' . Codes::beautify($item['introduction']);
             } else {
                 $suffix .= ' -&nbsp;' . $item['introduction'];
             }
         }
         // display all tags
         if ($item['tags']) {
             $suffix .= ' <span class="tags">' . Skin::build_tags($item['tags'], 'user:'******'id']) . '</span>';
         }
         // details
         $details = array();
         // capability
         if ($item['capability'] == 'A') {
             $details[] = i18n::s('Associate');
         } elseif ($item['capability'] == 'S') {
             $details[] = i18n::s('Subscriber');
         } else {
             $details[] = i18n::s('Member');
         }
         // creation date
         if ($item['create_date']) {
             $details[] = sprintf(i18n::s('registered %s'), Skin::build_date($item['create_date']));
         }
         // last login
         if ($this->layout_variant == 'dates') {
             if (isset($item['login_date']) && $item['login_date'] > NULL_DATE) {
                 $address = '';
                 if ($item['login_address']) {
                     $address = ' (' . $item['login_address'] . ')';
                 }
                 $details[] = sprintf(i18n::s('last login %s'), Skin::build_date($item['login_date']) . $address);
             } else {
                 $details[] = i18n::s('no login');
             }
         }
         // last post
         if ($this->layout_variant == 'dates') {
             if (isset($item['post_date']) && $item['post_date'] > NULL_DATE) {
                 $details[] = sprintf(i18n::s('last post %s'), Skin::build_date($item['post_date']));
             }
         }
         // posts
         if (intval($item['posts']) > 1) {
             $details[] = sprintf(i18n::s('%d posts'), intval($item['posts']));
         }
         if (count($details)) {
             if ($this->layout_variant == 'full') {
                 $suffix .= ' <span class="details">(' . implode(', ', $details) . ')</span>';
             } else {
                 $suffix .= ' <span class="details">' . implode(', ', $details) . '</span>';
             }
         }
         // flag idle users
         if (isset($item['click_date']) && $item['click_date'] < $idle) {
             $class = 'idle user';
         } else {
             $class = 'user';
         }
         // item summary
         $box .= $prefix . Skin::build_link($url, $title, 'user') . $suffix;
         // use the avatar, if any
         if (isset($item['avatar_url']) && isset($context['users_with_avatars']) && $context['users_with_avatars'] == 'Y') {
             $icon = $item['avatar_url'];
         }
         // layout this item
         if ($icon) {
             // build the complete HTML element
             $icon = '<img src="' . $icon . '" alt="" title="' . encode_field(strip_tags($title)) . '" />';
             // make it a clickable link
             $icon = Skin::build_link($url, $icon, 'basic');
             $list = array(array($box, $icon));
             $items[] = array($item['score'], Skin::finalize_list($list, 'decorated'));
             // put the item in a division
         } else {
             $items[] = array($item['score'], '<div style="margin: 0 0 1em 0">' . $box . '</div>');
         }
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Beispiel #17
0
 /**
  * format just one item
  *
  * @param array attributes of one item
  * @return array of ($url => array($prefix, $label, $suffix, ...))
  *
  * @see articles/edit.php
  **/
 function one(&$item)
 {
     global $context;
     // initialize variables
     $prefix = $suffix = $icon = '';
     // flag sections that are 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 restricted and private articles
     if ($item['active'] == 'N') {
         $prefix .= PRIVATE_FLAG;
     } elseif ($item['active'] == 'R') {
         $prefix .= RESTRICTED_FLAG;
     }
     // details
     $details = array();
     // info on related files
     if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
         $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'], TRUE)) {
         $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
     }
     // append details to the suffix
     if (count($details)) {
         $suffix .= "\n" . '<span class="details">(' . implode(', ', $details) . ')</span>';
     }
     // introduction
     if ($item['introduction']) {
         $suffix .= ' ' . Codes::beautify_introduction($item['introduction']);
     }
     // add a head list of related links
     $subs = array();
     // put the actual icon in the left column
     if (isset($item['thumbnail_url'])) {
         $icon = $item['thumbnail_url'];
     }
     // url to select this article
     $url = 'articles/edit.php?template=' . $item['id'];
     // use the title to label the link
     $label = Skin::strip($item['title'], 50);
     // list all components for this item
     $output = array($url => array($prefix, $label, $suffix, 'article', $icon, i18n::s('Select this model')));
     return $output;
 }
Beispiel #18
0
 /**
  * clean link label
  *
  * @param string link title, if any
  * @param string link URI
  * @param int maximum number of chars
  * @return string a cleaned label
  */
 public static function clean($title = '', $reference = '', $size = 100)
 {
     global $context;
     // use provided title
     $label = Skin::strip($title, $size);
     // or extract a label from the link itself
     if (!$label) {
         $label = basename($reference, '.htm');
         if (($position = strpos($label, '?')) > 0) {
             $label = substr($label, 0, $position);
         }
         $label = str_replace('_', ' ', str_replace('%20', ' ', $label));
         if (strlen($label) > $size) {
             $label = '...' . substr($label, -$size);
         }
     }
     // sanity check
     if (!$label) {
         $label = '...';
     }
     return $label;
 }
 /**
  * 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;
 }
Beispiel #20
0
 /**
  * get some introductory text from a section
  *
  * This function is used to introduce comments, or any sub-item related to an anchor.
  * Compared to the standard anchor implementation, this one adds the ability to handle overlay data.
  *
  * If there is some introductory text, it is used. Else the description text is used instead.
  * The number of words is capped in both cases.
  *
  * Also, the number of remaining words is provided.
  *
  * Following variants may be selected to adapt to various situations:
  * - 'basic' - strip every tag, we want almost plain ASCII - maybe this will be send in a mail message
  * - 'hover' - some text to be displayed while hovering a link
  * - 'quote' - transform YACS codes, then strip most HTML tags
  * - 'teaser' - limit the number of words, tranform YACS codes, and link to permalink
  *
  * @see shared/anchor.php
  *
  * @param string an optional variant
  * @return NULL, of some text
  */
 function &get_teaser($variant = 'basic')
 {
     global $context;
     // nothing to do
     if (!isset($this->item['id'])) {
         $text = NULL;
         return $text;
     }
     // the text to be returned
     $text = '';
     // use the introduction field, if any
     if ($this->item['introduction']) {
         $text = trim($this->item['introduction']);
         // may be rendered as an empty strings
         if ($variant != 'hover') {
             // remove toc and toq codes
             $text = preg_replace(FORBIDDEN_IN_TEASERS, '', $text);
             // render all codes
             if (is_callable(array('Codes', 'beautify'))) {
                 $text =& Codes::beautify($text, $this->item['options']);
             }
         }
         // remove most html
         if ($variant != 'teaser') {
             $text = xml::strip_visible_tags($text);
         }
         // combine with description
         if ($variant == 'quote') {
             $text .= BR . BR;
         }
     }
     // use overlay data, if any
     if (!$text) {
         $overlay = Overlay::load($this->item, 'section:' . $this->item['id']);
         if (is_object($overlay)) {
             $text .= $overlay->get_text('list', $this->item);
         }
     }
     // use the description field, if any
     $in_description = FALSE;
     if (!$text && $variant != 'hover' || $variant == 'quote') {
         $text .= trim($this->item['description']);
         $in_description = TRUE;
         // remove toc and toq codes
         $text = preg_replace(FORBIDDEN_IN_TEASERS, '', $text);
         // render all codes
         if (is_callable(array('Codes', 'beautify'))) {
             $text =& Codes::beautify($text, $this->item['options']);
         }
         // remove most html
         $text = xml::strip_visible_tags($text);
     }
     // turn html entities to unicode entities
     $text =& utf8::transcode($text);
     // now we have to process the provided text
     switch ($variant) {
         // strip everything
         case 'basic':
         default:
             // remove most html
             $text = xml::strip_visible_tags($text);
             // limit the number of words
             $text =& Skin::cap($text, 70);
             // done
             return $text;
             // some text for pop-up panels
         // some text for pop-up panels
         case 'hover':
             // remove most html
             $text = xml::strip_visible_tags($text);
             // limit the number of words
             $text =& Skin::strip($text, 70);
             // ensure we have some text
             if (!$text) {
                 $text = i18n::s('View the page');
             }
             // mention shortcut to section
             if (Surfer::is_associate()) {
                 $text .= ' [section=' . $this->item['id'] . ']';
             }
             // done
             return $text;
             // quote this
         // quote this
         case 'quote':
             // remove most html
             $text = xml::strip_visible_tags($text);
             // limit the number of words
             $text =& Skin::cap($text, 300);
             // done
             return $text;
             // preserve as much as possible
         // preserve as much as possible
         case 'teaser':
             // limit the number of words
             $text =& Skin::cap($text, 12, $this->get_url());
             // done
             return $text;
     }
 }
Beispiel #21
0
 /**
  * get some introductory text from an article
  *
  * This function is used to introduce comments, or any sub-item related to an anchor.
  * Compared to the standard anchor implementation, this one adds the ability to handle overlay data.
  *
  * If there is some introductory text, it is used. Else the description text is used instead.
  * The number of words is capped in both cases.
  *
  * Also, the number of remaining words is provided.
  *
  * Following variants may be selected to adapt to various situations:
  * - 'basic' - strip every tag, we want almost plain ASCII - maybe this will be send in a mail message
  * - 'hover' - some text to be displayed while hovering a link
  * - 'quote' - strip most HTML tags
  * - 'teaser' - limit the number of words, tranform YACS codes, and link to permalink
  *
  * @see shared/anchor.php
  *
  * @param string an optional variant, including
  * @return NULL, of some text
  */
 function &get_teaser($variant = 'basic')
 {
     global $context;
     // no item bound
     if (!isset($this->item['id'])) {
         $text = NULL;
         return $text;
     }
     // the text to be returned
     $text = '';
     // use the introduction field, if any
     if ($this->item['introduction']) {
         $text = trim($this->item['introduction']);
         // may be rendered as an empty strings
         if ($variant != 'hover') {
             // remove toc and toq codes
             $text = preg_replace(FORBIDDEN_IN_TEASERS, '', $text);
             // render all codes
             if (is_callable(array('Codes', 'beautify'))) {
                 $text = Codes::beautify($text, $this->item['options']);
             }
         }
         // combine with description
         if ($variant == 'quote') {
             $text .= BR . BR;
         }
     }
     // use overlay data, if any
     if (!$text) {
         if (!isset($this->overlay) && isset($this->item['overlay'])) {
             $this->overlay = Overlay::load($this->item, 'article:' . $this->item['id']);
         }
         if (is_object($this->overlay)) {
             $text .= $this->overlay->get_text('list', $this->item);
         }
     }
     // use the description field, if any
     $in_description = FALSE;
     if (!$text && $variant != 'hover') {
         $text .= trim($this->item['description']);
         $in_description = TRUE;
         // remove toc and toq codes
         $text = preg_replace(FORBIDDEN_IN_TEASERS, '', $text);
         // render all codes
         if ($variant == 'teaser' && is_callable(array('Codes', 'beautify'))) {
             $text = Codes::beautify($text, $this->item['options']);
         }
     }
     // turn html entities to unicode entities
     $text = utf8::transcode($text);
     // now we have to process the provided text
     switch ($variant) {
         // strip everything
         case 'basic':
         default:
             // strip every HTML and limit the size
             if (is_callable(array('Skin', 'strip'))) {
                 $text = Skin::strip($text, 70, NULL, '');
             }
             // done
             return $text;
             // some text for pop-up panels
         // some text for pop-up panels
         case 'hover':
             // strip every HTML and limit the size
             if (is_callable(array('Skin', 'strip'))) {
                 $text = Skin::strip($text, 70, NULL, '');
             }
             // ensure we have some text
             if (!$text) {
                 $text = i18n::s('View the page');
             }
             // mention shortcut to article
             if (Surfer::is_associate()) {
                 $text .= ' [article=' . $this->item['id'] . ']';
             }
             // done
             return $text;
             // quote this
         // quote this
         case 'quote':
             // strip every HTML and limit the size
             if (is_callable(array('Skin', 'strip'))) {
                 $text = Skin::strip($text, 300, NULL, '<a><b><br><i><img><strong><u>');
             }
             // done
             return $text;
             // preserve as much as possible
         // preserve as much as possible
         case 'teaser':
             // lower level of titles
             $text = str_replace(array('<h4', '</h4'), array('<h5', '</h5'), $text);
             $text = str_replace(array('<h3', '</h3'), array('<h4', '</h4'), $text);
             $text = str_replace(array('<h2', '</h2'), array('<h3', '</h3'), $text);
             // limit the number of words
             if (is_callable(array('Skin', 'cap'))) {
                 $text = Skin::cap($text, WORDS_IN_TEASER, $this->get_url());
             }
             // done
             return $text;
     }
 }
Beispiel #22
0
 /**
  * list categories
  *
  * @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
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // url to read the full category
         $url = Categories::get_permalink($item);
         // initialize variables
         $prefix = $suffix = $icon = '';
         // flag categories 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 restricted and private categories
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // use the title to label the link
         $label = Skin::strip($item['title'], 10);
         // details
         $details = array();
         // info on related categories
         $stats = Categories::stat_for_anchor('category:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d category', '%d categories', $stats['count']), $stats['count']);
         }
         // info on related sections
         if ($count = Members::count_sections_for_anchor('category:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
         }
         // info on related articles
         if ($count = Members::count_articles_for_anchor('category:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
         }
         // info on related files
         if ($count = Files::count_for_anchor('category:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
         }
         // info on related links
         if ($count = Links::count_for_anchor('category:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
         }
         // info on related comments
         if ($count = Comments::count_for_anchor('category:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
         }
         // info on related users
         if ($count = Members::count_users_for_anchor('category:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d user', '%d users', $count), $count);
         }
         // append details to the suffix
         if (count($details)) {
             $suffix .= "\n" . '<span class="details">(' . implode(', ', $details) . ')</span>';
         }
         // introduction
         if ($item['introduction']) {
             $suffix .= ' ' . Codes::beautify(trim($item['introduction']));
         }
         // put the actual icon in the left column
         if (isset($item['thumbnail_url']) && $this->layout_variant != 'sidebar') {
             $icon = $item['thumbnail_url'];
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'category', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Beispiel #23
0
    // see also
    $lines = array();
    $lines[] = Skin::build_link('categories/', i18n::s('Categories'));
    $lines[] = Skin::build_link('search.php', i18n::s('Search'));
    $lines[] = Skin::build_link('help/', i18n::s('Help index'));
    $lines[] = Skin::build_link('query.php', i18n::s('Contact'));
    $text .= Skin::build_box(i18n::s('See also'), Skin::finalize_list($lines, 'compact'), 'boxes');
    // list monthly publications in an extra box
    $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($anchor['title'], Skin::build_list($items, 'compact'), 'boxes') . "\n";
    }
    // side boxes for related categories, if any
    if ($categories = Categories::list_by_date_for_display('section:index', 0, 7, 'raw')) {
        foreach ($categories as $id => $attributes) {
            // link to the category page from the box title
            $label =& Skin::build_box_title(Skin::strip($attributes['title']), Categories::get_permalink($attributes), i18n::s('View the category'));
            // box content
            if ($items =& Members::list_articles_by_date_for_anchor('category:' . $id, 0, COMPACT_LIST_SIZE, 'compact')) {
                $text .= Skin::build_box($label, Skin::build_list($items, 'compact'), 'boxes') . "\n";
            }
        }
    }
    // save, whatever change, for 5 minutes
    Cache::put($cache_id, $text, 'stable', 300);
}
$context['components']['boxes'] = $text;
// referrals, if any
$context['components']['referrals'] = Skin::build_referrals('sections/index.php');
// render the skin
render_skin();
Beispiel #24
0
 /**
  * list locations
  *
  * Recognize following variants:
  * - 'no_anchor' to list items attached to one particular anchor
  * - 'no_author' to list items attached to one user prolocation
  *
  * @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)) {
         // initialize variables
         $prefix = $suffix = $icon = '';
         // the url to view this item
         $url = Locations::get_url($item['id']);
         // build a valid label
         if ($item['geo_place_name']) {
             $label = Skin::strip($item['geo_place_name'], 10);
         } else {
             $label = $item['latitude'] . ', ' . $item['longitude'];
         }
         // description
         if ($item['description']) {
             $suffix .= ' ' . ucfirst(trim($item['description']));
         }
         // the menu bar for associates and poster
         if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) {
             $menu = array(Locations::get_url($item['id'], 'edit') => i18n::s('Edit'), Locations::get_url($item['id'], 'delete') => i18n::s('Delete'));
             $suffix .= ' ' . Skin::build_list($menu, 'menu');
         }
         // add a separator
         if ($suffix) {
             $suffix = ' - ' . $suffix;
         }
         // append details to the suffix
         $suffix .= BR . '<span class="details">';
         // details
         $details = array();
         // item poster
         if (isset($this->layout_variant) && $this->layout_variant != 'no_author') {
             if ($item['edit_name']) {
                 $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
             }
         } else {
             $details[] = Anchors::get_action_label($item['edit_action']);
         }
         // show an anchor location
         if (isset($this->layout_variant) && $this->layout_variant != 'no_anchor' && $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'));
         }
         // all details
         if (count($details)) {
             $suffix .= ucfirst(implode(', ', $details)) . "\n";
         }
         // end of details
         $suffix .= '</span>';
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'location', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
 /**
  * list categories
  *
  * @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
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // url to read the full category
         $url = Categories::get_permalink($item);
         // initialize variables
         $prefix = $suffix = $icon = '';
         // flag categories 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 restricted and private categories
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // introduction
         if ($item['introduction']) {
             $suffix .= ' ' . Codes::beautify(trim($item['introduction']));
         }
         // details
         $details = array();
         // count related sub-elements
         $related_count = 0;
         // info on related categories
         $stats = Categories::stat_for_anchor('category:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d category', '%d categories', $stats['count']), $stats['count']);
         }
         $related_count += $stats['count'];
         // info on related sections
         if ($count = Members::count_sections_for_anchor('category:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
             $related_count += $count;
         }
         // info on related articles
         if ($count = Members::count_articles_for_anchor('category:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
             $related_count += $count;
         }
         // info on related files
         if ($count = Files::count_for_anchor('category:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
             $related_count += $count;
         }
         // info on related links
         if ($count = Links::count_for_anchor('category:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
             $related_count += $count;
         }
         // info on related comments
         if ($count = Comments::count_for_anchor('category:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
             $related_count += $stats['count'];
         }
         // info on related users
         if ($count = Members::count_users_for_anchor('category:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d user', '%d users', $count), $count);
         }
         // append details to the suffix
         if (count($details)) {
             $suffix .= "\n" . '<span class="details">(' . implode(', ', $details) . ')</span>';
         }
         // add a head list of related links
         $details = array();
         // add sub-categories on index pages
         if ($related = Categories::list_by_date_for_anchor('category:' . $item['id'], 0, YAHOO_LIST_SIZE, 'compact')) {
             foreach ($related as $sub_url => $label) {
                 $sub_prefix = $sub_suffix = $sub_hover = '';
                 if (is_array($label)) {
                     $sub_prefix = $label[0];
                     $sub_suffix = $label[2];
                     if (@$label[5]) {
                         $sub_hover = $label[5];
                     }
                     $label = $label[1];
                 }
                 $details[] = $sub_prefix . Skin::build_link($sub_url, $label, 'basic', $sub_hover) . $sub_suffix;
             }
         }
         // add related sections if necessary
         if (count($details) < YAHOO_LIST_SIZE && ($related =& Members::list_sections_by_title_for_anchor('category:' . $item['id'], 0, YAHOO_LIST_SIZE - count($details), 'compact'))) {
             foreach ($related as $sub_url => $label) {
                 $sub_prefix = $sub_suffix = $sub_hover = '';
                 if (is_array($label)) {
                     $sub_prefix = $label[0];
                     $sub_suffix = $label[2];
                     if (@$label[5]) {
                         $sub_hover = $label[5];
                     }
                     $label = $label[1];
                 }
                 $details[] = $sub_prefix . Skin::build_link($sub_url, $label, 'basic', $sub_hover) . $sub_suffix;
             }
         }
         // add related articles if necessary
         if (count($details) < YAHOO_LIST_SIZE && ($related =& Members::list_articles_by_date_for_anchor('category:' . $item['id'], 0, YAHOO_LIST_SIZE - count($details), 'compact'))) {
             foreach ($related as $sub_url => $label) {
                 $sub_prefix = $sub_suffix = $sub_hover = '';
                 if (is_array($label)) {
                     $sub_prefix = $label[0];
                     $sub_suffix = $label[2];
                     if (@$label[5]) {
                         $sub_hover = $label[5];
                     }
                     $label = $label[1];
                 }
                 $details[] = $sub_prefix . Skin::build_link($sub_url, $label, 'basic', $sub_hover) . $sub_suffix;
             }
         }
         // give me more
         if (count($details) && $related_count > YAHOO_LIST_SIZE) {
             $details[] = Skin::build_link(Categories::get_permalink($item), i18n::s('More') . MORE_IMG, 'more', i18n::s('View the category'));
         }
         // layout details
         if (count($details)) {
             $suffix .= BR . "\n&raquo;&nbsp;" . '<span class="details">' . implode(', ', $details) . "</span>\n";
         }
         // put the actual icon in the left column
         if (isset($item['thumbnail_url'])) {
             $icon = $item['thumbnail_url'];
         }
         // use the title to label the link
         $label = Skin::strip($item['title'], 50);
         // some hovering title for this category
         $hover = i18n::s('View the category');
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'category', $icon, $hover);
     }
     // end of processing
     SQL::free($result);
     $output = Skin::build_list($items, '2-columns');
     return $output;
 }
Beispiel #26
0
 /**
  * list sections
  *
  * @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 (!($delta = SQL::count($result))) {
         return $text;
     }
     // process all items in the list
     $count = 0;
     $items = array();
     while ($item = SQL::fetch($result)) {
         // the url to view this item
         $url = Sections::get_permalink($item);
         // initialize variables
         $prefix = $label = $suffix = '';
         // flag sections that are draft or dead
         if ($item['activation_date'] >= $context['now']) {
             $prefix .= DRAFT_FLAG;
         } elseif ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $prefix .= EXPIRED_FLAG;
         }
         // signal restricted and private sections
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // flag items updated recently
         if ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         //			// start the label with family, if any
         //			if($item['family'])
         //				$label = ucfirst(Skin::strip($item['family'], 30)).' - ';
         // use the title to label the link
         $label .= ucfirst(Skin::strip($item['title'], 30));
         // 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 section');
         }
         // help members to reference this page
         if (Surfer::is_member()) {
             $hover .= ' [section=' . $item['id'] . ']';
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'basic', NULL, $hover);
         // limit to one page of results
         if (++$count >= COMPACT_LIST_SIZE - 1) {
             break;
         }
     }
     // end of processing
     SQL::free($result);
     // turn this to some text
     $text .= Skin::build_list($items, 'comma');
     // some indications on the number of connections
     if (($delta -= $count) > 0) {
         $text .= ', ...';
     }
     return $text;
 }
Beispiel #27
0
 /** 
  * render a sound object with dewplayer
  * 
  * @global type $context
  * @param type $id
  * @return string 
  */
 public static function render_sound($id)
 {
     global $context;
     // maybe an alternate title has been provided
     $attributes = preg_split("/\\s*,\\s*/", $id, 2);
     $id = $attributes[0];
     $flashvars = '';
     if (isset($attributes[1])) {
         $flashvars = $attributes[1];
     }
     // get the file
     if (!($item = Files::get($id))) {
         $output = '[sound=' . $id . ']';
         return $output;
     }
     // where to get the file
     if (isset($item['file_href']) && $item['file_href']) {
         $url = $item['file_href'];
     } else {
         $url = $context['url_to_home'] . $context['url_to_root'] . 'files/' . str_replace(':', '/', $item['anchor']) . '/' . rawurlencode($item['file_name']);
     }
     // several ways to play flash
     switch (strtolower(substr(strrchr($url, '.'), 1))) {
         // stream a sound file
         case 'mp3':
             // a flash player to stream a sound
             $dewplayer_url = $context['url_to_root'] . 'included/browser/dewplayer.swf';
             if ($flashvars) {
                 $flashvars = 'son=' . $url . '&' . $flashvars;
             } else {
                 $flashvars = 'son=' . $url;
             }
             $output = '<div id="sound_' . $item['id'] . '" class="no_print">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n";
             Page::insert_script('var params = {};' . "\n" . 'params.base = "' . dirname($url) . '/";' . "\n" . 'params.quality = "high";' . "\n" . 'params.wmode = "transparent";' . "\n" . 'params.menu = "false";' . "\n" . 'params.flashvars = "' . $flashvars . '";' . "\n" . 'swfobject.embedSWF("' . $dewplayer_url . '", "sound_' . $item['id'] . '", "200", "20", "6", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", false, params);' . "\n");
             return $output;
             // link to file page
         // link to file page
         default:
             // link label
             $text = Skin::strip($item['title'] ? $item['title'] : str_replace('_', ' ', $item['file_name']));
             // make a link to the target page
             $url = Files::get_download_url($item);
             // return a complete anchor
             $output =& Skin::build_link($url, $text, 'basic');
             return $output;
     }
 }
Beispiel #28
0
 $text = '<?xml version="1.0" encoding="' . $context['charset'] . '"?>' . "\n" . '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"' . "\n" . '		   xmlns:dc="http://purl.org/dc/elements/1.1/"' . "\n" . '		   xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">' . "\n" . '	<rdf:Description' . "\n" . '		trackback:ping="' . $trackback_link . '"' . "\n" . '		dc:identifier="' . $permanent_link . '"' . "\n" . '		rdf:about="' . $permanent_link . '">' . "\n" . '		<dc:title>' . encode_field($item['title']) . '</dc:title>' . "\n" . '		<dc:description>' . encode_field(Skin::strip($description)) . '</dc:description>' . "\n" . '		<dc:creator>' . $item['create_name'] . '</dc:creator>' . "\n" . '		<dc:date>' . gmdate('Y-m-d') . '</dc:date>' . "\n" . '		<dc:format>text/html</dc:format>' . "\n";
 if (isset($item['language']) && $item['language'] && $item['language'] != 'none') {
     $text .= '		<dc:language>' . $item['language'] . '</dc:language>' . "\n";
 }
 if (is_object($anchor)) {
     $text .= '	<dc:subject>' . encode_field($anchor->get_title()) . '</dc:subject>' . "\n";
 }
 $text .= '	</rdf:Description>' . "\n" . '</rdf:RDF>';
 //
 // transfer to the user agent
 //
 // handle the output correctly
 render_raw('text/xml; charset=' . $context['charset']);
 // suggest a name on download
 if (!headers_sent()) {
     $file_name = Skin::strip($context['page_title']) . '.opml.xml';
     $file_name =& utf8::to_ascii($file_name);
     Safe::header('Content-Disposition: inline; filename="' . str_replace('"', '', $file_name) . '"');
 }
 // enable 30-minute caching (30*60 = 1800), even through https, to help IE6 on download
 http::expire(1800);
 // strong validator
 $etag = '"' . md5($text) . '"';
 // manage web cache
 if (http::validate(NULL, $etag)) {
     return;
 }
 // actual transmission except on a HEAD request
 if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
     echo $text;
 }
Beispiel #29
0
 $categories =& Members::list_categories_by_title_for_member($member, 0, CATEGORIES_LIST_SIZE, 'raw');
 // the form to link additional categories
 if (!is_array($categories) || count($categories) < CATEGORIES_LIST_SIZE) {
     $context['text'] .= '<form method="post" action="' . $context['script_url'] . '"><div style="margin-bottom: 2em;">' . i18n::s('Select a category') . ' <select name="anchor">' . Categories::get_options($categories) . '</select>' . ' ' . Skin::build_submit_button(i18n::s('Categorize')) . '<input type="hidden" name="member" value="' . encode_field($member) . '">' . '</div></form>' . "\n";
 }
 // the current list of linked categories
 if (count($categories)) {
     // display attached categories with unlink buttons
     $context['text'] .= '<p>' . i18n::s('All categories that have been associated to this page:') . '</p>';
     // browse the list
     foreach ($categories as $category_id => $attributes) {
         // make an url
         $url = Categories::get_permalink($attributes);
         // gather information on this category
         $prefix = $suffix = $type = $icon = '';
         $label = Skin::strip($attributes['title']);
         // add background color to distinguish this category against others
         if (isset($attributes['background_color']) && $attributes['background_color']) {
             $label = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $label . '</span>';
         }
         // build a unlink button for this category
         if (Surfer::is_associate()) {
             $suffix .= BR . '<form method="post" action="' . $context['script_url'] . '"><div>' . '<input type="hidden" name="anchor" value="category:' . $category_id . '" />' . '<input type="hidden" name="member" value="' . encode_field($member) . '" />' . Skin::build_submit_button(i18n::s('Unlink')) . '</div></form>';
         }
         // a button to change the thumbnail of the anchored page
         if ($icon) {
             $suffix .= ' <form method="post" action="' . $context['url_to_root'] . 'categories/set_as_thumbnail.php"><div>' . '<input type="hidden" name="anchor" value="' . encode_field($member) . '" />' . '<input type="hidden" name="id" value="' . $category_id . '" />' . Skin::build_submit_button(i18n::s('Use this thumbnail as the thumbnail of the page')) . '</div></form>';
         }
         // list sub-categories to be linked, if any
         // display active and restricted items
         $where = "categories.active='Y'";
Beispiel #30
0
 /**
  * get options recursively
  *
  * This function is called internally by Sections::get_options(), above.
  *
  * @param string the current anchor to an existing section (e.g., 'section:12')
  * @param string spaces to prepend before section name -- to reflect depth
  * @param string the reference of the default section
  * @param array list of sections made of $id => $attributes
  * @return the HTML to insert in the page
  *
  */
 public static function get_options_for_anchor($anchor, $spaces, $default, $to_avoid)
 {
     global $context;
     // add to text
     $text = '';
     // list sections at this level
     if ($sections = Sections::list_by_title_for_anchor($anchor, 0, 1000, 'raw')) {
         foreach ($sections as $id => $attributes) {
             if (Sections::match($id, $to_avoid)) {
                 continue;
             }
             // this section
             $reference = 'section:' . $id;
             $text .= '<option value="' . $reference . '"';
             // the section is locked
             if (isset($attributes['locked']) && $attributes['locked'] == 'Y' && !Surfer::is_associate()) {
                 $text .= ' style="font-style: italic;" disabled="disabled"';
             }
             // currently selected
             if ($default && $default == $reference) {
                 $text .= ' selected="selected"';
             }
             $text .= '>' . $spaces . Skin::strip($attributes['title']) . "</option>\n";
             // depending sections, if any
             if ($to_avoid == 'no_subsections') {
             } elseif ($depending = Sections::get_options_for_anchor($reference, $spaces . '&nbsp;&nbsp;', $default, $to_avoid)) {
                 $text .= $depending;
             }
         }
     }
     // associates can also access inactive sections at this level
     if ($anchor && Surfer::is_associate()) {
         if ($sections = Sections::list_inactive_by_title_for_anchor($anchor, 0, 100, 'raw')) {
             foreach ($sections as $id => $attributes) {
                 if (Sections::match($id, $to_avoid)) {
                     continue;
                 }
                 // this section
                 $reference = 'section:' . $id;
                 $text .= '<option value="' . $reference . '"';
                 if ($default && $default == $reference) {
                     $text .= ' selected="selected"';
                 }
                 $text .= '>' . $spaces . Skin::strip($attributes['title']) . "</option>\n";
                 // depending sections, if any
                 if ($depending = Sections::get_options_for_anchor($reference, $spaces . '&nbsp;&nbsp;', $default, $to_avoid)) {
                     $text .= $depending;
                 }
             }
         }
     }
     // end of job
     return $text;
 }