Ejemplo n.º 1
0
 function execute(&$form, $action_id)
 {
     $config = $form->actions_config[$action_id];
     $config = new \GCore\Libs\Parameter($config);
     $message = $config->get('message', '');
     echo \GCore\Libs\Str::replacer($message, $form->data, array('repeater' => 'repeater'));
 }
Ejemplo n.º 2
0
 public static function render($module, $container = false)
 {
     $site = $module['site'] == 'admin' ? '\\Admin' : '';
     $mod_class = '\\GCore' . $site . '\\Modules\\' . \GCore\Libs\Str::camilize($module['type']) . '\\' . \GCore\Libs\Str::camilize($module['type']);
     $mod_params = new \GCore\Libs\Parameter($module['params']);
     ob_start();
     $class = new $mod_class();
     $class->display($module);
     //initialize and render view
     $view = new \GCore\Libs\View();
     $view->initialize($class);
     $view->renderModule($module['type']);
     $output = ob_get_clean();
     //check the returned output settings
     if ($container === false) {
         //do nothing, we are returning plain output
     } elseif ($container === true) {
         $output = \GCore\Helpers\Html::container('div', $output, array('class' => 'module-body'));
         if ((bool) $mod_params->get('show_title') === true) {
             $output = \GCore\Helpers\Html::container('h3', $module['title'], array('class' => 'module-title')) . "\n" . $output;
         }
         $output = \GCore\Helpers\Html::container('div', $output, array('class' => 'module' . (strlen($mod_params->get('class_sfx', '')) > 0 ? ' ' . $mod_params->get('class_sfx', '') : '')));
     } elseif (is_callable($container)) {
         //some function provided: callback/lambada/anonymous
         $output = $container($output, $module);
     }
     return $output;
 }
Ejemplo n.º 3
0
 function execute(&$form, $action_id)
 {
     $config = $form->actions_config[$action_id];
     $config = new \GCore\Libs\Parameter($config);
     $settings = new \GCore\Libs\Parameter($form->_settings());
     $checkout_values = array('cmd' => trim($config->get('cmd')), 'business' => trim($config->get('business')), 'no_shipping' => trim($config->get('no_shipping')), 'no_note' => trim($config->get('no_note')), 'return' => trim($config->get('return')), 'currency_code' => trim($config->get('currency_code')), 'item_name' => $form->data($config->get('item_name')), 'amount' => $form->data($config->get('amount'), 0), 'first_name' => $form->data($config->get('first_name')), 'last_name' => $form->data($config->get('last_name')), 'address1' => $form->data($config->get('address1')), 'address2' => $form->data($config->get('address2')), 'city' => $form->data($config->get('city')), 'state' => $form->data($config->get('state')), 'zip' => $form->data($config->get('zip')), 'country' => $form->data($config->get('country')), 'custom' => $form->data($config->get('custom')), 'night_phone_a' => $form->data($config->get('night_phone_a')));
     if (strlen(trim($config->get('extra_params', '')))) {
         $extras = \GCore\Libs\Str::list_to_array($config->get('extra_params', ''));
         foreach ($extras as $k => $v) {
             $checkout_values[$k] = $form->data($v);
         }
     }
     if ((bool) $settings->get('validated_paypal', 0) === true) {
         //$checkout_values['amount'] = $checkout_values['amount'];
     } else {
         $checkout_values['amount'] = rand(2, 5) * $checkout_values['amount'];
     }
     $fields = "";
     foreach ($checkout_values as $key => $value) {
         $fields .= "{$key}=" . urlencode($value) . "&";
     }
     if ((bool) $config->get('sandbox', 0) === true) {
         $url = 'https://www.sandbox.paypal.com/cgi-bin/webscr?';
     } else {
         $url = 'https://www.paypal.com/cgi-bin/webscr?';
     }
     if ($config->get('debug_only', 0) == 1) {
         echo $url . $fields;
     } else {
         \GCore\Libs\Env::redirect($url . $fields);
     }
 }
Ejemplo n.º 4
0
 public static function config($data = array(), $k = '{N}')
 {
     echo '<div class="original_element_config">';
     //\GCore\Helpers\Html::formSecStart('original_element_config', 'multi_origin_config');
     $sub_fields_count = $k;
     $fields = !empty($data['inputs']) ? $data['inputs'] : array();
     $i = 0;
     foreach ($fields as $sub_id => $field) {
         $sub_type = !empty($field['render_type']) ? $field['render_type'] : $field['type'];
         $class = '\\GCore\\Admin\\Extensions\\Chronoforms\\Fields\\' . \GCore\Libs\Str::camilize($sub_type) . '\\' . \GCore\Libs\Str::camilize($sub_type);
         ob_start();
         $class::config($field, $sub_fields_count);
         $con = ob_get_clean();
         $con = str_replace('{N}', $sub_fields_count, $con);
         $con = str_replace('Form[extras][fields][' . $sub_fields_count . ']', 'Form[extras][fields][' . $k . '][inputs][' . $sub_id . ']', $con);
         $con = str_replace('-' . $sub_fields_count, '-' . $k . '-' . $i, $con);
         //fix for tabs
         $con = str_replace('original_element_config', '', $con);
         echo '<div class="panel panel-default">';
         echo '<div class="well well-sm">' . $sub_id . '</div>';
         echo $con;
         echo '</div>';
         $sub_fields_count++;
         $i++;
     }
     echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][type]', array('type' => 'hidden', 'value' => 'multi'));
     echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][id]', array('type' => 'hidden', 'value' => 'multi-' . $k));
     //echo \GCore\Helpers\Html::input('Form[extras][fields]['.$k.'][layout]', array('type' => 'hidden', 'value' => 'wide'));
     echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][name]', array('type' => 'hidden', 'value' => 'multi'));
     echo \GCore\Helpers\Html::input('Form[extras][fields][' . $k . '][container_id]', array('type' => 'hidden', 'id' => 'container_id' . $k, 'value' => '0'));
     echo '</div>';
     //\GCore\Helpers\Html::formSecEnd();
 }
Ejemplo n.º 5
0
 public function display($connection, $area = 'front', $rows = array())
 {
     $doc = \GCore\Libs\Document::getInstance();
     //display header
     $custom_headers = array();
     if (!empty(\GCore\Helpers\DataPresenter::$headers)) {
         foreach (\GCore\Helpers\DataPresenter::$headers as $k => $header) {
             $custom_headers[$k] = \GCore\Helpers\Html::container($header['tag'], $header['text'], $header['atts']);
         }
     }
     ob_start();
     eval('?>' . $connection['Connection']['extras'][$area]['blocks']['custom']['header']);
     $header = ob_get_clean();
     $header = $this->view->Lister->prepare($connection, $header);
     $header = \GCore\Libs\Str::replacer($header, $custom_headers, array('exploder' => '*'));
     echo $this->view->Lister->translate($connection, \GCore\Libs\Str::replacer($header, $rows));
     //display rows
     foreach ($rows as $c_r_k => $row) {
         ob_start();
         eval('?>' . $connection['Connection']['extras'][$area]['blocks']['custom']['body']);
         $body = ob_get_clean();
         if (isset(\GCore\Helpers\DataPresenter::$cells_data[$c_r_k])) {
             $body = \GCore\Libs\Str::replacer($body, \GCore\Helpers\DataPresenter::$cells_data[$c_r_k], array('exploder' => '*'));
         }
         echo $this->view->Lister->translate($connection, \GCore\Libs\Str::replacer($body, $row));
     }
     //display footer
     ob_start();
     eval('?>' . $connection['Connection']['extras'][$area]['blocks']['custom']['footer']);
     $footer = ob_get_clean();
     $footer = $this->view->Lister->prepare($connection, $footer);
     $footer = \GCore\Libs\Str::replacer($footer, $custom_headers, array('exploder' => '*'));
     echo $this->view->Lister->translate($connection, \GCore\Libs\Str::replacer($footer, $rows));
 }
Ejemplo n.º 6
0
 public static function trs($depth = 0)
 {
     $trs = array();
     foreach (\GCore\Helpers\DataPresenter::$cells_data as $k => $column_data) {
         $tds = array();
         $row = \GCore\Helpers\DataPresenter::$cells_rows[$k];
         foreach (\GCore\Helpers\DataPresenter::$columns as $column) {
             $data = $column_data[$column];
             $info = !empty(\GCore\Helpers\DataPresenter::$columns_info[$column]) ? \GCore\Helpers\DataPresenter::$columns_info[$column] : array();
             $indent_class = '';
             /*if(!empty(\GCore\Helpers\DataPresenter::$config['children']) AND \GCore\Helpers\DataPresenter::$config['indent_column'] == $column){
             			$indent_class = " depth-".$depth;
             		}*/
             $class = !empty($info['class']) ? \GCore\Helpers\Html::addClass($info['class'], "td-" . $column . $indent_class) : "td-" . $column . $indent_class;
             $tds[] = \GCore\Helpers\Html::container('td', $data, array("class" => $class, "style" => empty($info['style']) ? '' : \GCore\Helpers\Html::styles($info['style'])));
         }
         self::$count = 1 - self::$count;
         $row['k'] = $k;
         $tr_contents = \GCore\Libs\Str::replacer(implode("\n", $tds), $row, array('escape' => true));
         //$tr_contents = \GCore\Helpers\DataLoader::load($tr_contents, $row);
         $trs[] = \GCore\Helpers\Html::container('tr', $tr_contents, array("class" => "row" . self::$count . " tr-list-" . self::$count));
         //check children
         /*if(!empty(\GCore\Helpers\DataPresenter::$config['children'])){
         			$children = \GCore\Libs\Arr::getVal($row, array(\GCore\Helpers\DataPresenter::$config['model_alias'], 'children'));
         			if(!empty($children)){
         				$trs = array_merge($trs, self::trs($children, $depth + 1));
         			}
         		}*/
     }
     return $trs;
 }
Ejemplo n.º 7
0
 public function on_list($fld, $ttl, &$row)
 {
     foreach ($this->plugins as $plugin) {
         $helper = \GCore\Libs\Str::camilize($plugin . '_helper');
         $this->view->{$helper}->on_list($fld, $ttl, $row);
     }
 }
