function execute(&$form, $action_id)
 {
     $config = $form->actions_config[$action_id];
     $this->config = $config = new \GCore\Libs\Parameter($config);
     if ((bool) $config->get('enabled', 0) === false) {
         return;
     }
     $skipped = $config->get('skipped', '');
     if (!empty($skipped)) {
         $skipped = explode(',', $skipped);
         array_walk($skipped, create_function('&$val', '$val = trim($val);'));
     } else {
         $skipped = array();
     }
     $del = $config->get('delimiter', ',');
     //handle specific fields only ?
     if (strlen($config->get('fields_list', ''))) {
         $fields_list = explode(',', $config->get('fields_list', ''));
         foreach ($fields_list as $field) {
             $field = trim($field);
             //get field value
             $field_value = \GCore\Libs\Arr::getVal($form->data, explode('.', $field));
             if (is_array($field_value)) {
                 $form->data = \GCore\Libs\Arr::setVal($form->data, explode('.', $field), implode($del, $field_value));
             }
         }
     } else {
         $form->data = $this->array_handler($form->data, $skipped, $del);
     }
 }
Beispiel #2
0
    public static function config($data = array(), $k = '{N}')
    {
        echo \GCore\Helpers\Html::formStart('original_element_config single_element_config', 'password_origin_config');
        ?>
		<ul class="nav nav-tabs">
			<li><a href="#general-<?php 
        echo $k;
        ?>
" data-g-toggle="tab"><?php 
        echo l_('CF_GENERAL');
        ?>
</a></li>
			<li><a href="#validation-<?php 
        echo $k;
        ?>
" data-g-toggle="tab"><?php 
        echo l_('CF_VALIDATION');
        ?>
</a></li>
		</ul>
		<div class="tab-content">
			<div id="general-<?php 
        echo $k;
        ?>
" class="tab-pane">
			<?php 
        echo \GCore\Helpers\Html::formSecStart();
        foreach (self::$configs as $name => $params) {
            $value = \GCore\Libs\Arr::getVal($data, explode('.', $name));
            $field_name = implode('][', explode('.', $name));
            $params['value'] = $value ? $params['type'] == 'text' ? htmlspecialchars($value, ENT_QUOTES) : $value : (isset($params['value']) ? $params['value'] : '');
            $params['values'] = $value ? $value : (isset($params['values']) ? $params['values'] : '');
            echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][' . $field_name . ']', $params);
        }
        echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][type]', array('type' => 'hidden', 'value' => self::$settings['type']));
        echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][container_id]', array('type' => 'hidden', 'id' => 'container_id' . $k, 'value' => '0'));
        echo \GCore\Helpers\Html::formSecEnd();
        ?>
			</div>
			<div id="validation-<?php 
        echo $k;
        ?>
" class="tab-pane">
			<?php 
        echo \GCore\Helpers\Html::formSecStart();
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][validation][required]', array('type' => 'dropdown', 'label' => l_('CF_REQUIRED'), 'options' => array('' => l_('NO'), 1 => l_('YES'))));
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][validation][alpha]', array('type' => 'dropdown', 'label' => l_('CF_ALPHA'), 'options' => array('' => l_('NO'), 1 => l_('YES'))));
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][validation][alphanum]', array('type' => 'dropdown', 'label' => l_('CF_ALPHA_NUMERIC'), 'options' => array('' => l_('NO'), 1 => l_('YES'))));
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][validation][digit]', array('type' => 'dropdown', 'label' => l_('CF_DIGIT'), 'options' => array('' => l_('NO'), 1 => l_('YES'))));
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][validation][nodigit]', array('type' => 'dropdown', 'label' => l_('CF_NO_DIGIT'), 'options' => array('' => l_('NO'), 1 => l_('YES'))));
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][validation][number]', array('type' => 'dropdown', 'label' => l_('CF_NUMBER'), 'options' => array('' => l_('NO'), 1 => l_('YES'))));
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][validation][confirm]', array('type' => 'text', 'label' => l_('CF_VALIDATE_CONFIRM'), 'sublabel' => l_('CF_VALIDATE_CONFIRM_DESC')));
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][validation][custom]', array('type' => 'text', 'label' => l_('CF_VALIDATE_CUSTOM'), 'sublabel' => l_('CF_VALIDATE_CUSTOM_DESC')));
        echo \GCore\Helpers\Html::formSecEnd();
        ?>
			</div>
		</div>
		<?php 
        echo \GCore\Helpers\Html::formEnd();
    }
 function execute(&$form, $action_id)
 {
     $config = $form->actions_config[$action_id];
     $config = new \GCore\Libs\Parameter($config);
     $doc = new Spreadsheet();
     $doc->authenticate($config->get('username'), $config->get('password'));
     $doc->setSpreadsheet($config->get('spreadsheet'));
     $doc->setWorksheet($config->get('worksheet'));
     $path = $config->get('data_path', 'GSheet') ? explode('.', $config->get('data_path', 'GSheet')) : array();
     $data = \GCore\Libs\Arr::getVal($form->data, $path, array());
     //pr($data);
     $doc->add($data);
     $form->debug[$action_id][self::$title] = $doc->debug;
 }
Beispiel #4
0
 function execute(&$form, $action_id)
 {
     $config = $form->actions_config[$action_id];
     $config = new \GCore\Libs\Parameter($config);
     if (!$config->get('enabled')) {
         return;
     }
     $tablename = $config->get('tablename', '');
     if (!empty($tablename)) {
         \GCore\Libs\Model::generateModel('ListData', array('tablename' => $tablename));
         $list_model = '\\GCore\\Models\\ListData';
         if ($config->get('columns', '')) {
             $columns = array_map('trim', explode("\n", $config->get('columns', '')));
         } else {
             $columns = $list_model::getInstance()->dbo->getTableColumns($tablename);
         }
         if ($config->get('titles', '')) {
             $titles = array_map('trim', explode("\n", $config->get('titles', '')));
         } else {
             $titles = $columns;
         }
         if ($config->get('order_by', '')) {
             $order_by = array_map('trim', explode(',', $config->get('order_by', '')));
         } else {
             $order_by = $list_model::getInstance()->pkey;
         }
         $file_name = 'csv_export_' . $tablename . '_' . date('YmdHi') . '.csv';
         $rows = $list_model::getInstance()->find('all', array('fields' => $columns, 'order' => $order_by));
     } else {
         if (!$config->get('data_path', '')) {
             return;
         }
         $rows = \GCore\Libs\Arr::getVal($form->data, explode('.', $config->get('data_path', '')), array());
         $file_name = 'csv_export_' . date('YmdHi') . '.csv';
     }
     header('Content-type: text/csv');
     header('Content-Disposition: attachment; filename=' . $file_name);
     header('Pragma: no-cache');
     header('Expires: 0');
     $data = array($titles);
     if (!empty($rows)) {
         foreach ($rows as $row) {
             $data[] = $row['ListData'];
         }
     }
     @ob_end_clean();
     self::outputCSV($data);
     exit;
 }
Beispiel #5
0
 public static function config($data = array(), $k = '_XNX_')
 {
     echo \GCore\Helpers\Html::formStart('original_element_config single_element_config', 'recaptcha_origin_config');
     echo \GCore\Helpers\Html::formSecStart();
     foreach (self::$configs as $name => $params) {
         $value = \GCore\Libs\Arr::getVal($data, explode('.', $name));
         $field_name = implode('][', explode('.', $name));
         $params['value'] = $value ? $params['type'] == 'text' ? htmlspecialchars($value, ENT_QUOTES) : $value : (isset($params['value']) ? $params['value'] : '');
         $params['values'] = $value ? $value : (isset($params['values']) ? $params['values'] : '');
         echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][' . $field_name . ']', $params);
     }
     echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][name]', array('type' => 'hidden', 'alt' => 'ghost', 'value' => 'recaptcha'));
     echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][render_type]', array('type' => 'hidden', 'alt' => 'ghost', 'value' => 'recaptcha'));
     echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][type]', array('type' => 'hidden', 'alt' => 'ghost', 'value' => self::$settings['type']));
     echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][container_id]', array('type' => 'hidden', 'id' => 'container_id' . $k, 'value' => '0'));
     echo \GCore\Helpers\Html::formSecEnd();
     echo \GCore\Helpers\Html::formEnd();
 }
