コード例 #1
0
ファイル: password.php プロジェクト: vstorm83/propertease
    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();
    }
コード例 #2
0
 function execute(&$form, $action_id)
 {
     $config = $form->actions_config[$action_id];
     $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);
     }
 }
コード例 #3
0
 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;
 }
コード例 #4
0
ファイル: csv_export.php プロジェクト: vstorm83/propertease
 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;
 }
コード例 #5
0
 function array_handler($data = array(), $skipped = array(), $del = ',')
 {
     foreach ($data as $name => $value) {
         if (is_array($value) and !in_array($name, $skipped)) {
             if ($this->config->get('skip_associative', 1) and \GCore\Libs\Arr::is_assoc($value)) {
                 $value = $this->array_handler($value, $skipped, $del);
                 $data[$name] = $value;
                 continue;
             }
             $value = $this->array_handler($value, $skipped, $del);
             $data[$name] = implode($del, $value);
         }
     }
     return $data;
 }
コード例 #6
0
ファイル: recaptcha.php プロジェクト: ejailesb/repo_empr
 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();
 }
コード例 #7
0
ファイル: download.php プロジェクト: BillVGN/PortalPRP
 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');
                     }
                 }
             }
         }
     }
 }
コード例 #8
0
ファイル: message.php プロジェクト: joecacti/diversebuild
 public static function render($types = array())
 {
     if (!empty($types)) {
         //add the system css file
         $doc = \GCore\Libs\Document::getInstance();
         $doc->addCssFile('system_messages');
         $system_messages = array();
         foreach ($types as $type => $messages) {
             $list = array();
             $messages = \GCore\Libs\Arr::normalize($messages);
             foreach ($messages as $message) {
                 $list[] = \GCore\Helpers\Html::container('li', $message, array());
             }
             $ul = \GCore\Helpers\Html::container('ul', implode("\n", $list), array());
             $system_messages[] = self::wrap($ul, $type);
         }
         $system_messages_container = \GCore\Helpers\Html::container('div', implode("\n", $system_messages), array('class' => 'system-message-container'));
         return $system_messages_container;
     }
     return '';
 }
コード例 #9
0
ファイル: input.php プロジェクト: BillVGN/PortalPRP
	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();
	}
コード例 #10
0
    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();
    }
コード例 #11
0
ファイル: xls_export.php プロジェクト: vstorm83/propertease
 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;
         }
     }
 }
コード例 #12
0
ファイル: chronoforms.php プロジェクト: vstorm83/propertease
 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));
     }
 }
コード例 #13
0
ファイル: data_presenter.php プロジェクト: ejailesb/repo_empr
 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;
         }
     }
 }
コード例 #14
0
ファイル: app_j.php プロジェクト: vstorm83/propertease
 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');
 }
