Exemplo n.º 1
0
 /**
  * Get the src(s) for the list plugin js class
  *
  * @return  mixed  string or array or null. If string then is relative path to either compressed or uncompress js file.
  */
 public function loadJavascriptClass_result()
 {
     $this->onGetFilterKey();
     $p = $this->onGetFilterKey_result();
     $ext = FabrikHelperHTML::isDebug() ? '.js' : '-min.js';
     $file = 'plugins/fabrik_list/' . $p . '/' . $p . $ext;
     return JFile::exists(JPATH_SITE . '/' . $file) ? $file : null;
 }
Exemplo n.º 2
0
 /**
  * Not really an AJAX call, we just use the pluginAjax method so we can run this
  * method for handling scripted downloads.
  *
  * @return  void
  */
 public function onAjax_download()
 {
     $input = $this->app->input;
     $this->setId($input->getInt('element_id'));
     $this->loadMeForAjax();
     $this->getElement();
     $params = $this->getParams();
     $url = $input->server->get('HTTP_REFERER', '', 'string');
     $this->lang->load('com_fabrik.plg.element.fabrikfileupload', JPATH_ADMINISTRATOR);
     $rowId = $input->get('rowid', '', 'string');
     $repeatCount = $input->getInt('repeatcount', 0);
     $listModel = $this->getListModel();
     $row = $listModel->getRow($rowId, false, true);
     if (!$this->canView()) {
         $this->app->enqueueMessage(FText::_('PLG_ELEMENT_FILEUPLOAD_DOWNLOAD_NO_PERMISSION'));
         $this->app->redirect($url);
         exit;
     }
     if (empty($rowId)) {
         $errMsg = FText::_('PLG_ELEMENT_FILEUPLOAD_DOWNLOAD_NO_SUCH_FILE');
         $errMsg .= FabrikHelperHTML::isDebug() ? ' (empty rowid)' : '';
         $this->app->enqueueMessage($errMsg);
         $this->app->redirect($url);
         exit;
     }
     if (empty($row)) {
         $errMsg = FText::_('PLG_ELEMENT_FILEUPLOAD_DOWNLOAD_NO_SUCH_FILE');
         $errMsg .= FabrikHelperHTML::isDebug() ? " (no such row)" : '';
         $this->app->enqueueMessage($errMsg);
         $this->app->redirect($url);
         exit;
     }
     $aclEl = $this->getFormModel()->getElement($params->get('fu_download_acl', ''), true);
     if (!empty($aclEl)) {
         $aclEl = $aclEl->getFullName();
         $aclElRaw = $aclEl . '_raw';
         $groups = $this->user->getAuthorisedViewLevels();
         $canDownload = in_array($row->{$aclElRaw}, $groups);
         if (!$canDownload) {
             $this->app->enqueueMessage(FText::_('PLG_ELEMENT_FILEUPLOAD_DOWNLOAD_NO_PERMISSION'));
             $this->app->redirect($url);
         }
     }
     $storage = $this->getStorage();
     $elName = $this->getFullName(true, false);
     $filePath = $row->{$elName};
     $filePath = FabrikWorker::JSONtoData($filePath, false);
     $filePath = is_object($filePath) ? FArrayHelper::fromObject($filePath) : (array) $filePath;
     $filePath = FArrayHelper::getValue($filePath, $repeatCount);
     $filePath = $storage->getFullPath($filePath);
     $fileContent = $storage->read($filePath);
     if ($fileContent !== false) {
         $thisFileInfo = $storage->getFileInfo($filePath);
         if ($thisFileInfo === false) {
             $errMsg = FText::_('PLG_ELEMENT_FILEUPLOAD_DOWNLOAD_NO_SUCH_FILE');
             $errMsg .= FabrikHelperHTML::isDebug(true) ? ' (path: ' . $filePath . ')' : '';
             $this->app->enqueueMessage($errMsg);
             $this->app->redirect($url);
             exit;
         }
         // Some time in the past
         header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
         header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
         header("Cache-Control: no-store, no-cache, must-revalidate");
         header("Cache-Control: post-check=0, pre-check=0", false);
         header("Pragma: no-cache");
         header('Accept-Ranges: bytes');
         header('Content-Length: ' . $thisFileInfo['filesize']);
         header('Content-Type: ' . $thisFileInfo['mime_type']);
         header('Content-Disposition: attachment; filename="' . $thisFileInfo['filename'] . '"');
         // Serve up the file
         echo $fileContent;
         // $this->downloadEmail($row, $filePath);
         $this->downloadHit($rowId, $repeatCount);
         $this->downloadLog($row, $filePath);
         // And we're done.
         exit;
     } else {
         $this->app->enqueueMessage(FText::_('PLG_ELEMENT_FILEUPLOAD_DOWNLOAD_NO_SUCH_FILE'));
         $this->app->redirect($url);
         exit;
     }
 }