Beispiel #6
0
 public static function on_finalize($controller)
 {
     $config = new \GCore\Libs\Parameter($controller->connection['Connection']['extras']['plugins']['download']);
     $path_field = $config->get('path_field');
     $download_action = $config->get('download_action');
     if (!empty($path_field) and !empty($download_action)) {
         if ($controller->action == $download_action) {
             if (!empty($controller->data['gcb'])) {
                 $path_pcs = explode('.', $path_field);
                 $field = array_pop($path_pcs);
                 $model = array_pop($path_pcs);
                 $row = $controller->connection_models[$model]->load($controller->data['gcb']);
                 if (!empty($row)) {
                     $file_path = \GCore\Libs\Arr::getVal($row, explode('.', $path_field));
                     if ($config->get('download_path')) {
                         $file_path = rtrim($config->get('download_path'), DS) . DS . $file_path;
                     }
                     if (is_dir($file_path)) {
                         //this is a folder
                         $files = @\GCore\Libs\Folder::getFiles($file_path, false);
                         foreach ($files as $file) {
                             $found[$file] = filemtime($file);
                         }
                         if (empty($found)) {
                             return false;
                         }
                         arsort($found);
                         $files = array_keys($found);
                         sort($files);
                         $file = array_pop($files);
                         \GCore\Libs\Download::send($file, 'D');
                     } else {
                         //this is a file
                         $file = $file_path;
                         \GCore\Libs\Download::send($file, 'D');
                     }
                 }
             }
         }
     }
 }
    public static function config($data = array(), $k = '{N}')
    {
        //back check at v5.0.6
        if (isset($data['label']) and !isset($data['inputs']['field']['label'])) {
            $data['inputs']['field']['label'] = $data['label'];
        }
        echo \GCore\Helpers\Html::formStart('original_element_config single_element_config', 'captcha_origin_config');
        ?>
		<ul class="nav nav-tabs">
			<li><a href="#general-<?php 
        echo $k;
        ?>
" data-g-toggle="tab"><?php 
        echo l_('CF_GENERAL');
        ?>
</a></li>
			<li><a href="#validation-<?php 
        echo $k;
        ?>
" data-g-toggle="tab"><?php 
        echo l_('CF_VALIDATION');
        ?>
</a></li>
		</ul>
		<div class="tab-content">
			<div id="general-<?php 
        echo $k;
        ?>
" class="tab-pane">
			<?php 
        echo \GCore\Helpers\Html::formSecStart();
        foreach (self::$configs as $name => $params) {
            $value = \GCore\Libs\Arr::getVal($data, explode('.', $name));
            $field_name = implode('][', explode('.', $name));
            $params['value'] = !is_null($value) ? $params['type'] == 'text' ? htmlspecialchars($value, ENT_QUOTES) : $value : (isset($params['value']) ? $params['value'] : '');
            $params['values'] = !is_null($value) ? $value : (isset($params['values']) ? $params['values'] : '');
            echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][' . $field_name . ']', $params);
        }
        echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][inputs][field][type]', array('type' => 'hidden', 'alt' => 'ghost', 'value' => 'text'));
        echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][inputs][field][name]', array('type' => 'hidden', 'alt' => 'ghost', 'value' => 'captcha'));
        echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][inputs][image][type]', array('type' => 'hidden', 'alt' => 'ghost', 'value' => 'custom'));
        echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][inputs][image][name]', array('type' => 'hidden', 'alt' => 'ghost', 'value' => 'captcha'));
        echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][inputs][image][code]', array('type' => 'hidden', 'alt' => 'ghost', 'value' => '{captcha_img}'));
        echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][layout]', array('type' => 'hidden', 'alt' => 'ghost', 'value' => self::$settings['layout']));
        echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][name]', array('type' => 'hidden', 'alt' => 'ghost', 'value' => 'captcha'));
        echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][render_type]', array('type' => 'hidden', 'alt' => 'ghost', 'value' => 'captcha'));
        echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][type]', array('type' => 'hidden', 'alt' => 'ghost', 'value' => self::$settings['type']));
        echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][container_id]', array('type' => 'hidden', 'id' => 'container_id' . $k, 'value' => '0'));
        echo \GCore\Helpers\Html::formSecEnd();
        ?>
			</div>
			<div id="validation-<?php 
        echo $k;
        ?>
" class="tab-pane">
			<?php 
        echo \GCore\Helpers\Html::formSecStart();
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][inputs][field][validation][required]', array('type' => 'dropdown', 'label' => l_('CF_REQUIRED'), 'options' => array('' => l_('NO'), 1 => l_('YES'))));
        echo \GCore\Helpers\Html::formSecEnd();
        ?>
			</div>
		</div>
		<?php 
        echo \GCore\Helpers\Html::formEnd();
    }
Beispiel #8
0
 function save()
 {
     parent::_settings('chronoforms');
     $chronoforms_settings = new \GCore\Libs\Parameter($this->data['Chronoforms']);
     if ($chronoforms_settings->get('wizard.safe_save', 1)) {
         $s_form = array();
         //parse_str($this->data['serialized_form_data'], $s_form);
         $pairs = explode('&', $this->data['serialized_form_data']);
         $result = array();
         foreach ($pairs as $pair) {
             $dummy = array();
             parse_str($pair, $dummy);
             $path = array();
             self::extract_array_path($dummy, $path);
             $path = implode('.', $path);
             $new_path = explode('.', $path);
             $result = \GCore\Libs\Arr::setVal($result, $new_path, \GCore\Libs\Arr::getVal($dummy, $new_path));
         }
         $s_form = $result;
         $this->data = $s_form;
     }
     $result = parent::_save();
     if ($result) {
         if ($this->Request->get('save_act') == 'apply') {
             $this->redirect(r_('index.php?ext=chronoforms&act=edit&id=' . $this->Form->id));
         } else {
             $this->redirect(r_('index.php?ext=chronoforms'));
         }
     } else {
         $this->edit();
         $this->view = 'edit';
         $session = \GCore\Libs\Base::getSession();
         $session->setFlash('error', \GCore\Libs\Arr::flatten($this->Form->errors));
     }
 }
Beispiel #9
0
 function translate($connection, $data = '')
 {
     $_f = function ($e) {
         $cs = explode('=', $e, 2);
         return array_map('trim', $cs);
     };
     $site_lang = \GCore\Libs\Str::camilize(str_replace('-', '_', strtolower(\GCore\Libs\Base::getConfig('site_language'))));
     if (!empty($connection['Connection']['extras']['locales'])) {
         foreach ($connection['Connection']['extras']['locales'] as $tag => $lang_data) {
             $tag_cap = \GCore\Libs\Str::camilize($lang_data['lang_tag']);
             if ($tag_cap == $site_lang) {
                 $lines = explode("\n", $lang_data['strings']);
                 $strings = array_map($_f, $lines);
                 $texts = \GCore\Libs\Arr::getVal($strings, array('[n]', 0));
                 if (!empty($lang_data['strict'])) {
                     $texts = array_map(function ($text) {
                         return '[' . $text . ']';
                     }, $texts);
                 }
                 $locales = \GCore\Libs\Arr::getVal($strings, array('[n]', 1));
                 $data = str_replace($texts, $locales, $data);
             }
         }
     }
     return $data;
 }
