コード例 #1
0
ファイル: Code.php プロジェクト: vgrish/dvelum
 /**
  * Get JS code for project
  */
 public function projectcodeAction()
 {
     $project = $this->_getProject();
     $projectCfg = $project->getConfig();
     $templates = $this->_config->get('templates');
     $replaces = array(array('tpl' => $templates['wwwroot'], 'value' => $this->_configMain->get('wwwroot')), array('tpl' => $templates['adminpath'], 'value' => $this->_configMain->get('adminPath')), array('tpl' => $templates['urldelimiter'], 'value' => $this->_configMain->get('urlDelimiter')));
     Ext_Code::setRunNamespace($projectCfg['runnamespace']);
     Ext_Code::setNamespace($projectCfg['namespace']);
     Response::jsonSuccess($project->getCode($replaces));
 }
コード例 #2
0
ファイル: Store.php プロジェクト: vgrish/dvelum
 public function __toString()
 {
     $this->_convertFields();
     $this->_convertListeners();
     $fields = array();
     if (!empty($this->_fields)) {
         $this->fields = "[\n" . Utils_String::addIndent(implode(',', array_values($this->_fields))) . "\n]";
     }
     if ($this->_config->isValidProperty('model') && strlen($this->_config->model)) {
         $model = Ext_Code::appendNamespace($this->_config->model);
         $this->_config->model = $model;
     }
     return $this->_config->__toString();
 }
コード例 #3
0
ファイル: Code.php プロジェクト: vgrish/dvelum
 public static function setNamespace($name)
 {
     self::$_namespace = $name;
 }
コード例 #4
0
ファイル: Factory.php プロジェクト: vgrish/dvelum
 /**
  * Gel list of JS files to include
  * (load and render designer project)
  * @param string $cacheKey
  * @param Designer_Project $project
  * @param boolean $selfInclude
  * @param array $replace
  * @return array
  */
 public static function getProjectIncludes($cacheKey, Designer_Project $project, $selfInclude = true, $replace = array())
 {
     $applicationConfig = Registry::get('main', 'config');
     $designerConfig = Config::factory(Config::File_Array, $applicationConfig->get('configs') . 'designer.php');
     $projectConfig = $project->getConfig();
     $includes = array();
     // include langs
     if (isset($projectConfig['langs']) && !empty($projectConfig['langs'])) {
         $language = Lang::getDefaultDictionary();
         $lansPath = $designerConfig->get('langs_path');
         $langsUrl = $designerConfig->get('langs_url');
         foreach ($projectConfig['langs'] as $k => $file) {
             $file = $language . '/' . $file . '.js';
             if (file_exists($lansPath . $file)) {
                 $includes[] = $langsUrl . $file . '?' . filemtime($lansPath . $file);
             }
         }
     }
     if (isset($projectConfig['files']) && !empty($projectConfig['files'])) {
         foreach ($projectConfig['files'] as $file) {
             $ext = File::getExt($file);
             if ($ext === '.js' || $ext === '.css') {
                 $includes[] = $designerConfig->get('js_url') . $file;
             } else {
                 $projectFile = $designerConfig->get('configs') . $file;
                 $subProject = Designer_Factory::loadProject($designerConfig, $projectFile);
                 $projectKey = self::getProjectCacheKey($projectFile);
                 $files = self::getProjectIncludes($projectKey, $subProject, true, $replace);
                 unset($subProject);
                 if (!empty($files)) {
                     $includes = array_merge($includes, $files);
                 }
             }
         }
     }
     Ext_Code::setRunNamespace($projectConfig['runnamespace']);
     Ext_Code::setNamespace($projectConfig['namespace']);
     if ($selfInclude) {
         $layoutCacheFile = Utils::createCachePath($applicationConfig->get('jsCacheSysPath'), $cacheKey . '.js');
         /**
          * @todo remove slow operation
          */
         if (!file_exists($layoutCacheFile)) {
             file_put_contents($layoutCacheFile, Code_Js_Minify::minify($project->getCode($replace)));
         }
         $includes[] = str_replace('./', '/', $layoutCacheFile);
     }
     /*
      * Project actions
      */
     $actionFile = $project->getActionsFile();
     /**
      * @todo slow operation
      */
     $mTime = 0;
     if (file_exists('.' . $actionFile)) {
         $mTime = filemtime('.' . $actionFile);
     }
     $includes[] = $actionFile . '?' . $mTime;
     return $includes;
 }