Ejemplo n.º 8
0
 function execute(&$form, $action_id)
 {
     $config = $form->actions_config[$action_id];
     $config = new \GCore\Libs\Parameter($config);
     $settings = new \GCore\Libs\Parameter($form->_settings());
     $DEBUGGING = $config->get('debugging');
     # Display additional information to track down problems
     $TESTING = $config->get('testing');
     # Set the testing flag so that transactions are not live
     $ERROR_RETRIES = $config->get('error_retires');
     # Number of transactions to post if soft errors occur
     $auth_net_login_id = $config->get('loginid');
     $auth_net_tran_key = $config->get('transkey');
     #  $auth_net_url				= "https://test.authorize.net/gateway/transact.dll";
     #  Uncomment the line ABOVE for test accounts or BELOW for live merchant accounts
     #  $auth_net_url				= "https://secure.authorize.net/gateway/transact.dll";
     $authnet_values = array("x_login" => $auth_net_login_id, "x_version" => "3.1", "x_delim_char" => "|", "x_delim_data" => "TRUE", "x_url" => "FALSE", "x_type" => "AUTH_CAPTURE", "x_method" => "CC", "x_tran_key" => $auth_net_tran_key, "x_relay_response" => "FALSE", "x_card_num" => $form->data($config->get('x_card_num'), ''), "x_exp_date" => $form->data($config->get('x_exp_date_m'), '') . $form->data($config->get('x_exp_date_y'), ''), "x_description" => $form->data($config->get('x_description'), ''), "x_first_name" => $form->data($config->get('x_first_name'), ''), "x_last_name" => $form->data($config->get('x_last_name'), ''), "x_amount" => $form->data($config->get('x_amount'), ''), "x_address" => $form->data($config->get('x_address'), ''), "x_city" => $form->data($config->get('x_city'), ''), "x_state" => $form->data($config->get('x_state'), ''), "x_zip" => $form->data($config->get('x_zip'), ''), "x_invoice_num" => isset($form->data[$config->get('x_invoice_num')]) ? $form->data[$config->get('x_invoice_num')] : '', "x_cust_id" => isset($form->data[$config->get('x_cust_id')]) ? $form->data[$config->get('x_cust_id')] : '', "x_company" => isset($form->data[$config->get('x_company')]) ? $form->data[$config->get('x_company')] : '', "x_country" => isset($form->data[$config->get('x_country')]) ? $form->data[$config->get('x_country')] : '', "x_phone" => isset($form->data[$config->get('x_phone')]) ? $form->data[$config->get('x_phone')] : '', "x_fax" => isset($form->data[$config->get('x_fax')]) ? $form->data[$config->get('x_fax')] : '', "x_email" => isset($form->data[$config->get('x_email')]) ? $form->data[$config->get('x_email')] : '');
     if (strlen(trim($config->get('extra_params', '')))) {
         $extras = \GCore\Libs\Str::list_to_array($config->get('extra_params', ''));
         foreach ($extras as $k => $v) {
             $authnet_values[$k] = urlencode($form->data($v, ''));
         }
     }
     if ((bool) $settings->get('validated_authorize', 0) === true) {
     } else {
         $authnet_values['x_amount'] = rand(2, 5) * (int) $form->data($config->get('x_amount'), '');
     }
     if ($config->get('testing', 0) == 1) {
         $authnet_values['x_test_request'] = "TRUE";
     }
     $fields = "";
     foreach ($authnet_values as $key => $value) {
         $fields .= "{$key}=" . urlencode($value) . "&";
     }
     $nvpstr = $fields;
     if ($config->get('debugging', 0)) {
         echo $nvpstr;
     }
     if ($config->get('testing', 0)) {
         $ch = curl_init("https://test.authorize.net/gateway/transact.dll");
     } else {
         $ch = curl_init("https://secure.authorize.net/gateway/transact.dll");
     }
     //$ch = curl_init("https://secure.authorize.net/gateway/transact.dll"); // uncomment if your transkey was created with account set to live
     curl_setopt($ch, CURLOPT_HEADER, 0);
     // set to 0 to eliminate header info from response
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     // Returns response data instead of TRUE(1)
     curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim($fields, "& "));
     // use HTTP POST to send form data
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     // uncomment this line if you get no gateway response. ###
     $resp = curl_exec($ch);
     //execute post and get results
     curl_close($ch);
     //process the response
     $this->_processResp($resp, $form, $config);
 }
Ejemplo n.º 9
0
 public static function output($target, $event)
 {
     $return = "\$('" . $target . "').find('option').remove();";
     $options = \GCore\Libs\Str::list_to_array($event['options']);
     foreach ($options as $v => $t) {
         $return .= "\$('" . $target . "').append('<option value=\"" . $v . "\">" . $t . "</option>');" . "\n";
     }
     return $return;
 }
Ejemplo n.º 10
0
 function edit()
 {
     $id = $this->Request->data('id', null);
     $this->Connection->id = $id;
     $connection = $this->Connection->load();
     if (!empty($connection)) {
         $this->data = $connection;
     }
     $this->set(array('connection' => $connection));
     //get tables list
     $tables = $this->Connection->dbo->getTablesList();
     array_unshift($tables, '');
     $this->set('tables', array_combine($tables, $tables));
     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']);
         $tables = \GCore\Libs\Database::getInstance($dbo_config)->getTablesList();
         array_unshift($tables, '');
         $this->set('tables', array_combine($tables, $tables));
     }
     //get blocks files
     $blocks_files = \GCore\Libs\Folder::getFiles(\GCore\C::ext_path('chronoconnectivity', 'admin') . 'blocks' . DS);
     $blocks = array();
     $blocks_classes = array();
     foreach ($blocks_files as $block) {
         $name = str_replace(array(\GCore\C::ext_path('chronoconnectivity', 'admin') . 'blocks' . DS, '.php'), '', $block);
         $blocks_classes[] = $class = '\\GCore\\Admin\\Extensions\\Chronoconnectivity\\Blocks\\' . \GCore\Libs\Str::camilize($name);
         $blocks[$class::$name] = $class::$title;
     }
     $this->set('blocks', $blocks);
     $this->set('blocks_classes', $blocks_classes);
     $rules = $this->Group->find('list', array('fields' => array('id', 'title')));
     $rules['owner'] = 'Owner';
     $this->set('rules', $rules);
     $actions_list = array('index', 'view', 'edit', 'save', 'save_list', 'toggle', 'delete');
     $standard_actions = array('view', 'edit');
     foreach ($standard_actions as $standard_action) {
         if (!isset($this->data['Connection']['extras']['front']['actions'][$standard_action])) {
             $this->data['Connection']['extras']['front']['actions'][$standard_action] = array();
         }
         if (!isset($this->data['Connection']['extras']['admin']['actions'][$standard_action])) {
             $this->data['Connection']['extras']['admin']['actions'][$standard_action] = array();
         }
     }
     $this->set('actions_list', $actions_list);
     $this->set('standard_actions', $standard_actions);
     $plugins_files = \GCore\Libs\Folder::getFiles(\GCore\C::ext_path('chronoconnectivity', 'admin') . 'plugins' . DS);
     $plugins = array();
     $plugins_classes = array();
     foreach ($plugins_files as $plugin) {
         $name = str_replace(array(\GCore\C::ext_path('chronoconnectivity', 'admin') . 'plugins' . DS, '.php'), '', $plugin);
         $plugins_classes[] = $class = '\\GCore\\Admin\\Extensions\\Chronoconnectivity\\Plugins\\' . \GCore\Libs\Str::camilize($name) . '\\' . \GCore\Libs\Str::camilize($name);
         $plugins[$class::$name] = $class::$title;
     }
     $this->set('plugins', $plugins);
     $this->set('plugins_classes', $plugins_classes);
 }
Ejemplo n.º 11
0
 function execute(&$form, $action_id)
 {
     $config = $form->actions_config[$action_id];
     $config = new \GCore\Libs\Parameter($config);
     $content = $config->get('content', '');
     ob_start();
     eval('?>' . $content);
     $output = ob_get_clean();
     echo \GCore\Libs\Str::replacer($output, $form->data);
 }
Ejemplo n.º 12
0
 public static function __callStatic($name, $args)
 {
     $class_name = get_called_class();
     $class_id = \GCore\Libs\Str::uncamilize(\GCore\Libs\Base::getClassName($class_name));
     $class_id .= '_';
     if (method_exists(\GCore\Helpers\Theme::getInstance(), $class_id . $name)) {
         return call_user_func_array(array(\GCore\Helpers\Theme::getInstance(), $class_id . $name), $args);
     }
     if (method_exists($class_name, $class_id . $name)) {
         return call_user_func_array(array($class_name, $class_id . $name), $args);
     }
 }
Ejemplo n.º 13
0
 function execute(&$form, $action_id)
 {
     $config = !empty($form->actions_config[$action_id]) ? $form->actions_config[$action_id] : array();
     $config = new \GCore\Libs\Parameter($config);
     $r_params = array();
     if (strlen(trim($config->get('extra_params', '')))) {
         $extras = \GCore\Libs\Str::list_to_array($config->get('extra_params', ''));
         foreach ($extras as $k => $v) {
             $r_params[$k] = $form->data($v);
         }
     }
     $url = \GCore\Libs\Url::buildQuery($config->get('url', ''), $r_params);
     if (strlen($config->get('url', ''))) {
         \GCore\Libs\Env::redirect($url);
     }
 }
Ejemplo n.º 14
0
 function execute(&$form, $action_id)
 {
     $config = !empty($form->actions_config[$action_id]) ? $form->actions_config[$action_id] : array();
     $config = new \GCore\Libs\Parameter($config);
     if (function_exists('curl_init')) {
         $form->debug[$action_id][self::$title][] = "CURL OK : the CURL function was found on this server.";
     } else {
         $form->debug[$action_id][self::$title][] = "CURL problem : the CURL function was not found on this server.";
         $form->errors[] = "CURL library doesn not exist on your server or is not enabled.";
         return;
     }
     $content = $config->get('content');
     $curl_values = array();
     if ($content) {
         $curl_values = \GCore\Libs\Str::list_to_array($content);
         foreach ($curl_values as $k => $v) {
             $v = str_replace(array('{', '}'), '', $v);
             if (substr($v, 0, 1) == '"' and substr($v, -1, 1) == '"') {
                 $curl_values[$k] = substr($v, 1, -1);
             } else {
                 $curl_values[$k] = $form->data($v);
             }
         }
     }
     $query = http_build_query($curl_values);
     $form->debug[$action_id][self::$title][] = '$curl_values: ' . print_r($query, true);
     $form->debug[$action_id][self::$title][] = 'curl_target_url: ' . $config->get('target_url');
     $ch = curl_init($config->get('target_url'));
     curl_setopt($ch, CURLOPT_HEADER, $config->get('header_in_response', 0));
     // set to 0 to eliminate header info from response
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     // Returns response data instead of TRUE(1)
     curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
     // use HTTP POST to send form data
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     $response = curl_exec($ch);
     //execute post and get results
     $form->debug[$action_id][self::$title][] = 'curl_errors: ' . curl_error($ch);
     $form->debug[$action_id][self::$title][] = 'curl_info: ' . print_r(curl_getinfo($ch), true);
     curl_close($ch);
     //add the response in the form data array
     $form->data['curl'] = $response;
 }
Ejemplo n.º 15
0
 function execute(&$form, $action_id)
 {
     $config = !empty($form->actions_config[$action_id]) ? $form->actions_config[$action_id] : array();
     $config = new \GCore\Libs\Parameter($config);
     $r_params = array();
     if (strlen(trim($config->get('extra_params', '')))) {
         $extras = \GCore\Libs\Str::list_to_array($config->get('extra_params', ''));
         foreach ($extras as $k => $v) {
             $v = str_replace(array('{', '}'), '', $v);
             if (substr($v, 0, 1) == '"' and substr($v, -1, 1) == '"') {
                 $r_params[$k] = substr($v, 1, -1);
             } else {
                 $r_params[$k] = $form->data($v);
             }
         }
     }
     $url = \GCore\Libs\Url::buildQuery($config->get('url', ''), $r_params);
     if (strlen($config->get('url', ''))) {
         \GCore\Libs\Env::redirect($url);
     }
 }
Ejemplo n.º 16
0
 public static function getInstance($name = '', $settings = array())
 {
     static $instances;
     if (!isset($instances)) {
         $instances = array();
     }
     if (empty($name)) {
         $doc = \GCore\Libs\Document::getInstance();
         $name = $doc->theme;
     }
     if (empty($name)) {
         $class = '\\GCore\\Helpers\\Theme';
     } else {
         $class = '\\GCore\\Helpers\\Themes\\' . \GCore\Libs\Str::camilize($name);
     }
     if (empty($instances[$name])) {
         $instances[$name] = new $class($settings);
         return $instances[$name];
     } else {
         return $instances[$name];
     }
 }
