コード例 #1
0
 public function init()
 {
     $this->_modelRoutes = Modules_Router_Model_Router::getInstance();
     $this->_currentSection = $this->_modelRoutes->current();
     $this->_helper->viewRenderer->setNoRender();
     $this->view->current_route = $this->_currentSection;
     if ($this->_currentSection) {
         Zend_Registry::set('current_route', (object) $this->_currentSection);
     }
     $this->view->headTitle($this->_currentSection['name']);
     if (!$this->_currentSection || 1 == $this->_currentSection['disable'] || !Zetta_Acl::getInstance()->isAllowed('route_' . $this->_currentSection['route_id'], 'allow')) {
         return $this->_forwardTo404();
     }
     $this->_forwardToMVC();
 }
コード例 #2
0
ファイル: Url.php プロジェクト: kytvi2p/ZettaFramework
 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);
 }
コード例 #3
0
ファイル: Table.php プロジェクト: kytvi2p/ZettaFramework
 /**
  * Все таблицы для хранения данных имеют префикс
  *
  */
 protected function _setup()
 {
     parent::_setup();
     $this->_cleanName = $this->_name;
     $this->_name = self::PREFIX_TABLE . $this->_name;
     if (false == array_key_exists($this->_cleanName, self::$setupedTables)) {
         $modelFields = new Modules_Publications_Model_Fields();
         $this->_tableProfile = $modelFields->fetchAllByTableName($this->_cleanName);
         foreach ($this->_tableProfile as $row) {
             if ($row->list_values) {
                 if (false == array_key_exists($row->list_values, self::$linkedData)) {
                     if ('routes' == $row->list_values) {
                         self::$linkedData[$row->list_values] = Modules_Router_Model_Router::getInstance()->getRoutesTreeHash();
                     } else {
                         $model = new self($row->list_values);
                         self::$linkedData[$row->list_values] = $model->fetchAll()->toArray();
                     }
                 }
                 self::$linkedFieldsTableData[$this->_cleanName . '_' . $row->name] = self::$linkedData[$row->list_values];
             }
         }
         self::$setupedTables[$this->_cleanName] = $this->_tableProfile;
     } else {
         $this->_tableProfile = self::$setupedTables[$this->_cleanName];
     }
 }
コード例 #4
0
ファイル: Blocks.php プロジェクト: kytvi2p/ZettaFramework
 public function __construct($config = array(), $definition = null)
 {
     parent::__construct($config, $definition);
     $currentRoute = Modules_Router_Model_Router::getInstance()->current();
     $this->_currentRouteId = $currentRoute['route_id'];
     $this->_fetchBlocks();
 }
コード例 #5
0
ファイル: Breadcrumb.php プロジェクト: kytvi2p/ZettaFramework
 public function breadcrumb()
 {
     $modelRouter = Modules_Router_Model_Router::getInstance();
     $currentRoute = $modelRouter->current();
     $parentsId = array_reverse($modelRouter->getParentsId($currentRoute['route_id']));
     $return = '';
     foreach ($parentsId as $parent) {
         $item = $modelRouter->getItem($parent);
         $return .= '<a href="' . $this->view->url(array('route_id' => $item['route_id'])) . '">' . $this->view->escape($item['name']) . '</a>';
     }
     return $return . '<span>' . $currentRoute['name'] . '</span>';
 }
