示例#1
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')
 {
     $model = $this->getModel();
     $j3 = FabrikWorker::j3();
     $app = JFactory::getApplication();
     $input = $app->input;
     $usersConfig = JComponentHelper::getParams('com_fabrik');
     $id = $input->get('id', $usersConfig->get('visualizationid', $input->getInt('visualizationid', 0)));
     $model->setId($id);
     if (!$model->canView()) {
         echo FText::_('JERROR_ALERTNOAUTHOR');
         return false;
     }
     $this->id = $id;
     $this->row = $this->get('Visualization');
     $this->rows = $this->get('Rows');
     $this->containerId = $this->get('ContainerId');
     $this->calName = $this->get('VizName');
     $this->params = $model->getParams();
     $tpl = $j3 ? 'bootstrap' : $tpl;
     $this->_setPath('template', JPATH_SITE . '/plugins/fabrik_visualization/approvals/views/approvals/tmpl/' . $tpl);
     FabrikHelperHTML::stylesheetFromPath('plugins/fabrik_visualization/approvals/views/approvals/tmpl/' . $tpl . '/template.css');
     $ref = $model->getJSRenderContext();
     $js = "var {$ref} = new fbVisApprovals('approvals_" . $id . "');\n";
     $js .= "Fabrik.addBlock('" . $ref . "', {$ref});\n";
     $js .= $model->getFilterJs();
     $srcs = FabrikHelperHTML::framework();
     $srcs['FbListFilter'] = 'media/com_fabrik/js/listfilter.js';
     $srcs['Approvals'] = 'plugins/fabrik_visualization/approvals/approvals.js';
     FabrikHelperHTML::iniRequireJs($model->getShim());
     FabrikHelperHTML::script($srcs, $js);
     $text = $this->loadTemplate();
     FabrikHelperHTML::runContentPlugins($text);
     echo $text;
 }
