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


PHP item::find_by_relative_url方法代码示例

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


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

示例1: parse_url

 static function parse_url()
 {
     if (Router::$controller) {
         return;
     }
     // Work around problems with the CGI sapi by enforcing our default path
     if ($_SERVER["SCRIPT_NAME"] && "/" . Router::$current_uri == $_SERVER["SCRIPT_NAME"]) {
         Router::$controller_path = MODPATH . "gallery/controllers/albums.php";
         Router::$controller = "albums";
         Router::$method = 1;
         return;
     }
     $item = item::find_by_relative_url(html_entity_decode(Router::$current_uri, ENT_QUOTES));
     if ($item && $item->loaded()) {
         Router::$controller = "{$item->type}s";
         Router::$controller_path = MODPATH . "gallery/controllers/{$item->type}s.php";
         Router::$method = "show";
         Router::$arguments = array($item);
     }
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:20,代码来源:MY_url.php

示例2: find_by_relative_url_test

 public function find_by_relative_url_test()
 {
     $level1 = test::random_album();
     $level2 = test::random_album($level1);
     $level3 = test::random_photo_unsaved($level2);
     $level3->slug = "same";
     $level3->save()->reload();
     $level2b = test::random_album($level1);
     $level3b = test::random_photo_unsaved($level2b);
     $level3b->slug = "same";
     $level3b->save()->reload();
     // Item in album
     $this->assert_same($level3->id, item::find_by_relative_url("{$level1->slug}/{$level2->slug}/{$level3->slug}")->id);
     // Album, ends without a slash
     $this->assert_same($level2->id, item::find_by_relative_url("{$level1->slug}/{$level2->slug}")->id);
     // Return root if "" is passed
     $this->assert_same(item::root()->id, item::find_by_relative_url("")->id);
     // Verify that we don't get confused by the part slugs, using the fallback code.
     db::build()->update("items")->set(array("relative_url_cache" => null))->where("id", "IN", array($level3->id, $level3b->id))->execute();
     $this->assert_same($level3->id, item::find_by_relative_url("{$level1->slug}/{$level2->slug}/{$level3->slug}")->id);
     $this->assert_same($level3b->id, item::find_by_relative_url("{$level1->slug}/{$level2b->slug}/{$level3b->slug}")->id);
     // Verify that we don't get false positives
     $this->assert_false(item::find_by_relative_url("foo/bar/baz")->loaded());
     // Verify that the fallback code works
     $this->assert_same($level3b->id, item::find_by_relative_url("{$level1->slug}/{$level2b->slug}/{$level3b->slug}")->id);
 }
开发者ID:assad2012,项目名称:gallery3-appfog,代码行数:26,代码来源:Item_Helper_Test.php


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