/**
  * Поиск файла в системе
  *
  * @return string	Путь к найденому файлу
  */
 protected function _findFile()
 {
     $requestUri = parse_url($this->getRequest()->getRequestUri());
     $baseUri = $this->getRequest()->getBaseUrl();
     $findFilePath = FILE_PATH . str_ireplace($baseUri, '', urldecode($requestUri['path']));
     preg_match('/(.*)\\/thumbs\\/(.*)_(\\d+)x(\\d+)(_w)?(\\.[a-z]+)$/', $findFilePath, $matches);
     if (sizeof($matches) == 7) {
         $file = $matches[1] . DS . $matches[2] . $matches[6];
         if (false == is_file($file)) {
             throw new Exception('File ' . $file . ' not exists');
         }
         $thumbDir = dirname($findFilePath);
         if (false == is_dir($thumbDir)) {
             mkdir($thumbDir);
             chmod($thumbDir, 0777);
         }
         if ($matches[5] == '_w') {
             System_Functions::createThumbWatermark($file, $findFilePath, intval($matches[3]), intval($matches[4]));
         } else {
             System_Functions::createThumb($file, $findFilePath, intval($matches[3]), intval($matches[4]));
         }
         return $findFilePath;
     }
     return '';
 }
Example #2
0
 public function bootstrap()
 {
     parent::bootstrap();
     if (!System_Functions::tableExist('cron')) {
         $_migrationManager = new Modules_Dbmigrations_Framework_Manager();
         $_migrationManager->upTo('Modules_Cron_Migrations_CreateCronTable');
     }
 }
Example #3
0
 public function bootstrap()
 {
     if (!System_Functions::tableExist('seo')) {
         $_migrationManager = new Modules_Dbmigrations_Framework_Manager();
         $_migrationManager->upTo('Modules_Seo_Migrations_CreateTableSeo');
     }
     parent::bootstrap();
     $this->_registerPlugins();
 }
Example #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;
 }
Example #5
0
 public function bootstrap()
 {
     parent::bootstrap();
     if (!System_Functions::tableExist('publications_list')) {
         $_migrationManager = new Modules_Dbmigrations_Framework_Manager();
         $_migrationManager->upTo('Modules_Publications_Migrations_CreatePublicationListTable');
         $_migrationManager->upTo('Modules_Publications_Migrations_CreatePublicationFieldsTable');
     }
 }
Example #6
0
 public function bootstrap()
 {
     parent::bootstrap();
     if (!System_Functions::tableExist('blocks')) {
         $routerBootstrap = new Modules_Router_Bootstrap();
         $routerBootstrap->bootstrap();
         $_migrationManager = new Modules_Dbmigrations_Framework_Manager();
         $_migrationManager->upTo('Blocks_Migrations_CreateBlocksTable');
     }
     $this->_registerPlugin();
 }
Example #7
0
 public function bootstrap()
 {
     parent::bootstrap();
     if (!System_Functions::tableExist('menu')) {
         $routerBootstrap = new Modules_Router_Bootstrap();
         $routerBootstrap->bootstrap();
         $_migrationManager = new Modules_Dbmigrations_Framework_Manager();
         $_migrationManager->upTo('Modules_Menu_Migrations_CreateMenuTable');
         $_migrationManager->upTo('Modules_Menu_Migrations_CreateItemsTable');
         $_migrationManager->upTo('Modules_Menu_Migrations_AddDefaultMenu');
     }
 }
 public function isValid($value)
 {
     if (Zend_Controller_Front::getInstance()->getRequest()->getParam('rubric_id')) {
         return true;
     }
     // изменение публикации - валидатор пропускаем
     $isValid = true;
     if (System_Functions::tableExist(Modules_Publications_Model_Table::PREFIX_TABLE . $value)) {
         $this->_error(self::ERROR, $value);
         $isValid = false;
     }
     return $isValid;
 }
Example #9
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);
 }
Example #10
0
 public function bootstrap()
 {
     parent::bootstrap();
     if (!System_Functions::tableExist('admin_panel_favorites')) {
         $_migrationManager = new Modules_Dbmigrations_Framework_Manager();
         $_migrationManager->upTo('Modules_Admin_Migrations_CreatePanelFavoritesTable');
     }
     if (Zend_Controller_Front::getInstance()->getRequest()->isXmlHttpRequest()) {
         return false;
     }
     /* регистрируем плагин вывода панели администрирования на frontend */
     if (Zetta_Acl::getInstance()->isAllowed('admin')) {
         Zend_Controller_Front::getInstance()->registerPlugin(new Modules_Admin_Plugin_Panel());
     }
 }
