本文整理汇总了PHP中Slug::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Slug::get方法的具体用法?PHP Slug::get怎么用?PHP Slug::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slug
的用法示例。
在下文中一共展示了Slug::get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: elseif
/**
* Get the item tinyslug. If not exists -> create new
*
* @return string|boolean tinyslug on success, false otherwise
*/
function get_tinyslug()
{
global $preview;
$tinyslug_ID = $this->tiny_slug_ID;
if ($tinyslug_ID != NULL) {
// the tiny slug for this item was already created
$SlugCache =& get_SlugCache();
$Slug =& $SlugCache->get_by_ID($tinyslug_ID, false, false);
return $Slug === false ? false : $Slug->get('title');
} elseif ($this->ID > 0 && !$preview) {
// create new tiny Slug for this item
// Note: This may happen only in case of posts created before the tiny slug was introduced
global $DB;
load_funcs('slugs/model/_slug.funcs.php');
$Slug = new Slug();
$Slug->set('title', getnext_tinyurl());
$Slug->set('itm_ID', $this->ID);
$Slug->set('type', 'item');
$DB->begin();
if (!$Slug->dbinsert()) {
// Slug dbinsert failed
$DB->rollback();
return false;
}
$this->set('tiny_slug_ID', $Slug->ID);
// Update Item preserving mod date:
if (!$this->dbupdate(false)) {
// Item dbupdate failed
$DB->rollback();
return false;
}
$DB->commit();
// update last tinyurl value on database
// Note: This doesn't have to be part of the above transaction, no problem if it doesn't succeed to update, or if override a previously updated value.
global $Settings;
$Settings->set('tinyurl', $Slug->get('title'));
$Settings->dbupdate();
return $Slug->get('title');
}
return false;
}