Beispiel #10
0
    public static function config($data = array(), $k = '{N}')
    {
        echo \GCore\Helpers\Html::formStart('original_element_config single_element_config', 'radio_origin_config');
        ?>
		<ul class="nav nav-tabs">
			<li><a href="#general-<?php 
        echo $k;
        ?>
" data-g-toggle="tab"><?php 
        echo l_('CF_GENERAL');
        ?>
</a></li>
			<li><a href="#validation-<?php 
        echo $k;
        ?>
" data-g-toggle="tab"><?php 
        echo l_('CF_VALIDATION');
        ?>
</a></li>
			<li><a href="#dynamic-<?php 
        echo $k;
        ?>
" data-g-toggle="tab"><?php 
        echo l_('CF_DYNAMIC_DATA');
        ?>
</a></li>
			<li><a href="#events-<?php 
        echo $k;
        ?>
" data-g-toggle="tab"><?php 
        echo l_('CF_EVENTS');
        ?>
</a></li>
		</ul>
		<div class="tab-content">
			<div id="general-<?php 
        echo $k;
        ?>
" class="tab-pane">
			<?php 
        echo \GCore\Helpers\Html::formSecStart();
        foreach (self::$configs as $name => $params) {
            $value = \GCore\Libs\Arr::getVal($data, explode('.', $name));
            $field_name = implode('][', explode('.', $name));
            $params['value'] = $value ? $params['type'] == 'text' ? htmlspecialchars($value, ENT_QUOTES) : $value : (isset($params['value']) ? $params['value'] : '');
            $params['values'] = $value ? $value : (isset($params['values']) ? $params['values'] : '');
            echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][' . $field_name . ']', $params);
        }
        echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][type]', array('type' => 'hidden', 'value' => self::$settings['type']));
        echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][container_id]', array('type' => 'hidden', 'id' => 'container_id' . $k, 'value' => '0'));
        echo \GCore\Helpers\Html::formSecEnd();
        ?>
			</div>
			<div id="validation-<?php 
        echo $k;
        ?>
" class="tab-pane">
			<?php 
        echo \GCore\Helpers\Html::formSecStart();
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][validation][group:' . $k . ']', array('type' => 'dropdown', 'label' => l_('CF_REQUIRED'), 'options' => array('' => l_('NO'), 1 => l_('YES'))));
        echo \GCore\Helpers\Html::formSecEnd();
        ?>
			</div>
			<div id="dynamic-<?php 
        echo $k;
        ?>
" class="tab-pane">
			<?php 
        echo \GCore\Helpers\Html::formSecStart();
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][dynamic_data][enabled]', array('type' => 'dropdown', 'label' => l_('CF_ENABLED'), 'options' => array('' => l_('NO'), 1 => l_('YES'))));
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][dynamic_data][data_path]', array('type' => 'text', 'label' => l_('CF_DATA_PATH'), 'sublabel' => l_('CF_DATA_PATH_DESC')));
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][dynamic_data][value_key]', array('type' => 'text', 'label' => l_('CF_VALUE_KEY'), 'sublabel' => l_('CF_VALUE_KEY_DESC')));
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][dynamic_data][text_key]', array('type' => 'text', 'label' => l_('CF_TEXT_KEY'), 'sublabel' => l_('CF_TEXT_KEY_DESC')));
        echo \GCore\Helpers\Html::formSecEnd();
        ?>
			</div>
			<div id="events-<?php 
        echo $k;
        ?>
" class="tab-pane">
			<?php 
        echo \GCore\Helpers\Html::formSecStart();
        if (empty($data['events'])) {
            $data['events'] = array(array());
        }
        foreach ($data['events'] as $i => $event) {
            echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][events][required]', array('type' => 'multi', 'layout' => 'wide', 'inputs' => array(array('type' => 'custom', 'name' => 'Form[extras][fields][' . $k . '][events][' . $i . '][label]', 'code' => 'On'), array('type' => 'dropdown', 'name' => 'Form[extras][fields][' . $k . '][events][' . $i . '][operator]', 'options' => array('=' => '=', '!=' => '!=')), array('type' => 'text', 'name' => 'Form[extras][fields][' . $k . '][events][' . $i . '][state]', 'sublabel' => 'Value selected', 'class' => 'S'), array('type' => 'dropdown', 'name' => 'Form[extras][fields][' . $k . '][events][' . $i . '][action]', 'options' => array('' => '', 'enable' => 'enable', 'disable' => 'disable', 'show' => 'show', 'hide' => 'hide', 'show_parent' => 'show parent', 'hide_parent' => 'hide parent', 'function' => 'function'), 'sublabel' => 'Action', 'style' => 'width:auto;'), array('type' => 'text', 'name' => 'Form[extras][fields][' . $k . '][events][' . $i . '][target]', 'sublabel' => 'Target field ID or Function name'))));
        }
        //echo \GCore\Helpers\Html::formLine('add_field_event', array('type' => 'button', 'value' => l_('CF_ADD_EVENT'), 'id' => 'add_field_event_'.$k, 'onclick' => 'addFieldEvent(this, \'add_field_event_'.$k.'\');'));
        echo \GCore\Helpers\Html::formLine('process_field_event', array('type' => 'multi', 'layout' => 'wide', 'inputs' => array(array('type' => 'button', 'name' => 'add_field_event', 'class' => 'btn btn-success', 'value' => l_('CF_ADD_EVENT'), 'id' => 'add_field_event_' . $k, 'onclick' => 'addFieldEvent(this, \'add_field_event_' . $k . '\');'), array('type' => 'button', 'name' => 'remove_field_event', 'class' => 'btn btn-danger', 'value' => l_('CF_REMOVE_EVENT'), 'id' => 'remove_field_event_' . $k, 'onclick' => 'removeFieldEvent(this, \'remove_field_event_' . $k . '\');'))));
        echo \GCore\Helpers\Html::formSecEnd();
        ?>
			</div>
		</div>
		<?php 
        echo \GCore\Helpers\Html::formEnd();
    }
