示例#1
0
 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);
 }
示例#2
0
 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);
 }
示例#4
0
 /**
  * Поиск классов с тестами
  *
  * @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;
 }
示例#5
0
 /**
  * Проверка доступа к файлу
  *
  * @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;
 }
示例#6
0
 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);
                 }
             }
         }
     }
 }
示例#7
0
 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 fileuploadAction()
 {
     $dir = USER_FILES_PATH . DS . 'files' . DS;
     $name = explode('.', $_FILES['file']['name']);
     $ext = '.' . $name[sizeof($name) - 1];
     $fileName = str_replace($ext, '', $_FILES['file']['name']);
     $filename = System_String::translit($fileName) . date('_Hms') . $ext;
     $file = $dir . $filename;
     move_uploaded_file($_FILES['file']['tmp_name'], $file);
     chmod($file, 0777);
     echo json_encode(array('filelink' => $this->view->baseUrl() . DS . 'UserFiles/files' . DS . $filename, 'filename' => basename($file)));
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
 }
示例#9
0
 public function testStrToUpper()
 {
     $this->assertEquals(System_String::StrToUpper('Проверка'), 'ПРОВЕРКА');
     $this->assertEquals(System_String::StrToUpper('ПРОВЕРКА'), 'ПРОВЕРКА');
     $this->assertEquals(System_String::StrToUpper('проверка'), 'ПРОВЕРКА');
 }
示例#10
0
 protected function _unserialize($string)
 {
     if (!is_string($string)) {
         return false;
     }
     $string = System_String::Substr($string, 1, -1);
     return explode('÷', $string);
 }
示例#11
0
 /**
  * Получаем предустановленные действия для списка "Действие", когда тип маршрута: по умолчанию
  *
  * @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;
 }
示例#12
0
 /**
  * Retrieve the module name
  *
  * @return string
  */
 public function getModuleName()
 {
     return ucfirst(System_String::StrToLower(parent::getModuleName()));
 }