示例#2
0
 /**
  * Display
  *
  * @param   string $tpl Template
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     FabrikHelperHTML::framework();
     $input = $this->app->input;
     $item = $this->get('Item');
     $srcs = array('media/com_fabrik/js/icons.js', 'media/com_fabrik/js/icongen.js', 'media/com_fabrik/js/canvas.js', 'media/com_fabrik/js/history.js', 'media/com_fabrik/js/keynav.js', 'media/com_fabrik/js/tabs.js', 'media/com_fabrik/js/pages.js', 'media/com_fabrik/js/frontpackage.js');
     FabrikHelperHTML::script($srcs);
     FabrikHelperHTML::stylesheet('media/com_fabrik/css/package.css');
     $canvas = $item->params->get('canvas');
     // $$$ rob 08/11/2011 test if component name set but still rendering
     // in option=com_fabrik then we should use fabrik as the package
     if ($input->get('option') === 'com_fabrik') {
         $item->component_name = 'fabrik';
     }
     $tabs = FArrayHelper::getValue($canvas, 'tabs', array('Page 1'));
     $tabs = json_encode($tabs);
     $d = new stdClass();
     $layout = json_encode(FArrayHelper::getValue($canvas, 'layout', $d));
     $id = $this->get('State')->get('package.id');
     $script = "window.addEvent('fabrik.loaded', function() {\n\t\t\tnew FrontPackage({\n\t\ttabs : {$tabs},\n\t\ttabelement : 'packagemenu',\n\t\tpagecontainer : 'packagepages',\n\t\tlayout: {$layout},\n\t\t'packageId': {$id},\n\t\t'package':'{$item->component_name}'\n\t});\n\t\t});";
     FabrikHelperHTML::addScriptDeclaration($script);
     // Force front end templates
     $this->_basePath = COM_FABRIK_FRONTEND . '/views';
     $tmpl = !isset($item->template) ? 'default' : $item->template;
     $this->addTemplatePath($this->_basePath . '/' . $this->_name . '/tmpl/' . $tmpl);
     $text = $this->loadTemplate();
     FabrikHelperHTML::runContentPlugins($text);
     echo $text;
 }
示例#3
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')
 {
     $document = JFactory::getDocument();
     $app = JFactory::getApplication();
     $input = $app->input;
     $model = $this->getModel();
     $usersConfig = JComponentHelper::getParams('com_fabrik');
     $model->setId($input->getInt('id', $usersConfig->get('visualizationid', $input->getInt('visualizationid', 0))));
     if (!$model->canView()) {
         echo FText::_('JERROR_ALERTNOAUTHOR');
         return false;
     }
     $srcs = FabrikHelperHTML::framework();
     FabrikHelperHTML::styleSheet('plugins/fabrik_visualization/nvd3_chart/lib/novus-nvd3/src/nv.d3.css');
     $srcs['FbListFilter'] = 'media/com_fabrik/js/listfilter.js';
     $srcs['AdvancedSearch'] = 'media/com_fabrik/js/advanced-search.js';
     $lib = COM_FABRIK_LIVESITE . 'plugins/fabrik_visualization/nvd3_chart/lib/novus-nvd3/';
     $document->addScript($lib . 'lib/d3.v2.js');
     $document->addScript($lib . 'nv.d3.js');
     $document->addScript($lib . 'src/tooltip.js');
     $document->addScript($lib . 'lib/fisheye.js');
     $document->addScript($lib . 'src/utils.js');
     $document->addScript($lib . 'src/models/legend.js');
     $document->addScript($lib . 'src/models/axis.js');
     $document->addScript($lib . 'src/models/scatter.js');
     $document->addScript($lib . 'src/models/line.js');
     $document->addScript($lib . 'src/models/lineChart.js');
     $document->addScript($lib . 'src/models/multiBar.js');
     $document->addScript($lib . 'src/models/multiBarChart.js');
     $this->row = $model->getVisualization();
     $this->requiredFiltersFound = $model->getRequiredFiltersFound();
     $params = $model->getParams();
     $js = $model->js();
     FabrikHelperHTML::addScriptDeclaration($js);
     $this->params = $params;
     $viewName = $this->getName();
     $pluginManager = JModelLegacy::getInstance('Pluginmanager', 'FabrikFEModel');
     $plugin = $pluginManager->getPlugIn('calendar', 'visualization');
     $this->params = $params;
     $this->postText = $model->postText;
     $this->assign('containerId', $this->get('ContainerId'));
     $this->assign('filters', $this->get('Filters'));
     $this->showFilters = $model->showFilters();
     $this->assign('filterFormURL', $this->get('FilterFormURL'));
     $tpl = $params->get('nvd3_chart_layout', $tpl);
     $this->_setPath('template', JPATH_ROOT . '/plugins/fabrik_visualization/nvd3_chart/views/nvd3_chart/tmpl/' . $tpl);
     FabrikHelperHTML::stylesheetFromPath('plugins/fabrik_visualization/nvd3_chart/views/nvd3_chart/tmpl/' . $tpl . '/template.css');
     // Assign something to Fabrik.blocks to ensure we can clear filters
     $ref = $model->getJSRenderContext();
     $js = "{$ref} = {};";
     $js .= "\n" . "Fabrik.addBlock('{$ref}', {$ref});";
     $js .= $model->getFilterJs();
     FabrikHelperHTML::iniRequireJs($model->getShim());
     FabrikHelperHTML::script($srcs, $js);
     $text = $this->loadTemplate();
     FabrikHelperHTML::runContentPlugins($text);
     echo $text;
 }
示例#4
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();
     $srcs['FbListFilter'] = 'media/com_fabrik/js/listfilter.js';
     $srcs['AdvancedSearch'] = 'media/com_fabrik/js/advanced-search.js';
     $model = $this->getModel();
     $usersConfig = JComponentHelper::getParams('com_fabrik');
     $model->setId($input->getInt('id', $usersConfig->get('visualizationid', $input->getInt('visualizationid', 0))));
     $this->row = $model->getVisualization();
     if (!$model->canView()) {
         echo FText::_('JERROR_ALERTNOAUTHOR');
         return false;
     }
     $this->requiredFiltersFound = $this->get('RequiredFiltersFound');
     if ($this->requiredFiltersFound) {
         $this->chart = $this->get('Fusionchart');
     } else {
         $this->chart = '';
     }
     $params = $model->getParams();
     $this->params = $params;
     $viewName = $this->getName();
     $pluginManager = JModelLegacy::getInstance('Pluginmanager', 'FabrikFEModel');
     $plugin = $pluginManager->getPlugIn('calendar', 'visualization');
     $this->containerId = $this->get('ContainerId');
     $this->filters = $this->get('Filters');
     $this->showFilters = $model->showFilters();
     $this->filterFormURL = $this->get('FilterFormURL');
     $tpl = $j3 ? 'bootstrap' : 'default';
     $tpl = $params->get('fusionchart_layout', $tpl);
     $this->_setPath('template', JPATH_ROOT . '/plugins/fabrik_visualization/fusionchart/views/fusionchart/tmpl/' . $tpl);
     FabrikHelperHTML::stylesheetFromPath('plugins/fabrik_visualization/fusionchart/views/fusionchart/tmpl/' . $tpl . '/template.css');
     // Assign something to Fabrik.blocks to ensure we can clear filters
     $ref = $model->getJSRenderContext();
     $js = "{$ref} = {};";
     $js .= "\n" . "Fabrik.addBlock('{$ref}', {$ref});";
     $js .= $model->getFilterJs();
     FabrikHelperHTML::iniRequireJs($model->getShim());
     FabrikHelperHTML::script($srcs, $js);
     $text = $this->loadTemplate();
     FabrikHelperHTML::runContentPlugins($text);
     echo $text;
 }
示例#5
0
 /**
  * Finally output the HTML, running Joomla content plugins if needed
  *
  * @return  void
  */
 public function output()
 {
     $w = new FabrikWorker();
     $text = $this->loadTemplate();
     $model = $this->getModel();
     $params = $model->getParams();
     if ($params->get('process-jplugins', 2) == 1 || $params->get('process-jplugins', 2) == 2 && $model->isEditable() === false) {
         FabrikHelperHTML::runContentPlugins($text);
     }
     // Allows you to use {placeholders} in form template Only replacing data accessible to the users acl.
     $view = $model->isEditable() === false ? 'details' : 'form';
     $text = $w->parseMessageForPlaceHolder($text, $model->accessibleData($view));
     echo $text;
 }
