本文整理汇总了PHP中canonical函数的典型用法代码示例。如果您正苦于以下问题:PHP canonical函数的具体用法?PHP canonical怎么用?PHP canonical使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了canonical函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: underscore
/**
* Underscored and lowercased class name of an object, of the form "my.mamespace.my_class"
* @param object|string $object
* @return string
*/
function underscore($object)
{
return strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', canonical($object)));
}
示例2: C14NGeneral
function C14NGeneral($element, $exclusive = FALSE, $withcomments = FALSE)
{
/* IF PHP 5.2+ then use built in canonical functionality */
$php_version = explode('.', PHP_VERSION);
if ($php_version[0] > 5 || $php_version[0] == 5 && $php_version[1] >= 2) {
return $element->C14N($exclusive, $withcomments);
}
/* Must be element or document */
if (!$element instanceof DOMElement && !$element instanceof DOMDocument) {
return NULL;
}
/* Currently only exclusive XML is supported */
if ($exclusive == FALSE) {
throw new Exception("Only exclusive canonicalization is supported in this version of PHP");
}
$copyDoc = new DOMDocument();
canonical($copyDoc, $element, $withcomments);
return $copyDoc->saveXML($copyDoc->documentElement, LIBXML_NOEMPTYTAG);
}
示例3: foreach
foreach ($languages as $language_id => $language_code) {
$sitemap->addItem(canonical($language_id, $language_code, $url->link('catalog/category', 'category_id=' . $category->category_id)), '0.9', 'daily', $category->date_modified);
}
}
}
// Generate product links
$statement = $db->query('SELECT `product_id`, `date_modified` FROM `product` WHERE `status` = 1');
if ($statement->rowCount()) {
foreach ($statement->fetchAll() as $product) {
foreach ($languages as $language_id => $language_code) {
$sitemap->addItem(canonical($language_id, $language_code, $url->link('catalog/product', 'product_id=' . $product->product_id)), '0.8', 'weekly', $product->date_modified);
}
}
}
// Generate tag links
$statement = $db->query('SELECT `td`.`name`,
(SELECT MAX(`p`.`date_modified`)
FROM `product` AS `p`
JOIN `product_to_tag` AS `p2t` ON (`p2t`.`product_id` = `p`.`product_id`)
WHERE `p`.`status` = 1 AND `p2t`.`tag_id` = `td`.`tag_id`) AS `date_modified`
FROM `tag_description` AS `td`
HAVING `date_modified` IS NOT NULL');
if ($statement->rowCount()) {
foreach ($statement->fetchAll() as $search) {
foreach ($languages as $language_id => $language_code) {
$sitemap->addItem(canonical($language_id, $language_code, $url->link('catalog/search', 'q=' . rawurlencode($search->name))), '0.7', 'weekly', $search->date_modified);
}
}
}
// Save sitemap
$sitemap->createSitemapIndex(URL_BASE);
示例4: canonical
/**
* Canonical class name of an object, of the form "My.Namespace.MyClass"
* @param object|string $object
* @return string
*/
public static function canonical($object)
{
return canonical($object);
}
示例5: coreSiteFetch
//.........这里部分代码省略.........
}
// /вывод документа
//Работа с условиями
/*
$out = preg_replace('/\[tag:if_exp:?(.*)\]/u', '<?php
$my_exp000=true;
$my_exp0001=\'$my_exp000=\'. str_replace(\'#var#\',\'$\',<<<BLOCK
$1;
BLOCK
);
@eval($my_exp0001);
if($my_exp000==true)
{
?>', $out);
$out = str_replace('[tag:if_exp_else]', '<?php }else{ ?>', $out);
$out = str_replace('[tag:/if_exp]', '<?php } ?>', $out);
*/
// Тут мы вводим в хеадер иньекцию скриптов.
if (defined('RUB_ID')) {
$rubheader = $AVE_DB->Query("\n\t\t\t\t\t\t\tSELECT rubric_header_template\n\t\t\t\t\t\t\tFROM " . PREFIX . "_rubrics\n\t\t\t\t\t\t\tWHERE Id = '" . RUB_ID . "'\n\t\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t\t", CACHE_LIFETIME)->GetCell();
$out = str_replace('[tag:rubheader]', $rubheader . '[tag:rubheader]', $out);
}
$out = preg_replace('/\\[tag:rfld:([a-zA-Z0-9-_]+)]\\[(more|esc|img|[0-9-]+)]/e', "request_get_document_field(\"\$1\", {$id}, \"\$2\")", $out);
// Если в запросе пришел параметр print, т.е. страница для печати, парсим контент, который обрамлен
// тегами только для печати
if (isset($_REQUEST['print']) && $_REQUEST['print'] == 1) {
$out = str_replace(array('[tag:if_print]', '[/tag:if_print]'), '', $out);
$out = preg_replace('/\\[tag:if_notprint\\](.*?)\\[\\/tag:if_notprint\\]/si', '', $out);
} else {
// В противном случае наоборот, парсим только тот контент, который предназначен НЕ для печати
$out = preg_replace('/\\[tag:if_print\\](.*?)\\[\\/tag:if_print\\]/si', '', $out);
$out = str_replace(array('[tag:if_notprint]', '[/tag:if_notprint]'), '', $out);
}
// получаем из шаблона системный тег, определяющий название темы дизайна
$match = '';
preg_match('/\\[tag:theme:(\\w+)]/', $out, $match);
define('THEME_FOLDER', empty($match[1]) ? DEFAULT_THEME_FOLDER : $match[1]);
$out = preg_replace('/\\[tag:theme:(.*?)]/', '', $out);
// парсим теги модулей
$out = $this->coreModuleTagParse($out);
if (isset($_REQUEST['module']) && !(isset($this->install_modules[$_REQUEST['module']]) && '1' == $this->install_modules[$_REQUEST['module']]->ModuleStatus)) {
display_notice($this->_module_error);
}
// парсим теги системных блоков
$out = preg_replace_callback('/\\[tag:sysblock:([0-9-]+)\\]/', 'parse_sysblock', $out);
// парсим теги системы внутренних запросов
$out = preg_replace_callback('/\\[tag:request:(\\d+)\\]/', 'request_parse', $out);
// парсим теги навигации
$out = preg_replace_callback('/\\[tag:navigation:(\\d+):?([0-9,]*)\\]/', 'parse_navigation', $out);
// парсим теги скрытого текста
$out = parse_hide($out);
// парсим остальные теги основного шаблона
$search = array('[tag:mediapath]', '[tag:path]', '[tag:sitename]', '[tag:document]', '[tag:alias]', '[tag:home]', '[tag:robots]', '[tag:canonical]', '[tag:docid]', '[tag:breadcrumb]');
$replace = array(ABS_PATH . 'templates/' . THEME_FOLDER . '/', ABS_PATH, htmlspecialchars(get_settings('site_name'), ENT_QUOTES), get_redirect_link('print'), @$this->curentdoc->document_alias, get_home_link(), isset($this->curentdoc->document_meta_robots) ? $this->curentdoc->document_meta_robots : '', canonical($_SERVER['REQUEST_URI']), isset($this->curentdoc->Id) ? $this->curentdoc->Id : '', get_breadcrumb());
if (defined('MODULE_CONTENT')) {
// парсинг тегов при выводе из модуля
$search[] = '[tag:maincontent]';
$replace[] = MODULE_CONTENT;
$search[] = '[tag:title]';
$replace[] = htmlspecialchars(defined('MODULE_SITE') ? MODULE_SITE : '', ENT_QUOTES);
$search[] = '[tag:description]';
$replace[] = htmlspecialchars(defined('MODULE_DESCRIPTION') ? MODULE_DESCRIPTION : '', ENT_QUOTES);
$search[] = '[tag:keywords]';
$replace[] = htmlspecialchars(defined('MODULE_KEYWORDS') ? MODULE_KEYWORDS : '', ENT_QUOTES);
} else {
$search[] = '[tag:keywords]';
$replace[] = isset($this->curentdoc->document_meta_keywords) ? htmlspecialchars($this->curentdoc->document_meta_keywords, ENT_QUOTES) : '';
$search[] = '[tag:description]';
$replace[] = isset($this->curentdoc->document_meta_description) ? htmlspecialchars($this->curentdoc->document_meta_description, ENT_QUOTES) : '';
$search[] = '[tag:title]';
$replace[] = htmlspecialchars(pretty_chars($this->curentdoc->document_title), ENT_QUOTES);
}
$search[] = '[tag:maincontent]';
$replace[] = '';
$search[] = '[tag:printlink]';
$replace[] = get_print_link();
$search[] = '[tag:version]';
$replace[] = APP_INFO;
$search[] = '[tag:docviews]';
$replace[] = isset($this->curentdoc->document_count_view) ? $this->curentdoc->document_count_view : '';
// парсим тизер документа
$out = preg_replace('/\\[tag:teaser:(\\d+)\\]/e', "showteaser(\$1)", $out);
if (defined('RUB_ID')) {
$out = preg_replace('/\\[tag:docauthoravatar:(\\d+)\\]/e', "getAvatar(" . intval($this->curentdoc->document_author_id) . ",\"\$1\")", $out);
}
if (defined('RUB_ID')) {
$out = preg_replace('/\\[tag:lang:([a-zA-Z0-9-_]+)\\]/', '<?php if($AVE_Core->curentdoc->document_lang=="$1") { ?>', $out);
} else {
$out = preg_replace('/\\[tag:lang:([a-zA-Z0-9-_]+)\\]/', '<?php if($_SESSION["user_language"]=="$1") { ?>', $out);
}
$out = str_replace('[tag:/lang]', '<?php } ?>', $out);
// парсим остальные теги основного шаблона
$out = str_replace($search, $replace, $out);
unset($search, $replace);
// парсим теги для combine.php
$out = preg_replace_callback('/\\[tag:(css|js):([^ :\\/]+):?(\\S+)*\\]/', array($this, '_parse_combine'), $out);
// ЧПУ
$out = rewrite_link($out);
echo $out;
}
示例6: header
$fotos = nggdb::find_images_in_list($pids, false, 'DESC');
if (empty($fotos)) {
header('Location: /tags.php');
}
//页面title
$page_title = empty($_GET['tag']) ? $cfg['sitename'] : $_GET['tag'];
$title = $page_title . $cfg['sitetitle'];
} else {
header('Location: /tags.php');
}
//输出keywords
$keywords = $_GET['tag'] . ',' . $cfg['keywords'];
//输出description
$description = $cfg['description'];
//输出canonical
$canonical = canonical($tag->term_id, $tag->slug);
require_once './inc/html/head.html';
?>
<div id='main'>
<?php
foreach ($fotos as $foto) {
?>
<a href="/foto/<?php
echo $foto->pid;
?>
.html"><img src="<?php
echo fotourl($foto->thumbURL);
?>
" alt="<?php
echo fotourl($foto->alttext);
?>
示例7: array
$key_arr = array();
foreach ($tags as $tag) {
$key_arr[] = $tag->slug;
$keywords = implode(',', $key_arr);
}
} else {
$keywords = $cfg['keywords'];
}
//输出keywords
$keywords = $foto->name . ',' . $keywords;
//输出页面description
$description = empty($foto->description) ? $cfg['description'] : $foto->description;
//输出$title,$canonical
$page_title = empty($foto->alttext) ? $cfg['sitename'] : $foto->alttext;
$title = $page_title . $cfg['sitetitle'];
$canonical = canonical($foto->pid);
require_once './inc/html/head.html';
?>
<div id='main'>
<p><img title="<?php
echo $foto->alttext;
?>
" src="<?php
echo $foto_url;
?>
" alt="<?php
echo $foto->alttext;
?>
" /></p>
<a href="/foto/<?php
示例8: session_start
<?php
session_start();
$cfg['siteurl'] = 'http://foto.tfbj.cc/';
$cfg['baseurl'] = 'http://stat001.tfbj.cc/';
$cfg['trueurl'] = 'http://foto.tfbj.cc/wp-content/gallery/';
$cfg['sitename'] = 'FOTO';
$cfg['sitetitle'] = " | foto my life | foto your life | foto everyone's life";
$cfg['description'] = 'To find all beautiful things | colorful world,young body,pure desire,real dream,crazy movement';
$cfg['keywords'] = 'photo,graphic,shot,polaroid,camera,perfect,gorgeous,picture,nice,sex,babes';
$canonical = canonical();
//处理图片url 隐藏真实地址
function fotourl($url)
{
global $cfg;
return str_replace($cfg['trueurl'], $cfg['baseurl'], $url);
}
//生成canonical标签内容
function canonical($id = 0, $slug = '')
{
global $cfg;
switch ($_SERVER['SCRIPT_NAME']) {
case '/foto.php':
return $cfg['siteurl'] . 'foto/' . $id . '.html';
break;
case '/tag.php':
return $cfg['siteurl'] . 'tag/' . $id . '-' . $slug . '.html';
break;
default:
return $cfg['siteurl'] . substr($_SERVER['SCRIPT_NAME'], 1);
}
示例9: PDQ_Solve
function PDQ_Solve($meth)
{
global $DEBUG, $method, $streams, $nodes;
// extern int
//global $centers_declared, $streams_declared; // extern int
global $job;
// extern JOB_TYPE *
global $node;
// extern NODE_TYPE *
global $s1, $s2, $s3, $s4;
// extern char[]
global $sumD;
// extern double
$k = 0;
// int
$c = 0;
// int
$should_be_class = 0;
// int
$demand = 0.0;
// double
$maxD = 0.0;
// double
$p = "PDQ_Solve()";
// char *
if ($DEBUG) {
debug($p, "Entering");
}
/* There'd better be a job[0] or you're in trouble !!! */
$method = $meth;
switch ($method) {
case EXACT:
if ($job[0]->network != CLOSED) {
/* bail ! */
typetostr($s2, $job[0]->network);
typetostr($s3, $method);
$s1 = sprintf("Network should_be_class \"%s\" is incompatible with \"%s\" method", $s2, $s3);
errmsg($p, $s1);
}
switch ($job[0]->should_be_class) {
case TERM:
case BATCH:
exact();
break;
default:
break;
}
break;
case APPROX:
if ($job[0]->network != CLOSED) {
/* bail ! */
typetostr($s2, $job[0]->network);
typetostr($s3, $method);
$s1 = sprintf("Network should_be_class \"%s\" is incompatible with \"%s\" method", $s2, $s3);
errmsg($p, $s1);
}
switch ($job[0]->should_be_class) {
case TERM:
case BATCH:
approx();
break;
default:
break;
}
break;
case CANON:
if ($job[0]->network != OPEN) {
/* bail out ! */
typetostr($s2, $job[0]->network);
typetostr($s3, $method);
$s1 = sprintf("Network should_be_class \"%s\" is incompatible with \"%s\" method", $s2, $s3);
errmsg($p, $s1);
}
canonical();
break;
default:
typetostr($s3, $method);
$s1 = sprintf("Unknown method \"%s\"", $s3);
errmsg($p, $s1);
break;
}
/* Now compute bounds */
for ($c = 0; $c < $streams; $c++) {
$sumD = 0.0;
$maxD = 0.0;
$should_be_class = $job[$c]->should_be_class;
for ($k = 0; $k < $nodes; $k++) {
$demand = $node[$k]->demand[$c];
if ($node[$k]->sched == ISRV && $job[$c]->network == CLOSED) {
$demand /= $should_be_class == TERM ? $job[$c]->term->pop : $job[$c]->batch->pop;
}
if ($maxD < $demand) {
$maxD = $demand;
}
$sumD += $node[$k]->demand[$c];
}
/* Over k */
switch ($should_be_class) {
case TERM:
$job[$c]->term->sys->maxN = ($sumD + $job[$c]->term->think) / $maxD;
//.........这里部分代码省略.........