当前位置: 首页>>代码示例>>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;未经允许,请勿转载。