本文整理汇总了PHP中modResource::getAliasPath方法的典型用法代码示例。如果您正苦于以下问题:PHP modResource::getAliasPath方法的具体用法?PHP modResource::getAliasPath怎么用?PHP modResource::getAliasPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modResource
的用法示例。
在下文中一共展示了modResource::getAliasPath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkFriendlyAlias
/**
* Friendly URL alias checks
* @return mixed|string
*/
public function checkFriendlyAlias()
{
$this->isSiteStart = $this->object->get('id') == $this->workingContext->getOption('site_start') || $this->object->get('id') == $this->modx->getOption('site_start');
$pageTitle = $this->getProperty('pagetitle', null);
$alias = $this->getProperty('alias');
if ($this->workingContext->getOption('friendly_urls', false) && (!$this->getProperty('reloadOnly', false) || (!empty($pageTitle) || $this->isSiteStart))) {
/* auto assign alias */
if (empty($alias) && ($this->isSiteStart || $this->workingContext->getOption('automatic_alias', false))) {
if (empty($pageTitle)) {
$alias = 'index';
} else {
$alias = $this->object->cleanAlias($pageTitle);
}
}
if (empty($alias)) {
$this->addFieldError('alias', $this->modx->lexicon('field_required'));
}
/* check for duplicate alias */
$duplicateContext = $this->workingContext->getOption('global_duplicate_uri_check', false) ? '' : $this->getProperty('context_key');
$aliasPath = $this->object->getAliasPath($alias, $this->getProperties());
$duplicateId = $this->object->isDuplicateAlias($aliasPath, $duplicateContext);
if (!empty($duplicateId)) {
$err = $this->modx->lexicon('duplicate_uri_found', array('id' => $duplicateId, 'uri' => $aliasPath));
$this->addFieldError('uri', $err);
$uriOverride = $this->getProperty('uri_override', null);
if ($uriOverride == null || $uriOverride !== 1) {
$this->addFieldError('alias', $err);
}
}
$this->setProperty('alias', $alias);
}
return $alias;
}
示例2: prepareAlias
/**
* Clean and prepare the alias, automatically generating it if the option is set
* @return string
*/
public function prepareAlias()
{
$alias = '';
/* friendly url alias checks */
$pageTitle = $this->getProperty('pagetitle');
if ($this->workingContext->getOption('friendly_urls', false) && (!$this->getProperty('reloadOnly', false) || !empty($pageTitle))) {
$alias = $this->getProperty('alias');
/* auto assign alias */
if (empty($alias) && $this->workingContext->getOption('automatic_alias', false)) {
$alias = $this->object->cleanAlias($pageTitle);
}
if (empty($alias)) {
$this->addFieldError('alias', $this->modx->lexicon('field_required'));
} else {
$duplicateContext = $this->workingContext->getOption('global_duplicate_uri_check', false) ? '' : $this->getProperty('context_key');
$aliasPath = $this->object->getAliasPath($alias, $this->getProperties());
$duplicateId = $this->object->isDuplicateAlias($aliasPath, $duplicateContext);
if ($duplicateId) {
$err = $this->modx->lexicon('duplicate_uri_found', array('id' => $duplicateId, 'uri' => $aliasPath));
$this->addFieldError('uri', $err);
if ($this->getProperty('uri_override', 0) !== 1) {
$this->addFieldError('alias', $err);
}
}
}
$this->setProperty('alias', $alias);
}
return $alias;
}
示例3: checkForDuplicateAlias
/**
* Check for a duplicate alias before publishing
* @return boolean|string
*/
public function checkForDuplicateAlias()
{
$duplicateAlias = false;
/* get the targeted working context */
$workingContext = $this->modx->getContext($this->resource->get('context_key'));
/* friendly url duplicate alias checks */
if ($workingContext->getOption('friendly_urls', false)) {
$duplicateContext = $workingContext->getOption('global_duplicate_uri_check', false) ? '' : $this->resource->get('context_key');
$aliasPath = $this->resource->getAliasPath($this->resource->get('alias'));
$duplicateId = $this->resource->isDuplicateAlias($aliasPath, $duplicateContext);
if (!empty($duplicateId)) {
return $this->modx->lexicon('duplicate_uri_found', array('id' => $duplicateId, 'uri' => $aliasPath));
}
}
return $duplicateAlias;
}
示例4: prepareAlias
/**
* Clean and prepare the alias, automatically generating it if the option is set
* @return string
*/
public function prepareAlias()
{
// The user submitted alias & page title
$alias = $this->getProperty('alias');
$pageTitle = $this->getProperty('pagetitle');
$autoGenerated = false;
// If we don't have an alias passed, and automatic_alias is enabled, we generate one from the pagetitle.
if (empty($alias) && $this->workingContext->getOption('automatic_alias', false)) {
$alias = $this->object->cleanAlias($pageTitle);
$autoGenerated = true;
}
$friendlyUrlsEnabled = $this->workingContext->getOption('friendly_urls', false) && (!$this->getProperty('reloadOnly', false) || !empty($pageTitle));
// Check for duplicates
$duplicateContext = $this->workingContext->getOption('global_duplicate_uri_check', false) ? '' : $this->getProperty('context_key');
$aliasPath = $this->object->getAliasPath($alias, $this->getProperties());
$duplicateId = $this->object->isDuplicateAlias($aliasPath, $duplicateContext);
// We have a duplicate!
if ($duplicateId) {
// If friendly urls is enabled, we throw an error about the alias
if ($friendlyUrlsEnabled) {
$err = $this->modx->lexicon('duplicate_uri_found', array('id' => $duplicateId, 'uri' => $aliasPath));
$this->addFieldError('uri', $err);
if ($this->getProperty('uri_override', 0) !== 1) {
$this->addFieldError('alias', $err);
}
} elseif ($autoGenerated) {
$alias = '';
}
}
// If the alias is empty yet friendly urls is enabled, add an error to the alias field
if (empty($alias) && $friendlyUrlsEnabled) {
$this->addFieldError('alias', $this->modx->lexicon('field_required'));
}
// Set the new alias and return it, too.
$this->setProperty('alias', $alias);
return $alias;
}