/** * 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; }
/** * list dates * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // build the calendar $text = 'BEGIN:VCALENDAR' . CRLF . 'VERSION:2.0' . CRLF . 'PRODID:YACS' . CRLF . 'METHOD:PUBLISH' . CRLF; // organization, if any if (isset($context['site_name']) && $context['site_name']) { $text .= 'X-WR-CALNAME:' . $context['site_name'] . CRLF; } // process all items in the list while ($item = SQL::fetch($result)) { // one event at a time $text .= 'BEGIN:VEVENT' . CRLF; // the event spans limited time if (isset($item['duration']) && $item['duration']) { $text .= 'DTSTART:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['date_stamp'])) . CRLF; $text .= 'DTEND:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['date_stamp']) + $item['duration'] * 60) . CRLF; // a full-day event } else { $text .= 'DTSTART;VALUE=DATE:' . date('Ymd', SQL::strtotime($item['date_stamp'])) . CRLF; $text .= 'DTEND;VALUE=DATE:' . date('Ymd', SQL::strtotime($item['date_stamp']) + 86400) . CRLF; } // url to view the date $text .= 'URL:' . Articles::get_permalink($item) . CRLF; // organization, if any if (isset($item['introduction']) && $item['introduction']) { $text .= 'DESCRIPTION:' . str_replace(array("\n", "\r"), ' ', strip_tags($item['introduction'])) . CRLF; } // build a valid title if (isset($item['title']) && $item['title']) { $text .= 'SUMMARY:' . Codes::beautify_title($item['title']) . CRLF; } // required by Outlook 2003 if (isset($item['id']) && $item['id']) { $text .= 'UID:' . $item['id'] . CRLF; } // date of creation if (isset($item['create_date']) && $item['create_date']) { $text .= 'CREATED:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['create_date'])) . CRLF; } // date of last modification if (isset($item['edit_date']) && $item['edit_date']) { $text .= 'DTSTAMP:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['edit_date'])) . CRLF; } // next event $text .= 'SEQUENCE:0' . CRLF . 'END:VEVENT' . CRLF; } // date of last update $text .= 'END:VCALENDAR' . CRLF; // end of processing SQL::free($result); return $text; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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)) { // play freemind maps and flash files in separate windows if (preg_match('/\\.(mm|swf)$/i', $item['file_name'])) { $url = Files::get_url($item['id'], 'stream', $item['file_name']); } else { $url = Files::get_url($item['id'], 'fetch', $item['file_name']); } // provide absolute links because these could be put in a mail $url = $context['url_to_home'] . $context['url_to_root'] . $url; // initialize variables $prefix = $suffix = ''; // 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'])); } // list all components for this item $items[$url] = array($prefix, $label, $suffix, 'basic', NULL); } // end of processing SQL::free($result); return $items; }
$context['text'] .= '<p style="margin-top: 2em;">' . sprintf(i18n::s('This is the list of sections assigned to %s'), $anchor->get_title()) . '</p>'; // layout assigned sections if ($sections) { // browse the list foreach ($sections as $id => $section) { // get the related overlay, if any $overlay = Overlay::load($section, 'section:' . $id); // get parent anchor $parent = Anchors::get($section['anchor']); // the url to view this item $url = Sections::get_permalink($section); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $section)); } else { $title = Codes::beautify_title($section['title']); } // initialize variables $prefix = $suffix = $icon = ''; // flag sticky pages if ($section['rank'] < 10000) { $prefix .= STICKY_FLAG; } // signal restricted and private sections if ($section['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($section['active'] == 'R') { $section .= RESTRICTED_FLAG; } // flag sections that are dead, or created or updated very recently if ($section['expiry_date'] > NULL_DATE && $section['expiry_date'] <= $context['now']) {
/** * get invitation default message * * This is put in the invitation form. * * @see articles/invite.php * * @param string 'PUBLISH' or 'CANCEL' * @return string to be put in the web form */ function get_invite_default_message($method = 'PUBLISH') { global $context; // to be displayed into the web form for this invitation $text = ''; if ($value = $this->anchor->get_title()) { $text .= sprintf(i18n::c('%s: %s'), i18n::c('Topic'), Skin::build_link($context['url_to_home'] . $context['url_to_root'] . $this->anchor->get_url(), Codes::beautify_title($value))) . BR; } // dates if (isset($this->attributes['date_stamp']) && $this->attributes['date_stamp']) { $text .= sprintf(i18n::c('%s: %s'), i18n::c('Date'), Skin::build_date($this->attributes['date_stamp'], 'day')) . BR; } // build a link to the chairman page, if any if (isset($this->attributes['chairman']) && ($user = Users::get($this->attributes['chairman']))) { $text .= sprintf(i18n::c('%s: %s'), i18n::c('Chairman'), Users::get_link($user['full_name'], NULL, $user['id'])) . BR; } // event has been cancelled if ($method == 'CANCEL') { $text .= '<div><p>' . i18n::c('Event has been cancelled.') . '</p></div>'; } else { // copy content of the introduction field, if any if ($value = $this->anchor->get_value('introduction')) { $text .= '<div>' . Codes::beautify('<p>' . $value . '</p>') . '</div>'; } // copy the induction message, if any if (isset($this->attributes['induction_message'])) { $text .= '<div>' . Codes::render($this->attributes['induction_message']) . '</div>'; } } // done return $text; }
/** * 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 (!($count = SQL::count($result))) { return $text; } // allow for several lists in the same page static $serial; if (isset($serial)) { $serial++; } else { $serial = 1; } // don't blast too many people if ($count > 100) { $checked = ''; } elseif (isset($this->layout_variant) && $this->layout_variant == 'unchecked') { $checked = ''; } else { $checked = ' checked="checked"'; } // div prefix $text .= '<div id="users_as_mail_panel_' . $serial . '">'; // allow to select/deslect multiple rows at once $text .= '<input type="checkbox" class="row_selector" onclick="check_user_as_mail_panel_' . $serial . '(\'div#users_as_mail_panel_' . $serial . '\', this);"' . $checked . ' /> ' . i18n::s('Select all/none') . BR; // process all items in the list $count = 0; 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; } // get the related overlay, if any $overlay = Overlay::load($item, 'user:'******'id']); // column to select the row $text .= '<input type="checkbox" name="selected_users[]" class="row_selector" value="' . encode_field($item['email']) . '"' . $checked . ' />'; // signal restricted and private users if ($item['active'] == 'N') { $text .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $text .= RESTRICTED_FLAG; } // the url to view this item $url = Users::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['full_name']); } // sanity check if (!$title) { $title = $item['nick_name']; } // link to this page $text .= Skin::build_link($url, $title, 'user'); // the introductory text if ($item['introduction']) { $text .= '<span class="tiny"> - ' . Codes::beautify_introduction($item['introduction']) . '</span>'; } // insert overlay data, if any if (is_object($overlay)) { $text .= $overlay->get_text('list', $item); } // display all tags if ($item['tags']) { $text .= ' <span class="tags">' . Skin::build_tags($item['tags'], 'user:'******'id']) . '</span>'; } // append the row $text .= BR; $count++; } // the script used to check all items at once Page::insert_script('function check_user_as_mail_panel_' . $serial . '(scope, handle) {' . "\n" . ' $(scope + " input[type=\'checkbox\'].row_selector").each(' . "\n" . ' function() { $(this).attr("checked", $(handle).is(":checked"));}' . "\n" . ' );' . "\n" . '}' . "\n"); // div suffix $text .= '</div>'; // no valid account has been found if (!$count) { $text = ''; } // end of processing SQL::free($result); return $text; }
/** * list articles as an index * * @param resource the SQL result * @return string the rendered text **/ function layout($result) { global $context; // we return some text $text = ''; // referenced items $letters = array(); // empty list if (!SQL::count($result)) { return $text; } // build a list of articles include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Articles::get_permalink($item); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // reset everything $prefix = $label = $suffix = $icon = $details = ''; // signal articles to be published if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) { $prefix .= DRAFT_FLAG; } // signal restricted and private articles if (isset($item['active']) && $item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif (isset($item['active']) && $item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // flag articles updated recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $suffix .= ' ' . EXPIRED_FLAG; } elseif ($item['create_date'] >= $context['fresh']) { $suffix .= ' ' . NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= ' ' . UPDATED_FLAG; } // make a link $label = $prefix . Skin::build_link($url, $title, 'basic') . $suffix; // the associated letter $letter = strtoupper(ltrim($title[0])); if ($letter < 'A' || $letter > 'Z') { $letter = '#'; } // a new entry for this letter if (!isset($letters[$letter])) { $letters[$letter] = array(); } $letters[$letter][] = $label; } // mention all letters at the top $bar = array(); // all potential letters, in expected order $all = '#ABCDEFGHIJKLMNOPQRSTUVWXYZ'; for ($index = 0; $index < strlen($all); $index++) { $letter = $all[$index]; // some content for this letter if (isset($letters[$letter])) { // internal link to the right place $bar[] = Skin::build_link('#letter' . $letter, $letter, 'span'); // actual content for this letter $content = '<ul class="index"><li>' . join('</li><li>', $letters[$letter]) . '</li></ul>'; // content displayed in the page $text .= Skin::build_header_box($letter, $content, 'letter' . $letter); // no content for this letter } else { $bar[] = $letter; } } // insert local links at the top $text = Skin::finalize_list($bar, 'menu_bar') . $text; // end of processing SQL::free($result); return $text; }
/** * list articles * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // sanity check if (!isset($this->focus)) { $this->focus = 'map'; } // put in cache $cache_id = Cache::hash('articles/layout_articles_as_carrousel:' . $this->focus) . '.xml'; // save for one minute if (!file_exists($context['path_to_root'] . $cache_id) || filemtime($context['path_to_root'] . $cache_id) + 60 < time()) { // content of the slideshow $content = '<?xml version="1.0" encoding="utf-8"?><!-- fhShow Carousel 2.0 configuration file Please visit http://www.flshow.net/ -->' . "\n" . '<slide_show>' . "\n" . ' <options>' . "\n" . ' <debug>false</debug> <!-- true, false -->' . "\n" . ' <background>transparent</background> <!-- #RRGGBB, transparent -->' . "\n" . ' <friction>5</friction> <!-- [1,100] -->' . "\n" . ' <fullscreen>false</fullscreen> <!-- true, false -->' . "\n" . ' <margins>' . "\n" . ' <top>0</top> <!-- [-1000,1000] pixels -->' . "\n" . ' <left>0</left> <!-- [-1000,1000] pixels -->' . "\n" . ' <bottom>0</bottom> <!-- [-1000,1000] pixels -->' . "\n" . ' <right>0</right> <!-- [-1000,1000] pixels -->' . "\n" . ' <horizontal_ratio>20%</horizontal_ratio> <!-- [1,50] a photo may occupy at most horizontalRatio percent of the Carousel width -->' . "\n" . ' <vertical_ratio>90%</vertical_ratio> <!-- [1,100] a photo may occupy at most verticalRatio percent of the Carousel height -->' . "\n" . ' </margins>' . "\n" . ' <interaction>' . "\n" . ' <rotation>mouse</rotation> <!-- auto, mouse, keyboard -->' . "\n" . ' <view_point>none</view_point> <!-- none, mouse, keyboard -->' . "\n" . ' <speed>15</speed> <!-- [-360,360] degrees per second -->' . "\n" . ' <default_speed>15</default_speed> <!-- [-360,360] degrees per second -->' . "\n" . ' <default_view_point>20%</default_view_point> <!-- [0,100] percentage -->' . "\n" . ' <reset_delay>20</reset_delay> <!-- [0,600] seconds, 0 means never reset -->' . "\n" . ' </interaction>' . "\n" . ' <far_photos>' . "\n" . ' <size>50%</size> <!-- [0,100] percentage -->' . "\n" . ' <amount>50%</amount> <!-- [0,100] percentage -->' . "\n" . ' <blur>10</blur> <!-- [0,100] amount -->' . "\n" . ' <blur_quality>3</blur_quality> <!-- [1,3] 1=low - 3=high -->' . "\n" . ' </far_photos>' . "\n" . ' <reflection>' . "\n" . ' <amount>25</amount> <!-- [0,1000] pixels -->' . "\n" . ' <blur>2</blur> <!-- [0,100] blur amount -->' . "\n" . ' <distance>0</distance> <!-- [-1000,1000] pixels -->' . "\n" . ' <alpha>40%</alpha> <!-- [0,100] percentage -->' . "\n" . ' </reflection>' . "\n" . ' <titles>' . "\n" . ' <style>font-size: 14px; font-family: Verdana, _serif; color: #000000;</style>' . "\n" . ' <position>above center</position> <!-- [above, below] [left,center,right]-->' . "\n" . ' <background>' . $context['url_to_home'] . $context['url_to_root'] . 'skins/_reference/layouts/carrousel_bubble.png</background> <!-- image url -->' . "\n" . ' <scale9>35 35 35 35</scale9> <!-- [0,1000] pixels -->' . "\n" . ' <padding>8 15 10 15</padding> <!-- [-1000,1000] pixels -->' . "\n" . ' </titles>' . "\n" . ' </options>' . "\n"; // get a default image if (Safe::GetImageSize($context['path_to_root'] . $context['skin'] . '/layouts/map.gif')) { $default_href = $context['url_to_root'] . $context['skin'] . '/layouts/map.gif'; } elseif ($size = Safe::GetImageSize($context['path_to_root'] . 'skins/_reference/layouts/map.gif')) { $default_href = $context['url_to_root'] . 'skins/_reference/layouts/map.gif'; } else { $default_href = NULL; } // process all items in the list while ($item = SQL::fetch($result)) { // get the related overlay $overlay = Overlay::load($item, 'article:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // this is visual if (isset($item['icon_url']) && $item['icon_url']) { $image = $item['icon_url']; } elseif (isset($item['thumbnail_url']) && $item['thumbnail_url']) { $image = $item['thumbnail_url']; } elseif (is_callable(array($anchor, 'get_bullet_url')) && ($image = $anchor->get_bullet_url())) { } elseif ($default_href) { $image = $default_href; } else { continue; } // fix relative path if (!preg_match('/^(\\/|http:|https:|ftp:)/', $image)) { $image = $context['url_to_home'] . $context['url_to_root'] . $image; } // build a title if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // the url to view this item $url = Articles::get_permalink($item); // add to the list $content .= ' <photo>' . "\n" . ' <title>' . $title . '</title>' . "\n" . ' <src>' . $image . '</src>' . "\n" . ' <href>' . $url . '</href>' . "\n" . ' <target>_self</target>' . "\n" . ' </photo>' . "\n"; } // finalize slideshow content $content .= '</slide_show>'; // put in cache Safe::file_put_contents($cache_id, $content); } // allow multiple instances static $count; if (!isset($count)) { $count = 1; } else { $count++; } // load the right file $text = '<div id="articles_as_carrousel_' . $count . '"></div>' . "\n"; Page::insert_script('swfobject.embedSWF("' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/carrousel.swf",' . "\n" . '"articles_as_carrousel_' . $count . '",' . "\n" . '"100%",' . "\n" . '"150",' . "\n" . '"9.0.0",' . "\n" . 'false,' . "\n" . '{xmlfile:"' . $context['url_to_home'] . $context['url_to_root'] . $cache_id . '", loaderColor:"0x666666"},' . "\n" . '{wmode: "transparent"},' . "\n" . '{});' . "\n"); // end of processing SQL::free($result); return $text; }
/** * list files * * Recognize following variants: * - 'section:123' to list items attached to one particular anchor * - 'no_author' to list items attached to one user profile * * @param resource the SQL result * @return string HTML text to be displayed, or NULL * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // sanity check if (!isset($this->focus)) { $this->focus = ''; } // process all items in the list $items = array(); while ($item = SQL::fetch($result)) { // one box at a time $box = ''; // get the main anchor $anchor = Anchors::get($item['anchor']); // we feature only the head of the list, if we are at the origin page if (!count($items) && $anchor && is_string($this->focus) && $this->focus == $anchor->get_reference()) { $box .= Codes::render_object('file', $item['id']); // no side icon $icon = ''; // we are listing various files from various places } else { $prefix = $suffix = ''; // stream the file if (Files::is_stream($item['file_name'])) { $url = Files::get_url($item['id'], 'stream', $item['file_name']); } else { $url = Files::get_url($item['id'], 'fetch', $item['file_name']); } // absolute url $url = $context['url_to_home'] . $context['url_to_root'] . $url; // signal restricted and private files if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // file title or file name $label = Codes::beautify_title($item['title']); if (!$label) { $label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name'])); } // show a reference to the file for members $hover = i18n::s('Get the file'); if (Surfer::is_member()) { $hover .= ' [file=' . $item['id'] . ']'; } // flag files uploaded recently if ($item['create_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= UPDATED_FLAG; } // one line of text $box .= $prefix . Skin::build_link($url, $label, 'basic', $hover) . $suffix; // side icon if ($item['thumbnail_url']) { $icon = $item['thumbnail_url']; } else { $icon = $context['url_to_root'] . Files::get_icon_url($item['file_name']); } // build the complete HTML element $icon = '<img src="' . $icon . '" alt="" title="' . encode_field(strip_tags($label)) . '" />'; // make it a clickable link $icon = Skin::build_link($url, $icon, 'basic'); } // first line of details $details = array(); // file poster and last action if ($this->layout_variant != 'no_author') { $details[] = sprintf(i18n::s('shared by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date'])); } else { $details[] = Skin::build_date($item['edit_date']); } // downloads if ($item['hits'] > 1) { $details[] = Skin::build_number($item['hits'], i18n::s('downloads')); } // file size if ($item['file_size'] > 1) { $details[] = Skin::build_number($item['file_size'], i18n::s('bytes')); } // anchor link if ($anchor && is_string($this->focus) && $this->focus != $anchor->get_reference()) { $anchor_url = $anchor->get_url(); $anchor_label = ucfirst($anchor->get_title()); $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor_url, $anchor_label, 'article')); } $box .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>'; // append details $details = array(); // view the file $details[] = Skin::build_link(Files::get_permalink($item), i18n::s('details'), 'basic'); // file has been detached if (isset($item['assign_id']) && $item['assign_id']) { // who has been assigned? if (Surfer::is($item['assign_id'])) { $details[] = DRAFT_FLAG . sprintf(i18n::s('reserved by you %s'), Skin::build_date($item['assign_date'])); } else { $details[] = DRAFT_FLAG . sprintf(i18n::s('reserved by %s %s'), Users::get_link($item['assign_name'], $item['assign_address'], $item['assign_id']), Skin::build_date($item['assign_date'])); } } // detach or edit the file if (Files::allow_modification($item, $anchor)) { if (!isset($item['assign_id']) || !$item['assign_id']) { $details[] = Skin::build_link(Files::get_url($item['id'], 'reserve'), i18n::s('reserve'), 'basic', i18n::s('Prevent other persons from changing this file until you update it')); } // release reservation if (isset($item['assign_id']) && $item['assign_id'] && (Surfer::is($item['assign_id']) || is_object($anchor) && $anchor->is_owned())) { $details[] = Skin::build_link(Files::get_url($item['id'], 'release'), i18n::s('release reservation'), 'basic', i18n::s('Allow other persons to update this file')); } if (!isset($item['assign_id']) || !$item['assign_id'] || Surfer::is($item['assign_id']) || is_object($anchor) && $anchor->is_owned()) { $details[] = Skin::build_link(Files::get_url($item['id'], 'edit'), i18n::s('update'), 'basic', i18n::s('Share a new version of this file, or change details')); } } // delete the file if (Files::allow_deletion($item, $anchor)) { $details[] = Skin::build_link(Files::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic'); } // append details if (count($details)) { $box .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>'; } // insert item icon if ($icon) { $list = array(array($box, $icon)); $items[] = Skin::finalize_list($list, 'decorated'); // put the item in a division } else { $items[] = '<div style="margin: 0 0 1em 0">' . $box . '</div>'; } } // stack all items in a single column $text = Skin::finalize_list($items, 'rows'); // end of processing SQL::free($result); return $text; }
/** * get sections as radio buttons * * This allow to move a page to a parent section, or to a child section * * @param string the current anchor to an existing section (e.g., 'section:12') * @param int id of the section that is moved * @return the HTML to insert in the page * * @see articles/edit.php * @see articles/import.php * @see files/edit.php * @see images/edit.php * @see links/edit.php * @see panel.php * @see skins/upload.php */ public static function &get_radio_buttons($current = NULL, $me = NULL) { global $context; // we put radio buttons in a string $text = ''; // get section id from reference if (!strncmp($current, 'section:', 8)) { $current = substr($current, 8); } // get the current parent, if any $item = Sections::get($current); // list all children sections of parent $children = ''; if (isset($item['id'])) { $query = "SELECT * FROM " . SQL::table_name('sections') . " AS sections" . " WHERE (anchor LIKE 'section:" . $item['id'] . "')" . " ORDER BY sections.rank, sections.title, sections.edit_date DESC LIMIT 5000"; if ($result = SQL::query($query)) { while ($row = SQL::fetch($result)) { if ($children) { $children .= BR; } // prevent anchoring to myself if ($row['id'] == $me) { $children .= '<input type="radio" name="anchor" value="section:' . $row['id'] . '" disabled="disabled" /> <i>' . Codes::beautify_title($row['title']) . '</i>'; } else { $children .= '<input type="radio" name="anchor" value="section:' . $row['id'] . '" /> ' . Codes::beautify_title($row['title']); } } } } // list sections at the same level as parent $family = ''; if (isset($item['anchor']) && ($granparent = Anchors::get($item['anchor']))) { // limit to accessible scope $query = "SELECT * FROM " . SQL::table_name('sections') . " AS sections" . " WHERE (anchor LIKE '" . $item['anchor'] . "') AND " . sections::get_sql_where() . " ORDER BY sections.rank, sections.title, sections.edit_date DESC LIMIT 5000"; if ($result = SQL::query($query)) { // brothers and sisters of parent while ($row = SQL::fetch($result)) { if ($family && strncmp(substr($family, -6), '</div>', 6)) { $family .= BR; } if ($row['id'] == $item['id']) { if ($children) { $family .= '<input type="radio" name="anchor" value="section:' . $item['id'] . '" checked="checked" /> ' . Codes::beautify_title($item['title']) . '<div style="margin: 0 0 0 3em">' . $children . '</div>'; } else { $family .= '<input type="radio" name="anchor" value="section:' . $item['id'] . '" checked="checked" /> ' . Codes::beautify_title($item['title']); } } else { $family .= '<input type="radio" name="anchor" value="section:' . $row['id'] . '" /> ' . Codes::beautify_title($row['title']); } } } // move to granparent if ($granparent->is_assigned()) { $family = '<input type="radio" name="anchor" value="' . $granparent->get_reference() . '" /> ' . $granparent->get_title() . '<div style="margin: 0 0 0 3em">' . $family . '</div>'; } else { $family = '<input type="radio" name="anchor" value="' . $granparent->get_reference() . '" disabled="disabled" /> ' . $granparent->get_title() . '<div style="margin: 0 0 0 3em">' . $family . '</div>'; } // list top-level sections } else { // at the very top of the content tree if (surfer::is_associate()) { $family .= '<input type="radio" name="anchor" value="" ' . (!isset($item['id']) ? 'checked="checked"' : '') . ' /> ' . i18n::s('Top of the content tree') . BR . '<div style="margin: 0 0 0 3em">'; } // restrict to accessible scope $where = sections::get_sql_where(); // always mention current and parent sections if ($me) { $where .= " OR (sections.id=" . $me . ")"; } if ($current) { $where .= " OR (sections.id=" . $current . ")"; } // list regular sections first $query = "SELECT * FROM " . SQL::table_name('sections') . " AS sections" . " WHERE (sections.anchor='' OR sections.anchor IS NULL) AND (" . $where . ")" . " AND (sections.index_map = 'Y')" . " ORDER BY sections.rank, sections.title, sections.edit_date DESC LIMIT 5000"; if ($result = SQL::query($query)) { // process all matching sections while ($row = SQL::fetch($result)) { if ($row['id'] == $item['id']) { if ($children) { $family .= '<input type="radio" name="anchor" value="section:' . $item['id'] . '" checked="checked" /> ' . Codes::beautify_title($item['title']) . '<div style="margin: 0 0 0 3em">' . $children . '</div>'; } else { $family .= '<input type="radio" name="anchor" value="section:' . $item['id'] . '" checked="checked" /> ' . Codes::beautify_title($item['title']) . BR; } } elseif (!Surfer::is_associate()) { continue; } elseif ($row['id'] == $me) { $family .= '<input type="radio" name="anchor" disabled="disabled" /> ' . Codes::beautify_title($row['title']) . BR; } else { $family .= '<input type="radio" name="anchor" value="section:' . $row['id'] . '" /> ' . Codes::beautify_title($row['title']) . BR; } } } // close the top of the content tree if (surfer::is_associate()) { $family .= '</div>'; } // list special sections to associates if (Surfer::is_associate()) { $query = "SELECT * FROM " . SQL::table_name('sections') . " AS sections" . " WHERE (sections.anchor='' OR sections.anchor IS NULL)" . " AND (sections.index_map != 'Y')" . " ORDER BY sections.rank, sections.title, sections.edit_date DESC LIMIT 5000"; if ($result = SQL::query($query)) { $family .= '<hr />'; // process all matching sections while ($row = SQL::fetch($result)) { if ($row['id'] == $item['id']) { if ($children) { $family .= '<input type="radio" name="anchor" value="section:' . $item['id'] . '" checked="checked" /> ' . Codes::beautify_title($item['title']) . '<div style="margin: 0 0 0 3em">' . $children . '</div>'; } else { $family .= '<input type="radio" name="anchor" value="section:' . $item['id'] . '" checked="checked" /> ' . Codes::beautify_title($item['title']) . BR; } } else { $family .= '<input type="radio" name="anchor" value="section:' . $row['id'] . '" /> ' . Codes::beautify_title($row['title']) . BR; } } } } } $text .= $family; // at least show where we are if (!$text && isset($item['id'])) { $text .= '<input type="hidden" name="anchor" value="section:' . $item['id'] . '" />' . Codes::beautify_title($item['title']); } return $text; }
$context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><div>' . Users::list_for_ids($owners, 'request') . Skin::finalize_list(array(Skin::build_submit_button(i18n::s('Submit a request to get access'))), 'menu_bar') . '<input type="hidden" name="id" value="' . $item['id'] . '">' . '</div></form>'; } } // re-enforce the canonical link } elseif (!$zoom_type && $page == 1 && $context['self_url'] && $whole_rendering && strncmp($context['self_url'], $context['page_link'], strlen($context['page_link']))) { Safe::header('Status: 301 Moved Permanently', TRUE, 301); Safe::header('Location: ' . $context['page_link']); Logger::error(Skin::build_link($context['page_link'])); // display the article } else { // behaviors can change page menu if (is_object($behaviors)) { $context['page_menu'] = $behaviors->add_commands('articles/view.php', 'article:' . $item['id'], $context['page_menu']); } // remember surfer visit Surfer::is_visiting(Articles::get_permalink($item), Codes::beautify_title($item['title']), 'article:' . $item['id'], $item['active']); // increment silently the hits counter if not robot, nor associate, nor owner, nor at follow-up page if (Surfer::is_crawler() || Surfer::is_associate()) { } elseif (isset($item['owner_id']) && Surfer::is($item['owner_id'])) { } elseif (!$zoom_type) { $item['hits'] = isset($item['hits']) ? $item['hits'] + 1 : 1; Articles::increment_hits($item['id']); } // initialize the rendering engine Codes::initialize(Articles::get_permalink($item)); // neighbours information $neighbours = NULL; if (Articles::has_option('with_neighbours', $anchor, $item) && is_object($anchor)) { $neighbours = $anchor->get_neighbours('article', $item); } //
/** * list articles * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // the script used to check all pages at once Page::insert_script('function cascade_selection_to_all_article_rows(handle) {' . "\n" . ' $("div#articles_panel input[type=\'checkbox\'].row_selector").each(' . "\n" . ' function() { $(this).attr("checked", $(handle).is(":checked"));}' . "\n" . ' );' . "\n" . '}' . "\n"); // table prefix $text .= Skin::table_prefix('yc-grid'); // table headers $main = '<input type="checkbox" class="row_selector" onclick="cascade_selection_to_all_article_rows(this);" />'; $cells = array($main, i18n::s('Page'), i18n::s('Rank')); $text .= Skin::table_row($cells, 'header'); // process all items in the list include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; $count = 0; while ($item = SQL::fetch($result)) { $cells = array(); // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the main anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Articles::get_permalink($item); // column to select the row $cells[] = '<input type="checkbox" name="selected_articles[]" id="article_selector_' . $count . '" class="row_selector" value="' . $item['id'] . '" />'; // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // initialize variables $prefix = $suffix = $icon = ''; // flag sticky pages if ($item['rank'] < 10000) { $prefix .= STICKY_FLAG; } // signal locked articles if (isset($item['locked']) && $item['locked'] == 'Y') { $suffix .= ' ' . LOCKED_FLAG; } // flag articles that are dead, or created or updated very recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $prefix .= EXPIRED_FLAG; } elseif ($item['create_date'] >= $context['fresh']) { $suffix .= ' ' . NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= ' ' . UPDATED_FLAG; } // signal articles to be published if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) { $prefix .= DRAFT_FLAG; } // signal restricted and private articles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // the introductory text if (is_object($overlay)) { $introduction = $overlay->get_text('introduction', $item); } else { $introduction = $item['introduction']; } if ($introduction) { $suffix .= BR . Codes::beautify_introduction($introduction); } // insert overlay data, if any if (is_object($overlay)) { $suffix .= $overlay->get_text('list', $item); } // append details to the suffix $suffix .= BR . '<span class="details">'; // details $details = array(); // the author if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { if ($item['create_name'] != $item['edit_name']) { $details[] = sprintf(i18n::s('by %s, %s'), $item['create_name'], $item['edit_name']); } else { $details[] = sprintf(i18n::s('by %s'), $item['create_name']); } } // the last action $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']); // the number of hits if (Surfer::is_logged() && $item['hits'] > 1) { $details[] = Skin::build_number($item['hits'], i18n::s('hits')); } // info on related files $stats = Files::stat_for_anchor('article:' . $item['id']); if ($stats['count']) { $details[] = sprintf(i18n::ns('%d file', '%d files', $stats['count']), $stats['count']); } // info on related links $stats = Links::stat_for_anchor('article:' . $item['id']); if ($stats['count']) { $details[] = sprintf(i18n::ns('%d link', '%d links', $stats['count']), $stats['count']); } // info on related comments $stats = Comments::stat_for_anchor('article:' . $item['id']); if ($stats['count']) { $details[] = sprintf(i18n::ns('%d comment', '%d comments', $stats['count']), $stats['count']); } // rating if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) { $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // combine in-line details if (count($details)) { $suffix .= ucfirst(trim(implode(', ', $details))); } // list up to three categories by title, if any $anchors = array(); if ($members =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) { foreach ($members as $id => $attributes) { // add background color to distinguish this category against others if (isset($attributes['background_color']) && $attributes['background_color']) { $attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>'; } $anchors[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic'); } } if (count($anchors)) { $suffix .= BR . sprintf(i18n::s('In %s'), implode(' / ', $anchors)); } // end of details $suffix .= '</span>'; // strip empty details $suffix = str_replace(BR . '<span class="details"></span>', '', $suffix); $suffix = str_replace('<span class="details"></span>', '', $suffix); // the icon to put in the left column if ($item['thumbnail_url']) { $icon = $item['thumbnail_url']; } // commands $commands = array(Skin::build_link(Articles::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic'), Skin::build_link(Articles::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic')); // link to this page $cells[] = $prefix . Skin::build_link($url, $title, 'article') . ' - ' . Skin::finalize_list($commands, 'menu') . $suffix; // ranking $cells[] = '<input type="text" size="5" name="article_rank_' . $item['id'] . '" value="' . $item['rank'] . '" onfocus="$(\'#article_selector_' . $count . '\').attr(\'checked\', \'checked\');" onchange="$(\'#act_on_articles\').prop(\'selectedIndex\', 9);" />'; // append the row $text .= Skin::table_row($cells, $count++); } // select all rows $cells = array('<input type="checkbox" class="row_selector" onclick="cascade_selection_to_all_article_rows(this);" />', i18n::s('Select all/none'), ''); $text .= Skin::table_row($cells, $count++); // table suffix $text .= Skin::table_suffix(); // end of processing SQL::free($result); return $text; }
/** * list articles * * @param resource the SQL result * @return array * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ($url => $attributes) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // process all items in the list while ($item = SQL::fetch($result)) { // get the related overlay, if any $overlay = Overlay::load($item, 'category:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // provide an absolute link $url = Categories::get_permalink($item); // build a title if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // time of last update $time = SQL::strtotime($item['edit_date']); // the section $root = ''; if ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) { $root = ucfirst(trim(strip_tags(Codes::beautify_title($anchor->get_title())))); } // the icon to use $icon = ''; if ($item['thumbnail_url']) { $icon = $item['thumbnail_url']; } elseif ($item['anchor'] && ($anchor = Anchors::get($item['anchor'])) && is_callable($anchor, 'get_bullet_url')) { $icon = $anchor->get_bullet_url(); } if ($icon) { $icon = $context['url_to_home'] . $context['url_to_root'] . $icon; } // the author(s) is an e-mail address, according to rss 2.0 spec $author = ''; if (isset($item['create_address'])) { $author .= $item['create_address']; } if (isset($item['create_name']) && trim($item['create_name'])) { $author .= ' (' . $item['create_name'] . ')'; } if (isset($item['edit_address']) && trim($item['edit_address']) && $item['create_address'] != $item['edit_address']) { if ($author) { $author .= ', '; } $author .= $item['edit_address']; if (isset($item['edit_name']) && trim($item['edit_name'])) { $author .= ' (' . $item['edit_name'] . ')'; } } // list all components for this item $items[$url] = array($time, $title, $author, $root, $icon, '', '', ''); } // end of processing SQL::free($result); return $items; }
/** * list articles as rows in a table * * @param resource the SQL result * @return string the rendered text **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // build a list of articles $rows = array(); include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // get the related overlay $overlay = Overlay::load($item, 'article:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Articles::get_permalink($item); // reset everything $title = $abstract = $author = ''; // signal articles to be published if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) { $title .= DRAFT_FLAG; } // signal restricted and private articles if ($item['active'] == 'N') { $title .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $title .= RESTRICTED_FLAG; } // indicate the id in the hovering popup $hover = i18n::s('View the page'); if (Surfer::is_member()) { $hover .= ' [article=' . $item['id'] . ']'; } // use the title to label the link if (is_object($overlay)) { $label = Codes::beautify_title($overlay->get_text('title', $item)); } else { $label = Codes::beautify_title($item['title']); } // use the title as a link to the page $title .= Skin::build_link($url, $label, 'basic', $hover); // signal locked articles if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) { $title .= ' ' . LOCKED_FLAG; } // flag articles updated recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $title .= ' ' . EXPIRED_FLAG; } elseif ($item['create_date'] >= $context['fresh']) { $title .= ' ' . NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $title .= ' ' . UPDATED_FLAG; } // the icon if ($item['thumbnail_url']) { $abstract .= '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $item['thumbnail_url'] . '" class="right_image" alt="" /></a>'; } // the introductory text if (is_object($overlay)) { $abstract .= Codes::beautify_introduction($overlay->get_text('introduction', $item)); } elseif ($item['introduction']) { $abstract .= Codes::beautify_introduction($item['introduction']); } // insert overlay data, if any if (is_object($overlay)) { $abstract .= $overlay->get_text('list', $item); } // make some abstract out of main text if (!$item['introduction'] && $context['skins_with_details'] == 'Y') { $abstract .= Skin::cap(Codes::beautify($item['description'], $item['options']), 50); } // attachment details $details = array(); // info on related files if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) { Skin::define_img('FILES_LIST_IMG', 'files/list.gif'); $details[] = FILES_LIST_IMG . sprintf(i18n::ns('%d file', '%d files', $count), $count); } // info on related links if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) { Skin::define_img('LINKS_LIST_IMG', 'links/list.gif'); $details[] = LINKS_LIST_IMG . sprintf(i18n::ns('%d link', '%d links', $count), $count); } // comments if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) { Skin::define_img('COMMENTS_LIST_IMG', 'comments/list.gif'); $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'list'), COMMENTS_LIST_IMG . sprintf(i18n::ns('%d comment', '%d comments', $count), $count)); } // describe attachments if (count($details)) { $abstract .= '<p style="margin: 3px 0;">' . join(', ', $details) . '</p>'; } // anchors $anchors = array(); if ($members =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) { foreach ($members as $category_id => $attributes) { // add background color to distinguish this category against others if (isset($attributes['background_color']) && $attributes['background_color']) { $attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>'; } $anchors[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic'); } } if (@count($anchors)) { $abstract .= '<p class="tags" style="margin: 3px 0">' . implode(' ', $anchors) . '</p>'; } // poster name if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { if ($item['create_name']) { $author = Users::get_link($item['create_name'], $item['create_address'], $item['create_id']); } else { $author = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']); } } // more details $details =& Articles::build_dates($anchor, $item); // rating if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) { $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // page details if (count($details)) { $details = '<p class="details">' . join(', ', $details) . '</p>'; } // this is another row of the output -- title, abstract, (author,) details if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { $cells = array($title, $abstract, $author, $details); } else { $cells = array($title, $abstract, $details); } // append this row $rows[] = $cells; } // end of processing SQL::free($result); // headers if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { $headers = array(i18n::s('Topic'), i18n::s('Abstract'), i18n::s('Poster'), i18n::s('Details')); } else { $headers = array(i18n::s('Topic'), i18n::s('Abstract'), i18n::s('Details')); } // return a sortable table $text .= Skin::table($headers, $rows, 'grid'); return $text; }
/** * list articles as digg do * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $label = i18n::s('No page to display.'); if (Surfer::is_associate()) { $label .= ' ' . sprintf(i18n::s('Use the %s to populate this server.'), Skin::build_link('help/populate.php', i18n::s('Content Assistant'), 'shortcut')); } $output = '<p>' . $label . '</p>'; return $output; } // build a list of articles $text = ''; $item_count = 0; include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // permalink $url = Articles::get_permalink($item); // get the anchor $anchor = Anchors::get($item['anchor']); // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // next item $item_count += 1; // section opening if ($item_count == 1) { $text .= '<div class="newest">' . "\n"; } // reset everything $content = $prefix = $label = $suffix = $icon = ''; // the icon to put aside if ($item['thumbnail_url']) { $icon = $item['thumbnail_url']; } elseif (is_callable(array($anchor, 'get_bullet_url'))) { $icon = $anchor->get_bullet_url(); } if ($icon) { $icon = '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $icon . '" class="right_image" alt="' . encode_field(i18n::s('View the page')) . '" title="' . encode_field(i18n::s('View the page')) . '" /></a>'; } // signal restricted and private articles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // flag articles updated recently if ($item['create_date'] >= $context['fresh']) { $suffix .= ' ' . NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= ' ' . UPDATED_FLAG; } // add details $details = array(); // the author if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { if ($item['edit_name'] == $item['create_name']) { $details[] = sprintf(i18n::s('by %s'), ucfirst($item['create_name'])); } else { $details[] = sprintf(i18n::s('by %s, %s'), ucfirst($item['create_name']), ucfirst($item['edit_name'])); } } // the publish date $details[] = Skin::build_date($item['publish_date']); // rating $rating_label = ''; if ($item['rating_count']) { $rating_label = Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])) . ' ' . sprintf(i18n::ns('%d rating', '%d ratings', $item['rating_count']), $item['rating_count']) . ' '; } // add a link to let surfer rate this item if (is_object($anchor) && !$anchor->has_option('without_rating')) { if (!$item['rating_count']) { $rating_label .= i18n::s('Rate this page'); } $rating_label = Skin::build_link(Articles::get_url($item['id'], 'like'), $rating_label, 'basic', i18n::s('Rate this page')); } // display current rating, and allow for rating $details[] = $rating_label; // details if (count($details)) { $content .= '<p class="details">' . ucfirst(implode(', ', $details)) . '</p>'; } // the full introductory text if ($item['introduction']) { $content .= Codes::beautify($item['introduction'], $item['options']); } elseif (!is_object($overlay)) { include_once $context['path_to_root'] . 'articles/article.php'; $article = new Article(); $article->load_by_content($item); $content .= $article->get_teaser('teaser'); } // insert overlay data, if any if (is_object($overlay)) { $content .= $overlay->get_text('list', $item); } // an array of links $menu = array(); // rate the article $menu = array_merge($menu, array(Articles::get_url($item['id'], 'like') => i18n::s('Rate this page'))); // read the article $menu = array_merge($menu, array($url => i18n::s('Read more'))); // info on related files if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d file', '%d files', $count), $count), 'basic'); } // info on related comments if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) { $link = Comments::get_url('article:' . $item['id'], 'list'); $menu = array_merge($menu, array($link => sprintf(i18n::ns('%d comment', '%d comments', $count), $count))); } // discuss if (Comments::allow_creation($item, $anchor)) { $menu = array_merge($menu, array(Comments::get_url('article:' . $item['id'], 'comment') => i18n::s('Discuss'))); } // info on related links if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) { $menu = array_merge($menu, array($url . '#_attachments' => sprintf(i18n::ns('%d link', '%d links', $count), $count))); } // trackback if (Links::allow_trackback()) { $menu = array_merge($menu, array('links/trackback.php?anchor=' . urlencode('article:' . $item['id']) => i18n::s('Reference this page'))); } // link to the anchor page if (is_object($anchor)) { $menu = array_merge($menu, array($anchor->get_url() => $anchor->get_title())); } // list up to three categories by title, if any if ($items = Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 3, 'raw')) { foreach ($items as $id => $attributes) { $menu = array_merge($menu, array(Categories::get_permalink($attributes) => $attributes['title'])); } } // append a menu $content .= Skin::build_list($menu, 'menu_bar'); // insert a complete box $text .= Skin::build_box($icon . $prefix . Codes::beautify_title($item['title']) . $suffix, $content, 'header1', 'article_' . $item['id']); // section closing if ($item_count == 1) { $text .= '</div>' . "\n"; } } // end of processing SQL::free($result); // add links to archives $anchor = Categories::get(i18n::c('monthly')); if (isset($anchor['id']) && ($items = Categories::list_by_date_for_anchor('category:' . $anchor['id'], 0, COMPACT_LIST_SIZE, 'compact'))) { $text .= Skin::build_box(i18n::s('Previous pages'), Skin::build_list($items, 'menu_bar')); } return $text; }
/** * list articles as topics in a forum * * @param resource the SQL result * @return string the rendered text **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // start a table $text .= Skin::table_prefix('jive'); // headers $text .= Skin::table_row(array(i18n::s('Topic'), i18n::s('Content')), 'header'); // build a list of articles $odd = FALSE; include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Articles::get_permalink($item); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // one row per article $text .= '<tr class="' . ($odd ? 'odd' : 'even') . '"><td>'; $odd = !$odd; // signal articles to be published if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) { $text .= DRAFT_FLAG; } // signal restricted and private articles if ($item['active'] == 'N') { $text .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $text .= RESTRICTED_FLAG; } // use the title as a link to the page $text .= Skin::build_link($url, '<strong>' . $title . '</strong>', 'basic'); // signal locked articles if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) { $text .= ' ' . LOCKED_FLAG; } // flag articles updated recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $text .= ' ' . EXPIRED_FLAG; } elseif ($item['create_date'] >= $context['fresh']) { $text .= ' ' . NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $text .= ' ' . UPDATED_FLAG; } // add details, if any $details = array(); // poster name if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { if ($item['create_name']) { $details[] = sprintf(i18n::s('posted by %s %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']), Skin::build_date($item['create_date'])); } } // last update $details[] = sprintf(i18n::s('Updated %s'), Skin::build_date($item['edit_date'])); // add details to the title if (count($details)) { $text .= '<p class="details" style="margin: 3px 0">' . join(', ', $details) . '</p>'; } // display all tags if ($item['tags']) { $text .= '<p class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</p>'; } // next cell for the content $text .= '</td><td width="70%">'; // the content to be displayed $content = ''; // rating if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) { $content .= Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // the introductory text if (is_object($overlay)) { $content .= Codes::beautify_introduction($overlay->get_text('introduction', $item)); } else { $content .= Codes::beautify_introduction($item['introduction']); } // insert overlay data, if any if (is_object($overlay)) { $content .= $overlay->get_text('list', $item); } // the description $content .= Skin::build_block($item['description'], 'description', '', $item['options']); // attachment details $details = array(); // info on related files if ($count = Files::count_for_anchor('article:' . $item['id'])) { Skin::define_img('FILES_LIST_IMG', 'files/list.gif'); $details[] = Skin::build_link($url . '#_attachments', FILES_LIST_IMG . sprintf(i18n::ns('%d file', '%d files', $count), $count), 'span'); } // info on related links if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) { Skin::define_img('LINKS_LIST_IMG', 'links/list.gif'); $details[] = LINKS_LIST_IMG . sprintf(i18n::ns('%d link', '%d links', $count), $count); } // count replies if ($count = Comments::count_for_anchor('article:' . $item['id'])) { $details[] = Skin::build_link($url . '#_discussion', sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'span'); } // the command to reply if (Comments::allow_creation($item, $anchor)) { Skin::define_img('COMMENTS_ADD_IMG', 'comments/add.gif'); $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), COMMENTS_ADD_IMG . i18n::s('Post a comment'), 'span'); } // describe attachments $content .= Skin::finalize_list($details, 'menu_bar'); // end the row $text .= $content . '</td></tr>'; } // end of processing SQL::free($result); // return the table $text .= Skin::table_suffix(); return $text; }
/** * list sections as topics in a forum * * @param resource the SQL result * @return string the rendered text **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // layout in a table $text = Skin::table_prefix('wide'); // 'even' is used for title rows, 'odd' for detail rows $class_title = 'odd'; $class_detail = 'even'; // build a list of sections $family = ''; include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // change the family if ($item['family'] != $family) { $family = $item['family']; // show the family $text .= Skin::table_suffix() . '<h2><span>' . $family . ' </span></h2>' . "\n" . Skin::table_prefix('wide'); } // get the related overlay, if any $overlay = Overlay::load($item, 'section:' . $item['id']); // get the main anchor $anchor = Anchors::get($item['anchor']); // reset everything $prefix = $label = $suffix = $icon = ''; // signal restricted and private sections if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // indicate the id in the hovering popup $hover = i18n::s('View the section'); if (Surfer::is_member()) { $hover .= ' [section=' . $item['id'] . ']'; } // the url to view this item $url = Sections::get_permalink($item); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // use the title as a link to the page $title =& Skin::build_link($url, $title, 'basic', $hover); // flag sections updated recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $suffix = EXPIRED_FLAG . ' '; } elseif ($item['create_date'] >= $context['fresh']) { $suffix = NEW_FLAG . ' '; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix = UPDATED_FLAG . ' '; } // this is another row of the output $text .= '<tr class="' . $class_title . '"><th>' . $prefix . $title . $suffix . '</th><th>' . i18n::s('Poster') . '</th><th>' . i18n::s('Messages') . '</th><th>' . i18n::s('Last active') . '</th></tr>' . "\n"; $count = 1; // get last posts for this board --avoid sticky pages if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) { $order = $matches[1]; } else { $order = 'edition'; } if ($articles =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], 0, 5, 'raw', TRUE)) { foreach ($articles as $id => $article) { // get the related overlay, if any $article_overlay = Overlay::load($article, 'article:' . $id); // flag articles updated recently if ($article['expiry_date'] > NULL_DATE && $article['expiry_date'] <= $context['now']) { $flag = EXPIRED_FLAG . ' '; } elseif ($article['create_date'] >= $context['fresh']) { $flag = NEW_FLAG . ' '; } elseif ($article['edit_date'] >= $context['fresh']) { $flag = UPDATED_FLAG . ' '; } else { $flag = ''; } // use the title to label the link if (is_object($article_overlay)) { $title = Codes::beautify_title($article_overlay->get_text('title', $article)); } else { $title = Codes::beautify_title($article['title']); } // title $title = Skin::build_link(Articles::get_permalink($article), $title, 'article'); // poster $poster = Users::get_link($article['create_name'], $article['create_address'], $article['create_id']); // comments $comments = Comments::count_for_anchor('article:' . $article['id']); // last editor $action = ''; if ($article['edit_date']) { // label the action if (isset($article['edit_action'])) { $action = Anchors::get_action_label($article['edit_action']); } else { $action = i18n::s('edited'); } $action = '<span class="details">' . $action . ' ' . Skin::build_date($article['edit_date']) . '</span>'; } // this is another row of the output $text .= '<tr class="' . $class_detail . '"><td>' . $title . $flag . '</td><td>' . $poster . '</td><td style="text-align: center;">' . $comments . '</td><td>' . $action . '</td></tr>' . "\n"; } } // more details $details = array(); // board introduction if ($item['introduction']) { $details[] = Codes::beautify_introduction($item['introduction']); } // indicate the total number of threads here if (($count = Articles::count_for_anchor('section:' . $item['id'])) && $count >= 5) { $details[] = sprintf(i18n::s('%d threads'), $count) . ' »'; } // link to the section index page if ($details) { $details = Skin::build_link(Sections::get_permalink($item), join(' - ', $details), 'basic'); } else { $details = ''; } // add a command for new post $poster = ''; if (Surfer::is_empowered()) { $poster = Skin::build_link('articles/edit.php?anchor=' . urlencode('section:' . $item['id']), i18n::s('Add a page') . ' »', 'basic'); } // insert details in a separate row if ($details || $poster) { $text .= '<tr class="' . $class_detail . '"><td colspan="3">' . $details . '</td><td>' . $poster . '</td></tr>' . "\n"; } // more details $more = array(); // board moderators if ($moderators = Sections::list_editors_by_name($item, 0, 7, 'comma5')) { $more[] = sprintf(i18n::ns('Moderator: %s', 'Moderators: %s', count($moderators)), $moderators); } // children boards if ($children =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, COMPACT_LIST_SIZE, 'compact')) { $more[] = sprintf(i18n::ns('Child board: %s', 'Child boards: %s', count($children)), Skin::build_list($children, 'comma')); } // as a compact list if (count($more)) { $content = '<ul class="compact">'; foreach ($more as $list_item) { $content .= '<li>' . $list_item . '</li>' . "\n"; } $content .= '</ul>' . "\n"; // insert details in a separate row $text .= '<tr class="' . $class_detail . '"><td colspan="4">' . $content . '</td></tr>' . "\n"; } } // end of processing SQL::free($result); $text .= Skin::table_suffix(); return $text; }
/** * list sections * * @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 include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // get the related overlay, if any $overlay = Overlay::load($item, 'section:' . $item['id']); // get the main anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Sections::get_permalink($item); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // initialize variables $prefix = $suffix = $icon = ''; // flag sticky pages if ($item['rank'] < 10000) { $prefix .= STICKY_FLAG; } // signal restricted and private sections if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // flag sections 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; } // info on related comments if ($count = Comments::count_for_anchor('section:' . $item['id'], TRUE)) { $suffix .= ' (' . $count . ')'; } // details $details = array(); // info on related sections if ($count = Sections::count_for_anchor('section:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count); } // info on related articles if ($count = Articles::count_for_anchor('section:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count); } // info on related files if ($count = Files::count_for_anchor('section:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count); } // info on related links if ($count = Links::count_for_anchor('section:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count); } // the main anchor link if (is_object($anchor) && (!isset($this->focus) || $item['anchor'] != $this->focus)) { $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'section')); } // combine in-line details if (count($details)) { $suffix .= ' - <span class="details">' . trim(implode(', ', $details)) . '</span>'; } // list all components for this item $items[$url] = array($prefix, $title, $suffix, 'section', $icon); } // end of processing SQL::free($result); return $items; }
/** * list articles for search requests * * @param resource the SQL result * @return array of resulting items ($score, $summary), or NULL * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of array($score, $summary) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // process all items in the list include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // one box at a time $box = ''; // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the main anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Articles::get_permalink($item); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // initialize variables $prefix = $suffix = $icon = ''; // flag sticky pages if ($item['rank'] < 10000) { $prefix .= STICKY_FLAG; } // signal locked articles if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) { $suffix .= ' ' . LOCKED_FLAG; } // flag articles that are dead, or created or updated very recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $prefix .= EXPIRED_FLAG; } elseif ($item['create_date'] >= $context['fresh']) { $suffix .= ' ' . NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= ' ' . UPDATED_FLAG; } // signal articles to be published if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) { $prefix .= DRAFT_FLAG; } // signal restricted and private articles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // introduction $introduction = ''; if (is_object($overlay)) { $introduction = $overlay->get_text('introduction', $item); } else { $introduction = $item['introduction']; } // the introductory text if ($introduction) { $suffix .= ' - ' . Codes::beautify_introduction($introduction); // link to description, if any if ($item['description']) { $suffix .= ' ' . Skin::build_link($url, MORE_IMG, 'more', i18n::s('View the page')) . ' '; } } // insert overlay data, if any if (is_object($overlay)) { $suffix .= $overlay->get_text('list', $item); } // details $details = array(); // the author if ($item['create_name'] != $item['edit_name']) { $details[] = sprintf(i18n::s('by %s, %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id'])); } else { $details[] = sprintf(i18n::s('by %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id'])); } // the last action $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']); // the number of hits if (Surfer::is_logged() && $item['hits'] > 1) { $details[] = Skin::build_number($item['hits'], i18n::s('hits')); } // info on related files if ($count = Files::count_for_anchor('article:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count); } // info on related links if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count); } // info on related comments if ($count = Comments::count_for_anchor('article:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count); } // rating if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) { $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // the main anchor link if (is_object($anchor)) { $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'section')); } // display all tags if ($item['tags']) { $details[] = '<span class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>'; } // combine in-line details if (count($details)) { $suffix .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>'; } // insert a suffix separator if (trim($suffix)) { $suffix = ' ' . $suffix; } // item summary $box .= $prefix . Skin::build_link($url, $title, 'article') . $suffix; // the icon to put in the left column if ($item['thumbnail_url']) { $icon = $item['thumbnail_url']; } elseif (is_callable(array($anchor, 'get_bullet_url'))) { $icon = $anchor->get_bullet_url(); } // build the complete HTML element if ($icon) { $icon = '<img src="' . $icon . '" alt="" title="' . encode_field(strip_tags($title)) . '" />'; // make it a clickable link $icon = Skin::build_link($url, $icon, 'basic'); // default icon } else { $icon = DECORATED_IMG; } // layout this item $list = array(array($box, $icon)); $items[] = array($item['score'], Skin::finalize_list($list, 'decorated')); } // end of processing SQL::free($result); return $items; }
/** * echo the site menu * * You can override this function into your skin */ public static function echo_menu() { global $context; // ensure normal conditions if (file_exists($context['path_to_root'] . 'parameters/switch.on') && is_callable(array('Articles', 'get')) && is_callable(array('Codes', 'beautify'))) { // use content of a named global page if ($item = Articles::get('menu')) { echo Skin::build_box(Codes::beautify_title($item['title']), Codes::beautify($item['description']), 'navigation', 'main_menu'); } } }
/** * list articles * * @param resource the SQL result * @return array * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ($url => $attributes) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // process all items in the list include_once $context['path_to_root'] . 'articles/article.php'; include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'locations/locations.php'; while ($item = SQL::fetch($result)) { // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // provide an absolute link $url = Articles::get_permalink($item); // build a title if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // time of last update $time = SQL::strtotime($item['edit_date']); // the section $section = ''; if ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) { $section = ucfirst(trim(strip_tags(Codes::beautify_title($anchor->get_title())))); } // the icon to use $icon = ''; if ($item['thumbnail_url']) { $icon = $item['thumbnail_url']; } elseif ($item['anchor'] && ($anchor = Anchors::get($item['anchor'])) && is_callable($anchor, 'get_bullet_url')) { $icon = $anchor->get_bullet_url(); } if ($icon) { $icon = $context['url_to_home'] . $context['url_to_root'] . $icon; } // the author(s) is an e-mail address, according to rss 2.0 spec $author = ''; if (isset($item['create_address'])) { $author .= $item['create_address']; } if (isset($item['create_name']) && trim($item['create_name'])) { $author .= ' (' . $item['create_name'] . ')'; } if (isset($item['edit_address']) && trim($item['edit_address']) && $item['create_address'] != $item['edit_address']) { if ($author) { $author .= ', '; } $author .= $item['edit_address']; if (isset($item['edit_name']) && trim($item['edit_name'])) { $author .= ' (' . $item['edit_name'] . ')'; } } // some introductory text for this article $article = new Article(); $article->load_by_content($item); $introduction = $article->get_teaser('teaser'); // warns on restricted access if (isset($item['active']) && $item['active'] != 'Y') { $introduction = '[' . i18n::c('Restricted to members') . '] ' . $introduction; } // fix references $introduction = preg_replace('/"\\//', '"' . $context['url_to_home'] . '/', $introduction); // the article content $description = ''; // other rss fields $extensions = array(); // the geolocation for this page, if any if ($location = Locations::locate_anchor('article:' . $item['id'])) { $extensions[] = '<georss:point>' . str_replace(',', ' ', $location) . '</georss:point>'; } // url for comments if (is_object($anchor)) { $extensions[] = '<comments>' . encode_link($context['url_to_home'] . $context['url_to_root'] . $anchor->get_url('comments')) . '</comments>'; } // count comments $comment_count = Comments::count_for_anchor('article:' . $item['id']); $extensions[] = '<slash:comments>' . $comment_count . "</slash:comments>"; // the comment post url $extensions[] = '<wfw:comment>' . encode_link($context['url_to_home'] . $context['url_to_root'] . Comments::get_url('article:' . $item['id'], 'service.comment')) . "</wfw:comment>"; // the comment Rss url $extensions[] = '<wfw:commentRss>' . encode_link($context['url_to_home'] . $context['url_to_root'] . Comments::get_url('article:' . $item['id'], 'feed')) . "</wfw:commentRss>"; // the trackback url $extensions[] = '<trackback:ping>' . encode_link($context['url_to_home'] . $context['url_to_root'] . 'links/trackback.php?anchor=' . urlencode('article:' . $item['id'])) . "</trackback:ping>"; // no trackback:about; // list all components for this item $items[$url] = array($time, $title, $author, $section, $icon, $introduction, $description, $extensions); } // end of processing SQL::free($result); return $items; }
/** * get the path bar for this anchor * * This function is used to build a path bar relative to the anchor. * For example, if you are displaying an article related to a section, * the path bar has to mention the section. You can use following code * to do that: * [php] * $anchor = Anchors::get($article['anchor']); * $context['path_bar'] = array_merge($context['path_bar'], $anchor->get_path_bar()); * [/php] * * To be overloaded into derived class * * @return an array of $url => $label */ function get_path_bar() { global $context; // no item bound if (!isset($this->item['id'])) { return NULL; } // get the parent if (!isset($this->anchor)) { $this->anchor = Anchors::get($this->item['anchor']); } // the parent level $parent = array(); if (is_object($this->anchor)) { $parent = $this->anchor->get_path_bar(); } // this item $url = $this->get_permalink(); $label = Codes::beautify_title($this->get_title()); $path = array_merge($parent, array($url => $label)); // return the result return $path; }
/** * 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; }
/** * 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)) { // get the anchor for this file if ($item['anchor']) { $anchor = Anchors::get($item['anchor']); } // download the file directly $url = $context['url_to_home'] . $context['url_to_root'] . Files::get_url($item['id'], 'fetch', $item['file_name']); // time of last update $time = SQL::strtotime($item['edit_date']); // the title as the label if ($item['title']) { $label = Codes::beautify_title($item['title']) . ' (' . str_replace(array('%20', '-', '_'), ' ', $item['file_name']) . ')'; } else { $label = str_replace(array('%20', '-', '_'), ' ', $item['file_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); // always add a link to container if (is_object($anchor)) { if ($description) { $description .= BR; } $description .= sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), $anchor->get_title(), 'basic')); } // 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['file_name']); $extensions[] = '<enclosure url="' . $context['url_to_home'] . $context['url_to_root'] . Files::get_path($item['anchor']) . '/' . $item['file_name'] . '"' . ' length="' . $item['file_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; }
/** * layout one recent article * * @param array the article * @return an array ($prefix, $label, $suffix) **/ function layout_recent($item) { global $context; // permalink $url = Articles::get_permalink($item); // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // reset everything $prefix = $suffix = ''; // signal restricted and private articles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // rating if ($item['rating_count']) { $suffix .= Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // the introductory text $introduction = ''; if (is_object($overlay)) { $introduction = $overlay->get_text('introduction', $item); } elseif ($item['introduction']) { $introduction = $item['introduction']; } if ($introduction) { $suffix .= ' - ' . Codes::beautify_introduction($introduction); } // other details $details = array(); // the author $author = ''; if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { $author = sprintf(i18n::s('by %s'), $item['create_name']) . ' '; } // date $details[] = $author . Skin::build_date($item['publish_date']); // info on related files if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d file', '%d files', $count), $count), 'basic'); } // info on related comments $link = Comments::get_url('article:' . $item['id'], 'list'); if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = Skin::build_link($link, sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'basic'); } // discuss if (Comments::allow_creation($item, $anchor)) { $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), i18n::s('Discuss'), 'basic'); } // info on related links if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d link', '%d links', $count), $count), 'basic'); } // append a menu $suffix .= Skin::finalize_list($details, 'menu'); // display all tags if ($item['tags']) { $suffix .= ' <p class="tags" style="margin-top: 3px;">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</p>'; } // insert an array of links return array($prefix, $title, $suffix); }
/** * list sections as topics in a forum * * @param resource the SQL result * @return string the rendered text **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // output as a string $text = ''; // build a list of sections $family = ''; $first = TRUE; while ($item = SQL::fetch($result)) { // change the family if ($item['family'] != $family) { $family = $item['family']; // close last table only if a section has been already listed if (!$first) { $text .= Skin::table_suffix(); } // show the family $text .= '<h2><span>' . $family . ' </span></h2>' . "\n" . Skin::table_prefix('yabb') . Skin::table_row(array(i18n::s('Board'), 'center=' . i18n::s('Topics'), i18n::s('Last post')), 'header'); } elseif ($first) { $text .= Skin::table_prefix('yabb'); $text .= Skin::table_row(array(i18n::s('Board'), 'center=' . i18n::s('Topics'), i18n::s('Last post')), 'header'); } // done with this case $first = FALSE; // reset everything $prefix = $label = $suffix = $icon = ''; // signal restricted and private sections if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // indicate the id in the hovering popup $hover = i18n::s('View the section'); if (Surfer::is_member()) { $hover .= ' [section=' . $item['id'] . ']'; } // the url to view this item $url = Sections::get_permalink($item); // use the title as a link to the page $title =& Skin::build_link($url, Codes::beautify_title($item['title']), 'basic', $hover); // also use a clickable thumbnail, if any if ($item['thumbnail_url']) { $prefix = Skin::build_link($url, '<img src="' . $item['thumbnail_url'] . '" alt="" title="' . encode_field($hover) . '" class="left_image" />', 'basic', $hover) . $prefix; } // flag sections updated recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $suffix = EXPIRED_FLAG . ' '; } elseif ($item['create_date'] >= $context['fresh']) { $suffix = NEW_FLAG . ' '; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix = UPDATED_FLAG . ' '; } // board introduction if ($item['introduction']) { $suffix .= '<br style="clear: none;" />' . Codes::beautify_introduction($item['introduction']); } // more details $details = ''; $more = array(); // board moderators if ($moderators = Sections::list_editors_by_name($item, 0, 7, 'comma5')) { $more[] = sprintf(i18n::ns('Moderator: %s', 'Moderators: %s', count($moderators)), $moderators); } // children boards if ($children =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, COMPACT_LIST_SIZE, 'comma')) { $more[] = sprintf(i18n::ns('Child board: %s', 'Child boards: %s', count($children)), Skin::build_list($children, 'comma')); } // as a compact list if (count($more)) { $details .= '<ul class="compact">'; foreach ($more as $list_item) { $details .= '<li>' . $list_item . '</li>' . "\n"; } $details .= '</ul>' . "\n"; } // all details if ($details) { $details = BR . '<span class="details">' . $details . "</span>\n"; } // count posts here, and in children sections $anchors = Sections::get_branch_at_anchor('section:' . $item['id']); if (!($count = Articles::count_for_anchor($anchors))) { $count = 0; } // get last post $last_post = '--'; $article =& Articles::get_newest_for_anchor($anchors, TRUE); if ($article['id']) { // flag articles updated recently if ($article['expiry_date'] > NULL_DATE && $article['expiry_date'] <= $context['now']) { $flag = EXPIRED_FLAG . ' '; } elseif ($article['create_date'] >= $context['fresh']) { $flag = NEW_FLAG . ' '; } elseif ($article['edit_date'] >= $context['fresh']) { $flag = UPDATED_FLAG . ' '; } else { $flag = ''; } // title $last_post = Skin::build_link(Articles::get_permalink($article), Codes::beautify_title($article['title']), 'article'); // last editor if ($article['edit_date']) { // find a name, if any if ($article['edit_name']) { // label the action if (isset($article['edit_action'])) { $action = Anchors::get_action_label($article['edit_action']); } else { $action = i18n::s('edited'); } // name of last editor $user = sprintf(i18n::s('%s by %s'), $action, Users::get_link($article['edit_name'], $article['edit_address'], $article['edit_id'])); } $last_post .= $flag . BR . '<span class="tiny">' . $user . ' ' . Skin::build_date($article['edit_date']) . '</span>'; } } // this is another row of the output $text .= Skin::table_row(array($prefix . $title . $suffix . $details, 'center=' . $count, $last_post)); } // end of processing SQL::free($result); $text .= Skin::table_suffix(); return $text; }