コード例 #1
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);
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'server', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
コード例 #2
0
 /**
  * list users
  *
  * @param resource the SQL result
  * @return array of ($nick_name => $more)
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of ($nick_name => $more)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // unique identifier
         $key = $item['nick_name'];
         // use the full name, if nick name is not part of it
         $more = '';
         if ($item['full_name'] && !preg_match('/\\b' . preg_quote($item['nick_name'], '/') . '\\b/', $item['full_name'])) {
             $more = ucfirst($item['full_name']) . ' ';
         }
         // else use e-mail address, if any --but only to authenticated surfer
         if ($item['email'] && Surfer::is_logged()) {
             if ($more) {
                 $more .= '<' . $item['email'] . '>';
             } else {
                 $more .= $item['email'];
             }
         } elseif ($item['introduction']) {
             $more .= $item['introduction'];
         }
         // record this item
         $items[$key] = $more;
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
コード例 #3
0
 /**
  * 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;
 }
コード例 #4
0
ファイル: layout_links_as_compact.php プロジェクト: rair/yacs
 /**
  * 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)) {
         // url is the link itself
         $url = $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'], 30);
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
コード例 #5
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;
 }
コード例 #6
0
 /**
  * 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;
 }
コード例 #7
0
ファイル: layout_users_as_address.php プロジェクト: rair/yacs
 /**
  * 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)) {
         // we need some address
         if (!$item['email']) {
             continue;
         }
         // do not write to myself
         // 			if($item['id'] == Surfer::get_id())
         // 				continue;
         $label = ucfirst(trim(Codes::beautify(strip_tags($item['full_name'], '<br><div><img><p><span>'))));
         if (!$label) {
             $label = ucfirst($item['nick_name']);
         }
         // one entry per address
         $items[trim($item['email'])] = $label;
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
コード例 #8
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;
 }
コード例 #9
0
ファイル: layout_versions.php プロジェクト: rair/yacs
 /**
  * list versions
  *
  * @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 = '_' . $item['id'];
         // Versions::get_url($item['id']);
         // version description
         $label = sprintf(i18n::s('edited by %s %s'), ucfirst($item['edit_name']), Skin::build_date($item['edit_date']));
         // command to view this version
         $suffix .= ' ' . Skin::build_link(Versions::get_url($item['id'], 'view'), i18n::s('compare to current version'), 'button');
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'version', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
コード例 #10
0
ファイル: layout_links_as_simple.php プロジェクト: rair/yacs
 /**
  * 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('&', '&amp;', $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;
 }
コード例 #11
0
 /**
  * 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 some text
     $text = '';
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // we want to make it visual
         if (!$item['thumbnail_url']) {
             continue;
         }
         // a title for the image --do not force a title
         if (isset($item['title'])) {
             $title = $item['title'];
         } else {
             $title = '';
         }
         // the url to view this item
         $url = Sections::get_permalink($item);
         // use the skin to shape it
         $text .= Skin::build_image('thumbnail', $item['thumbnail_url'], $title, $url);
     }
     // end of processing
     SQL::free($result);
     return $text;
 }
コード例 #12
0
ファイル: layout_users_as_comma5.php プロジェクト: rair/yacs
 /**
  * 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;
 }
コード例 #13
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;
     }
     // clear flows
     $text .= '<br style="clear: left" />';
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the related overlay
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // 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');
         }
         // title is a link to the target article
         $title =& Skin::build_link($url, $title, 'basic', $hover);
         // use the thumbnail for this article
         if ($icon = trim($item['thumbnail_url'])) {
             // fix relative path
             if (!preg_match('/^(\\/|http:|https:|ftp:)/', $icon)) {
                 $icon = $context['url_to_root'] . $icon;
             }
             // use parameter of the control panel for this one
             $options = '';
             if (isset($context['classes_for_thumbnail_images'])) {
                 $options = 'class="' . $context['classes_for_thumbnail_images'] . '" ';
             }
             // build the complete HTML element
             $icon = '<img src="' . $icon . '" alt="" title="' . encode_field($hover) . '" ' . $options . ' />';
             // use default icon if nothing to display
         } else {
             $icon = MAP_IMG;
         }
         // use the image as a link to the target page
         $icon =& Skin::build_link($url, $icon, 'basic', $hover);
         // add a floating box
         $text .= Skin::build_box($title, $icon, 'floating');
     }
     // clear flows
     $text .= '<br style="clear: left" />';
     // end of processing
     SQL::free($result);
     return $text;
 }
コード例 #14
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;
     }
     // process all items in the list
     $items = array();
     $total = 0;
     $minimum = 10000;
     $maximum = 0;
     while ($item = SQL::fetch($result)) {
         // this will be sorted alphabetically
         $items[$item['title']] = array('importance' => (int) $item['importance'], 'href' => Categories::get_permalink($item));
         // assess the scope
         if ($minimum > (int) $item['importance']) {
             $minimum = (int) $item['importance'];
         }
         if ($maximum < (int) $item['importance']) {
             $maximum = (int) $item['importance'];
         }
     }
     // end of processing
     SQL::free($result);
     // sort the array alphabetically
     ksort($items);
     // scale items
     $text = '';
     foreach ($items as $title => $item) {
         switch ((string) ceil((1 + $item['importance'] - $minimum) * 6 / (1 + $maximum - $minimum))) {
             default:
             case 1:
                 $item['style'] = 'font-size: 0.8em';
                 break;
             case 2:
                 $item['style'] = 'font-size: 0.9em';
                 break;
             case 3:
                 $item['style'] = 'font-size: 1.3em';
                 break;
             case 4:
                 $item['style'] = 'font-size: 1.5em';
                 break;
             case 5:
                 $item['style'] = 'font-size: 1.7em';
                 break;
             case 6:
                 $item['style'] = 'font-size: 2em';
                 break;
         }
         $text .= '<span style="' . $item['style'] . '">' . Skin::build_link($item['href'], $title, 'basic') . '</span> ';
     }
     // final packaging
     $text = '<p class="cloud">' . rtrim($text) . '</p>';
     // return by reference
     return $text;
 }
コード例 #15
0
ファイル: layout_servers.php プロジェクト: rair/yacs
 /**
  * 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;
 }
コード例 #16
0
ファイル: layout_images_as_feed.php プロジェクト: rair/yacs
 /**
  * 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;
 }
コード例 #17
0
 /**
  * list comments as successive notes in a thread
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // we return formatted text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // build a list of comments
     while ($item = SQL::fetch($result)) {
         // automatic notification
         if ($item['type'] == 'notification') {
             $text = '<dd class="thread_other" style="font-style: italic;">' . ucfirst(trim($item['description'])) . '</dd>' . $text;
         } else {
             // link to user profile -- open links in separate window to enable side browsing of participant profiles
             if ($item['create_id']) {
                 if ($user = Users::get($item['create_id']) && $user['full_name']) {
                     $hover = $user['full_name'];
                 } else {
                     $hover = NULL;
                 }
                 $author = Users::get_link($item['create_name'], $item['create_address'], $item['create_id'], TRUE, $hover);
             } else {
                 $author = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id'], TRUE);
             }
             // differentiate my posts from others
             if (Surfer::get_id() && $item['create_id'] == Surfer::get_id()) {
                 $style = ' class="thread_me"';
             } else {
                 $style = ' class="thread_other"';
             }
             // a clickable label
             $stamp = '#';
             // flag old items on same day
             if (!strncmp($item['edit_date'], gmstrftime('%Y-%m-%d %H:%M:%S', time()), 10)) {
                 $stamp = Skin::build_time($item['edit_date']);
             } else {
                 $stamp = Skin::build_date($item['edit_date']);
             }
             // append this at the end of the comment
             $stamp = ' <div style="float: right; font-size: x-small">' . Skin::build_link(Comments::get_url($item['id']), $stamp, 'basic', i18n::s('Edit')) . '</div>';
             // package everything --change order to get oldest first
             $text = '<dt' . $style . '>' . $author . '</dt><dd' . $style . '>' . $stamp . ucfirst(trim($item['description'])) . '</dd>' . $text;
         }
     }
     // end of processing
     SQL::free($result);
     // finalize the returned definition list
     if ($text) {
         $text = '<dl>' . $text . '</dl>';
     }
     // process yacs codes
     $text = Codes::beautify($text);
     return $text;
 }
コード例 #18
0
ファイル: visits.php プロジェクト: rair/yacs
 /**
  * list pages browsed by one user
  *
  * @param int id of the visiting user
  * @param int the maximum size of the returned list
  * @param int maximum age of visit, in seconds
  * @return array a compact list of links, or NULL
  */
 public static function list_for_user($user, $count = 3, $timeout = 259200)
 {
     global $context;
     // return by reference
     $output = NULL;
     // sanity check
     if (!$user) {
         return $output;
     }
     // only consider recent presence records
     $threshold = gmstrftime('%Y-%m-%d %H:%M:%S', time() - $timeout);
     // limit the scope of the request
     $where = "visits.active='Y'";
     if (Surfer::is_logged() || Surfer::is_teased()) {
         $where .= " OR visits.active='R'";
     }
     if (Surfer::is_associate() || Surfer::is_teased()) {
         $where .= " OR visits.active='N'";
     }
     // select matching links
     $query = "SELECT * FROM " . SQL::table_name('visits') . " AS visits" . " WHERE (visits.user_id = " . SQL::escape($user) . ")" . "\tAND (visits.edit_date >= '" . SQL::escape($threshold) . "')" . "\tAND (" . $where . ")" . " ORDER BY visits.edit_date DESC LIMIT " . $count;
     if (!($result = SQL::query($query))) {
         return $output;
     }
     // empty list
     if (!SQL::count($result)) {
         return $output;
     }
     // process all items in the list
     $output = array();
     while ($item = SQL::fetch($result)) {
         // identify the visited page
         if (!($anchor = Anchors::get($item['anchor']))) {
             continue;
         }
         // ensure this one is visible
         if (!$anchor->is_viewable()) {
             continue;
         }
         // url to the visited page
         $url = $anchor->get_url();
         // title of the visited page
         $label = $anchor->get_title();
         // list all components for this item
         $output[$url] = $label;
     }
     // end of processing
     SQL::free($result);
     return $output;
 }