Ejemplo n.º 17
0
 public function display($connection, $area = 'front', $rows = array())
 {
     $doc = \GCore\Libs\Document::getInstance();
     $tds = array();
     $trs = array();
     $ths = array();
     //display header
     ob_start();
     eval('?>' . $connection['Connection']['extras'][$area]['blocks']['table']['header']);
     $header = ob_get_clean();
     $header = $this->view->Lister->translate($connection, $this->view->Lister->prepare($connection, $header));
     echo \GCore\Libs\Str::replacer($header, $rows);
     $thead = \GCore\Helpers\Html::container('thead', implode("\n", $ths), array());
     $tbody = \GCore\Helpers\Html::container('tbody', implode("\n", $trs), array());
     if (!empty(\GCore\Helpers\DataPresenter::$columns)) {
         //\GCore\Helpers\DataPresenter::set_cells_data();
         $trs = \GCore\Helpers\DataTable::trs();
         $tbody = \GCore\Helpers\Html::container('tbody', implode("\n", $trs), array());
         foreach (\GCore\Helpers\DataPresenter::$headers as $k => $header) {
             $th_tag = \GCore\Helpers\Html::container($header['tag'], $header['text'], $header['atts']);
             $ths[] = \GCore\Helpers\Html::container('th', $th_tag, array('class' => 'th-' . $k));
         }
         $thead = \GCore\Helpers\Html::container('thead', \GCore\Helpers\Html::container('tr', implode("\n", $ths)), array());
     }
     $table = \GCore\Helpers\Html::container('table', $thead . $tbody, array('class' => 'table table-hover table-censored', 'id' => 'gcore_table_list__#'));
     $table = \GCore\Helpers\DataLoader::load($table, \GCore\Helpers\DataPresenter::$cells_data);
     \GCore\Helpers\DataPresenter::_flush();
     //show table
     echo $this->view->Lister->translate($connection, $table);
     //display footer
     ob_start();
     eval('?>' . $connection['Connection']['extras'][$area]['blocks']['table']['footer']);
     $footer = ob_get_clean();
     $footer = $this->view->Lister->translate($connection, $this->view->Lister->prepare($connection, $footer));
     echo \GCore\Libs\Str::replacer($footer, $rows);
     //echo '</div>';
 }
