Ejemplo n.º 1
0
 /**
  * list users
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!($delta = SQL::count($result))) {
         return $text;
     }
     // flag idle users
     $idle = gmstrftime('%Y-%m-%d %H:%M:%S', time() - 600);
     // process all items in the list
     $count = 0;
     $items = array();
     while ($item = SQL::fetch($result)) {
         // url to view the user
         $url = Users::get_permalink($item);
         // initialize variables
         $prefix = $suffix = '';
         // signal restricted and private users
         if (isset($item['active']) && $item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif (isset($item['active']) && $item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // signal locked profiles
         if (isset($item['capability']) && $item['capability'] == '?') {
             $prefix .= EXPIRED_FLAG;
         }
         // item title
         if (isset($item['full_name']) && $item['full_name']) {
             $label = ucfirst(Skin::strip($item['full_name'], 10));
             $hover = $item['nick_name'];
         } else {
             $label = ucfirst(Skin::strip($item['nick_name'], 10));
             $hover = $item['full_name'];
         }
         // flag idle users
         if (!isset($item['click_date']) || $item['click_date'] < $idle) {
             $class = 'idle user';
         } else {
             $class = 'user';
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, $class, NULL, $hover);
         // provide only some results
         if (++$count >= 5) {
             break;
         }
     }
     // end of processing
     SQL::free($result);
     // turn this to some text
     $text = Skin::build_list($items, 'comma');
     // some indications on the number of connections
     if ($delta -= $count) {
         $text .= ', ...';
     }
     return $text;
 }
Ejemplo n.º 2
0
 /**
  * list servers
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // initialize variables
         $prefix = $suffix = $icon = '';
         // the url to view this item
         $url = Servers::get_url($item['id']);
         // use the title as a label
         $label = Skin::strip($item['title'], 10);
         // flag files uploaded recently
         if ($item['edit_date'] >= $context['fresh']) {
             $prefix = NEW_FLAG . $prefix;
         }
         // description
         if ($item['description']) {
             $suffix .= ' ' . ucfirst(trim($item['description']));
         }
         // the menu bar for associates and poster
         if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) {
             $menu = array(Servers::get_url($item['id'], 'edit') => i18n::s('Edit'), Servers::get_url($item['id'], 'delete') => i18n::s('Delete'));
             $suffix .= ' ' . Skin::build_list($menu, 'menu');
         }
         // add a separator
         if ($suffix) {
             $suffix = ' - ' . $suffix;
         }
         // append details to the suffix
         $suffix .= BR . '<span class="details">';
         // details
         $details = array();
         // item poster
         if ($item['edit_name']) {
             $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
         }
         // the edition date
         $details[] = Skin::build_date($item['edit_date']);
         // all details
         if (count($details)) {
             $suffix .= ucfirst(implode(', ', $details)) . "\n";
         }
         // end of details
         $suffix .= '</span>';
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'server', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Ejemplo n.º 3
0
Archivo: thread.php Proyecto: rair/yacs
 /**
  * list participants
  *
  * @see overlays/overlay.php
  *
  * @param array the hosting record
  * @return some HTML to be inserted into the resulting page
  */
 function &get_list_text($host = NULL)
 {
     global $context;
     // we return some text
     $text = '';
     $to_avoid = NULL;
     if ($id = Surfer::get_id()) {
         $to_avoid = 'user:'******'article:' . $host['id'], 0, USERS_LIST_SIZE, 'comma', $to_avoid)) {
         $text = '<p class="details">' . sprintf(i18n::s('with %s'), Skin::build_list($friends, 'comma')) . '</p>';
     }
     return $text;
 }
Ejemplo n.º 4
0
 public function render($matches)
 {
     $count = isset($matches[0]) ? $matches[0] : 20;
     // sanity check
     if (!(int) $count) {
         $count = 20;
     }
     // query the database and layout that stuff
     if (!($text = Members::list_categories_by_count_for_anchor(NULL, 0, $count, 'cloud'))) {
         $text = '<p>' . i18n::s('No item has been found.') . '</p>';
     }
     // we have an array to format
     if (is_array($text)) {
         $text = Skin::build_list($text, '2-columns');
     }
     // job done
     return $text;
 }
Ejemplo n.º 5
0
 /**
  * list articles as newspaper do
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // build a list of articles
     $others = array();
     $item_count = 0;
     include_once $context['path_to_root'] . 'comments/comments.php';
     while ($item = SQL::fetch($result)) {
         // permalink
         $url = Articles::get_permalink($item);
         // next item
         $item_count += 1;
         // section opening
         if ($item_count == 1) {
             $text .= '<div class="newest">' . "\n";
         } elseif ($item_count == 2) {
             $text .= '<div class="recent">' . "\n";
         }
         // layout first article
         if ($item_count == 1) {
             $text .= $this->layout_first($item);
             // layout newest articles
         } elseif ($item_count <= 4) {
             // the style to apply
             switch ($item_count) {
                 case 2:
                     $text .= '<div class="west">';
                     break;
                 case 3:
                     $text .= '<div class="center">';
                     break;
                 case 4:
                     $text .= '<div class="east">';
                     break;
             }
             $text .= $this->layout_newest($item) . '</div>';
             // layout recent articles
         } else {
             $others[$url] = $this->layout_recent($item);
         }
         // close newest
         if ($item_count == 1) {
             $text .= '<br style="clear: left;" /></div>' . "\n";
         } elseif ($item_count == 4) {
             $text .= '<br style="clear: left;" /></div>' . "\n";
         }
     }
     // not enough items in the database to fill the south; close it here
     if ($item_count == 2 || $item_count == 3) {
         $text .= '</div>' . "\n";
     }
     // build the list of other articles
     if (count($others)) {
         // make box
         $text .= Skin::build_box(i18n::s('Previous pages'), Skin::build_list($others, 'decorated'));
     }
     // end of processing
     SQL::free($result);
     return $text;
 }
Ejemplo n.º 6
0
 /**
  * render a compact list of voted pages
  *
  * @param string the anchor (e.g. 'section:123')
  * @param string layout to use
  * @return string the rendered text
  **/
 public static function render_voted($anchor = '', $layout = 'simple')
 {
     global $context;
     // we return some text;
     $text = '';
     // number of items to display
     $count = COMPACT_LIST_SIZE;
     if (($position = strpos($anchor, ',')) !== FALSE) {
         $count = (int) trim(substr($anchor, $position + 1));
         if (!$count) {
             $count = COMPACT_LIST_SIZE;
         }
         $anchor = trim(substr($anchor, 0, $position));
     }
     // scope is limited to current surfer
     if ($anchor == 'self' && Surfer::get_id()) {
         $anchor = 'user:'******'section:') === 0) {
         // look at this branch of the content tree
         $anchors = Sections::get_branch_at_anchor($anchor);
         // query the database and layout that stuff
         $text =& Articles::list_for_anchor_by('rating', $anchors, 0, $count, $layout);
         // scope is limited to pages of one surfer
     } elseif (strpos($anchor, 'user:'******'rating', substr($anchor, 5), 0, $count, $layout);
     } else {
         $text =& Articles::list_by('rating', 0, $count, $layout);
     }
     // we have an array to format
     if (is_array($text)) {
         $text =& Skin::build_list($text, $layout);
     }
     // job done
     return $text;
 }
Ejemplo n.º 7
0
Archivo: view.php Proyecto: rair/yacs
     $context['page_details'] .= '<p class="details">' . ucfirst(implode(', ', $details)) . "</p>\n";
 }
 // insert anchor prefix
 if (is_object($anchor)) {
     $text .= $anchor->get_prefix();
 }
 // main url
 if ($item['main_url']) {
     $text .= '<p>' . sprintf(i18n::s('Main URL: %s'), Skin::build_link($item['main_url'], NULL, 'external')) . "</p>\n";
 }
 // a section for remote services
 $text .= Skin::build_block(i18n::s('Services accessed remotely'), 'subtitle');
 // feed submission
 if ($item['submit_feed'] == 'Y') {
     $menu = array(Servers::get_url($item['id'], 'test') => i18n::s('Test feed'));
     $label = sprintf(i18n::s('News published at this server at %s - %s are fetched periodically'), Skin::build_link($item['feed_url'], NULL, 'external'), Skin::build_list($menu, 'menu'));
     if (is_object($anchor)) {
         $label .= BR . sprintf(i18n::s('and aggregated locally at %s'), Skin::build_link($anchor->get_url(), $anchor->get_title(), 'section'));
     }
 } else {
     $label = i18n::s('Do not check news from this server.');
 }
 $text .= '<p>' . $label . "</p>\n";
 // ping submission
 if ($item['submit_ping'] == 'Y') {
     $label = sprintf(i18n::s('This server has to be pinged on updates, by using XML-RPC calls <code>weblogUpdates.ping</code> at %s'), Skin::build_link($item['ping_url']));
 } else {
     $label = i18n::s('Updates are not transmitted to this server.');
 }
 $text .= '<p>' . $label . "</p>\n";
 // monitoring
