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