當前位置: 首頁>>代碼示例>>PHP>>正文


PHP modX::findResource方法代碼示例

本文整理匯總了PHP中modX::findResource方法的典型用法代碼示例。如果您正苦於以下問題:PHP modX::findResource方法的具體用法?PHP modX::findResource怎麽用?PHP modX::findResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在modX的用法示例。


在下文中一共展示了modX::findResource方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _cleanResourceIdentifier

 /**
  * Cleans the resource identifier from the request params.
  *
  * @param string $identifier The raw identifier.
  * @return string|integer The cleansed identifier.
  */
 public function _cleanResourceIdentifier($identifier)
 {
     if (empty($identifier)) {
         if ($this->modx->getOption('base_url', null, MODX_BASE_URL) !== strtok($_SERVER["REQUEST_URI"], '?')) {
             $this->modx->sendRedirect($this->modx->getOption('site_url', null, MODX_SITE_URL), array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
         }
         $identifier = $this->modx->getOption('site_start', null, 1);
         $this->modx->resourceMethod = 'id';
     } elseif ($this->modx->getOption('friendly_urls', null, false) && $this->modx->resourceMethod == 'alias') {
         $containerSuffix = trim($this->modx->getOption('container_suffix', null, ''));
         $found = $this->modx->findResource($identifier);
         if ($found === false && !empty($containerSuffix)) {
             $suffixLen = strlen($containerSuffix);
             $identifierLen = strlen($identifier);
             if (substr($identifier, $identifierLen - $suffixLen) === $containerSuffix) {
                 $identifier = substr($identifier, 0, $identifierLen - $suffixLen);
                 $found = $this->modx->findResource($identifier);
             } else {
                 $identifier = "{$identifier}{$containerSuffix}";
                 $found = $this->modx->findResource("{$identifier}{$containerSuffix}");
             }
             if ($found) {
                 $parameters = $this->getParameters();
                 unset($parameters[$this->modx->getOption('request_param_alias')]);
                 $url = $this->modx->makeUrl($found, $this->modx->context->get('key'), $parameters, 'full');
                 $this->modx->sendRedirect($url, array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
             }
             $this->modx->resourceMethod = 'alias';
         } elseif ((int) $this->modx->getOption('site_start', null, 1) === $found) {
             $parameters = $this->getParameters();
             unset($parameters[$this->modx->getOption('request_param_alias')]);
             $url = $this->modx->makeUrl($this->modx->getOption('site_start', null, 1), $this->modx->context->get('key'), $parameters, 'full');
             $this->modx->sendRedirect($url, array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
         } else {
             if ($this->modx->getOption('friendly_urls_strict', null, false)) {
                 $requestUri = $_SERVER['REQUEST_URI'];
                 $qsPos = strpos($requestUri, '?');
                 if ($qsPos !== false) {
                     $requestUri = substr($requestUri, 0, $qsPos);
                 }
                 $fullId = $this->modx->getOption('base_url', null, MODX_BASE_URL) . $identifier;
                 $requestUri = urldecode($requestUri);
                 if ($fullId !== $requestUri && strpos($requestUri, $fullId) !== 0) {
                     $parameters = $this->getParameters();
                     unset($parameters[$this->modx->getOption('request_param_alias')]);
                     $url = $this->modx->makeUrl($found, $this->modx->context->get('key'), $parameters, 'full');
                     $this->modx->sendRedirect($url, array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
                 }
             }
             $this->modx->resourceMethod = 'alias';
         }
     } else {
         $this->modx->resourceMethod = 'id';
     }
     return $identifier;
 }
開發者ID:ChrstnMgcn,項目名稱:revolution,代碼行數:62,代碼來源:modrequest.class.php

示例2: findResource

 /**
  * @param $uri
  * @param string $context
  *
  * @return bool|int|mixed
  */
 public function findResource($uri, $context = '')
 {
     return $this->modx->findResource($uri, $context);
 }
開發者ID:suasti,項目名稱:pdoTools,代碼行數:10,代碼來源:_micromodx.php


注:本文中的modX::findResource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。