Ejemplo n.º 8
0
 /**
  * embed an interactive object
  *
  * The id designates the target file.
  * It can also include width and height of the target canvas, as in: '12, 100%, 250px'
  *
  * @param string id of the target file
  * @return string the rendered string
  **/
 public static function render_embed($id)
 {
     global $context;
     // split parameters
     $attributes = preg_split("/\\s*,\\s*/", $id, 4);
     $id = $attributes[0];
     // get the file
     if (!($item = Files::get($id))) {
         $output = '[embed=' . $id . ']';
         return $output;
     }
     // stream in a separate page
     if (isset($attributes[1]) && preg_match('/window/i', $attributes[1])) {
         if (!isset($attributes[2])) {
             $attributes[2] = i18n::s('Play in a separate window');
         }
         $output = '<a href="' . $context['url_to_home'] . $context['url_to_root'] . Files::get_url($item['id'], 'stream', $item['file_name']) . '" onclick="window.open(this.href); return false;" class="button"><span>' . $attributes[2] . '</span></a>';
         return $output;
     }
     // file extension
     $extension = strtolower(substr($item['file_name'], -3));
     // set a default size
     if (!isset($attributes[1])) {
         if (!strcmp($extension, 'gan')) {
             $attributes[1] = '98%';
         } elseif (!strcmp($extension, 'mm') && isset($context['skins_freemind_canvas_width'])) {
             $attributes[1] = $context['skins_freemind_canvas_width'];
         } else {
             $attributes[1] = 480;
         }
     }
     if (!isset($attributes[2])) {
         if (!strcmp($extension, 'gan')) {
             $attributes[2] = '300px';
         } elseif (!strcmp($extension, 'mm') && isset($context['skins_freemind_canvas_height'])) {
             $attributes[2] = $context['skins_freemind_canvas_height'];
         } else {
             $attributes[2] = 360;
         }
     }
     // object attributes
     $width = $attributes[1];
     $height = $attributes[2];
     $flashvars = '';
     if (isset($attributes[3])) {
         $flashvars = $attributes[3];
     }
     // rendering depends on file extension
     switch ($extension) {
         // stream a video
         case '3gp':
         case 'flv':
         case 'm4v':
         case 'mov':
         case 'mp4':
             // a flash player to stream a flash video
             $flvplayer_url = $context['url_to_home'] . $context['url_to_root'] . 'included/browser/player_flv_maxi.swf';
             // file is elsewhere
             if (isset($item['file_href']) && $item['file_href']) {
                 $url = $item['file_href'];
             } else {
                 $url = $context['url_to_home'] . $context['url_to_root'] . Files::get_url($item['id'], 'fetch', $item['file_name']);
             }
             // pass parameters to the player
             if ($flashvars) {
                 $flashvars = str_replace('autostart=true', 'autoplay=1', $flashvars) . '&';
             }
             $flashvars .= 'width=' . $width . '&height=' . $height;
             // if there is a static image for this video, use it
             if (isset($item['icon_url']) && $item['icon_url']) {
                 $flashvars .= '&startimage=' . urlencode($item['icon_url']);
             }
             // if there is a subtitle file for this video, use it
             if (isset($item['file_name']) && ($srt = 'files/' . str_replace(':', '/', $item['anchor']) . '/' . str_replace('.' . $extension, '.srt', $item['file_name'])) && file_exists($context['path_to_root'] . $srt)) {
                 $flashvars .= '&srt=1&srturl=' . urlencode($context['url_to_home'] . $context['url_to_root'] . $srt);
             }
             // if there is a logo file in the skin, use it
             Skin::define_img_href('FLV_IMG_HREF', 'codes/flvplayer_logo.png', '');
             if (FLV_IMG_HREF) {
                 $flashvars .= '&top1=' . urlencode(FLV_IMG_HREF . '|10|10');
             }
             // rely on Flash
             if (Surfer::has_flash()) {
                 // the full object is built in Javascript --see parameters at http://flv-player.net/players/maxi/documentation/
                 $output = '<div id="flv_' . $item['id'] . '" class="no_print">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n";
                 Page::insert_script('var flashvars = { flv:"' . $url . '", ' . str_replace(array('&', '='), array('", ', ':"'), $flashvars) . '", autoload:0, margin:1, showiconplay:1, playeralpha:50, iconplaybgalpha:30, showfullscreen:1, showloading:"always", ondoubleclick:"fullscreen" }' . "\n" . 'var params = { allowfullscreen: "true", allowscriptaccess: "always" }' . "\n" . 'var attributes = { id: "file_' . $item['id'] . '", name: "file_' . $item['id'] . '"}' . "\n" . 'swfobject.embedSWF("' . $flvplayer_url . '", "flv_' . $item['id'] . '", "' . $width . '", "' . $height . '", "9", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", flashvars, params);' . "\n");
                 // native support
             } else {
                 // <video> is HTML5, <object> is legacy
                 $output = '<video width="' . $width . '" height="' . $height . '" autoplay="" controls="" src="' . $url . '" >' . "\n" . '	<object width="' . $width . '" height="' . $height . '" data="' . $url . '" type="' . Files::get_mime_type($item['file_name']) . '">' . "\n" . '		<param value="' . $url . '" name="movie" />' . "\n" . '		<param value="true" name="allowFullScreen" />' . "\n" . '		<param value="always" name="allowscriptaccess" />' . "\n" . '		<a href="' . $url . '">No video playback capabilities, please download the file</a>' . "\n" . '	</object>' . "\n" . '</video>' . "\n";
             }
             // job done
             return $output;
             // a ganttproject timeline
         // a ganttproject timeline
         case 'gan':
             // where the file is
             $path = Files::get_path($item['anchor']) . '/' . rawurlencode($item['file_name']);
             // we actually use a transformed version of the file
             $cache_id = Cache::hash($path) . '.xml';
             // apply the transformation
             if (!file_exists($context['path_to_root'] . $cache_id) || filemtime($context['path_to_root'] . $cache_id) < filemtime($context['path_to_root'] . $path) || !($text = Safe::file_get_contents($context['path_to_root'] . $cache_id))) {
                 // transform from GanttProject to SIMILE Timeline
                 $text = Files::transform_gan_to_simile($path);
                 // put in cache
                 Safe::file_put_contents($cache_id, $text);
             }
             // load the SIMILE Timeline javascript library in shared/global.php
             $context['javascript']['timeline'] = TRUE;
             // cache would kill the loading of the library
             cache::poison();
             // 1 week ago
             $now = gmdate('M d Y H:i:s', time() - 7 * 24 * 60 * 60);
             // load the right file
             $output = '<div id="gantt" style="height: ' . $height . '; width: ' . $width . '; border: 1px solid #aaa; font-family: Trebuchet MS, Helvetica, Arial, sans serif; font-size: 8pt"></div>' . "\n";
             Page::insert_script('var simile_handle;' . "\n" . 'function onLoad() {' . "\n" . '  var eventSource = new Timeline.DefaultEventSource();' . "\n" . '	var theme = Timeline.ClassicTheme.create();' . "\n" . '            theme.event.bubble.width = 350;' . "\n" . '            theme.event.bubble.height = 300;' . "\n" . '  var bandInfos = [' . "\n" . '    Timeline.createBandInfo({' . "\n" . '        eventSource:    eventSource,' . "\n" . '        date:           "' . $now . '",' . "\n" . '        width:          "80%",' . "\n" . '        intervalUnit:   Timeline.DateTime.WEEK,' . "\n" . '        intervalPixels: 200,' . "\n" . '		  theme:          theme,' . "\n" . '        layout:         "original"  // original, overview, detailed' . "\n" . '    }),' . "\n" . '    Timeline.createBandInfo({' . "\n" . '        showEventText: false,' . "\n" . '        trackHeight: 0.5,' . "\n" . '        trackGap: 0.2,' . "\n" . '        eventSource:    eventSource,' . "\n" . '        date:           "' . $now . '",' . "\n" . '        width:          "20%",' . "\n" . '        intervalUnit:   Timeline.DateTime.MONTH,' . "\n" . '        intervalPixels: 50' . "\n" . '    })' . "\n" . '  ];' . "\n" . '  bandInfos[1].syncWith = 0;' . "\n" . '  bandInfos[1].highlight = true;' . "\n" . '  bandInfos[1].eventPainter.setLayout(bandInfos[0].eventPainter.getLayout());' . "\n" . '  simile_handle = Timeline.create(document.getElementById("gantt"), bandInfos, Timeline.HORIZONTAL);' . "\n" . '	simile_handle.showLoadingMessage();' . "\n" . '  Timeline.loadXML("' . $context['url_to_home'] . $context['url_to_root'] . $cache_id . '", function(xml, url) { eventSource.loadXML(xml, url); });' . "\n" . '	simile_handle.hideLoadingMessage();' . "\n" . '}' . "\n" . "\n" . 'var resizeTimerID = null;' . "\n" . 'function onResize() {' . "\n" . '    if (resizeTimerID == null) {' . "\n" . '        resizeTimerID = window.setTimeout(function() {' . "\n" . '            resizeTimerID = null;' . "\n" . '            simile_handle.layout();' . "\n" . '        }, 500);' . "\n" . '    }' . "\n" . '}' . "\n" . "\n" . '// observe page major events' . "\n" . '$(document).ready( onLoad);' . "\n" . '$(window).resize(onResize);' . "\n");
             // job done
             return $output;
             // a Freemind map
         // a Freemind map
         case 'mm':
             // if we have an external reference, use it
             if (isset($item['file_href']) && $item['file_href']) {
                 $target_href = $item['file_href'];
                 // else redirect to ourself
             } else {
                 // ensure a valid file name
                 $file_name = utf8::to_ascii($item['file_name']);
                 // where the file is
                 $path = Files::get_path($item['anchor']) . '/' . rawurlencode($item['file_name']);
                 // map the file on the regular web space
                 $url_prefix = $context['url_to_home'] . $context['url_to_root'];
                 // redirect to the actual file
                 $target_href = $url_prefix . $path;
             }
             // allow several viewers to co-exist in the same page
             static $freemind_viewer_index;
             if (!isset($freemind_viewer_index)) {
                 $freemind_viewer_index = 1;
             } else {
                 $freemind_viewer_index++;
             }
             // load flash player
             $url = $context['url_to_home'] . $context['url_to_root'] . 'included/browser/visorFreemind.swf';
             // variables
             $flashvars = 'initLoadFile=' . $target_href . '&openUrl=_self';
             $output = '<div id="freemind_viewer_' . $freemind_viewer_index . '">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n";
             Page::insert_script('var params = {};' . "\n" . 'params.base = "' . dirname($url) . '/";' . "\n" . 'params.quality = "high";' . "\n" . 'params.wmode = "transparent";' . "\n" . 'params.menu = "false";' . "\n" . 'params.flashvars = "' . $flashvars . '";' . "\n" . 'swfobject.embedSWF("' . $url . '", "freemind_viewer_' . $freemind_viewer_index . '", "' . $width . '", "' . $height . '", "6", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", false, params);' . "\n");
             // offer to download a copy of the map
             $menu = array($target_href => i18n::s('Browse this map with Freemind'));
             // display menu commands below the viewer
             $output .= Skin::build_list($menu, 'menu_bar');
             // job done
             return $output;
             // native flash
         // native flash
         case 'swf':
             // where to get the file
             if (isset($item['file_href']) && $item['file_href']) {
                 $url = $item['file_href'];
             } else {
                 $url = $context['url_to_home'] . $context['url_to_root'] . 'files/' . str_replace(':', '/', $item['anchor']) . '/' . rawurlencode($item['file_name']);
             }
             $output = '<div id="swf_' . $item['id'] . '" class="no_print">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n";
             Page::insert_script('var params = {};' . "\n" . 'params.base = "' . dirname($url) . '/";' . "\n" . 'params.quality = "high";' . "\n" . 'params.wmode = "transparent";' . "\n" . 'params.allowfullscreen = "true";' . "\n" . 'params.allowscriptaccess = "always";' . "\n" . 'params.flashvars = "' . $flashvars . '";' . "\n" . 'swfobject.embedSWF("' . $url . '", "swf_' . $item['id'] . '", "' . $width . '", "' . $height . '", "6", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", false, params);' . "\n");
             return $output;
             // link to file page
         // link to file page
         default:
             // link label
             $text = Skin::strip($item['title'] ? $item['title'] : str_replace('_', ' ', $item['file_name']));
             // make a link to the target page
             $url = Files::get_permalink($item);
             // return a complete anchor
             $output =& Skin::build_link($url, $text);
             return $output;
     }
 }
