本文整理匯總了PHP中Backend\Core\Engine\Model::addNumber方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model::addNumber方法的具體用法?PHP Model::addNumber怎麽用?PHP Model::addNumber使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Backend\Core\Engine\Model
的用法示例。
在下文中一共展示了Model::addNumber方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getUrl
/**
* Retrieve the unique url for an item
*
* @param string $url
* @param int[optional] $id
* @return string
*/
public static function getUrl($url, $id = null)
{
// redefine Url
$url = \SpoonFilter::urlise((string) $url);
// get db
$db = BackendModel::get('database');
// new item
if ($id === null) {
$numberOfItems = (int) $db->getVar('SELECT 1
FROM media AS i
INNER JOIN meta AS m ON i.meta_id = m.id
WHERE i.language = ? AND m.url = ?
LIMIT 1', array(Language::getWorkingLanguage(), $url));
// already exists
if ($numberOfItems != 0) {
// add number
$url = BackendModel::addNumber($url);
// try again
return self::getUrl($url);
}
} else {
$numberOfItems = (int) $db->getVar('SELECT 1
FROM media AS i
INNER JOIN meta AS m ON i.meta_id = m.id
WHERE i.language = ? AND m.url = ? AND i.id != ?
LIMIT 1', array(Language::getWorkingLanguage(), $url, $id));
// already exists
if ($numberOfItems != 0) {
// add number
$url = BackendModel::addNumber($url);
// try again
return self::getUrl($url, $id);
}
}
// return the unique Url!
return $url;
}
示例2: getURLForCategory
/**
* Retrieve the unique URL for a category
*
* @param string $url The string whereon the URL will be based.
* @param int $id The id of the category to ignore.
*
* @return string
*/
public static function getURLForCategory($url, $id = null)
{
// redefine URL
$url = (string) $url;
// get db
$db = BackendModel::getContainer()->get('database');
// new category
if ($id === null) {
// already exists
if ((bool) $db->getVar('SELECT 1
FROM blog_categories AS i
INNER JOIN meta AS m ON i.meta_id = m.id
WHERE i.language = ? AND m.url = ?
LIMIT 1', array(BL::getWorkingLanguage(), $url))) {
$url = BackendModel::addNumber($url);
return self::getURLForCategory($url);
}
} else {
// current category should be excluded
if ((bool) $db->getVar('SELECT 1
FROM blog_categories AS i
INNER JOIN meta AS m ON i.meta_id = m.id
WHERE i.language = ? AND m.url = ? AND i.id != ?
LIMIT 1', array(BL::getWorkingLanguage(), $url, $id))) {
$url = BackendModel::addNumber($url);
return self::getURLForCategory($url, $id);
}
}
return $url;
}
示例3: getUrl
/**
* Retrieve a unique URL for a profile based on the display name.
*
* @param string $displayName The display name to base on.
* @param int $id The id of the profile to ignore.
* @return string
*/
public static function getUrl($displayName, $id = null)
{
// decode specialchars
$displayName = \SpoonFilter::htmlspecialcharsDecode((string) $displayName);
// urlise
$url = CommonUri::getUrl($displayName);
// get db
$db = BackendModel::getContainer()->get('database');
// new item
if ($id === null) {
// get number of profiles with this URL
$number = (int) $db->getVar('SELECT 1
FROM profiles AS p
WHERE p.url = ?
LIMIT 1', (string) $url);
// already exists
if ($number != 0) {
// add number
$url = BackendModel::addNumber($url);
// try again
return self::getURL($url);
}
} else {
// get number of profiles with this URL
$number = (int) $db->getVar('SELECT 1
FROM profiles AS p
WHERE p.url = ? AND p.id != ?
LIMIT 1', array((string) $url, (int) $id));
// already exists
if ($number != 0) {
// add number
$url = BackendModel::addNumber($url);
// try again
return self::getURL($url, $id);
}
}
// cough up new url
return $url;
}
示例4: getURL
/**
* Retrieve the unique URL for an item
*
* @param string $URL The URL to base on.
* @param int[optional] $id The id of the item to ignore.
*
* @return string
*/
public static function getURL($URL, $id = null)
{
$URL = (string) $URL;
// get db
$db = BackendModel::getContainer()->get('database');
// new item
if ($id === null) {
// already exists
if ((bool) $db->getVar('SELECT 1
FROM galleria_albums AS i
INNER JOIN meta AS m ON i.meta_id = m.id
WHERE i.language = ? AND m.url = ?
LIMIT 1', array(BL::getWorkingLanguage(), $URL))) {
$URL = BackendModel::addNumber($URL);
return self::getURL($URL);
}
} else {
// already exists
if ((bool) $db->getVar('SELECT 1
FROM galleria_albums AS i
INNER JOIN meta AS m ON i.meta_id = m.id
WHERE i.language = ? AND m.url = ? AND i.id != ?
LIMIT 1', array(BL::getWorkingLanguage(), $URL, $id))) {
$URL = BackendModel::addNumber($URL);
return self::getURL($URL, $id);
}
}
return $URL;
}
示例5: getURLForBrand
/**
* Retrieve the unique URL for a category
*
* @param string $url
* @param int [optional] $id The id of the category to ignore.
* @return string
*/
public static function getURLForBrand($url, $id = null)
{
$url = \SpoonFilter::urlise((string) $url);
$db = BackendModel::getContainer()->get('database');
// new category
if ($id === null) {
if ((bool) $db->getVar('SELECT 1
FROM catalog_brands AS i
INNER JOIN meta AS m ON i.meta_id = m.id
WHERE m.url = ?
LIMIT 1', array($url))) {
$url = BackendModel::addNumber($url);
return self::getURLForCategory($url);
}
} else {
// current category should be excluded
if ((bool) $db->getVar('SELECT 1
FROM catalog_brands AS i
INNER JOIN meta AS m ON i.meta_id = m.id
WHERE m.url = ? AND i.id != ?
LIMIT 1', array($url, $id))) {
$url = BackendModel::addNumber($url);
return self::getURLForCategory($url, $id);
}
}
return $url;
}
示例6: getURL
/**
* Get an unique URL for a page
*
* @param string $url The URL to base on.
* @param int $id The id to ignore.
* @param int $parentId The parent for the page to create an url for.
* @param bool $isAction Is this page an action.
*
* @return string
*/
public static function getURL($url, $id = null, $parentId = 0, $isAction = false)
{
$url = (string) $url;
$parentIds = array((int) $parentId);
// 0, 1, 2, 3, 4 are all top levels, so we should place them on the same level
if ($parentId == 0 || $parentId == 1 || $parentId == 2 || $parentId == 3 || $parentId == 4) {
$parentIds = array(0, 1, 2, 3, 4);
}
// get db
$db = BackendModel::getContainer()->get('database');
// no specific id
if ($id === null) {
// no items?
if ((bool) $db->getVar('SELECT 1
FROM pages AS i
INNER JOIN meta AS m ON i.meta_id = m.id
WHERE i.parent_id IN(' . implode(',', $parentIds) . ') AND i.status = ? AND m.url = ?
AND i.language = ?
LIMIT 1', array('active', $url, BL::getWorkingLanguage()))) {
// add a number
$url = BackendModel::addNumber($url);
// recall this method, but with a new URL
return self::getURL($url, null, $parentId, $isAction);
}
} else {
// one item should be ignored
// there are items so, call this method again.
if ((bool) $db->getVar('SELECT 1
FROM pages AS i
INNER JOIN meta AS m ON i.meta_id = m.id
WHERE i.parent_id IN(' . implode(',', $parentIds) . ') AND i.status = ?
AND m.url = ? AND i.id != ? AND i.language = ?
LIMIT 1', array('active', $url, $id, BL::getWorkingLanguage()))) {
// add a number
$url = BackendModel::addNumber($url);
// recall this method, but with a new URL
return self::getURL($url, $id, $parentId, $isAction);
}
}
// get full URL
$fullURL = self::getFullURL($parentId) . '/' . $url;
// get info about parent page
$parentPageInfo = self::get($parentId, null, BL::getWorkingLanguage());
// does the parent have extras?
if ($parentPageInfo['has_extra'] == 'Y' && !$isAction) {
// set locale
FrontendLanguage::setLocale(BL::getWorkingLanguage(), true);
// get all on-site action
$actions = FrontendLanguage::getActions();
// if the new URL conflicts with an action we should rebuild the URL
if (in_array($url, $actions)) {
// add a number
$url = BackendModel::addNumber($url);
// recall this method, but with a new URL
return self::getURL($url, $id, $parentId, $isAction);
}
}
// check if folder exists
if (is_dir(PATH_WWW . '/' . $fullURL) || is_file(PATH_WWW . '/' . $fullURL)) {
// add a number
$url = BackendModel::addNumber($url);
// recall this method, but with a new URL
return self::getURL($url, $id, $parentId, $isAction);
}
// check if it is an application
if (array_key_exists(trim($fullURL, '/'), \ApplicationRouting::getRoutes())) {
// add a number
$url = BackendModel::addNumber($url);
// recall this method, but with a new URL
return self::getURL($url, $id, $parentId, $isAction);
}
// return the unique URL!
return $url;
}
示例7: getURL
/**
* Get a unique URL for a tag
*
* @param string $URL The URL to use as a base.
* @param int $id The ID to ignore.
* @return string
*/
public static function getURL($URL, $id = null)
{
$URL = CommonUri::getUrl((string) $URL);
$language = BL::getWorkingLanguage();
// get db
$db = BackendModel::getContainer()->get('database');
// no specific id
if ($id === null) {
// get number of tags with the specified url
$number = (int) $db->getVar('SELECT 1
FROM tags AS i
WHERE i.url = ? AND i.language = ?
LIMIT 1', array($URL, $language));
// there are items so, call this method again.
if ($number != 0) {
// add a number
$URL = BackendModel::addNumber($URL);
// recall this method, but with a new url
$URL = self::getURL($URL, $id);
}
} else {
// specific id given
// get number of tags with the specified url
$number = (int) $db->getVar('SELECT 1
FROM tags AS i
WHERE i.url = ? AND i.language = ? AND i.id != ?
LIMIT 1', array($URL, $language, $id));
// there are items so, call this method again.
if ($number != 0) {
// add a number
$URL = BackendModel::addNumber($URL);
// recall this method, but with a new url
$URL = self::getURL($URL, $id);
}
}
return $URL;
}
示例8: getURLForCategory
/**
* Retrieve the unique URL for a category
*
* @param string $url
* @param int [optional] $id The id of the category to ignore.
* @return string
*/
public static function getURLForCategory($url, $id = null)
{
$url = \SpoonFilter::urlise((string) $url);
$db = BackendModel::get('database');
// new category
if ($id === null) {
if ((bool) $db->getVar('SELECT 1
FROM blocks_categories AS i
INNER JOIN meta AS m ON i.meta_id = m.id
WHERE i.language = ? AND m.url = ?
LIMIT 1', array(Language::getWorkingLanguage(), $url))) {
$url = BackendModel::addNumber($url);
return self::getURLForCategory($url);
}
} else {
if ((bool) $db->getVar('SELECT 1
FROM blocks_categories AS i
INNER JOIN meta AS m ON i.meta_id = m.id
WHERE i.language = ? AND m.url = ? AND i.id != ?
LIMIT 1', array(Language::getWorkingLanguage(), $url, $id))) {
$url = BackendModel::addNumber($url);
return self::getURLForCategory($url, $id);
}
}
return $url;
}
示例9: getURLForCategory
/**
* Retrieve the unique URL for a category
*
* @param string $url
* @param int $id The id of the category to ignore.
* @return string
*/
public static function getURLForCategory($url, $id = null)
{
$url = CommonUri::getUrl((string) $url);
$db = BackendModel::get('database');
// new category
if ($id === null) {
if ((bool) $db->getVar('SELECT 1
FROM faq_categories AS i
INNER JOIN meta AS m ON i.meta_id = m.id
WHERE i.language = ? AND m.url = ?
LIMIT 1', array(BL::getWorkingLanguage(), $url))) {
$url = BackendModel::addNumber($url);
return self::getURLForCategory($url);
}
} else {
// current category should be excluded
if ((bool) $db->getVar('SELECT 1
FROM faq_categories AS i
INNER JOIN meta AS m ON i.meta_id = m.id
WHERE i.language = ? AND m.url = ? AND i.id != ?
LIMIT 1', array(BL::getWorkingLanguage(), $url, $id))) {
$url = BackendModel::addNumber($url);
return self::getURLForCategory($url, $id);
}
}
return $url;
}
示例10: checkUrl
public static function checkUrl($url)
{
$numberOfItems = (int) BackendModel::getContainer()->get('database')->getVar('SELECT 1
FROM meta AS m
WHERE m.url = ?
LIMIT 1', array($url));
// already exists
if ($numberOfItems != 0) {
// add number
$url = BackendModel::addNumber($url);
// try again
return self::checkUrl($url);
}
return $url;
}