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


PHP PhabricatorEnv::isValidURIForLink方法代碼示例

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


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

示例1: markupImage

 public function markupImage(array $matches)
 {
     if (!$this->isFlatText($matches[0])) {
         return $matches[0];
     }
     $args = array();
     $defaults = array('uri' => null, 'alt' => null, 'href' => null, 'width' => null, 'height' => null);
     $trimmed_match = trim($matches[2]);
     if ($this->isURI($trimmed_match)) {
         $args['uri'] = new PhutilURI($trimmed_match);
     } else {
         $parser = new PhutilSimpleOptions();
         $keys = $parser->parse($trimmed_match);
         $uri_key = '';
         foreach (array('src', 'uri', 'url') as $key) {
             if (array_key_exists($key, $keys)) {
                 $uri_key = $key;
             }
         }
         if ($uri_key) {
             $args['uri'] = new PhutilURI($keys[$uri_key]);
         }
         $args += $keys;
     }
     $args += $defaults;
     if ($args['href'] && !PhabricatorEnv::isValidURIForLink($args['href'])) {
         $args['href'] = null;
     }
     if ($args['uri']) {
         $src_uri = id(new PhutilURI('/file/imageproxy/'))->setQueryParam('uri', (string) $args['uri']);
         $img = $this->newTag('img', array('src' => $src_uri, 'alt' => $args['alt'], 'href' => $args['href'], 'width' => $args['width'], 'height' => $args['height']));
         return $this->getEngine()->storeText($img);
     } else {
         return $matches[0];
     }
 }
開發者ID:endlessm,項目名稱:phabricator,代碼行數:36,代碼來源:PhabricatorImageRemarkupRule.php

示例2: renderFooter

 private function renderFooter()
 {
     if (!$this->getShowChrome()) {
         return null;
     }
     if (!$this->getShowFooter()) {
         return null;
     }
     $items = PhabricatorEnv::getEnvConfig('ui.footer-items');
     if (!$items) {
         return null;
     }
     $foot = array();
     foreach ($items as $item) {
         $name = idx($item, 'name', pht('Unnamed Footer Item'));
         $href = idx($item, 'href');
         if (!PhabricatorEnv::isValidURIForLink($href)) {
             $href = null;
         }
         if ($href !== null) {
             $tag = 'a';
         } else {
             $tag = 'span';
         }
         $foot[] = phutil_tag($tag, array('href' => $href), $name);
     }
     $foot = phutil_implode_html(" · ", $foot);
     return phutil_tag('div', array('class' => 'phabricator-standard-page-footer grouped'), $foot);
 }
開發者ID:rchicoli,項目名稱:phabricator,代碼行數:29,代碼來源:PhabricatorStandardPageView.php

示例3: isValidLinkURI

 private function isValidLinkURI($uri)
 {
     return PhabricatorEnv::isValidURIForLink($uri);
 }
開發者ID:subaochen,項目名稱:phabricator,代碼行數:4,代碼來源:PhabricatorLinkProfilePanel.php

示例4: getURIForRedirect

 /**
  * Format a URI for use in a "Location:" header.
  *
  * Verifies that a URI redirects to the expected type of resource (local or
  * remote) and formats it for use in a "Location:" header.
  *
  * The HTTP spec says "Location:" headers must use absolute URIs. Although
  * browsers work with relative URIs, we return absolute URIs to avoid
  * ambiguity. For example, Chrome interprets "Location: /\evil.com" to mean
  * "perform a protocol-relative redirect to evil.com".
  *
  * @param   string  URI to redirect to.
  * @param   bool    True if this URI identifies a remote resource.
  * @return  string  URI for use in a "Location:" header.
  */
 public static function getURIForRedirect($uri, $is_external)
 {
     $uri_object = new PhutilURI($uri);
     if ($is_external) {
         // If this is a remote resource it must have a domain set. This
         // would also be caught below, but testing for it explicitly first allows
         // us to raise a better error message.
         if (!strlen($uri_object->getDomain())) {
             throw new Exception(pht('Refusing to redirect to external URI "%s". This URI ' . 'is not fully qualified, and is missing a domain name. To ' . 'redirect to a local resource, remove the external flag.', (string) $uri));
         }
         // Check that it's a valid remote resource.
         if (!PhabricatorEnv::isValidURIForLink($uri)) {
             throw new Exception(pht('Refusing to redirect to external URI "%s". This URI ' . 'is not a valid remote web resource.', (string) $uri));
         }
     } else {
         // If this is a local resource, it must not have a domain set. This allows
         // us to raise a better error message than the check below can.
         if (strlen($uri_object->getDomain())) {
             throw new Exception(pht('Refusing to redirect to local resource "%s". The URI has a ' . 'domain, but the redirect is not marked external. Mark ' . 'redirects as external to allow redirection off the local ' . 'domain.', (string) $uri));
         }
         // If this is a local resource, it must be a valid local resource.
         if (!PhabricatorEnv::isValidLocalURIForLink($uri)) {
             throw new Exception(pht('Refusing to redirect to local resource "%s". This URI is not ' . 'formatted in a recognizable way.', (string) $uri));
         }
         // Fully qualify the result URI.
         $uri = PhabricatorEnv::getURI((string) $uri);
     }
     return (string) $uri;
 }
開發者ID:pugong,項目名稱:phabricator,代碼行數:44,代碼來源:AphrontRedirectResponse.php


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