本文整理汇总了PHP中CUrlManager::init方法的典型用法代码示例。如果您正苦于以下问题:PHP CUrlManager::init方法的具体用法?PHP CUrlManager::init怎么用?PHP CUrlManager::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUrlManager
的用法示例。
在下文中一共展示了CUrlManager::init方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
if ($this->getUrlFormat() !== self::PATH_FORMAT) {
throw new CException("LanguageUrlManager only works with urlFormat 'path'");
}
return parent::init();
}
示例2: init
public function init()
{
$langs = Lang::getActiveLangs();
$defaultLang = Lang::getDefaultLang();
$this->isInstalled = oreInstall::isInstalled();
$keyDefault = array_search($defaultLang, $langs);
if ($keyDefault !== false && $this->isInstalled) {
unset($langs[$keyDefault]);
}
//$countLangs = count($langs);
$this->langRoute = '<lang:' . implode('|', $langs) . '>';
$rules = array('sitemap.xml' => 'sitemap/main/viewxml', 'yandex_export_feed.xml' => 'yandexRealty/main/viewfeed', 'version' => '/site/version', 'site/uploadimage/' => 'site/uploadimage/', 'site/activation' => 'site/activation', 'min/serve/g/' => 'min/serve/', 'rss' => 'quicksearch/main/mainsearch/rss/1', '<module:\\w+>/backend/<controller:\\w+>/<action:\\w+>' => '<module>/backend/<controller>/<action>');
$rulesLang = array('/' => 'site/index', '/login' => 'site/login', '/admin' => 'site/login', '/administrator' => 'site/login', '/register' => 'site/register', '/recover' => 'site/recover', '/logout' => 'site/logout', '/site/activation' => 'site/activation', '/sell' => 'quicksearch/main/mainsearch/type/2', '/rent' => 'quicksearch/main/mainsearch/type/1', '/site/uploadimage/' => 'site/uploadimage/', '/min/serve/g/' => 'min/serve/', '/news' => 'news/main/index', '/news/<id:\\d+>' => 'news/main/view', '/news/<url:[-a-zA-Z0-9_+\\.]{1,255}>' => 'news/main/view', '/blog' => 'blog/main/index', '/blog/<id:\\d+>' => 'blog/main/view', '/blog/<url:[-a-zA-Z0-9_+\\.]{1,255}>' => 'blog/main/view', '/faq' => 'articles/main/index', '/faq/<id:\\d+>' => 'articles/main/view', '/faq/<url:[-a-zA-Z0-9_+\\.]{1,255}>' => 'articles/main/view', '/contact-us' => 'contactform/main/index', '/specialoffers' => 'specialoffers/main/index', '/sitemap' => 'sitemap/main/index', '/reviews' => 'reviews/main/index', '/reviews/add' => 'reviews/main/add', '/vacancy' => 'vacancy/main/index', '/vacancy/add' => 'vacancy/main/add', '/guestad/add' => 'guestad/main/create', '/page/<id:\\d+>' => 'infopages/main/view', '/page/<url:[-a-zA-Z0-9_+\\.]{1,255}>' => 'infopages/main/view', '/search' => 'quicksearch/main/mainsearch', '/comparisonList' => 'comparisonList/main/index', '/complain/add' => 'apartmentsComplain/main/complain', '/booking/add' => 'booking/main/bookingform', '/booking/request' => 'booking/main/mainform', '/usercpanel' => 'usercpanel/main/index', '/usercpanel/data' => 'usercpanel/main/data', '/usercpanel/xmlfeed' => 'usercpanel/main/xmlfeed', '/usercpanel/changepwd' => 'usercpanel/main/changepassword', '/usercpanel/tariffplans' => 'tariffPlans/main/index', '/usercpanel/payments' => 'usercpanel/main/payments', '/usercpanel/balance' => 'usercpanel/main/balance', '/usercpanel/bookingtable' => 'bookingtable/main/index', '/userads/create' => 'userads/main/create', '/userads/edit' => 'userads/main/update', '/userads/delete' => 'userads/main/delete', '/users/viewall' => 'users/main/search', '/users/alllistings' => 'apartments/main/alllistings', '/apartments/sendEmail' => 'apartments/main/sendEmail', '/mailbox' => 'messages/main/index', '/mailbox/send' => 'messages/main/sendform', '/mailbox/read' => 'messages/main/read', '/mailbox/delete' => 'messages/main/delete', '/messages/downloadFile' => 'messages/main/downloadFile', '/service-<serviceId:\\d+>' => 'quicksearch/main/mainsearch', '/property/<id:\\d+>' => 'apartments/main/view', '/property/<url:[-a-zA-Z0-9_+\\.]{1,255}>' => 'apartments/main/view', '/<controller:(quicksearch|specialoffers)>/main/index' => '<controller>/main/index', '/<_m>/<_c>/<_a>*' => '<_m>/<_c>/<_a>', '/<_c>/<_a>*' => '<_c>/<_a>', '/<_c>' => '<_c>');
foreach ($rulesLang as $key => $rule) {
if ($langs && $this->langRoute) {
$rules[$this->langRoute . $key] = $rule;
}
$rules[$key] = array($rule, 'defaultParams' => array('lang' => $defaultLang));
}
if ($langs && $this->langRoute) {
$rules[$this->langRoute] = '';
}
$this->addRules($rules);
if ($this->isInstalled) {
$modules = Yii::app()->getModules();
$paramModules = ConfigurationModel::getModulesList();
foreach ($paramModules as $module) {
if (isset($modules[$module]) && !param('module_enabled_' . $module)) {
$modules[$module]['enabled'] = false;
}
}
Yii::app()->setModules($modules);
}
return parent::init();
}
示例3: init
public function init()
{
/** Allow using GET format if seeing the ?r=... in the url */
if (isset($_GET['r']) && $this->urlFormat == 'path') {
$this->urlFormat = 'get';
}
parent::init();
}
示例4: init
public function init()
{
if ($this->showLangInUrl && $this->prependLangRules && is_array($this->rules)) {
$newRules = array();
$langInUrl = '';
foreach ($this->rules as $key => $value) {
$langInUrl = strpos($key, '/') === 0 ? '<_lang:\\w{2}>' : '<_lang:\\w{2}>/';
$newRules[$langInUrl . $key] = $value;
}
$this->rules = $newRules;
}
parent::init();
}
示例5: init
/**
* @return null
*/
public function init()
{
parent::init();
// Set this to false so extra query string parameters don't get the path treatment
$this->appendParams = false;
// makes more sense to set in HttpRequest
if (craft()->config->usePathInfo()) {
$this->setUrlFormat(static::PATH_FORMAT);
} else {
$this->setUrlFormat(static::GET_FORMAT);
}
$this->_routeVariables = array();
}
示例6: init
/**
* Initializes the application component.
*/
public function init()
{
if (!$this->languages) {
$this->languages = array(Yii::app()->language);
}
$langReg = implode('|', $this->languages);
$newRules = array();
foreach ($this->rules as $reg => $rule) {
$newRules['<language:' . $langReg . '>/' . $reg] = $rule;
}
$newRules['<language:' . $langReg . '>'] = Yii::app()->defaultController;
$this->rules = $newRules;
parent::init();
}
示例7: init
public function init()
{
$langs = Lang::getActiveLangs();
$countLangs = count($langs);
$langRoute = $countLangs > 1 || $countLangs == 1 && param('useLangPrefixIfOneLang') ? '<lang:' . implode('|', $langs) . '>' : '';
$rules = array('sitemap.xml' => 'sitemap/main/viewxml', 'yandex_export_feed.xml' => 'yandexRealty/main/viewfeed', 'version' => '/site/version', 'sell' => 'quicksearch/main/mainsearch/type/2', 'rent' => 'quicksearch/main/mainsearch/type/1', 'site/uploadimage/' => 'site/uploadimage/', $langRoute . '/site/uploadimage/' => 'site/uploadimage/', 'min/serve/g/' => 'min/serve/', $langRoute . '/min/serve/g/' => 'min/serve/', '<module:\\w+>/backend/<controller:\\w+>/<action:\\w+>' => '<module>/backend/<controller>/<action>', $langRoute . '/property/<id:\\d+>' => 'apartments/main/view', $langRoute . '/property/<url:[-a-zA-Z0-9_+\\.]{1,255}>' => 'apartments/main/view', $langRoute . '/news' => 'news/main/index', $langRoute . '/news/<id:\\d+>' => 'news/main/view', $langRoute . '/news/<url:[-a-zA-Z0-9_+\\.]{1,255}>' => 'news/main/view', $langRoute . '/faq' => 'articles/main/index', $langRoute . '/faq/<id:\\d+>' => 'articles/main/view', $langRoute . '/faq/<url:[-a-zA-Z0-9_+\\.]{1,255}>' => 'articles/main/view', $langRoute . '/contact-us' => 'contactform/main/index', $langRoute . '/specialoffers' => 'specialoffers/main/index', $langRoute . '/sitemap' => 'sitemap/main/index', $langRoute . '/reviews' => 'reviews/main/index', $langRoute . '/reviews/add' => 'reviews/main/add', $langRoute . '/guestad/add' => 'guestad/main/create', $langRoute . '/page/<id:\\d+>' => 'infopages/main/view', $langRoute . '/page/<url:[-a-zA-Z0-9_+\\.]{1,255}>' => 'infopages/main/view', $langRoute . '/search' => 'quicksearch/main/mainsearch', $langRoute . '/comparisonList' => 'comparisonList/main/index', $langRoute . '/complain/add' => 'apartmentsComplain/main/complain', $langRoute . '/booking/add' => 'booking/main/bookingform', $langRoute . '/booking/request' => 'booking/main/mainform', $langRoute . '/usercpanel' => 'usercpanel/main/index', $langRoute . '/userads/create' => 'userads/main/create', $langRoute . '/userads/edit' => 'userads/main/update', $langRoute . '/userads/delete' => 'userads/main/delete', $langRoute . '/users/viewall' => 'users/main/search', $langRoute . '/users/alllistings' => 'apartments/main/alllistings', $langRoute . '/apartments/sendEmail' => 'apartments/main/sendEmail', '/rss' => 'quicksearch/main/mainsearch/rss/1', $langRoute . '/service-<serviceId:\\d+>' => 'quicksearch/main/mainsearch', $langRoute . '/<controller:(quicksearch|specialoffers)>/main/index' => '<controller>/main/index', $langRoute . '/' => 'site/index', $langRoute . '/<_m>/<_c>/<_a>*' => '<_m>/<_c>/<_a>', $langRoute . '/<_c>/<_a>*' => '<_c>/<_a>', $langRoute . '/<_c>' => '<_c>', '/property/' => 'quicksearch/main/mainsearch', $langRoute . '/property/' => 'quicksearch/main/mainsearch');
if ($langRoute) {
$rules[$langRoute] = '';
}
$this->addRules($rules);
if (oreInstall::isInstalled()) {
$modules = Yii::app()->getModules();
$paramModules = ConfigurationModel::getModulesList();
foreach ($paramModules as $module) {
if (isset($modules[$module]) && !param('module_enabled_' . $module)) {
$modules[$module]['enabled'] = false;
}
}
Yii::app()->setModules($modules);
}
return parent::init();
}
示例8: testParsingOnly
public function testParsingOnly()
{
$config = array('basePath' => dirname(__FILE__), 'components' => array('request' => array('class' => 'TestHttpRequest')));
$rules = array('(articles|article)/<id:\\d+>' => array('article/read', 'parsingOnly' => true), 'article/<id:\\d+>' => array('article/read', 'verb' => 'GET'));
$_SERVER['REQUEST_METHOD'] = 'GET';
$app = new TestApplication($config);
$app->request->baseUrl = null;
// reset so that it can be determined based on scriptUrl
$app->request->scriptUrl = '/apps/index.php';
$app->request->pathInfo = 'articles/123';
$um = new CUrlManager();
$um->urlFormat = 'path';
$um->rules = $rules;
$um->init($app);
$route = $um->parseUrl($app->request);
$this->assertEquals('article/read', $route);
$url = $um->createUrl('article/read', array('id' => 345));
$this->assertEquals('/apps/index.php/article/345', $url);
}
示例9: testCreateUrlWithGetFormat
public function testCreateUrlWithGetFormat()
{
$config = array('basePath' => dirname(__FILE__), 'components' => array('request' => array('class' => 'TestHttpRequest')));
$app = new TestApplication($config);
$entries = array(array('scriptUrl' => '/apps/index.php', 'url' => '/apps/index.php?route=article/read&name=value&name1=value1', 'url2' => '/apps/?route=article/read&name=value&name1=value1', 'route' => 'article/read', 'params' => array('name' => 'value', 'name1' => 'value1')), array('scriptUrl' => '/index.php', 'url' => '/index.php?route=article/read&name=value&name1=value1', 'url2' => '/?route=article/read&name=value&name1=value1', 'route' => 'article/read', 'params' => array('name' => 'value', 'name1' => 'value1')));
foreach ($entries as $entry) {
$app->request->baseUrl = null;
$app->request->scriptUrl = $entry['scriptUrl'];
$um = new CUrlManager();
$um->urlFormat = 'get';
$um->routeVar = 'route';
$um->init($app);
$url = $um->createUrl($entry['route'], $entry['params'], '&');
$this->assertEquals($url, $entry['url']);
$um = new CUrlManager();
$um->urlFormat = 'get';
$um->routeVar = 'route';
$um->showScriptName = false;
$um->init($app);
$url = $um->createUrl($entry['route'], $entry['params'], '&');
$this->assertEquals($url, $entry['url2']);
}
}
示例10: init
public function init()
{
$this->initRules();
parent::init();
}
示例11: init
/**
* Init
* @access public
*/
public function init()
{
$this->_loadModuleUrls();
parent::init();
}
示例12: init
public function init()
{
parent::init();
}