Ejemplo n.º 1
0
Archivo: skin.php Proyecto: rair/yacs
 /**
  * define constants used with this skin
  */
 public static function initialize()
 {
     global $context;
     // we are HTML5
     define('SKIN_HTML5', TRUE);
     // add a empty span to tabs in order to justify the tabs (css tricks)
     define('TABS_SUFFIX', '<span class="finish-tabs"></span>');
     $options = '';
     if (isset($context['classes_for_thumbnail_images'])) {
         $options = 'class="' . $context['classes_for_thumbnail_images'] . '" ';
     }
     // the img tag used with the [decorated] code; either a decorating icon, or equivalent to the bullet
     Skin::define_img('DECORATED_IMG', 'layouts/decorated.png', '', '*', $options);
 }
Ejemplo n.º 2
0
Archivo: skin.php Proyecto: rair/yacs
 /**
  * define constants used with this skin
  */
 public static function initialize()
 {
     global $context;
     // we are XHTML
     define('BR', '<br />');
     define('EOT', ' />');
     // the bullet used to prefix list items
     Skin::define_img('BULLET_IMG', 'codes/art_end.gif');
     // the bullet prefix for compact lists
     define('COMPACT_LIST_ITEM_PREFIX', '&raquo;&nbsp;');
     // ensure extra boxes are displayed in this 2-columns layout
     if (strpos($context['skins_navigation_components'], 'extra') === FALSE) {
         $context['skins_navigation_components'] = str_replace('navigation', 'extra navigation', $context['skins_navigation_components']);
     }
 }
Ejemplo n.º 3
0
Archivo: embed.php Proyecto: rair/yacs
 /**
  * build the list of fields for this overlay
  *
  * @see overlays/overlay.php
  *
  * @param the hosting attributes
  * @return a list of ($label, $input, $hint)
  */
 function get_fields($host, $field_pos = NULL)
 {
     global $context;
     $fields = array();
     // the file itself
     $label = i18n::s('Share');
     $input = '';
     // a surfer is sharing something
     if (!isset($host['id'])) {
         // share a link
         Skin::define_img('EMBED_HREF_IMG', 'thumbnails/video.gif');
         $cell1 = '<div style="text-align: center"><a href="#" onclick="$(\'#share_href\').attr(\'checked\', \'checked\').trigger(\'change\'); return false;">' . EMBED_HREF_IMG . '</a>' . BR . '<input type="radio" name="embed_type" id="share_href" value="href" checked="checked" />' . i18n::s('a web address') . '</div>';
         // share a file
         $cell2 = '';
         if (Surfer::may_upload()) {
             Skin::define_img('EMBED_UPLOAD_IMG', 'thumbnails/download.gif');
             $cell2 = '<div style="text-align: center"><a href="#" onclick="$(\'#share_upload\').attr(\'checked\', \'checked\').trigger(\'change\'); return false;">' . EMBED_UPLOAD_IMG . '</a>' . BR . '<input type="radio" name="embed_type" id="share_upload" value="upload" />' . i18n::s('a file') . '</div>';
         }
         // share an idea
         Skin::define_img('EMBED_NONE_IMG', 'thumbnails/information.gif');
         $cell3 = '<div style="text-align: center"><a href="#" onclick="$(\'#share_none\').attr(\'checked\', \'checked\').trigger(\'change\'); return false;">' . EMBED_NONE_IMG . '</a>' . BR . '<input type="radio" name="embed_type" id="share_none" value="none" />' . i18n::s('some information') . '</div>';
         // three controls in a row
         $input = Skin::layout_horizontally($cell1, $cell2, $cell3);
         // sharing a web address
         $input .= '<div id="embed_a_link" style="padding: 1em 0 1em 0;">' . i18n::s('Paste the address of a web page that you have visited') . BR . '<input type="text" name="embed_href" id="embed_href" size="60" width="100%" value="" maxlength="255" />' . '<p class="details">' . sprintf(i18n::s('Some sites are recognized automatically: %s'), '<span id="provider_ticker" style="">' . '<span>YouTube</span>' . '<span>DailyMotion</span>' . '<span>Vimeo</span>' . '<span>Slideshare</span>' . '<span>Scribd</span>' . '<span>Flickr</span>' . '<span>PhotoBucket</span>' . '<span>DeviantArt</span>' . '<span>blip.tv</span>' . '<span>Viddler</span>' . '<span>revision3</span>' . '<span>5min.com</span>' . '<span>dotsub</span>' . '<span>hulu</span>' . '<span>yfrog</span>' . '<span>smugmug</span>' . '<span>soundcloud</span>' . '<span>official.fm</span>' . '<span>rd.io</span>' . '</span>') . '</p>' . '</div>';
         Page::insert_script('$(function() {' . "\n" . '	var obj = $("#provider_ticker");' . "\n" . '	var list = obj.children();' . "\n" . '	list.not(":first").hide();' . "\n" . '	setInterval(function(){' . "\n" . '		list = obj.children();' . "\n" . '		list.not(":first").hide();' . "\n" . '		var first_li = list.eq(0);' . "\n" . '		var second_li = list.eq(1);' . "\n" . '		first_li.fadeOut(function(){' . "\n" . '			obj.css("height",second_li.height());' . "\n" . '			second_li.fadeIn();' . "\n" . '			first_li.remove().appendTo(obj);' . "\n" . '		});' . "\n" . '	}, 2000);' . "\n" . '});' . "\n");
         // uploading a file
         if (Surfer::may_upload()) {
             $input .= '<div id="embed_a_file" style="display: none; padding: 1em 0 1em 0;">' . '<input type="file" name="upload" id="upload" size="30" />' . '<p class="details">' . sprintf(i18n::s('Select a file of less than %s'), $context['file_maximum_size'] . i18n::s('bytes')) . '</p>' . '</div>';
         }
         // change the display on selection
         Page::insert_script('$(function() {' . "\n" . '	$("input[name=embed_type]").change(function() {' . "\n" . '		if($("#share_href").attr("checked")) {' . "\n" . '			$("#embed_a_link").slideDown();' . "\n" . '			$("#embed_a_file").slideUp();' . "\n" . '		}' . "\n" . '		if($("#share_upload").attr("checked")) {' . "\n" . '			$("#embed_a_link").slideUp();' . "\n" . '			$("#embed_a_file").slideDown();' . "\n" . '		}' . "\n" . '		if($("#share_none").attr("checked")) {' . "\n" . '			$("#embed_a_link").slideUp();' . "\n" . '			$("#embed_a_file").slideUp();' . "\n" . '		}' . "\n" . '	});' . "\n" . '});' . "\n");
         // nothing to do
     } elseif (!isset($this->attributes['embed_type'])) {
     } elseif ($this->attributes['embed_type'] == 'href' && trim($this->attributes['embed_href'])) {
         $input .= $this->attributes['embed_href'];
     }
     // a complex field
     if ($input) {
         $fields[] = array($label, $input);
     }
     return $fields;
 }
Ejemplo n.º 4
0
Archivo: users.php Proyecto: rair/yacs
 /**
  * enable direct telephony service
  *
  * @param array of attributes for the first person to be called
  * @return string interactive form plus related AJAX code, or an empty string
  */
 public static function get_click_to_call($item)
 {
     global $context;
     // to be put in resulting page
     $text = '';
     // this user profile has a phone number and we can use the OBS back-end
     if (Surfer::get_id() != $item['id'] && $item['phone_number'] && isset($context['obs_api_key'])) {
         // allow for several controls in the same page
         $id = uniqid();
         Skin::define_img('PHONE_IMG', 'pagers/phone.gif');
         Skin::define_img('SPINNER_IMG', 'ajax/ajax_spinner.gif');
         $text .= ' <div id="a_' . $id . '" style="display: inline;">' . '<button onclick="ClickToCall.start(\'#b_' . $id . '\'); return false;">' . sprintf(i18n::s('Click to call %s'), ucfirst($item['nick_name'])) . PHONE_IMG . '</button>' . ' <input type="text" id="b_' . $id . '" style="display: none;" value="' . Surfer::get_phone_number() . '" />' . '</div>' . '<span id="d_' . $id . '" style="display: none;">' . SPINNER_IMG . i18n::s('Calling...') . '</span>' . '<span id="e_' . $id . '" style="display: none;">' . '<button onclick="ClickToCall.stop(\'#b_' . $id . '\'); return false;">' . i18n::s('Stop the call') . '</button>' . '</span>' . '<span id="f_' . $id . '" style="display: none;">' . SPINNER_IMG . i18n::s('Stopping the call...') . '</span>';
         Page::insert_script('var ClickToCall = {' . "\n" . "\n" . '	start: function(id) {' . "\n" . '		if(!$(id).is(":visible")) {' . "\n" . '			$(id).show("slide", ' . '{ direction: "right" }, ' . '500, ' . 'function() { $(id).focus().tipsy({fallback: "' . i18n::s('Your phone number in international format, starting with country code') . '", gravity: "w", fade: true}).tipsy("show") });' . "\n" . '			$(id).focus();' . "\n" . '			return;' . "\n" . '		}' . "\n" . '		if(!$(id).val()) {' . "\n" . '			$(id).focus();' . "\n" . '			return;' . "\n" . '		}' . "\n" . '		$(id).tipsy("hide");' . "\n" . '		$("#a_' . $id . '").hide();' . "\n" . '		$("#d_' . $id . '").show("slide", { direction: "right" }, 100);' . "\n" . '		Yacs.call( { method: "obs.call", params: { user: '******'id'] . ', number: $(id).val() }, id: 123 }, ' . 'function(s) { $("#d_' . $id . '").hide(); ' . 'if(s.message) { alert(s.message);$("#a_' . $id . '").show("slide", { direction: "right" }, 500);$(id).focus(); } ' . 'else { ClickToCall.call_id = s.call_id; $("#e_' . $id . '").show("slide", { direction: "right" }, 500); } } ' . '		);' . "\n" . '	},' . "\n" . "\n" . '	stop: function(id) {' . "\n" . '		$("#e_' . $id . '").hide("slide", { direction: "left" }, 500);' . "\n" . '		$("#f_' . $id . '").show("slide", { direction: "right" }, 500);' . "\n" . '		Yacs.call( { method: "obs.release", params: { call_id: ClickToCall.call_id }, id: 123 }, ' . 'function(s) { $("#f_' . $id . '").hide("slide", { direction: "left" }, 500); ' . 'if(s.message) {alert(s.message);} $("#a_' . $id . '").show("slide", { direction: "right" }, 500); } );' . "\n" . '	}' . "\n" . "\n" . '}' . "\n");
     }
     // job done
     return $text;
 }
