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


PHP Typeframe::GetByProxy方法代码示例

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


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

示例1: GetUrl

 /**
  * Get URL metadata for a URL.
  * @param string $url The URL. If null, use the current page.
  * @param boolean $create Create a new record if the URL is valid.
  * @param string $newLabel The label for the URL if it doesn't exist.
  * @return Dbi_Record The URL metadata record.
  */
 public static function GetUrl($url = null, $create = true, $newLabel = '')
 {
     if (is_null($url)) {
         //$url = Typeframe::CurrentPage()->uri();
         //$app = Typeframe::CurrentPage()->application();
         $url = Typeframe::CurrentPage()->uri();
         if (substr($url, 0, -1) == '/') {
             $url = substr($url, -1);
         }
         $response = Typeframe::CurrentPage();
     } else {
         $url = parse_url($url, PHP_URL_PATH);
         if (substr($url, 0, -1) == '/') {
             $url = substr($url, -1);
         }
         $url = preg_replace('/\\/+/', '/', $url);
         //$app = Typeframe::Registry()->applicationAt($url);
         $response = Typeframe::Registry()->responseAt($url);
     }
     $app = $response->application();
     // Return a blank (nonexistent) Dbi_Record for invalid URLs
     if (!$app) {
         return Model_UrlMeta::Create();
     }
     $model = new Model_UrlMeta();
     $model->where('pageid = ?', $response->pageid());
     if ($response->pageid()) {
         $pathinfo = substr($url, strlen($response->applicationUri()));
     } else {
         $pathinfo = substr($response->applicationUri(), strlen(TYPEF_WEB_DIR));
     }
     if ($pathinfo == '/') {
         $pathinfo = '';
     }
     $model->where('pathinfo = ?', $pathinfo);
     $urlmeta = $model->getFirst();
     if (!$urlmeta->exists() && $create) {
         // Record does not exist. Generate a label and save it.
         $urlmeta['pageid'] = $response->pageid();
         $urlmeta['pathinfo'] = $pathinfo;
         if (!$newLabel) {
             // We need to save the metadata before we request the URL by proxy. Otherwise it's hammers all the way down.
             $urlmeta->save();
             // Create a label for the URL metadata
             $html = Typeframe::GetByProxy($url);
             if (!$html) {
                 return Model_UrlMeta::Create();
             } else {
                 $xml = @Pagemill_SimpleXmlElement::LoadString($html);
                 if ($xml) {
                     $selector = URLMETA_LABEL_SELECTOR ? URLMETA_LABEL_SELECTOR : 'title';
                     $parts = explode(',', $selector);
                     foreach ($parts as $part) {
                         if (trim($part)) {
                             $elements = $xml->select(trim($part));
                             if ($elements) {
                                 $urlmeta['label'] = trim($elements[0]->innerXml());
                                 break;
                             }
                         }
                     }
                 }
             }
             if (!$urlmeta['label']) {
                 $urlmeta['label'] = $app->title();
             }
         } else {
             $urlmeta['label'] = $newLabel;
         }
         $urlmeta->save();
     }
     return $urlmeta;
 }
开发者ID:ssrsfs,项目名称:blg,代码行数:80,代码来源:UrlMeta.php


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