function render() { $this->view->headLink()->appendStylesheet('/css/express-table/style.css'); $formGroups = $this->_config->getFormGroups(); // print_r($formGroups); ?> <div style="text-align: center; width: 100%; padding-left: 20px" align="center" > <table class="statistics " style="width: 90%"> <?php $index = 0; foreach ($formGroups as $groups) { ?> <tr><th style="height: 5px"><?php echo $groups['label']; ?> </th></tr> <tr><td> <table class="hor-minimalist-b" style="width: 95%"> <?php foreach ($this->_config->getFormGroupElements(null, $index) as $elementid) { $prop = $this->_config->getPropByName($elementid); ?> <tr> <td style="text-align: left; width: 20%; max-width: 200px;text-transform: capitalize;font-weight: bold;;" ><?php echo $this->view->translate($prop->label); ?> </td> <td style="width: 10px"> : </td> <td style="text-align: left;" ><?php echo $this->_model->{$elementid}; ?> </td> </tr> <?php } ?> </table> </td></tr> <?php $index += 1; } ?> </table></div> <?php }
function loadFormXmlAction() { $nameSpace = new Sys_Model_Namespace(); $nameSpaces = $nameSpace->fetchAll(); foreach ($nameSpaces as $nameSpacObj) { $nameSpac = strtolower($nameSpacObj->namespace); $config = App_Model_Config::loadXml($nameSpac); foreach ($config->classes as $name => $modelconfig) { $entity = new Sys_Model_Entity(); $entity = $entity->fetchRow("model_name='{$name}'"); $id = $entity->id; foreach ($modelconfig->prop as $prop) { $ln = new Sys_Model_Entity_Property(); $ln->modelId = $id; $ln->name = $prop->name; $ln->column = $prop->column; $ln->label = $prop->label; $ln->sqltype = $prop->sqltype; $ln->varType = $prop->varType; $ln->input = $prop->input; $ln->isRequired = $prop->required == 'true' ? 1 : 0; $ln->isPk = $prop->pk == 'true' ? 1 : 0; $ln->isAutoincrement = $prop->autoincrement == 'true' ? 1 : 0; $ln->style = $prop->style; $ln->isReadonly = $prop->readonly == 'true' ? 1 : 0; $ln->isEnabled = $prop->enabled == 'true' ? 1 : 0; $ln->cssClass = $prop->class; $ln->save(); } } } $this->_helper->redirector('index'); $this->render('blank', null, true); }
function getHendleScript() { $scriptAffterRender = App_Model_Config::get(get_class($this->getModel()))->getFormScript(); $formId = $this->getFormId(); $formId2 = str_replace("-", "", $formId); $output = "\n \n \t\t\t\$('form#{$formId} legend ').css('color','#0088B5');\n \$('form#{$formId} div:first').before('<div style=\"text-align: right; height:22;\" colspan=\"2\" ><font color=\"red\" size=\"2\">*</font>Required Fields</div>');\n \t\t\t\$('form#{$formId} label.required').append(\"<font color='red' size='2'>*</font> :\");\n \t\t\t\$('form#{$formId} label.optional').append(' :');\n \t\t\t\n \t\t\t \$('form#{$formId} input, #{$formId} textarea, #{$formId} select').each(function(){ "; $output .= "\t if( \$.trim(\$(this).attr('alt')) !='' ){ \$(this).after( ' '+ \$(this).attr('alt') ) } \t\t \n });\n \t\t\t\n //\$('form#{$formId} fieldset' ).css({'background-image':'/css/tabs/tabright7.gif','background-repeat':'repeat-x'}); \n \$('form#{$formId} fieldset:last' ).after('<fieldset id=\"queryboxfooter\" class=\"tblFooters\" style=\" background:#F4F7FB \"> </fieldset>');\n \n var {$formId2}btns = new Array();\n\n \n \t\t\t\t\n \t\t\t\t\$(\"form#{$formId} input[type='hidden']\").each(function(){\n\t // \$(this).parent().hide();\n\t \$('#'+\$(this).attr('name')+'-label').hide();\n\t \$('#'+\$(this).attr('name')+'-element').hide();\n });\n \n \t\t \$('form#{$formId}').validate();\n \t\t\t\n \n \n function scriptAffterRender( form ){\n {$scriptAffterRender}\n }\n scriptAffterRender( \$('form#{$formId}') )\n "; return $output; }
function loadFormXmlAction() { ini_set('max_execution_time', 0); $nameSpace = new Sys_Model_Namespace(); $nameSpaces = $nameSpace->fetchAll(); foreach ($nameSpaces as $nameSpacObj) { $nameSpac = strtolower($nameSpacObj->namespace); $config = App_Model_Config::loadXml($nameSpac); $ordering = 0; foreach ($config->classes as $name => $modelconfig) { $entity = new Sys_Model_Entity(); $entity = $entity->fetchRow("model_name='{$name}'"); $id = trim($entity->id); if ($id != '') { $ln = new Sys_Model_Form(); $datagridid = $ln->formName = $name . "_Form_Default"; $ln->cssClass = 'form'; $ln->renderer = 'default'; $ln->modelId = $id; $ln->fometype = 'default'; $ln->description = ''; $ln->save(); foreach ($modelconfig->prop as $prop) { $gp = new Sys_model_Form_Field(); $gp->fieldid = $datagridid . "_" . $prop->name; $gp->fieldName = $prop->name; $gp->formId = $datagridid; $gp->fieldName = $prop->name; $gp->label = $prop->name; $gp->vartype = ''; $gp->inputtype = ''; $gp->cssClass = ''; $gp->required = 0; $gp->multiOptions = ''; $gp->refModel = ''; $gp->refFkField = ''; $gp->refLabelField = ''; $gp->suffix = ''; $gp->description = ''; $gp->ordering = ++$ordering; $gp->save(); } } } } $this->_helper->redirector('index'); $this->render('blank', null, true); }
function loadFromModelAction() { $config = App_Model_Config::loadXml('sdc'); //print_r($modelconfig); foreach ($config->classes as $modelconfig) { foreach ($modelconfig->prop as $prop) { $key = $prop->name; $value = $prop->label; $ln = new Sys_Model_Translation(); $ln->setKey($key); $ln->setEn($value); $ln->save(); } } $this->render('blank', null, true); }
function loadFromModelAction() { $config = App_Model_Config::loadXml('eau'); //$package = arrar(); foreach ($config->classes as $modelconfig) { foreach ($modelconfig->prop as $prop) { $key = $prop->name; $value = $prop->label; $ln = new Sys_Model_Translation(); $ln->setKey($key); $ln->setEn($value); $ln->save(); } } $this->_helper->redirector('index'); $this->render('blank', null, true); }
function loadFormXmlAction() { ini_set('max_execution_time', 0); $nameSpace = new Sys_Model_Namespace(); $nameSpaces = $nameSpace->fetchAll(); foreach ($nameSpaces as $nameSpacObj) { $nameSpac = strtolower($nameSpacObj->namespace); $config = App_Model_Config::loadXml($nameSpac); $ordering = 0; foreach ($config->classes as $name => $modelconfig) { $entity = new Sys_Model_Entity(); $entity = $entity->fetchRow("model_name='{$name}'"); $id = trim($entity->id); if ($id != '') { $ln = new Sys_Model_Datagrid(); $ln->modelId = $id; $datagridid = $ln->gridname = $name . "_Grid_Default"; $ln->cssClass = 'default'; $ln->width = '100%'; $ln->renderer = 'Table'; $ln->sperate = ''; $ln->sql = ''; $ln->save(); foreach ($modelconfig->prop as $prop) { //echo $prop->name; $gp = new Sys_Model_Datagrid_Fields(); $gp->id = $datagridid . "_" . $prop->name; $gp->datagridId = $datagridid; $gp->fieldName = $prop->name; $gp->show = '1'; $gp->ref = ''; $gp->width = ''; $gp->class = 'col'; $gp->align = 'left'; $gp->ordering = ++$ordering; $gp->save(); } } } } // $this->_helper->redirector('index'); $this->render('blank', null, true); }
public function saveAction() { $this->_helper->layout()->setLayout("nolayout"); $modelname = $this->_request->getParam("model", 'Eau_Model_Company'); $suffixname = "model-config.xml"; $modelnameAr = explode("_", $modelname); $packet = strtolower($modelnameAr[0]); $configfile = $packet . "-" . $suffixname; $config = new Zend_Config_Xml(CONFIG_PATH . "{$configfile}", null, true); $allfield = array(); $arrayKey = array(); $i = 0; foreach (App_Model_Config::get($modelname)->getProperties() as $element) { $allfield[] = $element->name; $arrayKey[$element->name] = $i++; } $config->production->classes->{$modelname}->text = "2"; $props = $config->production->classes->{$modelname}->prop->toArray(); foreach ($_POST as $key => $value) { list($field, $property) = explode("_", $key); if (in_array($field, $allfield)) { $index = $arrayKey[$field]; foreach ($props as $key => $prop) { if ($prop['name'] == $field) { $props[$key][$property] = $value; //$config->classes->{$modelname}->props->$field->$property = $value; } //echo $prop->name,"<br/>"; } //$config->classes->{$modelname}->prop->$property = $value; } } $config->production->classes->{$modelname}->prop = $props; $config->staging = array(); $config->setExtend('staging', 'production'); $config->development = array(); $config->setExtend('development', 'production'); $writer = new Zend_Config_Writer_Xml(); $writer->write(CONFIG_PATH . $configfile, $config); $this->render('blank', null, true); }
function loadFormXmlAction() { $nameSpace = new Sys_Model_Namespace(); $nameSpaces = $nameSpace->fetchAll(); foreach ($nameSpaces as $nameSpacObj) { $nameSpac = strtolower($nameSpacObj->namespace); $config = App_Model_Config::loadXml($nameSpac); //$package = arrar(); foreach ($config->classes as $name => $modelconfig) { // foreach ($modelconfig->prop as $prop) { $key = $prop->name; $value = $prop->label; $ln = new Sys_Model_Entity(); $ln->setNamespace($nameSpac); $ln->setEntityName($name); $ln->save(); // } } } $this->_helper->redirector('index'); $this->render('blank', null, true); }
/** * * Enter description here ... * @return GridConfig; */ function getGridConfig() { $modelName = $this->getModelName(); return App_Model_Config::get($modelName)->getGridConfig($this->getUiName()); }
static function get2($modelName) { $session = new Zend_Session_Namespace('App_Model_Config'); $key = "App_Model_Config{$modelName}"; if (isset($session->{$key})) { $obj = $session->{$key}; // true ; //$_SESSION ['ses_SamX_obj']; } else { $obj = new App_Model_Config(); $session->{$key} = $obj; } $obj->setModel($modelName); return $obj; }
function saveFormScriptAction() { $modelname = $this->_request->getParam("model", 'Eau_Model_Company'); $uiName = $this->_request->getParam("uiName", 'default'); $scriptAffter = $this->_request->getParam("formScriptAffterRendered", ""); $configXml = App_Model_Config::get($modelname)->getConfigXML(); $configArray = $configXml->production->classes->{$modelname}->config->toArray(); $scriptData = array('affterRendered' => $scriptAffter); $configArray['ui'][$uiName]['form']['scripts'] = $scriptData; $configXml->production->classes->{$modelname}->config = $configArray; App_Model_Config::get($modelname)->write($configXml); $this->_helper->redirector('form-script-editor', null, null, array('model' => $modelname, 'uiName' => $uiName)); }
protected function randerTemplateSelectInput() { $uilist = App_Model_Config::get($this->_modelName)->getUiList(); $input = "<select id='copyForm' name='template' style='width:120px'>"; foreach ($uilist as $uiName) { $selected = ""; if (trim($uiName) == trim($this->_template)) { $selected = "selected='selected'"; } $input .= "<option {$selected} > {$uiName} </option>"; } $input .= "</select>"; return $input; }
public function getModelConfig($modelName) { return App_Model_Config::get($modelName); }
protected function _getConfig($modelname) { if ($modelname instanceof App_Model_Abstract) { $modelname = get_class($modelname); } $config = clone App_Model_Config::get($modelname)->getConfig(); return $config; // // App_Env::getConfig($modelname); }
{ return "{$controler}/" . urlencode(str_replace(' ', '_', $title)); } static function getConfig($modelname)
function render() { $this->view->headLink()->appendStylesheet('/css/express-table/style.css'); $sections = $this->_modelInfoConfig->getSections(); // print_r($formGroups); ?> <div style="text-align: center; width: 100%; padding-left: 20px" align="center" > <table class="statistics " style="width: 90%"> <?php $index = 0; foreach ($sections as $section) { ?> <tr id="<?php echo $section['id']; ?> "><th style="height: 5px"><?php echo $section['label']; ?> </th></tr> <tr><td> <table class="hor-minimalist-b" style="width: 95%"> <tr> <?php $line = 0; $col = 0; foreach ($section['items'] as $item) { $line++; $col += 1; if ($item->type == 'field') { $elementid = $item->id; $prop = $this->_config->getPropByName($elementid); ?> <td style="text-align: left; width: 20%; max-width: 200px;text-transform: capitalize;font-weight: bold;;" ><?php echo $this->view->translate($prop->label); ?> </td> <td style="width: 10px"> : </td> <td style="text-align: left;" ><?php echo $this->_model->{$elementid}; ?> </td> <?php if ($line % 2 == 0) { echo "</tr><tr>"; $col = 0; } ?> <?php } elseif ($item->type == 'viewHelper') { ?> <tr> <td colspan="6"> <?php echo $this->view->{$item->id}($this->_model); ?> </td> </tr> <?php $col = 0; } ?> <?php } ?> <?php if ($col == 1) { echo "<td> </td><td> </td><td> </td></tr>"; $endline = true; } ?> </table> </td></tr> <?php $index += 1; } ?> </table></div> <?php }
function gen($package) { ini_set('display_errors', 1); $xml = App_Model_Config::getConfigFilePath($package); // APPLICATION_PATH . '/configs/' . $package . '-model-config.xml'; $configFileName = basename($xml); $data = $config = new Zend_Config_Xml($xml, 'production'); $classList = $data->classes; $project = $data->project; $createPackageFolder = true; $destinationFolder = $data->destinationDirectory; if ('application' == $project) { $createPackageFolder = false; $destinationFolder = APPLICATION_PATH . "/" . $destinationFolder; } elseif ('global' == $project) { $createPackageFolder = true; $destinationFolder = GLOBAL_PROJECT_PATH . "/" . $destinationFolder; } else { $createPackageFolder = true; $destinationFolder = realpath(APPLICATION_PATH . "/../library"); } // die($destinationFolder); $bodyConstruct = ''; foreach ($classList as $modelName => $attr) { $class = new Zend_CodeGenerator_Php_Class(); //$class->isAbstract(); $class->setAbstract(true); $class2 = new Zend_CodeGenerator_Php_Class(); $docblock = new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => $modelName, 'longDescription' => 'This is a class generated with Zend_CodeGenerator.', 'tags' => array(array('name' => 'uses', 'description' => $package . '_Model_Abstract'), array('name' => 'package', 'description' => $package), array('name' => 'subpackage', 'description' => 'Model'), array('name' => 'version', 'description' => '$Rev:$'), array('name' => 'update', 'description' => date('d/m/Y')), array('name' => 'license', 'description' => 'licensed By Patiwat Wisedsukol patiwat.wi@gmail.com')))); //$docblock2 = new Zend_CodeGenerator_Php_Docblock(); echo "create ", $modelName, "<br/>"; $class->setName($modelName . "_Abstract"); $class2->setName($modelName); if ('' == trim($attr->extendedClass)) { $class->setExtendedClass($package . '_Model_Abstract'); } else { $class->setExtendedClass($attr->extendedClass); } $class2->setExtendedClass($modelName . '_Abstract'); $Prop = array(); $Methods = array(); $PropertyData = array(); $columsToPropsList = array(); $propsToColumsList = array(); foreach ($attr->prop as $prop) { $name = $prop->name; $Prop[] = array('name' => "_" . $name, 'visibility' => 'protected', 'defaultValue' => null); $pdata = array(); $PropertyData[$name] = $this->process_data_array($prop); $columsToPropsList[$prop->column] = $prop->name; $propsToColumsList[$prop->name] = $prop->column; $Methods[] = $name; } // print_r($PropertyData); // exit(); $PropertyDataString = $this->gen_array($PropertyData); //$p = new Zend_CodeGenerator_Php_Property_DefaultValue(array('value'=>$PropertyDataString ,'type'=>Zend_CodeGenerator_Php_Property_DefaultValue::TYPE_ARRAY)); $Prop[] = array('name' => "propertyData", 'visibility' => 'public', 'defaultValue' => $PropertyDataString); if (isset($attr->config)) { $configDataString = $this->gen_array($attr->config->toArray()); } else { $configDataString = null; } $Prop[] = array('name' => "CONFIG_FILE_NAME", 'visibility' => 'public', 'const' => true, 'defaultValue' => $configFileName); $Prop[] = array('name' => "COLUMS_TO_PROPS_LIST", 'visibility' => 'public', 'defaultValue' => $this->gen_array($columsToPropsList)); $Prop[] = array('name' => "PROPS_TO_COLUMS_LIST", 'visibility' => 'public', 'defaultValue' => $this->gen_array($propsToColumsList)); $Prop[] = array('name' => "configData", 'visibility' => 'public', 'defaultValue' => $configDataString); $configSQLString = isset($attr->config->sql) ? (string) $attr->config->sql : ''; $Prop[] = array('name' => "_baseSQL", 'visibility' => 'public', 'defaultValue' => $configSQLString); $class->setDocblock($docblock); $class->setProperties($Prop); /* $Property = new Zend_CodeGenerator_Php_Property(); $pv = new Zend_CodeGenerator_Php_Property_DefaultValue($PropertyDataString); $pv->setType(Zend_CodeGenerator_Php_Property_DefaultValue::TYPE_ARRAY); $Property->setDefaultValue($pv); $Property->setName('_propertyData'); $class->setProperty($Property); */ $method = new Zend_CodeGenerator_Php_Method(); $method->setName('__construct'); $method->setBody("parent::__construct ( \$options, '{$modelName}');"); $method->setParameters(array(array('name' => 'options', 'type' => 'array', 'defaultValue' => null))); $class->setMethod($method); foreach ($Methods as $name) { $method = new Zend_CodeGenerator_Php_Method(); $method->setName('set' . strtoupper(substr($name, 0, 1)) . substr($name, 1, strlen($name))); $method->setBody(" \n \n\t\t \$this->_{$name} = \${$name}; \n\n\t\treturn \$this; \n "); $method->setParameter(array('name' => $name)); $docblock = new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => "Set the {$name} property", 'tags' => array(array('name' => 'param', 'description' => "\${$name} the \${$name} to set"), array('name' => 'return', 'description' => $modelName)))); $method->setDocblock($docblock); $class->setMethod($method); } foreach ($Methods as $name) { $method = new Zend_CodeGenerator_Php_Method(); $method->setName('get' . strtoupper(substr($name, 0, 1)) . substr($name, 1, strlen($name))); $method->setBody(" \n \n\t\treturn \$this->_{$name}; \n\n\t\t\n\t\t"); $docblock = new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => "get the {$name} property", 'tags' => array(array('name' => 'return', 'description' => "the {$name}")))); $method->setDocblock($docblock); $class->setMethod($method); } $method = new Zend_CodeGenerator_Php_Method(); $method->setParameter(array('name' => 'id')); $method->setStatic(true); $method->setName('getObjectByID'); $method->setBody("\n \n \n \$obj = new {$modelName}();\n\t\t \n \$obj->find(\$id);\n\t\t \n return \$obj;\n\t\t "); $docblock = new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => "get Singleton {$modelName}", 'tags' => array(array('name' => 'return', 'description' => "{$modelName}")))); $method->setDocblock($docblock); $class->setMethod($method); ////////////Gen Method Form Config///////////////// $tostringCreated = false; if (isset($attr->method->name)) { $this->addMethod($attr->method, $class); } else { if (is_array($attr->method)) { foreach ($attr->method as $methodConfig) { $this->addMethod($methodConfig, $class); } } } //ถ้ายังไม่มี __tostrint จะ เพิ่มให้ แต่จะ return ค่าว่าง if (false == $this->_isTostringCreated()) { $method = new Zend_CodeGenerator_Php_Method(); $method->setName('__toString'); $method->setBody("\n\n\t\t \n return '';\n\t\t "); $class->setMethod($method); } ///////////////////////END GEN METHOD/////////////////////////////// $file = new Zend_CodeGenerator_Php_File(); $file->setClass($class); $package = ucfirst(strtolower($package)); // Acc/Model/ if (false == $createPackageFolder) { $modelPath = str_replace(ucfirst(strtolower($package)) . "_Model_", "", $modelName); } else { $modelPath = $modelName; } $modelPath = str_replace("_", "/", $modelPath); //$structure = dirname ( __FILE__ )."/{$modelName}"; echo $destinationFolder . "/" . $modelPath; $structure = realpath($destinationFolder) . "/" . $modelPath; //"D:\workspaces\privatework\jiranan\private\library/"."/{$modelName}"; if (!is_dir($structure)) { mkdir($structure, 0777, true); } $filecontent = $this->filecontentfix($file->generate()); file_put_contents($structure . "/Abstract.php", $filecontent); echo "create [ ", $structure, "/Abstract.php ] complete <br/>"; // $structure2 = dirname ( __FILE__ )."/".$modelName.".php"; $structure2 = realpath($destinationFolder) . "/{$modelPath}.php"; //"D:\workspaces\privatework\jiranan\private\library/".$modelName.".php"; // echo file_exists ($structure2 ==true)? 'true' : 'false'; echo "<br/>"; if (file_exists($structure2)) { print "The file {$structure2} exists<br/>"; } else { print "The file {$structure2} does not exist<br/>"; echo "<br/>"; $file2 = new Zend_CodeGenerator_Php_File(); $file2->setClass($class2); //mkdir($structure, 0777, true); file_put_contents($structure2, $this->filecontentfix($file2->generate())); echo "create [ ", $structure2, " ] complete <br/>"; } echo "===================================================<br/>"; } // Render the generated file //echo $file; }
function render() { $this->view->headLink()->appendStylesheet('/css/express-table/style.css'); $formGroups = $this->_config->getFormGroups($this->_uiName); // print_r($formGroups); ?> <style > dt{ display:none; } </style> <form id='<?php echo $this->_form_id; ?> ' method="post" class='form-horizontal' role="form" action="<?php echo $this->view->url(); ?> " > <?php $index = 0; foreach ($formGroups as $groups) { ?> <fieldset> <h5><?php echo $groups['label']; ?> </h5> <?php foreach ($this->_config->getFormGroupElements($this->_uiName, $index) as $elementid) { $prop = $this->_config->getPropByName($elementid); $element = $this->getFormElement($elementid, $prop); $isRequired = true; if ($element instanceof Zend_Form_Element) { $isRequired = $element->isRequired(); } if (!$prop->isAllowEdit) { continue; } $style = ""; if ($prop->input == 'hidden') { $style = 'display: none;'; } ?> <div class="form-group"> <label for="<?php echo $elementid; ?> " class="col-sm-2 control-label"> <?php echo $this->view->translate($prop->label); ?> <?php if ($isRequired and $prop->modification == 'changeable') { echo "<span style='color: red;'>*<span>"; } ?> </label> <div class="col-sm-10"> <?php if (true == $this->_form->isEditForm()) { if ('readonly' == $prop->modification) { $value = $element->getValue(); echo $this->_config->fieldTranform($elementid, $value); echo "<input id='{$elementid}' name='{$elementid}' type='hidden' value='{$value}'>"; } else { echo $element; } } else { echo $element; } ?> </div> </div> <?php } ?> </fieldset> <?php $index += 1; } ?> </form> <?php $this->view->jQuery()->onLoadCaptureStart(); ?> $('form#<?php echo $this->_form_id; ?> ').find('dt').remove(); $('#SaveButton').unbind().bind('click',function(){ $('form#<?php echo $this->_form_id; ?> ').submit(); }); <?php $this->view->jQuery()->onLoadCaptureEnd(); ?> <?php }
function _setupPdfData($id = '') { $id = $this->_request->getParam('id', ''); $model = new $this->_model(); $model->find($id); $properties = App_Model_Config::get($this->_model)->getProperties(); //print_r($properties); foreach ($properties as $prop) { //$prop = new ConfigProp(); //echo $prop->name; $data['default'][$prop->name]['value'] = $model->{$prop->name}; $data['default'][$prop->name]['title'] = $this->_translate($prop->label); $data['default'][$prop->name]['suffix'] = $this->_translate($prop->suffix); } return $data; }