Exemplo n.º 3
0
 /**
  * Get the class to manage the plugin
  * to ensure that the file is loaded only once
  *
  * @since   3.1b
  *
  * @return void
  */
 public function formJavascriptClass()
 {
     $formModel = $this->getModel();
     $ext = FabrikHelperHTML::isDebug() ? '.js' : '-min.js';
     $name = $this->get('_name');
     static $jsClasses;
     if (!isset($jsClasses)) {
         $jsClasses = array();
     }
     // Load up the default script
     $script = 'plugins/fabrik_form/' . $name . '/' . $name . $ext;
     if (empty($jsClasses[$script])) {
         $formModel->formPluginShim[ucfirst($name)] = $script;
         $jsClasses[$script] = 1;
     }
 }
Exemplo n.º 4
0
 /**
  * Get the src(s) for the list plugin js class
  *
  * @return  mixed   array or null. If array then key is class name and value
  * is relative path to either compressed or uncompress js file.
  */
 public function loadJavascriptClass_result()
 {
     $this->onGetFilterKey();
     $p = $this->onGetFilterKey_result();
     $ext = FabrikHelperHTML::isDebug() ? '.js' : '-min.js';
     $file = 'plugins/fabrik_list/' . $p . '/' . $p . $ext;
     if (JFile::exists(JPATH_SITE . '/' . $file)) {
         return array('FbList' . ucfirst($p) => $file);
     } else {
         return null;
     }
 }
Exemplo n.º 5
0
 /**
  * JS lib for OSRef
  * As different map instances may or may not load this we shouldn't put it in
  * formJavascriptClass() but call this code from elementJavascript() instead.
  * The files are still only loaded when needed and only once
  *
  * @return  void
  */
 protected function OSRefJs()
 {
     if (!isset(self::$OSRefJs)) {
         $params = $this->getParams();
         if ($params->get('fb_gm_latlng_osref')) {
             $ext = FabrikHelperHTML::isDebug() ? '.js' : '-min.js';
             FabrikHelperHTML::script('media/com_fabrik/js/lib/jscoord-1.1.1/jscoord-1.1.1' . $ext);
             self::$OSRefJs = true;
         }
     }
 }
Exemplo n.º 6
0
 /**
  * Get the class to manage the form element
  * to ensure that the file is loaded only once
  *
  * @param   array  &$srcs  Scripts previously loaded
  * @param   string $script Script to load once class has loaded
  * @param   array  &$shim  Dependant class names to load before loading the class - put in requirejs.config shim
  *
  * @return void
  */
 public function formJavascriptClass(&$srcs, $script = '', &$shim = array())
 {
     $key = FabrikHelperHTML::isDebug() ? 'element/date/date' : 'element/date/date-min';
     // Ensure that we keep advanced dependencies from previous date elements regardless of current elements settings.
     $deps = array_key_exists($key, $shim) ? $shim[$key]->deps : array();
     $params = $this->getParams();
     if ($params->get('date_advanced', '0') == '1' && !in_array('lib/datejs/date', $deps)) {
         $deps[] = 'lib/datejs/globalization/' . JFactory::getLanguage()->getTag();
         $deps[] = 'lib/datejs/core';
         $deps[] = 'lib/datejs/parser';
         $deps[] = 'lib/datejs/extras';
     }
     if (count($deps) > 0) {
         $s = new stdClass();
         $s->deps = $deps;
         $shim[$key] = $s;
     }
     parent::formJavascriptClass($srcs, $script, $shim);
     // Return false, as we need to be called on per-element (not per-plugin) basis
     return false;
 }
Exemplo n.º 7
0
 /**
  * Load the javascript class that manages plugin interaction
  * should only be called once
  *
  * @return  string  Javascript class file
  */
 public function loadJavascriptClass()
 {
     $params = $this->getParams();
     $opts = array();
     $opts['container'] = 'radius_search_place_container';
     // Increase z-index with advanced class
     $opts['menuclass'] = 'auto-complete-container advanced';
     if ($params->get('myloc', 1) == 1) {
         $ext = FabrikHelperHTML::isDebug() ? '.js' : '-min.js';
         FabrikHelperHTML::script('media/com_fabrik/js/lib/geo-location/geo' . $ext);
     }
     parent::loadJavascriptClass();
 }