Ejemplo n.º 9
0
Archivo: index.php Proyecto: rair/yacs
    // see also
    $lines = array();
    $lines[] = Skin::build_link('categories/', i18n::s('Categories'));
    $lines[] = Skin::build_link('search.php', i18n::s('Search'));
    $lines[] = Skin::build_link('help/', i18n::s('Help index'));
    $lines[] = Skin::build_link('query.php', i18n::s('Contact'));
    $text .= Skin::build_box(i18n::s('See also'), Skin::finalize_list($lines, 'compact'), 'boxes');
    // list monthly publications in an extra box
    $anchor = Categories::get(i18n::c('monthly'));
    if (isset($anchor['id']) && ($items = Categories::list_by_date_for_anchor('category:' . $anchor['id'], 0, COMPACT_LIST_SIZE, 'compact'))) {
        $text .= Skin::build_box($anchor['title'], Skin::build_list($items, 'compact'), 'boxes') . "\n";
    }
    // side boxes for related categories, if any
    if ($categories = Categories::list_by_date_for_display('section:index', 0, 7, 'raw')) {
        foreach ($categories as $id => $attributes) {
            // link to the category page from the box title
            $label =& Skin::build_box_title(Skin::strip($attributes['title']), Categories::get_permalink($attributes), i18n::s('View the category'));
            // box content
            if ($items =& Members::list_articles_by_date_for_anchor('category:' . $id, 0, COMPACT_LIST_SIZE, 'compact')) {
                $text .= Skin::build_box($label, Skin::build_list($items, 'compact'), 'boxes') . "\n";
            }
        }
    }
    // save, whatever change, for 5 minutes
    Cache::put($cache_id, $text, 'stable', 300);
}
$context['components']['boxes'] = $text;
// referrals, if any
$context['components']['referrals'] = Skin::build_referrals('sections/index.php');
// render the skin
render_skin();
Ejemplo n.º 10
0
 /**
  * list sections as topics in a forum
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // 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 . '&nbsp;</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;
 }
Ejemplo n.º 11
0
Archivo: review.php Proyecto: rair/yacs
    $context['text'] .= Skin::build_block(i18n::s('Most recent members'), 'title');
    if (is_array($rows)) {
        $context['text'] .= Skin::build_list($rows, 'decorated');
    } else {
        $context['text'] .= $rows;
    }
}
// oldest posts, but only to associates
if (Surfer::is_associate() && ($rows = Users::list_by_post_date())) {
    $context['text'] .= Skin::build_block(i18n::s('Oldest posts'), 'title');
    $context['text'] .= '<p>' . i18n::s('Users who have never contributed are not listed at all.') . '</p>' . "\n";
    if (is_array($rows)) {
        $context['text'] .= Skin::build_list($rows, 'decorated');
    } else {
        $context['text'] .= $rows;
    }
}
// oldest logins, but only to associates
if (Surfer::is_associate() && ($rows = Users::list_by_login_date())) {
    $context['text'] .= Skin::build_block(i18n::s('Oldest logins'), 'title');
    $context['text'] .= '<p>' . i18n::s('Users who have never been authenticated are not listed at all.') . '</p>' . "\n";
    if (is_array($rows)) {
        $context['text'] .= Skin::build_list($rows, 'decorated');
    } else {
        $context['text'] .= $rows;
    }
}
// the menu bar for this page
$context['page_tools'][] = Skin::build_link('users/', i18n::s('People'));
// render the skin
render_skin();
Ejemplo n.º 12
0
Archivo: index.php Proyecto: rair/yacs
        Cache::put($cache_id, $text, 'categories');
    }
    $context['text'] .= $text;
}
// page tools
if (Surfer::is_associate()) {
    $context['page_tools'][] = Skin::build_link('categories/edit.php', i18n::s('Add a category'));
    $context['page_tools'][] = Skin::build_link('help/populate.php', i18n::s('Content Assistant'));
    $context['page_tools'][] = Skin::build_link('categories/check.php', i18n::s('Maintenance'));
}
// display extra information
$cache_id = 'categories/index.php#extra';
if (!($text = Cache::get($cache_id))) {
    // see also
    $links = array('categories/cloud.php' => i18n::s('Cloud of tags'), 'sections/' => i18n::s('Site map'), 'search.php' => i18n::s('Search'), 'help/' => i18n::s('Help index'), 'query.php' => i18n::s('Contact'));
    $text .= Skin::build_box(i18n::s('See also'), Skin::build_list($links, 'compact'), 'boxes');
    // side bar with the list of most popular articles, if this server is well populated
    if ($stats['count'] > CATEGORIES_PER_PAGE) {
        if ($items = Categories::list_by_hits(0, COMPACT_LIST_SIZE, 'compact')) {
            $title = i18n::s('Popular');
            $text .= Skin::build_box($title, Skin::build_list($items, 'compact'), 'boxes');
        }
    }
    // cache, whatever change, for 5 minutes
    Cache::put($cache_id, $text, 'stable', 300);
}
$context['components']['boxes'] = $text;
// referrals, if any
$context['components']['referrals'] = Skin::build_referrals('categories/index.php');
// render the skin
render_skin();
Ejemplo n.º 13
0
Archivo: review.php Proyecto: rair/yacs
}
// list future articles
if (Surfer::is_associate() && ($rows =& Articles::list_by('future', 0, 5))) {
    if (is_array($rows)) {
        $rows = Skin::build_list($rows, 'decorated');
    }
    $context['text'] .= Skin::build_box(i18n::s('Future articles'), $rows, 'header1', 'future');
}
// list dead articles
if (Surfer::is_associate() && ($rows =& Articles::list_by('expiry', 0, 10, 'hits'))) {
    if (is_array($rows)) {
        $rows = Skin::build_list($rows, 'decorated');
    }
    $context['text'] .= Skin::build_box(i18n::s('Dead articles'), $rows, 'header1', 'expired');
}
// list the oldest published articles, that have to be validated again
if (Surfer::is_associate() && ($rows =& Articles::list_by('review', 0, 10, 'review'))) {
    if (is_array($rows)) {
        $rows = Skin::build_list($rows, 'decorated');
    }
    $context['text'] .= Skin::build_box(i18n::s('Oldest articles'), $rows, 'header1', 'oldest');
}
// list articles with very few hits
if (Surfer::is_associate() && ($rows =& Articles::list_by('unread', 0, 10, 'hits'))) {
    if (is_array($rows)) {
        $rows = Skin::build_list($rows, 'decorated');
    }
    $context['text'] .= Skin::build_box(i18n::s('Less read articles'), $rows, 'header1', 'unread');
}
// render the skin
render_skin();
Ejemplo n.º 14
0
        } elseif (is_string($items)) {
            $box['text'] .= $items;
        }
        // navigation commands for links
        $home = Sections::get_permalink($item);
        $prefix = Sections::get_url($item['id'], 'navigate', 'links');
        $box['bar'] = array_merge($box['bar'], Skin::navigate($home, $prefix, $count, LINKS_PER_PAGE, $zoom_index));
    }
    // new links are allowed -- check option 'with_links'
    if (Links::allow_creation($item, $anchor, 'section')) {
        Skin::define_img('LINKS_ADD_IMG', 'links/add.gif');
        $box['bar'] += array('links/edit.php?anchor=' . urlencode('section:' . $item['id']) => LINKS_ADD_IMG . i18n::s('Add a link'));
    }
    // integrate commands
    if (count($box['bar'])) {
        $box['text'] = Skin::build_list($box['bar'], 'menu_bar') . $box['text'];
    }
    // there is some box content
    if (trim($box['text'])) {
        $attachments .= Skin::build_box(i18n::s('Links'), $box['text'], 'header1', 'links');
    }
}
// display in a separate panel
if (trim($attachments)) {
    $label = i18n::s('Attachments');
    if ($attachments_count) {
        $label .= ' (' . $attachments_count . ')';
    }
    $panels[] = array('attachments', $label, 'attachments_panel', $attachments);
}
//
Ejemplo n.º 15
0
 /**
  * dynamically generate the page
  *
  * @see skins/index.php
  */
 function send_body()
 {
     global $context;
     // populate tables for servers
     if (is_readable('../servers/populate.php')) {
         include_once '../servers/populate.php';
     }
     // splash
     echo '<h3>' . i18n::s('What do you want to do now?') . '</h3>';
     // follow-up commands
     $menu = array();
     $menu = array_merge($menu, array('servers/' => i18n::s('Servers')));
     $menu = array_merge($menu, array('help/populate.php' => i18n::s('Launch the Content Assistant again')));
     $menu = array_merge($menu, array('control/' => i18n::s('Control Panel')));
     echo Skin::build_list($menu, 'menu_bar');
     // new content has been created
     Logger::remember('help/populate.php: content assistant has created new content');
 }
