/** * Display * * @param string $tpl Template * * @return void */ public function display($tpl = null) { FabrikHelperHTML::framework(); $app = JFactory::getApplication(); $input = $app->input; $state = $this->get('State'); $item = $this->get('Item'); $document = JFactory::getDocument(); $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'; } $opts = JArrayHelper::getvalue($canvas, 'options', array()); $tabs = JArrayHelper::getValue($canvas, 'tabs', array('Page 1')); $tabs = json_encode($tabs); $d = new stdClass(); $layout = JArrayHelper::getValue($canvas, 'layout', $d); $layout = json_encode(JArrayHelper::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::runConentPlugins($text); echo $text; }
/** * Actually load the template and echo the view html * will process jplugins if required. * * @return void */ protected function output() { $app = JFactory::getApplication(); $input = $app->input; $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::runConentPlugins($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; }
/** * Do the plugin action * * @param array &$data data * * @return int number of records updated */ public function process(&$data) { $app = JFactory::getApplication(); jimport('joomla.mail.helper'); $params = $this->getParams(); $msg = $params->get('message'); FabrikHelperHTML::runConentPlugins($msg); $to = explode(',', $params->get('to')); $w = new FabrikWorker(); $MailFrom = $app->getCfg('mailfrom'); $FromName = $app->getCfg('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 {$thisto} is not an email address"; } } $updates[] = $row['__pk_val']; } } } $field = $params->get('cronemail-updatefield'); if (!empty($updates) && trim($field) != '') { // Do any update found $listModel = JModelLegacy::getInstance('list', 'FabrikFEModel'); $listModel->setId($params->get('table')); $table = $listModel->getTable(); $connection = $params->get('connection'); $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); }
/** * Finally output the HTML, running Joomla content plugins if needed * * @return void */ public function output() { $app = JFactory::getApplication(); $input = $app->input; $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::runConentPlugins($text); } // Allows you to use {placeholders} in form template. $text = $w->parseMessageForPlaceHolder($text, $model->data); echo $text; }