Exemplo n.º 8
0
 /**
  * Get the allowed dates based on evaluated PHP code
  *
  * @return multitype:|array
  */
 protected function getAllowedPHPDates()
 {
     $params = $this->getParams();
     $data = $this->getFormModel()->data;
     $php = $params->get('date_allow_php_func', '');
     $dates = array();
     if ($php === '') {
         return $dates;
     }
     $dates = FabrikHelperHTML::isDebug() ? eval($php) : @eval($php);
     FabrikWorker::logEval($dates, 'Eval exception : ' . $this->getElement()->name . '::getAllowedPHPDates() : %s');
     return (array) $dates;
 }
Exemplo n.º 9
0
 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a JError object.
  */
 public function display($tpl = 'default')
 {
     $srcs = FabrikHelperHTML::framework();
     FabrikHelperHTML::slimbox();
     $document = JFactory::getDocument();
     $usersConfig = JComponentHelper::getParams('com_fabrik');
     $model = $this->getModel();
     $model->setId(JRequest::getVar('id', $usersConfig->get('visualizationid', JRequest::getInt('visualizationid', 0))));
     $this->row = $model->getVisualization();
     $js = $model->getJs();
     $this->txt = $model->getText();
     $params = $model->getParams();
     $this->assign('params', $params);
     $tpl = $params->get('fb_gm_layout', $tpl);
     $tmplpath = JPATH_ROOT . '/plugins/fabrik_visualization/googlemap/views/googlemap/tmpl/' . $tpl;
     $srcs[] = 'media/com_fabrik/js/listfilter.js';
     $uri = JURI::getInstance();
     if ($params->get('fb_gm_center') == 'userslocation') {
         $document->addScript($uri->getScheme() . '://code.google.com/apis/gears/gears_init.js');
         $srcs[] = 'components/com_fabrik/libs/geo-location/geo.js';
     }
     $model->getPluginJsClasses($srcs);
     global $ispda;
     if ($ispda == 1) {
         // Pdabot
         $template = 'static';
         $this->assign('staticmap', $this->get('StaticMap'));
     } else {
         $src = $uri->getScheme() . '://maps.google.com/maps/api/js?sensor=' . $params->get('fb_gm_sensor', 'false');
         $document->addScript($src);
         if (FabrikHelperHTML::isDebug()) {
             $srcs[] = 'plugins/fabrik_visualization/googlemap/googlemap.js';
         } else {
             $srcs[] = 'plugins/fabrik_visualization/googlemap/googlemap-min.js';
         }
         if ((int) $this->params->get('fb_gm_clustering', '0') == 1) {
             if (FabrikHelperHTML::isDebug()) {
                 $srcs[] = 'components/com_fabrik/libs/googlemaps/markerclustererplus/src/markerclusterer.js';
             } else {
                 $srcs[] = 'components/com_fabrik/libs/googlemaps/markerclustererplus/src/markerclusterer_packed.js';
             }
         } else {
             // Doesn't work in v3
             // FabrikHelperHTML::script('components/com_fabrik/libs/googlemaps/markermanager.js');
         }
         FabrikHelperHTML::addScriptDeclaration($js);
         $template = null;
     }
     $js = $this->get('PluginJsObjects');
     $js .= $model->getFilterJs();
     FabrikHelperHTML::script($srcs, $js);
     FabrikHelperHTML::stylesheetFromPath('plugins/fabrik_visualization/googlemap/views/googlemap/tmpl/' . $tpl . '/template.css');
     // Check and add a general fabrik custom css file overrides template css and generic table css
     FabrikHelperHTML::stylesheetFromPath('media/com_fabrik/css/custom.css');
     // Check and add a specific viz template css file overrides template css generic table css and generic custom css
     FabrikHelperHTML::stylesheetFromPath('plugins/fabrik_visualization/googlemap/views/googlemap/tmpl/' . $tpl . '/custom.css');
     $this->assignRef('filters', $this->get('Filters'));
     $this->assign('showFilters', JRequest::getInt('showfilters', $params->get('show_filters')) === 1 ? 1 : 0);
     $this->assign('filterFormURL', $this->get('FilterFormURL'));
     $this->assign('sidebarPosition', $params->get('fb_gm_use_overlays_sidebar'));
     if ($this->get('ShowSideBar')) {
         $this->assign('showSidebar', 1);
         $this->assign('overlayUrls', (array) $params->get('fb_gm_overlay_urls'));
         $this->assign('overlayLabels', (array) $params->get('fb_gm_overlay_labels'));
     } else {
         $this->assign('showSidebar', 0);
     }
     $this->_setPath('template', $tmplpath);
     $this->assign('containerId', $this->get('ContainerId'));
     $this->assignRef('groupTemplates', $this->get('GroupTemplates'));
     echo parent::display($template);
 }