Ejemplo n.º 5
0
Archivo: list.php Proyecto: rair/yacs
        }
    }
    // insert anchor suffix
    if (is_object($anchor)) {
        $context['text'] .= $anchor->get_suffix();
    }
    // page menu
    //
    // get parent of the anchor too
    $parent = NULL;
    if (is_object($anchor) && ($parent = $anchor->get_parent())) {
        $parent =& Anchors::get($parent);
    }
    // the command to post a new file, if this is allowed
    if (is_object($anchor) && Files::allow_creation($anchor->get_values(), $parent, $anchor->get_type())) {
        Skin::define_img('FILES_UPLOAD_IMG', 'files/upload.gif');
        $context['page_menu'][] = Skin::build_link(Files::get_url($anchor->get_reference(), 'file'), FILES_UPLOAD_IMG . i18n::s('Add a file'));
    }
    // command to go back
    if (is_object($anchor) && $anchor->is_viewable()) {
        $context['page_menu'][] = Skin::build_link($anchor->get_url(), i18n::s('Back to main page'), 'basic');
    }
    // side tools
    //
    // the command to post a new file, if this is allowed
    if (is_object($anchor) && Files::allow_creation($anchor->get_values(), $parent, $anchor->get_type())) {
        $context['page_tools'][] = Skin::build_link(Files::get_url($anchor->get_reference(), 'file'), i18n::s('Add a file'));
    }
    // back to main page
    $context['page_tools'][] = Skin::build_link($anchor->get_url(), i18n::s('Back to main page'));
}
Ejemplo n.º 6
0
 /**
  * list articles as rows in a table
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // build a list of articles
     $rows = array();
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // get the related overlay
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // reset everything
         $title = $abstract = $author = '';
         // signal articles to be published
         if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
             $title .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $title .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $title .= RESTRICTED_FLAG;
         }
         // indicate the id in the hovering popup
         $hover = i18n::s('View the page');
         if (Surfer::is_member()) {
             $hover .= ' [article=' . $item['id'] . ']';
         }
         // use the title to label the link
         if (is_object($overlay)) {
             $label = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $label = Codes::beautify_title($item['title']);
         }
         // use the title as a link to the page
         $title .= Skin::build_link($url, $label, 'basic', $hover);
         // signal locked articles
         if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
             $title .= ' ' . LOCKED_FLAG;
         }
         // flag articles updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $title .= ' ' . EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $title .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $title .= ' ' . UPDATED_FLAG;
         }
         // the icon
         if ($item['thumbnail_url']) {
             $abstract .= '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $item['thumbnail_url'] . '" class="right_image" alt="" /></a>';
         }
         // the introductory text
         if (is_object($overlay)) {
             $abstract .= Codes::beautify_introduction($overlay->get_text('introduction', $item));
         } elseif ($item['introduction']) {
             $abstract .= Codes::beautify_introduction($item['introduction']);
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $abstract .= $overlay->get_text('list', $item);
         }
         // make some abstract out of main text
         if (!$item['introduction'] && $context['skins_with_details'] == 'Y') {
             $abstract .= Skin::cap(Codes::beautify($item['description'], $item['options']), 50);
         }
         // attachment details
         $details = array();
         // info on related files
         if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
             Skin::define_img('FILES_LIST_IMG', 'files/list.gif');
             $details[] = FILES_LIST_IMG . sprintf(i18n::ns('%d file', '%d files', $count), $count);
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             Skin::define_img('LINKS_LIST_IMG', 'links/list.gif');
             $details[] = LINKS_LIST_IMG . sprintf(i18n::ns('%d link', '%d links', $count), $count);
         }
         // comments
         if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
             Skin::define_img('COMMENTS_LIST_IMG', 'comments/list.gif');
             $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'list'), COMMENTS_LIST_IMG . sprintf(i18n::ns('%d comment', '%d comments', $count), $count));
         }
         // describe attachments
         if (count($details)) {
             $abstract .= '<p style="margin: 3px 0;">' . join(', ', $details) . '</p>';
         }
         // anchors
         $anchors = array();
         if ($members =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) {
             foreach ($members as $category_id => $attributes) {
                 // add background color to distinguish this category against others
                 if (isset($attributes['background_color']) && $attributes['background_color']) {
                     $attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>';
                 }
                 $anchors[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic');
             }
         }
         if (@count($anchors)) {
             $abstract .= '<p class="tags" style="margin: 3px 0">' . implode(' ', $anchors) . '</p>';
         }
         // poster name
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             if ($item['create_name']) {
                 $author = Users::get_link($item['create_name'], $item['create_address'], $item['create_id']);
             } else {
                 $author = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']);
             }
         }
         // more details
         $details =& Articles::build_dates($anchor, $item);
         // rating
         if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
             $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
         }
         // page details
         if (count($details)) {
             $details = '<p class="details">' . join(', ', $details) . '</p>';
         }
         // this is another row of the output -- title, abstract, (author,) details
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             $cells = array($title, $abstract, $author, $details);
         } else {
             $cells = array($title, $abstract, $details);
         }
         // append this row
         $rows[] = $cells;
     }
     // end of processing
     SQL::free($result);
     // headers
     if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
         $headers = array(i18n::s('Topic'), i18n::s('Abstract'), i18n::s('Poster'), i18n::s('Details'));
     } else {
         $headers = array(i18n::s('Topic'), i18n::s('Abstract'), i18n::s('Details'));
     }
     // return a sortable table
     $text .= Skin::table($headers, $rows, 'grid');
     return $text;
 }
Ejemplo n.º 7
0
Archivo: view.php Proyecto: rair/yacs
     Skin::define_img('FILES_EDIT_IMG', 'files/edit.gif');
     $context['page_tools'][] = Skin::build_link(Files::get_url($item['id'], 'edit'), FILES_EDIT_IMG . i18n::s('Update this file'), 'basic', i18n::s('Press [e] to edit'), FALSE, 'e');
     // post an image, if upload is allowed
     if (Images::allow_creation($item, $anchor, 'file')) {
         Skin::define_img('IMAGES_ADD_IMG', 'images/add.gif');
         $context['page_tools'][] = Skin::build_link('images/edit.php?anchor=' . urlencode('file:' . $item['id']), IMAGES_ADD_IMG . i18n::s('Add an image'), 'basic');
     }
 }
 // restore a previous version, if any
 if (is_object($anchor) && $anchor->is_owned() && Versions::count_for_anchor('file:' . $item['id'])) {
     Skin::define_img('FILES_VERSIONS_IMG', 'files/versions.gif');
     $context['page_tools'][] = Skin::build_link(Versions::get_url('file:' . $item['id'], 'list'), FILES_VERSIONS_IMG . i18n::s('Versions'));
 }
 // delete command provided to associates and owners
 if (is_object($anchor) && $anchor->is_owned() || Surfer::is_associate()) {
     Skin::define_img('FILES_DELETE_IMG', 'files/delete.gif');
     $context['page_tools'][] = Skin::build_link(Files::get_url($item['id'], 'delete'), FILES_DELETE_IMG . i18n::s('Delete this file'));
 }
 // the navigation sidebar
 $text = '';
 if (is_object($anchor)) {
     $neighbours = $anchor->get_neighbours('file', $item);
     $text .= Skin::neighbours($neighbours, 'sidebar');
 }
 // build a nice sidebar box
 if ($text) {
     $text =& Skin::build_box(i18n::s('Navigation'), $text, 'neighbours', 'neighbours');
 }
 $context['components']['neighbours'] = $text;
 // referrals, if any
 $context['components']['referrals'] =& Skin::build_referrals(Files::get_url($item['id']));
Ejemplo n.º 8
0
 /**
  * build a small form to post a comment
  *
  * @param string reference to the anchor to attach the comment
  * @param string the place to come back when complete
  * @return string the HTML tags to put in the page
  */
 public static function get_form($reference, $follow_up = 'comments', $placeholder = null, $file_attachement = true)
 {
     global $context, $render_overlaid;
     // default placeholder
     if (!$placeholder) {
         $placeholder = i18n::s('Reply');
     }
     // the form to post a comment
     $text = '<form method="post" action="' . $context['url_to_root'] . 'comments/edit.php" enctype="multipart/form-data" class="comment_form"><div style="margin: 1em 0;">';
     // use the right editor, maybe wysiwyg
     $text .= Surfer::get_editor('description', '', TRUE, 3, FALSE, $placeholder);
     // bottom commands
     $menu = array();
     // option to add a file
     $anchor = Anchors::get($reference);
     if ($file_attachement && $anchor->allows('creation', 'file')) {
         include_once $context['path_to_root'] . 'files/files.php';
         // input field to appear on demand
         $text .= '<p id="comment_upload" class="details" style="display: none;">' . '<input type="file" name="upload" id="upload" size="30" onchange="if(/\\.zip$/i.test($(this).val())){$(\'#upload_option\').slideDown();}else{$(\'#upload_option\').slideUp();}" />' . ' (&lt;&nbsp;' . $context['file_maximum_size'] . i18n::s('bytes') . ')' . '<input type="hidden" name="file_type" value="upload" /></p>' . '<div id="upload_option" style="display: none;" >' . '<input type="checkbox" name="explode_files" checked="checked" /> ' . i18n::s('Extract files from the archive') . '</div>';
         // the command to add a file
         Skin::define_img('FILES_UPLOAD_IMG', 'files/upload.gif');
         $menu[] = '<a href="#" onclick="$(\'#comment_upload\').slideDown(600);$(this).slideUp(); return false;"><span>' . FILES_UPLOAD_IMG . i18n::s('Add a file') . '</span></a>';
     }
     // the submit button
     $class_submit = $render_overlaid && $follow_up !== 'json' ? 'submit-overlaid' : 'button';
     $menu[] = Skin::build_submit_button(i18n::s('Send'), i18n::s('Press [s] to submit data'), 's', null, $class_submit);
     // case of a ajax submission
     if ($follow_up === 'json') {
         // insert js only once
         static $ajax_comment_form = false;
         if (!$ajax_comment_form) {
             Page::insert_script('Yacs.initAjaxComments();');
             $ajax_comment_form = true;
         }
     }
     // finalize the form
     $text .= '<input type="hidden" name="anchor" value="' . $reference . '" />' . '<input type="hidden" name="follow_up" value="' . $follow_up . '" />' . '<input type="hidden" name="notify_watchers" value="Y" />' . Skin::finalize_list($menu, 'menu_bar') . '</div></form>';
     // done
     return $text;
 }
