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