Exemplo n.º 10
0
/**
 * Bootstrap Tabs Form Template
 *
 * @package     Joomla
 * @subpackage  Fabrik
 * @copyright   Copyright (C) 2005-2015 fabrikar.com - All rights reserved.
 * @license     GNU/GPL http://www.gnu.org/copyleft/gpl.html
 * @since       3.1
 */
// No direct access
defined('_JEXEC') or die('Restricted access');
$form = $this->form;
$model = $this->getModel();
$groupTmpl = $model->editable ? 'group' : 'group_details';
$active = $form->error != '' ? '' : ' fabrikHide';
if ($model->isMultiPage() && FabrikHelperHTML::isDebug()) {
    $app = JFactory::getApplication();
    $app->enqueueMessage(FText::_('COM_FABRIK_ERR_TAB_FORM_TEMPLATE_INCOMPATIBLE_WITH_MULTIPAGE_FORMS'), 'error');
}
if ($this->params->get('show_page_heading', 1)) {
    ?>
	<div class="componentheading<?php 
    echo $this->params->get('pageclass_sfx');
    ?>
">
	<?php 
    echo $this->escape($this->params->get('page_heading'));
    ?>
	</div>
<?php 
}
Exemplo n.º 11
0
 /**
  * Get the class to manage the form element
  * to ensure that the file is loaded only once
  *
  * @param   array  &$srcs  Scripts previously loaded
  * @param   string $script Script to load once class has loaded
  * @param   array  &$shim  Dependant class names to load before loading the class - put in requirejs.config shim
  *
  * @return void
  */
 public function formJavascriptClass(&$srcs, $script = '', &$shim = array())
 {
     $key = FabrikHelperHTML::isDebug() ? 'element/digsig/digsig' : 'element/digsig/digsig-min';
     $s = new stdClass();
     $s->deps = array();
     $folder = 'element/digsig/libs/signature-pad/';
     $digsigShim = new stdClass();
     $digsigShim->deps = array($folder . 'jquery.signaturepad');
     $s->deps[] = $folder . 'jquery.signaturepad';
     $s->deps[] = $folder . 'flashcanvas';
     $shim[$folder . 'flashcanvas'] = $digsigShim;
     $s->deps[] = $folder . 'json2';
     $shim[$folder . 'json2'] = $digsigShim;
     $shim[$key] = $s;
     FabrikHelperHTML::stylesheet(COM_FABRIK_LIVESITE . 'plugins/fabrik_element/digsig/libs/signature-pad/jquery.signaturepad.css');
     parent::formJavascriptClass($srcs, $script, $shim);
     // $$$ hugh - added this, and some logic in the view, so we will get called on a per-element basis
     return false;
 }
Exemplo n.º 12
0
 /**
  * Perform calculation from ajax request
  *
  * @return  void
  */
 public function onAjax_calc()
 {
     $input = $this->app->input;
     $this->setId($input->getInt('element_id'));
     $this->loadMeForAjax();
     $params = $this->getParams();
     $w = new FabrikWorker();
     $filter = JFilterInput::getInstance();
     $d = $filter->clean($_REQUEST, 'array');
     $formModel = $this->getFormModel();
     $formModel->addEncrytedVarsToArray($d);
     $this->getFormModel()->data = $d;
     $this->swapValuesForLabels($d);
     $calc = $params->get('calc_calculation');
     $this->setStoreDatabaseFormat($d);
     // $$$ hugh - trying to standardize on $data so scripts know where data is
     $data = $d;
     $calc = $w->parseMessageForPlaceHolder($calc, $d);
     $c = FabrikHelperHTML::isDebug() ? eval($calc) : @eval($calc);
     $c = preg_replace('#(\\/\\*.*?\\*\\/)#', '', $c);
     echo $c;
 }