Example #11
0
 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);
 }
Example #12
0
 public function bootstrap()
 {
     parent::bootstrap();
     if (!System_Functions::tableExist('access_users')) {
         $_migrationManager = new Modules_Dbmigrations_Framework_Manager();
         $_migrationManager->upTo('Modules_Access_Migrations_CreateResourceTable');
         $_migrationManager->upTo('Modules_Access_Migrations_CreateRolesTable');
         $_migrationManager->upTo('Modules_Access_Migrations_CreateRulesTable');
         $_migrationManager->upTo('Modules_Access_Migrations_CreateUsersTable');
         $_migrationManager->upTo('Modules_Access_Migrations_SetDefaultResource');
     }
     /* Авторизуем пользователя, теперь везде можем использоваеть Zend_Auth::getInstance() */
     Modules_Access_Framework_Auth::getInstance()->bootstrap();
     /* Расставляем права доступа */
     Modules_Access_Framework_Acl::getInstance()->bootstrap();
 }
Example #13
0
 /**
  * insert с учётом создания таблицы для хранения данных о публикации
  *
  * @param array $data
  * @return int
  */
 public function insert(array $data)
 {
     $rowID = parent::insert($data);
     if ($rowID) {
         /* создаём таблицу для хранения данных */
         $tableName = $data['table_name'];
         if (!System_Functions::tableExist($tableName)) {
             $_migrationManager = new Modules_Dbmigrations_Framework_Manager();
             $_migrationManager->upTo('Modules_Publications_Migrations_CreatePublicationAbstractTable', $tableName, false);
             // Добавляем базовые поля
             $filedsModel = new Modules_Publications_Model_Fields();
             $filedsModel->insert(array('rubric_id' => $rowID, 'name' => 'name', 'title' => 'Название', 'type' => 'text', 'validator' => '.*', 'sort' => 1));
             $filedsModel->insert(array('rubric_id' => $rowID, 'name' => 'active', 'title' => 'активно', 'type' => 'checkbox', 'default' => '1', 'sort' => 2));
         }
     }
     return $rowID;
 }
Example #14
0
 public function init()
 {
     if ($this->getBootstrap()->hasPluginResource('multidb')) {
         $this->getBootstrap()->bootstrap('multidb');
     } else {
         $this->getBootstrap()->bootstrap('Db');
     }
     if ($this->getSaveHandler() instanceof Zend_Session_SaveHandler_DbTable) {
         $options = $this->getOptions();
         if (!System_Functions::tableExist($options['saveHandler']['options']['name'])) {
             $_migrationManager = new Modules_Dbmigrations_Framework_Manager();
             $_migrationManager->upTo('System_Migrations_CreateTableSession');
             $this->init();
         }
     }
     parent::init();
 }
 public function imagesAction()
 {
     $imagePath = USER_FILES_PATH;
     $folders = System_Functions::getFolderFilesRecursive($imagePath . DS . 'images', array('jpg', 'png', 'gif'));
     $result = array();
     foreach ($folders as $filename => $folder) {
         $fileRelative = explode($imagePath, $filename);
         $fileRelative = $fileRelative[1];
         $fileHttpPath = $this->view->baseUrl() . DS . 'UserFiles' . $fileRelative;
         if (strstr($fileHttpPath, 'thumbs')) {
             continue;
         }
         $result[] = array('thumb' => System_Functions::getThumbUrl($fileHttpPath, array(100, 75)), 'image' => $fileHttpPath, 'title' => basename($fileRelative), 'folder' => dirname($fileRelative));
     }
     echo json_encode($result);
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
 }
Example #16
0
 /**
  * Выборка доступных ролей у пользователя в виде дерева
  *
  * @return array()
  */
 public function getAccepdedRolesTree($roles = false)
 {
     $currentRoles = $this->getMyGroup();
     if (!$roles) {
         $roles = $this->_modelRoles->fetchAll()->toArray();
         $roles = System_Functions::toForest($roles, 'name', 'role_parent');
     }
     foreach ($roles as $key => $tree) {
         if ($key == $currentRoles) {
             $return = $tree['childs'];
         } else {
             if (sizeof($tree['childs'])) {
                 $return = $this->getAccepdedRolesTree($tree['childs']);
             }
         }
     }
     return $return;
 }
