本文整理汇总了PHP中Skin::define_img方法的典型用法代码示例。如果您正苦于以下问题:PHP Skin::define_img方法的具体用法?PHP Skin::define_img怎么用?PHP Skin::define_img使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Skin
的用法示例。
在下文中一共展示了Skin::define_img方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
/**
* 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);
}
示例2: get_fields
/**
* 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;
}
示例3: get_click_to_call
/**
* 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: ' . $item['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;
}
示例4:
}
}
// 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'));
}
示例5: layout
/**
* 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)) {
//.........这里部分代码省略.........
示例6: urlencode
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']));
示例7: get_form
/**
* 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();}" />' . ' (< ' . $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;
}
示例8: layout
/**
* 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);
//.........这里部分代码省略.........
示例9: array_merge
}
// 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');
}
示例10: layout
/**
* 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
//.........这里部分代码省略.........
示例11: layout
/**
* 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', '');
}
//.........这里部分代码省略.........
示例12:
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();
示例13: layout
/**
* 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');
//.........这里部分代码省略.........
示例14: layout
/**
* 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(' · ', $details)) . '</span>';
}
// display all tags
if ($item['tags']) {
$summary .= BR . '<span class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>';
}
// dates
//.........这里部分代码省略.........
示例15: elseif
/**
* 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 = '« ' . $previous_label;
$next_label = $next_label . ' »';
break;
case 'slideshow':
// images/view.php
Skin::define_img('PREVIOUS_PREFIX', 'tools/previous.gif', '« ');
$previous_label = PREVIOUS_PREFIX . $previous_label;
Skin::define_img('NEXT_SUFFIX', 'tools/next.gif', ' »');
$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);
//.........这里部分代码省略.........