PATH:
home
/
letacommog
/
letaweb
/
protected
/
modules
/
admin
/
models
<?php class ModuleDataForm extends CFormModel { public $id; public $module_name; public $view; public $backend; public $scripts; public $styles; public $data; public function rules() { return array( array('id', 'numerical'), array('module_name', 'required'), array('id, view, backend, scripts,styles,data', 'safe'), ); } function bbc_array_to_str($tab) { // This function return a string description of an array. // Format (_ == space): // |_array( // |__key1 => scal1, key2 => scal2, ... // |__key3 => // |___array( // |____key1 => scal1, ... // |___), // |__key4 => scal4, ... // |_) static $indent = ""; $oldindent = $indent; $indent .= " "; $sep = ""; $str = $indent."array(\n"; $last_is_array = false; $k = 0; @reset($tab); if(!is_array($tab)) $tab = array(); while (list($key, $val) = each($tab)) { // The separator treatment if (($last_is_array) || (is_array($val) && ($k !== 0))) { $str .= $sep."\n"; } else $str .= $sep; // The key treatment if (preg_match(":^[0-9]+$:", $key)) { if ($key !== $k) { $str .= (((is_array($val)) || ($k === 0) || ($last_is_array)) ? "$indent " : "") ."$key =>".((is_array($val)) ? "\n" : " "); } else $str .= ($k === 0) ? (is_array($val) ? "" : "$indent ") : ""; } else { $str .= (((is_array($val)) || ($k === 0) || ($last_is_array)) ? "$indent " : "") ."\"$key\" =>".((is_array($val)) ? "\n" : " "); } // The value treatment $last_is_array = false; if (is_array($val)) { $str .= bbc_array_to_str($val); $last_is_array = true; $sep = ","; } else { $str .= (preg_match(":^[0-9]+$:", $val) ? $val : "\"$val\""); $sep = ", "; } $k++; } $str .= "\n$indent)"; $indent = $oldindent; return $str; } public function save($item = null) { if ($this->validate()) { $module = ModuleData::model()->find('module_name=:name',array(':name'=>$this->module_name)); if (!isset($module)) $module = new ModuleData(); $module->module_name = $this->module_name; $module->view = $this->view; $module->backend = $this->backend; $module->scripts = $this->scripts; $module->styles = $this->styles; $module->data = $this->data; if ($module->validate() && $module->save()) { $script_path = Yii::getPathofAlias('application_root.scripts.editor.modules'); var_dump($script_path); copy($script_path.DIRECTORY_SEPARATOR.'__custom_module_template.js',$script_path.DIRECTORY_SEPARATOR.$this->module_name.'.js'); $admin_path = Yii::getPathofAlias('application_admin.widgets.modules'); $handle = fopen($admin_path.DIRECTORY_SEPARATOR.'CWidget'.$this->module_name.'.php', 'w'); fwrite($handle,'<?php class CWidget'.$this->module_name.' extends CWidgetCustomModule { public $rawData='.$this->bbc_array_to_str(json_decode($this->data,true)).'; }'); fclose($handle); $admin_view_path = Yii::getPathofAlias('application_admin.widgets.views.modules'); $handle = fopen($admin_view_path.DIRECTORY_SEPARATOR.$this->module_name.'.php', 'w'); fwrite($handle,$this->view); fclose($handle); $admin_backend_path = Yii::getPathofAlias('application_admin.views.builder.modules'); $handle = fopen($admin_backend_path.DIRECTORY_SEPARATOR.$this->module_name.'.php', 'w'); fwrite($handle,$this->backend); fclose($handle); return true; } else { $this->addErrors($module->getErrors()); } } else { return false; } } }
[+]
..
[-] DBPageForm.php
[edit]
[-] PlanDescriptionForm.php
[edit]
[-] HostingConfigurationForm.php
[edit]
[-] MailConfigurationForm.php
[edit]
[-] TemplateForm.php
[edit]
[-] ModuleForm.php
[edit]
[-] PageForm.php
[edit]
[-] PaymentConfigurationForm.php
[edit]
[-] CategoryForm.php
[edit]
[-] TermForm.php
[edit]
[-] DbListForm.php
[edit]
[-] ModuleDataForm.php
[edit]
[-] UploadTemplateForm.php
[edit]
[-] PlanConditionForm.php
[edit]
[-] ChangeDomainForm.php
[edit]
[-] LanguageForm.php
[edit]
[-] SkinPresetForm.php
[edit]
[-] PlanForm.php
[edit]
[-] UpgradePageForm.php
[edit]
[-] MailTemplateForm.php
[edit]
[-] ColorForm.php
[edit]
[-] MakeTempleteFromSiteForm.php
[edit]
[-] ResetPassForm.php
[edit]
[-] InterfaceForm.php
[edit]
[-] ContentForm.php
[edit]
[-] UserForm.php
[edit]
[-] ExtendPageForm.php
[edit]
[-] ConfigurationForm.php
[edit]
[-] ModuleCategoryForm.php
[edit]
[-] SocialShareButtonForm.php
[edit]