本文整理汇总了PHP中Surfer类的典型用法代码示例。如果您正苦于以下问题:PHP Surfer类的具体用法?PHP Surfer怎么用?PHP Surfer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Surfer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: layout
/**
* list users
*
* @param resource the SQL result
* @return array of ($nick_name => $more)
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($nick_name => $more)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// process all items in the list
while ($item = SQL::fetch($result)) {
// unique identifier
$key = $item['nick_name'];
// use the full name, if nick name is not part of it
$more = '';
if ($item['full_name'] && !preg_match('/\\b' . preg_quote($item['nick_name'], '/') . '\\b/', $item['full_name'])) {
$more = ucfirst($item['full_name']) . ' ';
}
// else use e-mail address, if any --but only to authenticated surfer
if ($item['email'] && Surfer::is_logged()) {
if ($more) {
$more .= '<' . $item['email'] . '>';
} else {
$more .= $item['email'];
}
} elseif ($item['introduction']) {
$more .= $item['introduction'];
}
// record this item
$items[$key] = $more;
}
// end of processing
SQL::free($result);
return $items;
}
开发者ID:rair,项目名称:yacs,代码行数:43,代码来源:layout_users_as_complete.php
示例2: get_fields
/**
* preserve content across page modification
*
* @see overlays/overlay.php
*
* @param the hosting attributes
* @return a list of ($label, $input, $hint)
*/
function get_fields($host, $field_pos = NULL)
{
global $context;
// form fields
$fields = array();
// item identifier
if (!isset($this->attributes['overlay_id'])) {
$this->attributes['overlay_id'] = '';
}
// only associates can change the overlay id
if (Surfer::is_associate()) {
// isset($host['anchor']) && ($parent =& Anchors::get($host['anchor'])) && $parent->is_assigned()) {
$label = i18n::s('Overlay identifier');
$input = '<input type="text" name="overlay_id" value="' . encode_field($this->attributes['overlay_id']) . '" />';
} else {
$label = 'hidden';
$input = '<input type="hidden" name="overlay_id" value="' . encode_field($this->attributes['overlay_id']) . '" />';
}
// hidden attributes
foreach ($this->attributes as $name => $value) {
if (preg_match('/_content$/', $name)) {
$input .= '<input type="hidden" name="' . encode_field($name) . '" value="' . encode_field($value) . '" />';
}
}
// we do have something to preserve
$fields[] = array($label, $input);
// job done
return $fields;
}
开发者ID:rair,项目名称:yacs,代码行数:37,代码来源:mutable.php
示例3: get_comment_notification
public function get_comment_notification($item)
{
global $context;
// build a tease notification for simple members
// sanity check
if (!isset($item['anchor']) || !($anchor = Anchors::get($item['anchor']))) {
throw new Exception('no anchor for this comment');
}
// headline
$headline = sprintf(i18n::c('%s has replied'), Surfer::get_link());
$content = BR;
// shape these
$tease = Skin::build_mail_content($headline, $content);
// a set of links
$menu = array();
// call for action
$link = $context['url_to_home'] . $context['url_to_root'] . Comments::get_url($item['id'], 'view');
$menu[] = Skin::build_mail_button($link, i18n::c('View the reply'), TRUE);
// link to the container
$menu[] = Skin::build_mail_button($anchor->get_url(), $anchor->get_title(), FALSE);
// finalize links
$tease .= Skin::build_mail_menu($menu);
// assemble all parts of the mail
$mail = array();
$mail['subject'] = sprintf(i18n::c('%s: %s'), i18n::c('Reply in the discussion'), strip_tags($anchor->get_title()));
$mail['notification'] = Comments::build_notification($item);
// full notification
$mail['tease'] = Mailer::build_notification($tease, 1);
return $mail;
}
开发者ID:rair,项目名称:yacs,代码行数:30,代码来源:thread.php
示例4: layout
/**
* list servers
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// we return an array of ($url => $attributes)
$items = array();
// process all items in the list
while ($item = SQL::fetch($result)) {
// initialize variables
$prefix = $suffix = $icon = '';
// the url to view this item
$url = Servers::get_url($item['id']);
// use the title as a label
$label = Skin::strip($item['title'], 10);
// flag files uploaded recently
if ($item['edit_date'] >= $context['fresh']) {
$prefix = NEW_FLAG . $prefix;
}
// description
if ($item['description']) {
$suffix .= ' ' . ucfirst(trim($item['description']));
}
// the menu bar for associates and poster
if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) {
$menu = array(Servers::get_url($item['id'], 'edit') => i18n::s('Edit'), Servers::get_url($item['id'], 'delete') => i18n::s('Delete'));
$suffix .= ' ' . Skin::build_list($menu, 'menu');
}
// add a separator
if ($suffix) {
$suffix = ' - ' . $suffix;
}
// append details to the suffix
$suffix .= BR . '<span class="details">';
// details
$details = array();
// item poster
if ($item['edit_name']) {
$details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
}
// the edition date
$details[] = Skin::build_date($item['edit_date']);
// all details
if (count($details)) {
$suffix .= ucfirst(implode(', ', $details)) . "\n";
}
// end of details
$suffix .= '</span>';
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, 'server', $icon);
}
// end of processing
SQL::free($result);
return $items;
}
开发者ID:rair,项目名称:yacs,代码行数:66,代码来源:layout_servers.php
示例5: 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 formatted text
$text = '';
// empty list
if (!SQL::count($result)) {
return $text;
}
// build a list of comments
while ($item = SQL::fetch($result)) {
// automatic notification
if ($item['type'] == 'notification') {
$text = '<dd class="thread_other" style="font-style: italic;">' . ucfirst(trim($item['description'])) . '</dd>' . $text;
} else {
// link to user profile -- open links in separate window to enable side browsing of participant profiles
if ($item['create_id']) {
if ($user = Users::get($item['create_id']) && $user['full_name']) {
$hover = $user['full_name'];
} else {
$hover = NULL;
}
$author = Users::get_link($item['create_name'], $item['create_address'], $item['create_id'], TRUE, $hover);
} else {
$author = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id'], TRUE);
}
// differentiate my posts from others
if (Surfer::get_id() && $item['create_id'] == Surfer::get_id()) {
$style = ' class="thread_me"';
} else {
$style = ' class="thread_other"';
}
// a clickable label
$stamp = '#';
// flag old items on same day
if (!strncmp($item['edit_date'], gmstrftime('%Y-%m-%d %H:%M:%S', time()), 10)) {
$stamp = Skin::build_time($item['edit_date']);
} else {
$stamp = Skin::build_date($item['edit_date']);
}
// append this at the end of the comment
$stamp = ' <div style="float: right; font-size: x-small">' . Skin::build_link(Comments::get_url($item['id']), $stamp, 'basic', i18n::s('Edit')) . '</div>';
// package everything --change order to get oldest first
$text = '<dt' . $style . '>' . $author . '</dt><dd' . $style . '>' . $stamp . ucfirst(trim($item['description'])) . '</dd>' . $text;
}
}
// end of processing
SQL::free($result);
// finalize the returned definition list
if ($text) {
$text = '<dl>' . $text . '</dl>';
}
// process yacs codes
$text = Codes::beautify($text);
return $text;
}
开发者ID:rair,项目名称:yacs,代码行数:62,代码来源:layout_comments_as_thread.php
示例6: add_commands
/**
* extend the page menu
*
* @param string script name
* @param string target anchor, if any
* @param array current menu
* @return array updated menu
*/
function add_commands($script, $anchor, $menu = array())
{
global $context;
// limit the scope of our check to viewed pages
if (!preg_match('/articles\\/view/', $script)) {
return $menu;
}
// surfer has to be authenticated
if (!Surfer::is_logged()) {
return $menu;
}
// sanity checks
if (!$anchor) {
Logger::error(i18n::s('No anchor has been found.'));
} elseif (!($target = Anchors::get($anchor))) {
Logger::error(i18n::s('No anchor has been found.'));
} elseif (!$this->parameters) {
Logger::error(sprintf(i18n::s('No parameter has been provided to %s'), 'behaviors/move_on_article_access'));
} else {
// look at parent container if possible
if (!($origin = Anchors::get($target->get_parent()))) {
$origin = $target;
}
// only container editors can proceed
if ($origin->is_assigned() || Surfer::is_associate()) {
// load target section
$tokens = explode(' ', $this->parameters, 2);
if ($section = Anchors::get('section:' . $tokens[0])) {
// make a label
if (count($tokens) < 2) {
$tokens[1] = sprintf(i18n::s('Move to %s'), $section->get_title());
}
// the target link to move the page
$link = Articles::get_url(str_replace('article:', '', $anchor), 'move', str_replace('section:', '', $section->get_reference()));
// make a sub-menu
$menu = array_merge(array($link => array('', $tokens[1], '', 'button')), $menu);
}
}
}
return $menu;
}
开发者ID:rair,项目名称:yacs,代码行数:49,代码来源:move_on_article_access.php
示例7: get_fields
/**
* get form fields to change the day
*
* @see overlays/overlay.php
*
* @param array hosting attributes
* @return a list of ($label, $input, $hint)
*/
function get_fields($host, $field_pos = NULL)
{
global $context;
$options = '<input type="hidden" name="time_stamp" value="12:00" />' . '<input type="hidden" name="duration" value="1440" />';
// default value is now
if (!isset($this->attributes['date_stamp']) || $this->attributes['date_stamp'] <= NULL_DATE) {
$this->attributes['date_stamp'] = gmstrftime('%Y-%m-%d %H:%M', time() + Surfer::get_gmt_offset() * 3600);
} else {
$this->attributes['date_stamp'] = Surfer::from_GMT($this->attributes['date_stamp']);
}
// split date from time
list($date, $time) = explode(' ', $this->attributes['date_stamp']);
// event time
$label = i18n::s('Date');
$input = Skin::build_input_time('date_stamp', $date, 'date') . $options;
$hint = i18n::s('Use format YYYY-MM-DD');
$fields[] = array($label, $input, $hint);
// ensure that we do have a date
Page::insert_script('func' . 'tion validateOnSubmit(container) {' . "\n" . "\n" . ' if(!Yacs.trim(container.date_stamp.value)) {' . "\n" . ' alert("' . i18n::s('Please provide a date.') . '");' . "\n" . ' container.date_stamp.focus();' . "\n" . ' Yacs.stopWorking();' . "\n" . ' return false;' . "\n" . ' }' . "\n\n" . ' return true;' . "\n" . '}' . "\n");
return $fields;
}
开发者ID:rair,项目名称:yacs,代码行数:29,代码来源:day.php
示例8: array
// the submit button
$context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . "\n" . Skin::finalize_list($menu, 'menu_bar') . '<input type="hidden" name="id" value="' . $item['id'] . '" />' . "\n" . '<input type="hidden" name="confirm" value="yes" />' . "\n" . '</p></form>' . "\n";
// set the focus
Page::insert_script('$("#confirmed").focus();');
// the title of the table
if (isset($item['title'])) {
$context['text'] .= Skin::build_block($item['title'], 'title');
}
// display the full text
$context['text'] .= Skin::build_block($item['description'], 'description');
// execute the query string to build the table
if (isset($item['query']) && $item['query']) {
$context['text'] .= Tables::build($item['id'], 'sortable');
}
// display the query string, if any
if (isset($item['query']) && $item['query']) {
$context['text'] .= BR . '<pre>' . $item['query'] . '</pre>' . BR . "\n";
}
// details
$details = array();
// information on uploader
if (Surfer::is_member() && $item['edit_name']) {
$details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
}
// all details
if ($details) {
$context['text'] .= '<p class="details">' . ucfirst(implode(', ', $details)) . '</p>' . "\n";
}
}
// render the skin
render_skin();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:delete.php
示例9: die
// stop crawlers
if (Surfer::is_crawler()) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
die(i18n::s('You are not allowed to perform this operation.'));
}
// page title
if (isset($item['title'])) {
$context['page_title'] = $item['title'];
}
// not found
if (!$item['id']) {
include '../error.php';
// access denied
} elseif (!Sections::allow_access($item, $anchor)) {
// give anonymous surfers a chance for HTTP authentication
if (!Surfer::is_logged()) {
Safe::header('WWW-Authenticate: Basic realm="' . utf8::to_iso8859($context['site_name']) . '"');
Safe::header('Status: 401 Unauthorized', TRUE, 401);
}
// permission denied to authenticated user
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// describe the section
} else {
// compute the url for this section
$url = Sections::get_permalink($item);
// get a description
if ($item['introduction']) {
$description = Codes::beautify($item['introduction']);
} else {
$description = Skin::strip(Codes::beautify($item['description']), 50);
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:describe.php
示例10: layout
/**
* list users
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return some text
$text = '';
// empty list
if (!($count = SQL::count($result))) {
return $text;
}
// allow for several lists in the same page
static $serial;
if (isset($serial)) {
$serial++;
} else {
$serial = 1;
}
// don't blast too many people
if ($count > 100) {
$checked = '';
} elseif (isset($this->layout_variant) && $this->layout_variant == 'unchecked') {
$checked = '';
} else {
$checked = ' checked="checked"';
}
// div prefix
$text .= '<div id="users_as_mail_panel_' . $serial . '">';
// allow to select/deslect multiple rows at once
$text .= '<input type="checkbox" class="row_selector" onclick="check_user_as_mail_panel_' . $serial . '(\'div#users_as_mail_panel_' . $serial . '\', this);"' . $checked . ' /> ' . i18n::s('Select all/none') . BR;
// process all items in the list
$count = 0;
while ($item = SQL::fetch($result)) {
// we need some address
if (!$item['email']) {
continue;
}
// do not write to myself
if ($item['id'] == Surfer::get_id()) {
continue;
}
// get the related overlay, if any
$overlay = Overlay::load($item, 'user:' . $item['id']);
// column to select the row
$text .= '<input type="checkbox" name="selected_users[]" class="row_selector" value="' . encode_field($item['email']) . '"' . $checked . ' />';
// signal restricted and private users
if ($item['active'] == 'N') {
$text .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$text .= RESTRICTED_FLAG;
}
// the url to view this item
$url = Users::get_permalink($item);
// use the title to label the link
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$title = Codes::beautify_title($item['full_name']);
}
// sanity check
if (!$title) {
$title = $item['nick_name'];
}
// link to this page
$text .= Skin::build_link($url, $title, 'user');
// the introductory text
if ($item['introduction']) {
$text .= '<span class="tiny"> - ' . Codes::beautify_introduction($item['introduction']) . '</span>';
}
// insert overlay data, if any
if (is_object($overlay)) {
$text .= $overlay->get_text('list', $item);
}
// display all tags
if ($item['tags']) {
$text .= ' <span class="tags">' . Skin::build_tags($item['tags'], 'user:' . $item['id']) . '</span>';
}
// append the row
$text .= BR;
$count++;
}
// the script used to check all items at once
Page::insert_script('function check_user_as_mail_panel_' . $serial . '(scope, handle) {' . "\n" . ' $(scope + " input[type=\'checkbox\'].row_selector").each(' . "\n" . ' function() { $(this).attr("checked", $(handle).is(":checked"));}' . "\n" . ' );' . "\n" . '}' . "\n");
// div suffix
$text .= '</div>';
// no valid account has been found
if (!$count) {
$text = '';
}
// end of processing
SQL::free($result);
return $text;
}
开发者ID:rair,项目名称:yacs,代码行数:99,代码来源:layout_users_as_mail.php
示例11: while
$text .= ' ' . Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's');
$text .= BR . '<span class="details">' . i18n::s('Select a .png, .gif or .jpeg image.') . ' (< ' . Skin::build_number($image_maximum_size, i18n::s('bytes')) . ')</span>';
// end of the form
$text .= '</div></form>';
// the script used for form handling at the browser
Page::insert_script('$("#upload").focus();');
$context['text'] .= Skin::build_content(NULL, i18n::s('Upload an image'), $text);
}
// use the library
//
// where images are
$path = 'skins/_reference/avatars';
// browse the path to list directories and files
if ($dir = Safe::opendir($context['path_to_root'] . $path)) {
$text = '';
if (Surfer::may_upload()) {
$text .= '<p>' . i18n::s('Click on one image below to make it your new picture.') . '</p>' . "\n";
}
// build the lists
while (($image = Safe::readdir($dir)) !== FALSE) {
// skip some files
if ($image[0] == '.') {
continue;
}
if (is_dir($context['path_to_root'] . $path . '/' . $image)) {
continue;
}
// consider only images
if (!preg_match('/(\\.gif|\\.jpeg|\\.jpg|\\.png)$/i', $image)) {
continue;
}
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:select_avatar.php
示例12: stat
/**
* get some statistics
*
* @return the resulting ($count, $min_date, $max_date) array
*
* @see links/index.php
*/
public static function stat()
{
global $context;
// if not associate, restrict to links attached to public published not expired pages
if (!Surfer::is_associate()) {
$where = ", " . SQL::table_name('articles') . " AS articles " . " WHERE ((links.anchor_type LIKE 'article') AND (links.anchor_id = articles.id))" . " AND (articles.active='Y')" . " AND NOT ((articles.publish_date is NULL) OR (articles.publish_date <= '0000-00-00'))" . " AND ((articles.expiry_date is NULL)" . "\tOR (articles.expiry_date <= '" . NULL_DATE . "') OR (articles.expiry_date > '" . gmstrftime('%Y-%m-%d %H:%M:%S') . "'))" . " AND (links.edit_id > 0)";
} else {
$where = "WHERE (links.edit_id > 0)";
}
// select among available items
$query = "SELECT COUNT(links.link_url) as count, MIN(links.edit_date) as oldest_date, MAX(links.edit_date) as newest_date" . " FROM " . SQL::table_name('links') . " AS links " . $where;
$output = SQL::query_first($query);
return $output;
}
开发者ID:rair,项目名称:yacs,代码行数:21,代码来源:links.php
示例13: ucfirst
}
// page details
if (is_array($details)) {
$context['text'] .= '<p class="details">' . ucfirst(implode(', ', $details)) . "</p>\n";
}
// insert anchor suffix
if (is_object($anchor)) {
$context['text'] .= $anchor->get_suffix();
}
// back to the anchor page
if (is_object($anchor) && $anchor->is_viewable()) {
$menu = array(Skin::build_link($anchor->get_url(), i18n::s('Back to main page'), 'button'));
$context['text'] .= Skin::build_block(Skin::finalize_list($menu, 'menu_bar'), 'bottom');
}
//
// populate the extra panel
//
// commands for associates and editors
if (Surfer::is_associate() || is_object($anchor) && $anchor->is_assigned()) {
$context['page_tools'][] = Skin::build_link(Locations::get_url($id, 'edit'), i18n::s('Edit'));
$context['page_tools'][] = Skin::build_link(Locations::get_url($id, 'delete'), i18n::s('Delete'));
// commands for the author
} elseif (Surfer::is($item['edit_id'])) {
$context['page_tools'][] = Skin::build_link(Locations::get_url($item['id'], 'edit'), i18n::s('Edit'));
}
// referrals, if any, in a sidebar
//
$context['components']['referrals'] =& Skin::build_referrals(Locations::get_url($item['id']));
}
// render the skin
render_skin();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:view.php
示例14: elseif
// look for the id
$id = NULL;
if (isset($_REQUEST['id'])) {
$id = $_REQUEST['id'];
} elseif (isset($context['arguments'][0])) {
$id = $context['arguments'][0];
} elseif (Surfer::is_logged()) {
$id = Surfer::get_id();
}
$id = strip_tags($id);
// get the item from the database
$item = Users::get($id);
// associates can do what they want
if (Surfer::is_associate()) {
$permitted = TRUE;
} elseif ($item['active'] == 'R' && Surfer::is_member()) {
$permitted = TRUE;
} elseif ($item['active'] == 'Y') {
$permitted = TRUE;
} else {
$permitted = FALSE;
}
// load the skin
load_skin('users');
// path to this page
$context['path_bar'] = array('users/' => i18n::s('People'));
// page title
$context['page_title'] = i18n::s('RSS feed');
// not found
if (!isset($item['id'])) {
include '../error.php';
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:feed.php
示例15: layout
/**
* main function to render layout
*
* @param type $result MySQL object
* @return string the rendering
*/
public function layout($result)
{
global $context;
// we return some text
$text = '';
// type of listed object
$items_type = $this->listed_type;
// this level root reference
if (isset($this->focus) && $this->focus) {
$root_ref = $this->focus;
} elseif (isset($context['current_item']) && $context['current_item']) {
$root_ref = $context['current_item'];
} else {
$root_ref = $items_type . ':index';
}
$this->tree_only = $this->has_variant('tree_only');
// drag&drop zone
$text .= '<div class="tm-ddz tm-drop" data-ref="' . $root_ref . '" data-variant="' . $this->layout_variant . '" >' . "\n";
// root create command
$text .= $this->btn_create();
// root ul
$text .= '<ul class="tm-sub_elems tm-root">' . "\n";
while ($item = SQL::fetch($result)) {
// get the object interface, this may load parent and overlay
$entity = new $items_type($item);
// title
$title = '<a class="tm-zoom" href="' . $entity->get_permalink() . '"><span class="tm-folder">' . $entity->get_title() . '</span></a>';
// sub elements of this entity
$sub = $this->get_sub_level($entity);
// command related to this entity
$cmd = $this->get_interactive_menu();
// one <li> per entity of this level of the tree
$text .= '<li class="tm-drag tm-drop" data-ref="' . $entity->get_reference() . '">' . $title . $cmd . $sub . '</li>' . "\n";
}
// this level may have childs that are not folders (exept index)
// do not search in variant tree_only is setted
if (!preg_match('/index$/', $root_ref) && !$this->tree_only) {
$thislevel = Anchors::get($root_ref);
$text .= $this->get_sub_level($thislevel, true);
// do not search for folders
}
// we have bound styles and scripts, but do not provide on ajax requests
if (!isset($context['AJAX_REQUEST']) || !$context['AJAX_REQUEST']) {
$this->load_scripts_n_styles();
// init js depending on user privilege for this level
if (isset($thislevel)) {
// get surfer privilege for this level
$powered = $thislevel->allows('creation');
} else {
$powered = Surfer::is_associate();
}
$powered = $powered ? 'powered' : '';
// cast to string
Page::insert_script('TreeManager.init("' . $powered . '");');
}
// end drag drop zone
$text .= '</ul></div>' . "\n";
// end of processing
SQL::free($result);
return $text;
}
开发者ID:rair,项目名称:yacs,代码行数:67,代码来源:layout_as_tree_manager.php
示例16: render_embed
/**
* embed an interactive object
*
* The id designates the target file.
* It can also include width and height of the target canvas, as in: '12, 100%, 250px'
*
* @param string id of the target file
* @return string the rendered string
**/
public static function render_embed($id)
{
global $context;
// split parameters
$attributes = preg_split("/\\s*,\\s*/", $id, 4);
$id = $attributes[0];
// get the file
if (!($item = Files::get($id))) {
$output = '[embed=' . $id . ']';
return $output;
}
// stream in a separate page
if (isset($attributes[1]) && preg_match('/window/i', $attributes[1])) {
if (!isset($attributes[2])) {
$attributes[2] = i18n::s('Play in a separate window');
}
$output = '<a href="' . $context['url_to_home'] . $context['url_to_root'] . Files::get_url($item['id'], 'stream', $item['file_name']) . '" onclick="window.open(this.href); return false;" class="button"><span>' . $attributes[2] . '</span></a>';
return $output;
}
// file extension
$extension = strtolower(substr($item['file_name'], -3));
// set a default size
if (!isset($attributes[1])) {
if (!strcmp($extension, 'gan')) {
$attributes[1] = '98%';
} elseif (!strcmp($extension, 'mm') && isset($context['skins_freemind_canvas_width'])) {
$attributes[1] = $context['skins_freemind_canvas_width'];
} else {
$attributes[1] = 480;
}
}
if (!isset($attributes[2])) {
if (!strcmp($extension, 'gan')) {
$attributes[2] = '300px';
} elseif (!strcmp($extension, 'mm') && isset($context['skins_freemind_canvas_height'])) {
$attributes[2] = $context['skins_freemind_canvas_height'];
} else {
$attributes[2] = 360;
}
}
// object attributes
$width = $attributes[1];
$height = $attributes[2];
$flashvars = '';
if (isset($attributes[3])) {
$flashvars = $attributes[3];
}
// rendering depends on file extension
switch ($extension) {
// stream a video
case '3gp':
case 'flv':
case 'm4v':
case 'mov':
case 'mp4':
// a flash player to stream a flash video
$flvplayer_url = $context['url_to_home'] . $context['url_to_root'] . 'included/browser/player_flv_maxi.swf';
// file is elsewhere
if (isset($item['file_href']) && $item['file_href']) {
$url = $item['file_href'];
} else {
$url = $context['url_to_home'] . $context['url_to_root'] . Files::get_url($item['id'], 'fetch', $item['file_name']);
}
// pass parameters to the player
if ($flashvars) {
$flashvars = str_replace('autostart=true', 'autoplay=1', $flashvars) . '&';
}
$flashvars .= 'width=' . $width . '&height=' . $height;
// if there is a static image for this video, use it
if (isset($item['icon_url']) && $item['icon_url']) {
$flashvars .= '&startimage=' . urlencode($item['icon_url']);
}
// if there is a subtitle file for this video, use it
if (isset($item['file_name']) && ($srt = 'files/' . str_replace(':', '/', $item['anchor']) . '/' . str_replace('.' . $extension, '.srt', $item['file_name'])) && file_exists($context['path_to_root'] . $srt)) {
$flashvars .= '&srt=1&srturl=' . urlencode($context['url_to_home'] . $context['url_to_root'] . $srt);
}
// if there is a logo file in the skin, use it
Skin::define_img_href('FLV_IMG_HREF', 'codes/flvplayer_logo.png', '');
if (FLV_IMG_HREF) {
$flashvars .= '&top1=' . urlencode(FLV_IMG_HREF . '|10|10');
}
// rely on Flash
if (Surfer::has_flash()) {
// the full object is built in Javascript --see parameters at http://flv-player.net/players/maxi/documentation/
$output = '<div id="flv_' . $item['id'] . '" class="no_print">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n";
Page::insert_script('var flashvars = { flv:"' . $url . '", ' . str_replace(array('&', '='), array('", ', ':"'), $flashvars) . '", autoload:0, margin:1, showiconplay:1, playeralpha:50, iconplaybgalpha:30, showfullscreen:1, showloading:"always", ondoubleclick:"fullscreen" }' . "\n" . 'var params = { allowfullscreen: "true", allowscriptaccess: "always" }' . "\n" . 'var attributes = { id: "file_' . $item['id'] . '", name: "file_' . $item['id'] . '"}' . "\n" . 'swfobject.embedSWF("' . $flvplayer_url . '", "flv_' . $item['id'] . '", "' . $width . '", "' . $height . '", "9", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", flashvars, params);' . "\n");
// native support
} else {
// <video> is HTML5, <object> is legacy
$output = '<video width="' . $width . '" height="' . $height . '" autoplay="" controls="" src="' . $url . '" >' . "\n" . ' <object width="' . $width . '" height="' . $height . '" data="' . $url . '" type="' . Files::get_mime_type($item['file_name']) . '">' . "\n" . ' <param value="' . $url . '" name="movie" />' . "\n" . ' <param value="true" name="allowFullScreen" />' . "\n" . ' <param value="always" name="allowscriptaccess" />' . "\n" . ' <a href="' . $url . '">No video playback capabilities, please download the file</a>' . "\n" . ' </object>' . "\n" . '</video>' . "\n";
}
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:code_embed.php
示例17: layout
//.........这里部分代码省略.........
$title = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$title = Codes::beautify_title($item['title']);
}
// initialize variables
$prefix = $suffix = $icon = '';
// flag articles that are dead, or created or updated very recently
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$prefix .= EXPIRED_FLAG;
}
// signal articles to be published
if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > $context['now']) {
$prefix .= DRAFT_FLAG;
}
// signal restricted and private articles
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// some details
$details = array();
// info on related files --optional
if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
}
// info on related comments --mandatory
if ($count = Comments::count_for_anchor('article:' . $item['id'], FALSE)) {
$details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
}
// info on related links --optional
if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
}
// details
if (count($details)) {
$suffix .= ' <span class="details">(' . ucfirst(implode(', ', $details)) . ')</span>';
}
// flag popular pages
if ($item['hits'] > 300) {
$suffix .= POPULAR_FLAG;
}
// last contribution
if ($item['edit_action']) {
$action = Anchors::get_action_label($item['edit_action']) . ' ';
} else {
$action = i18n::s('edited');
}
if ($item['edit_name']) {
$suffix .= '<br /><span class="details">' . sprintf(i18n::s('%s by %s %s'), $action, Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date'])) . '</span>';
} else {
$suffix .= '<br /><span class="details">' . $action . ' ' . Skin::build_date($item['edit_date']) . '</span>';
}
// flag articles updated recently
if ($item['create_date'] >= $context['fresh']) {
$suffix .= NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= UPDATED_FLAG;
}
// insert overlay data, if any
if (is_object($overlay)) {
$suffix .= $overlay->get_text('list', $item, $this->focus);
}
// the hovering title
if ($item['introduction'] && $context['skins_with_details'] == 'Y') {
$hover = strip_tags(Codes::beautify_introduction($item['introduction']));
} else {
$hover = i18n::s('View the page');
}
// help members to reference this page
if (Surfer::is_member()) {
$hover .= ' [article=' . $item['id'] . ']';
}
// add an image if available
if ($item['thumbnail_url']) {
$icon = $item['thumbnail_url'];
} elseif (is_callable(array($anchor, 'get_bullet_url'))) {
$icon = $anchor->get_bullet_url();
}
// format the image
if ($icon) {
$icon = Skin::build_link($url, '<img src="' . $icon . '" />', 'basic', $hover);
}
// list all components for this item
if ($odd = !$odd) {
$class = ' class="odd"';
} else {
$class = ' class="even"';
}
// use a table to layout the image properly
if ($icon) {
$text .= '<div' . $class . '><table class="decorated"><tr><td class="image" style="text-align: center">' . $icon . '</td><td class="content">' . $prefix . Skin::build_link($url, Skin::strip($title, 30), 'basic', $hover) . $suffix . '</td></tr></table></div>';
} else {
$text .= '<div' . $class . '>' . $prefix . Skin::build_link($url, Skin::strip($title, 30), 'basic', $hover) . $suffix . '</div>';
}
}
// end of processing
SQL::free($result);
return $text;
}
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:layout_articles_as_timeline.php
示例18: layout
/**
* list sections as topics in a forum
*
* @param resource the SQL result
* @return string the rendered text
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// layout in a table
$text = Skin::table_prefix('wide');
// 'even' is used for title rows, 'odd' for detail rows
$class_title = 'odd';
$class_detail = 'even';
// build a list of sections
$family = '';
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// change the family
if ($item['family'] != $family) {
$family = $item['family'];
// show the family
|
请发表评论