Ejemplo n.º 9
0
 /**
  * list articles
  *
  * @param resource the SQL result
  * @return a string to be displayed
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // no hovering label
     $href_title = '';
     // we build an array for the skin::build_tabs() function
     $panels = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // panel content
         $text = '';
         // insert anchor prefix
         if (is_object($anchor)) {
             $text .= $anchor->get_prefix();
         }
         // the introduction text, if any
         if (is_object($overlay)) {
             $text .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
         } elseif (isset($item['introduction']) && trim($item['introduction'])) {
             $text .= Skin::build_block($item['introduction'], 'introduction');
         }
         // get text related to the overlay, if any
         if (is_object($overlay)) {
             $text .= $overlay->get_text('view', $item);
         }
         // filter description, if necessary
         if (is_object($overlay)) {
             $description = $overlay->get_text('description', $item);
         } else {
             $description = $item['description'];
         }
         // the beautified description, which is the actual page body
         if ($description) {
             // use adequate label
             if (is_object($overlay) && ($label = $overlay->get_label('description'))) {
                 $text .= Skin::build_block($label, 'title');
             }
             // beautify the target page
             $text .= Skin::build_block($description, 'description', '', $item['options']);
         }
         // list files only to people able to change the page
         if (Articles::allow_modification($item, $anchor)) {
             $embedded = NULL;
         } else {
             $embedded = Codes::list_embedded($item['description']);
         }
         // build a complete box
         $box = array('bar' => array(), 'text' => '');
         // count the number of files in this article
         if ($count = Files::count_for_anchor('article:' . $item['id'], FALSE, $embedded)) {
             if ($count > 20) {
                 $box['bar'] += array('_count' => sprintf(i18n::ns('%d file', '%d files', $count), $count));
             }
             // list files by date (default) or by title (option files_by_title)
             $offset = ($zoom_index - 1) * FILES_PER_PAGE;
             if (Articles::has_option('files_by', $anchor, $item) == 'title') {
                 $items = Files::list_by_title_for_anchor('article:' . $item['id'], 0, 300, 'article:' . $item['id'], $embedded);
             } else {
                 $items = Files::list_by_date_for_anchor('article:' . $item['id'], 0, 300, 'article:' . $item['id'], $embedded);
             }
             // actually render the html
             if (is_array($items)) {
                 $box['text'] .= Skin::build_list($items, 'decorated');
             } elseif (is_string($items)) {
                 $box['text'] .= $items;
             }
             // the command to post a new file
             if (Files::allow_creation($item, $anchor, 'article')) {
                 Skin::define_img('FILES_UPLOAD_IMG', 'files/upload.gif');
                 $box['bar'] += array('files/edit.php?anchor=' . urlencode('article:' . $item['id']) => FILES_UPLOAD_IMG . i18n::s('Add a file'));
             }
         }
         // some files have been attached to this page
         if ($page == 1 && $count > 1) {
             // the command to download all files
             $link = 'files/fetch_all.php?anchor=' . urlencode('article:' . $item['id']);
             if ($count > 20) {
                 $label = i18n::s('Zip 20 first files');
             } else {
                 $label = i18n::s('Zip all files');
             }
             $box['bar'] += array($link => $label);
         }
         // there is some box content
         if ($box['text']) {
             $text .= Skin::build_content('files', i18n::s('Files'), $box['text'], $box['bar']);
         }
         // list of comments
         $title_label = '';
         if (is_object($anchor)) {
             $title_label = ucfirst($overlay->get_label('list_title', 'comments'));
         }
         if (!$title_label) {
             $title_label = i18n::s('Comments');
         }
         // no layout yet
         $layout = NULL;
         // label to create a comment
         $add_label = '';
         if (is_object($overlay)) {
             $add_label = $overlay->get_label('new_command', 'comments');
         }
         if (!$add_label) {
             $add_label = i18n::s('Post a comment');
         }
         // get a layout from anchor
         $layout =& Comments::get_layout($anchor, $item);
         // provide author information to layout
         if (is_object($layout) && isset($item['create_id']) && $item['create_id']) {
             $layout->set_focus('user:'******'create_id']);
         }
         // the maximum number of comments per page
         if (is_object($layout)) {
             $items_per_page = $layout->items_per_page();
         } else {
             $items_per_page = COMMENTS_PER_PAGE;
         }
         // the first comment to list
         $offset = 0;
         if (is_object($layout) && method_exists($layout, 'set_offset')) {
             $layout->set_offset($offset);
         }
         // build a complete box
         $box = array('bar' => array(), 'prefix_bar' => array(), 'text' => '');
         // feed the wall
         if (Comments::allow_creation($item, $anchor)) {
             $box['text'] .= Comments::get_form('article:' . $item['id']);
         }
         // a navigation bar for these comments
         if ($count = Comments::count_for_anchor('article:' . $item['id'])) {
             if ($count > 20) {
                 $box['bar'] += array('_count' => sprintf(i18n::ns('%d comment', '%d comments', $count), $count));
             }
             // list comments by date
             $items = Comments::list_by_date_for_anchor('article:' . $item['id'], $offset, $items_per_page, $layout, TRUE);
             // actually render the html
             if (is_array($items)) {
                 $box['text'] .= Skin::build_list($items, 'rows');
             } elseif (is_string($items)) {
                 $box['text'] .= $items;
             }
             // navigation commands for comments
             $prefix = Comments::get_url('article:' . $item['id'], 'navigate');
             $box['bar'] = array_merge($box['bar'], Skin::navigate(NULL, $prefix, $count, $items_per_page, $zoom_index));
         }
         // ensure that the surfer can change content
         if (Articles::allow_modification($item, $anchor)) {
             // view or modify this section
             $menu = array();
             $box['bar'] += array(Articles::get_permalink($item) => i18n::s('View the page'));
             if (!is_object($overlay) || !($label = $overlay->get_label('edit_command', 'articles'))) {
                 $label = i18n::s('Edit this page');
             }
             $box['bar'] += array(Articles::get_url($item['id'], 'edit') => $label);
         }
         // show commands
         if (count($box['bar'])) {
             // commands before the box
             $box['text'] = Skin::build_list($box['prefix_bar'], 'menu_bar') . $box['text'];
             // append the menu bar at the end
             $box['text'] .= Skin::build_list($box['bar'], 'menu_bar');
         }
         // build a box
         if ($box['text']) {
             // put a title if there are other titles or if more than 2048 chars
             $title = '';
             if (preg_match('/(<h1|<h2|<h3|<table|\\[title|\\[subtitle)/i', $context['text'] . $text) || strlen($context['text'] . $text) > 2048) {
                 $title = $title_label;
             }
             // insert a full box
             $text .= Skin::build_box($title, $box['text'], 'header1', 'comments');
         }
         // assemble the full panel
         $panels[] = array('att' . $item['id'], ucfirst(Skin::strip($item['title'], 30)), 'atc' . $item['id'], $text);
     }
     // there is some box content
     if (trim($box['text'])) {
         $text .= $box['text'];
     }
     // format tabs
     $text = Skin::build_tabs($panels);
     // end of processing
     SQL::free($result);
     return $text;
 }
Ejemplo n.º 10
0
Archivo: list.php Proyecto: rair/yacs
     }
     // navigation commands for comments
     $prefix = Comments::get_url($anchor->get_reference(), 'navigate');
     $box['bar'] = array_merge($box['bar'], Skin::navigate($anchor->get_url('comments'), $prefix, $count, $items_per_page, $page, FALSE));
     // list comments by date
     $items = Comments::list_by_date_for_anchor($anchor->get_reference(), $offset, $items_per_page, $layout, TRUE);
     // actually render the html
     if (is_array($items)) {
         $box['text'] .= Skin::build_list($items, 'rows');
     } elseif (is_string($items)) {
         $box['text'] .= $items;
     }
 }
 // the command to post a new comment, if this is allowed
 if (Comments::allow_creation($anchor)) {
     Skin::define_img('COMMENTS_ADD_IMG', 'comments/add.gif');
     $label = '';
     if (is_object($anchor->overlay)) {
         $label = $anchor->overlay->get_label('new_command', 'comments');
     }
     if (!$label) {
         $label = i18n::s('Add a comment');
     }
     $box['bar'] = array_merge($box['bar'], array(Comments::get_url($anchor->get_reference(), 'comment') => COMMENTS_ADD_IMG . $label));
 }
 // show commands
 if (@count($box['bar'])) {
     // append the menu bar at the end
     if (strlen($box['text']) > 10 && $count) {
         $box['text'] .= Skin::build_list($box['bar'], 'menu_bar');
     }
Ejemplo n.º 11
0
 /**
  * list comments as successive notes in a thread
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $output = '';
     // empty list
     if (!SQL::count($result)) {
         return $output;
     }
     // build a list of comments
     $rows = array();
     include_once $context['path_to_root'] . 'comments/comments.php';
     while ($item = SQL::fetch($result)) {
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // get poster information
         $poster = array();
         if ($item['create_name']) {
             if (!($poster = Users::get($item['create_id']))) {
                 $poster['id'] = 0;
                 $poster['full_name'] = $item['create_name'];
                 $poster['email'] = $item['create_address'];
             }
         } else {
             if (!($poster = Users::get($item['edit_id']))) {
                 $poster['id'] = 0;
                 $poster['full_name'] = $item['edit_name'];
                 $poster['email'] = $item['edit_address'];
             }
         }
         // author description
         $author = '';
         // avatar, but not for notifications
         if ($item['type'] != 'notification' && isset($poster['avatar_url']) && $poster['avatar_url']) {
             $author .= '<img src="' . $poster['avatar_url'] . '" alt="" title="avatar" class="avatar" />' . BR;
         }
         // link to poster, if possible
         if (isset($poster['id'])) {
             $author .= Users::get_link($poster['full_name'], $poster['email'], $poster['id']);
         }
         // commands to handle this comment
         $menu = array();
         // get an icon for this comment
         $icon = Comments::get_img($item['type']);
         // link to comment permalink
         $label = Skin::build_link(Comments::get_url($item['id']), $icon, 'basic', i18n::s('View this comment')) . ' ';
         // the creation date
         if ($item['create_date']) {
             $label .= Skin::build_date($item['create_date'], 'with_hour');
         } else {
             $label .= Skin::build_date($item['edit_date'], 'with_hour');
         }
         // flag new comments
         if ($item['create_date'] >= $context['fresh']) {
             $label .= NEW_FLAG;
         }
         $menu[] = $label;
         // an approval -- can be modified, but not deleted
         if ($item['type'] == 'approval') {
             // additional commands for associates and poster and editor
             if ($anchor->is_owned()) {
                 Skin::define_img('COMMENTS_EDIT_IMG', 'comments/edit.gif');
                 $menu[] = Skin::build_link(Comments::get_url($item['id'], 'edit'), COMMENTS_EDIT_IMG . i18n::s('Edit'), 'basic');
             }
             // an automatic notification -- can be deleted, but not modified
         } elseif ($item['type'] == 'notification') {
             // additional commands for associates and poster and editor
             if ($anchor->is_owned()) {
                 Skin::define_img('COMMENTS_DELETE_IMG', 'comments/delete.gif');
                 $menu[] = Skin::build_link(Comments::get_url($item['id'], 'delete'), COMMENTS_DELETE_IMG . i18n::s('Delete'), 'basic');
             }
             // regular case
         } else {
             // additional commands for associates and poster and editor
             if (Comments::allow_modification($anchor, $item)) {
                 Skin::define_img('COMMENTS_EDIT_IMG', 'comments/edit.gif');
                 $menu[] = Skin::build_link(Comments::get_url($item['id'], 'edit'), COMMENTS_EDIT_IMG . i18n::s('Edit'), 'basic');
                 Skin::define_img('COMMENTS_DELETE_IMG', 'comments/delete.gif');
                 $menu[] = Skin::build_link(Comments::get_url($item['id'], 'delete'), COMMENTS_DELETE_IMG . i18n::s('Delete'), 'basic');
             }
         }
         // comment main text
         $text = '';
         // state clearly that this is an approval
         if ($item['type'] == 'approval' && isset($poster['id'])) {
             $text .= '<p>' . sprintf(i18n::s('%s has provided his approval'), Users::get_link($poster['full_name'], $poster['email'], $poster['id'])) . '</p>';
         }
         // display comment main text
         $text .= $item['description'];
         // display signature, but not for notifications
         if ($item['type'] != 'notification') {
             $text .= Users::get_signature($item['create_id']);
         }
         // format and display
         $text = ucfirst(trim($text));
         // float the menu on the right
         if (count($menu)) {
             $text = '<div style="text-align: right">' . Skin::finalize_list($menu, 'menu') . '</div>' . $text;
         }
         // comment has been modified
         if ($item['create_name'] && $item['edit_name'] != $item['create_name']) {
             $text .= '<p class="details">' . ucfirst(sprintf(i18n::s('edited by %s %s'), $item['edit_name'], Skin::build_date($item['edit_date']))) . '</p>';
         }
         // potential replies to this comment
         if ($item['type'] != 'notification') {
             // look for replies
             if ($replies = Comments::list_next($item['id'], 'replies')) {
                 if (is_array($replies)) {
                     $replies = Skin::build_list($replies, 'compact');
                 }
                 $text .= '<div>' . $replies . '</div>';
             }
             // allow to reply to this comment
             if (Comments::allow_creation($anchor)) {
                 // the form to edit a comment
                 $text .= '<form method="post" action="' . $context['url_to_root'] . Comments::get_url($item['id'], 'reply') . '" onsubmit="return validateDocumentPost(this)" enctype="multipart/form-data"><div style="margin-top: 1em;">';
                 // reference the anchor page
                 $text .= '<input type="hidden" name="anchor" value="' . $item['anchor'] . '" />';
                 // remember the id of the replied comment
                 $text .= '<input type="hidden" name="previous_id" value="' . $item['id'] . '" />';
                 // notify watchers
                 $text .= '<input type="hidden" name="notify_watchers" value="Y" />';
                 // ensure id uniqueness
                 static $fuse_id;
                 if (!isset($fuse_id)) {
                     $fuse_id = 1;
                 } else {
                     $fuse_id++;
                 }
                 // a textarea that grow on focus
                 Page::insert_script('var reply' . $fuse_id . '=1;');
                 $text .= '<textarea name="description" id="reply' . $fuse_id . '"' . ' rows="1" cols="50"' . ' onfocus="if(reply' . $fuse_id . '){$(\'div#submit' . $fuse_id . '\').slideDown(600);reply' . $fuse_id . '=0;}">' . '</textarea>' . "\n";
                 // fix number of rows in firefox
                 Page::insert_script('$(function(){' . '$("textarea#reply' . $fuse_id . '")' . '.each(function(){' . 'var lineHeight = parseFloat($(this).css("line-height"));' . 'var lines = $(this).attr("rows")*1 || $(this).prop("rows")*1;' . '$(this).css("height", lines*lineHeight);' . '})' . '.autogrow();' . '});' . "\n");
                 // the submit button
                 $text .= '<div class="menu_bar" style="display: none;" id="submit' . $fuse_id . '">' . Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's') . '</div>';
                 // end of the form
                 $text .= '</div></form>';
             }
         }
         // the main part of the comment, with an id
         $text = '<td class="comment ' . $item['type'] . '" id="comment_' . $item['id'] . '">' . $text . '</td>';
         // this is another row of the output
         $rows[] = '<td class="author ' . $item['type'] . '">' . $author . '</td>' . $text;
     }
     // end of processing
     SQL::free($result);
     // sanity check
     if (!count($rows)) {
         return '';
     }
     // return a table
     $output = Skin::table_prefix('yabb');
     $count = 1;
     foreach ($rows as $row) {
         if ($count % 2) {
             $output .= '<tr class="odd">' . $row . '</tr>';
         } else {
             $output .= '<tr class="even">' . $row . '</tr>';
         }
         $count++;
     }
     $output .= '</table>';
     // process yacs codes
     $output = Codes::beautify($output);
     return $output;
 }
Ejemplo n.º 12
0
 /**
  * list articles as rows in a table
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // build a list of articles
     $rows = array();
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // get the related overlay
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // reset everything
         $id = $summary = $owner = $type = $status = $update = $progress = '';
         // link to the page
         $id = Skin::build_link($url, $item['id'], 'basic');
         // signal articles to be published
         if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
             $summary .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $summary .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $summary .= RESTRICTED_FLAG;
         }
         // indicate the id in the hovering popup
         $hover = i18n::s('View the page');
         if (Surfer::is_member()) {
             $hover .= ' [article=' . $item['id'] . ']';
         }
         // use the title to label the link
         if (is_object($overlay)) {
             $label = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $label = Codes::beautify_title($item['title']);
         }
         // use the title as a link to the page
         $summary .= Skin::build_link($url, $label, 'basic', $hover);
         // signal locked articles
         if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
             $summary .= ' ' . LOCKED_FLAG;
         }
         // flag articles updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $summary .= ' ' . EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $summary .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $summary .= ' ' . UPDATED_FLAG;
         }
         // attachment details
         $details = array();
         // info on related files
         if ($count = Files::count_for_anchor('article:' . $item['id'])) {
             Skin::define_img('FILES_LIST_IMG', 'files/list.gif');
             $details[] = FILES_LIST_IMG . sprintf(i18n::ns('%d file', '%d files', $count), $count);
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             Skin::define_img('LINKS_LIST_IMG', 'links/list.gif');
             $details[] = LINKS_LIST_IMG . sprintf(i18n::ns('%d link', '%d links', $count), $count);
         }
         // comments
         if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
             Skin::define_img('COMMENTS_LIST_IMG', 'comments/list.gif');
             $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'list'), COMMENTS_LIST_IMG . sprintf(i18n::ns('%d comment', '%d comments', $count), $count));
         }
         // combine in-line details
         if (count($details)) {
             $summary .= ' <span class="details">' . trim(implode(' ', $details)) . '</span>';
         }
         // dates
         $summary .= BR . '<span class="details">' . join(BR, Articles::build_dates($anchor, $item)) . '</span>';
         // display all tags
         if ($item['tags']) {
             $summary .= BR . '<span class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>';
         }
         // page owner
         if (isset($item['owner_id']) && ($owner = Users::get($item['owner_id']))) {
             $owner = Users::get_link($owner['full_name'], $owner['email'], $owner['id']);
         }
         // type is provided by the overlay
         if (is_object($overlay)) {
             $type = $overlay->get_value('type', '');
         }
         // status value
         if (is_object($overlay)) {
             $status = $overlay->get_value('status', '');
         }
         // progress value
         if (is_object($overlay)) {
             $progress = $overlay->get_value('progress', '');
         }
         // this is another row of the output
         $cells = array($id, $summary, $owner, $type, $status, $progress);
         // append this row
         $rows[] = $cells;
     }
     // end of processing
     SQL::free($result);
     // headers
     $headers = array(i18n::s('Number'), i18n::s('Information'), i18n::s('Owner'), i18n::s('Type'), i18n::s('Status'), i18n::s('Progress'));
     // return a sortable table
     $text .= Skin::table($headers, $rows, 'grid');
     return $text;
 }
Ejemplo n.º 13
0
Archivo: view.php Proyecto: rair/yacs
        if (Surfer::get_id() && $item['create_id'] == Surfer::get_id()) {
            Skin::define_img('COMMENTS_EDIT_IMG', 'comments/edit.gif');
            $context['page_tools'][] = Skin::build_link(Comments::get_url($item['id'], 'edit'), COMMENTS_EDIT_IMG . i18n::s('Edit'), 'basic', i18n::s('Press [e] to edit'), FALSE, 'e');
        } else {
            Skin::define_img('COMMENTS_REPLY_IMG', 'comments/reply.gif');
            $context['page_tools'][] = Skin::build_link(Comments::get_url($item['id'], 'reply'), COMMENTS_REPLY_IMG . i18n::s('Reply'));
            Skin::define_img('COMMENTS_QUOTE_IMG', 'comments/quote.gif');
            $context['page_tools'][] = Skin::build_link(Comments::get_url($item['id'], 'quote'), COMMENTS_QUOTE_IMG . i18n::s('Quote'));
            if (Surfer::is_associate()) {
                Skin::define_img('COMMENTS_EDIT_IMG', 'comments/edit.gif');
                $context['page_tools'][] = Skin::build_link(Comments::get_url($item['id'], 'edit'), COMMENTS_EDIT_IMG . i18n::s('Edit'), 'basic', i18n::s('Press [e] to edit'), FALSE, 'e');
            }
        }
    }
    // commands for associates, authenticated editors and author
    if (Comments::allow_modification($anchor, $item)) {
        Skin::define_img('COMMENTS_DELETE_IMG', 'comments/delete.gif');
        $context['page_tools'][] = Skin::build_link(Comments::get_url($item['id'], 'delete'), COMMENTS_DELETE_IMG . i18n::s('Delete'));
    }
    // turn this to an article
    if (Surfer::is_associate() || Surfer::is_member() && is_object($anchor) && $anchor->is_owned()) {
        Skin::define_img('COMMENTS_PROMOTE_IMG', 'comments/promote.gif');
        $context['page_tools'][] = Skin::build_link(Comments::get_url($item['id'], 'promote'), COMMENTS_PROMOTE_IMG . i18n::s('Promote'));
    }
    //
    // the referrals, if any, in a sidebar
    //
    $context['components']['referrals'] =& Skin::build_referrals(Comments::get_url($item['id']));
}
// render the skin
render_skin();
Ejemplo n.º 14
0
 /**
  * list sections
  *
  * @param resource the SQL result
  * @return a string to be displayed
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // no hovering label
     $href_title = '';
     // we build an array for the skin::build_tabs() function
     $panels = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'section:' . $item['id']);
         // get the overlay for content of this section, if any
         $content_overlay = NULL;
         if (isset($item['content_overlay'])) {
             $content_overlay = Overlay::bind($item['content_overlay']);
         }
         // panel content
         $text = '';
         // insert anchor prefix
         if (is_object($anchor)) {
             $text .= $anchor->get_prefix();
         }
         // the introduction text, if any
         if (is_object($overlay)) {
             $text .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
         } elseif (isset($item['introduction']) && trim($item['introduction'])) {
             $text .= Skin::build_block($item['introduction'], 'introduction');
         }
         // get text related to the overlay, if any
         if (is_object($overlay)) {
             $text .= $overlay->get_text('view', $item);
         }
         // filter description, if necessary
         if (is_object($overlay)) {
             $description = $overlay->get_text('description', $item);
         } else {
             $description = $item['description'];
         }
         // the beautified description, which is the actual page body
         if ($description) {
             // use adequate label
             if (is_object($overlay) && ($label = $overlay->get_label('description'))) {
                 $text .= Skin::build_block($label, 'title');
             }
             // beautify the target page
             $text .= Skin::build_block($description, 'description', '', $item['options']);
         }
         // delegate rendering to the overlay, where applicable
         if (is_object($content_overlay) && ($overlaid = $content_overlay->render('articles', 'section:' . $item['id'], 1))) {
             $text .= $overlaid;
             // regular rendering
         } elseif (!isset($item['articles_layout']) || $item['articles_layout'] != 'none') {
             // select a layout
             if (!isset($item['articles_layout']) || !$item['articles_layout']) {
                 include_once '../articles/layout_articles.php';
                 $layout = new Layout_articles();
             } else {
                 $layout = Layouts::new_($item['articles_layout'], 'article');
             }
             // avoid links to this page
             if (is_object($layout) && is_callable(array($layout, 'set_variant'))) {
                 $layout->set_focus('section:' . $item['id']);
             }
             // the maximum number of articles per page
             if (is_object($layout)) {
                 $items_per_page = $layout->items_per_page();
             } else {
                 $items_per_page = ARTICLES_PER_PAGE;
             }
             // sort and list articles
             $offset = 0;
             if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
                 $order = $matches[1];
             } elseif (is_callable(array($layout, 'items_order'))) {
                 $order = $layout->items_order();
             } else {
                 $order = 'edition';
             }
             // create a box
             $box = array('top_bar' => array(), 'text' => '', 'bottom_bar' => array());
             // the command to post a new page
             //if(Articles::allow_creation($item, $anchor)) {
             if ($anchor->allows('creation', 'article')) {
                 Skin::define_img('ARTICLES_ADD_IMG', 'articles/add.gif');
                 $url = 'articles/edit.php?anchor=' . urlencode('section:' . $item['id']);
                 if (is_object($content_overlay) && ($label = $content_overlay->get_label('new_command', 'articles'))) {
                 } else {
                     $label = ARTICLES_ADD_IMG . i18n::s('Add a page');
                 }
                 $box['top_bar'] += array($url => $label);
             }
             // list pages under preparation
             $this_section = new section();
             $this_section->load_by_content($item, $anchor);
             if ($this_section->is_assigned()) {
                 if ($order == 'publication' && ($items =& Articles::list_for_anchor_by('draft', 'section:' . $item['id'], 0, 20, 'compact'))) {
                     if (is_array($items)) {
                         $items = Skin::build_list($items, 'compact');
                     }
                     $box['top_bar'] += array('_draft' => Skin::build_sliding_box(i18n::s('Draft pages'), $items));
                 }
             }
             // top menu
             if ($box['top_bar']) {
                 $box['text'] .= Skin::build_list($box['top_bar'], 'menu_bar');
             }
             // get pages
             $items =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], $offset, $items_per_page, $layout);
             // items in the middle
             if (is_array($items) && isset($item['articles_layout']) && $item['articles_layout'] == 'compact') {
                 $box['text'] .= Skin::build_list($items, 'compact');
             } elseif (is_array($items)) {
                 $box['text'] .= Skin::build_list($items, 'decorated');
             } elseif (is_string($items)) {
                 $box['text'] .= $items;
             }
             // no navigation bar with alistapart
             if (!isset($item['articles_layout']) || $item['articles_layout'] != 'alistapart') {
                 // count the number of articles in this section
                 if ($count = Articles::count_for_anchor('section:' . $item['id'])) {
                     if ($count > 20) {
                         $box['bottom_bar'] += array('_count' => sprintf(i18n::ns('%d page', '%d pages', $count), $count));
                     }
                     // navigation commands for articles
                     $home = Sections::get_permalink($item);
                     $prefix = Sections::get_url($item['id'], 'navigate', 'articles');
                     $box['bottom_bar'] += Skin::navigate($home, $prefix, $count, $items_per_page, 1);
                 }
             }
             // bottom menu
             if ($box['bottom_bar']) {
                 $box['text'] .= Skin::build_list($box['bottom_bar'], 'menu_bar');
             }
             // there is some box content
             if ($box['text']) {
                 $text .= $box['text'];
             }
         }
         // layout sub-sections
         if (!isset($item['sections_layout']) || $item['sections_layout'] != 'none') {
             // select a layout
             if (!isset($item['sections_layout']) || !$item['sections_layout']) {
                 include_once 'layout_sections.php';
                 $layout = new Layout_sections();
             } else {
                 $layout = Layouts::new_($item['sections_layout'], 'section');
             }
             // the maximum number of sections per page
             if (is_object($layout)) {
                 $items_per_page = $layout->items_per_page();
             } else {
                 $items_per_page = SECTIONS_PER_PAGE;
             }
             // build a complete box
             $box = array('top_bar' => array(), 'text' => '', 'bottom_bar' => array());
             // the command to add a new section
             //if(Sections::allow_creation($item, $anchor)) {
             if ($anchor->allows('creation', 'section')) {
                 Skin::define_img('SECTIONS_ADD_IMG', 'sections/add.gif');
                 $box['top_bar'] += array('sections/edit.php?anchor=' . urlencode('section:' . $item['id']) => SECTIONS_ADD_IMG . i18n::s('Add a section'));
             }
             // top menu
             if ($box['top_bar']) {
                 $box['text'] .= Skin::build_list($box['top_bar'], 'menu_bar');
             }
             // list items by family then title
             $offset = 0 * $items_per_page;
             $items = Sections::list_by_title_for_anchor('section:' . $item['id'], $offset, $items_per_page, $layout, TRUE);
             // actually render the html for the section
             if (is_array($items) && is_string($item['sections_layout']) && $item['sections_layout'] == 'compact') {
                 $box['text'] .= Skin::build_list($items, 'compact');
             } elseif (is_array($items)) {
                 $box['text'] .= Skin::build_list($items, 'decorated');
             } elseif (is_string($items)) {
                 $box['text'] .= $items;
             }
             // count the number of subsections
             if ($count = Sections::count_for_anchor('section:' . $item['id'])) {
                 if ($count > 20) {
                     $box['bottom_bar'] = array('_count' => sprintf(i18n::ns('%d section', '%d sections', $count), $count));
                 }
                 // navigation commands for sections
                 $home = Sections::get_permalink($item);
                 $prefix = Sections::get_url($item['id'], 'navigate', 'sections');
                 $box['bottom_bar'] += Skin::navigate($home, $prefix, $count, $items_per_page, 1);
             }
             // bottom menu
             if ($box['bottom_bar']) {
                 $box['text'] .= Skin::build_list($box['bottom_bar'], 'menu_bar');
             }
             // there is some box content
             if ($box['text']) {
                 $text .= $box['text'];
             }
         }
         // ensure that the surfer can change content
         if (Sections::allow_modification($item, $anchor)) {
             // view or modify this section
             $menu = array();
             $menu[] = Skin::build_link(Sections::get_permalink($item), i18n::s('View the sub-section'), 'span');
             if (!is_object($overlay) || !($label = $overlay->get_label('edit_command', 'sections'))) {
                 $label = i18n::s('Edit this sub-section');
             }
             $menu[] = Skin::build_link(Sections::get_url($item['id'], 'edit'), $label, 'span');
             $text .= Skin::finalize_list($menu, 'menu_bar');
         }
         // assemble the full panel
         $panels[] = array('stt' . $item['id'], ucfirst(Skin::strip($item['title'], 30)), 'stc' . $item['id'], $text);
     }
     // format tabs
     if ($this->has_variant('as_array')) {
         $text = $panels;
     } else {
         $text = Skin::build_tabs($panels);
     }
     // end of processing
     SQL::free($result);
     return $text;
 }
Ejemplo n.º 15
0
 /**
  * list articles as rows in a table
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // we list pages for one surfer
     // sanity check
     if (!isset($this->focus)) {
         $this->focus = Surfer::get_id();
     }
     // build a list of articles
     Skin::define_img('CHECKED_IMG', 'ajax/accept.png', '*');
     $rows = array();
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // get the related overlay
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // reset everything
         $summary = $update = $owner = $editor = $watcher = '';
         // signal articles to be published
         if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
             $summary .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $summary .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $summary .= RESTRICTED_FLAG;
         }
         // indicate the id in the hovering popup
         $hover = i18n::s('View the page');
         if (Surfer::is_member()) {
             $hover .= ' [article=' . $item['id'] . ']';
         }
         // use the title to label the link
         if (is_object($overlay)) {
             $label = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $label = Codes::beautify_title($item['title']);
         }
         // use the title as a link to the page
         $summary .= Skin::build_link($url, $label, 'basic', $hover);
         // signal locked articles
         if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
             $summary .= ' ' . LOCKED_FLAG;
         }
         // flag articles updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $summary .= ' ' . EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $summary .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $summary .= ' ' . UPDATED_FLAG;
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $summary .= $overlay->get_text('list', $item);
         }
         // attachment details
         $details = array();
         // info on related files
         if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
         }
         // comments
         if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
         }
         // the main anchor link
         if (is_object($anchor) && (!isset($this->focus) || $item['anchor'] != $this->focus)) {
             $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'basic'));
         }
         // combine in-line details
         if (count($details)) {
             $summary .= BR . '<span class="details">' . trim(implode(' &middot; ', $details)) . '</span>';
         }
         // display all tags
         if ($item['tags']) {
             $summary .= BR . '<span class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>';
         }
         // dates
         //			$update = '<span class="details">'.join(BR, Articles::build_dates($anchor, $item)).'</span>';
         // watcher
         if (Articles::is_watched($item['id'], $this->focus)) {
             $watcher = CHECKED_IMG;
         }
         // editor
         if (Articles::is_assigned($item['id'], $this->focus)) {
             $editor = CHECKED_IMG;
         }
         // owner
         if (isset($item['owner_id']) && $item['owner_id'] == $this->focus) {
             $owner = CHECKED_IMG;
         }
         // this is another row of the output
         //			$cells = array($summary, $update, $watcher, $editor, $owner);
         $cells = array($summary, $watcher, $editor, $owner);
         // append this row
         $rows[] = $cells;
     }
     // end of processing
     SQL::free($result);
     // headers
     //		$headers = array(i18n::s('Page'), i18n::s('Dates'), i18n::s('Watcher'), i18n::s('Editor'), i18n::s('Owner'));
     $headers = array(i18n::s('Page'), i18n::s('Watcher'), i18n::s('Editor'), i18n::s('Owner'));
     // return a sortable table
     $text .= Skin::table($headers, $rows, 'grid');
     return $text;
 }
Ejemplo n.º 16
0
 /**
  * build a navigation bar to neighbours
  *
  * This function is useful to help surfers browse sets of images attached to some page.
  * In this case it is invoked from [script]images/view.php[/script], and the anchoring page
  * is supposed to provide URLs to previous and next neighbours ([code]$anchor->get_neighbours()[/code])
  *
  * @param an array of (previous_url, previous_label, next_url, next_label, option_url, option_label)
  * @param string describing the intended layout (ie, 'sidebar', 'manual', 'slideshow')
  * @result some text to be inserted in the page
  *
  * @see articles/view.php
  * @see comments/view.php
  * @see files/view.php
  * @see images/view.php
  * @see locations/view.php
  * @see shared/anchor.php
  */
 public static function &neighbours(&$data, $layout = 'sidebar')
 {
     global $context;
     // return by reference
     $output = NULL;
     // sanity check
     if (!is_array($data)) {
         return $output;
     }
     // extract navigation information from parameters
     $previous_url = '';
     if (isset($data[0]) && $data[0]) {
         $previous_url = $data[0];
     }
     if (!isset($data[1])) {
         $previous_label = $previous_hover = '';
     } elseif ($data[1] && $layout != 'manual') {
         $previous_label = Codes::strip($data[1]);
         $previous_hover = i18n::s('Previous');
     } else {
         $previous_label = i18n::s('Previous');
         $previous_hover = Codes::strip($data[1]);
     }
     $next_url = '';
     if (isset($data[2]) && $data[2]) {
         $next_url = $data[2];
     }
     if (!isset($data[3])) {
         $next_label = $next_hover = '';
     } elseif ($data[3] && $layout != 'manual') {
         $next_label = Codes::strip($data[3]);
         $next_hover = i18n::s('Next');
     } else {
         $next_label = i18n::s('Next');
         $next_hover = Codes::strip($data[3]);
     }
     $option_url = '';
     if (isset($data[4]) && $data[4]) {
         $option_url = $data[4];
     }
     $option_label = '';
     if (isset($data[5]) && $data[5]) {
         $option_label = Codes::strip($data[5]);
     }
     // nothing to do
     if (!$previous_url && !$next_url) {
         return $output;
     }
     // select a layout
     if (!$layout) {
         $layout = 'compact';
         if (preg_match('/\\bimg\\b/', $previous_label . ' ' . $next_label)) {
             $layout = 'table';
         }
     }
     // format labels
     switch ($layout) {
         case 'manual':
             // articles/view.php
             break;
         case 'sidebar':
         default:
             $previous_label = '&laquo; ' . $previous_label;
             $next_label = $next_label . ' &raquo;';
             break;
         case 'slideshow':
             // images/view.php
             Skin::define_img('PREVIOUS_PREFIX', 'tools/previous.gif', '&laquo; ');
             $previous_label = PREVIOUS_PREFIX . $previous_label;
             Skin::define_img('NEXT_SUFFIX', 'tools/next.gif', ' &raquo;');
             $next_label = $next_label . NEXT_SUFFIX;
             break;
     }
     // a link to go backwards
     $previous = '';
     if ($previous_url) {
         $previous =& Skin::build_link($previous_url, $previous_label, 'pager-previous', $previous_hover);
     }
     // a link to go forward
     $next = '';
     if ($next_url) {
         $next =& Skin::build_link($next_url, $next_label, 'pager-next', $next_hover);
     }
     // an option, if any
     $option = '';
     if ($option_url) {
         $option =& Skin::build_link($option_url, $option_label, 'basic');
     } elseif ($option_label) {
         $option = $option_label;
     }
     // layout everything
     $text = '';
     switch ($layout) {
         case 'manual':
             $items = array();
             if ($previous) {
                 $items[] = $previous;
             }
             if ($next) {
                 $items[] = $next;
             }
             if ($option) {
                 $items[] = $option;
             }
             $text .= '<p class="tiny" style="text-align: right; margin: 1em auto">' . implode(MENU_SEPARATOR, $items) . '</p>' . "\n";
             break;
         case 'sidebar':
         default:
             $text .= '<ul>';
             if ($previous) {
                 $text .= '<li class="previous">' . $previous . '</li>';
             }
             if ($next) {
                 $text .= '<li class="next">' . $next . '</li>';
             }
             $text .= '</ul>';
             break;
         case 'slideshow':
             $text .= '<table class="neighbours"><tr>' . '<td class="previous">' . ($previous ? $previous : '&nbsp;') . '</td>' . '<td class="option">' . ($option ? $option : '&nbsp;') . '</td>' . '<td class="next">' . ($next ? $next : '&nbsp;') . '</td>' . '</tr></table>' . "\n";
             break;
     }
     return $text;
 }
