function smarty_block_form($params, $content = '', $template, &$repeat) { if ($repeat) { // Set the current form to the context Clips\clips_context('indent_level', 1, true); $name = Clips\get_default($params, 'name', Clips\default_form_name()); $data = Clips\context('form_' . $name); if ($data) { Clips\context('current_form_data', $data); } Clips\clips_context('current_form', $name); return; } $content .= "\t" . Clips\create_tag('input', array('type' => 'hidden', 'name' => Clips\Form::FORM_FIELD, 'value' => Clips\get_default($params, 'name', 'form'))); $action = Clips\get_default($params, 'action'); if ($action) { if (strpos($action, 'http') !== 0) { $params['action'] = Clips\site_url($action); } } if (Clips\get_default($params, 'upload')) { unset($params['upload']); $params['enctype'] = 'multipart/form-data'; } Clips\context_pop('current_form'); Clips\context_pop('current_form_data'); Clips\context_pop('indent_level'); return Clips\create_tag_with_content('form', $content, $params, array('action' => '#', 'method' => 'post', 'class' => ['clips-form', 'default-form'])); }
public function init() { $this->tool->widget('ListView'); if (isset($this->value)) { if (!is_array($this->value)) { $this->value = array($this->value); } } else { $this->value = array(\Clips\default_form_name()); } // Initialize the ListView in javacript foreach ($this->getConfig() as $name => $config) { if ($config) { // Setting the default values for the datatable configuration if (!isset($config->ajax)) { $controller_class = \Clips\context('controller_seg'); $method = \Clips\context('controller_method'); $uri = \Clips\context('uri'); if (strpos($uri, $method) !== false) { $d = explode($method, $uri); $config->ajax = \Clips\site_url(\Clips\path_join($d[0], $name)); } else { if (strpos($uri, $controller_class) !== false) { $config->ajax = \Clips\site_url(\Clips\path_join($uri, $name)); } else { $config->ajax = \Clips\site_url(\Clips\path_join($uri, $controller_class, $name)); } } } $config->processing = true; $config->serverSide = true; foreach ($config->columns as $col) { if (isset($col->data)) { // Must smooth the data $col->data = \Clips\smooth($col->data); } if (isset($col->refer)) { $col->refer = \Clips\smooth($col->refer); } if (isset($col->action)) { // If has action, use action render $col->render = 'datatable_action_column'; } } // Adding the initialize script to jquery init \Clips\context('jquery_init', '$("ul[name=' . \Clips\to_flat($name) . ']").listview(' . json_encode($config) . ')', true); } } }
public function init() { $this->tool->widget('DataTable'); if (isset($this->value)) { if (!is_array($this->value)) { $this->value = array($this->value); } } else { $this->value = array(\Clips\default_form_name()); } // Initialize the datatable in javacript foreach ($this->getConfig() as $name => $config) { if ($config) { // Enforce security by default for DataTable $config->security = $this->securityengine; $config->name = $name; // Setting the default values for the datatable configuration if (!isset($config->ajax)) { $controller_class = \Clips\context('controller_seg'); $method = \Clips\context('controller_method'); $uri = \Clips\context('uri'); if (strpos($uri, $method) !== false) { $d = explode($method, $uri); $config->ajax = \Clips\site_url(\Clips\path_join($d[0], $name)); } else { if (strpos($uri, $controller_class) !== false) { $config->ajax = \Clips\site_url(\Clips\path_join($uri, $name)); } else { $config->ajax = \Clips\site_url(\Clips\path_join($uri, $controller_class, $name)); } } } $config->processing = true; $config->serverSide = true; // The bundle configuration in anntation has the highest priority $bundle = \Clips\get_default($this, 'bundle', null); if ($bundle === null) { // Try configuration's bundle settings $bundle = \Clips\get_default($config, 'bundle', null); if ($bundle === null) { // We can't find the bundle in annotation, try to find it using default name $bundle_name = 'pagination/' . $name; $bundle = $this->tool->bundle($bundle_name); if ($bundle->isEmpty()) { // All default bundle can't be found, try current controller's bundle $bundle = \Clips\context('current_bundle'); if ($bundle === null) { $bundle = ''; } } } } $bundle = \Clips\bundle($bundle); // Update the columns configuration to the filtered columns configuration $config->columns = $config->columns(); $replaces = array(); foreach ($config->columns as $col) { if (isset($col->title)) { $col->title = $bundle->message($col->title); } if (isset($col->data)) { // Must smooth the data if (strpos($col->data, " as ")) { $d = explode(' as ', $col->data); if ($d) { $col->data = trim($d[1]); } } $col->data = \Clips\smooth($col->data); } if (isset($col->refer)) { $col->refer = \Clips\smooth($col->refer); } if (isset($col->render)) { if (array_search($col->render, $replaces) === false) { $replaces[] = $col->render; } } if (isset($col->action)) { // If has action, use action render $col->render = 'datatable_action_column'; if (array_search($col->render, $replaces) === false) { $replaces[] = $col->render; } } } // Clean the where data stored in the session $controller = \Clips\context('controller'); if ($controller) { $controller->request->session($name, null); } $json = $config->toJson(); foreach ($replaces as $r) { $json = str_replace('"' . $r . '"', $r, $json); } // Adding the initialize script to jquery init \Clips\context('jquery_init', 'if(window[\'DatatableSettings\'] == undefined ) { DatatableSettings = {}; } DatatableSettings["' . $name . '"] = ' . $json . ';$("table[name=' . \Clips\to_flat($name) . ']").DataTable(DatatableSettings["' . $name . '"]);', true); } } }