示例#6
0
文件: email.php 项目: LGBGit/tierno
 /**
  * Do the plugin action
  *
  * @param   array  &$data  data
  *
  * @return  int  number of records updated
  */
 public function process(&$data)
 {
     jimport('joomla.mail.helper');
     $params = $this->getParams();
     $msg = $params->get('message');
     FabrikHelperHTML::runContentPlugins($msg);
     $to = explode(',', $params->get('to'));
     $w = new FabrikWorker();
     $params->get('cronemail_return', '') != '' ? $MailFrom = $params->get('cronemail_return') : ($MailFrom = $this->app->get('mailfrom'));
     $params->get('cronemail_from', '') != '' ? $FromName = $params->get('cronemail_from') : ($FromName = $this->app->get('fromname'));
     $subject = $params->get('subject', 'Fabrik cron job');
     $eval = $params->get('cronemail-eval');
     $condition = $params->get('cronemail_condition', '');
     $updates = array();
     $this->log = '';
     foreach ($data as $group) {
         if (is_array($group)) {
             foreach ($group as $row) {
                 if (!empty($condition)) {
                     $this_condition = $w->parseMessageForPlaceHolder($condition, $row);
                     if (eval($this_condition) === false) {
                         continue;
                     }
                 }
                 $row = JArrayHelper::fromObject($row);
                 foreach ($to as $thisTo) {
                     $thisTo = $w->parseMessageForPlaceHolder($thisTo, $row);
                     if (FabrikWorker::isEmail($thisTo)) {
                         $thisMsg = $w->parseMessageForPlaceHolder($msg, $row);
                         if ($eval) {
                             $thisMsg = eval($thisMsg);
                         }
                         $thisSubject = $w->parseMessageForPlaceHolder($subject, $row);
                         $mail = JFactory::getMailer();
                         $res = $mail->sendMail($MailFrom, $FromName, $thisTo, $thisSubject, $thisMsg, true);
                         if (!$res) {
                             $this->log .= "\n failed sending to {$thisTo}";
                         } else {
                             $this->log .= "\n sent to {$thisTo}";
                         }
                     } else {
                         $this->log .= "\n {$thisTo} is not an email address";
                     }
                 }
                 $updates[] = $row['__pk_val'];
             }
         }
     }
     $field = $params->get('cronemail-updatefield');
     if (!empty($updates) && trim($field) != '') {
         // Do any update found
         /** @var FabrikFEModelList $listModel */
         $listModel = JModelLegacy::getInstance('list', 'FabrikFEModel');
         $listModel->setId($params->get('table'));
         $table = $listModel->getTable();
         $field = $params->get('cronemail-updatefield');
         $value = $params->get('cronemail-updatefield-value');
         if ($params->get('cronemail-updatefield-eval', '0') == '1') {
             $value = @eval($value);
         }
         $field = str_replace('___', '.', $field);
         $fabrikDb = $listModel->getDb();
         $query = $fabrikDb->getQuery(true);
         $query->update($table->db_table_name)->set($field . ' = ' . $fabrikDb->quote($value))->where($table->db_primary_key . ' IN (' . implode(',', $updates) . ')');
         $this->log .= "\n update query: {$query}";
         $fabrikDb->setQuery($query);
         $fabrikDb->execute();
     }
     $this->log .= "\n updates " . count($updates) . " records";
     return count($updates);
 }
