當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。