Ejemplo n.º 16
0
 /**
  * list sections as topics in a forum
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // layout in a table
     $text = Skin::table_prefix('wide');
     // 'even' is used for title rows, 'odd' for detail rows
     $class_title = 'odd';
     $class_detail = 'even';
     // build a list of sections
     $family = '';
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // change the family
         if ($item['family'] != $family) {
             $family = $item['family'];
             // show the family
             $text .= Skin::table_suffix() . '<h2><span>' . $family . '&nbsp;</span></h2>' . "\n" . Skin::table_prefix('wide');
         }
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'section:' . $item['id']);
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // reset everything
         $prefix = $label = $suffix = $icon = '';
         // signal restricted and private sections
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // indicate the id in the hovering popup
         $hover = i18n::s('View the section');
         if (Surfer::is_member()) {
             $hover .= ' [section=' . $item['id'] . ']';
         }
         // the url to view this item
         $url = Sections::get_permalink($item);
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // use the title as a link to the page
         $title =& Skin::build_link($url, $title, 'basic', $hover);
         // flag sections updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $suffix = EXPIRED_FLAG . ' ';
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix = NEW_FLAG . ' ';
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix = UPDATED_FLAG . ' ';
         }
         // this is another row of the output
         $text .= '<tr class="' . $class_title . '"><th>' . $prefix . $title . $suffix . '</th><th>' . i18n::s('Poster') . '</th><th>' . i18n::s('Messages') . '</th><th>' . i18n::s('Last active') . '</th></tr>' . "\n";
         $count = 1;
         // get last posts for this board --avoid sticky pages
         if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
             $order = $matches[1];
         } else {
             $order = 'edition';
         }
         if ($articles =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], 0, 5, 'raw', TRUE)) {
             foreach ($articles as $id => $article) {
                 // get the related overlay, if any
                 $article_overlay = Overlay::load($article, 'article:' . $id);
                 // flag articles updated recently
                 if ($article['expiry_date'] > NULL_DATE && $article['expiry_date'] <= $context['now']) {
                     $flag = EXPIRED_FLAG . ' ';
                 } elseif ($article['create_date'] >= $context['fresh']) {
                     $flag = NEW_FLAG . ' ';
                 } elseif ($article['edit_date'] >= $context['fresh']) {
                     $flag = UPDATED_FLAG . ' ';
                 } else {
                     $flag = '';
                 }
                 // use the title to label the link
                 if (is_object($article_overlay)) {
                     $title = Codes::beautify_title($article_overlay->get_text('title', $article));
                 } else {
                     $title = Codes::beautify_title($article['title']);
                 }
                 // title
                 $title = Skin::build_link(Articles::get_permalink($article), $title, 'article');
                 // poster
                 $poster = Users::get_link($article['create_name'], $article['create_address'], $article['create_id']);
                 // comments
                 $comments = Comments::count_for_anchor('article:' . $article['id']);
                 // last editor
                 $action = '';
                 if ($article['edit_date']) {
                     // label the action
                     if (isset($article['edit_action'])) {
                         $action = Anchors::get_action_label($article['edit_action']);
                     } else {
                         $action = i18n::s('edited');
                     }
                     $action = '<span class="details">' . $action . ' ' . Skin::build_date($article['edit_date']) . '</span>';
                 }
                 // this is another row of the output
                 $text .= '<tr class="' . $class_detail . '"><td>' . $title . $flag . '</td><td>' . $poster . '</td><td style="text-align: center;">' . $comments . '</td><td>' . $action . '</td></tr>' . "\n";
             }
         }
         // more details
         $details = array();
         // board introduction
         if ($item['introduction']) {
             $details[] = Codes::beautify_introduction($item['introduction']);
         }
         // indicate the total number of threads here
         if (($count = Articles::count_for_anchor('section:' . $item['id'])) && $count >= 5) {
             $details[] = sprintf(i18n::s('%d threads'), $count) . '&nbsp;&raquo;';
         }
         // link to the section index page
         if ($details) {
             $details = Skin::build_link(Sections::get_permalink($item), join(' -&nbsp;', $details), 'basic');
         } else {
             $details = '';
         }
         // add a command for new post
         $poster = '';
         if (Surfer::is_empowered()) {
             $poster = Skin::build_link('articles/edit.php?anchor=' . urlencode('section:' . $item['id']), i18n::s('Add a page') . '&nbsp;&raquo;', 'basic');
         }
         // insert details in a separate row
         if ($details || $poster) {
             $text .= '<tr class="' . $class_detail . '"><td colspan="3">' . $details . '</td><td>' . $poster . '</td></tr>' . "\n";
         }
         // more details
         $more = array();
         // board moderators
         if ($moderators = Sections::list_editors_by_name($item, 0, 7, 'comma5')) {
             $more[] = sprintf(i18n::ns('Moderator: %s', 'Moderators: %s', count($moderators)), $moderators);
         }
         // children boards
         if ($children =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, COMPACT_LIST_SIZE, 'compact')) {
             $more[] = sprintf(i18n::ns('Child board: %s', 'Child boards: %s', count($children)), Skin::build_list($children, 'comma'));
         }
         // as a compact list
         if (count($more)) {
             $content = '<ul class="compact">';
             foreach ($more as $list_item) {
                 $content .= '<li>' . $list_item . '</li>' . "\n";
             }
             $content .= '</ul>' . "\n";
             // insert details in a separate row
             $text .= '<tr class="' . $class_detail . '"><td colspan="4">' . $content . '</td></tr>' . "\n";
         }
     }
     // end of processing
     SQL::free($result);
     $text .= Skin::table_suffix();
     return $text;
 }
Ejemplo n.º 17
0
Archivo: cloud.php Proyecto: rair/yacs
if (!($text = Cache::get($cache_id))) {
    // query the database and layout that stuff
    if (!($text =& Members::list_categories_by_count_for_anchor(NULL, 0, 200, 'cloud'))) {
        $text = '<p>' . i18n::s('No item has been found.') . '</p>';
    }
    // we have an array to format
    if (is_array($text)) {
        $text =& Skin::build_list($text, '2-columns');
    }
    // make a box
    if ($text) {
        $text =& Skin::build_box('', $text, 'header1', 'categories');
    }
    // cache this to speed subsequent queries
    Cache::put($cache_id, $text, 'categories');
}
$context['text'] .= $text;
// display extra information
$cache_id = 'categories/cloud.php#extra';
if (!($text = Cache::get($cache_id))) {
    // add an extra box with helpful links
    $links = array('sections/' => i18n::s('Site map'), 'search.php' => i18n::s('Search'), 'help/' => i18n::s('Help index'), 'query.php' => i18n::s('Contact'));
    $text .= Skin::build_box(i18n::s('See also'), Skin::build_list($links, 'compact'), 'boxes') . "\n";
    // save for later use
    Cache::put($cache_id, $text, 'articles');
}
$context['components']['boxes'] = $text;
// referrals, if any
$context['components']['referrals'] =& Skin::build_referrals('categories/cloud.php');
// render the skin
render_skin();
Ejemplo n.º 18
0
Archivo: index.php Proyecto: rair/yacs
 }
 // the category used to assign featured pages
 $anchor = Categories::get(i18n::c('featured'));
 if ($anchor['id'] && ($items =& Members::list_articles_by_date_for_anchor('category:' . $anchor['id'], 0, $context['root_featured_count'] + 1, 'news'))) {
     // link to the category page from the box title
     $title =& Skin::build_box_title($anchor['title'], Categories::get_permalink($anchor), i18n::s('Featured pages'));
     // limit to seven links only
     if (@count($items) > $context['root_featured_count']) {
         @array_splice($items, $context['root_featured_count']);
         // link to the category page
         $url = Categories::get_permalink($anchor);
         $items[$url] = i18n::s('Featured pages') . MORE_IMG;
     }
     // render html
     if (is_array($items)) {
         $items =& Skin::build_list($items, 'news');
     }
     // we do have something to display
     if ($items) {
         // animate the text if required to do so
         if ($context['root_featured_layout'] == 'scroll') {
             $items = Skin::scroll($items);
             $box_id = 'scrolling_featured';
         } elseif ($context['root_featured_layout'] == 'rotate') {
             $items = Skin::rotate($items);
             $box_id = 'rotating_featured';
         } else {
             $box_id = 'featured';
         }
         // make an extra box -- the css id is either #featured, #scrolling_featured or #rotating_featured
         $text .= Skin::build_box($title, $items, 'news', $box_id);
Ejemplo n.º 19
0
/**
 * dynamically generate the page
 *
 * @see skins/index.php
 */