Exemplo n.º 13
0
 /**
  * Get the class to manage the form element
  * to ensure that the file is loaded only once
  *
  * @param   array   &$srcs   Scripts previously loaded
  * @param   string  $script  Script to load once class has loaded
  * @param   array   &$shim   Dependant class names to load before loading the class - put in requirejs.config shim
  *
  * @return void|boolean
  */
 public function formJavascriptClass(&$srcs, $script = '', &$shim = array())
 {
     $key = FabrikHelperHTML::isDebug() ? 'element/tags/tags' : 'element/tags/tags-min';
     $s = new stdClass();
     // Even though fab/element is now an AMD defined module we should still keep it in here
     // otherwise (not sure of the reason) jQuery.mask is not defined in field.js
     // Seems OK now - reverting to empty array
     $s->deps = array();
     $folder = 'media/jui/js/';
     $s->deps[] = $folder . 'ajax-chosen';
     if (array_key_exists($key, $shim)) {
         $shim[$key]->deps = array_merge($shim[$key]->deps, $s->deps);
     } else {
         $shim[$key] = $s;
     }
     parent::formJavascriptClass($srcs, $script, $shim);
     // $$$ hugh - added this, and some logic in the view, so we will get called on a per-element basis
     return false;
 }
Exemplo n.º 14
0
 /**
  * As different map instances may or may not load geo.js we shouldn't put it in
  * formJavascriptClass() but call this code from elementJavascript() instead.
  * The files are still only loaded when needed and only once
  *
  * @return  void
  */
 protected function geoJs()
 {
     if (!isset(self::$geoJs)) {
         $params = $this->getParams();
         if ($params->get('fb_gm_defaultloc')) {
             $ext = FabrikHelperHTML::isDebug() ? '.js' : '-min.js';
             FabrikHelperHTML::script('media/com_fabrik/js/lib/geo-location/geo' . $ext);
             self::$geoJs = true;
         }
     }
 }
Exemplo n.º 15
0
 /**
  * Load the javascript class that manages plugin interaction
  * should only be called once
  *
  * @return  string  Javascript class file
  */
 public function loadJavascriptClass()
 {
     $params = $this->getParams();
     $model = $this->getModel();
     $mapElement = $this->getMapElement();
     if (!is_object($mapElement)) {
         throw new RuntimeException('Radius search plug-in active but map element unpublished');
         return;
     }
     $opts = array();
     $opts['container'] = 'radius_search_place_container';
     // Increase z-index with advanced class
     $opts['menuclass'] = 'auto-complete-container advanced';
     $formId = $model->getFormModel()->get('id');
     if ($params->get('place', 1) == 1) {
         $el = $this->getPlaceElement();
         FabrikHelperHTML::autoComplete("radius_search_place{$this->renderOrder}", $el->getElement()->id, $formId, $el->getElement()->plugin, $opts);
     }
     if ($params->get('myloc', 1) == 1) {
         $ext = FabrikHelperHTML::isDebug() ? '.js' : '-min.js';
         FabrikHelperHTML::script('media/com_fabrik/js/lib/geo-location/geo' . $ext);
     }
     parent::loadJavascriptClass();
 }
Exemplo n.º 16
0
 /**
  * Get the class to manage the form element
  * to ensure that the file is loaded only once
  *
  * @param   array   &$srcs   Scripts previously loaded
  * @param   string  $script  Script to load once class has loaded
  * @param   array   &$shim   Dependant class names to load before loading the class - put in requirejs.config shim
  *
  * @return void
  */
 public function formJavascriptClass(&$srcs, $script = '', &$shim = array())
 {
     $name = $this->getElement()->plugin;
     $ext = FabrikHelperHTML::isDebug() ? '.js' : '-min.js';
     $shimKey = 'element/' . $name . '/' . $name;
     if (!array_key_exists($shimKey, $shim)) {
         $s = new stdClass();
         $s->deps = array('fab/element');
         $shim['element/' . $name . '/' . $name] = $s;
     }
     $formId = $this->getFormModel()->getId();
     static $elementClasses;
     if (!isset($elementClasses)) {
         $elementClasses = array();
     }
     if (!array_key_exists($formId, $elementClasses)) {
         $elementClasses[$formId] = array();
     }
     // Load up the default script
     if ($script == '') {
         $script = 'plugins/fabrik_element/' . $name . '/' . $name . $ext;
     }
     if (empty($elementClasses[$formId][$script])) {
         $srcs[] = $script;
         $elementClasses[$formId][$script] = 1;
     }
 }
