public function __construct() { $this->_configMain = Registry::get('main', 'config'); $this->_lang = Lang::lang(); $this->_db = Application::getDbConnection(); $this->_config = Config::factory(Config::File_Array, $this->_configMain['configs'] . 'designer.php'); $this->_session = Store_Session::getInstance('Designer'); $this->_storage = Designer_Storage::getInstance($this->_config->get('storage'), $this->_config); }
/** * Create new report */ public function fsmakefileAction() { $name = Request::post('name', 'string', ''); $path = Request::post('path', 'string', ''); if (!strlen($name)) { Response::jsonError($this->_lang->WRONG_REQUEST . ' [code 1]'); } $configsPath = $this->_config->get('configs'); $actionsPath = $this->_config->get('actionjs_path'); if (strlen($path)) { $savePath = $path . DIRECTORY_SEPARATOR . $name . '.designer.dat'; $actionFilePath = $actionsPath . str_replace($configsPath, '', $path) . DIRECTORY_SEPARATOR . $name . '.js'; } else { $savePath = $configsPath . $name . '.designer.dat'; $actionFilePath = $actionsPath . $name . '.js'; } if (file_exists($savePath)) { Response::jsonError($this->_lang->FILE_EXISTS); } $obj = new Designer_Project(); $obj->actionjs = $actionFilePath; if ($this->_storage->save($savePath, $obj)) { Response::jsonSuccess(array('file' => $savePath)); } else { Response::jsonError($this->_lang->CANT_WRITE_FS . ' ' . $savePath); } }
/** * Scan files and create class map for autoloader * @param array $startPaths - paths for scan (relative paths) * @param string $mapFile - output php file path * @param string $mapPackagesFile - output php file path (with packages) * @param Config_File_Array - $packagesConfig * @return boolean */ public static function createClassMap(array $startPaths, $mapFile, $mapPackagesFile, Config_File_Array $packagesConfig) { $packages = $packagesConfig->get('packages'); $packPath = $packagesConfig->get('path'); $packMap = array(); if (!empty($packages)) { foreach ($packages as $key => $items) { if (!empty($items)) { foreach ($items['paths'] as $index => $path) { $packMap[$path] = $key; } } } } $map = array(); $mapPackaged = array(); foreach ($startPaths as $v) { self::_scanClassDir($v, $map, $mapPackaged, $v, $packMap, $packagesConfig); } ksort($map); ksort($packMap); $res1 = @file_put_contents($mapFile, '<?php return ' . var_export($map, true) . '; '); $vars = ''; $varNames = array(); $varValues = array(); foreach ($packagesConfig->get('packages') as $key => $item) { if (!$item['active']) { continue; } $varName = '$_pkg_' . $key; $packPath = $packagesConfig->get('path') . $key . '.php'; $vars .= $varName . " ='" . $packPath . "';\n"; $varNames[] = $varName; $varValues[] = "'" . $packPath . "'"; } $s = str_replace($varValues, $varNames, var_export($mapPackaged, true)) . ';'; $res2 = @file_put_contents($mapPackagesFile, '<?php ' . "\n" . $vars . ' return ' . $s); if ($res1 && $res2) { return true; } else { return false; } }
/** * Compilation of Layout Designer code * System method used by platform developers */ public function compileAction() { if (!$this->_config->get('development')) { die('Use development mode'); } $s = ''; $totalSize = 0; foreach (self::$_scripts as $filePath) { $s .= file_get_contents('.' . $filePath) . "\n"; $totalSize += filesize('.' . $filePath); } $time = microtime(true); file_put_contents('.' . $this->_config->get('compiled_js'), Code_Js_Minify::minify($s)); echo ' Compilation time: ' . number_format(microtime(true) - $time, 5) . ' sec<br> Files compiled: ' . sizeof(self::$_scripts) . ' <br> Total size: ' . Utils::formatFileSize($totalSize) . '<br> Compiled File size: ' . Utils::formatFileSize(filesize('.' . $this->_config->get('compiled_js'))) . ' <br> '; exit; }
public function fieldslistAction() { $connectionId = Request::post('connId', 'integer', false); $table = Request::post('table', 'string', false); if ($connectionId === false || !$table) { Response::jsonError($this->_lang->WRONG_REQUEST); } $config = $this->_connConfig->get($connectionId); $config = array('username' => $config['user'], 'password' => $config['pass'], 'dbname' => $config['base'], 'host' => $config['host'], 'charset' => 'UTF8'); try { $db = Zend_Db::factory('Mysqli', $config); } catch (Exception $e) { Response::jsonError($this->_lang->CANT_CONNECT); } $data = array(); $desc = $db->describeTable($table); foreach ($desc as $v => $k) { $data[] = array('name' => $v, 'type' => $k['DATA_TYPE']); } Response::jsonSuccess($data); }
/** * Rebuild all packages */ public function rebuildallAction() { $this->_checkCanEdit(); $dest = $this->_packagesConfig->get('path'); /* * Returning a reference from a function */ $data =& $this->_packagesConfig->dataLink(); if ($this->_packagesConfig->get('all_in_one')) { $s = ''; foreach ($data['packages'] as $item) { if (!$item['active']) { continue; } $s .= $this->_compilePackage($item); } Utils::exportCode($dest . $this->_packagesConfig->get('main_package') . '.php', $s); } else { foreach ($data['packages'] as $name => $item) { $s = $this->_compilePackage($item); $data['packages'][$name]['checksum'] = md5($s); if (Utils::exportCode($dest . $name . '.php', $s) === false) { Response::jsonError($this->_lang->CANT_WRITE_FS); } $data['packages'][$name]['fchecksum'] = md5_file($dest . $name . '.php'); } } if ($this->buildmapAction() === false) { Response::jsonError($this->_lang->CANT_WRITE_FS); } if (!$this->_packagesConfig->save()) { Response::jsonError($this->_lang->CANT_WRITE_FS); } else { Response::jsonSuccess(); } }