本文整理汇总了PHP中Codes::strip方法的典型用法代码示例。如果您正苦于以下问题:PHP Codes::strip方法的具体用法?PHP Codes::strip怎么用?PHP Codes::strip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Codes
的用法示例。
在下文中一共展示了Codes::strip方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
//.........这里部分代码省略.........
示例2: array
include_once '../feeds.php';
if (!($items = Feeds::get_local_news(20, 'compact'))) {
return;
}
// keep only titles and ISO8859-1 labels
$titles = array();
$links = array();
$count = 0;
foreach ($items as $url => $label) {
// we are not interested into all attributes
if (is_array($label)) {
$label = $label[1];
}
// strip codes
include_once '../../codes/codes.php';
$label = Codes::strip($label);
// remove every html tag
$label = strip_tags(Safe::html_entity_decode($label));
// remember this
$titles[$count] = $label;
$links[$count] = $url;
$count++;
}
// cache handling --except on scripts/validate.php
if (!headers_sent() && (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'GET')) {
// this is a schockwave object
Safe::header('Content-Type: application/x-shockwave-flash');
// enable 30-minute caching (30*60 = 1800), even through https, to help IE6 on download
http::expire(1800);
// the original content
$page = '';
示例3: layout
/**
* list dates
*
* Recognize following variants:
* - 'no_anchor' to list items attached to one particular anchor
* - 'no_author' to list items attached to one user prodate
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// we return an array of ($url => $attributes)
$items = array();
// process all items in the list
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// initialize variables
$prefix = $suffix = $icon = '';
// the url to view this item
$url = Articles::get_permalink($item);
// build a valid label
$label = Codes::beautify_title($item['title']);
// the introductory text
if ($item['introduction']) {
$suffix .= ' - ' . Codes::strip($item['introduction']);
// link to description, if any
if ($item['description']) {
$suffix .= ' ' . Skin::build_link($url, MORE_IMG, 'more', i18n::s('View the page')) . ' ';
}
}
// 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']));
}
// 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);
}
// info on related comments
if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
}
// rating
if ($item['rating_count']) {
$details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
}
// all details
if (count($details)) {
$suffix .= BR . '<span class="details">' . ucfirst(implode(', ', $details)) . '</span>';
}
// the icon to put in the left column
if ($item['thumbnail_url']) {
$icon = $item['thumbnail_url'];
}
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, 'date', $icon, $item['date_stamp']);
}
// end of processing
SQL::free($result);
return $items;
}
示例4: layout
//.........这里部分代码省略.........
}
$elements[] = $prefix . Skin::build_link($url, $label, 'article') . $suffix;
}
}
}
// info on related files
if ($entity->has_option('files_by') == 'title') {
$items = Files::list_by_title_for_anchor($entity->get_reference(), 0, MAXIMUM_ITEMS_PER_ACCORDION + 1, 'compact');
} else {
$items = Files::list_by_date_for_anchor($entity->get_reference(), 0, MAXIMUM_ITEMS_PER_ACCORDION + 1, 'compact');
}
if ($items) {
// mention the number of items in folded title
$details[] = sprintf(i18n::ns('%d file', '%d files', count($items)), count($items));
// add one link per item
foreach ($items as $url => $label) {
if (is_array($label)) {
$prefix = $label[0];
$suffix = $label[2];
$label = $label[1];
}
$elements[] = $prefix . Skin::build_link($url, $label, 'file') . $suffix;
}
}
// info on related comments
if ($items = Comments::list_by_date_for_anchor($entity->get_reference(), 0, MAXIMUM_ITEMS_PER_ACCORDION + 1, 'compact', TRUE)) {
// mention the number of items in folded title
$details[] = sprintf(i18n::ns('%d comment', '%d comments', count($items)), count($items));
// add one link per item
foreach ($items as $url => $label) {
$prefix = $suffix = '';
if (is_array($label)) {
$prefix = $label[0];
$suffix = rtrim(Codes::strip(' ' . $label[2]), '- ');
$label = $label[1];
}
$elements[] = $prefix . Skin::build_link($url, $label, 'comment') . $suffix;
}
}
// info on related links
if ($entity->has_option('links_by_title')) {
$items = Links::list_by_title_for_anchor($entity->get_reference(), 0, MAXIMUM_ITEMS_PER_ACCORDION + 1, 'compact');
} else {
$items = Links::list_by_date_for_anchor($entity->get_reference(), 0, MAXIMUM_ITEMS_PER_ACCORDION + 1, 'compact');
}
if ($items) {
// mention the number of items in folded title
$details[] = sprintf(i18n::ns('%d link', '%d links', count($items)), count($items));
// add one link per item
foreach ($items as $url => $label) {
$prefix = $suffix = '';
if (is_array($label)) {
$prefix = $label[0];
$suffix = $label[2];
$label = $label[1];
}
$elements[] = $prefix . Skin::build_link($url, $label) . $suffix;
}
}
// list related sub-sections, if any
if ($items_type == 'section') {
if ($items =& Sections::list_by_title_for_anchor($entity->get_reference(), 0, MAXIMUM_ITEMS_PER_ACCORDION + 1, 'compact')) {
// mention the number of sections in folded title
$details[] = sprintf(i18n::ns('%d section', '%d sections', count($items)), count($items));
// add one link per item
foreach ($items as $url => $label) {
示例5: beautify_title
/**
* format a title
*
* New lines and images are the only things accepted in titles.
* The goal is to provide a faster service than beautify()
*
* @param string raw title
* @return string finalized title
*/
public static function beautify_title($text)
{
// suppress pairing codes
$output = Codes::strip($text, FALSE);
// the only code transformed in titles
$output = str_replace(array('[nl]', '[NL]'), '<br />', $output);
// remove everything, except links, breaks and images, and selected tags
$output = strip_tags($output, '<a><abbr><acronym><b><big><br><code><del><div><dfn><em><i><img><ins><p><q><small><span><strong><sub><sup><tt><u>');
// return by reference
return $output;
}