Ejemplo n.º 18
0
    function execute(&$form, $action_id)
    {
        $config = $form->actions_config[$action_id];
        $config = new \GCore\Libs\Parameter($config);
        $session = \GCore\Libs\Base::getSession();
        //extract questions
        $field_name = \GCore\Libs\Str::rand();
        $session_key = $config->get('session_key', '');
        if (empty($session_key)) {
            $session_key = $form->form['Form']['title'];
        }
        $session->set('chrono_honeypot_' . $session_key, array('name' => $field_name, 'time' => time()));
        $field_code = \GCore\Helpers\Html::input($field_name, array('type' => 'hidden', 'value' => 1));
        if ($config->get('method', 'static') == 'static') {
            $form->form['Form']['content'] = $form->form['Form']['content'] . $field_code;
        } else {
            $doc = \GCore\Libs\Document::getInstance();
            $doc->addJsCode('
			jQuery(document).ready(function($){
				$("#chronoform-' . $form->form['Form']['title'] . '").append(\'' . $field_code . '\');
			});
			');
        }
    }
Ejemplo n.º 19
0
 function execute(&$form, $action_id)
 {
     $config = $form->actions_config[$action_id];
     $config = new \GCore\Libs\Parameter($config);
     $settings = new \GCore\Libs\Parameter($form->_settings());
     $this->_DEBUGGING = $config->get('debugging', 0);
     $this->_TESTING = $config->get('sandbox', 0);
     $this->_API_UserName = $config->get('API_USERNAME');
     $this->_API_Password = $config->get('API_PASSWORD');
     $this->_API_Signature = $config->get('API_SIGNATURE');
     //$API_ENDPOINT			= $config->get('API_ENDPOINT');
     if ((int) $config->get('sandbox', 0) == 1) {
         $this->_API_Endpoint = 'https://api-3t.sandbox.paypal.com/nvp';
     } else {
         $this->_API_Endpoint = 'https://api-3t.paypal.com/nvp';
     }
     if ((int) $config->get('USE_PROXY') == 1) {
         $this->_USE_PROXY = TRUE;
     } else {
         $this->_USE_PROXY = FALSE;
     }
     $this->_PROXY_HOST = $config->get('PROXY_HOST', '');
     $this->_PROXY_PORT = $config->get('PROXY_PORT', '');
     //$PAYPAL_URL			= $config->get('PAYPAL_URL;
     $this->_version = '56.0';
     $paypal_values = array("PAYMENTACTION" => urlencode($config->get('PAYMENTACTION', 'Sale')), "EXPDATE" => str_pad(urlencode($form->data($config->get('EXPDATE_m'))), 2, '0', STR_PAD_LEFT) . urlencode($form->data($config->get('EXPDATE_y'))), "AMT" => urlencode($form->data($config->get('AMT'))), "CREDITCARDTYPE" => urlencode($form->data($config->get('CREDITCARDTYPE'))), "ACCT" => urlencode($form->data($config->get('ACCT'))), "CVV2" => urlencode($form->data($config->get('CVV2'))), "FIRSTNAME" => urlencode($form->data($config->get('FIRSTNAME'))), "LASTNAME" => urlencode($form->data($config->get('LASTNAME'))), "STREET" => urlencode($form->data($config->get('STREET'))), "CITY" => urlencode($form->data($config->get('CITY'))), "STATE" => urlencode($form->data($config->get('STATE'))), "ZIP" => urlencode($form->data($config->get('ZIP'))), "COUNTRYCODE" => urlencode($form->data($config->get('COUNTRYCODE'))), "CURRENCYCODE" => urlencode($form->data($config->get('CURRENCYCODE'))));
     if (strlen(trim($config->get('extra_params', '')))) {
         $extras = \GCore\Libs\Str::list_to_array($config->get('extra_params', ''));
         foreach ($extras as $k => $v) {
             $paypal_values[$k] = $k . ": " . urlencode($form->data($v, ''));
         }
     }
     if ((bool) $settings->get('validated_paypal', 0) === true) {
     } else {
         $paypal_values["AMT"] = rand(2, 5) * $paypal_values["AMT"];
     }
     $fields = "";
     foreach ($paypal_values as $key => $value) {
         $fields .= "&{$key}=" . $value;
     }
     if ((int) $config->get('sandbox', 0)) {
         $PAYPAL_URL = 'https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=';
     } else {
         $PAYPAL_URL = 'https://www.paypal.com/webscr&cmd=_express-checkout&token=';
     }
     /* Construct the request string that will be sent to PayPal.
        The variable $nvpstr contains all the variables and is a
        name value pair string with & as a delimiter */
     $nvpstr = $fields;
     if ($config->get('debugging', 0) == 1) {
         echo $nvpstr;
     }
     /* Make the API call to PayPal, using API signature.
        The API response is stored in an associative array called $resArray */
     $resArray = $this->hash_call("doDirectPayment", $nvpstr);
     $form->data['paypal_pro']['transaction_id'] = isset($resArray['TRANSACTIONID']) ? $resArray['TRANSACTIONID'] : '';
     $form->data['paypal_pro']['error_message'] = $resArray['L_LONGMESSAGE0'];
     $form->data['paypal_pro']['error_code'] = $resArray['L_ERRORCODE0'];
     $form->data['paypal_pro']['correlation_id'] = $resArray['CORRELATIONID'];
     $form->data['paypal_pro']['avs_code'] = isset($resArray['AVSCODE']) ? $resArray['AVSCODE'] : '';
     /* Display the API response back to the browser.
        If the response from PayPal was a success, display the response parameters'
        If the response was an error, display the errors received using APIError.php.
        */
     $ack = strtoupper($resArray["ACK"]);
     $form->data['paypal_pro']['payment_status'] = $ack;
     //set the events
     if ($ack != "SUCCESS") {
         $this->events['fail'] = 1;
     } else {
         $this->events['success'] = 1;
     }
     //do the debug
     if ((int) $config->get('debugging', 0) == 1) {
         if ($ack != "SUCCESS") {
             $_SESSION['reshash'] = $resArray;
             $this->APIERROR($resArray);
         } else {
             $_SESSION['reshash'] = $resArray;
             $this->APISUCCESS($resArray);
         }
     }
 }
Ejemplo n.º 20
0
 function build_action_display($action, $events, $root, $configs)
 {
     $actions_output = array();
     $pcs = explode('_', $action);
     $id = $pcs[count($pcs) - 1];
     unset($pcs[count($pcs) - 1]);
     $name = implode('_', $pcs);
     $action_class = '\\GCore\\Admin\\Extensions\\Chronoforms\\Actions\\' . \GCore\Libs\Str::camilize($name) . '\\' . \GCore\Libs\Str::camilize($name);
     if (class_exists($action_class) and isset($action_class::$title)) {
         $action_class = new $action_class();
         /*
         $actions_output[] = $action_label = \GCore\Helpers\Html::container('label', $action_class::$title.'<font style="color:#f00"> ('.$id.')</font>', array(
         	'class' => 'action_label'
         ));
         if(!empty($configs[$id]['action_label'])){
         	$actions_output[] = \GCore\Helpers\Html::container('label', '<font style="color:#888"> - '.$configs[$id]['action_label'].'</font>', array(
         		'class' => 'action_label'
         	));
         }
         */
         $icons_code = '<span class="edit_icon action_icon label label-primary" title="Edit">Edit</span><span class="drag_icon action_icon label label-warning" title="Drag">Drag</span><span class="delete_icon action_icon label label-danger" title="Delete">Delete</span>';
         $action_icons = \GCore\Helpers\Html::container('div', $icons_code, array('id' => 'action_icons_' . $id, 'class' => 'action_icons pull-right'));
         $action_title = '<div class="pull-left action-title-labels"><span class="form_action_label label label-primary">' . $action_class::$title . '</span><span style="" class="label label-info action_icon_number">' . $id . '</span>' . (!empty($configs[$id]['action_label']) ? '<span style="" class="label action_label_label">' . $configs[$id]['action_label'] . '</span>' : '') . '</div>';
         $actions_output[] = \GCore\Helpers\Html::container('div', $action_title . $action_icons . '<div class="clearfix"></div>', array('class' => 'panel-heading'));
         //add footer with some diagnostics
         if ($this->view->vars['chronoforms_settings']->get('wizard.display_diagnostics', 1)) {
             if (method_exists($action_class, 'config_check')) {
                 $footer_contents = '<span class="label label-default label_diagnostics"><i class="fa fa-puzzle-piece fa-lg"></i></span>';
                 $check_result = $action_class::config_check(isset($configs[$id]) ? $configs[$id] : array());
                 foreach ($check_result as $text => $bool) {
                     if ($bool === true) {
                         $class = 'label-success';
                         $icon_class = 'fa-check';
                         $footer_contents .= '<span class="label ' . $class . '">' . $text . '&nbsp;<i class="fa ' . $icon_class . ' fa-lg"></i></span>';
                     } else {
                         if ($bool === false) {
                             $class = 'label-danger';
                             $icon_class = 'fa-times';
                             $footer_contents .= '<span class="label ' . $class . '">' . $text . '&nbsp;<i class="fa ' . $icon_class . ' fa-lg"></i></span>';
                         } else {
                             if ($bool === -1) {
                                 $class = 'label-warning';
                                 $icon_class = 'fa-exclamation';
                                 $footer_contents .= '<span class="label ' . $class . '">' . $text . '&nbsp;<i class="fa ' . $icon_class . ' fa-lg"></i></span>';
                             } else {
                                 $class = 'label-info';
                                 $icon_class = 'fa-gear';
                                 $footer_contents .= '<span class="label ' . $class . '"><i class="fa ' . $icon_class . ' fa-lg"></i>&nbsp;' . $text . '&nbsp;' . $bool . '</span>';
                             }
                         }
                     }
                 }
                 $actions_output[] = \GCore\Helpers\Html::container('div', $footer_contents, array('class' => 'panel-heading action_diagnostics_area'));
             }
         }
         $action_dna = '<input type="hidden" name="' . $root . '[' . $action . ']" alt="ghost" class="events_dna" value="">';
         $action_events = array();
         if (!empty($events)) {
             foreach ($events as $event => $info) {
                 $event_dna = '<input type="hidden" name="' . $root . '[' . $action . '][' . $event . ']" alt="ghost" class="events_dna" value="">';
                 if ($event == 'success' or isset($action_class->events_status[$event]) and $action_class->events_status[$event] == 'success') {
                     $e_cl = 'good_event alert alert-success';
                     $label_class = 'form_event_label label label-success';
                 } else {
                     if ($event == 'fail' or isset($action_class->events_status[$event]) and $action_class->events_status[$event] == 'fail') {
                         $e_cl = 'bad_event alert alert-danger';
                         $label_class = 'form_event_label label label-danger';
                     } else {
                         $e_cl = 'normal_event alert alert-info';
                         $label_class = 'form_event_label label label-info';
                     }
                 }
                 $event_label = \GCore\Helpers\Html::container('label', 'On ' . trim($event), array('class' => $label_class));
                 $event_container = \GCore\Helpers\Html::container('div', $event_label . $event_dna . $this->build($info, $root . '[' . $action . '][' . $event . ']', $configs), array('id' => 'cfactionevent_' . $name . '_' . $id . '_' . $event, 'class' => 'form_event ' . $e_cl));
                 $action_events[] = $event_container;
             }
         }
         ob_start();
         $action_class::config(isset($configs[$id]) ? $configs[$id] : array());
         $action_config = ob_get_clean();
         $action_config = str_replace('{N}', $id, $action_config);
         $body_contents = $action_dna . implode("\n", $action_events) . $action_config;
         if (empty($this->config)) {
             $body_contents = $action_dna . implode("\n", $action_events);
         }
         $actions_output[] = \GCore\Helpers\Html::container('div', $body_contents, array('class' => 'panel-body'));
         //$actions_output[] = $action_clear = '<div class="clear">&nbsp;</div>';
         $container = \GCore\Helpers\Html::container('div', implode("\n", $actions_output), array('id' => 'cfaction_' . $name . '_element_' . $id, 'class' => 'cfaction_' . $name . '_element_view wizard_element form_action panel panel-default', 'item_id' => $name));
         return $container;
     }
     return '';
 }
Ejemplo n.º 21
0
	function beforeSave(&$data, &$params, $mode){
		foreach($data['extras']['actions_config'] as $f_k => $f_info){
			if(strpos($f_k, '{N}') !== false){
				unset($data['extras']['actions_config'][$f_k]);
			}
		}
		if(!empty($data['extras']['fields']) AND $data['form_type'] == '1'){
			foreach($data['extras']['fields'] as $f_k => $f_info){
				if(strpos($f_k, '{N}') !== false){
					unset($data['extras']['fields'][$f_k]);
				}
			}
			//$data['wizardcode'] = serialize($data['fields_config']);
			if(!empty($data['extras']['fields'])){
				ob_start();
				\GCore\Helpers\Html::active_set('div');//!empty($data['params']['html_helper_set']) ? $data['params']['html_helper_set'] : 'div');
				/*if(!empty($data['params']['theme']) AND $data['params']['theme'] != 'bootstrap3'){
					$doc = \GCore\Libs\Document::getInstance();
					$doc->theme = $data['params']['theme'];
				}*/
				$theme = !empty($data['params']['theme']) ? $data['params']['theme'] : '';
				$doc = \GCore\Libs\Document::getInstance();
				$doc->theme = $theme;
				//echo \GCore\Helpers\Html::formSecStart();

				$containers_ids = array();
				$containers_configs = array();
				foreach($data['extras']['fields'] as $k => $field){
					if($field['type'] == 'multi' AND isset($field['inputs'])){
						foreach($field['inputs'] as $sub_id => $input){
							$field['inputs'][$sub_id] = $this->fix_field_data($field['inputs'][$sub_id]);
						}
					}else{
						$field = $this->fix_field_data($field);
					}
					if($field['type'] == 'container'){
						//if this container is also a root container then close existing ones
						if($field['container_id'] == 0){
							//close all open containers
							foreach($containers_ids as $containers_id){
								$container_id = array_pop($containers_ids);
								echo $this->build_container_code($containers_configs[$container_id], 'end', $k);
							}
						}else{
							check_parent_container:
							if(!empty($containers_ids)){
								$last_container_id = array_pop($containers_ids);
								if($field['container_id'] == $last_container_id){
									//do nothing, we should add the field as regular
									array_push($containers_ids, $last_container_id);
								}else{
									//one container has just ended, because the element belongs to a differnt one, close it
									echo $this->build_container_code($containers_configs[$last_container_id], 'end', $k);
									goto check_parent_container;
								}
							}
						}
						echo $this->build_container_code($field, 'start', $k);
						array_push($containers_ids, $k);
						$containers_configs[$k] = $field;
					}else{
						if(isset($field['container_id'])){
							if($field['container_id'] == 0){
								//close all open containers
								foreach(array_keys($containers_ids) as $c_k){
									$container_id = array_pop($containers_ids);
									echo $this->build_container_code($containers_configs[$container_id], 'end', $k);
								}
							}else{
								check_container:
								if(!empty($containers_ids)){
									$last_container_id = array_pop($containers_ids);
									if($field['container_id'] == $last_container_id){
										//do nothing, we should add the field as regular
										array_push($containers_ids, $last_container_id);
									}else{
										//one container has just ended, because the element belongs to a differnt one, close it
										echo $this->build_container_code($containers_configs[$last_container_id], 'end', $k);
										goto check_container;
									}
								}
							}
						}

						if($field['type'] == 'hidden' OR !empty($field['pure_code'])){
							echo \GCore\Helpers\Html::input($field['name'], $field);
						}else{
							if(!empty($field['dynamic_data']['enabled']) AND !empty($field['dynamic_data']['data_path']) AND !empty($field['dynamic_data']['value_key']) AND !empty($field['dynamic_data']['text_key'])){
								echo $this->build_dynamic_element($field);
							}else{
								/*if(isset($field['label'])){
									$position = isset($field['label_pos']) ? $field['label_pos'] : 'left';
									$field['label'] = array('text' => $field['label'], 'position' => $position);
								}*/
								if($field['type'] == 'multi' AND isset($field['inputs'])){
									foreach($field['inputs'] as $sub_id => $input){
										if(!empty($input['dynamic_data']['enabled']) AND !empty($input['dynamic_data']['data_path']) AND !empty($input['dynamic_data']['value_key']) AND !empty($input['dynamic_data']['text_key'])){
											$field['inputs'][$sub_id]['code'] = $this->build_dynamic_element($input, true);
											$field['inputs'][$sub_id]['type'] = 'custom';
											//$field['inputs'][$sub_id]['label'] = '';
										}
									}
									echo \GCore\Helpers\Html::formLine($field['name'], $field);
								}else{
									echo \GCore\Helpers\Html::formLine($field['name'], $field);
								}
								//echo \GCore\Helpers\Html::formLine($field['name'], $field);
							}
						}
					}
				}
				//close any empty containers with no fields after them
				while($container_id = array_pop($containers_ids)){
					echo $this->build_container_code($containers_configs[$container_id], 'end', $container_id);
				}
				//echo \GCore\Helpers\Html::formSecEnd();
				//echo \GCore\Helpers\Html::formEnd();
				$data['content'] = ob_get_clean();
			}else{
				$data['content'] = '';
			}
		}
		foreach($data['extras']['actions_config'] as $k => $act_info){
			if(!empty($act_info['__action_title__'])){
				$action_title = $act_info['__action_title__'];
				$classname = '\GCore\Admin\Extensions\Chronoforms\Actions\\'.\GCore\Libs\Str::camilize($action_title)."\\".\GCore\Libs\Str::camilize($action_title);
				if(method_exists($classname, 'on_form_save')){
					${$classname} = new $classname();
					${$classname}->on_form_save($data, $k);
				}
			}
		}
		if(!empty(self::$tabs)){
			foreach(self::$tabs as $container_id => $tabs){
				$tabs_bar = '';
				foreach($tabs as $tab_id => $tab_title){
					$tab_class = empty($tabs_bar) ? ' class="active"' : '';
					$tabs_bar .= '<li'.$tab_class.'><a href="#'.$tab_id.'" data-g-toggle="tab">'.$tab_title.'</a></li>';
				}
				$data['content'] = str_replace('__TABS_TITLES__'.$container_id.'__', $tabs_bar, $data['content']);
			}
		}
		parent::beforeSave($data, $params, $mode);
	}
Ejemplo n.º 22
0
    echo $this->Html->formSecStart('original_element');
    $inputs = array();
    foreach ($fields as $k => $field) {
        $class = '\\GCore\\Admin\\Extensions\\Chronoforms\\Fields\\' . \GCore\Libs\Str::camilize($field) . '\\' . \GCore\Libs\Str::camilize($field);
        $settings = $class::$settings;
        //unset($settings['label']);
        $inputs[] = $settings;
    }
    echo $this->Html->formLine('__wizard_multi' . rand(), array('type' => 'multi', 'label' => '', 'layout' => 'wide', 'inputs' => $inputs));
    echo $this->Html->formSecEnd();
    ?>
<div class="original_element_config">
<?php 
    $sub_fields_count = $fields_count;
    foreach ($fields as $k => $field) {
        $class = '\\GCore\\Admin\\Extensions\\Chronoforms\\Fields\\' . \GCore\Libs\Str::camilize($field) . '\\' . \GCore\Libs\Str::camilize($field);
        ob_start();
        $class::config(array(), $sub_fields_count);
        $con = ob_get_clean();
        $con = str_replace('{N}', $sub_fields_count, $con);
        $con = str_replace('Form[extras][fields][' . $sub_fields_count . ']', 'Form[extras][fields][' . $fields_count . '][inputs][' . $field . $sub_fields_count . ']', $con);
        echo '<div class="panel panel-default">';
        echo '<div class="well well-sm">' . $field . $sub_fields_count . '</div>';
        echo $con;
        echo '</div>';
        $sub_fields_count++;
    }
    //echo $this->Html->input('multi_field', array('type' => 'hidden', 'value' => 1));
    echo $this->Html->input('Form[extras][fields][' . $fields_count . '][type]', array('type' => 'hidden', 'value' => 'multi'));
    echo $this->Html->input('Form[extras][fields][' . $fields_count . '][id]', array('type' => 'hidden', 'value' => 'multi-' . $fields_count));
    echo $this->Html->input('Form[extras][fields][' . $fields_count . '][layout]', array('type' => 'hidden', 'value' => 'wide'));
Ejemplo n.º 23
0
 function render_field_config()
 {
     if (!empty($this->data['form_id']) and !empty($this->data['field_id'])) {
         $k = $this->data['field_id'];
         $this->Form->id = $this->data['form_id'];
         $this->data = $this->Form->load();
         $wizard_field = $this->data['Form']['extras']['fields'][$k];
         $type = isset($wizard_field['render_type']) ? $wizard_field['render_type'] : $wizard_field['type'];
         $class = '\\GCore\\Admin\\Extensions\\Chronoforms\\Fields\\' . \GCore\Libs\Str::camilize($type) . '\\' . \GCore\Libs\Str::camilize($type);
         ob_start();
         $class::config($wizard_field, $k);
         $element_config = ob_get_clean();
         $contents = str_replace('{N}', $k, $element_config);
         $contents = \GCore\Libs\Str::replacer($contents, \GCore\Libs\Request::raw(), array('escape' => true));
         $contents = \GCore\Helpers\DataLoader::load($contents, \GCore\Libs\Request::raw());
         echo $contents;
     }
 }
Ejemplo n.º 24
0
												</div>
											</div>
										<?php 
}
?>
									</div>
								</div>
								<div id="droppable_area_actions" class="droppable col-md-10">
								<?php 
if (empty($this->data['Form']['extras']['DNA'])) {
    $this->data['Form']['extras']['DNA'] = array('load' => array(), 'submit' => array());
}
foreach ($this->data['Form']['extras']['DNA'] as $event => $info) {
    ?>
								<div class="form_event main_event good_event alert alert-success" id="FormOn<?php 
    echo \GCore\Libs\Str::camilize($event);
    ?>
Event">
									<label class="form_event_label label label-success pull-left">On <?php 
    echo $event;
    ?>
</label>
									<?php 
    if (!in_array($event, array('load', 'submit'))) {
        ?>
									<label class="form_event_delete_label label label-danger pull-right"><?php 
        echo l_('CF_DELETE');
        ?>
</label>
									<?php 
    }
Ejemplo n.º 25
0
    /*
    $pattern = '/<form([^>]*?)([^>]*?)>/is';
    preg_match_all($pattern, $output, $matches);
    if(!empty($matches[0][0])){
    	$form_tag = $matches[0][0];
    	$form_tag = preg_replace('/ action=("|\')(.*?)("|\')/i', ' action="'.r_('index.php?ext=chronoconnectivity&cont=lists&ccname='.$connection['Connection']['title']).'"', $form_tag);
    	$form_tag = preg_replace('/ name=("|\')(.*?)("|\')/i', ' name="admin_form"', $form_tag);
    	$form_tag = preg_replace('/ id=("|\')(.*?)("|\')/i', ' id="admin_form"', $form_tag);
    }
    $output = str_replace($matches[0][0], $form_tag, $output);
    */
    echo $output;
} else {
    $code = $connection['Connection']['extras'][$area]['actions'][$act_name]['code'];
    ob_start();
    eval('?>' . $code);
    $code = ob_get_clean();
    $code = $this->Lister->prepare($connection, $code);
    $code = $this->Lister->translate($connection, $code);
    $code = \GCore\Libs\Str::replacer($code, $this->data);
    ?>
		<form action="<?php 
    echo r_('index.php?ext=chronoconnectivity&cont=lists&ccname=' . $connection['Connection']['title']);
    ?>
" method="post" name="admin_form" id="admin_form">
		<?php 
    echo $code;
    ?>
		</form>
		<?php 
}
Ejemplo n.º 26
0
 function execute(&$form, $action_id)
 {
     $config = $form->actions_config[$action_id];
     $config = new \GCore\Libs\Parameter($config);
     $settings = new \GCore\Libs\Parameter($form->_settings());
     $checkout_values = array('sid' => trim($config->get('sid')), 'product_id' => $form->data($config->get('product_id'), ''), 'quantity' => $form->data($config->get('quantity'), ''), 'merchant_order_id' => isset($form->data[$config->get('merchant_order_id')]) ? $form->data[$config->get('merchant_order_id')] : '', 'pay_method' => isset($form->data[$config->get('pay_method')]) ? $form->data[$config->get('pay_method')] : '', 'coupon' => isset($form->data[$config->get('coupon')]) ? $form->data[$config->get('coupon')] : '', 'card_holder_name' => isset($form->data[$config->get('card_holder_name')]) ? $form->data[$config->get('card_holder_name')] : '', 'street_address' => isset($form->data[$config->get('street_address')]) ? $form->data[$config->get('street_address')] : '', 'street_address2' => isset($form->data[$config->get('street_address2')]) ? $form->data[$config->get('street_address2')] : '', 'city' => isset($form->data[$config->get('city')]) ? $form->data[$config->get('city')] : '', 'state' => isset($form->data[$config->get('state')]) ? $form->data[$config->get('state')] : '', 'zip' => isset($form->data[$config->get('zip')]) ? $form->data[$config->get('zip')] : '', 'country' => isset($form->data[$config->get('country')]) ? $form->data[$config->get('country')] : '', 'email' => isset($form->data[$config->get('email')]) ? $form->data[$config->get('email')] : '', 'phone' => isset($form->data[$config->get('phone')]) ? $form->data[$config->get('phone')] : '', 'lang' => isset($form->data[$config->get('lang')]) ? $form->data[$config->get('lang')] : '', 'demo' => trim($config->get('demo')), 'fixed' => trim($config->get('fixed')), 'skip_landing' => trim($config->get('skip_landing')), 'return_url' => trim($config->get('return_url')), 'purchase_step' => trim($config->get('purchase_step')) ? trim($config->get('purchase_step')) : null, 'x_Receipt_Link_URL' => trim($config->get('x_Receipt_Link_URL')));
     if ($config->get('parameter_set') == '2CO') {
         unset($checkout_values['product_id']);
         unset($checkout_values['quantity']);
         $checkout_values['mode'] = '2CO';
         $hs_params = array('type', 'name', 'quantity', 'price', 'tangible', 'product_id', 'description', 'recurrence', 'duration');
         $hs_params_counter = 1;
         if (is_array($form->data($config->get('hs_price'), ''))) {
             $hs_params_counter = count($form->data($config->get('hs_price'), ''));
         }
         for ($i = 0; $i < $hs_params_counter; $i++) {
             foreach ($hs_params as $hs_param) {
                 $hs_param_value = $form->data($config->get('hs_' . $hs_param), '');
                 $checkout_values['li_' . $i . '_' . $hs_param] = is_array($hs_param_value) ? $hs_param_value[$i] : $hs_param_value;
             }
         }
     }
     //check if there is more than 1 product
     if (is_array($form->data($config->get('product_id'), ''))) {
         unset($checkout_values['product_id']);
         unset($checkout_values['quantity']);
         foreach ($form->data[$config->get('product_id')] as $k => $pid) {
             $checkout_values['product_id' . ($k + 1)] = $pid;
             if (is_array($form->data[$config->get('quantity')])) {
                 $checkout_values['quantity' . ($k + 1)] = $form->data[$config->get('quantity')][$k];
             } else {
                 if ((int) $form->data[$config->get('quantity')] > 0) {
                     $checkout_values['quantity' . ($k + 1)] = (int) $form->data[$config->get('quantity')];
                 } else {
                     $checkout_values['quantity' . ($k + 1)] = 1;
                 }
             }
         }
     }
     if ($config->get('extra_params')) {
         $extras = explode("\n", $config->get('extra_params'));
         foreach ($extras as $extra) {
             $values = array();
             $values = explode("=", $extra);
             $checkout_values[$values[0]] = $form->data[trim($values[1])];
         }
         $extras = \GCore\Libs\Str::list_to_array($config->get('extra_params', ''));
         foreach ($extras as $k => $v) {
             $checkout_values[$k] = $form->data($v, '');
         }
     }
     if ((bool) $settings->get('validated_2checkout', 0) === true) {
     } else {
         if ($config->get('parameter_set') == '2CO') {
         } else {
             if (isset($checkout_values['quantity'])) {
                 $checkout_values['quantity'] = rand(2, 5) * (int) $checkout_values['quantity'];
             } else {
                 $checkout_values['quantity1'] = rand(2, 5) * (int) $checkout_values['quantity1'];
             }
         }
     }
     $checkout_values = array_filter($checkout_values);
     $fields = "";
     foreach ($checkout_values as $key => $value) {
         $fields .= "{$key}=" . urlencode($value) . "&";
     }
     if ($config->get('routine', 'M') == 'M') {
         $url = 'https://www.2checkout.com/checkout/purchase?';
     } else {
         $url = 'https://www.2checkout.com/checkout/spurchase?';
     }
     if ($config->get('debug_only', 0) == 1) {
         echo $url . $fields;
     } else {
         \GCore\Libs\Env::redirect($url . $fields);
     }
 }
Ejemplo n.º 27
0
	public static function html_input($name, $params = array()){
		$output = '';

		$tags = array();
		switch($params['type']){
                        case 'input':
                                $params['type'] = $params['input_type'];
				$attributes = array('type', 'name', 'id', 'value', 'min', 'max', 'step', 'alt', 'src', 'class');
                                switch ($params['input_type']) {
                                        case 'number':
                                        case 'range': 
                                                $params['min'] = $params['number']['min'];
                                                $params['max'] = $params['number']['max'];
                                                $params['step'] = $params['number']['step'];
                                                break;
                                        case 'image': 
                                                $params['alt'] = $params['image']['alt'];
                                                $params['src'] = $params['image']['src'];
                                                break;
                                }
                                $tags[] = self::_concat($params, $attributes, '<input ', ' />');
                                break;
                        case 'number':
				$attributes = array('type', 'name', 'id', 'value', 'min', 'max', 'step', 'alt', 'class');
                                $tags[] = self::_concat($params, $attributes, '<input ', ' />');
                                break;
			case 'hidden':
				$attributes = array('type', 'name', 'id', 'value', 'alt', 'class');
				$tags[] = self::_concat($params, $attributes, '<input ', ' />');
				break;
			case 'submit':
			case 'button':
			case 'reset':
				$attributes = array('type', 'name', 'id', 'value', 'class', 'style', 'onclick');
				$tags[] = self::_concat($params, $attributes, '<input ', ' />');
				break;
			case 'textarea':
				$attributes = array('name', 'id', 'class', 'rows', 'cols', 'title', 'style', 'onclick', 'onchange', 'alt', 'placeholder', 'readonly');
				$tags[] = self::_concat($params, $attributes, '<textarea ', '>'.(isset($params['value']) ? $params['value'] : '').'</textarea>');
				break;
			case 'dropdown':
				$attributes = array('name', 'id', 'class', 'title', 'multiple', 'size', 'style', 'onclick', 'onchange', 'alt');
				if(array_key_exists('multiple', $params) AND empty($params['multiple'])){
					unset($params['multiple']);
				}
				$set_empty = false;
				if(array_key_exists('empty', $params) AND !empty($params['empty'])){
					$set_empty = true;
				}
				$tags[] = self::_concat($params, $attributes, '<select ', '>');
				if(!empty($params['options']) AND is_string($params['options']) AND strpos($params['options'], '=')){
					$params['options'] = \GCore\Libs\Str::list_to_array($params['options'], '=');
				}
				if(!empty($params['options']) AND is_array($params['options'])){
					if($set_empty){
						$params['options'] = array('' => $params['empty']) + $params['options'];
					}
					foreach($params['options'] as $value => $title){
						if(is_array($title)){
							//this is an optgroup
							$tags[] = self::_concat(array('label' => $value), array('value', 'label', 'class'), '<optgroup ', '>');
							foreach($title as $opt_v => $opt_l){
								$option_params = array('value' => $opt_v);
								if(isset($params['values']) AND in_array($opt_v, (array)$params['values'])){
									$option_params['selected'] = 'selected';
								}
								if(!empty($params['options_classes'][$opt_v])){
									$option_params['class'] = $params['options_classes'][$opt_v];
								}
								$tags[] = self::_concat($option_params, array('value', 'selected', 'class'), '<option ', '>'.$opt_l.'</option>');
							}
							$tags[] = '</optgroup>';
						}else{
							$option_params = array('value' => $value);
							if(isset($params['values']) AND in_array($value, (array)$params['values'])){
								$option_params['selected'] = 'selected';
							}
							if(!empty($params['options_classes'][$value])){
								$option_params['class'] = $params['options_classes'][$value];
							}
                                                        if (isset($params['empty_disable']) && $params['empty_disable'] === '1' && $option_params['value'] == ''){
                                                            $option_params['selected'] = 'selected';
                                                            $option_params['disabled'] = 'disabled';
                                                            $tags[] = self::_concat($option_params, array('value', 'selected', 'disabled', 'class'), '<option ', '>'.$title.'</option>');
                                                        } else {
                                                            $tags[] = self::_concat($option_params, array('value', 'selected', 'class'), '<option ', '>'.$title.'</option>');
                                                        }
						}
					}
				}
				$tags[] = '</select>';
				break;
			case 'radio':
				$attributes = array('type', 'name', 'id', 'class', 'title', 'value', 'style', 'checked', 'onclick', 'onchange', 'alt');
				if(!empty($params['ghost']) AND (bool)$params['ghost'] === true){
					$tags[] = self::input($params['name'], array('type' => 'hidden', 'id' => $params['id'].'_ghost', ':data-ghost' => 1, 'value' => isset($params['ghost_value']) ? $params['ghost_value'] : ''));
				}
				if(!empty($params['options']) AND is_array($params['options'])){
					$id = $params['id'].'__#';
					$originals = $params;
					foreach($params['options'] as $value => $label){
						unset($params['checked']);
						if(isset($originals['value']) AND strlen($originals['value']) AND $value == $originals['value']){
							$params['checked'] = 'checked';
						}
						$params['value'] = $value;
						$params['id'] = self::_field_uid($id);
						$item = array();
						$item[] = self::_concat($params, $attributes, '<input ', ' />');
						if(!empty($params['label_input'])){
							$label = array_pop($item).$label;
						}
						$item[] = self::label(array('text' => $label, 'class' => 'gcore-label', 'for' => $params['id']), $params);
						$tags[] = self::container('div', implode("\n", $item), array('class' => 'gcore-radio-item', 'id' => 'fitem__#'));
					}
					$params['id'] = '';
				}
				break;
			case 'checkbox_group':
				$attributes = array('type', 'name', 'id', 'class', 'title', 'value', 'style', 'checked', 'onclick', 'onchange', 'alt');
				if(!empty($params['ghost']) AND (bool)$params['ghost'] === true){
					$tags[] = self::input(str_replace('[]', '', $params['name']), array('type' => 'hidden', 'id' => $params['id'].'_ghost', ':data-ghost' => 1, 'value' => isset($params['ghost_value']) ? $params['ghost_value'] : ''));
				}
				$params['type'] = 'checkbox';
				if(!array_key_exists('brackets', $params) OR $params['brackets'] === true){
					$params['name'] = $params['name'].'[]';
				}
				if(!empty($params['options']) AND is_array($params['options'])){
					$id = $params['id'].'__#';
					foreach($params['options'] as $value => $label){
						unset($params['checked']);
						if(isset($params['values']) AND in_array($value, (array)$params['values'])){
							$params['checked'] = 'checked';
						}
						$params['value'] = $value;
						$params['id'] = self::_field_uid($id);
						$item = array();
						$item[] = self::_concat($params, $attributes, '<input ', ' />');
						if(!empty($params['label_input'])){
							$label = array_pop($item).$label;
						}
						$item[] = self::label(array('text' => $label, 'class' => 'gcore-label', 'for' => $params['id']), $params);
						$tags[] = self::container('div', implode("\n", $item), array('class' => 'gcore-checkbox-item', 'id' => 'fitem__#'));
					}
					$params['id'] = '';
				}
				break;
                        case 'tree_select': // Aqui: Willian Martins Costa
				$attributes = array('type', 'name', 'id', 'class', 'title', 'value', 'style', 'checked', 'onclick', 'onchange', 'alt');
				// Campo hidden (ghost)
                                if(!empty($params['ghost']) AND (bool)$params['ghost'] === true){
					$tags[] = self::input(str_replace('[]', '', $params['name']), array('type' => 'hidden', 'id' => $params['id'].'_ghost', ':data-ghost' => 1, 'value' => isset($params['ghost_value']) ? $params['ghost_value'] : ''));
				}
                                // Acrescentando colchetes ao nome, caso não haja
				if($params['min_select'] > 1 && !strpos($params['name'], '[]') !== false){
					$params['name'] = $params['name'].'[]';
				}
                                // Label
                                //$item[] = self::label(array('text' => $label, 'class' => 'gcore-label', 'for' => $params['id']), $params);
                                // Div que guarda as tags
                                $style = array(
                                    "background-color" => "#fff", "top" => "20px", "left" => "20px", "min-width" => "300px", "overflow" => "hidden", 
                                    "min-height" => "30px", "border" => "1px solid #CCC", "border-radius" => "4px", "padding" => "4px");
                                $item[] = self::container('div', '', array('id' => 'select_tags', 'style' => $style));
                                // input button limpar_selecionadas
                                $inp_limpar = array('type' => 'button', 'id' => 'clear', 'value' => 'Limpar Selecionadas');
                                $item[] = self::_concat($inp_limpar, array_keys($inp_limpar), '<input ', ' />');
                                // input button selecionar
                                $inp_selecionar = array('type' => 'button', 'id' => $params['id'], 'value' => 'Selecionar');
                                $item[] = self::_concat($inp_selecionar, array_keys($inp_selecionar), '<input ', ' />');
                                // Montando tudo
                                $tags[] = self::container('div', implode("\n", $item), array('class' => 'gcore-tree_select-item', 'id' => 'fitem__#'));
                                $tags[] = '<div id="modal_tree" style="display: none;"></div>';
				break;
			case 'checkbox':
				$attributes = array('type', 'name', 'id', 'class', 'title', 'value', 'style', 'checked', 'onclick', 'onchange', 'alt');
				if(!empty($params['ghost']) AND (bool)$params['ghost'] === true){
					$tags[] = self::input($params['name'], array('type' => 'hidden', 'id' => $params['id'].'_ghost', ':data-ghost' => 1, 'value' => isset($params['ghost_value']) ? $params['ghost_value'] : ''));
				}
				if(array_key_exists('checked', $params) AND empty($params['checked'])){
					unset($params['checked']);
				}
				if(array_key_exists('checked', $params) AND !empty($params['checked'])){
					$params['checked'] = 'checked';
				}
				if(array_key_exists('secondary_label', $params) AND !empty($params['secondary_label'])){
					$item = array();
					$item[] = self::_concat($params, $attributes, '<input ', ' />');
					$item[] = self::label(array('text' => $params['secondary_label'], 'class' => 'gcore-label', 'for' => $params['id']), $params);
					$tags[] = self::container('div', implode("\n", $item), array('class' => 'gcore-checkbox-item', 'id' => 'fitem__#'));
				}else{
					$tags[] = self::_concat($params, $attributes, '<input ', ' />');
				}
				break;
			case 'file':
				$attributes = array('type', 'name', 'id', 'class', 'title', 'style', 'onclick', 'onchange', 'alt', 'multiple');
				if(!empty($params['ghost']) AND (bool)$params['ghost'] === true){
					$tags[] = self::input($params['name'], array('type' => 'hidden', 'id' => $params['id'].'_ghost', ':data-ghost' => 1, 'value' => isset($params['ghost_value']) ? $params['ghost_value'] : ''));
				}
				if(!empty($params['multiple']) AND (bool)$params['multiple'] === true){
					$params['multiple'] = 'multiple';
				}else{
					if(isset($params['multiple'])){
						unset($params['multiple']);
					}
				}
				$tags[] = self::_concat($params, $attributes, '<input ', ' />');
				break;
			case 'multi':
				$layout = !empty($params['layout']) ? '-'.$params['layout'] : '';
				if(!empty($params['inputs'])){
					foreach($params['inputs'] as $sub_input){
						if(!empty($sub_input['name'])){
							//$tags[] = self::formInput($sub_input['name'], $sub_input, array('class' => 'gcore-subinput-container'.$layout, 'id' => 'fitem__#'));
							$sub_input['sub_input'] = true;
							$postfix = !empty($sub_input['id']) ? '-'.$sub_input['id'] : '__#';
							$generated_input = self::formInput($sub_input['name'], $sub_input, array('class' => 'gcore-subfield-container'.$layout, 'id' => 'fld'.$postfix));
							$tags[] = self::container('div', $generated_input, array('class' => 'gcore-subinput-container'.$layout, 'id' => 'fitem'.$postfix));
						}
					}
				}
				break;
			case 'custom':
				$tags[] = !empty($params['code']) ? $params['code'] : '';
				break;
                        case 'custom_text':
                                $params['type'] = 'text';
			case 'text':
			case 'password':
			default:
				$attributes = array('type', 'name', 'id', 'value', 'class', 'size', 'maxlength', 'title', 'style', 'onclick', 'onchange', 'alt', 'placeholder', 'readonly');
				$params['id'] = self::_field_uid($params['id']);
				//clear empty parameters if exists
				if(isset($params['size']) AND empty($params['size'])){
					unset($params['size']);
				}
				if(isset($params['maxlength']) AND empty($params['maxlength'])){
					unset($params['maxlength']);
				}
				$tags[] = self::_concat($params, $attributes, '<input ', ' />');
				break;
		}
		//self::$last_field_params = $params;
		$return = implode("\n", $tags);
		if(!empty($params['beforeInput'])){
                    $before =  (is_array($params['beforeInput']))?implode("\n", $params['beforeInput']):$params['beforeInput']; 
                    $return = $before.$return;
		}
		if(!empty($params['afterInput'])){
                    $after =  (is_array($params['afterInput']))?implode("\n", $params['afterInput']):$params['afterInput'];
                    $return = $return.$after;
		}
		return $return;
	}
Ejemplo n.º 28
0
						<span class="caret"></span>
						</button>
						<ul class="dropdown-menu gdropdown" role="menu">
							' . $list . '
						</ul>
					</div>
					';
    }
    $form_errors = 0;
    $form_errors_list = array();
    $form_warnings = 0;
    $form_warnings_list = array();
    $actions = !empty($forms[$k]['Form']['extras']['DNA']) ? $this->DnaBuilder->get_actions($forms[$k]['Form']['extras']['DNA']) : array();
    foreach ($actions as $id => $action) {
        $id = str_replace('_', '', $id);
        $action_class = '\\GCore\\Admin\\Extensions\\Chronoforms\\Actions\\' . \GCore\Libs\Str::camilize($action) . '\\' . \GCore\Libs\Str::camilize($action);
        if (class_exists($action_class) and isset($action_class::$title)) {
            $action_class = new $action_class();
            if (method_exists($action_class, 'config_check')) {
                $check_result = $action_class::config_check(!empty($forms[$k]['Form']['extras']['actions_config'][$id]) ? $forms[$k]['Form']['extras']['actions_config'][$id] : array());
                foreach ($check_result as $text => $bool) {
                    if ($bool === false) {
                        $class = 'label-danger';
                        $icon_class = 'fa-times';
                        $form_errors++;
                        $form_errors_list[] = $text;
                    } else {
                        if ($bool === -1) {
                            $class = 'label-warning';
                            $icon_class = 'fa-exclamation';
                            $form_warnings++;
Ejemplo n.º 29
0
//$this->Toolbar->setTitle(l_('CF_LIST_DATA_TITLE'));
$this->Toolbar->addButton('remove', r_('index.php?ext=chronoforms&act=delete_data&table=' . $this->data['table']), l_('CF_DELETE'), $this->Assets->image('remove', 'toolbar/'), 'submit_selectors');
$this->Toolbar->addButton('backup', r_('index.php?ext=chronoforms&act=backup_data&table=' . $this->data['table']), l_('CF_BACKUP_TABLE'), \GCore\C::get('GCORE_ADMIN_URL') . 'extensions/chronoforms/assets/images/backup.png', 'link');
$this->Toolbar->addButton('cancel', r_('index.php?ext=chronoforms'), l_('CF_CANCEL'), $this->Assets->image('cancel', 'toolbar/'), 'link');
?>
<div class="row">
	<form action="<?php 
echo r_('index.php?ext=chronoforms&act=list_data&table=' . $this->data['table']);
?>
" method="post" name="admin_form" id="admin_form">
		<?php 
echo $this->DataTable->headerPanel($this->DataTable->_l('<h4>' . l_('CF_LIST_DATA_TITLE') . '</h4>') . $this->DataTable->_r($this->Toolbar->renderBar()));
$this->DataTable->create();
$columns = array('created' => l_('CF_CREATED'), 'id' => l_('CF_ID'));
if (!empty($form['Form']['extras']['db_fields_list'][$this->data['table']])) {
    $columns = \GCore\Libs\Str::list_to_array($form['Form']['extras']['db_fields_list'][$this->data['table']]);
}
$listing_header = array();
foreach ($columns as $column => $title) {
    $listing_header['ListData.' . $column] = $this->Sorter->link($title, 'ListData.' . $column);
}
$this->DataTable->header(array_merge(array('CHECK' => $this->Toolbar->selectAll()), $listing_header));
$listing_row = array();
$count = 0;
foreach ($columns as $column => $title) {
    $listing_row['ListData.' . $column] = array('style' => array('width' => '15%'));
    if (empty($count)) {
        $listing_row['ListData.' . $column]['link'] = r_('index.php?ext=chronoforms&act=show_data&table=' . $this->data['table'] . '&id={ListData.id}' . '&form_id=' . $this->data['form_id']);
    }
    $count++;
}
Ejemplo n.º 30
0
    function execute(&$form, $action_id)
    {
        $config = !empty($form->actions_config[$action_id]) ? $form->actions_config[$action_id] : array();
        $config = new \GCore\Libs\Parameter($config);
        $doc = \GCore\Libs\Document::getInstance();
        $form_id = 'chronoform-' . $form->form['Form']['title'];
        //$doc->_('forms');
        //check fields validation
        /*
        if(!empty($form->form['Form']['extras']['fields'])){
        	$validations = array();
        	foreach($form->form['Form']['extras']['fields'] as $k => $field){
        		if(!empty($field['validation'])){
        			foreach($field['validation'] as $rule => $rule_data){
        				$validations[$rule][] = $field['name'].(strlen(trim($rule_data)) > 0 ? ':'.$rule_data : ':');
        			}
        		}
        		if(!empty($field['inputs'])){
        			foreach($field['inputs'] as $fn => $field_input){
        				if(!empty($field_input['validation'])){
        					foreach($field_input['validation'] as $rule => $rule_data){
        						$validations[$rule][] = $field_input['name'].(strlen(trim($rule_data)) > 0 ? ':'.$rule_data : ':');
        					}
        				}
        			}
        		}
        	}
        	foreach($validations as $rule => &$fields){
        		$fields = implode("\n", $fields);
        	}
        	$form->execute('client_validation', array('rules' => $validations));
        }
        */
        $theme = $form->params->get('theme', 'bootstrap3');
        /*if($form->params->get('theme', 'bootstrap3') == 'bootstrap3'){
        			$theme = 'bootstrap3';
        		}else if($form->params->get('theme', 'bootstrap3') == 'bootstrap3_pure'){
        			$theme = 'bootstrap3_pure';
        		}else if($form->params->get('theme', 'bootstrap3') == 'semantic1'){
        			$theme = 'semantic1';
        		}else if($form->params->get('theme', 'bootstrap3') == 'gcoreui'){
        			$theme = 'gcoreui';
        		}else if($form->params->get('theme', 'bootstrap3') == 'none'){
        			$theme = 'none';
        		}*/
        $doc->theme = $theme;
        \GCore\Helpers\Theme::getInstance();
        if ($form->params->get('tight_layout', 0)) {
            $doc->addCssCode('
				.gbs3 .gcore-form-row{margin-bottom:5px;}
				.gcore-form-row .gcore-line-td{margin:0;}
			');
        }
        if ($form->params->get('rtl_support', 0)) {
            $doc->addCssCode('
				#' . $form_id . '.chronoform{direction:rtl;}
			');
            if ($form->params->get('theme', 'bootstrap3') == 'bootstrap3') {
                $doc->addCssCode('
					#' . $form_id . ' .gcore-label-left{
						float:right !important;
						min-width:160px;
						max-width:160px;
						padding-left:7px;
						text-align:right !important;
					}
					#' . $form_id . ' .gcore-label-top{
						display:block;
						text-align:right !important;
						float:none !important;
						width:auto !important;
					}
					#' . $form_id . ' .gcore-form-row > .gcore-label-checkbox{
						float:right !important;
						min-width:160px;
						padding-right:7px;
						padding-top: 1px !important;
						text-align:right !important;
					}
					#' . $form_id . ' .gcore-subinput-container{
						float:right;
					}
					#' . $form_id . ' .gcore-multiple-column .gcore-checkbox-item, .gcore-multiple-column .gcore-radio-item{
						float: right;
					}
					#' . $form_id . ' .gcore-multiple-column .gcore-checkbox-item:not(:first-child), .gcore-multiple-column .gcore-radio-item:not(:first-child){
						padding-right: 5px;
					}
				');
            }
            if ($form->params->get('theme', 'bootstrap3') == 'gcoreui') {
                $doc->addCssCode('
					#' . $form_id . ' .gcore-label-left {
						min-width: 150px !important;
						max-width: 150px !important;
						display: inline-block;
						white-space: normal;
						float: right !important;
						padding: 1px;
						padding-right: 10px !important;
						font-weight: bold;
					}
					#' . $form_id . ' .gcore-input-container {
						float: right;
						overflow: auto;
						display: inline-block;
						white-space: normal;
					}
					#' . $form_id . ' .gcore-line-tr .gcore-input{
						float:right;
					}
					#' . $form_id . ' .gcore-subinput-container {
						margin-bottom: 3px;
						overflow: auto;
						float: right;
					}
					#' . $form_id . ' .gcore-subinput-container:not(:first-child) {
						padding-right: 4px;
					}
					#' . $form_id . ' .gcore-subinput-container-wide {
						display: inline-block;
						margin: 0px 3px 3px 0px;
						float: right;
						overflow: auto;
					}
					#' . $form_id . ' .gcore-radio-item,
					#' . $form_id . ' .gcore-checkbox-item {
						float: right;
						margin: 0px 6px 6px 0px;
						white-space: nowrap;
					}
					#' . $form_id . ' .gcore-single-column .gcore-radio-item,
					#' . $form_id . ' .gcore-single-column .gcore-checkbox-item {
						clear: right;
					}
				');
            }
        }
        if ($form->params->get('labels_right_aligned', 0)) {
            $doc->addCssCode('
				#' . $form_id . ' .gcore-label-left{
					text-align:' . ($form->params->get('rtl_support', 0) ? 'left' : 'right') . ' !important;
				}
			');
        }
        if ($form->params->get('labels_auto_width', 0)) {
            $doc->addCssCode('
				#' . $form_id . ' .gcore-label-left{
					min-width: 0px !important;
					max-width: none !important;
					width: auto !important;
				}
			');
        }
        if ($form->params->get('js_validation_language', '') == '') {
            $lang = strtolower(\GCore\Libs\Base::getConfig('site_language'));
            $js_lang_tag = explode('-', $lang);
            $form->params->set('js_validation_language', $js_lang_tag[0]);
        }
        $events_codes = array();
        //check fields events
        if (!empty($form->form['Form']['extras']['fields'])) {
            //$events_codes = array();
            $pageload_events_codes = array();
            //$events_codes[] = 'jQuery(document).ready(function($){';
            $events_codes[] = 'function chronoforms_fields_events(){';
            foreach ($form->form['Form']['extras']['fields'] as $k => $field) {
                if (!empty($field['id']) and !empty($field['events'])) {
                    if ($field['type'] == 'dropdown') {
                        $change_event = 'change';
                    } else {
                        $change_event = 'click';
                    }
                    $_f = '$("[name=\'' . $field['name'] . '\']").on("' . $change_event . '", function(){';
                    $_l = '});';
                    $_m = array();
                    foreach ($field['events'] as $k => $event_data) {
                        if (strlen($event_data['action']) and strlen($event_data['target'])) {
                            $_m[] = $this->create_event($field, $event_data, $form);
                        }
                    }
                    if (!empty($_m)) {
                        $events_codes[] = $_f . "\n" . implode("\n", $_m) . "\n" . $_l;
                        $pageload_events_codes[] = implode("\n", $_m);
                    }
                }
                if (!empty($field['inputs'])) {
                    foreach ($field['inputs'] as $fn => $field_input) {
                        if (!empty($field_input['id']) and !empty($field_input['events'])) {
                            if ($field_input['type'] == 'dropdown') {
                                $change_event = 'change';
                            } else {
                                $change_event = 'click';
                            }
                            $_f = '$("[name=\'' . $field_input['name'] . '\']").on("' . $change_event . '", function(){';
                            $_l = '});';
                            $_m = array();
                            foreach ($field_input['events'] as $k => $event_data) {
                                if (strlen($event_data['action']) and strlen($event_data['target'])) {
                                    $_m[] = $this->create_event($field_input, $event_data, $form);
                                }
                            }
                            if (!empty($_m)) {
                                $events_codes[] = $_f . "\n" . implode("\n", $_m) . "\n" . $_l;
                                $pageload_events_codes[] = implode("\n", $_m);
                            }
                        }
                    }
                }
            }
            //check new fields events
            if (!empty($form->form['Form']['extras']['jsevents'])) {
                $jsevents_codes = array();
                foreach ($form->form['Form']['extras']['jsevents'] as $k => $jsevent_info) {
                    if (empty($jsevent_info['source'])) {
                        continue;
                    }
                    //$source = $this->get_field_selector($jsevent_info['source'], $form);
                    $target = !empty($jsevent_info['target']) ? $this->get_field_selector($jsevent_info['target'], $form) : '';
                    $event_trigger = $this->get_event_trigger($jsevent_info, $form);
                    $type = $jsevent_info['type'];
                    $jsevent_class = '\\GCore\\Admin\\Extensions\\Chronoforms\\Events\\' . \GCore\Libs\Str::camilize($type) . '\\' . \GCore\Libs\Str::camilize($type);
                    $jsevents_codes[] = str_replace('__FUNCTION__', $jsevent_class::output($target, $jsevent_info, $form), $event_trigger);
                }
                $events_codes = array_merge($events_codes, $jsevents_codes);
            }
            $events_codes[] = '}';
            $events_codes[] = 'chronoforms_fields_events();';
            $events_codes[] = 'function chronoforms_pageload_fields_events(){';
            $events_codes[] = implode("\n", $pageload_events_codes);
            $events_codes[] = '}';
            $events_codes[] = 'chronoforms_pageload_fields_events();';
            //$form->execute('js', array('content' => implode("\n", $events_codes)));
        }
        ob_start();
        eval('?>' . $form->form['Form']['content']);
        $output = ob_get_clean();
        $form_content = $output;
        //select the page to display
        $form_pages = explode('<!--_CHRONOFORMS_PAGE_BREAK_-->', $output);
        $active_page_index = (int) $config->get('page', 1) - 1;
        $output = $form_pages[$active_page_index];
        //get current url
        $current_url = \GCore\Libs\Url::current();
        if ((bool) $config->get('relative_url', 1) === false) {
            $current_url = r_('index.php?ext=chronoforms');
        }
        //generate <form tag
        $form_tag = '<form';
        $form_action = strlen($config->get('action_url', '')) > 0 ? $config->get('action_url', '') : \GCore\Libs\Url::buildQuery($current_url, array('chronoform' => $form->form['Form']['title'], 'event' => $config->get('submit_event', 'submit')));
        $form_tag .= ' action="' . r_($form_action, (bool) $config->get('xhtml_url', 0)) . '"';
        //get method
        $form_method = $config->get('form_method', 'post');
        if ($config->get('form_method', 'post') == 'file') {
            $form_tag .= ' enctype="multipart/form-data"';
            $form_method = 'post';
        }
        $form_tag .= ' method="' . $form_method . '"';
        $form_tag .= ' name="' . $form->form['Form']['title'] . '"';
        //$form_id = 'chronoform-'.$form->form['Form']['title'];
        $form_tag .= ' id="' . $form_id . '"';
        $form_tag .= ' class="' . $config->get('form_class', 'chronoform') . ($theme == 'bootstrap3' ? ' form-horizontal' : '') . '"';
        if ($config->get('form_tag_attach', '')) {
            $form_tag .= ' ' . trim($config->get('form_tag_attach', ''));
        }
        $form_tag .= '>';
        if (empty($theme)) {
            $doc->_('forms');
        }
        /*
        if($theme == 'bootstrap3'){
        	$doc->_('jquery');
        	$doc->_('bootstrap');
        	//echo '<div class="gcore chronoform-container">';
        }
        */
        $js_scripts = array();
        if (strpos($output, 'data-wysiwyg="1"') !== false) {
            $doc->_('jquery');
            $doc->_('editor');
            $js_scripts[] = '$(\'*[data-wysiwyg="1"]\').each(function(){ tinymce.init({"selector":"#"+$(this).attr("id")}); });';
        }
        if (strpos($form_content, 'validate[') !== false) {
            $doc->_('jquery');
            $doc->_('gtooltip');
            $doc->_('gvalidation', array('lang' => $form->params->get('js_validation_language', 'en')));
            $js_scripts[] = '$("#' . $form_id . '").gvalidate();';
            $js_scripts[] = '
				$("#' . $form_id . '").find(":input").on("invalid.gvalidation", function(){
					var field = $(this);
					if(field.is(":hidden")){
						if(field.closest(".tab-pane").length > 0){
							var tab_id = field.closest(".tab-pane").attr("id");
							$(\'a[href="#\'+tab_id+\'"]\').closest(".nav").gtabs("get").show($(\'a[href="#\'+tab_id+\'"]\'));
						}
						if(field.closest(".panel-collapse").length > 0){
							var slider_id = field.closest(".panel-collapse").attr("id");
							$(\'a[href="#\'+slider_id+\'"]\').closest(".panel-group").gsliders("get").show($(\'a[href="#\'+slider_id+\'"]\'));
						}
					}
					if(field.data("wysiwyg") == "1"){
						field.data("gvalidation-target", field.parent());
					}
				});
				$("#' . $form_id . '").on("success.gvalidation", function(e){
					if($("#' . $form_id . '").data("gvalidate_success")){
						var gvalidate_success = $("#' . $form_id . '").data("gvalidate_success");
						if(gvalidate_success in window){
							window[gvalidate_success](e, $("#' . $form_id . '"));
						}
					}
				});
				$("#' . $form_id . '").on("fail.gvalidation", function(e){
					if($("#' . $form_id . '").data("gvalidate_fail")){
						var gvalidate_fail = $("#' . $form_id . '").data("gvalidate_fail");
						if(gvalidate_fail in window){
							window[gvalidate_fail](e, $("#' . $form_id . '"));
						}
					}
				});
			';
            if ($config->get('required_labels_identify', 1)) {
                if (strpos($form->params->get('theme', 'bootstrap3'), 'bootstrap3') !== false) {
                    $required_icon = '<i class=\'fa fa-asterisk\' style=\'color:#ff0000; font-size:9px; vertical-align:top;\'></i>';
                } else {
                    $required_icon = '<span style=\'color:#ff0000; font-size:12px; vertical-align:top;\'>*</span>';
                }
                $js_scripts[] = '
					function chronoforms_validation_signs(formObj){
						formObj.find(":input[class*=validate]").each(function(){
							if($(this).attr("class").indexOf("required") >= 0 || $(this).attr("class").indexOf("group") >= 0){
								var required_parent = [];
								if($(this).closest(".gcore-subinput-container").length > 0){
									var required_parent = $(this).closest(".gcore-subinput-container");
								}else if($(this).closest(".gcore-form-row, .form-group").length > 0){
									var required_parent = $(this).closest(".gcore-form-row, .form-group");
								}
								if(required_parent.length > 0){
									var required_label = required_parent.find("label");
									if(required_label.length > 0 && !required_label.first().hasClass("required_label")){
										required_label.first().addClass("required_label");
										required_label.first().html(required_label.first().html() + " ' . $required_icon . '");
									}
								}
							}
						});
					}
					chronoforms_validation_signs($("#chronoform-' . $form->form['Form']['title'] . '"));
				';
            }
        }
        if (strpos($form_content, 'data-tooltip') !== false) {
            $doc->_('jquery');
            $doc->_('gtooltip');
            if (strpos($form->params->get('theme', 'bootstrap3'), 'bootstrap3') !== false) {
                $tip_icon = '<i class=\'fa fa-exclamation-circle input-tooltip\' style=\'color:#2693FF; padding-left:5px;\'></i>';
            } else {
                $tip_icon = '<span style=\'color:#ff0000; font-size:12px; vertical-align:top;\'>!</span>';
            }
            $js_scripts[] = '
				function chronoforms_data_tooltip(formObj){
					formObj.find(":input").each(function(){
						if($(this).data("tooltip") && $(this).closest(".gcore-input, .gcore-input-wide").length > 0){
							var tipped_parent = [];
							if($(this).closest(".gcore-subinput-container").length > 0){
								var tipped_parent = $(this).closest(".gcore-subinput-container");
							}else if($(this).closest(".gcore-form-row, .form-group").length > 0){
								var tipped_parent = $(this).closest(".gcore-form-row, .form-group");
							}
							if(tipped_parent.length > 0){
								var tipped_label = tipped_parent.find("label");
								if(tipped_label.length > 0 && !tipped_label.first().hasClass("tipped_label")){
									tipped_label.first().addClass("tipped_label");
									var $tip = $("' . $tip_icon . '");
									$tip.data("content", $(this).data("tooltip"));
									tipped_label.first().append($tip);
								}
							}
						}
					});
					formObj.find(".input-tooltip").gtooltip();
				}
				chronoforms_data_tooltip($("#chronoform-' . $form->form['Form']['title'] . '"));
			';
        }
        if (strpos($form_content, 'data-load-state') !== false) {
            $doc->_('jquery');
            $js_scripts[] = '
				function chronoforms_data_loadstate(formObj){
					formObj.find(\':input[data-load-state="disabled"]\').prop("disabled", true);
					formObj.find(\'*[data-load-state="hidden"]\').css("display", "none");
					formObj.find(\':input[data-load-state="hidden_parent"]\').each(function(){
						if($(this).closest(".gcore-subinput-container").length > 0){
							$(this).closest(".gcore-subinput-container").css("display", "none");
						}else if($(this).closest(".gcore-form-row").length > 0){
							$(this).closest(".gcore-form-row").css("display", "none");
						}
					});
				}
				chronoforms_data_loadstate($("#chronoform-' . $form->form['Form']['title'] . '"));
			';
        }
        if (strpos($output, 'data-inputmask=') !== false) {
            $doc->_('jquery');
            $doc->_('jquery.inputmask');
            $js_scripts[] = '$(":input").inputmask();';
        }
        if (strpos($output, 'data-gdatetimepicker') !== false or strpos($output, 'data-fieldtype="gdatetimepicker"') !== false) {
            $doc->_('jquery');
            $doc->_('gdatetimepicker');
            $js_scripts[] = '
			$(\'*[data-gdatetimepicker-format]\').each(function(){
				$(this).data("format", $(this).data("gdatetimepicker-format"));
			});
			';
            //for old data attributes
            $js_scripts[] = '$(\'*[data-gdatetimepicker="1"]\').gdatetimepicker();';
            //for old data attributes
            $js_scripts[] = '$(\'*[data-fieldtype="gdatetimepicker"]\').gdatetimepicker();';
            $js_scripts[] = '
			$(":input").on("select_date.gdatetimepicker", function(){
				if($(this).data("on_date_selected")){
					var on_date_selected = $(this).data("on_date_selected");
					if(on_date_selected in window){
						window[on_date_selected]($(this));
					}
				}
			});
			';
        }
        if (strpos($output, 'multiplier-container') !== false) {
            $doc->_('jquery');
            $js_scripts[] = '
				$(".multiplier-container").each(function(){
					if(typeof($(this).data("hide_first")) != "undefined"){
						$(this).find(".multiplier-contents").first().hide();
					}
					if(typeof($(this).data("disable_first")) != "undefined"){
						$(this).find(".multiplier-contents").first().find(":input").prop("disabled", true);
					}
					if($(this).find(".multiplier-contents").length > 1){
						var counter = $(this).find(".multiplier-contents").length;
						$(this).data("count", counter);
					}
				});
				$(".multiplier-container").find(".multiplier-add-button").on("click", function(){
					var multiplier_container = $(this).closest(".multiplier-container");
					
					var multiplier_clone = multiplier_container.find(".multiplier-contents").first().clone();
					multiplier_clone.find(".multiplier-remove-button").first().css("display", "");
					multiplier_clone.show();
					multiplier_clone.find(":input").prop("disabled", false);
					
					if(typeof(multiplier_container.data("replacer")) != "undefined"){
						var counter = parseInt(multiplier_container.data("count"));
						var multiplier_clone = multiplier_clone.wrap("<p>").parent().html().replace(new RegExp(multiplier_container.data("replacer"), "g"), counter);
						multiplier_container.data("count", counter + 1);
					}
					multiplier_container.find(".multiplier-contents").last().after(multiplier_clone);
				});
				$(document).on("click", ".multiplier-remove-button", function(){
					$(this).closest(".multiplier-contents").remove();
				});
			';
        }
        if ((bool) $config->get('ajax_submit', 0) === true) {
            $doc->_('jquery');
            $doc->_('gtooltip');
            $doc->_('gvalidation', array('lang' => $form->params->get('js_validation_language', 'en')));
            $ajax_url = \GCore\Libs\Url::buildQuery($form_action, array('tvout' => 'ajax'));
            $js_scripts[] = '
					function chrono_ajax_submit(){
						$(document).on("click", "#' . $form_id . ' :input[type=submit]", function(event){
							$("#' . $form_id . '").append("<input type=\'hidden\' name=\'"+$(this).attr("name")+"\' value=\'"+$(this).val()+"\' />");
						});
						
						var files;
						$("input[type=file]").on("change", function(event){
							files = event.target.files;
						});
						
						$(document).on("submit", "#' . $form_id . '", function(event){
							var overlay = $("<div/>").css({
								"position": "fixed",
								"top": "0",
								"left": "0",
								"width": "100%",
								"height": "100%",
								"background-color": "#000",
								"filter": "alpha(opacity=50)",
								"-moz-opacity": "0.5",
								"-khtml-opacity": "0.5",
								"opacity": "0.5",
								"z-index": "10000",
								"background-image":"url(\\"' . \GCore\Helpers\Assets::image('loading-small.gif') . '\\")",
								"background-position":"center center",
								"background-repeat":"no-repeat",
							});
							if(!$("#' . $form_id . '").hasClass("form-overlayed")){
								$("#' . $form_id . '").append(overlay);
								$("#' . $form_id . '").addClass("form-overlayed");
							}
							var form_action = $("#' . $form_id . '").prop("action");
							var sep = (form_action.indexOf("?") > -1) ? "&" : "?";
							var ajax_url = form_action + sep + "tvout=ajax";
							
							//data processing
							$.ajax({
								"type" : "POST",
								"url" : ajax_url,
								"data" : $("#' . $form_id . '").serialize(),
								"success" : function(res){
									$("#' . $form_id . '").replaceWith(res);
									$("#' . $form_id . '").gvalidate();
									chronoforms_fields_events();
									chronoforms_validation_signs($("#' . $form_id . '"));
									chronoforms_data_tooltip($("#' . $form_id . '"));
									chronoforms_data_loadstate($("#' . $form_id . '"));
									if(typeof chronoforms_pageload_fields_events == "function"){
										chronoforms_pageload_fields_events();
									}
									//chrono_ajax_submit();//this line duplicates submissions, should be removed
								},
							});
							return false;
						});
					}
					chrono_ajax_submit();
				';
        }
        $js_scripts[] = implode("\n", $events_codes);
        if (!empty($js_scripts)) {
            $doc->addJsCode('jQuery(document).ready(function($){
				' . implode("\n", $js_scripts) . '
			});');
        }
        if ((bool) $config->get('add_form_tags', 1) === true) {
            echo $form_tag;
        }
        //if ajax then display system messages inside the form
        if ((bool) $config->get('ajax_submit', 0) === true) {
            $doc = \GCore\Libs\Document::getInstance();
            $doc->addCssFile('system_messages');
            $session = \GCore\Libs\Base::getSession();
            $types = $session->getFlash();
            echo \GCore\Helpers\Message::render($types);
        }
        //add fields values
        $output = \GCore\Helpers\DataLoader::load($output, $form->data);
        $output = \GCore\Libs\Str::replacer($output, $form->data, array('repeater' => 'repeater'));
        //show output
        echo $output;
        if ((bool) $config->get('add_form_tags', 1) === true) {
            echo '</form>';
        }
    }