Exemplo n.º 17
0
 /**
  * Get the class to manage the form element
  * to ensure that the file is loaded only once
  *
  * @param   array   &$srcs   Scripts previously loaded
  * @param   string  $script  Script to load once class has loaded
  * @param   array   &$shim   Dependant class names to load before loading the class - put in requirejs.config shim
  *
  * @return void|boolean
  */
 public function formJavascriptClass(&$srcs, $script = '', &$shim = array())
 {
     $key = FabrikHelperHTML::isDebug() ? 'element/field/field' : 'element/field/field-min';
     $params = $this->getParams();
     $inputMask = trim($params->get('text_input_mask', ''));
     $geoComplete = $params->get('autocomplete', '0') === '3';
     $s = new stdClass();
     // Even though fab/element is now an AMD defined module we should still keep it in here
     // otherwise (not sure of the reason) jQuery.mask is not defined in field.js
     // Seems OK now - reverting to empty array
     $s->deps = array();
     if (!empty($inputMask)) {
         $folder = 'components/com_fabrik/libs/masked_input/';
         $s->deps[] = $folder . 'jquery.maskedinput';
     }
     if ($geoComplete) {
         $folder = 'components/com_fabrik/libs/googlemaps/geocomplete/';
         $s->deps[] = $folder . 'jquery.geocomplete';
     }
     if (array_key_exists($key, $shim)) {
         $shim[$key]->deps = array_merge($shim[$key]->deps, $s->deps);
     } else {
         $shim[$key] = $s;
     }
     parent::formJavascriptClass($srcs, $script, $shim);
     // $$$ hugh - added this, and some logic in the view, so we will get called on a per-element basis
     return false;
 }
Exemplo n.º 18
0
 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a JError object.
  */
 public function display($tpl = 'default')
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     $j3 = FabrikWorker::j3();
     $srcs = FabrikHelperHTML::framework();
     FabrikHelperHTML::slimbox();
     $document = JFactory::getDocument();
     $usersConfig = JComponentHelper::getParams('com_fabrik');
     $model = $this->getModel();
     $model->setId($input->getInt('id', $usersConfig->get('visualizationid', $input->getInt('visualizationid', 0))));
     $this->row = $model->getVisualization();
     $js = $model->getJs();
     $this->txt = $model->getText();
     $params = $model->getParams();
     $this->params = $params;
     $tpl = $j3 ? 'bootstrap' : 'default';
     $tpl = $params->get('fb_gm_layout', $tpl);
     $tmplpath = JPATH_ROOT . '/plugins/fabrik_visualization/googlemap/views/googlemap/tmpl/' . $tpl;
     $srcs[] = 'media/com_fabrik/js/list-plugin.js';
     $srcs[] = 'media/com_fabrik/js/listfilter.js';
     $uri = JURI::getInstance();
     if ($params->get('fb_gm_center') == 'userslocation') {
         $srcs[] = 'components/com_fabrik/libs/geo-location/geo.js';
     }
     $model->getPluginJsClasses($srcs);
     global $ispda;
     if ($ispda == 1) {
         // Pdabot
         $template = 'static';
         $this->staticmap = $model->getStaticMap();
     } else {
         if (FabrikHelperHTML::isDebug()) {
             $srcs[] = 'plugins/fabrik_visualization/googlemap/googlemap.js';
         } else {
             $srcs[] = 'plugins/fabrik_visualization/googlemap/googlemap-min.js';
         }
         if ((int) $this->params->get('fb_gm_clustering', '0') == 1) {
             if (FabrikHelperHTML::isDebug()) {
                 $srcs[] = 'components/com_fabrik/libs/googlemaps/markerclustererplus/src/markerclusterer.js';
             } else {
                 $srcs[] = 'components/com_fabrik/libs/googlemaps/markerclustererplus/src/markerclusterer_packed.js';
             }
         } else {
             // Doesn't work in v3
             // FabrikHelperHTML::script('components/com_fabrik/libs/googlemaps/markermanager.js');
         }
         $template = null;
     }
     $js .= $model->getPluginJsObjects();
     $js .= $model->getFilterJs();
     FabrikHelperHTML::iniRequireJs($model->getShim());
     FabrikHelperHTML::script($srcs, $js);
     FabrikHelperHTML::stylesheetFromPath('plugins/fabrik_visualization/googlemap/views/googlemap/tmpl/' . $tpl . '/template.css');
     // Check and add a general fabrik custom css file overrides template css and generic table css
     FabrikHelperHTML::stylesheetFromPath('media/com_fabrik/css/custom.css');
     // Check and add a specific viz template css file overrides template css generic table css and generic custom css
     FabrikHelperHTML::stylesheetFromPath('plugins/fabrik_visualization/googlemap/views/googlemap/tmpl/' . $tpl . '/custom.css');
     $this->filters = $model->getFilters();
     $this->showFilters = $model->showFilters();
     $this->filterFormURL = $model->getFilterFormURL();
     $this->sidebarPosition = $params->get('fb_gm_use_overlays_sidebar');
     $this->showOverLays = (bool) $params->get('fb_gm_use_overlays');
     if ($model->getShowSideBar()) {
         $this->showSidebar = 1;
         $this->overlayUrls = (array) $params->get('fb_gm_overlay_urls');
         $this->overlayLabels = (array) $params->get('fb_gm_overlay_labels');
     } else {
         $this->showSidebar = 0;
     }
     $this->_setPath('template', $tmplpath);
     $this->containerId = $model->getContainerId();
     $this->groupTemplates = $model->getGroupTemplates();
     echo parent::display($template);
 }