Beispiel #11
0
    public function on_list($fld, $ttl, &$data_columns)
    {
        $config = new \GCore\Libs\Parameter($this->connection['Connection']['extras']['plugins']['download']);
        if ($config->get('path_field') and $config->get('download_action')) {
            $path = $config->get('path_field');
            $action = $config->get('download_action');
            if ($fld == '_DOWNLOAD_.link') {
                $link = r_('index.php?ext=chronoconnectivity&cont=lists&act=' . $action . '&ccname=' . $this->connection['Connection']['title'] . '&gcb={' . $this->model->alias . '.' . $this->model->pkey . '}');
                $text = $ttl;
                if ($config->get('display_icon', 1)) {
                    $text = '<i class="fa fa-download fa-fw"></i> ' . $text;
                }
                $data_columns[$fld]['html'] = '<a class="' . $config->get('download_link_class', 'btn btn-success btn-xs') . '" href="' . $link . '">' . $text . '</a>';
            }
            $file_info = array();
            $file_info['filesize'] = '';
            $file_info['filetime'] = '';
            $file_info['filename'] = '';
            $get_file_info = function ($cell, $row, $column) use($path, $file_info, $config) {
                $file_path = \GCore\Libs\Arr::getVal($row, explode('.', $path));
                if ($config->get('download_path')) {
                    $file_path = rtrim($config->get('download_path'), DS) . DS . $file_path;
                }
                //$file_info = array();
                if (file_exists($file_path)) {
                    if (is_dir($file_path)) {
                        //this is a folder
                        $files = @\GCore\Libs\Folder::getFiles($file_path, false);
                        foreach ($files as $file) {
                            $found[$file] = filemtime($file);
                        }
                        if (empty($found)) {
                            return false;
                        }
                        arsort($found);
                        $files = array_keys($found);
                        sort($files);
                        $file = array_pop($files);
                        $file_info['filesize'] = \GCore\Libs\File::humanSize(filesize($file));
                        $file_info['filetime'] = date($config->get('filetime_format', 'd-m-Y H:i'), filemtime($file));
                        $file_info['filename'] = basename($file);
                    } else {
                        //this is a file
                        $file = $file_path;
                        $file_info['filesize'] = \GCore\Libs\File::humanSize(filesize($file));
                        $file_info['filetime'] = date($config->get('filetime_format', 'd-m-Y H:i'), filemtime($file));
                        $file_info['filename'] = basename($file);
                    }
                }
                foreach ($file_info as $k => $info) {
                    if ($column == '_DOWNLOAD_.' . $k) {
                        return $file_info[$k];
                    }
                }
                return '';
                //$file_info;
            };
            foreach ($file_info as $k => $info) {
                if ($fld == '_DOWNLOAD_.' . $k) {
                    $data_columns[$fld]['function'] = $get_file_info;
                }
            }
            if ($fld == '_HkkITS_.hot') {
                $data_columns[$fld]['function'] = create_function('$value,$row', '
					if(\\GCore\\Libs\\Arr::getVal($row, explode(".", "' . $download . '"), 0) >= (int)' . $config->get('hot_limit', '1000') . '){
						return 1;
					}else{
						return 0;
					}
				');
                $data_columns[$fld]['html'] = array(0 => '', 1 => '<span class="label label-danger">' . $config->get('hot_text', 'Hot') . '</span>');
            }
        }
    }
Beispiel #12
0
	public static function config($data = array(), $k = '{N}'){
		echo \GCore\Helpers\Html::formStart('original_element_config single_element_config', 'input_origin_config');
		?>
		<script>
			function input_enable_tab(elem, SID){
				if(jQuery.inArray(jQuery(elem).val(), ['number', 'range']) != -1){
					jQuery(elem).closest('.config_box').find('.input-special-tab').css('display', 'none');
					jQuery('#input-number-tab-'+SID).css('display', '');
				}else if(jQuery.inArray(jQuery(elem).val(), ['image']) != -1){
					jQuery(elem).closest('.config_box').find('.input-special-tab').css('display', 'none');
					jQuery('#input-image-tab-'+SID).css('display', '');
				}else {
					jQuery(elem).closest('.config_box').find('.input-special-tab').css('display', 'none');
				}
			}
		</script>
		<ul class="nav nav-tabs">
			<li><a href="#general-<?php echo $k; ?>" data-g-toggle="tab"><?php echo l_('CF_GENERAL'); ?></a></li>
			<li><a href="#validation-<?php echo $k; ?>" data-g-toggle="tab"><?php echo l_('CF_VALIDATION'); ?></a></li>
                        <li class="input-special-tab" id="input-number-tab-<?php echo $k; ?>" style="<?php echo (empty($data['input_type']) || in_array($data['input_type'], array('number','range'))) ? '' : 'display:none;'; ?>"><a href="#number-<?php echo $k; ?>" data-g-toggle="tab"><?php echo l_('CF_INPUT_NUMBER'); ?></a></li>
			<li class="input-special-tab" id="input-image-tab-<?php echo $k; ?>" style="<?php echo (!empty($data['input_type']) && in_array($data['input_type'], array('image'))) ? '' : 'display:none;'; ?>"><a href="#image-<?php echo $k; ?>" data-g-toggle="tab"><?php echo l_('CF_INPUT_IMAGE'); ?></a></li>
		</ul>
		<div class="tab-content">
			<div id="general-<?php echo $k; ?>" class="tab-pane">
			<?php
			echo \GCore\Helpers\Html::formSecStart();
			foreach(self::$configs as $name => $params){
				$value = \GCore\Libs\Arr::getVal($data, explode('.', $name));
				$field_name = implode('][', explode('.', $name));
				$params['value'] = $value ? (($params['type'] == 'text') ? htmlspecialchars($value, ENT_QUOTES) : $value) : (isset($params['value']) ? $params['value'] : '');
				$params['values'] = $value ? $value : (isset($params['values']) ? $params['values'] : '');
				echo \GCore\Helpers\Html::formLine('Form[extras][fields]['.$k.']['.$field_name.']', $params);
			}
			echo \GCore\Helpers\Html::input('Form[extras][fields]['.$k.'][type]', array('type' => 'hidden', 'value' => self::$settings['type']));
			echo \GCore\Helpers\Html::formSecEnd();
			?>
			</div>
			<div id="validation-<?php echo $k; ?>" class="tab-pane">
			<?php
			echo \GCore\Helpers\Html::formSecStart();
			echo \GCore\Helpers\Html::formLine('Form[extras][fields]['.$k.'][validation][required]', array('type' => 'dropdown', 'label' => l_('CF_REQUIRED'), 'options' => array('' => l_('NO'), 1 => l_('YES'))));
			echo \GCore\Helpers\Html::formLine('Form[extras][fields]['.$k.'][validation][alpha]', array('type' => 'dropdown', 'label' => l_('CF_ALPHA'), 'options' => array('' => l_('NO'), 1 => l_('YES'))));
			echo \GCore\Helpers\Html::formLine('Form[extras][fields]['.$k.'][validation][alphanum]', array('type' => 'dropdown', 'label' => l_('CF_ALPHA_NUMERIC'), 'options' => array('' => l_('NO'), 1 => l_('YES'))));
			echo \GCore\Helpers\Html::formLine('Form[extras][fields]['.$k.'][validation][digit]', array('type' => 'dropdown', 'label' => l_('CF_DIGIT'), 'options' => array('' => l_('NO'), 1 => l_('YES'))));
			echo \GCore\Helpers\Html::formLine('Form[extras][fields]['.$k.'][validation][nodigit]', array('type' => 'dropdown', 'label' => l_('CF_NO_DIGIT'), 'options' => array('' => l_('NO'), 1 => l_('YES'))));
			echo \GCore\Helpers\Html::formLine('Form[extras][fields]['.$k.'][validation][nospace]', array('type' => 'dropdown', 'label' => l_('CF_NO_SPACE'), 'options' => array('' => l_('NO'), 1 => l_('YES'))));
			echo \GCore\Helpers\Html::formLine('Form[extras][fields]['.$k.'][validation][number]', array('type' => 'dropdown', 'label' => l_('CF_NUMBER'), 'options' => array('' => l_('NO'), 1 => l_('YES'))));
			echo \GCore\Helpers\Html::formLine('Form[extras][fields]['.$k.'][validation][email]', array('type' => 'dropdown', 'label' => l_('CF_EMAIL'), 'options' => array('' => l_('NO'), 1 => l_('YES'))));
			echo \GCore\Helpers\Html::formLine('Form[extras][fields]['.$k.'][validation][phone]', array('type' => 'dropdown', 'label' => l_('CF_PHONE'), 'options' => array('' => l_('NO'), 1 => l_('YES'))));
			echo \GCore\Helpers\Html::formLine('Form[extras][fields]['.$k.'][validation][phone_inter]', array('type' => 'dropdown', 'label' => l_('CF_INT_PHONE'), 'options' => array('' => l_('NO'), 1 => l_('YES'))));
			echo \GCore\Helpers\Html::formLine('Form[extras][fields]['.$k.'][validation][url]', array('type' => 'dropdown', 'label' => l_('CF_URL'), 'options' => array('' => l_('NO'), 1 => l_('YES'))));
			echo \GCore\Helpers\Html::formLine('Form[extras][fields]['.$k.'][validation][confirm]', array('type' => 'text', 'label' => l_('CF_VALIDATE_CONFIRM'), 'sublabel' => l_('CF_VALIDATE_CONFIRM_DESC')));
			echo \GCore\Helpers\Html::formLine('Form[extras][fields]['.$k.'][validation][custom]', array('type' => 'text', 'label' => l_('CF_VALIDATE_CUSTOM'), 'sublabel' => l_('CF_VALIDATE_CUSTOM_DESC')));
			echo \GCore\Helpers\Html::formSecEnd();
			?>
			</div>
			<div id="number-<?php echo $k; ?>" class="tab-pane">
			<?php
			echo \GCore\Helpers\Html::formSecStart();
			echo \GCore\Helpers\Html::formLine('Form[extras][fields]['.$k.'][number][min]', array('type' => 'number', 'value' => 1, 'label' => l_('CF_INPUT_NUMBER_MIN')));
			echo \GCore\Helpers\Html::formLine('Form[extras][fields]['.$k.'][number][max]', array('type' => 'number', 'value' => 10, 'label' => l_('CF_INPUT_NUMBER_MAX')));
			echo \GCore\Helpers\Html::formLine('Form[extras][fields]['.$k.'][number][step]', array('type' => 'number', 'value' => 1, 'label' => l_('CF_INPUT_NUMBER_STEP')));
			echo \GCore\Helpers\Html::formSecEnd();
			?>
			</div>
			<div id="image-<?php echo $k; ?>" class="tab-pane">
			<?php
			echo \GCore\Helpers\Html::formSecStart();
			echo \GCore\Helpers\Html::formLine('Form[extras][fields]['.$k.'][image][src]', array('type' => 'text', 'value' => '', 'label' => l_('CF_INPUT_IMAGE_SRC')));
			echo \GCore\Helpers\Html::formLine('Form[extras][fields]['.$k.'][image][alt]', array('type' => 'text', 'value' => '', 'label' => l_('CF_INPUT_IMAGE_ALT')));
			echo \GCore\Helpers\Html::formSecEnd();
			?>
			</div>
		</div>
		<?php
		echo \GCore\Helpers\Html::formEnd();
	}
Beispiel #13
0
 function _initialize()
 {
     //$this->area = 'front';
     $session = \GCore\Libs\Base::getSession();
     if ($this->get('ccname', null)) {
         $this->data['ccname'] = $this->get('ccname');
     }
     if (!empty($this->data['ccname'])) {
         $this->connection = $connection = $this->Connection->find('first', array('conditions' => array('title' => $this->data['ccname'], 'published' => 1)));
         if (!empty($connection['Connection']['extras']['models']['name'][1]) and !empty($connection['Connection']['extras']['models']['tablename'][1])) {
             $dbo_config = array();
             if (!empty($connection['Connection']['extras']['ndb']['enabled'])) {
                 $dbo_config = array('type' => $connection['Connection']['extras']['ndb']['driver'], 'host' => $connection['Connection']['extras']['ndb']['host'], 'name' => $connection['Connection']['extras']['ndb']['database'], 'user' => $connection['Connection']['extras']['ndb']['user'], 'pass' => $connection['Connection']['extras']['ndb']['password'], 'prefix' => $connection['Connection']['extras']['ndb']['prefix']);
             }
             //primary model available
             \GCore\Libs\GModel::generateModel(trim($connection['Connection']['extras']['models']['name'][1]), array('tablename' => trim($connection['Connection']['extras']['models']['tablename'][1]), 'dbo_config' => $dbo_config));
             $pmodel = '\\GCore\\Models\\' . $connection['Connection']['extras']['models']['name'][1];
             $this->pmodel = $pmodel::getInstance();
             $this->connection_models[$this->pmodel->alias] = $this->pmodel;
             //find secondary models if available
             foreach ($this->connection['Connection']['extras']['models']['name'] as $k => $name) {
                 if ($k != 1) {
                     $name = trim($this->connection['Connection']['extras']['models']['name'][$k]);
                     $tablename = trim($this->connection['Connection']['extras']['models']['tablename'][$k]);
                     $pkey = !empty($this->connection['Connection']['extras']['models']['pkey'][$k]) ? trim($this->connection['Connection']['extras']['models']['pkey'][$k]) : NULL;
                     if (!empty($name) and !empty($tablename)) {
                         \GCore\Libs\GModel::generateModel($name, array('tablename' => $tablename, 'pkey' => $pkey, 'dbo_config' => $dbo_config));
                         //setup relation to primary if exists
                         $relation = $this->connection['Connection']['extras']['models']['relation'][$k];
                         if (!empty($relation)) {
                             $relation_settings = array('className' => '\\GCore\\Models\\' . $name);
                             if (!empty($this->connection['Connection']['extras']['models']['foreignKey'][$k])) {
                                 $relation_settings['foreignKey'] = trim($this->connection['Connection']['extras']['models']['foreignKey'][$k]);
                             }
                             if (!empty($this->connection['Connection']['extras']['models']['assoc_save'][$k])) {
                                 $relation_settings['save_on_save'] = true;
                             }
                             if (!empty($this->connection['Connection']['extras']['models']['assoc_delete'][$k])) {
                                 $relation_settings['delete_on_delete'] = true;
                             }
                             if (!empty($this->connection['Connection']['extras']['models']['conditions'][$k])) {
                                 $conditions = eval('?>' . $this->connection['Connection']['extras']['models']['conditions'][$k]);
                                 $relation_settings['conditions'] = is_array($conditions) ? $conditions : array();
                             }
                             if (!empty($this->connection['Connection']['extras']['models']['join_conditions'][$k])) {
                                 $join_conditions = eval('?>' . $this->connection['Connection']['extras']['models']['join_conditions'][$k]);
                                 $relation_settings['join_conditions'] = is_array($join_conditions) ? $join_conditions : array();
                             }
                             if (!empty($this->connection['Connection']['extras']['models']['join_type'][$k])) {
                                 $relation_settings['type'] = $this->connection['Connection']['extras']['models']['join_type'][$k];
                             }
                             if (!empty($this->connection['Connection']['extras']['models']['fields'][$k])) {
                                 $relation_settings['fields'] = $this->_process_fields_list($this->connection['Connection']['extras']['models']['fields'][$k]);
                             }
                             if (!empty($this->connection['Connection']['extras']['models']['order'][$k])) {
                                 $relation_settings['order'] = $this->_process_fields_list($this->connection['Connection']['extras']['models']['order'][$k]);
                             }
                             if (!empty($this->connection['Connection']['extras']['models']['group'][$k])) {
                                 $relation_settings['group'] = $this->_process_fields_list($this->connection['Connection']['extras']['models']['group'][$k]);
                             }
                             if (empty($this->connection['Connection']['extras']['models']['associated_model'][$k])) {
                                 $this->pmodel->bindModels($relation, array($name => $relation_settings));
                                 $this->connection_models[$name] = $this->pmodel->{$name};
                             } else {
                                 $associated_model = $this->connection['Connection']['extras']['models']['associated_model'][$k];
                                 $associated_model_class = '\\GCore\\Models\\' . $this->connection['Connection']['extras']['models']['associated_model'][$k];
                                 if ($associated_model == $this->pmodel->alias) {
                                     $this->pmodel->bindModels($relation, array($name => $relation_settings));
                                     $this->connection_models[$name] = $this->pmodel->{$name};
                                 } else {
                                     $check_model = $this->pmodel;
                                     check_again:
                                     if (in_array($associated_model, array_keys($check_model->associated_models))) {
                                         $check_model->{$associated_model}->bindModels($relation, array($name => $relation_settings));
                                         $this->connection_models[$name] = $check_model->{$associated_model}->{$name};
                                     } else {
                                         $sub_models = array_keys($check_model->associated_models);
                                         foreach ($sub_models as $sub_model) {
                                             $check_model = $sub_model;
                                             goto check_again;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         } else {
             $session->setFlash('error', l_('CONN_CONNECTION_NOT_FOUND'));
             return false;
         }
     } else {
         $session->setFlash('error', l_('CONN_NO_CONNECTION_NAME'));
         return false;
     }
     //check permissions
     if (!empty($this->connection['Connection']['extras'][$this->area]['permissions'][$this->action])) {
         $gcb = $this->Request->data('gcb', null);
         $owner_id = null;
         if ($this->connection['Connection']['extras'][$this->area]['permissions'][$this->action]['owner'] == 1) {
             if (!empty($gcb) and !empty($this->connection['Connection']['extras'][$this->area]['permissions_conf']['owner_id_column'])) {
                 $user_id_column = $this->connection['Connection']['extras'][$this->area]['permissions_conf']['owner_id_column'];
                 $records = $this->pmodel->find('all', array('recursive' => -1, 'fields' => array($this->pmodel->pkey, $user_id_column), 'conditions' => array($this->pmodel->pkey => $gcb)));
                 if (strpos($user_id_column, '.') === false) {
                     $user_id_column = $this->pmodel->alias . '.' . $user_id_column;
                 }
                 $owners = \GCore\Libs\Arr::getVal($records, explode('.', '[n].' . $user_id_column));
                 $owners = array_values(array_unique($owners));
                 if (count($owners) > 1) {
                     goto check_all;
                 } else {
                     $owner_id = $owners[0];
                 }
             }
         }
         check_all:
         if (!\GCore\Libs\Authorize::check_rules($this->connection['Connection']['extras'][$this->area]['permissions'][$this->action], \GCore\Libs\Authenticate::get_user_groups(), $owner_id)) {
             $session->setFlash('error', l_('CONNECTIVITY_ACCESS_DENIED'));
             return false;
         }
     }
     //load plugins
     if (!empty($this->pmodel)) {
         if (!empty($this->connection['Connection']['extras'][$this->area]['display']['page_limit']) and is_numeric($this->connection['Connection']['extras'][$this->area]['display']['page_limit'])) {
             $this->pmodel->page_limit = (int) $this->connection['Connection']['extras'][$this->area]['display']['page_limit'];
         }
         //run plugins
         if (!empty($this->connection['Connection']['extras']['plugins'])) {
             //sort plugins execution
             $plugins_priority = array();
             foreach ($this->connection['Connection']['extras']['plugins'] as $plg => $plg_data) {
                 $plugins_priority[$plg] = \GCore\Libs\Arr::getVal($plg_data, array('priority'), 0);
             }
             array_multisort($plugins_priority, SORT_DESC, $this->connection['Connection']['extras']['plugins']);
             foreach ($this->connection['Connection']['extras']['plugins'] as $plugin => $plugin_data) {
                 if (!empty($plugin_data['enabled'])) {
                     $this->plugins[] = $plugin;
                     if (class_exists('\\GCore\\Admin\\Extensions\\Chronoconnectivity\\Plugins\\' . \GCore\Libs\Str::camilize($plugin) . '\\' . \GCore\Libs\Str::camilize($plugin . '_helper'))) {
                         $plugin_helper = '\\GCore\\Admin\\Extensions\\Chronoconnectivity\\Plugins\\' . \GCore\Libs\Str::camilize($plugin) . '\\' . \GCore\Libs\Str::camilize($plugin . '_helper');
                         $this->helpers[$plugin_helper]['connection'] = $this->connection;
                         $this->helpers[$plugin_helper]['model'] = $this->pmodel;
                     }
                 }
             }
         }
         $this->helpers['\\GCore\\Admin\\Extensions\\Chronoconnectivity\\Helpers\\Plugin']['plugins'] = $this->plugins;
         $this->_process_plugins('on_initialize', $this);
     }
 }
Beispiel #14
0
 function data($key, $default = null)
 {
     //check POST
     $value = \GCore\Libs\Arr::getVal($this->data, explode('.', $key), null);
     if (!is_null($value)) {
         return $value;
     }
     //return default
     return $default;
 }
 function save()
 {
     $session = \GCore\Libs\Base::getSession();
     parent::_settings('chronoforms');
     $chronoforms_settings = new \GCore\Libs\Parameter($this->data['Chronoforms']);
     if ($chronoforms_settings->get('wizard.safe_save', 1)) {
         $s_form = array();
         //parse_str($this->data['serialized_form_data'], $s_form);
         if (!empty($this->data['serialized_form_data_chunks'])) {
             $chunks = $this->data['serialized_form_data_chunks'];
             $this->data['serialized_form_data'] = implode('', $chunks);
         }
         $pairs = explode('&', $this->data['serialized_form_data']);
         $result = array();
         foreach ($pairs as $pair) {
             $dummy = array();
             parse_str($pair, $dummy);
             $path = array();
             self::extract_array_path($dummy, $path);
             $path = implode('.', $path);
             $new_path = explode('.', $path);
             //check if the last path item is numeric, then its an array of values
             if (is_numeric($new_path[count($new_path) - 1])) {
                 $value = \GCore\Libs\Arr::getVal($dummy, $new_path);
                 $last_numeric_index = $new_path[count($new_path) - 1];
                 unset($new_path[count($new_path) - 1]);
                 $existing_results = (array) \GCore\Libs\Arr::getVal($result, $new_path, array());
                 if (!in_array($last_numeric_index, array_keys($existing_results))) {
                     $existing_results[$last_numeric_index] = $value;
                 } else {
                     $existing_results[] = $value;
                 }
                 $result = \GCore\Libs\Arr::setVal($result, $new_path, $existing_results);
                 continue;
             }
             if (in_array('{N}', $new_path) !== false) {
                 continue;
             }
             $result = \GCore\Libs\Arr::setVal($result, $new_path, \GCore\Libs\Arr::getVal($dummy, $new_path));
         }
         $s_form = $result;
         $this->data = $s_form;
     }
     $result = parent::_save();
     if ($result) {
         $this->_limit_forms();
         if ($this->Request->get('save_act') == 'apply') {
             $this->redirect(r_('index.php?ext=chronoforms&act=edit&id=' . $this->Form->id));
         } else {
             $session->setFlash('success', sprintf(l_('CF_FORM_X_HAS_BEEN_UPDATED'), $this->data['Form']['title']));
             $this->redirect(r_('index.php?ext=chronoforms'));
         }
     } else {
         $this->edit();
         $this->view = 'edit';
         $session->setFlash('error', \GCore\Libs\Arr::flatten($this->Form->errors));
     }
 }
Beispiel #16
0
 function dispatch($content_only = false)
 {
     Event::trigger('on_before_dispatch', $this);
     $session = Base::getSession();
     reset:
     //if no action set, set it to index
     if (strlen(trim($this->action)) == 0) {
         $this->action = 'index';
     }
     //set admin path
     $site = '';
     if ($this->site == 'admin') {
         $site = '\\Admin';
     }
     //load the extension class
     $controller = !empty($this->controller) ? '\\Controllers\\' . Str::camilize($this->controller) : '\\' . Str::camilize($this->extension);
     $extension = !empty($this->extension) ? '\\Extensions\\' . Str::camilize($this->extension) : '';
     $classname = '\\GCore' . $site . $extension . $controller;
     $this->tvout = strlen(Request::data('tvout', null)) > 0 ? Request::data('tvout') : $this->tvout;
     //set referer
     if (!$content_only) {
         if (!($this->controller == 'users' and ($this->action == 'login' or $this->action == 'logout' or $this->action == 'register')) and (!empty($this->extension) or !empty($this->controller)) and $this->tvout == 'index') {
             //$session->set('_referer', Url::current());
         } else {
             //$session->set('_referer', 'index.php');
         }
     }
     $G_User = $session->get('user', array());
     //check permissions
     $J_User = \JFactory::getUser();
     if (empty($J_User->groups) or empty($G_User['groups']) or array_values($J_User->groups) !== $G_User['groups'] or empty($G_User['inheritance'])) {
         $user_session = array();
         $user_session['id'] = $J_User->id;
         $user_session['name'] = $J_User->name;
         $user_session['username'] = $J_User->username;
         $user_session['email'] = $J_User->email;
         $user_session['last_login'] = $J_User->lastvisitDate;
         $user_session['logged_in'] = !$J_User->guest;
         $user_session['guest'] = $J_User->guest;
         $user_session['groups'] = empty($J_User->groups) ? array(1) : array_values($J_User->groups);
         $user_session['inheritance'] = array();
         if (!empty($J_User->groups)) {
             //sort groups
             $groups = \GCore\Admin\Models\Group::getInstance()->find('all', array('order' => 'Group.parent_id ASC'));
             $valid_groups = array_intersect($user_session['groups'], \GCore\Libs\Arr::getVal($groups, array('[n]', 'Group', 'id')));
             if (!empty($groups) and $valid_groups) {
                 reloop:
                 foreach ($groups as $group) {
                     //if this group exists in the user's groups or its inheitance then add its parent_id
                     if (in_array($group['Group']['id'], $user_session['groups']) or in_array($group['Group']['id'], $user_session['inheritance'])) {
                         $user_session['inheritance'][] = $group['Group']['parent_id'];
                     }
                 }
                 //find the number of occurances of each group in the inheritane
                 $groups_counted = array_count_values($user_session['inheritance']);
                 //if the count of root parent (0 parent_id) is less than the count of user's groups then not all pathes have been found, reloop
                 if (count($user_session['groups']) and !isset($groups_counted[0]) or $groups_counted[0] < count($user_session['groups'])) {
                     goto reloop;
                 } else {
                     $user_session['inheritance'] = array_unique($user_session['inheritance']);
                 }
             }
         }
         if ($session->get('user', array()) !== $user_session) {
             $session->clear('acos_permissions');
         }
         $session->set('user', array_merge($session->get('user', array()), $user_session));
     }
     //copy some config
     $mainframe = \JFactory::getApplication();
     //set timezone
     date_default_timezone_set($mainframe->getCfg('offset'));
     //site title
     \GCore\Libs\Base::setConfig('site_title', $mainframe->getCfg('sitename'));
     //$lang = \JFactory::getLanguage();
     //\GCore\Libs\Base::setConfig('site_language', $lang->getTag());
     /*if(!Authorize::authorized($classname, $this->action)){
     			if($content_only){
     				return;
     			}
     			$this->redirect(r_('index.php?cont=users&act=login'));
     		}*/
     //if the extension class not found or the action function not found then load an error
     if (!class_exists($classname) or !in_array($this->action, get_class_methods($classname)) and !in_array('__call', get_class_methods($classname)) or substr($this->action, 0, 1) == '_') {
         $this->controller = 'errors';
         $this->action = 'e404';
         //reset the controller
         //$classname = '\GCore\Controllers\Errors';
         $this->buffer = 'Page not found';
         \GCore\Libs\Env::e404();
         \JError::raiseError(404, $this->buffer);
         //we need the rendered content only
         if ($content_only) {
             return;
         }
     }
     //load language file
     if (!empty($extension)) {
         Lang::load($site . $extension);
     }
     //set theme
     $doc = Document::getInstance($this->site, $this->thread);
     $doc->theme = 'bootstrap3';
     $theme = \GCore\Helpers\Theme::getInstance();
     //load class and run the action
     ${$classname} = new $classname($this->site, $this->thread);
     ob_start();
     $continue = ${$classname}->_initialize();
     //check and read cache
     if (!empty(${$classname}->cache)) {
         if (!is_array(${$classname}->cache)) {
             ${$classname}->cache = array();
         }
         if (empty(${$classname}->cache['time'])) {
             ${$classname}->cache['time'] = Base::getConfig('app_cache_expiry', 900);
         }
         if (empty(${$classname}->cache['title'])) {
             ${$classname}->cache['title'] = File::makeSafe($classname . '_' . $this->action);
         } else {
             ${$classname}->cache['title'] = File::makeSafe(${$classname}->cache['title']);
         }
         if (empty(${$classname}->cache['key'])) {
             ${$classname}->cache['key'] = 'cached_view';
         } else {
             ${$classname}->cache['key'] = 'cached_view_' . ${$classname}->cache['key'];
         }
         $cache = Cache::getInstance(${$classname}->cache['title'], array('expiration' => ${$classname}->cache['time']));
         $cached_view = $cache->get(${$classname}->cache['key']);
         $cached = false;
         if (!empty($cached_view)) {
             $cached = true;
             $continue = false;
             echo $cached_view;
         }
     }
     if ($continue !== false) {
         ${$classname}->{$this->action}();
         if ($this->reset === true) {
             $this->reset = false;
             goto reset;
         }
         //initialize and render view
         $view = new View();
         $view->initialize(${$classname});
         $view->renderView($this->action);
     }
     //get the action output buffer
     $this->buffer = ob_get_clean();
     //check and save cache
     if (!empty(${$classname}->cache) and !$cached) {
         $cache = Cache::getInstance(${$classname}->cache['title'], array('expiration' => ${$classname}->cache['time']));
         $cache->set(${$classname}->cache['key'], $this->buffer);
     }
     //finalize
     ob_start();
     ${$classname}->_finalize();
     $this->buffer .= ob_get_clean();
     if ($this->tvout != 'ajax' and $doc->theme == 'bootstrap3') {
         $this->buffer = '<div class="gbs3">' . $this->buffer . '</div>';
     }
     //Event::trigger('on_after_dispatch');
 }
 private static function _select(&$html, $data, $skipped)
 {
     //select boxes
     $pattern = '/<select(.*?)select>/is';
     preg_match_all($pattern, $html, $matches);
     if (!empty($matches)) {
         foreach ($matches[0] as $field) {
             $ghost_pat = '/alt=["-\']ghost["-\']|data-ghost=["-\']1["-\']/i';
             preg_match($ghost_pat, $field, $ghost_attr);
             if (!empty($ghost_attr[0])) {
                 continue;
             }
             $updated_field = $field;
             $sel_pat = '/<select([^>]*?)>/is';
             preg_match_all($sel_pat, $field, $sel_matches);
             $extracted_options = preg_replace(array('/' . preg_quote($sel_matches[0][0]) . '/is', '/<\\/select>/i'), array('', ''), $field);
             $n_pat = '/ name=("|\')(.*?)("|\')/i';
             $v_pat = '/ value=("|\')(.*?)(\\1)/i';
             $opt_pat = '/<option(.*?)<\\/option>/is';
             $slct_pat = '/selected=("|\')selected("|\')/i';
             preg_match($n_pat, $sel_matches[0][0], $name_attr);
             $name = self::_dotname($name_attr[2], true);
             $value = \GCore\Libs\Arr::getVal($data, explode('.', $name));
             if (!in_array($name, $skipped) and !is_null($value)) {
                 preg_match_all($opt_pat, $extracted_options, $matched_options);
                 foreach ($matched_options[0] as $matched_option) {
                     preg_match($v_pat, $matched_option, $matched_option_value);
                     $updated_option = $matched_option;
                     if (isset($matched_option_value[2]) and (in_array($matched_option_value[2], (array) $value) or in_array(htmlspecialchars_decode($matched_option_value[2], ENT_QUOTES), (array) $value))) {
                         $updated_option = preg_replace('/<option/i', '<option selected="selected"', $matched_option);
                     } elseif (isset($matched_option_value[2]) and !in_array($matched_option_value[2], (array) $value) and !in_array(htmlspecialchars_decode($matched_option_value[2], ENT_QUOTES), (array) $value)) {
                         //remove any preset selected
                         $updated_option = preg_replace($slct_pat, '', $matched_option);
                     } else {
                         //option value doesn't match posted value, do nothing
                         //$updated_option = preg_replace('/<option(.*?)>/is', '<option value="'.$matched_option_value[2].'">', $matched_option);
                     }
                     $updated_field = str_replace($matched_option, $updated_option, $updated_field);
                 }
                 //$html = str_replace($field, $updated_field, $html);
                 $pos = strpos($html, $field);
                 $html = substr_replace($html, $updated_field, $pos, strlen($field));
             }
         }
     }
 }
Beispiel #18
0
 public static function set_cells_data($data_rows = array())
 {
     $data_rows = empty($data_rows) ? self::$items : $data_rows;
     self::$cells_rows = $data_rows;
     foreach ($data_rows as $k => $row) {
         $row = (array) $row;
         foreach (self::$columns as $column) {
             $info = !empty(self::$columns_info[$column]) ? self::$columns_info[$column] : array();
             $r_val = $data = \GCore\Libs\Arr::getVal($row, explode(".", $column));
             if (isset($info['function'])) {
                 if (!is_array($info['function'])) {
                     $data = $info['function']($data, $row, $column);
                 } else {
                     if (isset($info['function'][$r_val])) {
                         $data = $info['function'][$r_val]($data, $row, $column);
                     } elseif (isset($info['function']['*'])) {
                         $_fn = $info['function']['*'];
                         $data = $_fn($data, $row, $column);
                     }
                 }
                 //update the record value based on returned function value
                 $r_val = $data;
             }
             if (isset($info['html'])) {
                 if (!is_array($info['html'])) {
                     $data = $info['html'];
                 } else {
                     if (isset($info['html'][$r_val])) {
                         $data = $info['html'][$r_val];
                     } elseif (isset($info['html']['*'])) {
                         $data = $info['html']['*'];
                     }
                 }
             }
             if (isset($info['image'])) {
                 if (!is_array($info['image'])) {
                     $data = $info['image'];
                 } else {
                     if (isset($info['image'][$r_val])) {
                         $data = $info['image'][$r_val];
                     } elseif (isset($info['image']['*'])) {
                         $data = $info['image']['*'];
                     }
                 }
             }
             if (isset($info['link']) and !empty($data)) {
                 if (!is_array($info['link'])) {
                     if (!empty($info['link'])) {
                         $data = \GCore\Helpers\Html::url($data, $info['link']);
                     }
                 } else {
                     if (isset($info['link'][$r_val])) {
                         if (!empty($info['link'][$r_val])) {
                             $data = \GCore\Helpers\Html::url($data, $info['link'][$r_val]);
                         }
                     } elseif (isset($info['link']['*'])) {
                         $data = \GCore\Helpers\Html::url($data, $info['link']['*']);
                     }
                 }
             }
             if (isset($info['field'])) {
                 if (!is_array($info['field'])) {
                     $data = $info['field'];
                 } else {
                     if (isset($info['field'][$r_val])) {
                         $data = $info['field'][$r_val];
                     } elseif (isset($info['field']['*'])) {
                         $data = $info['field']['*'];
                     }
                 }
                 $data = \GCore\Helpers\DataLoader::load($data, $row);
             }
             if (!strlen($data)) {
                 $data = '';
                 //'&nbsp;';
             }
             self::$cells_data[$k][$column] = $data;
         }
     }
 }
    public static function config($data = array(), $k = '{N}')
    {
        echo \GCore\Helpers\Html::formStart('original_element_config single_element_config', 'datepicker_origin_config');
        ?>
		<ul class="nav nav-tabs">
			<li><a href="#general-<?php 
        echo $k;
        ?>
" data-g-toggle="tab"><?php 
        echo l_('CF_GENERAL');
        ?>
</a></li>
			<li><a href="#advanced-<?php 
        echo $k;
        ?>
" data-g-toggle="tab"><?php 
        echo l_('CF_ADVANCED');
        ?>
</a></li>
			<li><a href="#validation-<?php 
        echo $k;
        ?>
" data-g-toggle="tab"><?php 
        echo l_('CF_VALIDATION');
        ?>
</a></li>
		</ul>
		<div class="tab-content">
			<div id="general-<?php 
        echo $k;
        ?>
" class="tab-pane">
			<?php 
        echo \GCore\Helpers\Html::formSecStart();
        foreach (self::$configs as $name => $params) {
            $value = \GCore\Libs\Arr::getVal($data, explode('.', $name));
            $field_name = implode('][', explode('.', $name));
            $params['value'] = $value ? $params['type'] == 'text' ? htmlspecialchars($value, ENT_QUOTES) : $value : (isset($params['value']) ? $params['value'] : '');
            $params['values'] = $value ? $value : (isset($params['values']) ? $params['values'] : '');
            echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][' . $field_name . ']', $params);
        }
        echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][type]', array('type' => 'hidden', 'value' => self::$settings['type']));
        //echo \GCore\Helpers\Html::input('Form[extras][fields]['.$k.'][:data-gdatetimepicker]', array('type' => 'hidden', 'value' => '1'));
        echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][:data-fieldtype]', array('type' => 'hidden', 'value' => 'gdatetimepicker'));
        echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][container_id]', array('type' => 'hidden', 'id' => 'container_id' . $k, 'value' => '0'));
        echo \GCore\Helpers\Html::formSecEnd();
        ?>
			</div>
			<div id="advanced-<?php 
        echo $k;
        ?>
" class="tab-pane">
			<?php 
        echo \GCore\Helpers\Html::formSecStart();
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][data][start_date]', array('type' => 'text', 'class' => 'XL', 'label' => l_('CF_DATEPICKER_START_DATE'), 'sublabel' => l_('CF_DATEPICKER_START_DATE_DESC')));
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][data][end_date]', array('type' => 'text', 'class' => 'XL', 'label' => l_('CF_DATEPICKER_END_DATE'), 'sublabel' => l_('CF_DATEPICKER_END_DATE_DESC')));
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][data][open_days]', array('type' => 'text', 'class' => 'XL', 'label' => l_('CF_DATEPICKER_OPEN_DAYS'), 'sublabel' => l_('CF_DATEPICKER_OPEN_DAYS_DESC')));
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][data][on_date_selected]', array('type' => 'text', 'class' => 'XL', 'label' => l_('CF_DATEPICKER_ON_DATE_SELECTED'), 'sublabel' => l_('CF_DATEPICKER_ON_DATE_SELECTED_DESC')));
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][data][shortdays]', array('type' => 'text', 'class' => 'XL', 'label' => l_('CF_DATEPICKER_SHORT_DAYS'), 'sublabel' => l_('CF_DATEPICKER_SHORT_DAYS_DESC')));
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][data][shortmonths]', array('type' => 'text', 'class' => 'XL', 'label' => l_('CF_DATEPICKER_SHORT_MONTHS'), 'sublabel' => l_('CF_DATEPICKER_SHORT_MONTHS_DESC')));
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][data][start_view]', array('type' => 'dropdown', 'label' => l_('CF_DATEPICKER_START_VIEW'), 'options' => array('d' => l_('CF_DATEPICKER_DAYS'), 'm' => l_('CF_DATEPICKER_MONTHS'), 'y' => l_('CF_DATEPICKER_YEARS')), 'sublabel' => l_('CF_DATEPICKER_START_VIEW_DESC')));
        echo \GCore\Helpers\Html::formSecEnd();
        ?>
			</div>
			<div id="validation-<?php 
        echo $k;
        ?>
