public function onBeforeDispatch() { $result = parent::onBeforeDispatch(); if ($result) { // Load Akeeba Strapper include_once JPATH_ROOT . '/media/akeeba_strapper/strapper.php'; AkeebaStrapper::$tag = AKEEBAMEDIATAG; AkeebaStrapper::bootstrap(); AkeebaStrapper::jQueryUI(); AkeebaStrapper::addJSfile('media://com_akeeba/js/gui-helpers.js'); AkeebaStrapper::addJSfile('media://com_akeeba/js/akeebaui.js'); AkeebaStrapper::addJSfile('media://com_akeeba/js/piecon.min.js'); jimport('joomla.filesystem.file'); if (JFile::exists(F0FTemplateUtils::parsePath('media://com_akeeba/plugins/js/akeebaui.js', true))) { AkeebaStrapper::addJSfile('media://com_akeeba/plugins/js/akeebaui.js'); } AkeebaStrapper::addCSSfile('media://com_akeeba/theme/akeebaui.css'); // Control Check $view = F0FInflector::singularize($this->input->getCmd('view', $this->defaultView)); if ($view == 'liveupdate') { $url = JUri::base() . 'index.php?option=com_akeeba'; JFactory::getApplication()->redirect($url); return; } } return $result; }
public function cron($cachable = false) { // Makes sure SiteGround's SuperCache doesn't cache the CRON view JResponse::setHeader('X-Cache-Control', 'False', true); require_once F0FTemplateUtils::parsePath('admin://components/com_akeebasubs/helpers/cparams.php', true); $configuredSecret = AkeebasubsHelperCparams::getParam('secret', ''); if (empty($configuredSecret)) { header('HTTP/1.1 503 Service unavailable due to configuration'); JFactory::getApplication()->close(); } $secret = $this->input->get('secret', null, 'raw'); if ($secret != $configuredSecret) { header('HTTP/1.1 403 Forbidden'); JFactory::getApplication()->close(); } $command = $this->input->get('command', null, 'raw'); $command = trim(strtolower($command)); if (empty($command)) { header('HTTP/1.1 501 Not implemented'); JFactory::getApplication()->close(); } F0FPlatform::getInstance()->importPlugin('system'); F0FPlatform::getInstance()->runPlugins('onAkeebasubsCronTask', array($command, array('time_limit' => 10))); echo "{$command} OK"; JFactory::getApplication()->close(); }
/** * Create objects for the options * * @return array The array of option objects */ protected function getOptions() { $options = array(); // Get the field $options foreach ($this->element->children() as $option) { // Only add <option /> elements. if ($option->getName() != 'option') { continue; } // Create a new option object based on the <option /> element. $options[] = JHtml::_('select.option', (string) $option['value'], JText::alt(trim((string) $option), preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)), 'value', 'text', (string) $option['disabled'] == 'true'); } // Do we have a class and method source for our options? $source_file = empty($this->element['source_file']) ? '' : (string) $this->element['source_file']; $source_class = empty($this->element['source_class']) ? '' : (string) $this->element['source_class']; $source_method = empty($this->element['source_method']) ? '' : (string) $this->element['source_method']; $source_key = empty($this->element['source_key']) ? '*' : (string) $this->element['source_key']; $source_value = empty($this->element['source_value']) ? '*' : (string) $this->element['source_value']; $source_translate = empty($this->element['source_translate']) ? 'true' : (string) $this->element['source_translate']; $source_translate = in_array(strtolower($source_translate), array('true', 'yes', '1', 'on')) ? true : false; $source_format = empty($this->element['source_format']) ? '' : (string) $this->element['source_format']; if ($source_class && $source_method) { // Maybe we have to load a file? if (!empty($source_file)) { $source_file = F0FTemplateUtils::parsePath($source_file, true); if (F0FPlatform::getInstance()->getIntegrationObject('filesystem')->fileExists($source_file)) { include_once $source_file; } } // Make sure the class exists if (class_exists($source_class, true)) { // ...and so does the option if (in_array($source_method, get_class_methods($source_class))) { // Get the data from the class if ($source_format == 'optionsobject') { $options = array_merge($options, $source_class::$source_method()); } else { $source_data = $source_class::$source_method(); // Loop through the data and prime the $options array foreach ($source_data as $k => $v) { $key = empty($source_key) || $source_key == '*' ? $k : $v[$source_key]; $value = empty($source_value) || $source_value == '*' ? $v : $v[$source_value]; if ($source_translate) { $value = JText::_($value); } $options[] = JHtml::_('select.option', $key, $value, 'value', 'text'); } } } } } reset($options); return $options; }
/** * Get the rendering of this field type for a repeatable (grid) display, * e.g. in a view listing many item (typically a "browse" task) * * @since 2.0 * * @return string The field HTML */ public function getRepeatable() { include_once F0FTemplateUtils::parsePath('admin://components/com_akeebasubs/helpers/image.php', true); // Initialise $class = $this->id; // Get field parameters if ($this->element['class']) { $class = (string) $this->element['class']; } // Start the HTML output $html = '<span class="' . $class . '">'; $html .= '<img src="' . AkeebasubsHelperImage::getURL($this->value) . '" width="32" height="32" class="sublevelpic" />'; // End the HTML output $html .= '</span>'; return $html; }
/** * Get the rendering of this field type for a repeatable (grid) display, * e.g. in a view listing many item (typically a "browse" task) * * @since 2.0 * * @return string The field HTML */ public function getRepeatable() { include_once F0FTemplateUtils::parsePath('admin://components/com_akeebasubs/helpers/cparams.php', true); // Initialise $class = $this->id; $typeField = 'type'; $classValue = 'akeebasubs-coupon-discount-value'; $classPercent = 'akeebasubs-coupon-discount-percent'; $classLastPercent = 'akeebasubs-coupon-discount-lastpercent'; // Get field parameters if ($this->element['class']) { $class = (string) $this->element['class']; } if ($this->element['type_field']) { $typeField = (string) $this->element['type_field']; } if ($this->element['class_value']) { $classValue = (string) $this->element['class_value']; } if ($this->element['class_percent']) { $classPercent = (string) $this->element['class_percent']; } if ($this->element['class_lastpercent']) { $classLastPercent = (string) $this->element['class_lastpercent']; } $type = $this->item->{$typeField}; // Start the HTML output $extraClass = $type == 'value' ? $classValue : $classPercent; $extraClass .= $type == 'lastpercent' ? ' ' . $classLastPercent : ''; $html = '<span class="' . $class . ' ' . $extraClass . '">'; // Case 1: Value discount if ($type == 'value') { if (AkeebasubsHelperCparams::getParam('currencypos', 'before') == 'before') { $html .= AkeebasubsHelperCparams::getParam('currencysymbol', '€'); } $html .= ' ' . sprintf('%02.02f', (double) $this->value) . ' '; if (AkeebasubsHelperCparams::getParam('currencypos', 'before') == 'after') { $html .= AkeebasubsHelperCparams::getParam('currencysymbol', '€'); } } else { $html .= sprintf('%2.2f', (double) $this->value) . ' %'; } // End the HTML output $html .= '</span>'; return $html; }
public function onBeforeDispatch() { $result = parent::onBeforeDispatch(); if ($result) { // Load Akeeba Strapper include_once JPATH_ROOT . '/media/akeeba_strapper/strapper.php'; AkeebaStrapper::$tag = AKEEBAMEDIATAG; AkeebaStrapper::bootstrap(); AkeebaStrapper::jQueryUI(); AkeebaStrapper::addJSfile('media://com_akeeba/js/gui-helpers.js'); AkeebaStrapper::addJSfile('media://com_akeeba/js/system.js'); AkeebaStrapper::addJSfile('media://com_akeeba/js/akeebaui.js'); AkeebaStrapper::addJSfile('media://com_akeeba/js/piecon.min.js'); jimport('joomla.filesystem.file'); if (JFile::exists(F0FTemplateUtils::parsePath('media://com_akeeba/js/akeebauipro.js', true))) { AkeebaStrapper::addJSfile('media://com_akeeba/js/akeebauipro.js'); } AkeebaStrapper::addCSSfile('media://com_akeeba/theme/akeebaui.css'); } return $result; }
/** * Get the rendering of this field type for a repeatable (grid) display, * e.g. in a view listing many item (typically a "browse" task) * * @since 2.0 * * @return string The field HTML */ public function getRepeatable() { include_once F0FTemplateUtils::parsePath('admin://components/com_akeebasubs/helpers/cparams.php', true); // Initialise $class = $this->id; // Get field parameters if ($this->element['class']) { $class = (string) $this->element['class']; } // Start the HTML output $html = '<span class="' . $class . '">'; // First line: regular price if (AkeebasubsHelperCparams::getParam('currencypos', 'before') == 'before') { $html .= AkeebasubsHelperCparams::getParam('currencysymbol', '€'); } $html .= ' ' . sprintf('%02.02f', (double) $this->value) . ' '; if (AkeebasubsHelperCparams::getParam('currencypos', 'before') == 'after') { $html .= AkeebasubsHelperCparams::getParam('currencysymbol', '€'); } // Second line: sign-up fee if (property_exists($this->item, 'signupfee') && $this->item->signupfee >= 0.01) { $html .= '<br /><span class="small">( '; $html .= JText::_('COM_AKEEBASUBS_LEVEL_FIELD_SIGNUPFEE_LIST'); if (AkeebasubsHelperCparams::getParam('currencypos', 'before') == 'before') { $html .= ' ' . AkeebasubsHelperCparams::getParam('currencysymbol', '€'); } $html .= sprintf('%02.02f', (double) $this->item->signupfee); if (AkeebasubsHelperCparams::getParam('currencypos', 'before') == 'after') { $html .= AkeebasubsHelperCparams::getParam('currencysymbol', '€'); } $html .= ' )</span>'; } // End the HTML output $html .= '</span>'; return $html; }
" src="<?php echo F0FTemplateUtils::parsePath('media://com_akeebasubs/images/dashboard/money.png'); ?> " /> <span><?php echo JText::_('COM_AKEEBASUBS_REPORTS_VIES'); ?> </span> </a> </div> </div> <div style="float:left;"> <div class="icon"> <a href="index.php?option=com_akeebasubs&view=reports&task=vatmoss"> <img alt="<?php echo JText::_('COM_AKEEBASUBS_REPORTS_VATMOSS'); ?> " src="<?php echo F0FTemplateUtils::parsePath('media://com_akeebasubs/images/dashboard/money.png'); ?> " /> <span><?php echo JText::_('COM_AKEEBASUBS_REPORTS_VATMOSS'); ?> </span> </a> </div> </div> </div>
/** * Method to get the field options. * * Ordering is disabled by default. You can enable ordering by setting the * 'order' element in your form field. The other order values are optional. * * - order What to order. Possible values: 'name' or 'value' (default = false) * - order_dir Order direction. Possible values: 'asc' = Ascending or 'desc' = Descending (default = 'asc') * - order_case_sensitive Order case sensitive. Possible values: 'true' or 'false' (default = false) * * @return array The field option objects. * * @since Ordering is available since F0F 2.1.b2. */ protected function getOptions() { // Ordering is disabled by default for backward compatibility $order = false; // Set default order direction $order_dir = 'asc'; // Set default value for case sensitive sorting $order_case_sensitive = false; if ($this->element['order'] && $this->element['order'] !== 'false') { $order = $this->element['order']; } if ($this->element['order_dir']) { $order_dir = $this->element['order_dir']; } if ($this->element['order_case_sensitive']) { // Override default setting when the form element value is 'true' if ($this->element['order_case_sensitive'] == 'true') { $order_case_sensitive = true; } } // Create a $sortOptions array in order to apply sorting $i = 0; $sortOptions = array(); foreach ($this->element->children() as $option) { $name = JText::alt(trim((string) $option), preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)); $sortOptions[$i] = new stdClass(); $sortOptions[$i]->option = $option; $sortOptions[$i]->value = $option['value']; $sortOptions[$i]->name = $name; $i++; } // Only order if it's set if ($order) { jimport('joomla.utilities.arrayhelper'); F0FUtilsArray::sortObjects($sortOptions, $order, $order_dir == 'asc' ? 1 : -1, $order_case_sensitive, false); } // Initialise the options $options = array(); // Get the field $options foreach ($sortOptions as $sortOption) { $option = $sortOption->option; $name = $sortOption->name; // Only add <option /> elements. if ($option->getName() != 'option') { continue; } $tmp = JHtml::_('select.option', (string) $option['value'], $name, 'value', 'text', (string) $option['disabled'] == 'true'); // Set some option attributes. $tmp->class = (string) $option['class']; // Set some JavaScript option attributes. $tmp->onclick = (string) $option['onclick']; // Add the option object to the result set. $options[] = $tmp; } // Do we have a class and method source for our options? $source_file = empty($this->element['source_file']) ? '' : (string) $this->element['source_file']; $source_class = empty($this->element['source_class']) ? '' : (string) $this->element['source_class']; $source_method = empty($this->element['source_method']) ? '' : (string) $this->element['source_method']; $source_key = empty($this->element['source_key']) ? '*' : (string) $this->element['source_key']; $source_value = empty($this->element['source_value']) ? '*' : (string) $this->element['source_value']; $source_translate = empty($this->element['source_translate']) ? 'true' : (string) $this->element['source_translate']; $source_translate = in_array(strtolower($source_translate), array('true', 'yes', '1', 'on')) ? true : false; $source_format = empty($this->element['source_format']) ? '' : (string) $this->element['source_format']; if ($source_class && $source_method) { // Maybe we have to load a file? if (!empty($source_file)) { $source_file = F0FTemplateUtils::parsePath($source_file, true); if (F0FPlatform::getInstance()->getIntegrationObject('filesystem')->fileExists($source_file)) { include_once $source_file; } } // Make sure the class exists if (class_exists($source_class, true)) { // ...and so does the option if (in_array($source_method, get_class_methods($source_class))) { // Get the data from the class if ($source_format == 'optionsobject') { $options = array_merge($options, $source_class::$source_method()); } else { // Get the data from the class $source_data = $source_class::$source_method(); } } } } //to avoid jquery error foreach ($source_data as $cat) { $cat->title = str_replace(' ', '_', $cat->title); } return $source_data; }
/** * Adds an arbitrary CSS file. * * @param $path string The path to the file, in the format media://path/to/file * @param $overrideTag string If defined this version tag overrides AkeebaStrapper::$tag */ public static function addCSSfile($path, $overrideTag = null) { if (self::isCli()) { return; } $tag = self::getTag($overrideTag); self::$cssURLs[] = array(F0FTemplateUtils::parsePath($path), $tag); }
/** * Adds or updates a post-installation message (PIM) definition for Joomla! 3.2 or later. You can use this in your * post-installation script using this code: * * The $options array contains the following mandatory keys: * * extension_id The numeric ID of the extension this message is for (see the #__extensions table) * * type One of message, link or action. Their meaning is: * message Informative message. The user can dismiss it. * link The action button links to a URL. The URL is defined in the action parameter. * action A PHP action takes place when the action button is clicked. You need to specify the * action_file (RAD path to the PHP file) and action (PHP function name) keys. See * below for more information. * * title_key The JText language key for the title of this PIM * Example: COM_FOOBAR_POSTINSTALL_MESSAGEONE_TITLE * * description_key The JText language key for the main body (description) of this PIM * Example: COM_FOOBAR_POSTINSTALL_MESSAGEONE_DESCRIPTION * * action_key The JText language key for the action button. Ignored and not required when type=message * Example: COM_FOOBAR_POSTINSTALL_MESSAGEONE_ACTION * * language_extension The extension name which holds the language keys used above. For example, com_foobar, * mod_something, plg_system_whatever, tpl_mytemplate * * language_client_id Should we load the front-end (0) or back-end (1) language keys? * * version_introduced Which was the version of your extension where this message appeared for the first time? * Example: 3.2.1 * * enabled Must be 1 for this message to be enabled. If you omit it, it defaults to 1. * * condition_file The RAD path to a PHP file containing a PHP function which determines whether this message * should be shown to the user. @see F0FTemplateUtils::parsePath() for RAD path format. Joomla! * will include this file before calling the condition_method. * Example: admin://components/com_foobar/helpers/postinstall.php * * condition_method The name of a PHP function which will be used to determine whether to show this message to * the user. This must be a simple PHP user function (not a class method, static method etc) * which returns true to show the message and false to hide it. This function is defined in the * condition_file. * Example: com_foobar_postinstall_messageone_condition * * When type=message no additional keys are required. * * When type=link the following additional keys are required: * * action The URL which will open when the user clicks on the PIM's action button * Example: index.php?option=com_foobar&view=tools&task=installSampleData * * Then type=action the following additional keys are required: * * action_file The RAD path to a PHP file containing a PHP function which performs the action of this PIM. * * @see F0FTemplateUtils::parsePath() for RAD path format. Joomla! will include this file * before calling the function defined in the action key below. * Example: admin://components/com_foobar/helpers/postinstall.php * * action The name of a PHP function which will be used to run the action of this PIM. This must be a * simple PHP user function (not a class method, static method etc) which returns no result. * Example: com_foobar_postinstall_messageone_action * * @param array $options See description * * @return void * * @throws Exception */ protected function addPostInstallationMessage(array $options) { // Make sure there are options set if (!is_array($options)) { throw new Exception('Post-installation message definitions must be of type array', 500); } // Initialise array keys $defaultOptions = array('extension_id' => '', 'type' => '', 'title_key' => '', 'description_key' => '', 'action_key' => '', 'language_extension' => '', 'language_client_id' => '', 'action_file' => '', 'action' => '', 'condition_file' => '', 'condition_method' => '', 'version_introduced' => '', 'enabled' => '1'); $options = array_merge($defaultOptions, $options); // Array normalisation. Removes array keys not belonging to a definition. $defaultKeys = array_keys($defaultOptions); $allKeys = array_keys($options); $extraKeys = array_diff($allKeys, $defaultKeys); if (!empty($extraKeys)) { foreach ($extraKeys as $key) { unset($options[$key]); } } // Normalisation of integer values $options['extension_id'] = (int) $options['extension_id']; $options['language_client_id'] = (int) $options['language_client_id']; $options['enabled'] = (int) $options['enabled']; // Normalisation of 0/1 values foreach (array('language_client_id', 'enabled') as $key) { $options[$key] = $options[$key] ? 1 : 0; } // Make sure there's an extension_id if (!(int) $options['extension_id']) { throw new Exception('Post-installation message definitions need an extension_id', 500); } // Make sure there's a valid type if (!in_array($options['type'], array('message', 'link', 'action'))) { throw new Exception('Post-installation message definitions need to declare a type of message, link or action', 500); } // Make sure there's a title key if (empty($options['title_key'])) { throw new Exception('Post-installation message definitions need a title key', 500); } // Make sure there's a description key if (empty($options['description_key'])) { throw new Exception('Post-installation message definitions need a description key', 500); } // If the type is anything other than message you need an action key if ($options['type'] != 'message' && empty($options['action_key'])) { throw new Exception('Post-installation message definitions need an action key when they are of type "' . $options['type'] . '"', 500); } // You must specify the language extension if (empty($options['language_extension'])) { throw new Exception('Post-installation message definitions need to specify which extension contains their language keys', 500); } // The action file and method are only required for the "action" type if ($options['type'] == 'action') { if (empty($options['action_file'])) { throw new Exception('Post-installation message definitions need an action file when they are of type "action"', 500); } $file_path = F0FTemplateUtils::parsePath($options['action_file'], true); if (!@is_file($file_path)) { throw new Exception('The action file ' . $options['action_file'] . ' of your post-installation message definition does not exist', 500); } if (empty($options['action'])) { throw new Exception('Post-installation message definitions need an action (function name) when they are of type "action"', 500); } } if ($options['type'] == 'link') { if (empty($options['link'])) { throw new Exception('Post-installation message definitions need an action (URL) when they are of type "link"', 500); } } // The condition file and method are only required when the type is not "message" if ($options['type'] != 'message') { if (empty($options['condition_file'])) { throw new Exception('Post-installation message definitions need a condition file when they are of type "' . $options['type'] . '"', 500); } $file_path = F0FTemplateUtils::parsePath($options['condition_file'], true); if (!@is_file($file_path)) { throw new Exception('The condition file ' . $options['condition_file'] . ' of your post-installation message definition does not exist', 500); } if (empty($options['condition_method'])) { throw new Exception('Post-installation message definitions need a condition method (function name) when they are of type "' . $options['type'] . '"', 500); } } // Check if the definition exists $tableName = '#__postinstall_messages'; $db = F0FPlatform::getInstance()->getDbo(); $query = $db->getQuery(true)->select('*')->from($db->qn($tableName))->where($db->qn('extension_id') . ' = ' . $db->q($options['extension_id']))->where($db->qn('type') . ' = ' . $db->q($options['type']))->where($db->qn('title_key') . ' = ' . $db->q($options['title_key'])); $existingRow = $db->setQuery($query)->loadAssoc(); // Is the existing definition the same as the one we're trying to save (ignore the enabled flag)? if (!empty($existingRow)) { $same = true; foreach ($options as $k => $v) { if ($k == 'enabled') { continue; } if ($existingRow[$k] != $v) { $same = false; break; } } // Trying to add the same row as the existing one; quit if ($same) { return; } // Otherwise it's not the same row. Remove the old row before insert a new one. $query = $db->getQuery(true)->delete($db->qn($tableName))->where($db->q('extension_id') . ' = ' . $db->q($options['extension_id']))->where($db->q('type') . ' = ' . $db->q($options['type']))->where($db->q('title_key') . ' = ' . $db->q($options['title_key'])); $db->setQuery($query)->execute(); } // Insert the new row $options = (object) $options; $db->insertObject($tableName, $options); }
<p id="aksaleschart-nodata" style="display:none"> <?php echo JText::_('COM_AKEEBASUBS_DASHBOARD_STATS_NODATA'); ?> </p> </div> <div style="clear: both;"> </div> <h3><?php echo JText::_('COM_AKEEBASUBS_DASHBOARD_LEVELSTATS'); ?> </h3> <div id="aklevelschart"> <img src="<?php echo F0FTemplateUtils::parsePath('media://com_akeebasubs/images/throbber.gif'); ?> " id="akthrobber2" /> <p id="aklevelschart-nodata" style="display:none"> <?php echo JText::_('COM_AKEEBASUBS_DASHBOARD_STATS_NODATA'); ?> </p> </div> <script type="text/javascript"> akeebasubs_cpanel_graph_from = "<?php echo $graphDayFrom; ?> ";
<p id="aksaleschart-nodata" style="display:none"> <?php echo JText::_('COM_ADMINTOOLS_DASHBOARD_STATS_NODATA'); ?> </p> </div> <div style="clear: both;"> </div> <h3><?php echo JText::_('COM_ADMINTOOLS_DASHBOARD_EXCEPTSTATS'); ?> </h3> <div id="aklevelschart"> <img src="<?php echo F0FTemplateUtils::parsePath('admin://components/com_admintools/media/images/throbber.gif'); ?> " id="akthrobber2"/> <p id="aklevelschart-nodata" style="display:none"> <?php echo JText::_('COM_ADMINTOOLS_DASHBOARD_STATS_NODATA'); ?> </p> </div> <script type="text/javascript"> admintools_cpanel_graph_from = "<?php echo $graphDayFrom;
<p id="aksaleschart-nodata" style="display:none"> <?php echo JText::_('COM_ADMINTOOLS_DASHBOARD_STATS_NODATA'); ?> </p> </div> <div style="clear: both;"> </div> <h3><?php echo JText::_('COM_ADMINTOOLS_DASHBOARD_EXCEPTSTATS'); ?> </h3> <div id="aklevelschart"> <img src="<?php echo F0FTemplateUtils::parsePath('media://com_admintools/images/throbber.gif'); ?> " id="akthrobber2"/> <p id="aklevelschart-nodata" style="display:none"> <?php echo JText::_('COM_ADMINTOOLS_DASHBOARD_STATS_NODATA'); ?> </p> </div> <script type="text/javascript"> admintools_cpanel_graph_from = "<?php echo $graphDayFrom;