コード例 #5
0
ファイル: Code.php プロジェクト: vgrish/dvelum
 /**
  * Get object js code for layout
  * @param string $id - object id
  * @return string
  */
 public function getObjectLayoutCode($id)
 {
     $object = $this->_project->getObject($id);
     $oClass = $object->getClass();
     $eventManager = $this->_project->getEventManager();
     $objectEvents = $eventManager->getObjectEvents($id);
     if (!empty($objectEvents)) {
         $eventsConfig = $object->getConfig()->getEvents()->__toArray();
         foreach ($objectEvents as $event => $config) {
             $params = '';
             if (isset($eventsConfig[$event])) {
                 $params = implode(',', array_keys($eventsConfig[$event]));
             }
             if ($event === 'handler') {
                 $object->addListener($event, "function(" . $params . "){\n" . Utils_String::addIndent($config['code'], 2) . "\n}");
             } else {
                 $object->addListener($event, "{\n\t\t\tfn:function(" . $params . "){\n" . Utils_String::addIndent($config['code'], 2) . "\n},\n\t\t\tscope:this\n\t\t}\n");
             }
         }
     }
     /**
      * Convert ActionColumn listeners
      */
     if ($oClass === 'Grid') {
         $this->_applycolumnEvents($object);
         $this->_applyFiltersEvents($object->getFiltersFeature());
     }
     switch ($oClass) {
         case 'Docked':
             return "\n" . Ext_Code::appendRunNamespace($object->getName()) . ' = ' . Utils_String::addIndent($object->__toString(), 1, "\t", true) . ';' . "\n";
             break;
         case 'Component_Filter':
             return "\n" . Ext_Code::appendRunNamespace($object->getName()) . ' = Ext.create("' . $object->getViewObject()->getConfig()->getExtends() . '",' . Utils_String::addIndent($object->__toString()) . "\n" . ');' . "\n";
             break;
         case 'Menu':
             return "\n" . Ext_Code::appendRunNamespace($object->getName()) . ' = ' . Utils_String::addIndent($object->__toString(), 1, "\t", true) . ';' . "\n";
             break;
         default:
             if ($object->isInstance()) {
                 return "\n" . Ext_Code::appendRunNamespace($object->getName()) . ' = Ext.create("' . Ext_Code::appendNamespace($object->getObject()->getName()) . '",' . Utils_String::addIndent($object->__toString()) . "\n" . ');' . "\n";
             } else {
                 if ($object->isExtendedComponent()) {
                     return "\n" . Ext_Code::appendRunNamespace($object->getName()) . ' = Ext.create("' . Ext_Code::appendNamespace($object->getName()) . '",{});' . "\n";
                 } else {
                     return "\n" . Ext_Code::appendRunNamespace($object->getName()) . ' = Ext.create("' . $object->getConfig()->getExtends() . '",' . Utils_String::addIndent($object->__toString()) . "\n" . ');' . "\n";
                 }
             }
             break;
     }
 }
