本文整理汇总了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);
}
}
示例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);
}