Ejemplo n.º 17
0
Archivo: view.php Proyecto: rair/yacs
 if (count($details)) {
     $context['text'] .= '<p class="details">' . ucfirst(implode(', ', $details)) . '</p>';
 }
 // back to the anchor page
 if (is_object($anchor) && $anchor->is_viewable()) {
     $context['text'] .= Skin::build_block(Skin::build_link($anchor->get_url(), i18n::s('Back to main page'), 'button'), 'bottom');
 }
 // page tools
 //
 if ($editable) {
     Skin::define_img('IMAGES_EDIT_IMG', 'images/edit.gif');
     $context['page_tools'][] = Skin::build_link(Images::get_url($item['id'], 'edit'), IMAGES_EDIT_IMG . i18n::s('Update this image'), 'basic', i18n::s('Press [e] to edit'), FALSE, 'e');
 }
 // the delete command is available to associates and editors
 if ($item['id'] && (Surfer::is_associate() || is_object($anchor) && $anchor->is_assigned())) {
     Skin::define_img('IMAGES_DELETE_IMG', 'images/delete.gif');
     $context['page_tools'][] = Skin::build_link(Images::get_url($item['id'], 'delete'), IMAGES_DELETE_IMG . i18n::s('Delete this image'));
 }
 // general help on this page
 //
 $help = '<p>' . i18n::s('To save this image on your hard drive, drag the mouse above the image and use the right button. A contextual pop-up menu should appear. Select the adequate command depending on the browser used.') . '</p>';
 $context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help');
 // thumbnail, in an extra box
 //
 if (Surfer::is_associate() && $item['thumbnail_name'] && $item['thumbnail_name'] != $item['image_name']) {
     $url = $context['url_to_root'] . Files::get_path($item['anchor'], 'images') . '/' . $item['thumbnail_name'];
     $context['components']['boxes'] .= Skin::build_box(i18n::s('Thumbnail'), '<img src="' . $url . '" />', 'boxes');
 }
 // referrals, if any
 //
 $context['components']['referrals'] =& Skin::build_referrals(Images::get_url($item['id']));