function send_body()
{
    global $context, $local;
    // $local is required to localize included scripts
    // include every script that has to be run once
    global $scripts, $scripts_count;
    if (@count($scripts)) {
        // the alphabetical order may be used to control script execution order
        sort($scripts);
        reset($scripts);
        // process each script one by one
        foreach ($scripts as $item) {
            // do not execute on first installation
            if (file_exists('../parameters/switch.on') || file_exists('../parameters/switch.off')) {
                // ensure we have a valid database resource
                if (!$context['connection']) {
                    break;
                }
                // remember this as an event
                Logger::remember('scripts/run_once.php: ' . sprintf(i18n::c('script %s has been executed'), $item));
                // where scripts actually are
                $actual_item = str_replace('//', '/', $context['path_to_root'] . 'scripts/run_once/' . $item);
                // include the script to execute it
                $scripts_count++;
                echo Skin::build_block($item, 'subtitle');
                include $actual_item;
                echo "\n";
            }
            // ensure enough overall execution time
            Safe::set_time_limit(30);
            // stamp the file to remember execution time
            Safe::touch($actual_item);
            // rename the script to avoid further execution
            Safe::unlink($actual_item . '.done');
            Safe::rename($actual_item, $actual_item . '.done');
        }
        // refresh javascript libraries
        Cache::purge('js');
    }
    // report on actual execution
    if ($scripts_count) {
        echo '<p>&nbsp;</p><p>' . sprintf(i18n::ns('%d script has been executed', '%d scripts have been executed', $scripts_count), $scripts_count) . "</p>\n";
    } else {
        echo '<p>' . i18n::s('No script has been executed') . "</p>\n";
    }
    // display the total execution time
    $time = round(get_micro_time() - $context['start_time'], 2);
    if ($time > 30) {
        echo '<p>' . sprintf(i18n::s('Script terminated in %.2f seconds.'), $time) . '</p>';
    }
    // if the server has been switched off, go back to the control panel
    if (file_exists('../parameters/switch.off')) {
        echo '<form method="get" action="' . $context['url_to_root'] . 'control/">' . "\n" . '<p class="assistant_bar">' . Skin::build_submit_button(i18n::s('Control Panel')) . '</p>' . "\n" . '</form>' . "\n";
        // else back to the control panel as well, but without a button
    } else {
        $menu = array('control/' => i18n::s('Control Panel'));
        echo Skin::build_list($menu, 'menu_bar');
    }
    // purge the cache, since it is likely that we have modified some data
    Cache::clear();
}
Ejemplo n.º 20
0
         $box .= Skin::build_list($menu, 'menu_bar');
     }
     if ($items = Images::list_by_date_for_anchor('article:' . $item['id'])) {
         $box .= Skin::build_list($items, 'decorated');
     }
     if ($box) {
         $text .= Skin::build_box(i18n::s('Images'), $box, 'folded');
     }
     // files
     $box = '';
     if ($cur_article->allows('creation', 'file')) {
         $menu = array('files/edit.php?anchor=' . urlencode('article:' . $item['id']) => i18n::s('Add a file'));
         $box .= Skin::build_list($menu, 'menu_bar');
     }
     if ($items = Files::list_embeddable_for_anchor('article:' . $item['id'], 0, 50)) {
         $box .= Skin::build_list($items, 'decorated');
     }
     if ($box) {
         $text .= Skin::build_box(i18n::s('Files'), $box, 'folded');
     }
 }
 // display in a separate panel
 if ($text) {
     $panels[] = array('resources', i18n::s('Resources'), 'resources_panel', $text);
 }
 //
 // options tab is visible only to site associates
 //
 if (Surfer::is_associate()) {
     $text = '';
     // provide information to section owner
Ejemplo n.º 21
0
 /**
  * list categories
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // url to read the full category
         $url = Categories::get_permalink($item);
         // initialize variables
         $prefix = $suffix = $icon = '';
         // flag categories that are dead, or created or updated very recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $prefix .= EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         // signal restricted and private categories
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // introduction
         if ($item['introduction']) {
             $suffix .= ' ' . Codes::beautify(trim($item['introduction']));
         }
         // details
         $details = array();
         // count related sub-elements
         $related_count = 0;
         // info on related categories
         $stats = Categories::stat_for_anchor('category:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d category', '%d categories', $stats['count']), $stats['count']);
         }
         $related_count += $stats['count'];
         // info on related sections
         if ($count = Members::count_sections_for_anchor('category:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
             $related_count += $count;
         }
         // info on related articles
         if ($count = Members::count_articles_for_anchor('category:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
             $related_count += $count;
         }
         // info on related files
         if ($count = Files::count_for_anchor('category:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
             $related_count += $count;
         }
         // info on related links
         if ($count = Links::count_for_anchor('category:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
             $related_count += $count;
         }
         // info on related comments
         if ($count = Comments::count_for_anchor('category:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
             $related_count += $stats['count'];
         }
         // info on related users
         if ($count = Members::count_users_for_anchor('category:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d user', '%d users', $count), $count);
         }
         // append details to the suffix
         if (count($details)) {
             $suffix .= "\n" . '<span class="details">(' . implode(', ', $details) . ')</span>';
         }
         // add a head list of related links
         $details = array();
         // add sub-categories on index pages
         if ($related = Categories::list_by_date_for_anchor('category:' . $item['id'], 0, YAHOO_LIST_SIZE, 'compact')) {
             foreach ($related as $sub_url => $label) {
                 $sub_prefix = $sub_suffix = $sub_hover = '';
                 if (is_array($label)) {
                     $sub_prefix = $label[0];
                     $sub_suffix = $label[2];
                     if (@$label[5]) {
                         $sub_hover = $label[5];
                     }
                     $label = $label[1];
                 }
                 $details[] = $sub_prefix . Skin::build_link($sub_url, $label, 'basic', $sub_hover) . $sub_suffix;
             }
         }
         // add related sections if necessary
         if (count($details) < YAHOO_LIST_SIZE && ($related =& Members::list_sections_by_title_for_anchor('category:' . $item['id'], 0, YAHOO_LIST_SIZE - count($details), 'compact'))) {
             foreach ($related as $sub_url => $label) {
                 $sub_prefix = $sub_suffix = $sub_hover = '';
                 if (is_array($label)) {
                     $sub_prefix = $label[0];
                     $sub_suffix = $label[2];
                     if (@$label[5]) {
                         $sub_hover = $label[5];
                     }
                     $label = $label[1];
                 }
                 $details[] = $sub_prefix . Skin::build_link($sub_url, $label, 'basic', $sub_hover) . $sub_suffix;
             }
         }
         // add related articles if necessary
         if (count($details) < YAHOO_LIST_SIZE && ($related =& Members::list_articles_by_date_for_anchor('category:' . $item['id'], 0, YAHOO_LIST_SIZE - count($details), 'compact'))) {
             foreach ($related as $sub_url => $label) {
                 $sub_prefix = $sub_suffix = $sub_hover = '';
                 if (is_array($label)) {
                     $sub_prefix = $label[0];
                     $sub_suffix = $label[2];
                     if (@$label[5]) {
                         $sub_hover = $label[5];
                     }
                     $label = $label[1];
                 }
                 $details[] = $sub_prefix . Skin::build_link($sub_url, $label, 'basic', $sub_hover) . $sub_suffix;
             }
         }
         // give me more
         if (count($details) && $related_count > YAHOO_LIST_SIZE) {
             $details[] = Skin::build_link(Categories::get_permalink($item), i18n::s('More') . MORE_IMG, 'more', i18n::s('View the category'));
         }
         // layout details
         if (count($details)) {
             $suffix .= BR . "\n&raquo;&nbsp;" . '<span class="details">' . implode(', ', $details) . "</span>\n";
         }
         // put the actual icon in the left column
         if (isset($item['thumbnail_url'])) {
             $icon = $item['thumbnail_url'];
         }
         // use the title to label the link
         $label = Skin::strip($item['title'], 50);
         // some hovering title for this category
         $hover = i18n::s('View the category');
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'category', $icon, $hover);
     }
     // end of processing
     SQL::free($result);
     $output = Skin::build_list($items, '2-columns');
     return $output;
 }
Ejemplo n.º 22
0
    if (isset($_REQUEST['files_url'])) {
        $content .= '$context[\'files_url\']=\'' . addcslashes($_REQUEST['files_url'], "\\'") . "';\n";
    }
    $content .= '?>' . "\n";
    // update the parameters file
    if (!Safe::file_put_contents('parameters/files.include.php', $content)) {
        Logger::error(sprintf(i18n::s('ERROR: Impossible to write to the file %s. The configuration has not been saved.'), 'parameters/files.include.php'));
        // allow for a manual update
        $context['text'] .= '<p style="text-decoration: blink;">' . sprintf(i18n::s('To actually change the configuration, please copy and paste following lines by yourself in file %s.'), 'parameters/files.include.php') . "</p>\n";
        // job done
    } else {
        $context['text'] .= '<p>' . sprintf(i18n::s('The following configuration has been saved into the file %s.'), 'parameters/files.include.php') . "</p>\n";
        // purge the cache
        Cache::clear();
        // remember the change
        $label = sprintf(i18n::c('%s has been updated'), 'parameters/files.include.php');
        Logger::remember('files/configure.php: ' . $label);
    }
    // display updated parameters
    $context['text'] .= Skin::build_box(i18n::s('Configuration parameters'), Safe::highlight_string($content), 'folded');
    // follow-up commands
    $follow_up = i18n::s('Where do you want to go now?');
    $menu = array();
    $menu = array_merge($menu, array('files/' => i18n::s('Files')));
    $menu = array_merge($menu, array('control/' => i18n::s('Control Panel')));
    $menu = array_merge($menu, array('files/configure.php' => i18n::s('Configure again')));
    $follow_up .= Skin::build_list($menu, 'menu_bar');
    $context['text'] .= Skin::build_block($follow_up, 'bottom');
}
// render the skin
render_skin();
Ejemplo n.º 23
0
Archivo: select.php Proyecto: rair/yacs
            if (is_object($parent)) {
                $details[] = sprintf(i18n::s('in %s'), Skin::build_link($parent->get_url(), ucfirst($parent->get_title()), 'section'));
            }
            // combine in-line details
            if (count($details)) {
                $suffix .= ' - <span class="details">' . trim(implode(', ', $details)) . '</span>';
            }
            // surfer cannot be deselected
            if (!strcmp($anchor->get_reference(), 'user:'******'owner_id'])) {
                $suffix .= ' - <span class="details">' . i18n::s('owner') . '</span>';
            } elseif (Surfer::is_associate()) {
                $link = $context['script_url'] . '?anchor=' . urlencode($anchor->get_reference()) . '&amp;member=section:' . $section['id'] . '&amp;action=reset';
                $suffix .= ' - <span class="details">' . Skin::build_link($link, i18n::s('unassign'), 'basic') . '</span>';
            }
            // format the item
            $new_sections[$url] = array($prefix, $title, $suffix, 'section', $icon);
        }
        // display attached sections with unlink buttons
        $context['text'] .= Skin::build_list($new_sections, 'decorated');
    }
    // back to the anchor page
    $links = array();
    $links[] = Skin::build_link($anchor->get_url(), i18n::s('Done'), 'button');
    $context['text'] .= Skin::finalize_list($links, 'assistant_bar');
    // insert anchor suffix
    if (is_object($anchor)) {
        $context['text'] .= $anchor->get_suffix();
    }
}
// render the skin
render_skin();
Ejemplo n.º 24
0
Archivo: tables.php Proyecto: rair/yacs
 /**
  * build one table
  *
  * Accept following variants:
  * - csv - to provide a downloadable csv page
  * - json - to provide all values in one column
  * - inline - to render tables within articles
  * - simple - the legacy fixed table
  * - sortable - click on column to sort the row
  *
  * @param the id of the table to build
  * @param string the variant to provide - default is 'simple'
  * @return a displayable string
  */
 public static function build($id, $variant = 'simple')
 {
     global $context;
     // split parameters
     $attributes = preg_split("/\\s*,\\s*/", $id, 3);
     $id = $attributes[0];
     // get the table object
     if (!($table = Tables::get($id))) {
         return NULL;
     }
     // do the SELECT statement
     if (!($rows = SQL::query($table['query']))) {
         Logger::error(sprintf(i18n::s('Error in table query %s'), $id) . BR . htmlspecialchars($table['query']) . BR . SQL::error());
         return NULL;
     }
     // build the resulting string
     $text = '';
     switch ($variant) {
         // produce a table readable into MS-Excel
         case 'csv':
             // comma separated values
             $separator = ",";
             // one row for the title
             if ($table['title']) {
                 $label = preg_replace('/\\s/', ' ', $table['title']);
                 // encode to ASCII
                 $label = utf8::to_ascii($label, PRINTABLE_SAFE_ALPHABET);
                 // escape quotes to preserve them in the data
                 $label = str_replace('"', '""', $label);
                 $text .= '"' . $label . '"';
                 $text .= "\n";
             }
             // one row for header fields
             $index = 0;
             while ($field = SQL::fetch_field($rows)) {
                 if ($index++) {
                     $text .= $separator;
                 }
                 $label = trim(preg_replace('/\\s/', ' ', ucfirst($field->name)));
                 // encode
                 $label = utf8::to_ascii($label, PRINTABLE_SAFE_ALPHABET);
                 // escape quotes to preserve them in the data
                 $label = str_replace('"', '""', $label);
                 $text .= '"' . $label . '"';
             }
             $text .= "\n";
             // process every table row
             $row_index = 0;
             while ($row = SQL::fetch($rows)) {
                 // one cell at a time
                 $index = 0;
                 foreach ($row as $name => $value) {
                     // glue cells
                     if ($index++) {
                         $text .= $separator;
                     }
                     // remove HTML tags
                     $value = strip_tags(str_replace('</', ' </', str_replace(BR, ' / ', $value)));
                     // clean spaces
                     $label = trim(preg_replace('/\\s+/', ' ', $value));
                     // encode
                     $label = utf8::to_ascii($label, PRINTABLE_SAFE_ALPHABET);
                     // escape quotes to preserve them in the data
                     $label = str_replace('"', '""', $label);
                     // make a link if this is a reference
                     if ($index == 1 && $table['with_zoom'] == 'Y') {
                         $label = $context['url_to_home'] . $context['url_to_root'] . $label;
                     }
                     // quote data
                     $text .= '"' . $label . '"';
                 }
                 // new line
                 $text .= "\n";
             }
             return $text;
             // a JSON set of values
         // a JSON set of values
         case 'json':
             // get header labels
             $labels = array();
             while ($field = SQL::fetch_field($rows)) {
                 $labels[] = trim(preg_replace('/[^\\w]+/', '', ucfirst($field->name)));
             }
             // all items
             $data = array();
             $data['items'] = array();
             while ($row = SQL::fetch_row($rows)) {
                 // all rows
                 $datum = array();
                 $label = FALSE;
                 $index = 0;
                 $link = NULL;
                 foreach ($row as $name => $value) {
                     $index++;
                     // first column is only a link
                     if ($index == 1 && $table['with_zoom'] == 'Y') {
                         $link = $context['url_to_home'] . $context['url_to_root'] . ltrim($value, '/');
                         continue;
                     }
                     // adjust types to not fool the json encoder
                     if (preg_match('/^(\\+|-){0,1}[0-9]+$/', $value)) {
                         $value = intval($value);
                     } elseif (preg_match('/^(\\+|-){0,1}[0-9\\.,]+$/', $value)) {
                         $value = floatval($value);
                     } elseif (preg_match('/^(true|false)$/i', $value)) {
                         $value = intval($value);
                     }
                     // ensure we have some label for SIMILE Exhibit
                     if (!$label) {
                         $label = $value;
                     }
                     // combine first and second columns
                     if ($index == 2 && $link) {
                         $value = Skin::build_link($link, $value, 'basic');
                     }
                     // save this value
                     $datum[$labels[$name]] = utf8::to_ascii($value, PRINTABLE_SAFE_ALPHABET);
                 }
                 if ($label && !in_array('label', $labels)) {
                     $datum['label'] = utf8::to_ascii($label, PRINTABLE_SAFE_ALPHABET);
                 }
                 // add a tip, if any
                 $data['items'][] = $datum;
             }
             include_once $context['path_to_root'] . 'included/json.php';
             $text .= json_encode2($data);
             return $text;
             // list of facets for SIMILE Exhibit
         // list of facets for SIMILE Exhibit
         case 'json-facets':
             // columns are actual facets
             $facets = array();
             $index = 0;
             while ($field = SQL::fetch_field($rows)) {
                 $index++;
                 // first column is only a link
                 if ($index == 1 && $table['with_zoom'] == 'Y') {
                     continue;
                 }
                 // first column has a link
                 if ($index == 2 && $table['with_zoom'] == 'Y') {
                     continue;
                 }
                 // column is a facet
                 $label = '.' . trim(preg_replace('/[^\\w]+/', '', ucfirst($field->name)));
                 $title = trim(str_replace(',', '', ucfirst($field->name)));
                 $facets[] = '<div ex:role="facet" ex:expression="' . $label . '" ex:facetLabel="' . $title . '"></div>';
                 // only last columns can be faceted
                 if (count($facets) > 7) {
                     array_shift($facets);
                 }
             }
             // reverse facet order
             $facets = array_reverse($facets);
             // job done
             $text = join("\n", $facets);
             return $text;
             // list of columns for SIMILE Exhibit
         // list of columns for SIMILE Exhibit
         case 'json-labels':
             // get header labels
             $labels = array();
             $index = 0;
             while ($field = SQL::fetch_field($rows)) {
                 $index++;
                 // first column is only a link
                 if ($index == 1 && $table['with_zoom'] == 'Y') {
                     continue;
                 }
                 // column id
                 $labels[] = '.' . trim(preg_replace('/[^\\w]+/', '', ucfirst($field->name)));
                 // limit the number of columns put on screen
                 if (count($labels) >= 7) {
                     break;
                 }
             }
             // job done
             $text = join(', ', $labels);
             return $text;
             // titles of columns for SIMILE Exhibit
         // titles of columns for SIMILE Exhibit
         case 'json-titles':
             // get header labels
             $labels = array();
             $index = 0;
             while ($field = SQL::fetch_field($rows)) {
                 $index++;
                 // first column is only a link
                 if ($index == 1 && $table['with_zoom'] == 'Y') {
                     continue;
                 }
                 // column header
                 $labels[] = trim(str_replace(',', '', ucfirst($field->name)));
             }
             $text = join(', ', $labels);
             return $text;
             // produce an HTML table
         // produce an HTML table
         default:
         case 'inline':
         case 'sortable':
             // a table with a grid
             $text .= Skin::table_prefix('grid');
             // the title, with a menu to download the table into Excel
             if ($variant == 'inline') {
                 $item_bar = array();
                 $item_bar += array(Tables::get_url($id) => $table['title']);
                 $item_bar += array(Tables::get_url($id, 'fetch_as_csv') => 'CSV (Excel)');
                 if (Surfer::is_associate()) {
                     $item_bar += array(Tables::get_url($id, 'edit') => i18n::s('edit'));
                 }
                 if (count($item_bar)) {
                     $text .= '<caption>' . Skin::build_list($item_bar, 'menu') . "</caption>\n";
                 }
             }
             // column headers are clickable links
             $cells = array();
             $index = 0;
             while ($field = SQL::fetch_field($rows)) {
                 if ($index++ != 0 || $table['with_zoom'] != 'Y') {
                     $cells[] = ucfirst($field->name);
                 }
             }
             $text .= "\t\t" . Skin::table_row($cells, 'sortable');
             // the table body
             $count = 0;
             $row_index = 0;
             while ($row = SQL::fetch_row($rows)) {
                 $cells = array();
                 $link = '';
                 for ($index = 0; $index < count($row); $index++) {
                     if ($index == 0 && $table['with_zoom'] == 'Y') {
                         $link = $row[$index];
                     } elseif ($link) {
                         $cells[] = Skin::build_link($link, $row[$index]);
                         $link = '';
                     } else {
                         $cells[] = $row[$index];
                     }
                 }
                 $text .= "\t\t" . Skin::table_row($cells, $count++);
             }
             $text .= Skin::table_suffix();
             return $text;
             // adapted to open chart flash
         // adapted to open chart flash
         case 'chart':
             // get title for y series
             $y_title = $y2_title = $y3_title = NULL;
             $y_index = $y2_index = $y3_index = 0;
             $index = 0;
             while ($field = SQL::fetch_field($rows)) {
                 // time will be used for x labels
                 if ($index == 0 && $table['with_zoom'] == 'T') {
                 } elseif ($index == 0 && $table['with_zoom'] == 'Y') {
                 } elseif (!$y_title) {
                     $y_title = '"' . ucfirst($field->name) . '"';
                     $y_index = $index;
                 } elseif (!$y2_title) {
                     $y2_title = '"' . ucfirst($field->name) . '"';
                     $y2_index = $index;
                 } elseif (!$y3_title) {
                     $y3_title = '"' . ucfirst($field->name) . '"';
                     $y3_index = $index;
                     break;
                 }
                 $index++;
             }
             // process every table row
             $x_labels = array();
             $y_values = array();
             $y2_values = array();
             $y3_values = array();
             $y_min = $y_max = NULL;
             $count = 1;
             while ($row = SQL::fetch($rows)) {
                 // one cell at a time
                 $index = 0;
                 foreach ($row as $name => $value) {
                     // clean spaces
                     $label = trim(preg_replace('/\\s/', ' ', $value));
                     // encode in iso8859
                     $label = utf8::to_iso8859($label);
                     // escape quotes to preserve them in the data
                     $label = str_replace('"', '""', $label);
                     // quote data
                     if (preg_match('/-*[^0-9\\,\\.]/', $label)) {
                         $label = '"' . $label . '"';
                     }
                     // x labels
                     if ($index == 0) {
                         if ($table['with_zoom'] == 'T') {
                             array_unshift($x_labels, $label);
                         } else {
                             $x_labels[] = $count++;
                         }
                         // y value
                     } elseif ($index == $y_index) {
                         if ($table['with_zoom'] == 'T') {
                             array_unshift($y_values, $label);
                         } else {
                             $y_values[] = $label;
                         }
                         if (!isset($y_min) || intval($label) < $y_min) {
                             $y_min = intval($label);
                         }
                         if (!isset($y_max) || intval($label) > $y_max) {
                             $y_max = intval($label);
                         }
                         // y2 value
                     } elseif ($index == $y2_index) {
                         if ($table['with_zoom'] == 'T') {
                             array_unshift($y2_values, $label);
                         } else {
                             $y_values[] = $label;
                         }
                         if (!isset($y_min) || intval($label) < $y_min) {
                             $y_min = intval($label);
                         }
                         if (!isset($y_max) || intval($label) > $y_max) {
                             $y_max = intval($label);
                         }
                         // y3 value
                     } elseif ($index == $y3_index) {
                         if ($table['with_zoom'] == 'T') {
                             array_unshift($y3_values, $label);
                         } else {
                             $y_values[] = $label;
                         }
                         if (!isset($y_min) || intval($label) < $y_min) {
                             $y_min = intval($label);
                         }
                         if (!isset($y_max) || intval($label) > $y_max) {
                             $y_max = intval($label);
                         }
                         // we won't process the rest
                         break;
                     }
                     // next column
                     $index++;
                 }
             }
             // y minimum
             if ($y_min > 0) {
                 $y_min = 0;
             }
             // y maximum
             $y_max = strval($y_max);
             if (strlen($y_max) == 1) {
                 $y_max = 10;
             } elseif (strlen($y_max) == 2) {
                 $y_max = (intval(substr($y_max, 0, 1)) + 1) * 10;
             } elseif (strlen($y_max) == 3) {
                 $y_max = (intval(substr($y_max, 0, 2)) + 1) * 10;
             } else {
                 $y_max = strval(intval(substr($y_max, 0, 2)) + 1) . substr('0000000000000000000000000000000000000000000000000000', 0, strlen($y_max) - 2);
             }
             // data series
             $elements = array();
             if (count($y_values)) {
                 $elements[] = '{ "type":"bar_glass", "colour":"#BF3B69", "values": [ ' . join(',', $y_values) . ' ], "text": ' . $y_title . ', "font-size": 12 }';
             }
             if (count($y2_values)) {
                 $elements[] = '{ "type": "line", "width": 1, "colour": "#5E4725", "values": [ ' . join(',', $y2_values) . ' ], "text": ' . $y2_title . ', "font-size": 12 }';
             }
             if (count($y3_values)) {
                 $elements[] = '{ "type":"bar_glass", "colour":"#5E0722", "values": [ ' . join(',', $y3_values) . ' ], "text": ' . $y3_title . ', "font-size": 12 }';
             }
             // the full setup
             $text = '{ "elements": [ ' . join(',', $elements) . ' ], "x_axis": { "offset": false, "steps": 1, "labels": { "steps": 3, "rotate": 310, "labels": [ ' . join(',', $x_labels) . ' ] } }, "y_axis": { "min": ' . $y_min . ', "max": ' . $y_max . ' } }';
             return $text;
             // first number
         // first number
         case 'column':
             // comma separated values
             $separator = ",";
             // process every table row
             while ($row = SQL::fetch($rows)) {
                 // not always the first column
                 $index = 0;
                 foreach ($row as $name => $value) {
                     $index++;
                     // skip dates and links
                     if ($index == 1 && $table['with_zoom'] != 'N') {
                         continue;
                     }
                     // glue cells
                     if ($text) {
                         $text .= $separator;
                     }
                     // clean spaces
                     $label = trim(preg_replace('/\\s/', ' ', $value));
                     // encode in iso8859
                     $label = utf8::to_iso8859($label);
                     // escape quotes to preserve them in the data
                     $label = str_replace('"', '""', $label);
                     // quote data
                     if (preg_match('/[^a-zA-Z0-9\\,\\.\\-_]/', $label)) {
                         $text .= '"' . $label . '"';
                     } else {
                         $text .= $label;
                     }
                     // only first column
                     break;
                 }
             }
             return $text;
             // produce a raw table
         // produce a raw table
         case 'raw':
             // comma separated values
             $separator = ",";
             // process every table row
             while ($row = SQL::fetch($rows)) {
                 // one cell at a time
                 $index = 0;
                 foreach ($row as $name => $value) {
                     // glue cells
                     if ($index++) {
                         $text .= $separator;
                     }
                     // clean spaces
                     $label = trim(preg_replace('/\\s/', ' ', $value));
                     // encode in iso8859
                     $label = utf8::to_iso8859($label);
                     // escape quotes to preserve them in the data
                     $label = str_replace('"', '""', $label);
                     // make a link if this is a reference
                     if ($index == 0 && $table['with_zoom'] == 'Y') {
                         $label = $context['url_to_home'] . $context['url_to_root'] . $label;
                     }
                     // quote data
                     if (preg_match('/[^a-zA-Z0-9\\-_]/', $label)) {
                         $text .= '"' . $label . '"';
                     } else {
                         $text .= $label;
                     }
                 }
                 // new line
                 $text .= "\n";
             }
             return $text;
             // a simple table
         // a simple table
         case 'simple':
             $text .= Skin::table_prefix('table');
             // columns headers
             $index = 0;
             while ($field = SQL::fetch_field($rows)) {
                 $cells[] = ucfirst($field->name);
             }
             $text .= Skin::table_row($cells, 'header');
             // other rows
             while ($row = SQL::fetch_row($rows)) {
                 $text .= Skin::table_row($row, $count++);
             }
             $text .= Skin::table_suffix();
             return $text;
             // xml table
         // xml table
         case 'xml':
             $text = '';
             while ($row = SQL::fetch($rows)) {
                 $text .= '	<item>' . "\n";
                 foreach ($row as $name => $value) {
                     $type = preg_replace('/[^a-z0-9]+/i', '_', $name);
                     if (preg_match('/^[^a-z]/i', $type)) {
                         $type = '_' . $type;
                     }
                     $text .= '		<' . $type . '>' . preg_replace('/&(?!(amp|#\\d+);)/i', '&amp;', utf8::transcode(str_replace(array('left=', 'right='), '', $value))) . '</' . $type . '>' . "\n";
                 }
                 $text .= '	</item>' . "\n\n";
             }
             return '<?xml version="1.0" encoding="' . $context['charset'] . '"?>' . "\n" . '<items>' . "\n" . $text . '</items>' . "\n";
     }
 }
Ejemplo n.º 25
0
Archivo: index.php Proyecto: rair/yacs
        // query the database and layout that stuff
        if (!($text = Comments::list_threads_by_date($offset, THREADS_PER_PAGE, $layout))) {
            $context['text'] .= '<p>' . i18n::s('No comment has been transmitted.') . '</p>';
        }
        // we have an array to format
        if (is_array($text)) {
            $text =& Skin::build_list($text, 'rows');
        }
        // cache, whatever changes, for 1 minute
        Cache::put($cache_id, $text, 'stable', 60);
    }
    $context['text'] .= $text;
}
// page tools
if (Surfer::is_associate()) {
    $context['page_tools'][] = Skin::build_link('comments/check.php', i18n::s('Maintenance'), 'basic');
}
// page extra information
$cache_id = 'comments/index.php#extra';
if (!($text = Cache::get($cache_id))) {
    // side bar with the list of most recent pages
    if ($items =& Articles::list_by('publication', 0, COMPACT_LIST_SIZE, 'compact')) {
        $text =& Skin::build_box(i18n::s('Recent pages'), Skin::build_list($items, 'compact'), 'boxes');
    }
    Cache::put($cache_id, $text, 'articles');
}
$context['components']['boxes'] = $text;
// referrals, if any
$context['components']['referrals'] = Skin::build_referrals('comments/index.php');
// render the skin
render_skin();
Ejemplo n.º 26
0
 /**
  * list sections
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!($delta = SQL::count($result))) {
         return $text;
     }
     // process all items in the list
     $count = 0;
     $items = array();
     while ($item = SQL::fetch($result)) {
         // the url to view this item
         $url = Sections::get_permalink($item);
         // initialize variables
         $prefix = $label = $suffix = '';
         // flag sections that are draft or dead
         if ($item['activation_date'] >= $context['now']) {
             $prefix .= DRAFT_FLAG;
         } elseif ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $prefix .= EXPIRED_FLAG;
         }
         // signal restricted and private sections
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // flag items updated recently
         if ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         //			// start the label with family, if any
         //			if($item['family'])
         //				$label = ucfirst(Skin::strip($item['family'], 30)).' - ';
         // use the title to label the link
         $label .= ucfirst(Skin::strip($item['title'], 30));
         // the hovering title
         if ($item['introduction'] && $context['skins_with_details'] == 'Y') {
             $hover = strip_tags(Codes::beautify_introduction($item['introduction']));
         } else {
             $hover = i18n::s('View the section');
         }
         // help members to reference this page
         if (Surfer::is_member()) {
             $hover .= ' [section=' . $item['id'] . ']';
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'basic', NULL, $hover);
         // limit to one page of results
         if (++$count >= COMPACT_LIST_SIZE - 1) {
             break;
         }
     }
     // end of processing
     SQL::free($result);
     // turn this to some text
     $text .= Skin::build_list($items, 'comma');
     // some indications on the number of connections
     if (($delta -= $count) > 0) {
         $text .= ', ...';
     }
     return $text;
 }
Ejemplo n.º 27
0
Archivo: switch.php Proyecto: rair/yacs
        // if the server is currently switched off
    } elseif (file_exists($context['path_to_root'] . 'parameters/switch.off')) {
        Logger::error(i18n::s('The server is currently switched off. All users are redirected to the closed page.'));
    } else {
        Logger::error(i18n::s('Impossible to rename the file parameters/switch.on to parameters/switch.off. Do it yourself manually if you like.'));
    }
    // follow-up commands
    $menu = array();
    // do it again
    if (file_exists($context['path_to_root'] . 'parameters/switch.off')) {
        $menu = array_merge($menu, array('control/switch.php?action=on' => i18n::s('Switch on')));
    }
    // control panel
    $menu = array_merge($menu, array('control/' => i18n::s('Control Panel')));
    // display follow-up commands
    $context['text'] .= Skin::build_list($menu, 'menu_bar');
    // confirmation is required
} else {
    // if the server is currently switched off
    if (file_exists($context['path_to_root'] . 'parameters/switch.off')) {
        // server status
        Logger::error(i18n::s('The server is currently switched off. All users are redirected to the closed page.'));
        // the confirmation question
        $context['text'] .= '<b>' . i18n::s('You are about to open the server again. Are you sure?') . "</b>\n";
        // the menu for this page
        $context['text'] .= '<form method="post" action="' . $context['script_url'] . '"><p>' . Skin::build_submit_button(i18n::s('Yes, I do want to switch this server on')) . '<input type="hidden" name="action" value="on" />' . '</p></form>' . "\n";
        // else the server is currently switched on
    } else {
        // server status
        $context['text'] .= '<p>' . i18n::s('The server is currently switched on. Pages are provided normally to surfers.') . "</p>\n";
        // the confirmation question
Ejemplo n.º 28
0
Archivo: print.php Proyecto: rair/yacs
    //
    // title
    $section = Skin::build_block(i18n::s('Files'), 'title');
    // list files by date (default) or by title (option :files_by_title:)
    if (preg_match('/\\bfiles_by_title\\b/i', $item['options'])) {
        $items = Files::list_by_title_for_anchor('category:' . $item['id'], 0, 300, 'category:' . $item['id']);
    } else {
        $items = Files::list_by_date_for_anchor('category:' . $item['id'], 0, 300, 'category:' . $item['id']);
    }
    // actually render the html for the section
    if ($items) {
        $context['text'] .= $section . Skin::build_list($items, 'decorated');
    }
    //
    // the links section
    //
    // title
    $section = Skin::build_block(i18n::s('See also'), 'title');
    // list links by date (default) or by title (option :links_by_title:)
    if (preg_match('/\\blinks_by_title\\b/i', $item['options'])) {
        $items = Links::list_by_title_for_anchor('category:' . $item['id'], 0, 50);
    } else {
        $items = Links::list_by_date_for_anchor('category:' . $item['id'], 0, 50);
    }
    // actually render the html
    if ($items) {
        $context['text'] .= $section . Skin::build_list($items, 'decorated');
    }
}
// render the skin
render_skin();
Ejemplo n.º 29
0
Archivo: select.php Proyecto: rair/yacs
                $where .= " OR categories.active='N'";
            }
            // only consider live categories
            $where = '(' . $where . ')' . ' AND ((categories.expiry_date is NULL)' . "\tOR (categories.expiry_date <= '" . NULL_DATE . "') OR (categories.expiry_date > '" . $context['now'] . "'))";
            // limit the query to top level only
            $query = "SELECT categories.id, categories.title " . " FROM " . SQL::table_name('categories') . " AS categories " . " WHERE (" . $where . ") AND (categories.anchor='category:" . $category_id . "')" . " ORDER BY categories.title";
            $result = SQL::query($query);
            $sub_categories = array();
            while ($result && ($option = SQL::fetch($result))) {
                $sub_categories['category:' . $option['id']] = $option['title'];
            }
            if (count($sub_categories)) {
                $suffix .= '<form method="post" action="' . $context['script_url'] . '"><div>' . i18n::s('More specific:') . ' <select name="anchor">';
                foreach ($sub_categories as $option_reference => $option_label) {
                    $suffix .= '<option value="' . $option_reference . '">' . $option_label . "</option>\n";
                }
                $suffix .= '</select>' . ' ' . Skin::build_submit_button(" >> ") . '<input type="hidden" name="member" value="' . $member . '">' . '<input type="hidden" name="father" value="category:' . $category_id . '">' . '</div></form>' . "\n";
            }
            // format the item
            $new_categories[$url] = array($prefix, $label, $suffix, $type, $icon);
        }
        // display attached categories with unlink buttons
        $context['text'] .= Skin::build_list($new_categories, 'decorated');
    }
    // insert anchor suffix
    if (is_object($anchor)) {
        $context['text'] .= $anchor->get_suffix();
    }
}
// render the skin
render_skin();
Ejemplo n.º 30
0
 /**
  * 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;
 }