本文整理汇总了PHP中Uri::match方法的典型用法代码示例。如果您正苦于以下问题:PHP Uri::match方法的具体用法?PHP Uri::match怎么用?PHP Uri::match使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Uri
的用法示例。
在下文中一共展示了Uri::match方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
public static function get($foldername)
{
if (!($match = Uri::match($foldername . '\\/(\\w+)'))) {
throw new Exception("Not match valid route.");
}
$routeName = $match[1];
$pluginPath = ROOT_PATH . 'contents/themes/' . $foldername . '/api.php';
define("THIS_URL", ROOT_URL . 'contents/themes/' . $foldername . '/');
define("THIS_PATH", ROOT_PATH . 'contents/themes/' . $foldername . '/');
if (!file_exists($pluginPath)) {
return false;
}
include $pluginPath;
$routes = SelfApi::route();
if (!isset($routes[$routeName])) {
throw new Exception("Theme not support this route.");
}
$func = $routes[$routeName];
if (!method_exists('SelfApi', $func)) {
throw new Exception('Route ' . $routeName . ' not ready for runc.');
}
try {
$result = SelfApi::$func();
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
return $result;
}
示例2: index
public function index()
{
$post = array('alert' => '');
// Model::load('admincp/setting');
if ($match = Uri::match('\\/setting\\/(\\w+)')) {
if (method_exists("controlSetting", $match[1])) {
$method = $match[1];
$this->{$method}();
die;
}
}
if (Request::has('btnSave')) {
System::saveSetting(Request::get('general'));
}
$data = array();
if (!($data = Cache::loadKey('systemSetting', -1))) {
$data = System::makeSetting();
} else {
$data = unserialize($data);
}
$post = $data;
$post['usergroups'] = UserGroups::get();
System::setTitle('Setting System - ' . ADMINCP_TITLE);
View::make('admincp/head');
self::makeContents('settingGeneral', $post);
View::make('admincp/footer');
}
示例3: listRss
function listRss()
{
header("Content-Type: application/xml; charset=UTF-8");
$location = Url::rss();
if ($match = Uri::match('^(.*?)$')) {
$location = ROOT_URL . $match[1];
$reLocation = base64_encode($location);
if ($loadData = Cache::loadKey($reLocation, 60)) {
$loadData = json_decode($loadData, true);
return $loadData;
}
}
$inputData = array('limitShow' => 15, 'limitPage' => 0);
if ($match = Uri::match('\\/page\\/(\\d+)')) {
$inputData['limitPage'] = $match[1];
}
if ($match = Uri::match('\\/category\\/(\\d+)')) {
$id = $match[1];
$inputData['where'] = "where catid='{$id}'";
}
if ($match = Uri::match('rss\\/products')) {
$loadData = Products::get($inputData);
} else {
$loadData = Post::get($inputData);
}
$reLocation = base64_encode($location);
Cache::saveKey($reLocation, json_encode($loadData));
return $loadData;
}
示例4: searchResult
function searchResult()
{
$curPage = 0;
$keywords = '';
if ($matches = Uri::match('tag\\/(.*?)\\/page\\/(\\d+)')) {
$curPage = $matches[2];
$keywords = $matches[1];
} elseif ($matches = Uri::match('tag\\/(.*?)$')) {
$curPage = 0;
$keywords = $matches[1];
}
// $loadPostNode=PostTags::get(array(
// 'limitShow'=>10,
// 'limitPage'=>$curPage,
// 'where'=>"where tag_title LIKE '%$keywords%'"
// ));
// // print_r($loadPostNode);die();
// $total=count($loadPostNode);
// $listID='';
// for($i=0;$i<$total;$i++)
// {
// $listID.="'".$loadPostNode[$i]['postid']."', ";
// }
// $listID=substr($listID, 0, strlen($listID)-2);
$loadData = Post::get(array('where' => "where postid IN (select postid from post_tags where title='{$keywords}')", 'orderby' => "group by postid order by date_added"));
return $loadData;
}
示例5: index
public function index()
{
Cache::loadPage('', 30);
$inputData = array();
$postid = 0;
$curPage = 0;
// Model::loadWithPath('home',System::getThemePath().'model/');
if ($match = Uri::match('page\\/(\\d+)')) {
$curPage = (int) $match[1];
}
$txtKeywords = addslashes(Request::get('txtKeywords', ''));
if ($match = Uri::match('\\/keyword\\/(.*?)\\/page')) {
$txtKeywords = base64_decode($match[1]);
}
$loadData = Post::get(array('limitShow' => 10, 'limitPage' => $curPage, 'cacheTime' => 30, 'where' => "where title LIKE '%{$txtKeywords}%'", 'orderby' => "order by postid desc"));
if (!isset($loadData[0]['postid'])) {
Redirect::to('404page');
}
$inputData['newPost'] = $loadData;
$inputData['keywords'] = $txtKeywords;
$inputData['listPage'] = Misc::genPage('search/keyword/' . base64_encode($txtKeywords), $curPage);
System::setTitle('Search result with keyword "' . $txtKeywords . '" results:');
self::makeContent('search', $inputData);
Cache::savePage();
}
示例6: index
public function index()
{
Cache::loadPage('', 30);
$inputData = array();
$postid = 0;
Model::loadWithPath('page', System::getThemePath() . 'model/');
if (!($match = Uri::match('page\\/(.*?)\\.html$'))) {
Redirect::to('404page');
}
$friendly_url = addslashes($match[1]);
$loadData = Pages::get(array('cacheTime' => 30, 'where' => "where friendly_url='{$friendly_url}'"));
if (!isset($loadData[0]['pageid'])) {
Redirect::to('404page');
}
$inputData = $loadData[0];
$postid = $loadData[0]['pageid'];
if (Uri::isNull()) {
System::setTitle(ucfirst($loadData[0]['title']));
}
$keywords = isset($loadData[0]['keywords'][4]) ? $loadData[0]['keywords'] : System::getKeywords();
System::setKeywords($keywords);
if ($loadData[0]['page_type'] == 'fullwidth') {
self::makeContent('pageFullWidth', $inputData);
} else {
self::makeContent('page', $inputData);
}
Cache::savePage();
}
示例7: index
public function index()
{
Cache::loadPage('', 30);
$inputData = array();
$postid = 0;
Model::loadWithPath('post', System::getThemePath() . 'model/');
if (!($match = Uri::match('post\\/(.*?)\\.html$'))) {
Redirect::to('404page');
}
$friendly_url = addslashes($match[1]);
$loadData = Post::get(array('cacheTime' => 30, 'where' => "where friendly_url='{$friendly_url}'"));
if (!isset($loadData[0]['postid'])) {
Redirect::to('404page');
}
$inputData = $loadData[0];
if (Request::has('btnComment')) {
try {
sendComment($loadData[0]['postid']);
$inputData['commentAlert'] = '<div class="alert alert-success">Send comment success.</div>';
} catch (Exception $e) {
$inputData['commentAlert'] = '<div class="alert alert-warning">' . $e->getMessage() . '</div>';
}
}
$postid = $loadData[0]['postid'];
$listTag = PostTags::renderToLink($postid);
$inputData['listTag'] = $listTag;
$inputData['listComments'] = Comments::get(array('where' => "where postid='{$postid}' AND status='1'", 'orderby' => "order by postid desc"));
Post::upView($postid);
System::setTitle(ucfirst($loadData[0]['title']));
$keywords = isset($loadData[0]['keywords'][4]) ? $loadData[0]['keywords'] : System::getKeywords();
System::setKeywords($keywords);
self::makeContent('post', $inputData);
Cache::savePage();
}
示例8: loadApi
function loadApi($action)
{
switch ($action) {
case 'post_image':
if (!($match = Uri::match('post_image\\/(\\d+)\\.(jpg|png)'))) {
throw new Exception('Data not valid');
}
$fileUrl = '';
try {
$fileUrl = Post::getImageFromContent($match[1]);
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
Redirect::to($fileUrl, 301);
exit;
break;
case 'post_thumb':
if (!($match = Uri::match('post_thumb\\/(\\d+)\\.(jpg|png)'))) {
throw new Exception('Data not valid');
}
$fileUrl = '';
try {
$fileUrl = System::getUrl() . Post::getThumb($match[1]);
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
Redirect::to($fileUrl, 301);
exit;
break;
}
}
示例9: index
public function index()
{
Cache::loadPage('', 30);
$inputData = array();
$postid = 0;
$curPage = 0;
// Model::loadWithPath('home',System::getThemePath().'model/');
if (!($match = Uri::match('tag\\/(\\w+)\\/?'))) {
Redirect::to('404page');
}
$friendly_url = addslashes($match[1]);
if ($match = Uri::match('page\\/(\\d+)')) {
$curPage = (int) $match[1];
}
$loadData = Post::get(array('limitShow' => 10, 'limitPage' => $curPage, 'cacheTime' => 30, 'where' => "where postid IN (select postid from post_tags where title='{$friendly_url}')", 'orderby' => "order by postid desc"));
if (!isset($loadData[0]['postid'])) {
Redirect::to('404page');
}
$inputData['newPost'] = $loadData;
$inputData['keywords'] = $friendly_url;
$inputData['listPage'] = Misc::genPage('tag/' . $friendly_url, $curPage);
System::setTitle('Tag "' . $friendly_url . '" results:');
self::makeContent('tag', $inputData);
Cache::savePage();
}
示例10: index
public function index()
{
if ($match = Uri::match('\\/jsonCategory')) {
$keyword = String::encode(Request::get('keyword', ''));
$loadData = Categories::get(array('where' => "where title LIKE '%{$keyword}%'", 'orderby' => 'order by title asc'));
$total = count($loadData);
$li = '';
for ($i = 0; $i < $total; $i++) {
$li .= '<li><span data-method="category" data-id="' . $loadData[$i]['catid'] . '" >' . $loadData[$i]['title'] . '</span></li>';
}
echo $li;
die;
}
$post = array('alert' => '');
Model::load('admincp/categories');
$curPage = 0;
if ($match = Uri::match('\\/page\\/(\\d+)')) {
$curPage = $match[1];
}
if (Request::has('btnAction')) {
actionProcess();
}
if (Request::has('btnAdd')) {
try {
insertProcess();
$post['alert'] = '<div class="alert alert-success">Add new category success.</div>';
} catch (Exception $e) {
$post['alert'] = '<div class="alert alert-warning">' . $e->getMessage() . '</div>';
}
}
if (Request::has('btnSave')) {
$match = Uri::match('\\/edit\\/(\\d+)');
try {
updateProcess($match[1]);
$post['alert'] = '<div class="alert alert-success">Update category success.</div>';
} catch (Exception $e) {
$post['alert'] = '<div class="alert alert-warning">' . $e->getMessage() . '</div>';
}
}
if (Request::has('btnSearch')) {
filterProcess();
} else {
$post['pages'] = Misc::genSmallPage('admincp/categories', $curPage);
$post['theList'] = Categories::get(array('limitShow' => 20, 'limitPage' => $curPage, 'orderby' => 'order by catid desc', 'cache' => 'no'));
}
if ($match = Uri::match('\\/edit\\/(\\d+)')) {
$loadData = Categories::get(array('where' => "where catid='" . $match[1] . "'", 'cache' => 'no'));
$post['edit'] = $loadData[0];
}
System::setTitle('Categories list - ' . ADMINCP_TITLE);
View::make('admincp/head');
self::makeContents('categoriesList', $post);
View::make('admincp/footer');
}
示例11: searchResult
function searchResult()
{
$curPage = 0;
$keywords = '';
if ($matches = Uri::match('search\\/keyword\\/(.*?)\\/page\\/(\\d+)')) {
$curPage = $matches[2];
$keywords = base64_decode($matches[1]);
} else {
$keywords = Request::get('txtKeywords', '');
}
$loadData = Post::get(array('limitShow' => 24, 'limitPage' => $curPage, 'where' => "where title LIKE '%{$keywords}%'"));
return $loadData;
}
示例12: view
public function view()
{
if (!($match = Uri::match('\\/view\\/(\\d+)'))) {
Redirect::to(ADMINCP_URL . 'comments/');
}
$commentid = $match[1];
$loadData = Comments::get(array('query' => "select p.title,c.* from " . Database::getPrefix() . "post p," . Database::getPrefix() . "comments c where p.postid=c.postid AND c.commentid='{$commentid}'"));
$post['edit'] = $loadData[0];
System::setTitle('View comment - ' . ADMINCP_TITLE);
View::make('admincp/head');
self::makeContents('commentView', $post);
View::make('admincp/footer');
}
示例13: index
public function index()
{
$post = array('alert' => '');
// Model::load('admincp/dbstore');
if ($match = Uri::match('\\/dbstore\\/(\\w+)')) {
if (method_exists("controlDBStore", $match[1])) {
$method = $match[1];
$this->{$method}();
die;
}
}
Redirect::to(ADMINCP_URL);
}
示例14: index
public function index()
{
if ($match = Uri::match('^api\\/(\\w+)')) {
Model::load('api');
try {
apiProcess();
} catch (Exception $e) {
echo $e->getMessage();
}
} else {
echo json_encode(array('error' => 'yes'));
}
}
示例15: view
public function view()
{
if (!($match = Uri::match('\\/view\\/(\\d+)'))) {
Redirect::to(ADMINCP_URL . 'contacts/');
}
$postid = $match[1];
$post = array('alert' => '');
$loadData = Contactus::get(array('where' => "where contactid='{$postid}'"));
$post = $loadData[0];
System::setTitle('View contact - ' . ADMINCP_TITLE);
View::make('admincp/head');
self::makeContents('contactView', $post);
View::make('admincp/footer');
}