" class="tab-pane">
			<?php 
        echo \GCore\Helpers\Html::formSecStart();
        echo \GCore\Helpers\Html::formLine('Form[extras][fields][' . $k . '][validation][required]', array('type' => 'dropdown', 'label' => l_('CF_REQUIRED'), 'options' => array('' => l_('NO'), 1 => l_('YES'))));
        echo \GCore\Helpers\Html::formSecEnd();
        ?>
			</div>
		</div>
		<?php 
        echo \GCore\Helpers\Html::formEnd();
    }
Beispiel #20
0
 function execute(&$form, $action_id)
 {
     $config = $form->actions_config[$action_id];
     $config = new \GCore\Libs\Parameter($config);
     if (!$config->get('enabled')) {
         return;
     }
     $data_path = trim($config->get('data_path', ''));
     $data = \GCore\Libs\Arr::getVal($form->data, explode('.', $data_path));
     if (!empty($data) and is_array($data)) {
         $data = array_values($data);
         $first_data_record = $data[0];
         $list_fields = strlen(trim($config->get('list_fields', ''))) ? explode(',', trim($config->get('list_fields', ''))) : array_keys($first_data_record);
         $list_headers = strlen(trim($config->get('list_headers', ''))) ? explode(',', trim($config->get('list_headers', ''))) : array_keys($first_data_record);
         $table_rows = '';
         if (strlen(trim($config->get('before_headers', '')))) {
             $table_rows .= '<tr bgcolor="#fff">' . "\n";
             $table_rows .= '<td>' . \GCore\Libs\Arr::getVal($form->data, explode('.', trim($config->get('before_headers', '')))) . '</td>' . "\n";
             $table_rows .= '</tr>' . "\n";
         }
         //add headers
         $table_rows .= '<tr bgcolor="#999999">' . "\n";
         foreach ($list_headers as $k => $v) {
             $table_rows .= '<td style="color:white">' . $v . '</td>' . "\n";
         }
         $table_rows .= '</tr>' . "\n";
         //add data rows
         foreach ($data as $record) {
             $table_rows .= '<tr>' . "\n";
             foreach ($record as $k => $v) {
                 if (!in_array($k, $list_fields)) {
                     continue;
                 }
                 $table_rows .= '<td valign="top" style="mso-number-format:\\@">' . $v . '</td>' . "\n";
             }
             $table_rows .= '</tr>' . "\n";
         }
         //finalize table
         $excel_table = "<table border='1'>" . $table_rows . "</table>";
         if ($config->get('save_file', 0) == 1) {
             $save_path = $config->get('save_path', '') ? $config->get('save_path', '') : \GCore\C::ext_path('chronoforms', 'front') . 'exports' . DS . $form->form['Form']['title'] . DS;
             if (!file_exists($save_path . 'index.html')) {
                 if (!mkdir($save_path, 0755, true)) {
                     $form->debug[$action_id][self::$title] = "Couldn't create save folder: {$save_path}";
                     return;
                 }
                 file_put_contents($save_path . 'index.html', '');
             }
             if ((bool) $config->get('add_bom', 0) === true) {
                 $excel_table = "" . $excel_table;
             }
             $file_name = $config->get('file_name', 'cf_export.xls');
             $saved = file_put_contents($save_path . $file_name, $excel_table);
             if (empty($saved)) {
                 $form->debug[$action_id][self::$title] = "Couldn't create XLS file";
                 return;
             }
             if (strlen($config->get('post_file_name', '')) > 0) {
                 $post_file_name = $config->get('post_file_name', '');
                 $form->data[$post_file_name] = $file_name;
                 $form->files[$post_file_name] = array('name' => $file_name, 'path' => $save_path . $file_name, 'size' => filesize($save_path . $file_name));
                 //$form->files[$post_file_name]['link'] = $save_url.$file_name;
             }
         } else {
             //set headers
             header("Pragma: public");
             header("Expires: 0");
             header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
             header("Content-Type: application/force-download");
             header("Content-Type: application/octet-stream");
             header("Content-Type: application/download");
             header("Content-Disposition: attachment;filename=" . $config->get('file_name', 'cf_export.xls'));
             header("Content-Transfer-Encoding: binary");
             header('Content-Encoding: UTF-8');
             //output data
             @ob_end_clean();
             if ((bool) $config->get('add_bom', 0) === true) {
                 echo "";
             }
             echo $excel_table;
             exit;
         }
     }
 }