Exemplo n.º 19
0
 /**
  * Raise a J Error notice if in dev mode or log a J error otherwise
  *
  * @param   string  $errString  Message to display / log
  * @param   string  $msgType    Joomla enqueueMessage message type e.g. 'error', 'warning' etc.
  *
  * @return  void
  */
 public static function logError($errString, $msgType)
 {
     if (FabrikHelperHTML::isDebug()) {
         $app = JFactory::getApplication();
         $app->enqueueMessage($errString, $msgType);
     } else {
         switch ($msgType) {
             case 'message':
                 $priority = JLog::INFO;
                 break;
             case 'warning':
                 $priority = JLog::WARNING;
                 break;
             case 'error':
             default:
                 $priority = JLog::ERROR;
                 break;
         }
         JLog::add($errString, $priority, 'com_fabrik');
     }
 }
Exemplo n.º 20
0
 /**
  * Internal element validation
  *
  * @param   array $data          form data
  * @param   int   $repeatCounter repeat group counter
  *
  * @return bool
  */
 public function validate($data, $repeatCounter = 0)
 {
     $params = $this->getParams();
     $input = $this->app->input;
     if (!$this->canUse()) {
         return true;
     }
     if ($params->get('captcha-method') == 'recaptcha') {
         if (!function_exists('_recaptcha_qsencode')) {
             require_once JPATH_SITE . '/plugins/fabrik_element/captcha/libs/recaptcha-php-1.11/recaptchalib.php';
         }
         $privateKey = $params->get('recaptcha_privatekey');
         if ($input->get('recaptcha_response_field')) {
             $challenge = $input->get('recaptcha_challenge_field');
             $response = $input->get('recaptcha_response_field');
             $resp = recaptcha_check_answer($privateKey, FabrikString::filteredIp(), $challenge, $response);
             return $resp->is_valid ? true : false;
         }
         return false;
     } elseif ($params->get('captcha-method') == 'nocaptcha') {
         if ($input->get('g-recaptcha-response')) {
             require_once JPATH_SITE . '/plugins/fabrik_element/captcha/libs/ReCaptcha/ReCaptcha.php';
             require_once JPATH_SITE . '/plugins/fabrik_element/captcha/libs/ReCaptcha/RequestMethod.php';
             require_once JPATH_SITE . '/plugins/fabrik_element/captcha/libs/ReCaptcha/RequestMethod/Post.php';
             require_once JPATH_SITE . '/plugins/fabrik_element/captcha/libs/ReCaptcha/RequestParameters.php';
             require_once JPATH_SITE . '/plugins/fabrik_element/captcha/libs/ReCaptcha/Response.php';
             $privateKey = $params->get('recaptcha_privatekey');
             $noCaptcha = new \ReCaptcha\ReCaptcha($privateKey);
             $response = $input->get('g-recaptcha-response');
             $server = $input->server->get('REMOTE_ADDR');
             $resp = $noCaptcha->verify($response, $server);
             if ($resp->isSuccess()) {
                 return true;
             } else {
                 if (FabrikHelperHTML::isDebug()) {
                     $msg = "noCaptcha error: ";
                     foreach ($resp->getErrorCodes() as $code) {
                         $msg .= '<tt>' . $code . '</tt> ';
                     }
                     $this->app->enqueueMessage($msg);
                 }
                 return false;
             }
         }
         if (FabrikHelperHTML::isDebug()) {
             $this->app->enqueueMessage("No g-recaptcha-response!");
         }
         return false;
     } elseif ($params->get('captcha-method') == 'playthru') {
         if (!defined('AYAH_PUBLISHER_KEY')) {
             define('AYAH_PUBLISHER_KEY', $params->get('playthru_publisher_key', ''));
             define('AYAH_SCORING_KEY', $params->get('playthru_scoring_key', ''));
         }
         require_once JPATH_SITE . '/plugins/fabrik_element/captcha/libs/ayah_php_bundle_1.1.7/ayah.php';
         $ayah = new AYAH();
         return $ayah->scoreResult();
     } else {
         $this->getParams();
         if ($this->session->get('com_' . $this->package . '.element.captcha.security_code', null) != $data) {
             return false;
         }
         return true;
     }
 }