示例#7
0
 /**
  * Actually load the template and echo the view html
  * will process jplugins if required.
  *
  * @return  void
  */
 protected function output()
 {
     $profiler = JProfiler::getInstance('Application');
     $text = $this->loadTemplate();
     JDEBUG ? $profiler->mark('template loaded') : null;
     $model = $this->getModel();
     $params = $model->getParams();
     if ($params->get('process-jplugins')) {
         FabrikHelperHTML::runContentPlugins($text);
     }
     JDEBUG ? $profiler->mark('end fabrik display') : null;
     // $$$ rob 09/06/2011 no need for isMambot test? should use ob_start() in module / plugin to capture the output
     echo $text;
 }
示例#8
0
 /**
  * Get the map icons
  *
  * @return  array
  */
 public function getJSIcons()
 {
     $input = $this->app->input;
     $icons = array();
     $w = new FabrikWorker();
     $uri = JURI::getInstance();
     $params = $this->getParams();
     $templates = (array) $params->get('fb_gm_detailtemplate');
     $templates_nl2br = (array) $params->get('fb_gm_detailtemplate_nl2br');
     $listIds = (array) $params->get('googlemap_table');
     // Images for file system
     $aIconImgs = (array) $params->get('fb_gm_iconimage');
     // Image from marker data
     $markerImages = (array) $params->get('fb_gm_iconimage2');
     $markerImagesPath = (array) $params->get('fb_gm_iconimage2_path');
     // Specified letter
     $letters = (array) $params->get('fb_gm_icon_letter');
     $aFirstIcons = (array) $params->get('fb_gm_first_iconimage');
     $aLastIcons = (array) $params->get('fb_gm_last_iconimage');
     $titleElements = (array) $params->get('fb_gm_title_element');
     $radiusElements = (array) $params->get('fb_gm_radius_element');
     $radiusDefaults = (array) $params->get('fb_gm_radius_default');
     $radiusUnits = (array) $params->get('fb_gm_radius_unit');
     $groupClass = (array) $params->get('fb_gm_group_class');
     $c = 0;
     $this->recordCount = 0;
     $maxMarkers = $params->get('fb_gm_markermax', 0);
     $recLimit = count($listIds) == 1 ? $maxMarkers : 0;
     $limitMessageShown = false;
     $limitMessage = $params->get('fb_gm_markermax_message');
     $groupedIcons = array();
     $lc = 0;
     foreach ($listIds as $listId) {
         $listModel = $this->getlistModel($listId);
         $template = FArrayHelper::getValue($templates, $c, '');
         /**
          * One day we should get smarter about how we decide which elements to render
          * but for now all we can do is set formatAll(), in case they use an element
          * which isn't set for list display, which then wouldn't get rendered unless we do this.
          */
         if (FabrikString::usesElementPlaceholders($template)) {
             $listModel->formatAll(true);
         }
         $template_nl2br = FArrayHelper::getValue($templates_nl2br, $c, '1') == '1';
         $mapsElements = FabrikHelperList::getElements($listModel, array('plugin' => 'googlemap', 'published' => 1));
         $coordColumn = $mapsElements[0]->getFullName(true, false) . "_raw";
         // Are we using random start location for icons?
         $listModel->_randomRecords = $params->get('fb_gm_random_marker') == 1 && $recLimit != 0 ? true : false;
         // Used in list model setLimits
         $input->set('limit' . $listId, $recLimit);
         $listModel->setLimits();
         $listModel->getPagination(0, 0, $recLimit);
         $data = $listModel->getData();
         $this->txt = array();
         $k = 0;
         foreach ($data as $groupKey => $group) {
             foreach ($group as $row) {
                 $customImageFound = false;
                 $iconImg = FArrayHelper::getValue($aIconImgs, $c, '');
                 if ($k == 0) {
                     $firstIcon = FArrayHelper::getValue($aFirstIcons, $c, $iconImg);
                     if ($firstIcon !== '') {
                         $iconImg = $firstIcon;
                     }
                 }
                 if (!empty($iconImg)) {
                     $iconImg = '/media/com_fabrik/images/' . $iconImg;
                 }
                 $v = $this->getCordsFromData($row->{$coordColumn});
                 if ($v == array(0, 0)) {
                     // Don't show icons with no data
                     continue;
                 }
                 $rowData = ArrayHelper::fromObject($row);
                 $rowData['rowid'] = $rowData['__pk_val'];
                 $rowData['coords'] = $v[0] . ',' . $v[1];
                 $rowData['nav_url'] = "http://maps.google.com/maps?q=loc:" . $rowData['coords'] . "&navigate=yes";
                 $html = $w->parseMessageForPlaceHolder($template, $rowData);
                 FabrikHelperHTML::runContentPlugins($html);
                 $titleElement = FArrayHelper::getValue($titleElements, $c, '');
                 $title = $titleElement == '' ? '' : html_entity_decode(strip_tags($row->{$titleElement}), ENT_COMPAT, 'UTF-8');
                 /* $$$ hugh - if they provided a template, lets assume they will handle the link themselves.
                  * http://fabrikar.com/forums/showthread.php?p=41550#post41550
                  * $$$ hugh - at some point the fabrik_view / fabrik_edit links became optional
                  */
                 if (empty($html) && (array_key_exists('fabrik_view', $rowData) || array_key_exists('fabrik_edit', $rowData))) {
                     // Don't insert line break in empty bubble without links $html .= "<br />";
                     // Use edit link by preference
                     if (array_key_exists('fabrik_edit', $rowData)) {
                         if ($rowData['fabrik_edit'] != '') {
                             $html .= "<br />";
                         }
                         $html .= $rowData['fabrik_edit'];
                     } else {
                         if ($rowData['fabrik_view'] != '') {
                             $html .= "<br />";
                         }
                         $html .= $rowData['fabrik_view'];
                     }
                 }
                 if ($template_nl2br) {
                     /*
                      *  $$$ hugh - not sure why we were doing this rather than nl2br?
                      If there was a reason, this is still broken, as it ends up inserting
                      two breaks.  So if we can't use nl2br ... I need fix this before using it again!
                     
                     $html = str_replace(array("\n\r"), "<br />", $html);
                     $html = str_replace(array("\r\n"), "<br />", $html);
                     $html = str_replace(array("\n", "\r"), "<br />", $html);
                     */
                     $html = nl2br($html);
                 }
                 $html = str_replace("'", '"', $html);
                 $this->txt[] = $html;
                 if ($iconImg == '') {
                     $iconImg = FArrayHelper::getValue($markerImages, $c, '');
                     if ($iconImg != '') {
                         /**
                          * $$$ hugh - added 'path' choice for data icons, to make this option more flexible.  Up till
                          * now we have been forcing paths relative to /media/com_fabrik/images (which was added in the JS).
                          * New options for path root are:
                          *
                          * media - (default) existing behavior of /meadia/com_fabrik/images
                          * jroot - relative to J! root
                          * absolute - full server path
                          * url - url (surprise surprise)
                          * img - img tag (so we extract src=)
                          */
                         $iconImgPath = FArrayHelper::getValue($markerImagesPath, $c, 'media');
                         $iconImg = FArrayHelper::getValue($rowData, $iconImg, '');
                         // Normalize the $iconimg so it is either a file path relative to J! root, or a non-local URL
                         switch ($iconImgPath) {
                             case 'media':
                             default:
                                 $iconImg = 'media/com_fabrik/images' . $iconImg;
                                 break;
                             case 'jroot':
                                 break;
                             case 'absolute':
                                 $iconImg = str_replace(JPATH_BASE, '', $iconImg);
                                 break;
                             case 'url':
                                 $iconImg = str_replace(COM_FABRIK_LIVESITE, '', $iconImg);
                                 break;
                             case 'img':
                                 // Get the src
                                 preg_match('/src=["|\'](.*?)["|\']/', $iconImg, $matches);
                                 if (array_key_exists(1, $matches)) {
                                     $iconImg = $matches[1];
                                 }
                                 $iconImg = str_replace(COM_FABRIK_LIVESITE, '', $iconImg);
                                 break;
                         }
                         if (strstr($iconImg, 'http://') || strstr($iconImg, 'https://') || JFile::exists(JPATH_BASE . $iconImg)) {
                             $customImageFound = true;
                         }
                     }
                     if ($iconImg != '' && !(strstr($iconImg, 'http://') || strstr($iconImg, 'https://'))) {
                         list($width, $height) = $this->markerSize(JPATH_BASE . $iconImg);
                     } else {
                         // Standard google map icon size
                         $width = 20;
                         $height = 34;
                     }
                 } else {
                     // Standard google map icon size
                     list($width, $height) = $this->markerSize(JPATH_BASE . $iconImg);
                 }
                 $gClass = FArrayHelper::getValue($groupClass, 0, '');
                 if (!empty($gClass)) {
                     $gClass .= '_raw';
                     $gClass = isset($row->{$gClass}) ? $row->{$gClass} : '';
                 }
                 if (array_key_exists($v[0] . $v[1], $icons)) {
                     $existingIcon = $icons[$v[0] . $v[1]];
                     if ($existingIcon['groupkey'] == $groupKey) {
                         /* $$$ hugh - this inserts label between multiple record $html, but not at the top.
                          * If they want to insert label, they can do it themselves in the template.
                          * $icons[$v[0].$v[1]][2] = $icons[$v[0].$v[1]][2] . "<h6>$table->label</h6>" . $html;
                          * Don't insert linebreaks in empty bubble
                          */
                         if ($html != '') {
                             $html = "<br />" . $html;
                         }
                         $icons[$v[0] . $v[1]][2] = $icons[$v[0] . $v[1]][2] . $html;
                         if ($customImageFound) {
                             $icons[$v[0] . $v[1]][3] = $iconImg;
                         }
                     } else {
                         $groupedIcons[] = array($v[0], $v[1], $html, $iconImg, $width, $height, 'groupkey' => $groupKey, 'listid' => $listId, 'title' => $title, 'groupClass' => 'type' . $gClass);
                     }
                 } else {
                     // Default icon - lets see if we need to use a letter icon instead
                     if (FArrayHelper::getValue($letters, $c, '') != '') {
                         $iconImg = $uri->getScheme() . '://www.google.com/mapfiles/marker' . JString::strtoupper($letters[$c]) . '.png';
                     }
                     $icons[$v[0] . $v[1]] = array($v[0], $v[1], $html, $iconImg, $width, $height, 'groupkey' => $groupKey, 'listid' => $listId, 'title' => $title, 'groupClass' => 'type' . $gClass);
                 }
                 if ($params->get('fb_gm_use_radius', '0') == '1') {
                     $radiusElement = FArrayHelper::getValue($radiusElements, $c, '');
                     $radiusUnits = FArrayHelper::getValue($radiusUnits, $c, 'k');
                     $radiusMeters = $radiusUnits == 'k' ? 1000 : 1609.34;
                     if (!empty($radiusElement)) {
                         $radius = (double) $row->{$radiusElement};
                         $radius *= $radiusMeters;
                         $icons[$v[0] . $v[1]]['radius'] = $radius;
                     } else {
                         $default = (double) ArrayHelper::getvalue($radiusDefaults, $c, 50);
                         $default *= $radiusMeters;
                         $icons[$v[0] . $v[1]]['radius'] = $default;
                     }
                 }
                 $icons[$v[0] . $v[1]]['c'] = $c;
                 $this->recordCount++;
                 $k++;
             }
         }
         // Replace last icon?
         $iconImg = FArrayHelper::getValue($aLastIcons, $c, '');
         if ($iconImg != '' && !empty($icons)) {
             list($width, $height) = $this->markerSize(JPATH_SITE . '/media/com_fabrik/images/' . $iconImg);
             $icons[$v[0] . $v[1]][3] = '/media/com_fabrik/images/' . $iconImg;
             $icons[$v[0] . $v[1]][4] = $width;
             $icons[$v[0] . $v[1]][5] = $height;
         }
         $c++;
     }
     // Replace coord keys with numeric keys
     $icons = array_values($icons);
     $icons = array_merge($icons, $groupedIcons);
     if ($maxMarkers != 0 && $maxMarkers < count($icons)) {
         $icons = array_slice($icons, -$maxMarkers);
     }
     $limitMessageShown = !($k >= $recLimit);
     if (!$limitMessageShown && $recLimit !== 0 && $limitMessage != '') {
         $this->app->enqueueMessage($limitMessage);
     }
     FabrikHelperHTML::debug($icons, 'map');
     return $icons;
 }