コード例 #15
0
ファイル: email.php プロジェクト: joecacti/diversebuild
 function execute(&$form, $action_id)
 {
     $config = $form->actions_config[$action_id];
     $config = new \GCore\Libs\Parameter($config);
     ob_start();
     eval('?>' . $config->get('template', ''));
     $body = ob_get_clean();
     $others = array();
     //get recipient
     $tos = array();
     if (strlen(trim($config->get('to', '')))) {
         $tos = explode(',', \GCore\Libs\Str::replacer(trim($config->get('to', '')), $form->data));
     }
     if (strlen(trim($config->get('dto', '')))) {
         $dtos = explode(',', trim($config->get('dto', '')));
         foreach ($dtos as $dto) {
             $d_email = explode(',', $form->data($dto));
             $tos = array_merge((array) $d_email, $tos);
         }
     }
     $ccs = array();
     if (strlen(trim($config->get('cc', '')))) {
         $ccs = explode(',', \GCore\Libs\Str::replacer(trim($config->get('cc', '')), $form->data));
     }
     if (strlen(trim($config->get('dcc', '')))) {
         $dccs = explode(',', trim($config->get('dcc', '')));
         foreach ($dccs as $dcc) {
             $d_email = explode(',', $form->data($dcc));
             $ccs = array_merge((array) $d_email, $ccs);
         }
     }
     $others['cc'] = $ccs;
     $bccs = array();
     if (strlen(trim($config->get('bcc', '')))) {
         $bccs = explode(',', \GCore\Libs\Str::replacer(trim($config->get('bcc', '')), $form->data));
     }
     if (strlen(trim($config->get('dbcc', '')))) {
         $dbccs = explode(',', trim($config->get('dbcc', '')));
         foreach ($dbccs as $dbcc) {
             $d_email = explode(',', $form->data($dbcc));
             $bccs = array_merge((array) $d_email, $bccs);
         }
     }
     $others['bcc'] = $bccs;
     //subject
     $subject = trim($config->get('subject', '')) ? \GCore\Libs\Str::replacer($config->get('subject', ''), $form->data) : $form->data($config->get('dsubject', ''));
     //from
     $others['from_name'] = trim($config->get('from_name', '')) ? \GCore\Libs\Str::replacer($config->get('from_name', ''), $form->data) : $form->data($config->get('dfrom_name'), null);
     $others['from_email'] = trim($config->get('from_email', '')) ? \GCore\Libs\Str::replacer($config->get('from_email', ''), $form->data) : $form->data($config->get('dfrom_email'), null);
     //reply to
     $others['reply_name'] = trim($config->get('reply_name', '')) ? \GCore\Libs\Str::replacer($config->get('reply_name', ''), $form->data) : $form->data($config->get('dreply_name'), null);
     $others['reply_email'] = trim($config->get('reply_email', '')) ? \GCore\Libs\Str::replacer($config->get('reply_email', ''), $form->data) : $form->data($config->get('dreply_email'), null);
     $others['type'] = $config->get('email_type', 'html');
     $form->data['ip_address'] = $_SERVER['REMOTE_ADDR'];
     if ($others['type'] == 'html') {
         if ($config->get('append_ip_address', 1)) {
             $body = $body . "<br /><br />" . "IP: {ip_address}";
         }
         $body = \GCore\Libs\Str::replacer($body, $form->data, array('replace_null' => true, 'nl2br' => true, 'repeater' => 'repeater'));
     } else {
         if ($config->get('append_ip_address', 1)) {
             $body = $body . "\n\n" . "IP: {ip_address}";
         }
         $body = \GCore\Libs\Str::replacer($body, $form->data, array('replace_null' => true, 'repeater' => 'repeater'));
     }
     //attach
     $attachments = array();
     if (strlen(trim($config->get('attach', '')))) {
         ob_start();
         $attach_fields = eval('?>' . trim($config->get('attach', '')));
         ob_end_clean();
         if (is_array($attach_fields)) {
             $attachs = array_keys($attach_fields);
             foreach ($form->files as $name => $file) {
                 if (in_array($name, $attachs)) {
                     if (\GCore\Libs\Arr::is_assoc($file)) {
                         $attachments[] = array_merge($attach_fields[$name], array('path' => $file['path']));
                     } else {
                         foreach ($file as $fi => $fv) {
                             //$attachments[] = $fv['path'];
                             $attachments[] = array_merge($attach_fields[$name], array('path' => $fv['path']));
                         }
                     }
                 }
             }
         } else {
             $attachs = explode(',', trim($config->get('attach', '')));
             foreach ($form->files as $name => $file) {
                 if (in_array($name, $attachs)) {
                     if (\GCore\Libs\Arr::is_assoc($file)) {
                         $attachments[] = $file['path'];
                     } else {
                         foreach ($file as $fi => $fv) {
                             $attachments[] = $fv['path'];
                         }
                     }
                 }
             }
         }
     }
     //load global settings
     $settings = $form::_settings();
     if (!empty($settings['mail'])) {
         if (!empty($settings['mail']['smtp']) and empty($settings['mail']['mail_method'])) {
             $settings['mail']['mail_method'] = 'smtp';
         }
         foreach ($settings['mail'] as $k => $v) {
             \GCore\Libs\Base::setConfig($k, $v);
         }
     }
     //encrypt the email
     if ($config->get('encrypt_enabled', 0) == 1 and class_exists('Crypt_GPG')) {
         $mySecretKeyId = trim($config->get('gpg_sec_key', ''));
         //Add Encryption key here
         $gpg = new Crypt_GPG();
         $gpg->addEncryptKey($mySecretKeyId);
         $body = $gpg->encrypt($body);
     }
     $sent = \GCore\Libs\Mailer::send($tos, $subject, $body, $attachments, $others);
     if ($sent) {
         $form->debug[$action_id][self::$title][] = "An email with the details below was sent successfully:";
     } else {
         $form->debug[$action_id][self::$title][] = "An email with the details below could NOT be sent:";
     }
     $form->debug[$action_id][self::$title][] = "To:" . implode(", ", $tos);
     $form->debug[$action_id][self::$title][] = "Subject:" . $subject;
     $form->debug[$action_id][self::$title][] = "From name:" . $others['from_name'];
     $form->debug[$action_id][self::$title][] = "From email:" . $others['from_email'];
     $form->debug[$action_id][self::$title][] = "CC:" . implode(", ", $ccs);
     $form->debug[$action_id][self::$title][] = "BCC:" . implode(", ", $bccs);
     $form->debug[$action_id][self::$title][] = "Reply name:" . $others['reply_name'];
     $form->debug[$action_id][self::$title][] = "Reply email:" . $others['reply_email'];
     $form->debug[$action_id][self::$title][] = "Attachments:";
     $form->debug[$action_id][self::$title][] = $attachments;
     $form->debug[$action_id][self::$title][] = "Body:\n" . $body;
 }