コード例 #19
0
ファイル: layout_files_as_simple.php プロジェクト: rair/yacs
 /**
  * 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;
 }
コード例 #20
0
ファイル: layout_links_as_feed.php プロジェクト: rair/yacs
 /**
  * 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;
 }
コード例 #21
0
ファイル: layout_dates_as_compact.php プロジェクト: rair/yacs
 /**
  * list dates
  *
  * @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)) {
         // the url to use
         $url = Articles::get_permalink($item);
         // initialize variables
         $prefix = $suffix = $icon = '';
         // signal restricted and private dates/articles
         if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE) {
             $prefix .= DRAFT_FLAG;
         }
         // signal restricted and private dates/articles
         if (!isset($item['active'])) {
         } elseif ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // flag new dates/articles
         if ($item['edit_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         }
         // build a valid label
         if (isset($item['title'])) {
             $label = Codes::beautify_title($item['title']);
             if (isset($item['date_stamp'])) {
                 $label .= ' [' . Skin::build_date($item['date_stamp'], 'day') . ']';
             }
         } else {
             $label = Skin::build_date($item['date_stamp'], 'day');
         }
         // may have variant overlay for links
         $link_type = $this->has_variant('overlaid') ? 'overlaid' : 'basic';
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, $link_type, NULL, $item['date_stamp']);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
コード例 #22
0
 /**
  * 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;
     }
     // sanity check
     if (!isset($this->layout_variant)) {
         $this->layout_variant = 'articles/edit.php?anchor=section:';
     }
     // we return some text
     $text = '';
     // stack of items
     $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';
     $family = '';
     while ($item = SQL::fetch($result)) {
         // strip locked sections, except to associates and editors
         if (isset($item['locked']) && $item['locked'] == 'Y' && !Surfer::is_empowered()) {
             continue;
         }
         // change the family
         if ($item['family'] != $family) {
             // flush current stack, if any
             if (count($items)) {
                 $text .= Skin::build_list($items, '2-columns');
             }
             $items = array();
             // show the family
             $family = $item['family'];
             $text .= '<h3 class="family">' . $family . '</h3>' . "\n";
         }
         // format one item
         $items = array_merge($items, $this->one($item));
     }
     // flush the stack
     if (count($items)) {
         $text .= Skin::build_list($items, '2-columns');
     }
     // end of processing
     SQL::free($result);
     return $text;
 }
コード例 #23
0
ファイル: layout_users_as_ids.php プロジェクト: rair/yacs
 /**
  * list users
  *
  * @param resource the SQL result
  * @return array a bare list of item ids
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of ids
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // just remember the id
         $items[] = $item['id'];
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
コード例 #24
0
ファイル: layout_files_as_raw.php プロジェクト: rair/yacs
 /**
  * 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;
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // include all available attributes for this item
         $items[$item['id']] = $item;
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
コード例 #25
0
ファイル: layout_users_as_feed.php プロジェクト: rair/yacs
 /**
  * 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;
 }
コード例 #26
0
ファイル: layout_files_as_hits.php プロジェクト: rair/yacs
 /**
  * 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;
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // 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']));
         }
         // with hits
         if ($item['hits'] > 1) {
             $suffix .= ' <span class="details">- ' . Skin::build_number($item['hits'], i18n::s('downloads')) . '</span>';
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
コード例 #27
0
 /**
  * list sections
  *
  * @param resource the SQL result
  * @return an array of items
  *
  * @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'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         $items = array_merge($items, Layout_articles_as_select::one($item));
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
コード例 #28
0
ファイル: layout_sections_as_xml.php プロジェクト: rair/yacs
 /**
  * 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 (!SQL::count($result)) {
         return $text;
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the related overlay
         $overlay = Overlay::load($item, 'section:' . $item['id']);
         // more text
         $text .= Sections::to_xml($item, $overlay);
     }
     // end of processing
     SQL::free($result);
     return $text;
 }
コード例 #29
0
ファイル: layout_files_as_dates.php プロジェクト: rair/yacs
 /**
  * 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;
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // download the file directly
         $url = Files::get_url($item['id'], 'fetch', $item['file_name']);
         // file title or file name
         $label = Codes::beautify_title($item['title']);
         if (!$label) {
             $label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name']));
         }
         // initialize variables
         $prefix = $suffix = '';
         $contributor = Users::get_link($item['create_name'], $item['create_address'], $item['create_id']);
         $flag = '';
         if ($item['create_date'] >= $context['fresh']) {
             $flag = NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $flag = UPDATED_FLAG;
         }
         $suffix .= '<span class="details"> - ' . sprintf(i18n::s('By %s'), $contributor) . ' ' . Skin::build_date($item['create_date']) . $flag . '</span>';
         // signal restricted and private files
         if ($item['active'] == 'N' && defined('PRIVATE_FLAG')) {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R' && defined('RESTRICTED_FLAG')) {
             $prefix .= RESTRICTED_FLAG;
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'file', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
コード例 #30
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
     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;
 }