示例#9
0
文件: email.php 项目: glauberm/cinevi
 /**
  * Run right at the end of the form processing
  * form needs to be set to record in database for this to hook to be called
  *
  * @return	bool
  */
 public function onAfterProcess()
 {
     $profiler = JProfiler::getInstance('Application');
     JDEBUG ? $profiler->mark("email: start: onAfterProcess") : null;
     $params = $this->getParams();
     $input = $this->app->input;
     jimport('joomla.mail.helper');
     $w = new FabrikWorker();
     /** @var \FabrikFEModelForm $formModel */
     $formModel = $this->getModel();
     $emailTemplate = JPath::clean(JPATH_SITE . '/plugins/fabrik_form/email/tmpl/' . $params->get('email_template', ''));
     $this->data = $this->getProcessData();
     /* $$$ hugh - moved this to here from above the previous line, 'cos it needs $this->data
      * check if condition exists and is met
      */
     if ($this->alreadySent() || !$this->shouldProcess('email_conditon', null, $params)) {
         return true;
     }
     /**
      * Added option to run content plugins on message text.  Note that rather than run it one time at the
      * end of the following code, after we have assembled all the various options in to a single $message,
      * it needs to be run separately on each type of content.  This is because we do placeholder replacement
      * in various places, which will strip all {text} which doesn't match element names.
      */
     $runContentPlugins = $params->get('email_run_content_plugins', '0') === '1';
     $contentTemplate = $params->get('email_template_content');
     $content = $contentTemplate != '' ? FabrikHelperHTML::getContentTemplate($contentTemplate, 'both', $runContentPlugins) : '';
     // Always send as html as even text email can contain html from wysiwyg editors
     $htmlEmail = true;
     $messageTemplate = '';
     if (JFile::exists($emailTemplate)) {
         $messageTemplate = JFile::getExt($emailTemplate) == 'php' ? $this->_getPHPTemplateEmail($emailTemplate) : $this->_getTemplateEmail($emailTemplate);
         // $$$ hugh - added ability for PHP template to return false to abort, same as if 'condition' was was false
         if ($messageTemplate === false) {
             return true;
         }
         if ($runContentPlugins === true) {
             FabrikHelperHTML::runContentPlugins($messageTemplate);
         }
         $messageTemplate = str_replace('{content}', $content, $messageTemplate);
     }
     $messageText = $params->get('email_message_text', '');
     if (!empty($messageText)) {
         if ($runContentPlugins === true) {
             FabrikHelperHTML::runContentPlugins($messageText);
         }
         $messageText = str_replace('{content}', $content, $messageText);
         $messageText = str_replace('{template}', $messageTemplate, $messageText);
         $messageText = $w->parseMessageForPlaceholder($messageText, $this->data, false);
     }
     if (!empty($messageText)) {
         $message = $messageText;
     } elseif (!empty($messageTemplate)) {
         $message = $messageTemplate;
     } elseif (!empty($content)) {
         $message = $content;
     } else {
         $message = $this->_getTextEmail();
     }
     $this->addAttachments();
     $cc = null;
     $bcc = null;
     // $$$ hugh - test stripslashes(), should be safe enough.
     $message = stripslashes($message);
     $editURL = COM_FABRIK_LIVESITE . 'index.php?option=com_' . $this->package . '&amp;view=form&amp;fabrik=' . $formModel->get('id') . '&amp;rowid=' . $input->get('rowid', '', 'string');
     $viewURL = COM_FABRIK_LIVESITE . 'index.php?option=com_' . $this->package . '&amp;view=details&amp;fabrik=' . $formModel->get('id') . '&amp;rowid=' . $input->get('rowid', '', 'string');
     $editLink = '<a href="' . $editURL . '">' . FText::_('EDIT') . '</a>';
     $viewLink = '<a href="' . $viewURL . '">' . FText::_('VIEW') . '</a>';
     $message = str_replace('{fabrik_editlink}', $editLink, $message);
     $message = str_replace('{fabrik_viewlink}', $viewLink, $message);
     $message = str_replace('{fabrik_editurl}', $editURL, $message);
     $message = str_replace('{fabrik_viewurl}', $viewURL, $message);
     // $$$ rob if email_to is not a valid email address check the raw value to see if that is
     $emailTo = explode(',', $params->get('email_to'));
     foreach ($emailTo as &$emailKey) {
         $emailKey = $w->parseMessageForPlaceholder($emailKey, $this->data, false);
         // Can be in repeat group in which case returns "email1,email2"
         $emailKey = explode(',', $emailKey);
         foreach ($emailKey as &$key) {
             // $$$ rob added strstr test as no point trying to add raw suffix if not placeholder in $emailKey
             if (!FabrikWorker::isEmail($key) && trim($key) !== '' && strstr($key, '}')) {
                 $key = explode('}', $key);
                 if (substr($key[0], -4) !== '_raw') {
                     $key = $key[0] . '_raw}';
                 } else {
                     $key = $key[0] . '}';
                 }
                 $key = $w->parseMessageForPlaceholder($key, $this->data, false);
             }
         }
     }
     // Reduce back down to single dimension array
     foreach ($emailTo as $i => $a) {
         foreach ($a as $v) {
             $emailTo[] = $v;
         }
         unset($emailTo[$i]);
     }
     $emailToEval = $params->get('email_to_eval', '');
     if (!empty($emailToEval)) {
         $emailToEval = $w->parseMessageForPlaceholder($emailToEval, $this->data, false);
         $emailToEval = @eval($emailToEval);
         FabrikWorker::logEval($emailToEval, 'Caught exception on eval in email emailto : %s');
         $emailToEval = explode(',', $emailToEval);
         $emailTo = array_merge($emailTo, $emailToEval);
     }
     @(list($emailFrom, $emailFromName) = explode(":", $w->parseMessageForPlaceholder($params->get('email_from'), $this->data, false), 2));
     if (empty($emailFrom)) {
         $emailFrom = $this->config->get('mailfrom');
     }
     if (empty($emailFromName)) {
         $emailFromName = $this->config->get('fromname', $emailFrom);
     }
     // Changes by JFQ
     @(list($returnPath, $returnPathName) = explode(":", $w->parseMessageForPlaceholder($params->get('return_path'), $this->data, false), 2));
     if (empty($returnPath)) {
         $returnPath = null;
     }
     if (empty($returnPathName)) {
         $returnPathName = null;
     }
     // End changes
     $subject = $params->get('email_subject');
     if ($subject == '') {
         $subject = $this->config->get('sitename') . " :: Email";
     }
     $subject = preg_replace_callback('/&#([0-9a-fx]+);/mi', array($this, 'replace_num_entity'), $subject);
     $attachType = $params->get('email_attach_type', '');
     $attachFileName = $this->config->get('tmp_path') . '/' . uniqid() . '.' . $attachType;
     $query = $this->_db->getQuery(true);
     $emailTo = array_map('trim', $emailTo);
     // Add any assigned groups to the to list
     $sendTo = (array) $params->get('to_group');
     $groupEmails = (array) $this->getUsersInGroups($sendTo, $field = 'email');
     $emailTo = array_merge($emailTo, $groupEmails);
     $emailTo = array_unique($emailTo);
     // Remove blank email addresses
     $emailTo = array_filter($emailTo);
     $dbEmailTo = array_map(array($this->_db, 'quote'), $emailTo);
     // Get an array of user ids from the email to array
     if (!empty($dbEmailTo)) {
         $query->select('id, email')->from('#__users')->where('email IN (' . implode(',', $dbEmailTo) . ')');
         $this->_db->setQuery($query);
         $userIds = $this->_db->loadObjectList('email');
     } else {
         $userIds = array();
     }
     // Send email
     foreach ($emailTo as $email) {
         $email = strip_tags($email);
         if (FabrikWorker::isEmail($email)) {
             $thisAttachments = $this->attachments;
             $this->data['emailto'] = $email;
             $userId = array_key_exists($email, $userIds) ? $userIds[$email]->id : 0;
             $thisUser = JFactory::getUser($userId);
             $thisMessage = $w->parseMessageForPlaceholder($message, $this->data, true, false, $thisUser);
             $thisSubject = strip_tags($w->parseMessageForPlaceholder($subject, $this->data, true, false, $thisUser));
             if (!empty($attachType)) {
                 if (JFile::write($attachFileName, $thisMessage)) {
                     $thisAttachments[] = $attachFileName;
                 } else {
                     $attachFileName = '';
                 }
             }
             $this->pdfAttachment($thisAttachments);
             /*
              * Sanity check for attachment files existing.  Could have base folder paths for things
              * like file upload elements with no file.  As of J! 3.5.1, the J! mailer tosses an exception
              * if files don't exist.  We catch that in the sendMail helper, but remove non-files here anyway
              */
             foreach ($thisAttachments as $aKey => $attachFile) {
                 if (!JFile::exists($attachFile)) {
                     unset($thisAttachments[$aKey]);
                 }
             }
             $res = FabrikWorker::sendMail($emailFrom, $emailFromName, $email, $thisSubject, $thisMessage, $htmlEmail, $cc, $bcc, $thisAttachments, $returnPath, $returnPathName);
             /*
              * $$$ hugh - added some error reporting, but not sure if 'invalid address' is the appropriate message,
              * may need to add a generic "there was an error sending the email" message
              */
             if ($res !== true) {
                 $this->app->enqueueMessage(JText::sprintf('PLG_FORM_EMAIL_DID_NOT_SEND_EMAIL', $email), 'notice');
             }
             if (JFile::exists($attachFileName)) {
                 JFile::delete($attachFileName);
             }
         } else {
             $this->app->enqueueMessage(JText::sprintf('PLG_FORM_EMAIL_DID_NOT_SEND_EMAIL_INVALID_ADDRESS', $email), 'notice');
         }
     }
     foreach ($this->deleteAttachments as $attachment) {
         if (JFile::exists($attachment)) {
             JFile::delete($attachment);
         }
     }
     $this->updateRow();
     return true;
 }