コード例 #6
0
ファイル: Viewframe.php プロジェクト: vgrish/dvelum
    public function indexAction()
    {
        if (!$this->_session->keyExists('loaded') || !$this->_session->get('loaded')) {
            Response::put('');
            exit;
        }
        $designerConfig = Config::factory(Config::File_Array, $this->_configMain['configs'] . 'designer.php');
        $res = Resource::getInstance();
        $res->addJs('/js/lib/jquery.js', 0);
        Model::factory('Medialib')->includeScripts();
        $res->addJs('/js/app/system/SearchPanel.js');
        $res->addJs('/js/app/system/HistoryPanel.js', 0);
        $res->addJs('/js/lib/ext_ux/RowExpander.js', 0);
        $res->addJs('/js/app/system/RevisionPanel.js', 1);
        $res->addJs('/js/app/system/EditWindow.js', 2);
        $res->addJs('/js/app/system/ContentWindow.js', 3);
        $res->addJs('/js/app/system/designer/viewframe/main.js', 4);
        $res->addJs('/js/app/system/designer/lang/' . $designerConfig['lang'] . '.js', 5);
        $project = $this->_getProject();
        $projectCfg = $project->getConfig();
        Ext_Code::setRunNamespace($projectCfg['runnamespace']);
        Ext_Code::setNamespace($projectCfg['namespace']);
        $grids = $project->getGrids();
        if (!empty($grids)) {
            foreach ($grids as $name => $object) {
                if ($object->isInstance()) {
                    continue;
                }
                $cols = $object->getColumns();
                if (!empty($cols)) {
                    foreach ($cols as $column) {
                        $column['data']->itemId = $column['id'];
                    }
                }
                $object->addListener('columnresize', '{
							 fn:function( ct, column, width,eOpts){
								app.application.onGridColumnResize("' . $name . '", ct, column, width, eOpts);
							 }
				}');
                $object->addListener('columnmove', '{
							fn:function(ct, column, fromIdx, toIdx, eOpts){
								app.application.onGridColumnMove("' . $name . '", ct, column, fromIdx, toIdx, eOpts);
							}
				}');
            }
        }
        $dManager = new Dictionary_Manager();
        $key = 'vf_' . md5($dManager->getDataHash() . serialize($project));
        $templates = $designerConfig->get('templates');
        $replaces = array(array('tpl' => $templates['wwwroot'], 'value' => $this->_configMain->get('wwwroot')), array('tpl' => $templates['adminpath'], 'value' => $this->_configMain->get('adminPath')), array('tpl' => $templates['urldelimiter'], 'value' => $this->_configMain->get('urlDelimiter')));
        $includes = Designer_Factory::getProjectIncludes($key, $project, true, $replaces);
        if (!empty($includes)) {
            foreach ($includes as $file) {
                if (File::getExt($file) == '.css') {
                    $res->addCss($file, false);
                } else {
                    $res->addJs($file, false, false);
                }
            }
        }
        $names = $project->getRootPanels();
        $basePaths = array();
        $parts = explode('/', $this->_configMain->get('wwwroot'));
        if (is_array($parts) && !empty($parts)) {
            foreach ($parts as $item) {
                if (!empty($item)) {
                    $basePaths[] = $item;
                }
            }
        }
        $basePaths[] = $this->_configMain['adminPath'];
        $basePaths[] = 'designer';
        $basePaths[] = 'sub';
        //' . $project->getCode($replaces) . '
        $initCode = '
		app.delimiter = "' . $this->_configMain['urlDelimiter'] . '";
		app.admin = "' . $this->_configMain->get('wwwroot') . $this->_configMain->get('adminPath') . '";
		app.wwwRoot = "' . $this->_configMain->get('wwwroot') . '";

		var applicationClassesNamespace = "' . $projectCfg['namespace'] . '";
		var applicationRunNamespace = "' . $projectCfg['runnamespace'] . '";
		var designerUrlPaths = ["' . implode('","', $basePaths) . '"];
		var canDelete = true;
		var canPublish = true;
		var canEdit = true;

		Ext.onReady(function(){
		    app.application.mainUrl = app.createUrl(designerUrlPaths);
            ';
        if (!empty($names)) {
            foreach ($names as $name) {
                if ($project->getObject($name)->isExtendedComponent()) {
                    if ($project->getObject($name)->getConfig()->defineOnly) {
                        continue;
                    }
                    $initCode .= Ext_Code::appendRunNamespace($name) . ' = Ext.create("' . Ext_Code::appendNamespace($name) . '",{});';
                }
                $initCode .= '
			        app.viewFrame.add(' . Ext_Code::appendRunNamespace($name) . ');
			    ';
            }
        }
        $initCode .= '
        	 app.application.fireEvent("projectLoaded");
	   });';
        $res->addInlineJs($initCode);
        $tpl = new Template();
        $tpl->lang = $this->_configMain['language'];
        $tpl->development = $this->_configMain['development'];
        $tpl->resource = $res;
        $tpl->useCSRFToken = Registry::get('backend', 'config')->get('use_csrf_token');
        Response::put($tpl->render(Application::getTemplatesPath() . 'designer/viewframe.php'));
    }