コード例 #16
0
ファイル: radio.php プロジェクト: vstorm83/propertease
    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();
    }
コード例 #17
0
 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));
     }
 }
コード例 #18
0
ファイル: lister.php プロジェクト: BillVGN/PortalPRP
 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;
 }
コード例 #19
0
ファイル: lists.php プロジェクト: BillVGN/PortalPRP
 function save()
 {
     $this->save_model = $this->pmodel;
     $result = parent::_save();
     if ($result) {
         if ($this->Request->get('save_act') == 'apply') {
             $this->redirect(r_('index.php?ext=chronoconnectivity&cont=lists&act=edit&ccname=' . $this->connection['Connection']['title'] . '&gcb=' . $this->pmodel->id));
         } else {
             $this->redirect(r_('index.php?ext=chronoconnectivity&cont=lists&act=index&ccname=' . $this->connection['Connection']['title']));
         }
     } else {
         $this->edit();
         $this->view = 'edit';
         $session = \GCore\Libs\Base::getSession();
         $session->setFlash('error', \GCore\Libs\Arr::flatten($this->pmodel->errors));
     }
 }
コード例 #20
0
ファイル: form.php プロジェクト: ejailesb/repo_empr
 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;
 }
コード例 #21
0
 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));
             }
         }
     }
 }
コード例 #22
0
ファイル: download_helper.php プロジェクト: BillVGN/PortalPRP
    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>');
            }
        }
    }
コード例 #23
0
    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();
    }
コード例 #24
0
 function save()
 {
     //check the new database connection details
     if (!empty($this->data['Connection']['extras']['ndb']['enabled'])) {
         $dbo_config = array('type' => $this->data['Connection']['extras']['ndb']['driver'], 'host' => $this->data['Connection']['extras']['ndb']['host'], 'name' => $this->data['Connection']['extras']['ndb']['database'], 'user' => $this->data['Connection']['extras']['ndb']['user'], 'pass' => $this->data['Connection']['extras']['ndb']['password'], 'prefix' => $this->data['Connection']['extras']['ndb']['prefix']);
         $tables = \GCore\Libs\Database::getInstance($dbo_config)->getTablesList();
     }
     $result = parent::_save();
     if ($result) {
         if ($this->Request->get('save_act') == 'apply') {
             $this->redirect(r_('index.php?ext=chronoconnectivity&act=edit&id=' . $this->Connection->id));
         } else {
             $this->redirect(r_('index.php?ext=chronoconnectivity'));
         }
     } else {
         $this->edit();
         $this->view = 'edit';
         $session = \GCore\Libs\Base::getSession();
         $session->setFlash('error', \GCore\Libs\Arr::flatten($this->Connection->errors));
     }
 }