public function url(array $urlOptions = array(), $name = null, $reset = false, $encode = true) { $front = Zend_Controller_Front::getInstance(); if ($name == null) { $name = Zend_Controller_Front::getInstance()->getRouter()->getCurrentRouteName(); } if ($name == 'mvc') { $router = $front->getRouter(); $return = $router->assemble($urlOptions, $name, $reset, $encode); } else { $menu_routes = Modules_Router_Model_Router::getInstance(); if (array_key_exists('route_id', $urlOptions)) { $current = $menu_routes->getItem($urlOptions['route_id']); } else { $module = array_key_exists('module', $urlOptions) ? $urlOptions['module'] : $front->getDefaultModule(); $controller = array_key_exists('controller', $urlOptions) ? $urlOptions['controller'] : $front->getDefaultControllerName(); $action = array_key_exists('action', $urlOptions) ? $urlOptions['action'] : $front->getDefaultAction(); $current = $menu_routes->getRoute($module, $controller, $action); } $currentUrl = $front->getBaseUrl() . $current['url']; $options = array(); foreach ($urlOptions as $key => $val) { if ($key == 'route_id' || $key == 'controller' || $key == 'module' || $key == 'action' && $action != $front->getDefaultAction()) { continue; } $options[] = $key . '=' . ($encode ? urlencode($val) : $val); } $return = $currentUrl . (sizeof($options) ? '?' . implode('&', $options) : ''); } return System_String::StrToLower($return); }
public function routeShutdown(Zend_Controller_Request_Abstract $request) { if (in_array(System_String::StrToLower($request->getControllerName()), array('admin', 'panel')) && false == $request->isXmlHttpRequest() && false == $request->getParam('direct')) { $redirector = new Zend_Controller_Action_Helper_Redirector(); $redirector->gotoUrlAndExit('#' . $this->_view->baseUrl() . $this->_view->currentUrl()); } }
/** * Запускаем подклченный модуль * */ protected function _forwardToMVC() { $module = $this->_currentSection['module']; $controller = $this->_currentSection['controller']; switch (true) { case $action = $this->_currentSection['action']: // action явно указан в роутинге break; case $action = $this->getRequest()->getParam('action'): // action указан в URL (?action=:action) break; case $action = $this->getFrontController()->getDefaultAction(): // action по умолчанию break; } $params = ($params = $this->_currentSection['parms']) ? unserialize($params) : $this->getRequest()->getParams(); $params = (array) $params; // в URL можно передавать один параметро вида /param_value.html, он ложится в переменную $this->getRequest()->getParam('main_param') $url = Zend_Controller_Front::getInstance()->getRequest()->getPathInfo(); if (preg_match('|.*/(.*)\\.html|u', $url, $matches)) { $params['main_param'] = $matches[1]; } Zend_Registry::set('main_param', isset($params['main_param']) ? $params['main_param'] : false); $this->_helper->actionStack(System_String::StrToLower($action), System_String::StrToLower($controller), System_String::StrToLower($module), $params); }
/** * Поиск классов с тестами * * @return array */ public function getTestCaseClasses() { $files = $this->_findFiles(); $array = array(); foreach ($files as $file) { $array[System_String::StrToLower(System_Functions::File2Class($file))] = System_Functions::File2Class($file); } return $array; }
/** * Проверка доступа к файлу * * @return bool */ protected function _isAllowed() { $ext = explode('.', basename($this->_needFile)); $ext = System_String::StrToLower(end($ext)); $return = in_array($ext, array('png', 'jpg', 'gif', 'jpeg', 'css', 'ico', 'js', 'swf', 'ttf', 'eot', 'svg', 'woff', 'txt')); if (!$return) { throw new Exception('Access deny ' . $this->_needFile); } return $return; }
protected function _setScriptPath($module) { if ($module) { foreach (Zend_Controller_Front::getInstance()->getControllerDirectory() as $moduleName => $path) { if (System_String::StrToLower($moduleName) == System_String::StrToLower($module)) { $dirs = array(MODULES_PATH . DS . $moduleName, HEAP_PATH . DS . $moduleName); foreach ($dirs as $dir) { Zetta_Controller_Plugin_Layout::addBasePath($dir); } } } } }
public function getFavorites($username) { $data = $this->fetchAll($this->select()->where('username = ?', $username)->order('id')); $allModules = array_merge($this->findModules(), $this->findModulesDeveloper()); $return = array(); foreach ($data as $user_row) { foreach ($allModules as $row) { if (System_String::StrToLower($row['module']) == System_String::StrToLower($user_row['module'])) { $return[] = array_merge(array('id' => $user_row['id']), $row); } } } return System_Functions::toObject($return); }
public function testStrToLower() { $this->assertEquals(System_String::StrToLower('Проверка'), 'проверка'); $this->assertEquals(System_String::StrToLower('ПРОВЕРКА'), 'проверка'); $this->assertEquals(System_String::StrToLower('проверка'), 'проверка'); }
/** * Получаем предустановленные действия для списка "Действие", когда тип маршрута: по умолчанию * * @return array */ public function getDefaultActions($module, $controller) { $return = array(); $controller = HEAP_PATH . '/' . ucfirst($module) . '/App/controllers/' . ucfirst($controller) . 'Controller.php'; require_once $controller; $classes = System_Functions::get_php_classes(file_get_contents($controller)); foreach ($classes as $className) { if (preg_match('/(.+)_(.+)Controller/', $className, $matches)) { $moduleName = System_String::StrToLower($matches[1]); $controllerName = System_String::StrToLower($matches[2]); $class = new ReflectionClass($className); $methods = $class->getMethods(); foreach ($methods as $method) { if ($method->isPublic() && stristr($method->getName(), 'Action') && preg_match('/@description (.*)/', $method->getDocComment(), $matches)) { $return[$moduleName . '~' . $controllerName . '~' . str_replace('Action', '', $method->getName())] = $matches[1]; } } } } return $return; }
/** * Retrieve the module name * * @return string */ public function getModuleName() { return ucfirst(System_String::StrToLower(parent::getModuleName())); }