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


PHP dmString::getDataFromUrl方法代码示例

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


在下文中一共展示了dmString::getDataFromUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepareAttributesForHtml

 protected function prepareAttributesForHtml(array $attributes)
 {
     $attributes = parent::prepareAttributesForHtml($attributes);
     list($attributes['href'], $attributes['params']) = $this->getBaseHref(true);
     if (array_key_exists('params', $attributes)) {
         if (!empty($attributes['params'])) {
             $attributes['href'] = $this->buildUrl(dmString::getBaseFromUrl($attributes['href']), array_merge(dmString::getDataFromUrl($attributes['href']), $attributes['params']));
             /*
              * if last href char is a =, remove it
              * fixes http://github.com/diem-project/diem/issues/#issue/6
              */
             if ('=' === substr($attributes['href'], -1)) {
                 $attributes['href'] = substr($attributes['href'], 0, strlen($attributes['href']) - 1);
             }
         }
         unset($attributes['params']);
     }
     if (isset($attributes['anchor'])) {
         $attributes['href'] .= '#' . $attributes['anchor'];
     }
     // makes unit testing easier
     ksort($attributes);
     return $attributes;
 }
开发者ID:theolymp,项目名称:diem,代码行数:24,代码来源:dmFrontLinkTagRoute.php

示例2: initialize

 public function initialize($source)
 {
     $this->source = $source;
     $this->params = false;
     if (empty($source)) {
         $this->type = 'page';
         $this->subject = dmDb::table('DmPage')->findOneBySource(null);
     } elseif (is_string($source)) {
         /*
          * If a blank space is found in the source,
          * remove characters after it
          * because they are just a comment
          * i.e. page:1?var=val Home
          */
         if ($blankSpacePos = strpos($source, ' ')) {
             $source = substr($source, 0, $blankSpacePos);
         }
         /*
          * Extract url parameters from source string
          */
         $this->params = dmString::getDataFromUrl($source);
         $source = dmString::getBaseFromUrl($source);
         if ('@homepage' === $source) {
             $source = 'main/root';
         }
         if (strncmp($source, 'page:', 5) === 0) {
             if ($page = dmDb::table('DmPage')->findOneBySource($source)) {
                 $this->type = 'page';
                 $this->subject = $page;
             } else {
                 throw new dmException(sprintf('%s is not a valid link resource', $source));
             }
         } elseif (strncmp($source, 'media:', 6) === 0) {
             if ($media = dmDb::table('DmMedia')->findOneByIdWithFolder(substr($source, 6))) {
                 $this->type = 'media';
                 $this->subject = $media;
             } else {
                 throw new dmException(sprintf('%s is not a valid link resource', $source));
             }
         } elseif (strncmp($source, 'app:', 4) === 0) {
             $app = substr($source, 4);
             /*
              * A slug may be added to the app name, extract it
              */
             if ($slashPos = strpos($app, '/')) {
                 $slug = substr($app, $slashPos);
                 $app = substr($app, 0, $slashPos);
             } else {
                 $slug = '';
             }
             $this->type = 'uri';
             $this->subject = dmContext::hasInstance() ? dmContext::getInstance()->get('script_name_resolver')->get($app) . $slug : $slug;
         } elseif (strncmp($source, '@', 1) === 0) {
             $this->type = 'route';
             $this->subject = $source;
         } elseif (strncmp($source, 'http://', 7) === 0 || strncmp($source, 'https://', 7) === 0 || strncmp($source, 'ftp://', 6) === 0 || strncmp($source, 'mailto:', 7) === 0 || strncmp($source, '#', 1) === 0) {
             $this->type = 'uri';
             $this->subject = $source;
         } elseif (strncmp($source, '/', 1) === 0) {
             $this->type = 'uri';
             $this->subject = $source;
         } elseif (strncmp($source, '+/', 2) === 0) {
             $this->type = 'action';
             $this->subject = substr($source, 2);
         } elseif (substr_count($source, '/') === 1) {
             if ($page = dmDb::table('DmPage')->findOneBySource($source)) {
                 $this->type = 'page';
                 $this->subject = $page;
             } else {
                 throw new dmException(sprintf('%s is not a valid link resource', $source));
             }
         } else {
             throw new dmException(sprintf('%s is not a valid link resource', $source));
         }
     } elseif (is_object($source)) {
         if ($source instanceof DmPage) {
             $this->type = 'page';
             $this->subject = $source;
         } elseif ($source instanceof DmMedia) {
             $this->type = 'media';
             $this->subject = $source;
         } elseif ($source instanceof dmDoctrineRecord) {
             if ($module = $source->getDmModule()) {
                 if ($module->hasPage()) {
                     $this->type = 'record';
                     $this->subject = $source;
                 } else {
                     throw new dmException(sprintf('%s module has no page', $module));
                 }
             } else {
                 throw new dmException(sprintf('%s object can not be associated to a page', get_class($source)));
             }
         } elseif ($source instanceof Exception) {
             $this->type = 'error';
             $this->subject = $source;
         }
     } elseif (is_array($source)) {
         if (isset($source[1])) {
             if (is_object($source[1])) {
                 $this->type = 'action';
//.........这里部分代码省略.........
开发者ID:theolymp,项目名称:diem,代码行数:101,代码来源:dmFrontLinkResource.php


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