当前位置: 首页>>代码示例>>PHP>>正文


PHP modResource::isDuplicateAlias方法代码示例

本文整理汇总了PHP中modResource::isDuplicateAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP modResource::isDuplicateAlias方法的具体用法?PHP modResource::isDuplicateAlias怎么用?PHP modResource::isDuplicateAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在modResource的用法示例。


在下文中一共展示了modResource::isDuplicateAlias方法的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;
 }
开发者ID:semencov-com,项目名称:affiliate,代码行数:37,代码来源:update.class.php

示例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;
 }
开发者ID:e-gob,项目名称:apps.gob.cl,代码行数:33,代码来源:create.class.php

示例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;
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:20,代码来源:publish.class.php

示例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;
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:41,代码来源:create.class.php


注:本文中的modResource::isDuplicateAlias方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。