Exemplo n.º 21
0
 /**
  * Get the class to manage the form element
  * to ensure that the file is loaded only once
  *
  * @param   array   &$srcs   Scripts previously loaded
  * @param   string  $script  Script to load once class has loaded
  * @param   array   &$shim   Dependant class names to load before loading the class - put in requirejs.config shim
  *
  * @return void
  */
 public function formJavascriptClass(&$srcs, $script = '', &$shim = array())
 {
     $ext = FabrikHelperHTML::isDebug() ? '.js' : '-min.js';
     $files = array('media/com_fabrik/js/element' . $ext, 'media/com_fabrik/js/elementlist' . $ext);
     foreach ($files as $file) {
         if (!in_array($file, $srcs)) {
             $srcs[] = $file;
         }
     }
     parent::formJavascriptClass($srcs, $script, $shim);
 }
Exemplo n.º 22
0
 /**
  * Get fields to update/insert
  *
  * @param   bool  $upsertRowExists
  *
  * @return  array
  */
 protected function upsertData($upsertRowExists = false)
 {
     $params = $this->getParams();
     $w = new FabrikWorker();
     $upsertDb = $this->getDb();
     $upsert = json_decode($params->get('upsert_fields'));
     $fields = array();
     /** @var FabrikFEModelForm $formModel */
     $formModel = $this->getModel();
     if ($formModel->isNewRecord() || !$upsertRowExists) {
         if ($params->get('upsert_pk_or_fk', 'pk') == 'fk') {
             $row_value = $params->get('row_value', '');
             if ($row_value == '{origid}') {
                 $fk = FabrikString::safeColName($params->get('primary_key'));
                 $rowId = $formModel->getInsertId();
                 $fields[] = $fk . ' = ' . $upsertDb->q($rowId);
             }
         }
     }
     for ($i = 0; $i < count($upsert->upsert_key); $i++) {
         $k = FabrikString::shortColName($upsert->upsert_key[$i]);
         $k = $upsertDb->qn($k);
         $v = $upsert->upsert_value[$i];
         $v = $w->parseMessageForPlaceholder($v, $this->data);
         if ($upsert->upsert_eval_value[$i] === '1') {
             $res = FabrikHelperHTML::isDebug() ? eval($v) : @eval($v);
             FabrikWorker::logEval($res, 'Eval exception : upsert : ' . $v . ' : %s');
             $v = $res;
         }
         if ($v == '') {
             $v = $w->parseMessageForPlaceholder($upsert->upsert_default[$i], $this->data);
         }
         /*
          * $$$ hugh - permit the use of expressions, by putting the value in parens, with option use
          * of double :: to provide a default for new row (rowid is empty).  This default is seperate from
          * the simple default used above, which is predicated on value being empty.  So simple usage
          * might be ..
          *
          * (counter+1::0)
          *
          * ... if you want to increment a 'counter' field.  Or you might use a subquery, like ...
          *
          * ((SELECT foo FROM other_table WHERE fk_id = {rowid})::'foo default')
          */
         if (!preg_match('#^\\((.*)\\)$#', $v)) {
             $v = $upsertDb->q($v);
         } else {
             $matches = array();
             preg_match('#^\\((.*)\\)$#', $v, $matches);
             $v = $matches[1];
             $v = explode('::', $v);
             if (count($v) == 1) {
                 $v = $v[0];
             } else {
                 if ($formModel->isNewRecord()) {
                     $v = $v[1];
                 } else {
                     $v = $v[0];
                 }
             }
         }
         $fields[] = $k . ' = ' . $v;
     }
     return $fields;
 }