/** * Display * * @param string $tmpl Template * * @return void */ public function display($tmpl = 'default') { $srcs = FabrikHelperHTML::framework(); $app = JFactory::getApplication(); $input = $app->input; FabrikHelperHTML::script($srcs); $model = $this->getModel(); $usersConfig = JComponentHelper::getParams('com_fabrik'); $model->setId($input->getInt('id', $usersConfig->get('visualizationid', $input->getInt('visualizationid', 0)))); $visualization = $model->getVisualization(); $pluginParams = $model->getPluginParams(); $pluginManager = JModelLegacy::getInstance('Pluginmanager', 'FabrikModel'); $plugin = $pluginManager->getPlugIn($visualization->plugin, 'visualization'); $plugin->_row = $visualization; if ($visualization->published == 0) { return JError::raiseWarning(500, FText::_('COM_FABRIK_SORRY_THIS_VISUALIZATION_IS_UNPUBLISHED')); } // Plugin is basically a model $pluginTask = $input->get('plugintask', 'render', 'request'); // @FIXME cant set params directly like this, but I think plugin model setParams() is not right $plugin->_params = $pluginParams; $tmpl = $plugin->getParams()->get('calendar_layout', $tmpl); $plugin->{$pluginTask}($this); $this->plugin = $plugin; $viewName = $this->getName(); $this->addTemplatePath($this->_basePath . '/plugins/' . $this->_name . '/' . $plugin->_name . '/tmpl/' . $tmpl); $root = $app->isAdmin() ? JPATH_ADMINISTRATOR : JPATH_SITE; $this->addTemplatePath($root . '/templates/' . $app->getTemplate() . '/html/com_fabrik/visualization/' . $plugin->_name . '/' . $tmpl); $ab_css_file = JPATH_SITE . '/plugins/fabrik_visualization/' . $plugin->_name . '/tmpl/' . $tmpl . '/template.css'; if (JFile::exists($ab_css_file)) { JHTML::stylesheet('template.css', 'plugins/fabrik_visualization/' . $plugin->_name . '/tmpl/' . $tmpl . '/', true); } echo parent::display(); }
/** * Get RSS News feed * * @return string */ public function getRSSFeed() { // Get RSS parsed object $rssDoc = JSimplepieFactory::getFeedParser('http://feeds.feedburner.com/fabrik', 86400); if ($rssDoc == false) { $output = FText::_('Error: Feed not retrieved'); } else { // Channel header and link $title = $rssDoc->get_title(); $link = $rssDoc->get_link(); $output = '<table class="adminlist">'; $output .= '<tr><th colspan="3"><a href="' . $link . '" target="_blank">' . FText::_($title) . '</th></tr>'; $items = array_slice($rssDoc->get_items(), 0, 3); $numItems = count($items); if ($numItems == 0) { $output .= '<tr><th>' . FText::_('No news items found') . '</th></tr>'; } else { $k = 0; for ($j = 0; $j < $numItems; $j++) { $item = $items[$j]; $output .= '<tr><td class="row' . $k . '">'; $output .= '<a href="' . $item->get_link() . '" target="_blank">' . $item->get_title() . '</a>'; $output .= '<br />' . $item->get_date('Y-m-d'); if ($item->get_description()) { $description = $this->_truncateText($item->get_description(), 50); $output .= '<br />' . $description; } $output .= '</td></tr>'; $k = 1 - $k; } } $output .= '</table>'; } return $output; }
/** * Method to get the field options. * * @return array The field option objects. */ protected function getOptions() { $app = JFactory::getApplication(); if ($this->element['package']) { $package = $app->setUserState('com_fabrik.package', $this->element['package']); } $db = FabrikWorker::getDbo(true); $query = $db->getQuery(true); $query->select('id AS value, label AS ' . $db->quote('text') . ', published'); $query->from('#__{package}_forms'); if (!$this->element['showtrashed']) { $query->where('published <> -2'); } $query->order('published DESC, label ASC'); $db->setQuery($query); $rows = $db->loadObjectList(); foreach ($rows as &$row) { switch ($row->published) { case '0': $row->text .= ' [' . FText::_('JUNPUBLISHED') . ']'; break; case '-2': $row->text .= ' [' . FText::_('JTRASHED') . ']'; break; } } $o = new stdClass(); $o->value = ''; $o->text = ''; array_unshift($rows, $o); return $rows; }
/** * Get the input * * @return string */ protected function getInput() { $iframeid = $this->id . '_iframe'; $app = JFactory::getApplication(); $input = $app->input; $cid = $input->get('id', array(0), 'array'); $cid = FArrayHelper::getValue($cid, 0); // $$$ hugh - when creating a new form, no 'cid' ... not sure what to do, so just set it to 0. Should // prolly just return something like 'available after save' ? $c = isset($this->form->repeatCounter) ? (int) $this->form->repeatCounter : 0; $href = COM_FABRIK_LIVESITE . 'index.php?option=com_fabrik&task=plugin.pluginAjax&plugin=twitter'; $href .= '&g=form&method=authenticateAdmin&tmpl=component&formid=' . $cid . '&repeatCounter=' . $c; $clearjs = '$(\'jform_params_twitter_oauth_token-' . $c . '\').value = \'\';'; $clearjs .= '$(\'jform_params_twitter_oauth_token_secret-' . $c . '\').value = \'\';'; $clearjs .= '$(\'jform_params_twitter_oauth_user-' . $c . '\').value = \'\';'; $clearjs .= "return false;"; $src = COM_FABRIK_LIVESITE . 'components/com_fabrik/libs/abraham-twitteroauth/images/lighter.png'; $winOpts = 'width=800,height=460,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes'; $js = "window.open('{$href}', 'twitterwins', '" . $winOpts . "');return false;"; $parsedUrl = parse_url(JUri::root()); $origin = $parsedUrl['scheme'] . '://' . $parsedUrl['host']; $str = "\n<script type='text/javascript'>\nwindow.addEventListener('message', function(event) {\n\tif (~event.origin.indexOf('" . $origin . "')) {\n\t\tjQuery(event.data).each(function (i, k) {\n\t\t\tjQuery(k[0]).val(k[1]);\n\t\t});\n\t} else {\n\t\treturn;\n\t}\n});\n</script>\n"; $str .= '<a href="#" onclick="' . $js . '">'; $str .= '<img src="' . $src . '" alt="Sign in with Twitter"/></a>'; $str .= " | <button class=\"button btn\" href=\"#\" onclick=\"{$clearjs}\">"; $str .= FText::_('PLG_FORM_TWITTER_CLEAR_CREDENTIALS') . "</button><br/>"; $str .= "<br /><input type=\"hidden\" readonly=\"readonly\" name=\"" . $this->name . "\" id=\"" . $this->id . "\" value=\"" . $this->value . "\" />"; return $str; }
/** * Method to get the list of groups and elements * grouped by group and element. * * @return array The field option objects as a nested array in groups. */ protected function getGroups() { $app = JFactory::getApplication(); $input = $app->input; $db = FabrikWorker::getDbo(true); $query = $db->getQuery(true); $query->select('form_id')->from($db->quoteName('#__{package}_formgroup') . ' AS fg')->join('LEFT', '#__{package}_elements AS e ON e.group_id = fg.group_id')->where('e.id = ' . $input->getInt('elementid')); $db->setQuery($query); $formId = $db->loadResult(); $formModel = JModelLegacy::getInstance('Form', 'FabrikFEModel'); $formModel->setId($formId); $rows = array(); $rows[FText::_('COM_FABRIK_GROUPS')] = array(); $rows[FText::_('COM_FABRIK_ELEMENTS')] = array(); // Get available element types $groups = $formModel->getGroupsHiarachy(); foreach ($groups as $groupModel) { $group = $groupModel->getGroup(); $label = $group->name; $value = 'fabrik_trigger_group_group' . $group->id; $rows[FText::_('COM_FABRIK_GROUPS')][] = JHTML::_('select.option', $value, $label); $elementModels = $groupModel->getMyElements(); foreach ($elementModels as $elementModel) { $label = $elementModel->getFullName(false, false); $value = 'fabrik_trigger_element_' . $elementModel->getFullName(true, false); $rows[FText::_('COM_FABRIK_ELEMENTS')][] = JHTML::_('select.option', $value, $label); } } reset($rows); asort($rows[FText::_('COM_FABRIK_ELEMENTS')]); return $rows; }
/** * Send sms * * @param string $method post/get * @param string $url url to request * @param string $vars querystring vars to post * @param string $auth auth * @param string $callback method * * @return mixed data or curl error */ public static function doRequest($method, $url, $vars, $auth = '', $callback = false) { if (!function_exists('curl_init')) { throw new RuntimeException(FText::_('COM_FABRIK_ERR_CURL_NOT_INSTALLED')); return; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt'); if ($method == 'POST') { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $vars); } if (!empty($auth)) { curl_setopt($ch, CURLOPT_USERPWD, $auth); } $data = curl_exec($ch); curl_close($ch); if ($data) { if ($callback) { return call_user_func($callback, $data); } else { return $data; } } else { return curl_error($ch); } }
/** * Shows the data formatted for the list view * * @param string $data Elements data * @param stdClass &$thisRow All the data in the lists current row * @param array $opts Rendering options * * @return string formatted value */ public function renderListData($data, stdClass &$thisRow, $opts = array()) { $params = $this->getParams(); $tz_offset = $params->get('gmt_or_local', '0') == '0'; $data = JHTML::_('date', $data, FText::_($params->get('timestamp_format', 'DATE_FORMAT_LC2')), $tz_offset); return parent::renderListData($data, $thisRow, $opts); }
/** * Render uploaded image * * @param object &$model Element model * @param object &$params Element params * @param string $file Row data for this element * @param object $thisRow All row's data * * @return void */ public function render(&$model, &$params, $file, $thisRow = null) { $src = str_replace("\\", "/", COM_FABRIK_LIVESITE . $file); $ext = JString::strtolower(JFile::getExt($file)); if (!JPluginHelper::isEnabled('content', 'jw_allvideos')) { $this->output = FText::_('PLG_ELEMENT_FILEUPLOAD_INSTALL_ALL_VIDEOS'); return; } $extra = array(); $extra[] = $src; if ($this->inTableView || $params->get('fu_show_image') < 2) { $extra[] = $params->get('thumb_max_width'); $extra[] = $params->get('thumb_max_height'); } else { $extra[] = $params->get('fu_main_max_width'); $extra[] = $params->get('fu_main_max_height'); } $src = implode('|', $extra); switch ($ext) { case 'flv': $this->output = "{flvremote}{$src}{/flvremote}"; break; case '3gp': $this->output = "{3gpremote}{$src}{/3gpremote}"; break; case 'divx': $this->output = "{divxremote}{$src}{/divxremote}"; break; } }
/** * 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; }
/** * Choose which list to add an event to * * @return void */ public function chooseAddEvent() { $app = JFactory::getApplication(); $input = $app->input; $this->setLayout('chooseAddEvent'); $model = $this->getModel(); $usersConfig = JComponentHelper::getParams('com_fabrik'); $model->setId($input->getInt('id', $usersConfig->get('visualizationid', $input->getInt('visualizationid', 0)))); $rows = $model->getEventLists(); $model->getVisualization(); $options = array(); $options[] = JHTML::_('select.option', '', FText::_('PLG_VISUALIZATION_FULLCALENDAR_PLEASE_SELECT')); $model->getEvents(); $attribs = 'class="inputbox" size="1" '; $options = array_merge($options, $rows); $this->_eventTypeDd = JHTML::_('select.genericlist', $options, 'event_type', $attribs, 'value', 'text', '', 'fabrik_event_type'); /* * Tried loading in iframe and as an ajax request directly - however * in the end decided to set a call back to the main calendar object (via the package manager) * to load up the new add event form */ $ref = $model->getJSRenderContext(); $script = array(); $script[] = "document.id('fabrik_event_type').addEvent('change', function(e) {"; $script[] = "var fid = e.target.get('value');"; $script[] = "var o = ({'id':'','listid':fid,'rowid':0});"; $script[] = "o.title = Joomla.JText._('PLG_VISUALIZATION_FULLCALENDAR_ADD_EVENT');"; $script[] = "Fabrik.blocks['" . $ref . "'].addEvForm(o);"; $script[] = "Fabrik.Windows.chooseeventwin.close();"; $script[] = "});"; echo '<h2>' . FText::_('PLG_VISUALIZATION_FULLCALENDAR_PLEASE_CHOOSE_AN_EVENT_TYPE') . ':</h2>'; echo $this->_eventTypeDd; FabrikHelperHTML::addScriptDeclaration(implode("\n", $script)); }
/** * 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(); $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->js = $this->get('JS'); $viewName = $this->getName(); $params = $model->getParams(); $this->params = $params; $pluginManager = JModelLegacy::getInstance('Pluginmanager', 'FabrikFEModel'); $plugin = $pluginManager->getPlugIn('slideshow', 'visualization'); $this->showFilters = $model->showFilters(); $this->filters = $this->get('Filters'); $this->filterFormURL = $this->get('FilterFormURL'); $this->params = $model->getParams(); $this->containerId = $this->get('ContainerId'); $srcs['FbListFilter'] = 'media/com_fabrik/js/listfilter.js'; if ($this->get('RequiredFiltersFound')) { $srcs['Slideshow2'] = 'components/com_fabrik/libs/slideshow2/js/slideshow.js'; $mode = $params->get('slideshow_viz_type', 1); switch ($mode) { case 1: break; case 2: $srcs['Kenburns'] = 'components/com_fabrik/libs/slideshow2/js/slideshow.kenburns.js'; break; case 3: $srcs['Push'] = 'components/com_fabrik/libs/slideshow2/js/slideshow.push.js'; break; case 4: $srcs['Fold'] = 'components/com_fabrik/libs/slideshow2/js/slideshow.fold.js'; break; default: break; } JHTML::stylesheet('components/com_fabrik/libs/slideshow2/css/slideshow.css'); $srcs['SlideShow'] = 'plugins/fabrik_visualization/slideshow/slideshow.js'; } FabrikHelperHTML::slimbox(); FabrikHelperHTML::iniRequireJs($model->getShim()); FabrikHelperHTML::script($srcs, $this->js); //FabrikHelperHTML::slimbox(); $tpl = $j3 ? 'bootstrap' : 'default'; $tpl = $params->get('slideshow_viz_layout', $tpl); $tmplpath = $model->pathBase . 'slideshow/views/slideshow/tmpl/' . $tpl; $this->_setPath('template', $tmplpath); FabrikHelperHTML::stylesheetFromPath('plugins/fabrik_visualization/slideshow/views/slideshow/tmpl/' . $tpl . '/template.css'); FabrikHelperHTML::stylesheetFromPath('plugins/fabrik_visualization/slideshow/views/slideshow/tmpl/' . $tpl . '/custom.css'); echo parent::display(); }
/** * Attempt to alter the db structure to match the form's current status * * @return null */ public function updateDatabase() { // Check for request forgeries JSession::checkToken() or die('Invalid Token'); $this->setRedirect('index.php?option=com_fabrik&view=forms'); $this->getModel()->updateDatabase(); $this->setMessage(FText::_('COM_FABRIK_DATABASE_UPDATED')); }
/** * Method to get the field input markup. * * @return string The field input markup. */ protected function getInput() { if ((int) $this->form->getValue('form') === 0) { return '<input class="readonly" size="60" value="' . FText::_('COM_FABRIK_FIELD_ASSIGN_GROUP_TO_FORM_FIRST') . '" type="readonly" />'; } else { return parent::getInput(); } }
/** * Overloaded check function * * @return bool */ public function check() { if (trim($this->name) == '') { $this->_error = FText::_("YOUR GROUP MUST CONTAIN A NAME"); return false; } return true; }
/** * 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; }
/** * Get the input - a right floated help icon * * @return string */ public function getInput() { $url = $this->element['url'] ? (string) $this->element['url'] : ''; $js = 'Joomla.popupWindow(\'' . FText::_($url) . '\', \'Help\', 800, 600, 1);return false'; $label = '<div style="float:right;">'; $label .= '<a class="btn btn-small btn-info" href="#" rel="help" onclick="' . $js . '">'; $label .= '<i class="icon-help icon-32-help icon-question-sign"></i> ' . FText::_('JHELP') . '</a></div>'; return $label; }
/** * Method to get the field options. * * @return array The field option objects. */ protected function getOptions() { require_once COM_FABRIK_FRONTEND . '/helpers/image.php'; $imageLibs = FabimageHelper::getLibs(); if (empty($imageLibs)) { return JHTML::_('select.option', FText::_('COM_FABRIK_IMAGELIBS_NOT_FOUND')); } return $imageLibs; }
/** * 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 = null) { $input = $this->app->input; /** @var FabrikFEModelCSVExport $exporter */ $exporter = JModelLegacy::getInstance('Csvexport', 'FabrikFEModel'); /** @var FabrikFEModelList $model */ $model = JModelLegacy::getInstance('list', 'FabrikFEModel'); $model->setId($input->getInt('listid')); if (!parent::access($model)) { exit; } $model->setOutPutFormat('csv'); $exporter->model = $model; $input->set('limitstart' . $model->getId(), $input->getInt('start', 0)); $limit = $exporter->getStep(); $input->set('limit' . $model->getId(), $limit); // $$$ rob moved here from csvimport::getHeadings as we need to do this before we get // the list total $selectedFields = $input->get('fields', array(), 'array'); $model->setHeadingsForCSV($selectedFields); if (empty($model->asfields)) { throw new LengthException('CSV Export - no fields found', 500); } $request = $model->getRequestData(); $model->storeRequestData($request); $key = 'fabrik.list.' . $model->getId() . 'csv.total'; $start = $input->getInt('start', 0); // If we are asking for a new export - clear previous total as list may be filtered differently if ($start === 0) { $this->session->clear($key); } if (!$this->session->has($key)) { // Only get the total if not set - otherwise causes memory issues when we downloading $total = $model->getTotalRecords(); $this->session->set($key, $total); } else { $total = $this->session->get($key); } if ($start < $total) { if ((int) $total === 0) { $notice = new stdClass(); $notice->err = FText::_('COM_FABRIK_CSV_EXPORT_NO_RECORDS'); echo json_encode($notice); return; } $download = (bool) $input->getInt('download', true); $canDownload = $start + $limit >= $total && $download; $exporter->writeFile($total, $canDownload); if ($canDownload) { $this->download($model, $exporter, $key); } } else { $this->download($model, $exporter, $key); } return; }
/** * Method to get the field label markup. * * @return string The field label markup. */ protected function getLabel() { // Get the label text from the XML element, defaulting to the element name. $text = $this->element['label'] ? (string) $this->element['label'] : (string) $this->element['name']; $text = $this->translateLabel ? FText::_($text) : $text; $max = $this->getMax(); $mb = $max / 1024; $this->description = FText::_($this->description) . $max . 'Kb / ' . $mb . 'Mb'; return parent::getLabel(); }
/** * Gets the hover/alt text that appears over the validation rule icon in the form * * @return string label */ protected function getLabel() { $params = $this->getParams(); $tipText = $params->get('tip_text', ''); if ($tipText !== '') { return FText::_($tipText); } $isNot = $params->get('isnot-isnot'); return JText::sprintf('PLG_VALIDATIONRULE_ISNOT_LABEL', $isNot); }
/** * Method to get the field options. * * @return array The field option objects. */ protected function getOptions() { $a = array(JHTML::_('select.option', '', FText::_('COM_FABRIK_PLEASE_SELECT'))); $db = FabrikWorker::getDbo(true); $query = $db->getQuery(true); $query->select('id AS value, label AS text')->from('#__{package}_visualizations')->where('published = 1')->order('text'); $db->setQuery($query); $elementstypes = $db->loadObjectList(); $elementstypes = array_merge($a, $elementstypes); return $elementstypes; }
/** * Do the plugin action * * @param array &$data Record data * @param object &$listModel List model * @return number of records updated */ public function process(&$data, &$listModel) { $db = FabrikWorker::getDbo(); $query = $db->getQuery(true); $query->select('n.*, e.event AS event, e.id AS event_id, n.user_id AS observer_id, observer_user.name AS observer_name, observer_user.email AS observer_email, e.user_id AS creator_id, creator_user.name AS creator_name, creator_user.email AS creator_email')->from('#__{package}_notification AS n')->join('LEFT', '#__{package}_notification_event AS e ON e.reference = n.reference')->join('LEFT', '#__{package}_notification_event_sent AS s ON s.notification_event_id = e.id')->join('INNER', '#__users AS observer_user ON observer_user.id = n.user_id')->join('INNER', '#__users AS creator_user ON creator_user.id = e.user_id')->where('(s.sent <> 1 OR s.sent IS NULL) AND n.user_id <> e.user_id')->order('n.reference'); $db->setQuery($query); $rows = $db->loadObjectList(); $email_from = $this->config->get('mailfrom'); $siteName = $this->config->get('sitename'); $sent = array(); $usermsgs = array(); $successMails = array(); $failedMails = array(); foreach ($rows as $row) { /* * {observer_name, creator_name, event, record url * dear %s, %s has %s on %s */ $event = FText::_($row->event); list($listId, $formId, $rowId) = explode('.', $row->reference); $url = JRoute::_('index.php?option=com_fabrik&view=details&listid=' . $listId . '&formid=' . $formId . '&rowid=' . $rowId); $msg = JText::sprintf('FABRIK_NOTIFICATION_EMAIL_PART', $row->creator_name, $url, $event); if (!array_key_exists($row->observer_id, $usermsgs)) { $usermsgs[$row->observer_email] = array(); } $usermsgs[$row->observer_email][] = $msg; $query->clear(); $query->insert('#__{package}_notification_event_sent')->set(array('notification_event_id = ' . $row->event_id, 'user_id = ' . $row->observer_id, 'sent = 1')); $sent[] = (string) $query; } $subject = $siteName . ": " . FText::_('FABRIK_NOTIFICATION_EMAIL_SUBJECT'); foreach ($usermsgs as $email => $messages) { $msg = implode(' ', $messages); $mailer = JFactory::getMailer(); if ($mailer->sendMail($email_from, $email_from, $email, $subject, $msg, true)) { $successMails[] = $email; } else { $failedMails[] = $email; } } if (!empty($sent)) { $sent = implode(';', $sent); $db->setQuery($sent); $db->execute(); } $this->log = count($sent) . ' notifications sent.<br />'; $this->log .= 'Emailed users: <ul><li>' . implode('</li><li>', $successMails) . '</li></ul>'; if (!empty($failedMails)) { $this->log .= 'Failed emails: <ul><li>' . implode('</li><li>', $failedMails) . '</li></ul>'; } return count($successMails); }
/** * 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() { $params = $this->getParams(); $input = $this->app->input; $formModel = $this->getModel(); if ($params->get('ask-receipt')) { if (!array_key_exists('fabrik_email_copy', $_POST)) { return; } } $rowId = $input->get('rowid'); $config = JFactory::getConfig(); $w = new FabrikWorker(); $data = $this->getProcessData(); $message = $params->get('receipt_message'); $editURL = COM_FABRIK_LIVESITE . "index.php?option=com_" . $this->package . "&view=form&fabrik=" . $formModel->get('id') . "&rowid=" . $rowId; $viewURL = COM_FABRIK_LIVESITE . "index.php?option=com_" . $this->package . "&view=details&fabrik=" . $formModel->get('id') . "&rowid=" . $rowId; $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); $message = $w->parseMessageForPlaceHolder($message, $data, false); $to = $w->parseMessageForPlaceHolder($params->get('receipt_to'), $data, false); $to = FabrikString::stripSpace($to); if (empty($to)) { /* $$$ hugh - not much point trying to send if we don't have a To address * (happens frequently if folk don't properly validate their form inputs and are using placeholders) * @TODO - might want to add some feedback about email not being sent */ return; } $to = explode(',', $to); $subject = html_entity_decode($params->get('receipt_subject', '')); $subject = JText::_($w->parseMessageForPlaceHolder($subject, $data, false)); $from = $config->get('mailfrom', ''); $fromName = $config->get('fromname', ''); // Darn silly hack for poor joomfish settings where lang parameters are set to override joomla global config but not mail translations entered $rawConfig = new JConfig(); if ($from === '') { $from = $rawConfig->mailfrom; } if ($fromName === '') { $fromName = $rawConfig->fromname; } $from = $params->get('from_email', $from); $res = FabrikWorker::sendMail($from, $fromName, $to, $subject, $message, true); if (!$res) { throw new RuntimeException('Couldn\'t send receipt', 500); } }
/** * Method to get the field input markup. * * @return string The field input markup. */ protected function getInput() { $id = $this->form->getValue('id'); if ($id) { // Get the field options. $options = (array) $this->getOptions(); $ordering = JHTML::_('select.genericlist', $options, $this->name, 'class="inputbox" size="1"', 'value', 'text', $this->value); } else { $text = FText::_('COM_FABRIK_NEW_ITEMS_LAST'); $ordering = '<input type="text" size="40" readonly="readonly" class="readonly" name="' . $this->name . '" value="' . $this->value . $text . '" />'; } return $ordering; }
/** * Display the view * * @param string $tmpl Template * * @return void */ public function display($tmpl = 'default') { $model = $this->getModel(); $app = JFactory::getApplication(); $input = $app->input; $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; } echo $model->getEvents(); }
/** * Create empty index.html for security * * @param string $path path to folder * * @return bool success */ public function createIndexFile($path) { // Don't write a index.html in root if ($path === '') { return true; } $index_file = $path . '/index.html'; if (!$this->exists($index_file)) { $content = FText::_('PLG_ELEMENT_FILEUPLOAD_INDEX_FILE_CONTENT'); return JFile::write($index_file, $content); } return true; }
/** * Build the radius search HTML * * @param array &$args Plugin args * * @return void */ public function onMakeFilters(&$args) { if (!is_object($this->getMapElement())) { return; } $model = $this->getModel(); $params = $this->getParams(); $f = new stdClass(); $f->label = FText::_($params->get('radius_label', 'Radius search')); FabrikHelperHTML::stylesheet('plugins/fabrik_list/radius_search/radius_search.css'); $layoutData = new stdClass(); $layoutData->renderOrder = $this->renderOrder; $layoutData->baseContext = $this->getSessionContext(); $layoutData->defaultSearch = $params->get('default_search', 'mylocation'); $layoutData->geocodeDefault = $params->get('geocode_default', ''); $layoutData->unit = $this->getParams()->get('radius_unit', 'km'); $layoutData->distance = $this->getValue(); $layoutData->startActive = $params->get('start_active', 0); $typeKey = $layoutData->baseContext . 'radius_search_type' . $this->renderOrder; $type = $this->app->getUserStateFromRequest($typeKey, 'radius_search_type' . $this->renderOrder, array($layoutData->defaultSearch)); $layoutData->select = $this->searchSelectList($type); $layoutData->type = $type[0]; list($layoutData->searchLatitude, $layoutData->searchLongitude) = $this->getSearchLatLon(); $layoutData->geocodeAsYouType = $params->get('geocode_as_type', 1); $layoutData->hasGeocode = $params->get('geocode', 1) == 1; $layoutData->address = $address = $this->app->getUserStateFromRequest($layoutData->baseContext . 'geocode' . $this->renderOrder, 'radius_search_geocode_field' . $this->renderOrder); $lat = $this->app->getUserStateFromRequest($layoutData->baseContext . 'lat' . $this->renderOrder, 'radius_search_lat' . $this->renderOrder); $lon = $this->app->getUserStateFromRequest($layoutData->baseContext . 'lon' . $this->renderOrder, 'radius_search_lon' . $this->renderOrder); $o = FabrikString::mapStrToCoords($layoutData->geocodeDefault); $layoutData->defaultLat = $lat ? $lat : (double) $o->lat; $layoutData->defaultLon = $lon ? $lon : (double) $o->long; $layoutData->defaultZoom = (int) $o->zoom === 0 ? 7 : (int) $o->zoom; $layoutData->lat = $lat; $layoutData->lon = $lon; $active = $this->app->getUserStateFromRequest($layoutData->baseContext . 'radius_search_active', 'radius_search_active' . $this->renderOrder, array($layoutData->startActive)); $layoutData->active = $active[0]; $layout = $this->getLayout('filters'); $str = $layout->render($layoutData); $f->element = $str; $f->required = ''; if ($this->app->input->get('format') !== 'raw') { FabrikHelperHTML::addStyleDeclaration("table.radius_table{border-collapse:collapse;border:0;}\n\t\t\ttable.radius_table td{border:0;}"); } JText::script('PLG_VIEW_RADIUS_NO_GEOLOCATION_AVAILABLE'); JText::script('COM_FABRIK_SEARCH'); JText::script('PLG_LIST_RADIUS_SEARCH'); JText::script('PLG_LIST_RADIUS_SEARCH_BUTTON'); $mapElement = $this->getMapElement(); $mapName = $mapElement->getFullName(true, false); $model->viewfilters[$mapName] = $f; }
/** * Get a html drop down list of the element types with this objs element type selected as default * * @param string $default Selected option * @param string $name Html name for drop down * @param string $extra Extra info for drop down * @param string $defaultlabel Html element type list * * @return string */ public function getElementTypeDd($default, $name = 'plugin', $extra = 'class="inputbox elementtype" size="1"', $defaultlabel = '') { $hash = $default . $name . $extra . $defaultlabel; if (!array_key_exists($hash, $this->elementLists)) { if ($defaultlabel == '') { $defaultlabel = FText::_('COM_FABRIK_PLEASE_SELECT'); } $a = array(JHTML::_('select.option', '', $defaultlabel)); $elementstypes = $this->_getList(); $elementstypes = array_merge($a, $elementstypes); $this->elementLists[$hash] = JHTML::_('select.genericlist', $elementstypes, $name, $extra, 'value', 'text', $default); } return $this->elementLists[$hash]; }
/** * 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(); $usersConfig = JComponentHelper::getParams('com_fabrik'); $model = $this->getModel(); $id = $input->getInt('id', $usersConfig->get('visualizationid', $input->getInt('visualizationid', 0))); $model->setId($id); $row = $model->getVisualization(); if (!$model->canView()) { echo FText::_('JERROR_ALERTNOAUTHOR'); return false; } $js = $model->render(); $this->containerId = $this->get('ContainerId'); $this->row = $row; $this->showFilters = $input->getInt('showfilters', 1) === 1 ? 1 : 0; $this->filters = $model->getFilters(); $this->advancedSearch = $model->getAdvancedSearchLink(); $this->filterFormURL = $model->getFilterFormURL(); $params = $model->getParams(); $this->params = $params; $this->width = $params->get('timeline_width', '700'); $this->height = $params->get('timeline_height', '300'); $tpl = $j3 ? 'bootstrap' : 'default'; $tpl = $params->get('timeline_layout', $tpl); $tmplpath = '/plugins/fabrik_visualization/timeline/views/timeline/tmpl/' . $tpl; $this->_setPath('template', JPATH_ROOT . $tmplpath); JHTML::stylesheet('media/com_fabrik/css/list.css'); FabrikHelperHTML::stylesheetFromPath($tmplpath . '/template.css'); $srcs['FbListFilter'] = 'media/com_fabrik/js/listfilter.js'; $srcs['Timeline'] = 'plugins/fabrik_visualization/timeline/timeline.js'; $srcs['AdvancedSearch'] = 'media/com_fabrik/js/advanced-search.js'; $js .= $model->getFilterJs(); FabrikHelperHTML::iniRequireJs($model->getShim()); FabrikHelperHTML::script($srcs, $js); JText::script('COM_FABRIK_ADVANCED_SEARCH'); JText::script('COM_FABRIK_LOADING'); $opts = array('alt' => 'calendar', 'class' => 'calendarbutton', 'id' => 'timelineDatePicker_cal_img'); $img = FabrikHelperHTML::image('calendar.png', 'form', @$this->tmpl, $opts); $this->datePicker = '<input type="text" name="timelineDatePicker" id="timelineDatePicker" value="" />' . $img; // 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 biz template css file overrides template css generic table css and generic custom css FabrikHelperHTML::stylesheetFromPath('plugins/fabrik_visualization/timeline/views/timeline/tmpl/' . $tpl . '/custom.css'); return parent::display(); }
/** * Method to get the field options. * * @return array The field option objects. */ protected function getOptions() { // Initialize variables. $options = array(); $db = FabrikWorker::getDbo(true); $query = $db->getQuery(true); $query->select('f.id AS value, f.label AS text, l.id AS listid')->from('#__{package}_forms AS f')->join('LEFT', '#__{package}_lists As l ON f.id = l.form_id')->where('f.published = 1 AND l.db_table_name = ' . $db->quote($this->form->getValue('params.join_db_name')))->order('f.label'); // Get the options. $db->setQuery($query); $options = $db->loadObjectList('value'); if (empty($options)) { $options[] = JHTML::_('select.option', '', FText::_('COM_FABRIK_NO_POPUP_FORMS_AVAILABLE')); } return $options; }