本文整理汇总了PHP中Files::get_permalink方法的典型用法代码示例。如果您正苦于以下问题:PHP Files::get_permalink方法的具体用法?PHP Files::get_permalink怎么用?PHP Files::get_permalink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Files
的用法示例。
在下文中一共展示了Files::get_permalink方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_embed
//.........这里部分代码省略.........
if (FLV_IMG_HREF) {
$flashvars .= '&top1=' . urlencode(FLV_IMG_HREF . '|10|10');
}
// rely on Flash
if (Surfer::has_flash()) {
// the full object is built in Javascript --see parameters at http://flv-player.net/players/maxi/documentation/
$output = '<div id="flv_' . $item['id'] . '" class="no_print">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n";
Page::insert_script('var flashvars = { flv:"' . $url . '", ' . str_replace(array('&', '='), array('", ', ':"'), $flashvars) . '", autoload:0, margin:1, showiconplay:1, playeralpha:50, iconplaybgalpha:30, showfullscreen:1, showloading:"always", ondoubleclick:"fullscreen" }' . "\n" . 'var params = { allowfullscreen: "true", allowscriptaccess: "always" }' . "\n" . 'var attributes = { id: "file_' . $item['id'] . '", name: "file_' . $item['id'] . '"}' . "\n" . 'swfobject.embedSWF("' . $flvplayer_url . '", "flv_' . $item['id'] . '", "' . $width . '", "' . $height . '", "9", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", flashvars, params);' . "\n");
// native support
} else {
// <video> is HTML5, <object> is legacy
$output = '<video width="' . $width . '" height="' . $height . '" autoplay="" controls="" src="' . $url . '" >' . "\n" . ' <object width="' . $width . '" height="' . $height . '" data="' . $url . '" type="' . Files::get_mime_type($item['file_name']) . '">' . "\n" . ' <param value="' . $url . '" name="movie" />' . "\n" . ' <param value="true" name="allowFullScreen" />' . "\n" . ' <param value="always" name="allowscriptaccess" />' . "\n" . ' <a href="' . $url . '">No video playback capabilities, please download the file</a>' . "\n" . ' </object>' . "\n" . '</video>' . "\n";
}
// job done
return $output;
// a ganttproject timeline
// a ganttproject timeline
case 'gan':
// where the file is
$path = Files::get_path($item['anchor']) . '/' . rawurlencode($item['file_name']);
// we actually use a transformed version of the file
$cache_id = Cache::hash($path) . '.xml';
// apply the transformation
if (!file_exists($context['path_to_root'] . $cache_id) || filemtime($context['path_to_root'] . $cache_id) < filemtime($context['path_to_root'] . $path) || !($text = Safe::file_get_contents($context['path_to_root'] . $cache_id))) {
// transform from GanttProject to SIMILE Timeline
$text = Files::transform_gan_to_simile($path);
// put in cache
Safe::file_put_contents($cache_id, $text);
}
// load the SIMILE Timeline javascript library in shared/global.php
$context['javascript']['timeline'] = TRUE;
// cache would kill the loading of the library
cache::poison();
// 1 week ago
$now = gmdate('M d Y H:i:s', time() - 7 * 24 * 60 * 60);
// load the right file
$output = '<div id="gantt" style="height: ' . $height . '; width: ' . $width . '; border: 1px solid #aaa; font-family: Trebuchet MS, Helvetica, Arial, sans serif; font-size: 8pt"></div>' . "\n";
Page::insert_script('var simile_handle;' . "\n" . 'function onLoad() {' . "\n" . ' var eventSource = new Timeline.DefaultEventSource();' . "\n" . ' var theme = Timeline.ClassicTheme.create();' . "\n" . ' theme.event.bubble.width = 350;' . "\n" . ' theme.event.bubble.height = 300;' . "\n" . ' var bandInfos = [' . "\n" . ' Timeline.createBandInfo({' . "\n" . ' eventSource: eventSource,' . "\n" . ' date: "' . $now . '",' . "\n" . ' width: "80%",' . "\n" . ' intervalUnit: Timeline.DateTime.WEEK,' . "\n" . ' intervalPixels: 200,' . "\n" . ' theme: theme,' . "\n" . ' layout: "original" // original, overview, detailed' . "\n" . ' }),' . "\n" . ' Timeline.createBandInfo({' . "\n" . ' showEventText: false,' . "\n" . ' trackHeight: 0.5,' . "\n" . ' trackGap: 0.2,' . "\n" . ' eventSource: eventSource,' . "\n" . ' date: "' . $now . '",' . "\n" . ' width: "20%",' . "\n" . ' intervalUnit: Timeline.DateTime.MONTH,' . "\n" . ' intervalPixels: 50' . "\n" . ' })' . "\n" . ' ];' . "\n" . ' bandInfos[1].syncWith = 0;' . "\n" . ' bandInfos[1].highlight = true;' . "\n" . ' bandInfos[1].eventPainter.setLayout(bandInfos[0].eventPainter.getLayout());' . "\n" . ' simile_handle = Timeline.create(document.getElementById("gantt"), bandInfos, Timeline.HORIZONTAL);' . "\n" . ' simile_handle.showLoadingMessage();' . "\n" . ' Timeline.loadXML("' . $context['url_to_home'] . $context['url_to_root'] . $cache_id . '", function(xml, url) { eventSource.loadXML(xml, url); });' . "\n" . ' simile_handle.hideLoadingMessage();' . "\n" . '}' . "\n" . "\n" . 'var resizeTimerID = null;' . "\n" . 'function onResize() {' . "\n" . ' if (resizeTimerID == null) {' . "\n" . ' resizeTimerID = window.setTimeout(function() {' . "\n" . ' resizeTimerID = null;' . "\n" . ' simile_handle.layout();' . "\n" . ' }, 500);' . "\n" . ' }' . "\n" . '}' . "\n" . "\n" . '// observe page major events' . "\n" . '$(document).ready( onLoad);' . "\n" . '$(window).resize(onResize);' . "\n");
// job done
return $output;
// a Freemind map
// a Freemind map
case 'mm':
// if we have an external reference, use it
if (isset($item['file_href']) && $item['file_href']) {
$target_href = $item['file_href'];
// else redirect to ourself
} else {
// ensure a valid file name
$file_name = utf8::to_ascii($item['file_name']);
// where the file is
$path = Files::get_path($item['anchor']) . '/' . rawurlencode($item['file_name']);
// map the file on the regular web space
$url_prefix = $context['url_to_home'] . $context['url_to_root'];
// redirect to the actual file
$target_href = $url_prefix . $path;
}
// allow several viewers to co-exist in the same page
static $freemind_viewer_index;
if (!isset($freemind_viewer_index)) {
$freemind_viewer_index = 1;
} else {
$freemind_viewer_index++;
}
// load flash player
$url = $context['url_to_home'] . $context['url_to_root'] . 'included/browser/visorFreemind.swf';
// variables
$flashvars = 'initLoadFile=' . $target_href . '&openUrl=_self';
$output = '<div id="freemind_viewer_' . $freemind_viewer_index . '">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n";
Page::insert_script('var params = {};' . "\n" . 'params.base = "' . dirname($url) . '/";' . "\n" . 'params.quality = "high";' . "\n" . 'params.wmode = "transparent";' . "\n" . 'params.menu = "false";' . "\n" . 'params.flashvars = "' . $flashvars . '";' . "\n" . 'swfobject.embedSWF("' . $url . '", "freemind_viewer_' . $freemind_viewer_index . '", "' . $width . '", "' . $height . '", "6", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", false, params);' . "\n");
// offer to download a copy of the map
$menu = array($target_href => i18n::s('Browse this map with Freemind'));
// display menu commands below the viewer
$output .= Skin::build_list($menu, 'menu_bar');
// job done
return $output;
// native flash
// native flash
case 'swf':
// where to get the file
if (isset($item['file_href']) && $item['file_href']) {
$url = $item['file_href'];
} else {
$url = $context['url_to_home'] . $context['url_to_root'] . 'files/' . str_replace(':', '/', $item['anchor']) . '/' . rawurlencode($item['file_name']);
}
$output = '<div id="swf_' . $item['id'] . '" class="no_print">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n";
Page::insert_script('var params = {};' . "\n" . 'params.base = "' . dirname($url) . '/";' . "\n" . 'params.quality = "high";' . "\n" . 'params.wmode = "transparent";' . "\n" . 'params.allowfullscreen = "true";' . "\n" . 'params.allowscriptaccess = "always";' . "\n" . 'params.flashvars = "' . $flashvars . '";' . "\n" . 'swfobject.embedSWF("' . $url . '", "swf_' . $item['id'] . '", "' . $width . '", "' . $height . '", "6", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", false, params);' . "\n");
return $output;
// link to file page
// link to file page
default:
// link label
$text = Skin::strip($item['title'] ? $item['title'] : str_replace('_', ' ', $item['file_name']));
// make a link to the target page
$url = Files::get_permalink($item);
// return a complete anchor
$output =& Skin::build_link($url, $text);
return $output;
}
}
示例2: elseif
}
}
// deletion has to be confirmed
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
Logger::error(i18n::s('The action has not been confirmed.'));
} else {
// commands
$menu = array();
$class_submit = $render_overlaid ? 'submit-overlaid' : 'button';
if (!is_object($overlay) || !($delete_text = strtolower($overlay->get_label('delete_command')))) {
$delete_text = i18n::s('delete this file');
}
$menu[] = Skin::build_submit_button(sprintf(i18n::s('Yes, I want to %s'), $delete_text), NULL, NULL, 'confirmed', $class_submit);
if (!$render_overlaid) {
if (isset($item['id'])) {
$menu[] = Skin::build_link(Files::get_permalink($item), i18n::s('Cancel'), 'span');
}
} else {
$menu[] = '<span><a href="javascript:;" onclick="Yacs.closeModalBox();">' . i18n::s('Cancel') . '</a></span>';
}
// 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();');
// use a table for the layout
$context['text'] .= Skin::table_prefix('form');
$lines = 1;
// the title
if ($item['title']) {
$cells = array(i18n::s('Title'), 'left=' . $item['title']);
$context['text'] .= Skin::table_row($cells, $lines++);
示例3: layout
//.........这里部分代码省略.........
$label = Codes::beautify_title($item['title']);
if (!$label) {
$label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name']));
}
// show a reference to the file for members
$hover = i18n::s('Get the file');
if (Surfer::is_member()) {
$hover .= ' [file=' . $item['id'] . ']';
}
// flag files uploaded recently
if ($item['create_date'] >= $context['fresh']) {
$suffix .= NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= UPDATED_FLAG;
}
// one line of text
$box .= $prefix . Skin::build_link($url, $label, 'basic', $hover) . $suffix;
// side icon
if ($item['thumbnail_url']) {
$icon = $item['thumbnail_url'];
} else {
$icon = $context['url_to_root'] . Files::get_icon_url($item['file_name']);
}
// build the complete HTML element
$icon = '<img src="' . $icon . '" alt="" title="' . encode_field(strip_tags($label)) . '" />';
// make it a clickable link
$icon = Skin::build_link($url, $icon, 'basic');
}
// first line of details
$details = array();
// file poster and last action
if ($this->layout_variant != 'no_author') {
$details[] = sprintf(i18n::s('shared by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
} else {
$details[] = Skin::build_date($item['edit_date']);
}
// downloads
if ($item['hits'] > 1) {
$details[] = Skin::build_number($item['hits'], i18n::s('downloads'));
}
// file size
if ($item['file_size'] > 1) {
$details[] = Skin::build_number($item['file_size'], i18n::s('bytes'));
}
// anchor link
if ($anchor && is_string($this->focus) && $this->focus != $anchor->get_reference()) {
$anchor_url = $anchor->get_url();
$anchor_label = ucfirst($anchor->get_title());
$details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor_url, $anchor_label, 'article'));
}
$box .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>';
// append details
$details = array();
// view the file
$details[] = Skin::build_link(Files::get_permalink($item), i18n::s('details'), 'basic');
// file has been detached
if (isset($item['assign_id']) && $item['assign_id']) {
// who has been assigned?
if (Surfer::is($item['assign_id'])) {
$details[] = DRAFT_FLAG . sprintf(i18n::s('reserved by you %s'), Skin::build_date($item['assign_date']));
} else {
$details[] = DRAFT_FLAG . sprintf(i18n::s('reserved by %s %s'), Users::get_link($item['assign_name'], $item['assign_address'], $item['assign_id']), Skin::build_date($item['assign_date']));
}
}
// detach or edit the file
if (Files::allow_modification($item, $anchor)) {
if (!isset($item['assign_id']) || !$item['assign_id']) {
$details[] = Skin::build_link(Files::get_url($item['id'], 'reserve'), i18n::s('reserve'), 'basic', i18n::s('Prevent other persons from changing this file until you update it'));
}
// release reservation
if (isset($item['assign_id']) && $item['assign_id'] && (Surfer::is($item['assign_id']) || is_object($anchor) && $anchor->is_owned())) {
$details[] = Skin::build_link(Files::get_url($item['id'], 'release'), i18n::s('release reservation'), 'basic', i18n::s('Allow other persons to update this file'));
}
if (!isset($item['assign_id']) || !$item['assign_id'] || Surfer::is($item['assign_id']) || is_object($anchor) && $anchor->is_owned()) {
$details[] = Skin::build_link(Files::get_url($item['id'], 'edit'), i18n::s('update'), 'basic', i18n::s('Share a new version of this file, or change details'));
}
}
// delete the file
if (Files::allow_deletion($item, $anchor)) {
$details[] = Skin::build_link(Files::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic');
}
// append details
if (count($details)) {
$box .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>';
}
// insert item icon
if ($icon) {
$list = array(array($box, $icon));
$items[] = Skin::finalize_list($list, 'decorated');
// put the item in a division
} else {
$items[] = '<div style="margin: 0 0 1em 0">' . $box . '</div>';
}
}
// stack all items in a single column
$text = Skin::finalize_list($items, 'rows');
// end of processing
SQL::free($result);
return $text;
}
示例4: layout
/**
* list files
*
* @param resource the SQL result
* @return array of resulting items, or NULL
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($url => $attributes)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// sanity check
if (!isset($this->layout_variant)) {
$this->layout_variant = '';
}
// process all items in the list
while ($item = SQL::fetch($result)) {
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// initialize variables
$prefix = $suffix = $icon = '';
// more details
$url = Files::get_permalink($item);
// codes
$codes = array();
// files that can be embedded
if (preg_match('/\\.(3gp|flv|gan|m4v|mm|mov|mp4|swf)$/i', $item['file_name'])) {
$codes[] = '[embed=' . $item['id'] . ']';
}
// link for direct download
$codes[] = '[file=' . $item['id'] . ']';
$codes[] = '[download=' . $item['id'] . ']';
// integrate codes
if (!isset($_SESSION['surfer_editor']) || $_SESSION['surfer_editor'] == 'yacs') {
foreach ($codes as $code) {
$suffix .= '<a onclick="edit_insert(\'\', \' ' . $code . '\');return false;" title="insert" tabindex="2000">' . $code . '</a> ';
}
} else {
$suffix .= join(' ', $codes);
}
$suffix .= BR . '<span class="details">';
// signal restricted and private files
if ($item['active'] == 'N') {
$suffix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$suffix .= RESTRICTED_FLAG;
}
// file title or file name
$label = Codes::beautify_title($item['title']);
if (!$label) {
$label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name']));
}
$suffix .= $label;
// flag files uploaded recently
if ($item['create_date'] >= $context['fresh']) {
$suffix .= NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= UPDATED_FLAG;
}
$suffix .= '</span>';
// details
$details = array();
if (Surfer::is_logged() && $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 menu bar for associates and poster
if (Surfer::is_empowered()) {
$details[] = Skin::build_link($url, i18n::s('details'), 'basic');
$details[] = Skin::build_link(Files::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic');
$details[] = Skin::build_link(Files::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic');
}
// append details
if (count($details)) {
$suffix .= BR . Skin::finalize_list($details, 'menu');
}
// explicit icon
if ($item['thumbnail_url']) {
$icon = $item['thumbnail_url'];
} else {
$icon = $context['url_to_root'] . Files::get_icon_url($item['file_name']);
}
// list all components for this item
$items[$url] = array($prefix, '_', $suffix, 'file', $icon);
}
// end of processing
SQL::free($result);
return $items;
}
示例5: array
// push the list of uploaded files to the notification
$attributes = array();
$attributes['message'] = '<p>' . i18n::s('Following files have been added:') . '</p>' . $compact_list;
$attributes['anchor'] = $anchor->get_reference();
// notification to send by e-mail
$mail = array();
$mail['subject'] = sprintf(i18n::c('%s: %s'), i18n::c('Contribution'), strip_tags($anchor->get_title()));
$mail['notification'] = Files::build_notification('multiple', $attributes);
// one file has been added
} elseif ($item =& Files::get_by_anchor_and_name($anchor->get_reference(), $uploaded)) {
$context['text'] .= '<p>' . i18n::s('Following file has been added:') . '</p>' . Codes::render_object('file', $item['id']);
// use this file record
$_REQUEST['id'] = $item['id'];
// log single upload
$label = sprintf(i18n::c('New file in %s'), strip_tags($anchor->get_title()));
$link = Files::get_permalink($item);
$description = sprintf(i18n::c('%s at %s'), $item['file_name'], '<a href="' . $link . '">' . $link . '</a>');
Logger::notify('files/edit.php: ' . $label, $description);
// notification to send by e-mail
$mail = array();
$mail['subject'] = sprintf(i18n::c('%s: %s'), i18n::c('Contribution'), strip_tags($anchor->get_title()));
$mail['notification'] = Files::build_notification('upload', $item);
}
// send to anchor watchers
if (isset($_REQUEST['notify_watchers']) && $_REQUEST['notify_watchers'] == 'Y') {
$anchor->alert_watchers($mail, $action, isset($_REQUEST['active']) && $_REQUEST['active'] == 'N');
}
// send to followers of this user
if (isset($_REQUEST['notify_followers']) && $_REQUEST['notify_followers'] == 'Y' && Surfer::get_id() && $_REQUEST['active'] != 'N') {
$mail['message'] = Mailer::build_notification($mail['notification'], 2);
Users::alert_watchers('user:' . Surfer::get_id(), $mail);
示例6: elseif
} elseif ($context['self_url'] && ($canonical = Files::get_permalink($item)) && strncmp($context['self_url'], $canonical, strlen($canonical))) {
Safe::header('Status: 301 Moved Permanently', TRUE, 301);
Safe::header('Location: ' . $canonical);
Logger::error(Skin::build_link($canonical));
// display the page that describes the file
} else {
// remember surfer visit
Surfer::is_visiting(Files::get_permalink($item), Codes::beautify_title($item['title']), 'file:' . $item['id'], $item['active']);
// initialize the rendering engine
Codes::initialize(Files::get_permalink($item));
// prevent search engines to present cache versions of this page
if ($item['active'] != 'Y') {
$context['page_header'] .= "\n" . '<meta name="robots" content="noarchive" />';
}
// add canonical link
$context['page_header'] .= "\n" . '<link rel="canonical" href="' . Files::get_permalink($item) . '" />';
// do not mention details to crawlers
if (!Surfer::is_crawler()) {
// all details
$context['page_details'] .= '<p class="details">';
$details = array();
// information on upload
if (Surfer::is_logged()) {
$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']));
} else {
$details[] = Skin::build_date($item['edit_date']);
}
// all details
$context['page_details'] .= ucfirst(implode(', ', $details));
// reference this item
if (Surfer::is_member()) {
示例7: get_permalink
/**
* get permalink to item
*/
function get_permalink()
{
if (!isset($this->item['id'])) {
return NULL;
}
$link = Files::get_permalink($this->item);
return $link;
}
示例8: get_previous_url
/**
* get url of previous file
*
* This function is used to build navigation bars.
*
* @param array the current item
* @param string the anchor of the current item
* @param string the order, either 'date' or 'title'
* @return some text
*
* @see articles/article.php
*/
public static function get_previous_url($item, $anchor, $order = 'date')
{
global $context;
// sanity check
if (!is_array($item)) {
return $item;
}
// limit the scope of the request
$where = Files::get_sql_where();
// depending on selected sequence
if ($order == 'date') {
$match = "files.edit_date < '" . SQL::escape($item['edit_date']) . "'";
$order = 'files.edit_date';
} elseif ($order == 'title') {
$match = "files.file_name < '" . SQL::escape($item['file_name']) . "'";
$order = 'files.file_name DESC';
} else {
return "unknown order '" . $order . "'";
}
// query the database
$query = "SELECT id, file_name FROM " . SQL::table_name('files') . " AS files " . " WHERE (files.anchor LIKE '" . SQL::escape($anchor) . "') AND (" . $match . ") AND " . $where . " ORDER BY " . $order . " LIMIT 0, 1";
if (!($result = SQL::query($query))) {
return NULL;
}
// no result
if (!SQL::count($result)) {
return NULL;
}
// return url of the first item of the list
$item = SQL::fetch($result);
return Files::get_permalink($item);
}