Ejemplo n.º 18
0
Archivo: index.php Proyecto: rair/yacs
    // cache, whatever change, for 5 minutes
    Cache::put($cache_id, $text, 'stable', 300);
}
$context['text'] .= $text;
//
// extra panel
//
// page tools
if (Surfer::is_associate()) {
    $context['page_tools'][] = Skin::build_link('feeds/configure.php', i18n::s('Configure'), 'basic');
}
// an extra box with popular standard icons for newsfeeds
$text = '';
Skin::define_img('FEEDS_OPML_IMG', 'feeds/opml.png');
$text .= Skin::build_link(Feeds::get_url('opml'), FEEDS_OPML_IMG, '') . BR;
Skin::define_img('FEEDS_ATOM_IMG', 'feeds/atom.png');
$text .= Skin::build_link(Feeds::get_url('atom'), FEEDS_ATOM_IMG, '') . BR;
Skin::define_img('FEEDS_RSS_IMG', 'feeds/rss_2.0.png');
$text .= Skin::build_link(Feeds::get_url('rss'), FEEDS_RSS_IMG, '') . BR;
Skin::define_img('FEEDS_RDF_IMG', 'feeds/rss_1.0.png');
$text .= Skin::build_link(Feeds::get_url('rdf'), FEEDS_RDF_IMG, '') . BR;
$context['components']['channels'] = Skin::build_box(i18n::s('Pick a feed'), '<p>' . $text . '</p>', 'channels');
// public aggregrators
if (!isset($context['without_internet_visibility']) || $context['without_internet_visibility'] != 'Y') {
    $link = $context['url_to_home'] . $context['url_to_root'] . Feeds::get_url('rss');
    $context['components']['channels'] .= Skin::build_box(i18n::s('Aggregate this site'), '<p>' . join(BR, Skin::build_subscribers($link)) . '</p>', 'channels');
}
// referrals, if any
$context['components']['referrals'] = Skin::build_referrals('feeds/index.php');
// render the skin
render_skin();
Ejemplo n.º 19
0
Archivo: event.php Proyecto: rair/yacs
 /**
  * list dates at some anchor
  *
  * @param string type of replaced items (e.g., 'articles')
  * @param string the anchor to consider (e.g., 'section:123')
  * @param int page index
  * @return string to be inserted in resulting web page, or NULL
  */
 function render($type, $anchor, $page = 1)
 {
     global $context;
     // instead of articles
     if ($type != 'articles') {
         return NULL;
     }
     // get the containing page
     $container = Anchors::get($anchor);
     // handle dates
     include_once $context['path_to_root'] . 'dates/dates.php';
     // the maximum number of articles per page
     if (!defined('DATES_PER_PAGE')) {
         define('DATES_PER_PAGE', 50);
     }
     // where we are
     $offset = ($page - 1) * DATES_PER_PAGE;
     // should we display all dates, or not?
     $with_past_dates = FALSE;
     if (preg_match('/\\bwith_past_dates\\b/i', $this->attributes['overlay_parameters'])) {
         $with_past_dates = TRUE;
     }
     // menu to be displayed at the top
     $menu = array();
     // empowered users can contribute
     if (Articles::allow_creation(NULL, $container)) {
         Skin::define_img('ARTICLES_ADD_IMG', 'articles/add.gif');
         $menu[] = '<div style="display: inline">' . Skin::build_link('articles/edit.php?anchor=' . urlencode($anchor), ARTICLES_ADD_IMG . i18n::s('Add an event'), 'span') . '</div>';
     }
     // ensure access to past dates
     if (!$with_past_dates && ($items = Dates::list_past_for_anchor($anchor, $offset, DATES_PER_PAGE, 'compact'))) {
         // turn an array to a string
         if (is_array($items)) {
             $items =& Skin::build_list($items, 'compact');
         }
         // navigation bar
         $bar = array();
         // count the number of dates in this section
         $stats = Dates::stat_past_for_anchor($anchor);
         if ($stats['count'] > DATES_PER_PAGE) {
             $bar = array_merge($bar, array('_count' => sprintf(i18n::ns('%d date', '%d dates', $stats['count']), $stats['count'])));
         }
         // navigation commands for dates
         if ($section = Sections::get(str_replace('section:', '', $anchor))) {
             $home = Sections::get_permalink($section);
             $prefix = Sections::get_url($section['id'], 'navigate', 'articles');
             $bar = array_merge($bar, Skin::navigate($home, $prefix, $stats['count'], DATES_PER_PAGE, $page));
         }
         // display the bar
         if (is_array($bar)) {
             $items = Skin::build_list($bar, 'menu_bar') . $items;
         }
         // in a separate box
         $menu[] = Skin::build_sliding_box(i18n::s('Past dates'), $items, 'past_dates', TRUE);
     }
     // menu displayed towards the top of the page
     $text = Skin::finalize_list($menu, 'menu_bar');
     // build a list of events
     if (preg_match('/\\blayout_as_list\\b/i', $this->attributes['overlay_parameters'])) {
         // list all dates
         if ($with_past_dates) {
             // navigation bar
             $bar = array();
             // count the number of dates in this section
             $stats = Dates::stat_for_anchor($anchor);
             if ($stats['count'] > DATES_PER_PAGE) {
                 $bar = array_merge($bar, array('_count' => sprintf(i18n::ns('%d date', '%d dates', $stats['count']), $stats['count'])));
             }
             // navigation commands for dates
             $section = Sections::get($anchor);
             $home = Sections::get_permalink($section);
             $prefix = Sections::get_url($section['id'], 'navigate', 'articles');
             $bar = array_merge($bar, Skin::navigate($home, $prefix, $stats['count'], DATES_PER_PAGE, $page));
             // display the bar
             if (count($bar)) {
                 $text .= Skin::build_list($bar, 'menu_bar');
             }
             // list one page of dates
             if ($items = Dates::list_for_anchor($anchor, $offset, DATES_PER_PAGE, 'family')) {
                 $text .= $items;
             }
             // display only future dates to regular surfers
         } else {
             // show future dates on first page
             if ($page == 1 && ($items = Dates::list_future_for_anchor($anchor, 0, 500, 'family', TRUE))) {
                 $text .= $items;
             }
         }
         // deliver a calendar view for current month, plus months around
     } else {
         // show past dates as well
         if ($with_past_dates) {
             $items = Dates::list_for_anchor($anchor, 0, 500, 'links');
         } else {
             $items = Dates::list_future_for_anchor($anchor, 0, 500, 'links', TRUE);
         }
         // layout all these dates
         if ($items) {
             $text .= Dates::build_months($items);
         }
     }
     // integrate this into the page
     return $text;
 }
