diff --git a/pandora_console/godmode/modules/manage_block_templates.php b/pandora_console/godmode/modules/manage_block_templates.php index 45fc367a4d..c9f55c14c2 100644 --- a/pandora_console/godmode/modules/manage_block_templates.php +++ b/pandora_console/godmode/modules/manage_block_templates.php @@ -13,9 +13,9 @@ // GNU General Public License for more details. // Load global vars // TESTING -/* - ini_set('display_errors', 1); - ini_set('display_startup_errors', 1); + /* + ini_set('display_errors', 1); + ini_set('display_startup_errors', 1); error_reporting(E_ALL); */ // END global $config; @@ -80,6 +80,16 @@ if (is_ajax()) { $manageBlock->moduleBlockList(); } else { // Create new o update Template. - $manageBlock->moduleTemplateForm($id_np); + $manageBlock->moduleTemplateForm(); } } + +?> + \ No newline at end of file diff --git a/pandora_console/include/class/ManageBlock.class.php b/pandora_console/include/class/ManageBlock.class.php index 97534f8f0d..2eda9d9f56 100644 --- a/pandora_console/include/class/ManageBlock.class.php +++ b/pandora_console/include/class/ManageBlock.class.php @@ -63,6 +63,27 @@ class ManageBlock extends HTML */ private $id_np; + /** + * Name of Block Template + * + * @var [type] + */ + private $name; + + /** + * Description of Block Template + * + * @var [type] + */ + private $description; + + /** + * Private Enterprise Numbers of Block Templates + * + * @var [type] + */ + private $pen; + /** * Constructor @@ -90,14 +111,15 @@ class ManageBlock extends HTML exit; } - $this->id_np = get_parameter('id_np', -1); - - $this->offset = get_parameter('offset', 0); - - $this->ajaxController = $ajax_controller; - - // Set baseUrl for use it in several locations in this class - $this->baseUrl = ui_get_full_url('index.php?sec=gmodules&sec2=godmode/modules/manage_block_templates'); + // Set baseUrl for use it in several locations in this class. + $this->baseUrl = ui_get_full_url('index.php?sec=gmodules&sec2=godmode/modules/manage_block_templates'); + // Capture all parameters before start. + $this->id_np = get_parameter('id_np', -1); + $this->name = get_parameter('name', ''); + $this->description = get_parameter('description', ''); + $this->pen = get_parameter('pen', ''); + $this->offset = get_parameter('offset', 0); + $this->ajaxController = $ajax_controller; return $this; } @@ -162,6 +184,34 @@ class ManageBlock extends HTML } + /** + * Undocumented function + * + * @return void + */ + private function manageData() + { + // if ($) + $name = get_parameter('name', ''); + $description = get_parameter('description', ''); + $pen = get_parameter('pen', ''); + hd($name); + hd($description); + hd($pen); + } + + + private function setNetworkProfile() + { + if ($this->id_np !== 0) { + $output = db_get_row('tnetwork_profile', 'id_np', $this->id_np); + $this->name = $output['name']; + $this->description = $output['description']; + $this->pen = $output['pen']; + } + } + + /** * Create the table with the list of Blocks Templates * @@ -288,44 +338,32 @@ class ManageBlock extends HTML /** * Prints Form for template management - * - * @param integer $id_np */ - public function moduleTemplateForm(int $id_np=0) + public function moduleTemplateForm() { - $output = []; - $createNewBlock = ($id_np === 0) ? true : false; + $createNewBlock = ($this->id_np === 0) ? true : false; if ($createNewBlock) { // Assignation for submit button. $formButtonClass = 'sub wand'; $formButtonName = 'crtbutton'; $formButtonLabel = __('Create'); - // Set of empty values. - $description = ''; - $name = ''; - $pen = ''; } else { // Assignation for submit button. $formButtonClass = 'sub upd'; $formButtonName = 'updbutton'; $formButtonLabel = __('Update'); - // Profile exists. - $row = db_get_row('tnetwork_profile', 'id_np', $id_np); - // Fill the inputs with the obtained data. - $description = $row['description']; - $name = $row['name']; - $pen = ''; + // Profile exists. Set the attributes with the info. + $this->setNetworkProfile(); } // Main form. $form = [ - 'action' => $this->baseUrl, - 'id' => 'module_block_form', - 'onsubmit' => 'return false;', - 'method' => 'POST', - 'class' => 'databox filters', - 'extra' => '', + 'action' => $this->baseUrl, + 'id' => 'module_block_form', + 'method' => 'POST', + 'class' => 'databox filters', + 'extra' => '', ]; // Inputs. @@ -338,7 +376,7 @@ class ManageBlock extends HTML 'name' => 'name', 'input_class' => 'flex-row', 'type' => 'text', - 'value' => $name, + 'value' => $this->name, 'return' => true, ], ]; @@ -350,7 +388,7 @@ class ManageBlock extends HTML 'name' => 'description', 'input_class' => 'flex-row', 'type' => 'textarea', - 'value' => $description, + 'value' => $this->description, 'return' => true, ], ]; @@ -362,7 +400,7 @@ class ManageBlock extends HTML 'name' => 'pen', 'input_class' => 'flex-row', 'type' => 'text', - 'value' => $pen, + 'value' => $this->pen, 'return' => true, ], ]; @@ -371,26 +409,22 @@ class ManageBlock extends HTML 'arguments' => [ 'name' => $formButtonName, 'label' => $formButtonLabel, - 'type' => 'button', + 'type' => 'submit', 'attributes' => 'class="'.$formButtonClass.'"', 'return' => true, ], ]; - $inputs[] = [ - 'arguments' => [ - 'name' => 'buttonGoBack', - 'label' => __('Go back'), - 'type' => 'button', - 'attributes' => 'class="sub cancel"', - 'return' => true, - ], - ]; + ui_require_jquery_file('tag-editor'); + ui_require_css_file('jquery.tag-editor'); + + $js = '$(\'#text-pen\').tagEditor();'; $this->printFormAsList( [ 'form' => $form, 'inputs' => $inputs, + 'js' => $js, true ] ); @@ -402,83 +436,108 @@ class ManageBlock extends HTML FROM tnetwork_profile_component AS npc, tnetwork_component AS nc INNER JOIN tnetwork_component_group AS ncg ON ncg.id_sg = nc.id_group WHERE npc.id_nc = nc.id_nc AND npc.id_np = %d', - $id_np + $this->id_np ); $moduleBlocks = db_get_all_rows_sql($sql); - $blockTables = []; - // Build the information of the blocks - foreach ($moduleBlocks as $block) { - if (key_exists($block['group'], $blockTables) === false) { - $blockTables[$block['group']] = [ - 'name' => $block['group_name'], - 'data' => [], - ]; - } else { - $blockTables[$block['group']]['data'][] = [ - 'component_id' => $block['component_id'], - 'name' => $block['name'], - 'type' => $block['type'], - 'description' => $block['description'], - ]; - } - } - - if (count($blockTables) === 0) { - ui_print_info_message(__('No module blocks for this profile')); - } else { - foreach ($blockTables as $id_group => $blockTable) { - $blockData = $blockTable['data']; - $blockTitle = $blockTable['name']; - $blockTitle .= '