本文整理汇总了PHP中Zend_Controller_Router_Route类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Router_Route类的具体用法?PHP Zend_Controller_Router_Route怎么用?PHP Zend_Controller_Router_Route使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Controller_Router_Route类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: routeStartup
public function routeStartup(Zend_Controller_Request_Abstract $request)
{
if (!$this->_issession) {
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
if ($this->_domain) {
$doms = $this->_model->fetchPairs('id', 'domain');
if ($doms) {
foreach ($doms as $k => $el) {
$doms[$k] = @$el[0] ? explode(' ', $el) : array();
}
}
$lang = $request->getParam('lang');
if ($lang) {
$this->_session->lang = $this->_model->fetchOne('id', array('`stitle` = ?' => $lang));
} else {
if ($doms) {
foreach ($doms as $k => $el) {
if (in_array($_SERVER['HTTP_HOST'], $el)) {
$this->_session->lang = $k;
break;
}
}
}
}
$this->_lang = $this->_model->fetchRow(null, '(`id` = ' . (int) $this->_session->lang . ') DESC, (`default` = 1) DESC');
if ($this->_lang) {
$this->_lang = new Zkernel_View_Data($this->_lang);
}
$this->_lang->_default = $this->getDefault();
$this->_lang->_ids = $this->_model->fetchIds();
$this->_lang->_doms = $doms;
} else {
$routes = $router->getRoutes();
$router->removeDefaultRoutes();
if ($routes) {
foreach ($routes as $k => $el) {
$router->removeRoute($k);
}
}
$langRoute = new Zend_Controller_Router_Route(':lang', array('lang' => $this->getDefault()->stitle));
$router->addRoute('default', $langRoute->chain(new Zend_Controller_Router_Route_Module(array(), $front->getDispatcher(), $front->getRequest())));
$router->addRoute('lang', $langRoute);
if ($routes) {
foreach ($routes as $k => $el) {
$router->addRoute($k, $k == 'fu' || $k == 'minify' ? $el : $langRoute->chain($el));
}
}
}
}
$this->save();
}
开发者ID:s-kalaus,项目名称:zkernel,代码行数:52,代码来源:Multilang.php
示例2: match
/**
* Attempt to match the current request URL
* If a match is found, instantiate a new ImboClient
*
* @see Zend_Controller_Router_Route::match()
*/
public function match($path, $partial = false)
{
$match = parent::match($path, $partial);
$config = array();
$instance = false;
$imgUrl = '';
if ($match) {
$instance = $match['instance'];
// Check if the passed instance exists
if (!isset($this->instances[$instance])) {
throw new Zend_Controller_Router_Exception('Instance "' . $instance . '" does not exist in configuration', 404);
}
// If this is not a sub-action, check if this is an XMLHttpRequest
if ($match['controller'] != 'instance' && (!isset($_SERVER['X_REQUESTED_WITH']) || $_SERVER['X_REQUESTED_WITH'] != 'XMLHttpRequest')) {
$match['controller'] = 'instance';
$match['action'] = 'index';
}
// Create an imbo client for the given instance and make it available in request
$config = $this->instances[$instance];
$match['imboClient'] = new ImboClient\Client($config['host'], $config['pubkey'], $config['privkey']);
$imgUrl = $match['imboClient']->getImagesUrl();
}
// Set active instance name to view so we may use it in frontend
$frontController = Zend_Controller_Front::getInstance();
$view = $frontController->getParam('bootstrap')->getResource('view');
$view->activeInstance = $instance;
$view->imagesUrl = $imgUrl;
$view->maxUploadSize = $this->getMaxUploadSize($config);
return $match;
}
开发者ID:rexxars,项目名称:imbo-dashboard,代码行数:36,代码来源:Instance.php
示例3: routeShutdown
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{
$language = $request->getParam("language", Zend_Registry::get('Zend_Locale')->getLanguage());
$locale = new Zend_Locale($language);
Zend_Registry::get('Zend_Locale')->setLocale($locale);
$translate = Zend_Registry::get('Zend_Translate');
$translate->getAdapter()->setLocale(Zend_Registry::get('Zend_Locale'));
Zend_Controller_Router_Route::setDefaultTranslator($translate);
}
开发者ID:BGCX262,项目名称:zweer-gdr-svn-to-git,代码行数:9,代码来源:Multilanguage.php
示例4: init
/**
* Defined by Zend_Application_Resource_Resource
*
* @return Zend_Controller_Router_Rewrite
*/
public function init()
{
if (null === $this->_router) {
$router = $this->getRouter();
// returns $this->_router
$router->addConfig($this->_getConfig());
// add locale chain if using translate
if ($this->getBootstrap()->hasPluginResource('Translate')) {
$locale = new Zend_Controller_Router_Route(':locale', array(), array('locale' => '^[a-z]{2}$'));
$router->addDefaultRoutes();
foreach ($router->getRoutes() as $name => $route) {
//rename existing routes
$router->removeRoute($name)->addRoute($name . 'Default', $route)->addRoute($name, $locale->chain($route));
}
}
}
return $this->_router;
}
开发者ID:uglide,项目名称:zfcore-transition,代码行数:23,代码来源:Router.php
示例5: _initRoutes
/**
* Routes initialization
*
* @return Zend_Controller_Router
*/
protected function _initRoutes()
{
$this->bootstrapOptions();
$router = new \Zend_Controller_Router_Rewrite();
foreach (\NS\Service\AbstractService::getConfig() as $module => $config) {
if ($config->routes) {
foreach ($config->routes as $r => $routeConfig) {
$router->addRoute($module . '_' . $r, \Zend_Controller_Router_Route::getInstance($routeConfig));
}
}
}
\Zend_Controller_Front::getInstance()->setRouter($router);
return $router;
}
开发者ID:MossesX,项目名称:mongo-cms,代码行数:19,代码来源:Bootstrap.php
示例6: testEscapedSpecialCharsWithTranslation
public function testEscapedSpecialCharsWithTranslation()
{
$route = new Zend_Controller_Router_Route('::foo/@@bar/:@myvar');
$path = $route->assemble(array('myvar' => 'foo'));
$this->assertEquals($path, ':foo/@bar/en_foo');
$values = $route->match(':foo/@bar/en_foo');
$this->assertEquals($values['myvar'], 'foo');
}
开发者ID:netvlies,项目名称:zf,代码行数:8,代码来源:RouteTest.php
示例7: testAssembleWithRemovedDefaults
public function testAssembleWithRemovedDefaults() // Test for ZF-1197
{
$route = new Zend_Controller_Router_Route(':controller/:action/*', array('controller' => 'index', 'action' => 'index'));
$url = $route->assemble(array('id' => 3));
$this->assertSame('index/index/id/3', $url);
$url = $route->assemble(array('action' => 'test'));
$this->assertSame('index/test', $url);
$url = $route->assemble(array('action' => 'test', 'id' => 3));
$this->assertSame('index/test/id/3', $url);
$url = $route->assemble(array('controller' => 'test'));
$this->assertSame('test', $url);
$url = $route->assemble(array('controller' => 'test', 'action' => 'test'));
$this->assertSame('test/test', $url);
$url = $route->assemble(array('controller' => 'test', 'id' => 3));
$this->assertSame('test/index/id/3', $url);
$url = $route->assemble(array());
$this->assertSame('', $url);
$route->match('ctrl');
$url = $route->assemble(array('id' => 3));
$this->assertSame('ctrl/index/id/3', $url);
$url = $route->assemble(array('action' => 'test'));
$this->assertSame('ctrl/test', $url);
$url = $route->assemble();
$this->assertSame('ctrl', $url);
$route->match('index');
$url = $route->assemble();
$this->assertSame('', $url);
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:41,代码来源:RouteTest.php
示例8: _initTranslate
/**
* Initializes translator
*
* @return Zend_Translate_Adapter
*/
public function _initTranslate()
{
$log = new Zend_Log();
if (APPLICATION_ENV == 'development') {
$log = new Zend_Log();
$log->addWriter(new Zend_Log_Writer_Firebug());
//$log->addWriter(new Zend_Log_Writer_Stream(APPLICATION_PATH . '/temporary/log/translate.log'));
} else {
$log->addWriter(new Zend_Log_Writer_Null());
}
$params['log'] = $log;
// Create the object and add a language
$translate = new Zend_Translate('Array', APPLICATION_PATH . '/languages/vi/vi.php', 'vi_VN');
// Add another translation
$translate->addTranslation(APPLICATION_PATH . '/languages/en/en.php', 'en_US');
// Set nb_NO as default translation
$translate->setLocale('vi_VN');
Zend_Registry::set('Zend_Translate', $translate);
Zend_Validate_Abstract::setDefaultTranslator($translate);
Zend_Form::setDefaultTranslator($translate);
Zend_Controller_Router_Route::setDefaultTranslator($translate);
return $translate;
}
开发者ID:nhochong,项目名称:qlkh-sgu,代码行数:28,代码来源:Bootstrap.php
示例9: Zend_Translate
<?php
$conf = Zend_Registry::get("conf");
try {
// Translation
$translateUrl = new Zend_Translate('gettext', APPLICATION_DIRECTORY . '/Joobsbox/Languages/' . $locale . '/LC_MESSAGES/url.mo', $locale, array('disableNotices' => true));
} catch (Exception $e) {
$translateUrl = new Zend_Translate('gettext', APPLICATION_DIRECTORY . '/Joobsbox/Languages/en/LC_MESSAGES/url.mo', 'en');
}
Zend_Registry::set("Joobsbox_Translate_URL", $translateUrl);
Zend_Controller_Router_Route::setDefaultTranslator($translateUrl);
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
$rssRoute = new Zend_Controller_Router_Route('rss/@category/:category', array('controller' => 'rss', 'action' => 'index'));
$mainRoute = new Zend_Controller_Router_Route(':@controller/:@action/*', array('controller' => 'index', 'action' => 'index'));
$mainRoute2 = new Zend_Controller_Router_Route('index.php/:@controller/:@action/*', array('controller' => 'index', 'action' => 'index'));
$router->addRoute("main", $mainRoute);
$router->addRoute("main2", $mainRoute2);
$router->addRoute("rss", $rssRoute);
$mainRoute->assemble(array());
$mainRoute->assemble(array());
$mainRoute2->assemble(array());
$mainRoute2->assemble(array());
$front->setRouter($router);
开发者ID:valentinbora,项目名称:joobsbox-php,代码行数:24,代码来源:router.php
示例10: test_RESTfulApp_route_chaining_urlencodedWithPlusSymbol
/**
* @group ZF-10964
*/
public function test_RESTfulApp_route_chaining_urlencodedWithPlusSymbol()
{
$request = $this->_buildRequest('GET', '/api/user/email%2Btest%40example.com');
$this->_front->setRequest($request);
$router = $this->_front->getRouter();
$router->removeDefaultRoutes();
$nonRESTRoute = new Zend_Controller_Router_Route('api');
$RESTRoute = new Zend_Rest_Route($this->_front);
$router->addRoute("api", $nonRESTRoute->chain($RESTRoute));
$routedRequest = $router->route($request);
$this->assertEquals("default", $routedRequest->getParam("module"));
$this->assertEquals("user", $routedRequest->getParam("controller"));
$this->assertEquals("get", $routedRequest->getParam("action"));
$this->assertEquals("[email protected]", $routedRequest->getParam("id"));
}
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:18,代码来源:RouteTest.php
示例11: _initTranslate
//.........这里部分代码省略.........
foreach( $it as $item ) {
if( $item->isDot() || !$item->isDir() ) {
continue;
}
$name = $item->getBasename();
if( !Zend_Locale::isLocale($name) ) {
continue;
}
$languages[] = $name;
}
*/
// If in development, log untranslated messages
$params = array('scan' => Zend_Translate_Adapter::LOCALE_DIRECTORY, 'logUntranslated' => true);
$log = new Zend_Log();
if (APPLICATION_ENV == 'development') {
$log = new Zend_Log();
$log->addWriter(new Zend_Log_Writer_Firebug());
$log->addWriter(new Zend_Log_Writer_Stream(APPLICATION_PATH . '/temporary/log/translate.log'));
} else {
$log->addWriter(new Zend_Log_Writer_Null());
}
$params['log'] = $log;
// Check Locale
$locale = Zend_Locale::findLocale();
// Make Sure Language Folder Exist
$languageFolder = is_dir(APPLICATION_PATH . '/application/languages/' . $locale);
if ($languageFolder === false) {
$locale = substr($locale, 0, 2);
$languageFolder = is_dir(APPLICATION_PATH . '/application/languages/' . $locale);
if ($languageFolder == false) {
$locale = 'en';
}
}
// Check which Translation Adapter has been selected
$db = Engine_Db_Table::getDefaultAdapter();
$translationAdapter = $db->select()->from('engine4_core_settings', 'value')->where('`name` = ?', 'core.translate.adapter')->query()->fetchColumn();
// If adapter is 'array', Make sure array files exist
/*
if( $translationAdapter == 'array'){
// Check if Language File Exists
if( !file_exists(APPLICATION_PATH . '/application/languages/' . $locale . '/' . $locale . '.php')){
//echo 'Locale does not exist ' . APPLICATION_PATH . '/application/languages/' . $locale . '/' . $locale . '_array.php<br />';
// Try looking elsewhere
$newLocale = substr($locale, 0, 2);
//echo 'Attempting to Look for ' . $newLocale . '<br />';
if( file_exists(APPLICATION_PATH . '/application/languages/' . $newLocale . '/' . $newLocale . '.php')){
$locale = $newLocale;
//echo 'New Locale Found ' . APPLICATION_PATH . '/application/languages/' . $newLocale . '/' . $newLocale . '_array.php<br />';
} else { $translationAdapter = 'csv'; $locale = 'en'; }
}
}
*/
// Use Array Translation Adapter, Loop through all Availible Translations
if ($translationAdapter == 'array') {
// Find all Valid Language Arrays
// Check For Array Files
$languagePath = APPLICATION_PATH . '/application/languages';
// Get List of Folders
$languageFolders = array_filter(glob($languagePath . DIRECTORY_SEPARATOR . '*'), 'is_dir');
// Look inside Folders for PHP array
$locale_array = array();
foreach ($languageFolders as $folder) {
// Get Locale code
$locale_code = str_replace($languagePath . DIRECTORY_SEPARATOR, "", $folder);
$locale_array[] = $locale_code;
if (!file_exists($folder . DIRECTORY_SEPARATOR . $locale_code . '.php')) {
// If Array files do not exist, switch to CSV
$translationAdapter = 'csv';
}
}
$language_count = count($locale_array);
// Add the First One
$translate = new Zend_Translate(array('adapter' => 'array', 'content' => $languagePath . DIRECTORY_SEPARATOR . $locale_array[0] . DIRECTORY_SEPARATOR . $locale_array[0] . '.php', 'locale' => $locale_array[0]));
if ($language_count > 1) {
for ($i = 1; $i < $language_count; $i++) {
$translate->addTranslation(array('content' => $languagePath . DIRECTORY_SEPARATOR . $locale_array[$i] . DIRECTORY_SEPARATOR . $locale_array[$i] . '.php', 'locale' => $locale_array[$i]));
}
}
/*
if( $language_count > 1) {
for( $i = 1; $i < $language_count; $i++ ) {
$translate->addTranslation(
array(
'content' => $languageFolders[$i] . DIRECTORY_SEPARATOR . $locale_array[$i] . '.php',
'locale' => $locale_array[$i] )
);
echo $locale_array[$i] . ' Translation Added<br />';
}
}
* */
} else {
$translate = new Zend_Translate('Csv', APPLICATION_PATH . '/application/languages', null, $params);
}
Zend_Registry::set('Zend_Translate', $translate);
Zend_Validate_Abstract::setDefaultTranslator($translate);
Zend_Form::setDefaultTranslator($translate);
Zend_Controller_Router_Route::setDefaultTranslator($translate);
return $translate;
}
开发者ID:hoalangoc,项目名称:ftf,代码行数:101,代码来源:Bootstrap.php
示例12: testAssembleWithVariableMissing
public function testAssembleWithVariableMissing()
{
$route = new Zend_Controller_Router_Route('archive/:year', array('controller' => 'archive', 'action' => 'show'), array('year' => '\\d+'));
try {
$url = $route->assemble();
} catch (Exception $e) {
}
$this->assertTrue($e instanceof Zend_Controller_Router_Exception, 'Expected Zend_Controller_Router_Exception to be thrown');
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:9,代码来源:RouteTest.php
示例13: testAssembleWithDefaultAndValue
public function testAssembleWithDefaultAndValue()
{
$route = new Zend_Controller_Router_Route('authors/:name', array('name' => 'martel'));
$url = $route->assemble(array('name' => 'mike'));
$this->assertEquals('authors/mike', $url);
}
开发者ID:Tony133,项目名称:zf-web,代码行数:6,代码来源:RouteTest.php
示例14: testGetDefault
public function testGetDefault()
{
$route = new Zend_Controller_Router_Route('users/all', array('controller' => 'ctrl', 'action' => 'act'));
$this->assertSame('ctrl', $route->getDefault('controller'));
$this->assertSame(null, $route->getDefault('bogus'));
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:6,代码来源:RouteTest.php
示例15: testChainingWithEmptyStaticRoutesMatchesCorrectly
/**
* @group ZF-7848
*/
public function testChainingWithEmptyStaticRoutesMatchesCorrectly()
{
$adminRoute = new Zend_Controller_Router_Route('admin', array('module' => 'admin', 'controller' => 'index', 'action' => 'index'));
$indexRoute = new Zend_Controller_Router_Route_Static('', array('module' => 'admin', 'controller' => 'index', 'action' => 'index'));
$loginRoute = new Zend_Controller_Router_Route('login', array('module' => 'admin', 'controller' => 'login', 'action' => 'index'));
$emptyRoute = $adminRoute->chain($indexRoute);
$nonEmptyRoute = $adminRoute->chain($loginRoute);
$request = new Zend_Controller_Request_Http();
$request->setPathInfo('/admin');
$values = $emptyRoute->match($request);
$this->assertEquals(array('module' => 'admin', 'controller' => 'index', 'action' => 'index'), $values);
$request->setPathInfo('/admin/');
$values = $emptyRoute->match($request);
$this->assertEquals(array('module' => 'admin', 'controller' => 'index', 'action' => 'index'), $values);
$request->setPathInfo('/admin/login');
$values = $nonEmptyRoute->match($request);
$this->assertEquals(array('module' => 'admin', 'controller' => 'login', 'action' => 'index'), $values);
}
开发者ID:JeancarloPerez,项目名称:booking-system,代码行数:21,代码来源:ChainTest.php
示例16: testEncode
public function testEncode()
{
$route = new Zend_Controller_Router_Route(':controller/:action/*', array('controller' => 'index', 'action' => 'index'));
$url = $route->assemble(array('controller' => 'My Controller'), false, true);
$this->assertEquals('My+Controller', $url);
$url = $route->assemble(array('controller' => 'My Controller'), false, false);
$this->assertEquals('My Controller', $url);
$token = $route->match('en/foo/id/My Value');
$url = $route->assemble(array(), false, true);
$this->assertEquals('en/foo/id/My+Value', $url);
$url = $route->assemble(array('id' => 'My Other Value'), false, true);
$this->assertEquals('en/foo/id/My+Other+Value', $url);
$route = new Zend_Controller_Router_Route(':controller/*', array('controller' => 'My Controller'));
$url = $route->assemble(array('id' => 1), false, true);
$this->assertEquals('My+Controller/id/1', $url);
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:22,代码来源:RouteTest.php
示例17: getLocale
/**
* Get the locale
*
* @return mixed
*/
public function getLocale()
{
if ($this->_locale !== null) {
return $this->_locale;
} else {
if (($locale = Zend_Controller_Router_Route::getDefaultLocale()) !== null) {
return $locale;
} else {
try {
$locale = Zend_Registry::get('Zend_Locale');
} catch (Zend_Exception $e) {
$locale = null;
}
if ($locale !== null) {
return $locale;
}
}
}
return null;
}
开发者ID:BackupTheBerlios,项目名称:dkplusengine,代码行数:25,代码来源:Module.php
示例18: _initRoutes
public function _initRoutes()
{
$this->bootstrap('FrontController');
$this->_frontController = $this->getResource('FrontController');
$router = $this->_frontController->getRouter();
$langRoute = new Zend_Controller_Router_Route(':lang/', array('lang' => 'en'));
$defaultRoute = new Zend_Controller_Router_Route(':controller/:action', array('module' => 'default', 'controller' => 'index', 'action' => 'index'));
$defaultRoute = $langRoute->chain($defaultRoute);
$router->addRoute('langRoute', $langRoute);
$router->addRoute('defaultRoute', $defaultRoute);
}
开发者ID:eulernunez,项目名称:RentAFlat-Zend-1,代码行数:11,代码来源:__Bootstrap.php
示例19: match
/**
* Matches a user submitted path with parts defined by a map. Assigns and
* returns an array of variables on a successful match.
*
* @param string $path Path used to match against this routing map
* @return array|false An array of assigned values or a false on a mismatch
*/
public function match($request, $partial = false)
{
if (!$request instanceof \Zend_Controller_Request_Http) {
throw new \Zend_Controller_Router_Exception("Route needs a http request");
}
$return = parent::match($request->getPathInfo(), $partial);
if (!$return) {
return $return;
}
if (!($token = $return[$this->_tokenVariable])) {
throw new \Zend_Controller_Router_Exception("Token not defined", 400);
}
if (!($tokenData = \Download\Service\DownloadTokenService::getInstance()->popToken($token))) {
throw new \Zend_Controller_Router_Exception("Token does not exist or has expired", 400);
}
$return = array_merge($return, $tokenData->exportData());
$return['downloadToken'] = $tokenData;
$return['module'] = 'download';
//Data defined inside token
$return['controller'] = $tokenData->controller;
$return['action'] = $tokenData->action;
if (is_array($tokenData->params)) {
$return += $tokenData->params;
}
return $return;
}
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:33,代码来源:OneUse.php
示例20: __construct
public function __construct()
{
/* Informações */
$route = $this->getRoute();
$defaults = $this->getDefaults();
/* Construtor */
parent::__construct($route, $defaults);
}
开发者ID:laiello,项目名称:wanderson,代码行数:8,代码来源:Auth.php
注:本文中的Zend_Controller_Router_Route类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论