コード例 #6
0
ファイル: Form.php プロジェクト: kytvi2p/ZettaFramework
 public function addElement($element, $name = null, $options = null)
 {
     switch ($element) {
         case 'html':
             $element = 'textarea';
             break;
         case 'file_dialog':
             $element = 'text';
             $options['z_image_dialog'] = 1;
             break;
         case 'date':
             $element = 'text';
             $options['z_date'] = 1;
             break;
         case 'datetime':
             $element = 'text';
             $options['z_date_time'] = 1;
             break;
         case 'captcha':
             // throw new Exception('Мы ещё не подключили этот тип поля');
             $options['captcha'] = array('captcha' => 'Image', 'font' => SYSTEM_PATH . '/public/font/captcha_font.ttf', 'imgDir' => TEMP_PATH . DS . 'Captcha', 'imgUrl' => HTTP_HOST . '/Temp/Captcha/', 'wordLen' => 5, 'lineNoiseLevel' => 2, 'dotNoiseLevel' => 50);
             break;
         case 'route':
             $element = 'select';
             $options['list_values'] = 'routes';
             break;
     }
     if (array_key_exists('default', $options) && $options['default']) {
         $options['value'] = $options['default'];
     }
     if (array_key_exists('title', $options) && $options['title']) {
         $options['label'] = $options['title'];
     }
     $elementObject = parent::addElement($element, $name, $options);
     if (array_key_exists('list_values', $options) && $options['list_values']) {
         switch ($element) {
             case 'multiCheckbox':
             case 'radio':
             case 'select':
                 if ('routes' == $options['list_values']) {
                     $this->getElement($name)->addMultiOptions(Modules_Router_Model_Router::getInstance()->getRoutesTreeHash());
                 } else {
                     $model = new Modules_Publications_Model_Table($options['list_values']);
                     $options = $model->getAssocArray('publication_id', 'name');
                     $this->getElement($name)->addMultiOptions($options);
                 }
                 break;
         }
     }
     return $elementObject;
 }
コード例 #7
0
ファイル: Bootstrap.php プロジェクト: kytvi2p/ZettaFramework
 public function bootstrap()
 {
     parent::bootstrap();
     if (!System_Functions::tableExist('routes')) {
         $_migrationManager = new Modules_Dbmigrations_Framework_Manager();
         $_migrationManager->upTo('Modules_Router_Migrations_CreateRoutesTable');
         $_migrationManager->upTo('Modules_Router_Migrations_AddDefaultRoutes');
     }
     $router = Zend_Controller_Front::getInstance()->getRouter();
     $router->addConfig(Zend_Registry::get('config')->Router, 'routes');
     Zend_Registry::set('Router', Modules_Router_Model_Router::getInstance());
     $currentRoute = Modules_Router_Model_Router::getInstance()->current();
     Zend_Registry::set('RouteCurrent', $currentRoute);
     Zend_Registry::set('RouteCurrentId', $currentRoute['route_id']);
     defined('ZETTA_FRONT') || define('ZETTA_FRONT', $currentRoute['route_id'] ? true : false);
 }
コード例 #8
0
ファイル: Uri.php プロジェクト: kytvi2p/ZettaFramework
 public function isValid($value)
 {
     if (Zend_Controller_Front::getInstance()->getRequest()->getParam('route_id')) {
         return true;
     }
     $this->_setValue($value);
     $isValid = true;
     $model = Modules_Router_Model_Router::getInstance();
     $sql = $model->select()->where('uri = ?', $value)->where('parent_route_id = ?', $_REQUEST['parent_route_id']);
     $data = $model->fetchRow($sql);
     if (sizeof($data)) {
         $this->_error(self::ERROR);
         $isValid = false;
     }
     return $isValid;
 }