Ejemplo n.º 20
0
 /**
  * list articles as topics in a forum
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // page size for comments
     include_once $context['path_to_root'] . 'comments/layout_comments_as_updates.php';
     $layout = new Layout_comments_as_updates();
     // build a list of articles
     $rows = array();
     include_once $context['path_to_root'] . 'comments/comments.php';
     while ($item = SQL::fetch($result)) {
         // get the related overlay
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // build a title
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // reset everything
         $text = $prefix = $label = $suffix = $icon = '';
         // signal articles to be published
         if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
             $prefix .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // flag expired articles, and articles updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $suffix = EXPIRED_FLAG . ' ';
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix = NEW_FLAG . ' ';
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix = UPDATED_FLAG . ' ';
         }
         // rating
         if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
             $suffix .= ' ' . Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
         }
         // select an icon for this thread
         $item['comments_count'] = Comments::count_for_anchor('article:' . $item['id']);
         if (is_object($overlay) && $overlay->attributes['overlay_type'] == 'poll') {
             Skin::define_img('POLL_IMG', 'articles/poll.gif');
             $icon = POLL_IMG;
         } elseif ($item['rank'] < 10000) {
             Skin::define_img('STICKY_THREAD_IMG', 'articles/sticky_thread.gif');
             $icon = STICKY_THREAD_IMG;
         } elseif (isset($item['comments_count']) && $item['comments_count'] >= 20) {
             Skin::define_img('VERY_HOT_THREAD_IMG', 'articles/very_hot_thread.gif');
             $icon = VERY_HOT_THREAD_IMG;
         } elseif (isset($item['comments_count']) && $item['comments_count'] >= 10) {
             $icon = HOT_THREAD_IMG;
         } else {
             $icon = THREAD_IMG;
         }
         // indicate the id in the hovering popup
         $hover = i18n::s('View the page');
         if (Surfer::is_member()) {
             $hover .= ' [article=' . $item['id'] . ']';
         }
         // use the title as a link to the page
         $title = $prefix . Skin::build_link($url, ucfirst($title), 'basic', $hover) . $suffix;
         $suffix = '';
         // the introductory text
         $introduction = '';
         if (is_object($overlay)) {
             $introduction = $overlay->get_text('introduction', $item);
         } elseif ($item['introduction']) {
             $introduction = $item['introduction'];
         }
         if ($introduction) {
             $suffix .= BR . Codes::beautify_introduction($introduction);
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $suffix .= $overlay->get_text('list', $item);
         }
         // shortcuts to comments pages
         if (isset($item['comments_count']) && ($pages = (int) ceil($item['comments_count'] / $layout->items_per_page())) && $pages > 1) {
             $suffix .= '<p class="details">Pages ';
             for ($index = 1; $index <= $pages; $index++) {
                 $suffix .= Skin::build_link('comments/list.php?id=article:' . $item['id'] . '&amp;page=' . $index, $index, 'basic', i18n::s('One page of comments')) . ' ';
             }
             $suffix .= Skin::build_link('comments/list.php?id=article:' . $item['id'] . '&amp;page=' . $pages, MORE_IMG, 'basic', i18n::s('Most recent comments')) . '</p>';
         }
         // links to sections and categories
         $anchors = array();
         // the main anchor link
         if (is_object($anchor) && (!isset($this->focus) || $item['anchor'] != $this->focus)) {
             $anchors[] = Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'basic', i18n::s('In this section'));
         }
         // list categories by title, if any
         if ($members =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) {
             foreach ($members as $category_id => $attributes) {
                 // add background color to distinguish this category against others
                 if (isset($attributes['background_color']) && $attributes['background_color']) {
                     $attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>';
                 }
                 if (!isset($this->focus) || $this->focus != 'category:' . $category_id) {
                     $anchors[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic', i18n::s('Related topics'));
                 }
             }
         }
         // list section and categories in the suffix
         if (@count($anchors)) {
             $suffix .= '<p class="tags">' . implode(' ', $anchors) . '</p>';
         }
         // the creator of this article
         $starter = '';
         if ($item['create_name']) {
             $starter = '<span class="details">' . Users::get_link($item['create_name'], $item['create_address'], $item['create_id']) . '</span>';
         }
         // the last editor
         $details = '';
         if ($item['edit_date']) {
             // find a name, if any
             $user = '';
             if ($item['edit_name']) {
                 // label the action
                 if (isset($item['edit_action'])) {
                     $user .= Anchors::get_action_label($item['edit_action']) . ' ';
                 }
                 // name of last editor
                 $user .= sprintf(i18n::s('by %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']));
             }
             $details .= $user . ' ' . Skin::build_date($item['edit_date']);
         }
         // signal locked articles
         if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
             $details .= ', ' . LOCKED_FLAG;
         }
         // poster details
         if ($details) {
             $details = '<p class="details">' . $details . "</p>\n";
         }
         if (!isset($item['comments_count'])) {
             $item['comments_count'] = 0;
         }
         // this is another row of the output
         $cells = array($title . $suffix, 'center=' . $starter, 'center=' . $item['comments_count'], 'center=' . Skin::build_number($item['hits']), $details);
         if (THREAD_IMG) {
             $cells = array_merge(array($icon), $cells);
         }
         $rows[] = $cells;
     }
     // end of processing
     SQL::free($result);
     // headers
     $headers = array(i18n::s('Topic'), 'center=' . i18n::s('Poster'), 'center=' . i18n::s('Replies'), 'center=' . i18n::s('Views'), i18n::s('Last post'));
     if (THREAD_IMG) {
         $headers = array_merge(array(''), $headers);
     }
     // make a sortable table
     $output = Skin::table($headers, $rows, 'yabb');
     return $output;
 }
Ejemplo n.º 21
0
 $followers = '';
 if ($items = Members::list_watchers_by_name_for_anchor('user:'******'id'], 0, 1000, 'compact')) {
     if (is_array($items)) {
         $items = Skin::build_list($items, 'compact');
     }
     if (Surfer::get_id() == $item['id']) {
         $followers .= '<p>' . i18n::s('Persons who follow you:') . '</p>' . $items;
     } else {
         $followers .= '<p>' . sprintf(i18n::s('Persons who follow %s:'), $item['full_name']) . '</p>' . $items;
     }
 }
 // connect to people
 if (Surfer::get_id() && Surfer::get_id() != $item['id']) {
     // suggest a new connection
     if (!Members::check('user:'******'id'], 'user:'******'USERS_WATCH_IMG', 'users/watch.gif');
         $link = Users::get_url('user:'******'id'], 'track');
         $followers .= '<p style="margin: 1em 0;">' . Skin::build_link($link, USERS_WATCH_IMG . sprintf(i18n::s('Follow %s'), $item['full_name']), 'basic', i18n::s('Be notified of additions from this person')) . '</p>';
     }
 }
 // put followers in a sidebar
 if ($followers) {
     $output .= Skin::layout_horizontally($watched, Skin::build_block($followers, 'sidecolumn'));
 } else {
     $output .= $watched;
 }
 // actual transmission except on a HEAD request
 if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
     echo $output;
 }
 // the post-processing hook, then exit
Ejemplo n.º 22
0
    // the command to list all files
    if (count($items)) {
        $items = array_merge($items, array(Files::get_url('article:' . $item['id'], 'list') => i18n::s('All files')));
    }
    $items = Skin::build_list($items, 'compact');
}
// display this aside the thread
if ($items || $invite) {
    $text .= Skin::build_box(i18n::s('Files'), '<div id="thread_files_panel">' . $items . '</div>' . $invite, 'boxes', 'files');
}
// links
//
// new links are allowed
$invite = '';
if (Links::allow_creation($item, $anchor)) {
    Skin::define_img('LINKS_ADD_IMG', 'links/add.gif');
    $link = 'links/edit.php?anchor=' . urlencode('article:' . $item['id']);
    $invite = Skin::build_link($link, LINKS_ADD_IMG . i18n::s('Add a link'));
}
// list links by date (default) or by title (option links_by_title)
if (Articles::has_option('links_by_title', $anchor, $item)) {
    $items = Links::list_by_title_for_anchor('article:' . $item['id'], 0, 20, 'compact');
} else {
    $items = Links::list_by_date_for_anchor('article:' . $item['id'], 0, 20, 'compact');
}
// actually render the html
if (is_array($items)) {
    $items = Skin::build_list($items, 'compact');
}
// display this aside the thread
if ($items . $invite) {
Ejemplo n.º 23
0
Archivo: view.php Proyecto: rair/yacs
        }
        // lock command provided to container and page owners
        if ($cur_article->allows('locking')) {
            if (!isset($item['locked']) || $item['locked'] == 'N') {
                Skin::define_img('ARTICLES_LOCK_IMG', 'articles/lock.gif');
                $context['page_tools'][] = Skin::build_link(Articles::get_url($item['id'], 'lock'), ARTICLES_LOCK_IMG . i18n::s('Lock'));
            } else {
                Skin::define_img('ARTICLES_UNLOCK_IMG', 'articles/unlock.gif');
                $context['page_tools'][] = Skin::build_link(Articles::get_url($item['id'], 'lock'), ARTICLES_UNLOCK_IMG . i18n::s('Unlock'));
            }
        }
        // delete command
        if ($cur_article->allows('deletion')) {
            Skin::define_img('ARTICLES_DELETE_IMG', 'articles/delete.gif');
            if (!is_object($overlay) || !($label = $overlay->get_label('delete_command', 'articles'))) {
                $label = i18n::s('Delete this page');
            }
            $context['page_tools'][] = Skin::build_link(Articles::get_url($item['id'], 'delete'), ARTICLES_DELETE_IMG . $label);
        }
        // duplicate command provided to container owners
        if ($cur_article->allows('duplicate')) {
            Skin::define_img('ARTICLES_DUPLICATE_IMG', 'articles/duplicate.gif');
            if (!is_object($overlay) || !($label = $overlay->get_label('duplicate_command', 'articles'))) {
                $label = i18n::s('Duplicate this page');
            }
            $context['page_tools'][] = Skin::build_link(Articles::get_url($item['id'], 'duplicate'), ARTICLES_DUPLICATE_IMG . $label);
        }
    }
}
// render the skin
render_skin();
Ejemplo n.º 24
0
 /**
  * list articles as a table of content of a manual
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // build a list of articles
     include_once $context['path_to_root'] . 'links/links.php';
     $text .= '<ul class="manual">';
     while ($item = SQL::fetch($result)) {
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // reset everything
         $prefix = $label = $suffix = $icon = $details = '';
         // signal articles to be published
         if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
             $prefix .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if (isset($item['active']) && $item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif (isset($item['active']) && $item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // flag articles updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $suffix .= ' ' . EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= ' ' . UPDATED_FLAG;
         }
         // attachment details
         $details = array();
         // info on related files
         if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
             Skin::define_img('FILES_LIST_IMG', 'files/list.gif');
             $details[] = FILES_LIST_IMG . sprintf(i18n::ns('%d file', '%d files', $count), $count);
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             Skin::define_img('LINKS_LIST_IMG', 'links/list.gif');
             $details[] = LINKS_LIST_IMG . sprintf(i18n::ns('%d link', '%d links', $count), $count);
         }
         // rating
         if ($item['rating_count']) {
             $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
         }
         // describe attachments
         if (count($details)) {
             $suffix .= ' <span class="details">' . join(', ', $details) . '</span>';
         }
         // display all tags
         if ($item['tags']) {
             $suffix .= ' <span class="details">- ' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>';
         }
         // make a link
         $label = $prefix . Skin::build_link($url, $title, 'basic') . $suffix;
         // use the title as a link to the page
         $text .= '<li>' . $label . "</li>\n";
     }
     $text .= '</ul>' . "\n";
     // end of processing
     SQL::free($result);
     return $text;
 }
Ejemplo n.º 25
0
 /**
  * list articles as topics in a forum
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // start a table
     $text .= Skin::table_prefix('jive');
     // headers
     $text .= Skin::table_row(array(i18n::s('Topic'), i18n::s('Content')), 'header');
     // build a list of articles
     $odd = FALSE;
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // one row per article
         $text .= '<tr class="' . ($odd ? 'odd' : 'even') . '"><td>';
         $odd = !$odd;
         // signal articles to be published
         if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
             $text .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $text .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $text .= RESTRICTED_FLAG;
         }
         // use the title as a link to the page
         $text .= Skin::build_link($url, '<strong>' . $title . '</strong>', 'basic');
         // signal locked articles
         if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
             $text .= ' ' . LOCKED_FLAG;
         }
         // flag articles updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $text .= ' ' . EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $text .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $text .= ' ' . UPDATED_FLAG;
         }
         // add details, if any
         $details = array();
         // poster name
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             if ($item['create_name']) {
                 $details[] = sprintf(i18n::s('posted by %s %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']), Skin::build_date($item['create_date']));
             }
         }
         // last update
         $details[] = sprintf(i18n::s('Updated %s'), Skin::build_date($item['edit_date']));
         // add details to the title
         if (count($details)) {
             $text .= '<p class="details" style="margin: 3px 0">' . join(', ', $details) . '</p>';
         }
         // display all tags
         if ($item['tags']) {
             $text .= '<p class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</p>';
         }
         // next cell for the content
         $text .= '</td><td width="70%">';
         // the content to be displayed
         $content = '';
         // rating
         if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
             $content .= Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
         }
         // the introductory text
         if (is_object($overlay)) {
             $content .= Codes::beautify_introduction($overlay->get_text('introduction', $item));
         } else {
             $content .= Codes::beautify_introduction($item['introduction']);
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $content .= $overlay->get_text('list', $item);
         }
         // the description
         $content .= Skin::build_block($item['description'], 'description', '', $item['options']);
         // attachment details
         $details = array();
         // info on related files
         if ($count = Files::count_for_anchor('article:' . $item['id'])) {
             Skin::define_img('FILES_LIST_IMG', 'files/list.gif');
             $details[] = Skin::build_link($url . '#_attachments', FILES_LIST_IMG . sprintf(i18n::ns('%d file', '%d files', $count), $count), 'span');
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             Skin::define_img('LINKS_LIST_IMG', 'links/list.gif');
             $details[] = LINKS_LIST_IMG . sprintf(i18n::ns('%d link', '%d links', $count), $count);
         }
         // count replies
         if ($count = Comments::count_for_anchor('article:' . $item['id'])) {
             $details[] = Skin::build_link($url . '#_discussion', sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'span');
         }
         // the command to reply
         if (Comments::allow_creation($item, $anchor)) {
             Skin::define_img('COMMENTS_ADD_IMG', 'comments/add.gif');
             $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), COMMENTS_ADD_IMG . i18n::s('Post a comment'), 'span');
         }
         // describe attachments
         $content .= Skin::finalize_list($details, 'menu_bar');
         // end the row
         $text .= $content . '</td></tr>';
     }
     // end of processing
     SQL::free($result);
     // return the table
     $text .= Skin::table_suffix();
     return $text;
 }
Ejemplo n.º 26
0
    if (!Surfer::is_associate() && ($overlay->attributes['user_status'] == 'donotdisturb' || $overlay->attributes['user_status'] == 'anonymous' || $item['without_alerts'] == 'Y')) {
        $context['text'] .= '<p>' . sprintf(i18n::s('Sorry, "%s" wish not to receive private message'), $item['nick_name']) . '</p>' . "\n";
        render_skin();
        finalize_page(TRUE);
    }
    $context['text'] .= Users::get_thread_creation_form($item['id']);
    // layout the available contact options
} elseif ($threads = Sections::get('threads')) {
    // do not link to this user profile
    //include_once $context['path_to_root'].'articles/layout_articles_as_timeline.php';
    //$layout = new Layout_articles_as_timeline();
    //$layout->set_variant($item['id']);
    $layout = layouts::new_('last', 'article');
    // i am looking at my own record
    if (Surfer::get_id() == $item['id']) {
        Skin::define_img('ARTICLES_ADD_IMG', 'articles/add.gif');
        $url = 'users/contact.php?start=Y&overlaid=Y';
        $label = ARTICLES_ADD_IMG . i18n::s('Start a new thread');
        // new theard is overlaid
        $label = array(null, $label, null, 'edit-overlaid');
        $menu_top = array($url => $label);
        $context['text'] .= Skin::build_list($menu_top, 'menu_bar');
        $context['text'] .= Members::list_surfer_threads(0, 50, $layout);
        //if($items = Members::list_surfer_threads(0, 50, $layout))
        //	$context['text'] .= Skin::build_list($items, 'compact');
        // navigating another profile
    } else {
        if ($items = Members::list_shared_thread_for_user($item['id'], 0, 50, $layout)) {
            $context['text'] .= '<p>' . sprintf(i18n::s('Your threads with "%s"'), $item['nick_name']) . '</p>' . $items . '<p> </p>' . "\n";
        }
    }
Ejemplo n.º 27
0
    // access previous versions, if any
    if ($has_versions) {
        Skin::define_img('SECTIONS_VERSIONS_IMG', 'sections/versions.gif');
        $context['page_tools'][] = Skin::build_link(Versions::get_url('section:' . $item['id'], 'list'), SECTIONS_VERSIONS_IMG . i18n::s('Versions'), 'basic', i18n::s('Restore a previous version if necessary'));
    }
    // lock the page
    if (!isset($item['locked']) || $item['locked'] == 'N') {
        Skin::define_img('SECTIONS_LOCK_IMG', 'sections/lock.gif');
        $context['page_tools'][] = Skin::build_link(Sections::get_url($item['id'], 'lock'), SECTIONS_LOCK_IMG . i18n::s('Lock'), 'basic');
    } else {
        Skin::define_img('SECTIONS_UNLOCK_IMG', 'sections/unlock.gif');
        $context['page_tools'][] = Skin::build_link(Sections::get_url($item['id'], 'lock'), SECTIONS_UNLOCK_IMG . i18n::s('Unlock'), 'basic');
    }
    // delete the page
    Skin::define_img('SECTIONS_DELETE_IMG', 'sections/delete.gif');
    $context['page_tools'][] = Skin::build_link(Sections::get_url($item['id'], 'delete'), SECTIONS_DELETE_IMG . i18n::s('Delete this section'), 'basic');
    // manage content
    if ($has_content) {
        Skin::define_img('SECTIONS_MANAGE_IMG', 'sections/manage.gif');
        $context['page_tools'][] = Skin::build_link(Sections::get_url($item['id'], 'manage'), SECTIONS_MANAGE_IMG . i18n::s('Manage content'), 'basic', i18n::s('Bulk operations'));
    }
    // duplicate command provided to container owners
    Skin::define_img('SECTIONS_DUPLICATE_IMG', 'sections/duplicate.gif');
    $context['page_tools'][] = Skin::build_link(Sections::get_url($item['id'], 'duplicate'), SECTIONS_DUPLICATE_IMG . i18n::s('Duplicate this section'));
}
// use date of last modification into etag computation
if (isset($item['edit_date'])) {
    $context['page_date'] = $item['edit_date'];
}
// render the skin
render_skin();
Ejemplo n.º 28
0
Archivo: issue.php Proyecto: rair/yacs
 /**
  * add some tabs
  *
  * Display additional information in panels.
  *
  * Accepted action codes:
  * - 'edit' - embedded into the main form page
  *
  * @see overlays/overlay.php
  *
  * @param string the on-going action
  * @param array the hosting record
  * @return an array of array('tab_id', 'tab_label', 'panel_id', 'panel_content') or NULL
  */
 function &get_tabs($variant = 'view', $host = NULL)
 {
     global $context, $local;
     // returned tabs
     $tabs = array();
     $now = strftime('%Y-%m-%d %H:%M:%S', time() + (Surfer::get_gmt_offset() - intval($context['gmt_offset'])) * 3600);
     // trackings
     //
     $tracking = '';
     // only associates and page owners can change the status
     if ($variant == 'edit' && isset($this->anchor) && $this->anchor->is_owned()) {
         // a table of fields
         $fields = array();
         // owner
         $label = i18n::s('Owner');
         if (isset($host['owner_id']) && ($user = Users::get($host['owner_id']))) {
             $value = $user['nick_name'];
         } else {
             $value = '';
         }
         $input = '<input type="text" name="owner" id="owner" value ="' . encode_field($value) . '" size="25" maxlength="32" />';
         $hint = i18n::s('Type some letters of the name and select in the list');
         $fields[] = array($label, $input, $hint);
         // enable owner autocompletion
         Page::insert_script('$(function() { Yacs.autocomplete_names("owner",true); });');
         // priority
         $label = i18n::s('Priority');
         if (!isset($this->attributes['color'])) {
             $this->attributes['color'] = 'green';
         }
         $input = self::get_color_as_radio_buttons($this->attributes['color']);
         $fields[] = array($label, $input);
         // type
         $label = i18n::s('Workflow');
         if (!isset($this->attributes['type'])) {
             $this->attributes['type'] = 'incident';
         }
         $input = '<select name="type" id="type">' . self::get_type_options($this->attributes['type']) . '</select>';
         $fields[] = array($label, $input);
         // format these fields
         $tracking .= Skin::build_form($fields);
         $fields = array();
         // to represent transitions from one step to the next one
         Skin::define_img('NEXT_STEP', 'overlays/next_step.gif', 'V');
         // status
         if (!isset($this->attributes['status'])) {
             $this->attributes['status'] = 'on-going:suspect';
         }
         // create_date
         if (!isset($host['create_date']) || !$host['create_date']) {
             $host['create_date'] = gmstrftime('%Y-%m-%d %H:%M:%S');
         }
         $host['create_date'] = Surfer::from_GMT($host['create_date']);
         if ($this->attributes['type'] == 'feature') {
             $label = i18n::s('Feature request has been created on %s');
         } elseif ($this->attributes['type'] == 'patch') {
             $label = i18n::s('Patch has been submitted on %s');
         } else {
             $label = i18n::s('Page has been created on %s');
         }
         $tracking .= '<div class="bottom" style="margin-bottom: 1em;">' . sprintf($label, Skin::build_input_time('create_date', $host['create_date'], 'date_time') . ' <a onclick="$(\'#create_date\').val(\'' . $now . '\')" style="cursor: pointer;" class="details">' . i18n::s('now') . '</a>') . '</div>';
         $tracking .= NEXT_STEP;
         // qualification_date
         if (isset($this->attributes['qualification_date'])) {
             $this->attributes['qualification_date'] = Surfer::from_GMT($this->attributes['qualification_date']);
         }
         $tracking .= '<div style="margin-top: 1em">' . sprintf(i18n::s('Qualification has taken place on %s'), Skin::build_input_time('qualification_date', isset($this->attributes['qualification_date']) ? $this->attributes['qualification_date'] : NULL_DATE, 'date_time') . ' <a onclick="$(\'#qualification_date\').val(\'' . $now . '\')" style="cursor: pointer;" class="details">' . i18n::s('now') . '</a>') . '<p>';
         $checked = '';
         if (isset($this->attributes['status']) && $this->attributes['status'] == 'on-going:problem') {
             $checked = 'checked="checked"';
         }
         $tracking .= '<input type="radio" name="status" value ="on-going:problem" ' . $checked . ' />&nbsp;' . $this->get_status_label('on-going:problem');
         $checked = '';
         if (isset($this->attributes['status']) && $this->attributes['status'] == 'cancelled:suspect') {
             $checked = 'checked="checked"';
         }
         $tracking .= BR . '<input type="radio" name="status" value ="cancelled:suspect" ' . $checked . ' />&nbsp;' . $this->get_status_label('cancelled:suspect') . '</p></div>';
         $tracking .= NEXT_STEP;
         // analysis_date, except for maintenance cases
         if ($this->attributes['type'] != 'maintenance') {
             if (isset($this->attributes['analysis_date'])) {
                 $this->attributes['analysis_date'] = Surfer::from_GMT($this->attributes['analysis_date']);
             }
             $tracking .= '<div style="margin-top: 1em">' . sprintf(i18n::s('Analysis has ended on %s'), Skin::build_input_time('analysis_date', isset($this->attributes['analysis_date']) ? $this->attributes['analysis_date'] : NULL_DATE, 'date_time') . ' <a onclick="$(\'#analysis_date\').val(\'' . $now . '\')" style="cursor: pointer;" class="details">' . i18n::s('now') . '</a>') . '<p>';
             $checked = '';
             if (isset($this->attributes['status']) && $this->attributes['status'] == 'on-going:issue') {
                 $checked = 'checked="checked"';
             }
             $tracking .= '<input type="radio" name="status" value ="on-going:issue" ' . $checked . ' />&nbsp;' . $this->get_status_label('on-going:issue');
             $checked = '';
             if (isset($this->attributes['status']) && $this->attributes['status'] == 'cancelled:problem') {
                 $checked = 'checked="checked"';
             }
             $tracking .= BR . '<input type="radio" name="status" value ="cancelled:problem" ' . $checked . ' />&nbsp;' . $this->get_status_label('cancelled:problem') . '</p></div>';
             $tracking .= NEXT_STEP;
         }
         // resolution_date
         if (isset($this->attributes['resolution_date'])) {
             $this->attributes['resolution_date'] = Surfer::from_GMT($this->attributes['resolution_date']);
         }
         if ($this->attributes['type'] == 'feature') {
             $label = i18n::s('Assignment has been finalized on %s');
         } elseif ($this->attributes['type'] == 'maintenance') {
             $label = i18n::s('Change has been finalized on %s');
         } elseif ($this->attributes['type'] == 'patch') {
             $label = i18n::s('Assignment has been finalized on %s');
         } else {
             $label = i18n::s('Resolution has been finalized on %s');
         }
         $tracking .= '<div style="margin-top: 1em">' . sprintf($label, Skin::build_input_time('resolution_date', isset($this->attributes['resolution_date']) ? $this->attributes['resolution_date'] : NULL_DATE, 'date_time') . ' <a onclick="$(\'#resolution_date\').val(\'' . $now . '\')" style="cursor: pointer;" class="details">' . i18n::s('now') . '</a>') . '<p>';
         $checked = '';
         if (isset($this->attributes['status']) && $this->attributes['status'] == 'on-going:solution') {
             $checked = 'checked="checked"';
         }
         $tracking .= '<input type="radio" name="status" value ="on-going:solution" ' . $checked . ' />&nbsp;' . $this->get_status_label('on-going:solution');
         $checked = '';
         if (isset($this->attributes['status']) && $this->attributes['status'] == 'cancelled:issue') {
             $checked = 'checked="checked"';
         }
         $tracking .= BR . '<input type="radio" name="status" value ="cancelled:issue" ' . $checked . ' />&nbsp;' . $this->get_status_label('cancelled:issue') . '</p></div>';
         $tracking .= NEXT_STEP;
         // close_date
         if (isset($this->attributes['close_date'])) {
             $this->attributes['close_date'] = Surfer::from_GMT($this->attributes['close_date']);
         }
         $tracking .= '<div style="margin-top: 1em">' . sprintf(i18n::s('Case has been closed on %s'), Skin::build_input_time('close_date', isset($this->attributes['close_date']) ? $this->attributes['close_date'] : NULL_DATE, 'date_time') . ' <a onclick="$(\'#close_date\').val(\'' . $now . '\')" style="cursor: pointer;" class="details">' . i18n::s('now') . '</a>') . '<p>';
         $checked = '';
         if (isset($this->attributes['status']) && $this->attributes['status'] == 'completed:solution') {
             $checked = 'checked="checked"';
         }
         $tracking .= '<input type="radio" name="status" value ="completed:solution" ' . $checked . ' />&nbsp;' . $this->get_status_label('completed:solution');
         $checked = '';
         if (isset($this->attributes['status']) && $this->attributes['status'] == 'cancelled:solution') {
             $checked = 'checked="checked"';
         }
         $tracking .= BR . '<input type="radio" name="status" value ="cancelled:solution" ' . $checked . ' />&nbsp;' . $this->get_status_label('cancelled:solution') . '</p></div>';
     }
     // finalize this tab
     if ($tracking) {
         $tabs[] = array('tracking', i18n::s('Tracking'), 'tracking_panel', $tracking);
     }
     // add these tabs
     return $tabs;
 }
