本文整理匯總了PHP中DiscussHelper::permalinkSlug方法的典型用法代碼示例。如果您正苦於以下問題:PHP DiscussHelper::permalinkSlug方法的具體用法?PHP DiscussHelper::permalinkSlug怎麽用?PHP DiscussHelper::permalinkSlug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DiscussHelper
的用法示例。
在下文中一共展示了DiscussHelper::permalinkSlug方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getAlias
public static function getAlias($title, $type = 'post', $id = '0')
{
$items = explode(' ', $title);
foreach ($items as $index => $item) {
if (strpos($item, '*') !== false) {
$items[$index] = 'censored';
}
}
$title = implode($items, ' ');
$alias = DiscussHelper::permalinkSlug($title);
// Make sure no such alias exists.
$i = 1;
while (DiscussRouter::_isAliasExists($alias, $type, $id)) {
$alias = DiscussHelper::permalinkSlug($title) . '-' . $i;
$i++;
}
return $alias;
}
示例2: bind
/**
* Overrides parent's bind method to add our own logic.
*
* @param Array $data
**/
public function bind($data, $ignore = array())
{
parent::bind($data);
if (empty($this->created)) {
$date = DiscussHelper::getDate();
$this->created = $date->toMySQL();
}
jimport('joomla.filesystem.filter.filteroutput');
$i = 1;
while ($this->aliasExists() || empty($this->alias)) {
$this->alias = empty($this->alias) ? $this->title : $this->alias . '-' . $i;
$i++;
}
$this->alias = DiscussHelper::permalinkSlug($this->alias);
}
示例3: _createDefault
public function _createDefault($id)
{
$db = DiscussHelper::getDBO();
$user = JFactory::getUser($id);
$date = DiscussHelper::getDate();
if ($user->id) {
$obj = new stdClass();
$obj->id = $user->id;
$obj->nickname = $user->name;
$obj->avatar = 'default.png';
$obj->description = '';
$obj->url = '';
$obj->params = '';
//default to username for blogger alias
$obj->alias = DiscussHelper::permalinkSlug($user->username);
$isCreated = $db->insertObject('#__discuss_users', $obj);
if ($isCreated) {
$this->bind($obj);
}
}
}
示例4: setAlias
public function setAlias()
{
jimport('joomla.filesystem.filter.filteroutput');
$i = 1;
$alias = $this->alias ? $this->alias : $this->title;
$alias = DiscussHelper::permalinkSlug($alias);
$tmp = $alias;
while ($this->aliasExists($tmp) || empty($tmp)) {
$alias = empty($alias) ? DiscussHelper::permalinkSlug($this->title) : $alias;
$tmp = empty($tmp) ? DiscussHelper::permalinkSlug($this->title) : $alias . '-' . $i;
$i++;
}
$this->alias = $tmp;
}