コード例 #9
0
 public function addAction()
 {
     $form = new Zetta_Form(Zend_Registry::get('config')->Access->form->resource);
     $routes = Modules_Router_Model_Router::getInstance()->getRoutesTreeHash();
     $menuIdElement = $form->getElement('route_id');
     $menuIdElement->addMultiOptions($routes);
     if ($resource_id = $this->getParam('resource')) {
         $resource = $this->_modelResources->getResource($resource_id)->toArray();
         $resource['type'] = 'free';
         if (preg_match('/route_(\\d*)/', $resource['resource_name'], $matches)) {
             $resource['route_id'] = $matches[1];
             $resource['type'] = 'router';
         }
         $this->view->resource = $resource;
         $form->setDefaults($resource);
         $form->getElement('type')->setAttrib('disabled', 'disabled');
         $form->getElement('resource_name')->setAttrib('disabled', 'disabled');
     }
     if (!sizeof($_POST) || !$form->isValid($_POST)) {
         $this->view->form = $form;
     } else {
         if ($form->getValue('type') == 'router') {
             $arrayData = array('resource_name' => $resource_name = 'route_' . $form->getValue('route_id'), 'description' => 'Ограничение доступа к разделу "' . trim($routes[$form->getValue('route_id')], '- ') . '"');
         } else {
             $arrayData = array('resource_name' => $resource_name = $form->getValue('resource_name'), 'description' => $form->getValue('description'));
         }
         if (!$arrayData['resource_name'] || !$arrayData['description']) {
             // проверка, чтобы не добавлялись пустые привелегии
             return $this->renderScript('admin/addComplete.ajax.phtml');
         }
         if ($resource_id) {
             $this->_modelResources->update($arrayData, $this->_modelResources->getAdapter()->quoteInto('resource_name = ?', $resource_id));
         } else {
             $this->_modelResources->insert($arrayData);
             // дадим доступ администраторам по умолчанию
             $this->_modelRules->addRule($resource_name, 'admin', 'allow');
         }
         $this->renderScript('admin/addComplete.ajax.phtml');
     }
 }
コード例 #10
0
 public function addsectionAction()
 {
     $menu = $this->_modelMenu->getMenu($this->getParam('menu_id'));
     $this->view->menu_id = $menu->menu_id;
     if ('router' == $menu->type) {
         $form = new Zetta_Form(Zend_Registry::get('config')->Menu->formSectionRouter);
         $item_id = $this->view->item_id = $this->getParam('item_id');
         $editRouteData = $this->_modelMenu->getSection($item_id, $menu->menu_id);
         $form->setDefaults($editRouteData);
         if (!sizeof($_POST) || !$form->isValid($_POST)) {
             $this->view->form = $form;
         } else {
             if ((!$form->getValue('name') || $form->getValue('name') == $editRouteData['name_route']) && intval($form->getValue('disable')) == 0) {
                 $this->_modelMenu->deleteItem($editRouteData['item_id']);
             } else {
                 $arrayData = array('menu_id' => $menu->menu_id, 'parent_id' => $pId = intval($form->getValue('parent_id')) ? $pId : new Zend_Db_Expr('NULL'), 'name' => !$form->getValue('name') || $form->getValue('name') == $editRouteData['name_route'] ? new Zend_Db_Expr('NULL') : $form->getValue('name'), 'type' => 'router', 'disable' => intval($form->getValue('disable')), 'route_id' => $item_id);
                 if (array_key_exists('item_id', $editRouteData) && $editRouteData['item_id'] != $item_id) {
                     $this->_modelMenu->updateSection($arrayData, $this->_modelMenu->getAdapter()->quoteInto('item_id = ?', $editRouteData['item_id']));
                 } else {
                     $this->_modelMenu->insertSection($arrayData);
                 }
             }
             $this->renderScript('admin/addItemComplete.ajax.phtml');
         }
     } else {
         $form = new Zetta_Form(Zend_Registry::get('config')->Menu->formSection);
         $menuIdElement = $form->getElement('route_id');
         $menuIdElement->addMultiOptions(Modules_Router_Model_Router::getInstance()->getRoutesTreeHash());
         $arrayParents = array('0' => '') + $this->_modelMenu->getTreeHash($menu->menu_id);
         $parentIdElement = $form->getElement('parent_id');
         $parentIdElement->addMultiOptions($arrayParents);
         if ($pId = $this->getParam('parent_id')) {
             $parentIdElement->setValue($pId);
         }
         if ($item_id = $this->getParam('item_id')) {
             $this->view->item_id = $item_id;
             $editRouteData = $this->_modelMenu->getSection($item_id, $menu->menu_id);
             $form->setDefaults($editRouteData);
         }
         if (!sizeof($_POST) || !$form->isValid($_POST)) {
             $this->view->form = $form;
         } else {
             $arrayData = array('menu_id' => intval($this->getParam('menu_id')), 'parent_id' => ($pId = intval($form->getValue('parent_id'))) ? $pId : new Zend_Db_Expr('NULL'), 'name' => $form->getValue('name'), 'type' => $form->getValue('type_section'), 'disable' => intval($form->getValue('disable')), 'route_id' => new Zend_Db_Expr('NULL'), 'external_link' => new Zend_Db_Expr('NULL'));
             if ($arrayData['type'] == 'router') {
                 $arrayData['route_id'] = intval($form->getValue('route_id'));
             } else {
                 $arrayData['external_link'] = $form->getValue('external_link');
             }
             if ($item_id) {
                 $this->_modelMenu->updateSection($arrayData, $this->_modelMenu->getAdapter()->quoteInto('item_id = ?', $item_id));
             } else {
                 $this->_modelMenu->insertSection($arrayData);
             }
             $this->renderScript('admin/addItemComplete.ajax.phtml');
         }
     }
 }