Ejemplo n.º 29
0
         $item['rank'] = 10000;
     }
     $label = i18n::s('Rank');
     $input = '<input type="text" name="rank" id="rank" size="10" value="' . encode_field($item['rank']) . '" maxlength="255" />';
     $hint = sprintf(i18n::s('For %s pages; regular pages are ranked at %s.'), '<a href="#" onclick="$(\'#rank\').value=10; return false;">' . i18n::s('sticky') . '</a>', '<a href="#" onclick="$(\'#rank\').value=10000; return false;">' . i18n::s('10000') . '</a>');
     $fields[] = array($label, $input, $hint);
 }
 // the publication date
 $label = i18n::s('Publication date');
 if (isset($item['publish_date']) && $item['publish_date'] > NULL_DATE) {
     $input = Surfer::from_GMT($item['publish_date']);
 } elseif (isset($item['id']) && (Surfer::is_associate() || Surfer::is_member() && is_object($anchor) && $anchor->is_assigned())) {
     Skin::define_img('ARTICLES_PUBLISH_IMG', 'articles/publish.gif');
     $input = Skin::build_link(Articles::get_url($item['id'], 'publish'), ARTICLES_PUBLISH_IMG . i18n::s('Publish'), 'basic');
 } else {
     Skin::define_img('ARTICLES_UNPUBLISH_IMG', 'articles/unpublish.gif');
     $input = ARTICLES_UNPUBLISH_IMG . i18n::s('not published');
 }
 $fields[] = array($label, $input);
 // the expiry date
 $label = i18n::s('Expiry date');
 if (isset($item['expiry_date']) && $item['expiry_date'] > NULL_DATE) {
     $input = Surfer::from_GMT($item['expiry_date']);
 } else {
     $input = i18n::s('never');
 }
 $fields[] = array($label, $input);
 // the parent section
 if (is_object($anchor)) {
     if (isset($item['id']) && Articles::is_owned($item, $anchor)) {
         $label = i18n::s('Section');
Ejemplo n.º 30
0
Archivo: view.php Proyecto: rair/yacs
 }
 // add extra information from this item, if any
 if (isset($item['extra']) && $item['extra']) {
     $context['components']['boxes'] = Codes::beautify_extra($item['extra']);
 }
 // 'Share' box
 //
 $lines = array();
 // the command to track back
 if (Links::allow_trackback()) {
     Skin::define_img('TOOLS_TRACKBACK_IMG', 'tools/trackback.gif');
     $lines[] = Skin::build_link('links/trackback.php?anchor=' . urlencode('category:' . $item['id']), TOOLS_TRACKBACK_IMG . i18n::s('Reference this page'), 'basic', i18n::s('Various means to link to this page'));
 }
 // print this page
 if (Surfer::is_logged()) {
     Skin::define_img('TOOLS_PRINT_IMG', 'tools/print.gif');
     $lines[] = Skin::build_link(Categories::get_url($item['id'], 'print'), TOOLS_PRINT_IMG . i18n::s('Print this page'), 'basic', i18n::s('Get a paper copy of this page.'));
 }
 // in a side box
 if (count($lines)) {
     $context['components']['share'] = Skin::build_box(i18n::s('Share'), Skin::finalize_list($lines, 'newlines'), 'share', 'share');
 }
 // get news from rss
 if (isset($item['id']) && (!isset($context['skins_general_without_feed']) || $context['skins_general_without_feed'] != 'Y')) {
     $content = Skin::build_link($context['url_to_home'] . $context['url_to_root'] . Categories::get_url($item['id'], 'feed'), i18n::s('Recent pages'), 'xml');
     // public aggregators
     // 		if(!isset($context['without_internet_visibility']) || ($context['without_internet_visibility'] != 'Y'))
     // 			$content .= BR.join(BR, Skin::build_subscribers($context['url_to_home'].$context['url_to_root'].Categories::get_url($item['id'], 'feed'), $item['title']));
     $context['components']['channels'] = Skin::build_box(i18n::s('Monitor'), $content, 'channels', 'feeds');
 }
 // search on keyword, if any