Example #17
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;
 }
Example #18
0
 public function thumbUrl($path, $sizes = array(200, 100), $watermarked = false)
 {
     return System_Functions::getThumbUrl($path, $sizes, $watermarked);
 }
Example #19
0
 public function testClass2File()
 {
     $this->assertEquals('System/TestCase/Functions.php', System_Functions::Class2File('System_TestCase_Functions'));
 }
 protected function _generateFiles($name, $description)
 {
     $fromFolder = MODULES_PATH . DS . 'Publications' . DS . 'CodeTemplates';
     $toFolder = HEAP_PATH . DS . 'Publications' . DS . 'App';
     $toController = $toFolder . DS . 'controllers' . DS . ucfirst($name) . 'Controller.php';
     $toViewFolder = $toFolder . DS . 'views' . DS . 'scripts' . DS . $name;
     // копируем контроллер
     System_Functions::Copy($fromFolder . DS . 'BaseController.php', $toController);
     // копируем view скрипты
     System_Functions::Copy($fromFolder . DS . 'views', $toFolder . DS . 'views' . DS . 'scripts' . DS . $name);
     $files = glob($toViewFolder . DS . '*.*');
     $files[] = $toController;
     foreach ($files as $file) {
         $content = file_get_contents($file);
         $content = str_replace('{base}', $name, $content);
         $content = str_replace('{Base}', ucfirst($name), $content);
         $content = str_replace('{description}', $description, $content);
         file_put_contents($file, $content);
     }
 }
Example #21
0
 /**
  * Чистим старые бекапы (срок хранения 15 дней)
  *
  * @return Modules_Service_Model_Backup
  */
 protected function _cleanOldBackups()
 {
     $backups = glob($this->_backupsDir . '/*', GLOB_ONLYDIR);
     foreach ($backups as $dir) {
         if (time() - 15 * 24 * 3600 >= filemtime($dir)) {
             System_Functions::unlinkDir($dir);
         }
     }
     return $this;
 }
Example #22
0
 /**
  * Получаем дерево разделов определённого меню
  *
  * @param int $menuId
  * @return array
  */
 public function getMenuTree($menuId)
 {
     $menu = $this->getMenu($menuId);
     if (!sizeof($menu)) {
         return array();
     }
     $sections = $this->_modelItems->fetchAll($this->_modelItems->select()->where('menu_id = ?', $menu->menu_id)->order('sort', 'item_id'));
     if ($menu->type == 'router') {
         $routerTree = Modules_Router_Model_Router::getInstance()->getItem($menu->parent_route_id);
         $_makeTreeFromRouter = function ($routerTree, $sections, $parentDisable) use(&$_makeTreeFromRouter) {
             $return = array();
             foreach ($routerTree as $i => $row) {
                 if (1 == $row['disable']) {
                     continue;
                 }
                 $return[$i] = $row;
                 $return[$i]['type'] = 'from_router';
                 $return[$i]['item_id'] = $row['route_id'];
                 $return[$i]['parent_id'] = $row['parent_route_id'];
                 $return[$i]['disable'] = $parentDisable;
                 unset($return[$i]['route_id'], $return[$i]['parent_route_id'], $return[$i]['childs']);
                 if (sizeof($sections)) {
                     foreach ($sections as $item) {
                         if ($item->route_id == $row['route_id']) {
                             $return[$i]['disable'] = $item->disable || $parentDisable;
                             $return[$i]['name'] = $item->name ? $item->name : $row['name'];
                         }
                     }
                 }
                 $return[$i]['childs'] = $_makeTreeFromRouter($row['childs'], $sections, $return[$i]['disable']);
             }
             return $return;
         };
         $sections = $_makeTreeFromRouter($routerTree['childs'], $sections, false);
     } else {
         $_makeUrl = function ($sections) use(&$_makeUrl) {
             $return = array();
             foreach ($sections as $i => $item) {
                 $return[$i] = $item;
                 if ($item['external_link']) {
                     $return[$i]['url'] = $item['external_link'];
                 } else {
                     $return[$i] += Modules_Router_Model_Router::getInstance()->getItem($item['route_id']);
                 }
                 $return[$i]['childs'] = $_makeUrl($item['childs']);
             }
             return $return;
         };
         $sections = System_Functions::toForest($sections->toArray(), 'item_id', 'parent_id');
         $sections = $_makeUrl($sections);
     }
     $this->_setCurrents($sections);
     return $sections;
 }