public static function js($name, $path = "") { if (strtolower(substr($name, -3, 3)) != '.js') { $name .= ".js"; } return \GCore\C::get('GCORE_FRONT_URL') . "assets/js/" . $path . $name; }
public static function on_editor_enable($id, $params = array()) { if (self::$settings->get('active_editor', 'tinymce') == 'tinymce') { $doc = \GCore\Libs\Document::getInstance(); //$params = array_merge(array('script_url' => \GCore\C::get('GCORE_FRONT_URL').'extensions/editors/assets/tinymce/tinymce.js'), $params); //$doc->addJsCode('jQuery(document).ready(function($){$("'.$id.'").tinymce('.stripslashes(json_encode($params)).');});'); $params = array_merge(array('selector' => $id), $params); $doc->addJsCode('jQuery(document).ready(function($){ tinymce.init(' . stripslashes(json_encode($params)) . '); });'); return true; } else { if (self::$settings->get('active_editor', 'tinymce') == 'ckeditor') { $doc = \GCore\Libs\Document::getInstance(); $doc->addJsCode('jQuery(document).ready(function($){CKEDITOR.replace("' . str_replace('#', '', $id) . '", ' . stripslashes(json_encode($params)) . ');});'); return true; } else { if (self::$settings->get('active_editor', 'tinymce') == 'sceditor') { $doc = \GCore\Libs\Document::getInstance(); $doc->addJsCode('jQuery(document).ready( function($){ $("' . $id . '").sceditor({ plugins: "bbcode", emoticonsRoot: "' . \GCore\C::get('GCORE_FRONT_URL') . 'extensions/editors/assets/sceditor/", style: "' . \GCore\C::get('GCORE_FRONT_URL') . 'extensions/editors/assets/sceditor/jquery.sceditor.default.min.css" }); } );'); return true; } } } }
function index() { $path = \GCore\C::get('GCORE_ADMIN_PATH') . 'extensions' . DS . 'chronoforms' . DS; $files = \GCore\Libs\Folder::getFiles($path, true); $strings = array(); //function to prepare strings $prepare = function ($str) { /*$path = \GCore\C::get('GCORE_FRONT_PATH'); if(strpos($str, $path) !== false AND strpos($str, $path) == 0){ return '//'.str_replace($path, '', $str); }*/ $val = !empty(\GCore\Libs\Lang::$translations[$str]) ? \GCore\Libs\Lang::$translations[$str] : ''; return 'const ' . trim($str) . ' = "' . str_replace("\n", '\\n', $val) . '";'; }; foreach ($files as $file) { if (substr($file, -4, 4) == '.php') { // AND strpos($file, DS.'extensions'.DS) === TRUE){ //$strings[] = $file; $file_code = file_get_contents($file); preg_match_all('/l_\\(("|\')([^(\\))]*?)("|\')\\)/i', $file_code, $langs); if (!empty($langs[2])) { $strings = array_merge($strings, $langs[2]); } } } $strings = array_unique($strings); $strings = array_map($prepare, $strings); echo '<textarea rows="20" cols="80">' . implode("\n", $strings) . '</textarea>'; }
public static function config() { echo \GCore\Helpers\Html::formStart('action_config file_download_action_config', 'file_download_action_config_{N}'); echo \GCore\Helpers\Html::formSecStart(); echo \GCore\Helpers\Html::formLine('Form[extras][actions_config][{N}][path]', array('type' => 'text', 'label' => l_('CF_FILE_DOWNLOAD_PATH'), 'value' => \GCore\C::ext_path('chronoforms', 'front'), 'class' => 'XXL', 'sublabel' => l_('CF_FILE_DOWNLOAD_PATH_DESC'))); echo \GCore\Helpers\Html::formSecEnd(); echo \GCore\Helpers\Html::formEnd(); }
function __construct($site = GCORE_SITE, $thread = 'gcore') { $this->path = \GCore\C::get('GCORE_' . strtoupper($site) . '_PATH'); $this->url = \GCore\C::get('GCORE_' . strtoupper($site) . '_URL'); $this->language = Base::getConfig('site_language', 'en-gb'); $this->site = $site; $this->thread = $thread; }
protected static function get_extensions() { if (is_null(self::$extensions)) { self::$extensions = \GCore\Admin\Models\Extension::getInstance()->find('list', array('cache' => true, 'fields' => array('id', 'name'), 'conditions' => array('enabled' => 1), 'order' => array('ordering ASC'))); } if (!in_array('editors', self::$extensions) and file_exists(\GCore\C::get('GCORE_FRONT_PATH') . 'extensions' . DS . 'editors' . DS)) { self::$extensions[] = 'editors'; } return self::$extensions; }
function execute(&$form, $action_id) { $config = $form->actions_config[$action_id]; $config = new \GCore\Libs\Parameter($config); if ((bool) $config->get('refresh_button', 0) === true) { $form->form['Form']['content'] = str_replace('{captcha_img}', '<img src="' . r_(\GCore\C::get('GCORE_ROOT_URL') . 'index.php?ext=chronoforms&act=render&action=load_captcha&chronoform=' . $form->form['Form']['title'] . '&action_id=' . $action_id . '&tvout=ajax&rand=' . mt_rand()) . '" alt="captcha" id="gcaptcha_' . $action_id . '" /><img src="' . \GCore\C::get('GCORE_FRONT_URL') . 'admin/extensions/chronoforms/actions/load_captcha/refresh.png" border="0" style="padding:0px 0px 15px 10px;" alt="refresh" onclick="document.getElementById(\'gcaptcha_' . $action_id . '\').src = \'' . r_(\GCore\C::get('GCORE_ROOT_URL') . 'index.php?ext=chronoforms&act=render&tvout=ajax&action=load_captcha&action_id=' . $action_id . '&chronoform=') . $form->form['Form']['title'] . '\' + \'&\' + Math.random();" />', $form->form['Form']['content']); } else { $form->form['Form']['content'] = str_replace('{captcha_img}', '<img src="' . r_(\GCore\C::get('GCORE_ROOT_URL') . 'index.php?ext=chronoforms&act=render&action=load_captcha&chronoform=' . $form->form['Form']['title'] . '&action_id=' . $action_id . '&tvout=ajax&rand=' . mt_rand()) . '" alt="captcha" />', $form->form['Form']['content']); } }
function execute(&$form, $action_id) { $config = $form->actions_config[$action_id]; $config = new \GCore\Libs\Parameter($config); //set the images path $upload_path = $config->get('upload_path', ''); if (!empty($upload_path)) { $upload_path = str_replace(array("/", "\\"), DS, $upload_path); if (substr($upload_path, -1) == DS) { $upload_path = substr_replace($upload_path, '', -1); } $upload_path = $upload_path . DS; $config->set('upload_path', $upload_path); } else { $upload_path = \GCore\C::ext_path('chronoforms', 'front') . 'uploads' . DS . $form->form['Form']['title'] . DS; } $image_file_name = $config->get('photo', ''); if (strpos($image_file_name, ',') !== false) { $image_file_names = explode(',', $image_file_name); } else { $image_file_names = array($image_file_name); } foreach ($image_file_names as $image_file_name) { //stop if the field name is not set or if the file data doesn't exist //if((strlen($image_file_name) == 0) || !isset($form->data[$image_file_name]) || !isset($form->files[$image_file_name]['path'])){ if (strlen($image_file_name) == 0 || !isset($form->files[$image_file_name])) { continue; } if ($form->files[$image_file_name] === array_values($form->files[$image_file_name])) { //array of files $reset = false; } else { $form->files[$image_file_name] = array($form->files[$image_file_name]); $reset = true; } foreach ($form->files[$image_file_name] as $k => $image) { // Common parameters $photo = $image['name']; //$form->data[$image_file_name]; $filein = $image['path']; $file_info = pathinfo($filein); $form->debug[$action_id][self::$title][] = $form->files[$image_file_name][$k]['thumb_big'] = $this->processSize('big', $form, $config, $form->actions_config[$action_id], $photo, $filein, $upload_path, $file_info); // treatment of the medium image $form->debug[$action_id][self::$title][] = $form->files[$image_file_name][$k]['thumb_med'] = $this->processSize('med', $form, $config, $form->actions_config[$action_id], $photo, $filein, $upload_path, $file_info); // treatment of the small image $form->debug[$action_id][self::$title][] = $form->files[$image_file_name][$k]['thumb_small'] = $this->processSize('small', $form, $config, $form->actions_config[$action_id], $photo, $filein, $upload_path, $file_info); if ($config->get('delete_original')) { unlink($filein); } } if ($reset) { $form->files[$image_file_name] = $form->files[$image_file_name][0]; } } }
function _finalize() { $tvout = \GCore\Libs\Request::data('tvout', ''); if ($this->_validated($this->fparams) === false and $tvout != 'ajax') { if (\GCore\C::get('GSITE_PLATFORM') == 'wordpress') { //echo '<p class="chrono_credits"><strong>Powered by ChronoForms - ChronoEngine.com</strong></p>'; } else { echo '<p class="chrono_credits"><a href="http://www.chronoengine.com" target="_blank">Powered by ChronoForms - ChronoEngine.com</a></p>'; } } }
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(); $ajax_url = $config->get('results_event', '') ? r_(\GCore\C::get('GCORE_ROOT_URL') . 'index.php?ext=chronoforms&chronoform=' . $form->form['Form']['title'] . '&event=' . $config->get('results_event', '') . '&tvout=ajax') : $config->get('results_url', ''); if ((bool) $form->params->get('jquery', 1) === true) { $doc->_('jquery'); } $doc->_('autocompleter'); $doc->__('autocompleter', $config->get('field_selector', '.auto_complete'), array('path' => $ajax_url, 'length' => $config->get('length', 2), 'multiple' => $config->get('multiple', 0))); }
function index() { //apply updates $sql = file_get_contents(\GCore\C::ext_path('chronoforms', 'admin') . 'sql' . DS . 'install.chronoforms.sql'); $queries = \GCore\Libs\Database::getInstance()->split_sql($sql); foreach ($queries as $query) { \GCore\Libs\Database::getInstance()->exec(\GCore\Libs\Database::getInstance()->_prefixTable($query)); } $session = \GCore\Libs\Base::getSession(); $session->setFlash('success', l_('CF_DB_TABLES_INSTALLED')); $this->redirect(r_('index.php?ext=chronoforms')); }
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(); $ajax_url = $config->get('results_event', '') ? r_(\GCore\C::get('GCORE_ROOT_URL') . 'index.php?ext=chronoforms&chronoform=' . $form->form['Form']['title'] . '&event=' . $config->get('results_event', '') . '&tvout=ajax') : $config->get('results_url', ''); $doc->_('jquery'); //$doc->_('autocompleter'); //$doc->__('autocompleter', $config->get('field_selector', '.auto_complete'), array('path' => $ajax_url, 'length' => $config->get('length', 2), 'multiple' => $config->get('multiple', 0))); $doc->_('select2'); $doc->addJsCode(' jQuery(document).ready(function($){ $("' . $config->get('field_selector', '') . '").select2( { minimumInputLength: ' . $config->get('length', 2) . ', containerCss:{"min-width":"200px"}, width: "element", multiple: ' . ($config->get('multiple', 0) ? 'true' : 'false') . ', //tags: true, tokenSeparators: [","," "], ajax:{ url: "' . $ajax_url . '", dataType: "json", data: function (term, page){ return { ' . $config->get('field_name', 'tag') . ': term, }; }, results: function (data, page){ return {results: data}; } }, formatNoMatches: "' . $config->get('no_matches_msg', 'Error!!') . '", formatSearching: "' . $config->get('searching_msg', 'Loading....') . '", formatAjaxError: "' . $config->get('ajax_error_msg', 'Loading failed....') . '", ' . ($config->get('multiple', 0) ? ' initSelection: function(element, callback){ var data = []; $(element.val().split(",")).each(function (){ data.push({id: this, text: this}); }); callback(data); } ' : ' initSelection: function(element, callback){ var data = {"id": $(element).val(), "text": $(element).val()}; callback(data); } ') . ' } ); });'); }
public static function sorter_build_link_params($text, $params, $drc, $active) { //$params = array(); if ($active) { $params['class'] = 'sort-link sorted-' . $drc; $params['style'] = !empty($params['style']) ? $params['style'] : array(); $params['style']['padding-right'] = '15px'; $params['style']['background'] = "right center url('" . \GCore\C::get('GCORE_FRONT_URL') . "assets/images/sort_" . $drc . ".png') no-repeat transparent"; $params['style'] = \GCore\Helpers\Html::styles($params['style']); } else { $params['class'] = 'sort-link'; } return array('params' => $params, 'text' => $text); }
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(); $doc->_('jquery'); $doc->addJsFile(\GCore\C::ext_url('chronoforms', 'admin') . 'actions/load_signature_pad/signature_pad.min.js'); $doc->addJsCode(' jQuery(document).ready(function($){ var wrapper = $("canvas").closest(".m-signature-pad"), clearButton = wrapper.find("[data-action=clear]"), saveButton = wrapper.find("[data-action=save]"), canvas = wrapper.find("canvas").get(0), signaturePad; function resizeCanvas() { var ratio = window.devicePixelRatio || 1; canvas.width = canvas.offsetWidth * ratio; canvas.height = canvas.offsetHeight * ratio; canvas.getContext("2d").scale(ratio, ratio); } window.onresize = resizeCanvas; resizeCanvas(); signaturePad = new SignaturePad(canvas, { "onEnd": function(){ wrapper.find("input[type=hidden]").val(signaturePad.toDataURL()); }, }); clearButton.on("click", function (event) { signaturePad.clear(); }); if(wrapper.find("input[type=hidden]").val()){ signaturePad.fromDataURL(wrapper.find("input[type=hidden]").val()); } });'); }
public static function url_to_abs($url) { return str_replace(array(\GCore\C::get('GCORE_FRONT_URL'), '/'), array(\GCore\C::get('GCORE_FRONT_PATH'), DS), $url); }
function delete_cache() { $path = \GCore\C::get('GCORE_FRONT_PATH') . 'cache' . DS; $files = \GCore\Libs\Folder::getFiles($path); $count = 0; foreach ($files as $k => $file) { if (basename($file) != 'index.html' and basename($file) != 'demos.cf5bak') { $result = \GCore\Libs\File::delete($file); if ($result) { $count++; } } } $session = \GCore\Libs\Base::getSession(); $session->setFlash('info', $count . ' ' . l_('CACHE_FILES_DELETED')); $this->redirect(r_('index.php?ext=chronoforms')); }
private static function getViewsPath($classname, $views_dir = 'views') { $dirs = explode('\\', $classname); $dirs = array_values(array_filter($dirs)); $strings = array(); foreach ($dirs as $k => $dir) { if ($dir === 'GCore') { //root dir $strings[] = \GCore\C::get('GCORE_FRONT_PATH'); continue; } if (empty($dirs[$k])) { //empty value continue; } //otherwise, uncamilize the namespace name to get the directory name $strings[] = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $dir)); } if ($strings[count($strings) - 1] == $strings[count($strings) - 2]) { //main controller used $strings[count($strings) - 1] = $views_dir; } elseif ($strings[count($strings) - 2] == 'controllers') { $strings[count($strings) - 2] = $views_dir; } return Str::fixSeparator(implode(DS, $strings), DS); }
function __call($name, $arguments = array()) { if (isset($this->connection['Connection']['extras'][$this->area]['actions'][$name]['code'])) { //$this->view = 'custom_act'; $this->view = \GCore\C::ext_path('chronoconnectivity', 'admin') . 'views' . DS . 'lists' . DS . 'custom_act.php'; $this->set('act_name', $name); } $this->set('connection', $this->connection); $this->set('area', $this->area); }
function is_alive() { if (\GCore\C::get('GSITE_PLATFORM') == '') { if (!$this->_active or $this->_expired or $this->_destroyed) { return false; } } return true; }
function processUpload(&$form, $file_post = array(), $field_name, $file_extensions) { //check valid file if (!\GCore\Libs\Upload::valid($file_post)) { return false; } //check not empty file upload if (!\GCore\Libs\Upload::not_empty($file_post)) { return false; } //check errors if (!isset($file_post['tmp_name']) or !is_uploaded_file($file_post['tmp_name'])) { if (!empty($file_post['error']) and $file_post['error'] !== UPLOAD_ERR_OK) { $form->debug[$action_id][self::$title][] = 'PHP returned this error for file upload by : ' . $field_name . ', PHP error is: ' . $file_post['error']; $form->errors[$field_name] = $file_post['error']; } $this->events['fail'] = 1; return false; } else { $form->debug[$action_id][self::$title][] = 'Upload routine started for file upload by : ' . $field_name; } if ((bool) $this->config->get('safe_file_name', 1) === true) { $file_name = \GCore\Libs\File::makeSafe($file_post['name']); } else { $file_name = utf8_decode($file_post['name']); } $real_file_name = $file_name; $file_tmp_name = $file_post['tmp_name']; $file_info = pathinfo($file_name); //mask the file name if (strlen($this->config->get('forced_file_name', '')) > 0) { $file_name = str_replace('FILE_NAME', $file_name, $this->config->get('forced_file_name', '')); } else { $file_name = date('YmdHis') . '_' . $file_name; } //check the file size if ($file_tmp_name) { //check max size if ($file_post['error'] === UPLOAD_ERR_INI_SIZE) { $form->debug[$action_id][self::$title][] = 'File : ' . $field_name . ' size is over the max PHP configured limit.'; $form->errors[$field_name] = $this->config->get('max_error', 'Sorry, Your uploaded file size (' . $file_post["size"] / 1024 . ' KB) exceeds the allowed limit.'); $this->events['fail'] = 1; return false; } elseif ($file_post["size"] / 1024 > (int) $this->config->get('max_size', 100)) { $form->debug[$action_id][self::$title][] = 'File : ' . $field_name . ' size is over the max limit.'; $form->errors[$field_name] = $this->config->get('max_error', 'Sorry, Your uploaded file size (' . $file_post["size"] / 1024 . ' KB) exceeds the allowed limit.'); $this->events['fail'] = 1; return false; } elseif ($file_post["size"] / 1024 < (int) $this->config->get('min_size', 0)) { $form->debug[$action_id][self::$title][] = 'File : ' . $field_name . ' size is less than the minimum limit.'; $form->errors[$field_name] = $this->config->get('min_error', 'Sorry, Your uploaded file size (' . $file_post["size"] / 1024 . ' KB) is less than the minimum limit.'); $this->events['fail'] = 1; return false; } elseif (!in_array(strtolower($file_info['extension']), $file_extensions)) { $form->debug[$action_id][self::$title][] = 'File : ' . $field_name . ' extension is not allowed.'; $form->errors[$field_name] = $this->config->get('type_error', 'Sorry, Your uploaded file type is not allowed.'); $this->events['fail'] = 1; return false; } else { $uploaded_file = \GCore\Libs\Upload::save($file_tmp_name, $this->upload_path . $file_name); if ($uploaded_file) { $uploaded_file_data = array(); $uploaded_file_data = array('name' => $file_name, 'original_name' => $real_file_name, 'path' => $this->upload_path . $file_name, 'size' => $file_post["size"]); //Try to generate an auto file link $site_link = \GCore\C::get('GCORE_FRONT_URL'); if (substr($site_link, -1) == "/") { $site_link = substr_replace($site_link, '', -1); } $uploaded_file_data['link'] = str_replace(array(\GCore\C::get('GCORE_FRONT_PATH'), DS), array($site_link, "/"), $this->upload_path . $file_name); //$form->data[$field_name] = $file_name; $form->debug[$action_id][self::$title][] = $this->upload_path . $file_name . ' has been uploaded successfully.'; $this->events['success'] = 1; return $uploaded_file_data; } else { $form->debug[$action_id][self::$title][] = $this->upload_path . $file_name . ' could not be uploaded!!'; $this->events['fail'] = 1; return false; } } } }
<?php } ?> <div class="row"<?php if (!empty($this->data['setup']) or !empty($this->data['Form']['params']['setup'])) { ?> style="display:none;"<?php } ?> > <?php $action_cats = array(); foreach ($actions_list as $action) { $action_class = '\\GCore\\Admin\\Extensions\\Chronoforms\\Actions\\' . \GCore\Libs\Str::camilize($action) . '\\' . \GCore\Libs\Str::camilize($action); if (class_exists($action_class)) { if (isset($action_class::$platforms) and !in_array(\GCore\C::get('GSITE_PLATFORM'), $action_class::$platforms)) { continue; } if (isset($action_class::$group)) { $group_ids = array_keys($action_class::$group); $actions_groups[$group_ids[0]][] = $action; $action_cats[$group_ids[0]] = $action_class::$group[$group_ids[0]]; } else { $actions_groups['1_basic'][] = $action; $action_cats['1_basic'] = l_('CF_BASIC'); } } } ksort($action_cats); ?> <div id="actions_list" class="col-md-2">
function _($name, $params = array()) { switch ($name) { case 'jquery': if (\GCore\C::get('GSITE_PLATFORM') == 'wordpress') { wp_enqueue_script('jquery'); } else { $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/jquery/jquery.js'); } break; case 'jquery-noconflict': $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/jquery/jquery-noconflict.js'); break; case 'jquery-migrate': if (\GCore\C::get('GSITE_PLATFORM') == 'wordpress') { wp_enqueue_script('jquery-migrate'); } else { $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/jquery/jquery-migrate.js'); } break; case 'jquery-ui': if (\GCore\C::get('GSITE_PLATFORM') == 'wordpress') { $jquery_ui = array("jquery-ui-core", "jquery-ui-widget", "jquery-ui-mouse", "jquery-ui-accordion", "jquery-ui-autocomplete", "jquery-ui-slider", "jquery-ui-tabs", "jquery-ui-sortable", "jquery-ui-draggable", "jquery-ui-droppable", "jquery-ui-selectable", "jquery-ui-position", "jquery-ui-datepicker", "jquery-ui-resizable", "jquery-ui-dialog", "jquery-ui-button"); foreach ($jquery_ui as $script) { wp_enqueue_script($script); } } else { $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/jquery/jquery-ui.js'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/jquery/ui-themes/' . Base::getConfig('jquery_theme', 'base') . '/jquery-ui.min.css'); } break; case 'bootstrap': $bs_style = !empty($params['style']) ? '-' . $params['style'] : ''; //$this->addJsFile(\GCore\C::get('GCORE_FRONT_URL').'assets/bootstrap/js/bootstrap.js'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/bootstrap/css/bootstrap' . $bs_style . '.css'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/bootstrap/css/bootstrap-theme.css'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/bootstrap/css/bootstrap-gcore.css'); //$this->addCssFile(\GCore\C::get('GCORE_FRONT_URL').'assets/bootstrap/css/bootstrap-ltr.css'); $this->_('font-awesome'); break; case 'bootstrap.js': $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/bootstrap/js/bootstrap.js'); break; case 'semantic-ui': $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/semantic-ui/js/semantic.min.js'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/semantic-ui/css/semantic.min.css'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/semantic-ui/css/semantic-gcore.css'); break; case 'semantic-ui.js': $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/semantic-ui/js/semantic.min.js'); break; case 'gcore-ui': $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gcore-ui/css/gcore-ui.css'); break; /*case 'font-awesome': $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL').'assets/font_awesome/css/font-awesome.css'); break;*/ /*case 'font-awesome': $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL').'assets/font_awesome/css/font-awesome.css'); break;*/ case 'jquery.validate': $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/jquery/jquery.validate.js'); break; case 'jquery.inputmask': $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/jquery/jquery.inputmask.js'); break; case 'gvalidation': $this->_('gtooltip'); $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/gvalidation/gvalidation.js'); if (!empty($params['lang'])) { $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/gvalidation/lang/' . $params['lang'] . '.js'); } $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/gvalidation/gvalidation.css'); break; case 'gdatetimepicker': $this->_('gtooltip'); $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/gdatetimepicker/gdatetimepicker.js'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/gdatetimepicker/gdatetimepicker.css'); break; case 'gmagnify': $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/gmagnify/gmagnify.js'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/gmagnify/gmagnify.css'); break; case 'gtooltip': $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/gtooltip/gtooltip.js'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/gtooltip/gtooltip.css'); break; case 'gmodal': $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/gmodal/gmodal.js'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/gmodal/gmodal.css'); break; case 'gdropdown': $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/gdropdown/gdropdown.js'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/gdropdown/gdropdown.css'); break; case 'gcompleter': $this->_('gdropdown'); $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/gcompleter/gcompleter.js'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/gcompleter/gcompleter.css'); break; case 'gtabs': $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/gtabs/gtabs.js'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/gtabs/gtabs.css'); break; case 'gsliders': $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/gsliders/gsliders.js'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/gsliders/gsliders.css'); break; case 'gloader': $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/gloader/gloader.js'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/gloader/gloader.css'); break; case 'guploader': $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/guploader/guploader.js'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/guploader/guploader.css'); break; case 'geditor': $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/geditor/geditor.js'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/geditor/geditor.css'); break; case 'select2': $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/select2/select2.min.js'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/select2/select2.css'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/select2/select2-bootstrap.css'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/select2/select2-gcore.css'); break; case 'keepalive': $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/js/keepalive.js'); break; case 'forms': $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/css/forms/' . Base::getConfig('forms_theme', 'default') . '.css'); break; case 'datatable': $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/css/datatable/' . Base::getConfig('tables_theme', 'default') . '.css'); break; case 'autocompleter': $this->_('autocomplete'); $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/js/autocompleter/autocompleter.js'); break; case 'editor': //run editor files load hook $hook_results = \GCore\Libs\Event::trigger('on_editor_load'); if (in_array(true, $hook_results, true)) { break; } $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/geditor/geditor.js'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/gplugins/geditor/geditor.css'); break; case 'highlight': $this->addJsFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/highlight/highlight.pack.js'); $this->addCssFile(\GCore\C::get('GCORE_FRONT_URL') . 'assets/highlight/styles/' . (!empty($params['style']) ? $params['style'] : 'default') . '.css'); $this->addJsCode('hljs.initHighlightingOnLoad();'); break; default: break; } }
function __construct($area, $joption, $extension, $setup = null, $cont_vars = array()) { require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'gcloader.php'; if (phpversion('pdo') !== false and in_array('mysql', PDO::getAvailableDrivers())) { //good, we use PDO \GCore\Libs\Base::setConfig('db_adapter', 'joomla'); } else { \GCore\Libs\Base::setConfig('db_adapter', 'joomla'); } \GCore\C::set('EXTENSIONS_PATHS', array(dirname(__FILE__) . DS . 'admin' . DS . 'extensions' . DS => JPATH_SITE . DS . 'administrator' . DS . 'components' . DS, dirname(__FILE__) . DS . 'extensions' . DS => JPATH_SITE . DS . 'components' . DS)); \GCore\C::set('EXTENSIONS_URLS', array(\JFactory::getURI()->root() . 'libraries/cegcore/admin/extensions/' => \JFactory::getURI()->root() . 'administrator/components/', \JFactory::getURI()->root() . 'libraries/cegcore/extensions/' => \JFactory::getURI()->root() . 'components/')); \GCore\C::set('EXTENSIONS_NAMES', array('chronomigrator' => 'com_chronomigrator', 'chronoforms' => 'com_chronoforms5', 'chronoconnectivity' => 'com_chronoconnectivity5', 'chronoforums' => 'com_chronoforums', 'chronolistings' => 'com_chronolistings', 'chronocommunity' => 'com_chronocommunity', 'chronosearch' => 'com_chronosearch', 'chronocontact' => 'com_chronocontact', $extension => 'com_' . $joption)); //GCore\Libs\Url::$root_ext = array('components', 'com_'.$joption); \GCore\Bootstrap::initialize('joomla', array('component' => 'com_' . $joption, 'ext' => $extension)); $tvout = strlen(\GCore\Libs\Request::data('tvout', null)) > 0 ? \GCore\Libs\Request::data('tvout') : ''; $controller = \GCore\Libs\Request::data('cont', ''); $action = \GCore\Libs\Request::data('act', ''); if (is_callable($setup)) { $return_vars = $setup(); if (!empty($return_vars)) { $cont_vars = array_merge($cont_vars, $return_vars); } } if (isset($cont_vars['controller'])) { $controller = $cont_vars['controller']; } if (isset($cont_vars['action'])) { $action = $cont_vars['action']; } $cont_vars['_app_thread'] = 'gcore'; ob_start(); echo \GCore\Libs\AppJ::call($area, $extension, $controller, $action, $cont_vars); $output = ob_get_clean(); $output = \GCore\C::fix_urls($output); if ($tvout == 'ajax') { echo $output; $mainframe = \JFactory::getApplication(); $mainframe->close(); } else { ob_start(); $toolbar = \GCore\Helpers\Module::render(array('type' => 'toolbar', 'site' => 'admin', 'params' => '')); $messages = \GCore\Libs\AppJ::getSystemMessages(); echo \GCore\Libs\AppJ::getHeader(); if ($toolbar) { echo $toolbar; echo '<div style="clear:both;"></div>'; } echo $messages; //echo \GCore\Libs\AppJ::getHeader(); $system_output = ob_get_clean(); $system_output = \GCore\C::fix_urls($system_output); echo $system_output; echo $output; } }
<?php /* @copyright:ChronoEngine.com @license:GPLv2 */ defined('_JEXEC') or die('Restricted access'); defined("GCORE_SITE") or die; ?> <div class="chrono-page-container"> <div class="container" style="width:100%;"> <?php $this->Toolbar->addButton('show_data', r_('index.php?ext=chronoforms&act=show_data&table=' . $this->data['table'] . '&form_id=' . $this->data['form_id']), l_('CF_VIEW_RECORD'), \GCore\C::ext_url('chronoforms', 'admin') . 'assets/images/preview.png', 'submit_selectors'); $this->Toolbar->addButton('remove', r_('index.php?ext=chronoforms&act=delete_data&table=' . $this->data['table'] . '&form_id=' . $this->data['form_id']), 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('backup_records', r_('index.php?ext=chronoforms&act=backup_records&table=' . $this->data['table']), l_('CF_BACKUP_RECORDS'), \GCore\C::get('GCORE_ADMIN_URL') . 'extensions/chronoforms/assets/images/backup.png', 'submit_selectors'); $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'), $pkey => 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); }
} } } } if ($field_name_errors) { $forms[$k]['Form']['diagnostics'] .= '<div class="alert alert-danger">' . l_('CF_FIELD_NAME_ERRORS') . '</div>'; } if ($field_name_warnings) { if (\GCore\C::get('GSITE_PLATFORM') == 'wordpress') { $forms[$k]['Form']['diagnostics'] .= '<div class="alert alert-warning">' . sprintf(l_('CF_FIELD_NAME_WARNINGS'), implode(", ", $invalid_names_wp), "Wordpress") . '</div>'; } else { $forms[$k]['Form']['diagnostics'] .= '<div class="alert alert-warning">' . sprintf(l_('CF_FIELD_NAME_WARNINGS'), implode(", ", $invalid_names_j), "Joomla") . '</div>'; } } } $title_width_desc = function ($cell, $row) { $out = '<a href="' . r_('index.php?ext=chronoforms&act=edit&id={Form.id}') . '">{Form.title}</a>'; if (!empty($row['Form']['params']['description'])) { $out .= '<br><small>{Form.params.description}</small>'; } return $out; }; $this->DataTable->cells($forms, array('CHECK' => array('style' => array('width' => '5%'), 'html' => $this->Toolbar->selector('{Form.id}')), 'Form.title' => array('function' => $title_width_desc, 'style' => array('text-align' => 'left', 'width' => '20%')), 'Form.view' => array('style' => array('width' => '10%'), 'html' => '<a href="' . r_(\GCore\C::get('GCORE_ROOT_URL') . 'index.php?ext=chronoforms&chronoform={Form.title}') . '" target="_blank">' . l_('CF_VIEW_FORM') . '</a>'), 'Form.diagnostics' => array('style' => array('width' => '25%')), 'Form.tables' => array('style' => array('width' => '10%')), 'Form.app' => array('style' => array('width' => '10%')), 'Form.published' => array('link' => array(r_('index.php?ext=chronoforms&act=toggle&gcb={Form.id}&val=1&fld=published'), r_('index.php?ext=chronoforms&act=toggle&gcb={Form.id}&val=0&fld=published')), 'image' => array($this->Assets->image('disabled.png'), $this->Assets->image('enabled.png')), 'style' => array('width' => '5%')), 'Form.id' => array('style' => array('width' => '5%')))); echo $this->DataTable->build(); echo $this->DataTable->footerPanel($this->DataTable->_l($this->Paginator->getInfo()) . $this->DataTable->_r($this->Paginator->getNav())); echo $this->DataTable->footerPanel($this->DataTable->_r($this->Paginator->getList())); ?> </form> </div> </div> </div>
/* @copyright:ChronoEngine.com @license:GPLv2 */ defined('_JEXEC') or die('Restricted access'); defined("GCORE_SITE") or die; ?> <div class="chrono-page-container"> <div class="container" style="width:100%;"> <?php $doc = \GCore\Libs\Document::getInstance(); $doc->_('datatable'); $doc->_('jquery'); //$doc->_('jquery-ui'); $doc->_('bootstrap'); //$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();
public static function send($to = array(), $subject = '', $body = '', $attachments = array(), $other = array()) { if (!class_exists('PHPMailer')) { require_once \GCore\C::get('GCORE_FRONT_PATH') . 'vendors' . DS . 'phpmailer' . DS . 'PHPMailerAutoload.php'; } $mail = new \PHPMailer(); $mail->CharSet = 'utf-8'; //get recipients foreach ((array) $to as $address) { $mail->AddAddress(trim($address)); } //subject $mail->Subject = $subject; //reply to $reply_name = !empty($other['reply_name']) ? $other['reply_name'] : Base::getConfig('mail_reply_name'); $reply_email = !empty($other['reply_email']) ? $other['reply_email'] : Base::getConfig('mail_reply_email'); if (!empty($reply_name) and !empty($reply_email)) { $mail->AddReplyTo($reply_email, $reply_name); } //from $from_name = !empty($other['from_name']) ? $other['from_name'] : Base::getConfig('mail_from_name'); $from_email = !empty($other['from_email']) ? $other['from_email'] : Base::getConfig('mail_from_email'); $mail->SetFrom($from_email, $from_name); //set custom headers if (!empty($other['custom'])) { foreach ($other['custom'] as $k => $v) { $mail->addCustomHeader($k . ': ' . $v); } } //set CC and BCC if (!empty($other['cc'])) { foreach ($other['cc'] as $k => $cc) { $mail->AddCC($cc); } } if (!empty($other['bcc'])) { foreach ($other['bcc'] as $k => $bcc) { $mail->AddBCC($bcc); } } if ((bool) Base::getConfig('smtp', 0) === true or Base::getConfig('mail_method', 'phpmail') == 'smtp') { $mail->IsSMTP(); if (Base::getConfig('smtp_username') and Base::getConfig('smtp_password')) { $mail->SMTPAuth = true; } if (Base::getConfig('smtp_secure')) { $mail->SMTPSecure = Base::getConfig('smtp_secure'); } $mail->Host = Base::getConfig('smtp_host'); $mail->Port = Base::getConfig('smtp_port'); $mail->Username = Base::getConfig('smtp_username'); $mail->Password = Base::getConfig('smtp_password'); } else { if (Base::getConfig('mail_method', 'phpmail') == 'sendmail') { $mail->IsSendmail(); } } if (!isset($other['type']) or $other['type'] == 'html') { $mail->AltBody = strip_tags($body); //'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically //$body = nl2br($body); //$mail->MsgHTML($body); $mail->Body = $body; $mail->IsHTML(true); } else { $mail->Body = $body; $mail->IsHTML(false); } $mail->SMTPDebug = (int) Base::getConfig('smtp_debug', 0); //attachments foreach ((array) $attachments as $attachment) { if (is_array($attachment) and !empty($attachment['path'])) { $attachment = array_merge(array('name' => basename($attachment['path']), 'type' => 'application/octet-stream', 'encoding' => 'base64'), $attachment); $mail->AddAttachment($attachment['path'], $attachment['name'], $attachment['encoding'], $attachment['type']); } else { $mail->AddAttachment($attachment); } } if (!$mail->Send()) { $session = Base::getSession(); $session->setFlash('warning', 'Mailer Error: ' . $mail->ErrorInfo); return false; } return true; }
?> <div class="chrono-page-container"> <div class="container" style="width:100%;"> <?php //$this->Toolbar->setTitle(l_('CONNECTIONS_MANAGER')); $this->Toolbar->addButton('add', r_('index.php?ext=chronoconnectivity&act=edit'), l_('_NEW_'), $this->Assets->image('add', 'toolbar/')); $this->Toolbar->addButton('remove', r_('index.php?ext=chronoconnectivity&act=delete'), l_('DELETE'), $this->Assets->image('remove', 'toolbar/'), 'submit_selectors'); $this->Toolbar->addButton('copy', r_('index.php?ext=chronoconnectivity&act=copy'), l_('CONN_COPY'), \GCore\C::get('GCORE_ADMIN_URL') . 'extensions/chronoconnectivity/assets/images/copy.png', 'submit_selectors'); $this->Toolbar->addButton('create_table', r_('index.php?ext=chronoconnectivity&act=create_table'), l_('CONN_CREATE_TABLE'), \GCore\C::get('GCORE_ADMIN_URL') . 'extensions/chronoconnectivity/assets/images/database_table.png', 'link'); $this->Toolbar->addButton('delete_cache', r_('index.php?ext=chronoconnectivity&act=delete_cache'), l_('CONN_DELETE_CACHE'), \GCore\C::get('GCORE_ADMIN_URL') . 'extensions/chronoconnectivity/assets/images/delete_cache.png', 'link'); $this->Toolbar->addButton('backup', r_('index.php?ext=chronoconnectivity&act=backup'), l_('CONN_BACKUP'), \GCore\C::get('GCORE_ADMIN_URL') . 'extensions/chronoconnectivity/assets/images/backup.png', 'submit_selectors'); $this->Toolbar->addButton('restore', r_('index.php?ext=chronoconnectivity&act=restore'), l_('CONN_RESTORE'), \GCore\C::get('GCORE_ADMIN_URL') . 'extensions/chronoconnectivity/assets/images/restore.png'); ?> <div class="row"> <form action="<?php echo r_('index.php?ext=chronoconnectivity'); ?> " method="post" name="admin_form" id="admin_form"> <?php echo $this->DataTable->headerPanel($this->DataTable->_l('<h4>' . l_('CONNECTIONS_MANAGER') . '</h4>') . $this->DataTable->_r($this->Toolbar->renderBar())); $this->DataTable->create(); $this->DataTable->header(array('CHECK' => $this->Toolbar->selectAll(), 'Connection.title' => $this->Sorter->link(l_('TITLE'), 'Connection.title'), 'Connection.aview' => l_('ADMIN_VIEW'), 'Connection.fview' => l_('FRONT_VIEW'), 'Connection.published' => l_('PUBLISHED'), 'Connection.id' => $this->Sorter->link('ID', 'Connection.id'))); $this->DataTable->cells($connections, array('CHECK' => array('style' => array('width' => '5%'), 'html' => $this->Toolbar->selector('{Connection.id}')), 'Connection.title' => array('link' => r_('index.php?ext=chronoconnectivity&act=edit&id={Connection.id}'), 'style' => array('text-align' => 'left')), 'Connection.aview' => array('html' => '<a href="' . r_('index.php?ext=chronoconnectivity&cont=lists&act=index&ccname={Connection.title}') . '" target="_blank">View Connection</a>', 'style' => array('width' => '15%')), 'Connection.fview' => array('html' => '<a href="' . \GCore\C::get('GCORE_ROOT_URL') . r_('index.php?ext=chronoconnectivity&cont=lists&act=index&ccname={Connection.title}') . '" target="_blank">View Connection</a>', 'style' => array('width' => '15%')), 'Connection.published' => array('link' => array(r_('index.php?ext=chronoconnectivity&act=toggle&gcb={Connection.id}&val=1&fld=published'), r_('index.php?ext=chronoconnectivity&act=toggle&gcb={Connection.id}&val=0&fld=published')), 'image' => array($this->Assets->image('disabled.png'), $this->Assets->image('enabled.png')), 'style' => array('width' => '10%')), 'Connection.id' => array('style' => array('width' => '5%')))); echo $this->DataTable->build(); echo $this->DataTable->footerPanel($this->DataTable->_l($this->Paginator->getInfo()) . $this->DataTable->_r($this->Paginator->getNav())); echo $this->DataTable->footerPanel($this->DataTable->_r($this->Paginator->getList())); ?> </form> </div> </div> </div>
public static function _($link = '') { //no routing for admin if (GCORE_SITE == 'admin') { return $link; } if (\GCore\C::get('GSITE_PLATFORM') != '') { return $link; } //if sef is disabled, return if ((bool) Base::getConfig('sef_urls') === false) { return $link; } $web_root = Url::root(); //index.php, return if ($link == 'index.php' or empty($link) or $link == $web_root) { return $web_root; } //parse the link $link = str_replace($web_root, '', $link); $link_comps = parse_url($link); if (!empty($link_comps['host']) and $link_comps['host'] != $_SERVER['SERVER_NAME']) { //external URL, return as is return $link; } if (!empty($link_comps['query'])) { parse_str($link_comps['query'], $vars); if (!empty($vars['ext'])) { //run the router class $ext_router = '\\GCore\\Extensions\\' . Str::camilize($vars['ext']) . '\\' . Str::camilize($vars['ext']) . 'Router'; if (!class_exists($ext_router)) { goto end; } //some url params should be processed if ((bool) Base::getConfig('sef_rewrite') === true) { $chunks = array(); } else { $chunks = array('index.php'); } $chunks['ext'] = $vars['ext']; unset($vars['ext']); if (method_exists($ext_router, '_')) { $chunks = array_merge($chunks, (array) $ext_router::_($vars)); } else { if (!empty($ext_router::$params) and !empty($vars)) { foreach ($ext_router::$params as $k => $param) { //check if param index exists in the current path if (isset($vars[$param])) { $chunks[] = $vars[$param]; unset($vars[$param]); } else { //break on the first non existent param break; } } } } $sef_link = implode('/', $chunks); if (!empty($vars)) { $sef_link .= '?' . http_build_query($vars); } return $web_root . $sef_link; } elseif (empty($vars['ext']) and !empty($vars['cont'])) { //run the router class $cont_router = '\\GCore\\Controllers\\' . Str::camilize($vars['cont']) . 'Router'; if (!class_exists($cont_router)) { goto end; } //some url params should be processed if ((bool) Base::getConfig('sef_rewrite') === true) { $chunks = array(); } else { $chunks = array('index.php'); } if ($vars['cont'] != 'pages') { $chunks['cont'] = $vars['cont']; } unset($vars['cont']); if (method_exists($cont_router, '_')) { $chunks = array_merge($chunks, (array) $cont_router::_($vars)); } else { if (!empty($cont_router::$params) and !empty($vars)) { foreach ($cont_router::$params as $k => $param) { //check if param index exists in the current path if (isset($vars[$param])) { $chunks[] = $vars[$param]; unset($vars[$param]); } else { //break on the first non existent param break; } } } } $sef_link = implode('/', $chunks); if (!empty($vars)) { $sef_link .= '?' . http_build_query($vars); } return $web_root . $sef_link; } } end: return $web_root . $link; }
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(); //if the content box was empty, display the form output if(empty($output)){ $output = $form->form_output; } $output = \GCore\Libs\Str::replacer($output, $form->data); //begin tcpdf code require_once('tcpdf/config/lang/eng.php'); require_once('tcpdf/tcpdf.php'); // create new PDF document $pdf = new \TCPDF($config->get('pdf_page_orientation', 'P'), PDF_UNIT, $config->get('pdf_page_format', 'A4'), true, 'UTF-8', false); //set protection if enabled if((bool)$config->get('enable_protection', 0) === true){ $owner_pass = ($config->get('owner_pass', "") ? $config->get('owner_pass', "") : null); $perms = (strlen($config->get('permissions', "")) > 0) ? explode(",", $config->get('permissions', "")) : array(); $pdf->SetProtection($perms, $config->get('user_pass', ""), $owner_pass, $config->get('sec_mode', ""), $pubkeys=null); } // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor($config->get('pdf_author', 'PDF Author.')); $pdf->SetTitle($config->get('pdf_title', 'PDF Title Goes Here.')); $pdf->SetSubject($config->get('pdf_subject', 'Powered by Chronoforms + TCPDF')); $pdf->SetKeywords($config->get('pdf_keywords', 'Chronoforms, PDF Plugin, TCPDF, PDF, '.$form->form['Form']['title'])); // Willian // set header data, font and margins if((bool)$config->get((bool)$config->get('pdf_header_show', 1))){ if(strlen($config->get('pdf_title')) OR strlen($config->get('pdf_header'))){ $pdf->SetHeaderData(false, 0, $config->get('pdf_title', 'PDF Title Goes Here.'), $config->get('pdf_header', 'Powered by Chronoforms + TCPDF')); } $pdf->setHeaderFont(Array($config->get('pdf_header_font', 'helvetica'), '', (int)$config->get('pdf_header_font_size', 10))); $pdf->SetHeaderMargin($config->get('pdf_margin_header', 5)); $pdf->setPrintHeader(true); } else { $pdf->setPrintHeader(false); } // set footer font and margins if((bool)$config->get((bool)$config->get('pdf_footer_show', 1))){ $pdf->setFooterFont(Array($config->get('pdf_footer_font', 'helvetica'), '', (int)$config->get('pdf_footer_font_size', 8))); $pdf->SetFooterMargin($config->get('pdf_margin_footer', 10)); $pdf->setPrintFooter(true); } else { $pdf->setPrintFooter(false); } // set default monospaced font $pdf->SetDefaultMonospacedFont($config->get('pdf_monospaced_font', 'courier')); //set margins $pdf->SetMargins($config->get('pdf_margin_left', 15), $config->get('pdf_margin_top', 27), $config->get('pdf_margin_right', 15)); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, $config->get('pdf_margin_bottom', 25)); //set image scale factor $pdf->setImageScale($config->get('pdf_image_scale_ratio', 1.25)); //set some language-dependent strings $pdf->setLanguageArray($l); // Willian // Mostrar/Esconder Cabeçalho $pdf->setPrintHeader((bool)$config->get('pdf_header_show', 1)); // Mostrar/Esconder Rodapé $pdf->setPrintHeader((bool)$config->get('pdf_footer_show', 1)); // --------------------------------------------------------- // set font $pdf->SetFont($config->get('pdf_body_font', 'courier'), '', (int)$config->get('pdf_body_font_size', 14)); // add a page $pdf->AddPage(); // create some HTML content $css = ""; $output = $css.$output; $html = $output; // output the HTML content $pdf->writeHTML($html, true, false, true, false, ''); // reset pointer to the last page $pdf->lastPage(); //Close and output PDF document if(isset($form->data['pdf_file_name']) && !empty($form->data['pdf_file_name'])){ $PDF_file_name = $form->data['pdf_file_name']; }else{ if(strlen(trim($config->get('pdf_file_name', ''))) > 0){ $PDF_file_name = trim($config->get('pdf_file_name', ''))."_".date('YmdHis'); }else{ $PDF_file_name = $form->form['Form']['title']."_".date('YmdHis'); } } $PDF_view = $config->get('pdf_view', 'I'); if(($PDF_view == 'F') || ($PDF_view == 'FI') || ($PDF_view == 'FD')){ jimport('joomla.utilities.error'); jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); $upload_path = $config->get('pdf_save_path'); if(!empty($upload_path)){ $upload_path = str_replace(array("/", "\\"), DS, $upload_path); if(substr($upload_path, -1) == DS){ $upload_path = substr_replace($upload_path, '', -1); } $upload_path = $upload_path.DS; $config->set('pdf_save_path', $upload_path); }else{ $upload_path = \GCore\C::ext_path('chronoforms', 'front').'pdfs'.DS.$form->form['Form']['title'].DS; } //check the save files path is ok if(!file_exists($upload_path.DS.'index.html')){ if(!\GCore\Libs\Folder::create($upload_path)){ $form->errors[] = "Couldn't create upload directory: ".$upload_path; $this->events['fail'] = 1; return; } $dummy_c = '<html><body bgcolor="#ffffff"></body></html>'; if(!\GCore\Libs\File::write($upload_path.DS.'index.html', $dummy_c)){ $form->errors[] = "Couldn't create upload directory index file."; $this->events['fail'] = 1; return; } } $PDF_file_path = $upload_path.$PDF_file_name.".pdf"; $pdf->Output($PDF_file_path, $PDF_view); //Try to generate an auto file link $site_link = \GCore\C::get('GCORE_FRONT_URL'); if(substr($site_link, -1) == "/"){ $site_link = substr_replace($site_link, '', -1); } if(strlen(trim($config->get('pdf_post_name', ''))) > 0){ $form->files[trim($config->get('pdf_post_name', ''))] = array('name' => $PDF_file_name.".pdf", 'path' => $PDF_file_path, 'size' => 0); $form->files[trim($config->get('pdf_post_name', ''))]['link'] = str_replace(array(\GCore\C::get('GCORE_FRONT_PATH'), DS), array($site_link, "/"), $upload_path.$PDF_file_name.".pdf"); $form->data[trim($config->get('pdf_post_name', ''))] = $PDF_file_name.".pdf"; $form->debug[$action_id][self::$title][] = $PDF_file_path.' has been saved correctly.'; } }else{ $pdf->Output($PDF_file_name.".pdf", $PDF_view); } if($PDF_view != 'F'){ @flush(); @ob_flush(); exit; } }