コード例 #11
0
 /**
  * Просмотр добавленных публикаций
  *
  * @param int $_REQUEST['rubric_id']		ID рубрики в которую добавлены материалы
  */
 public function viewAction()
 {
     if (!$this->_rubric) {
         throw new Exception('rubric_id не определён');
     }
     $this->_modelPublications->setRouteId($this->getParam('route_id'));
     $this->view->publications = $this->_modelPublications->fetchAll($this->_modelPublications->select()->order('sort'));
     $this->view->route_id = $this->getParam('route_id');
     $this->view->route = Modules_Router_Model_Router::getInstance()->getItem($this->getParam('route_id'));
     try {
         // пробуем подключить пользовательский шаблон
         $this->renderScript('admin/view_' . $this->_rubric->rubric_id . '.ajax.phtml');
     } catch (Exception $e) {
     }
 }
コード例 #12
0
 public function up($params = null)
 {
     $model = new Modules_Router_Model_Router();
     $model->insert(array('route_id' => 1, 'name' => 'Главная страница', 'uri' => '', 'module' => 'default', 'controller' => 'index'));
     $model->insert(array('route_id' => 2, 'parent_route_id' => 1, 'name' => 'Вход', 'uri' => 'login', 'module' => 'access', 'controller' => 'login'));
 }
コード例 #13
0
ファイル: Menu.php プロジェクト: kytvi2p/ZettaFramework
 protected function _setCurrents(&$tree)
 {
     if (sizeof($this->_parents) == 0) {
         $router = Modules_Router_Model_Router::getInstance();
         $current = $router->current();
         if ($current) {
             $this->_parents = $router->getParentsId($current['route_id']);
         }
     }
     $currentUrl = Zend_Controller_Front::getInstance()->getRequest()->getPathInfo();
     preg_match('|(.*/)(.*\\.html)?|', $currentUrl, $matches);
     // отрубаем *.html от пути
     if (sizeof($tree)) {
         foreach ($tree as &$row) {
             if ($row['type'] == 'router' && in_array($row['route_id'], $this->_parents)) {
                 $row['current'] = true;
                 return true;
             } else {
                 if (sizeof($matches) > 1 && $row['url'] == $matches[1]) {
                     $row['current'] = true;
                     return true;
                 } else {
                     $row['current'] = $this->_setCurrents($row['childs']);
                 }
             }
         }
     }
     return false;
 }
コード例 #14
0
 public function getmoduleactionsAction()
 {
     if ($this->getRequest()->isPost() && $this->getParam('_module') && $this->getParam('_controller')) {
         $this->view->actions = $this->_modelRoutes->getDefaultActions($this->getParam('_module'), $this->getParam('_controller'));
     }
 }
コード例 #15
0
ファイル: Router.php プロジェクト: kytvi2p/ZettaFramework
 public static function resetInstance()
 {
     self::$_instance = new self();
 }