. * * @since iCagenda 3.5.16 *---------------------------------------------------------------------------- */ defined('_JEXEC') or die; /** * iCagenda Quick Icon update notification plugin */ class PlgQuickiconiCagendaupdate extends JPlugin { /** * Constructor (ONLY NEEDED FOR JOOMLA 2.5) * * @param object $subject The object to observe * @param array $config An array that holds the plugin configuration * * @since 1.0 */ public function __construct(& $subject, $config) { parent::__construct($subject, $config); $this->loadLanguage(); } /** * Load the language file on instantiation. * * @var boolean * @since 1.0 */ protected $autoloadLanguage = true; /** * This method is called when the Quick Icons module is constructing its set * of icons. You can return an array which defines a single icon and it will * be rendered right after the stock Quick Icons. * * @param string $context The calling context * * @return array A list of icon definition associative arrays, consisting of the * keys link, image, text and access. * * @since 1.0 */ public function onGetIcons($context) { $UTILITIES_DIR = is_dir(JPATH_ADMINISTRATOR . '/components/com_icagenda/utilities'); if ($context != $this->params->get('context', 'mod_quickicon') || ! JFactory::getUser()->authorise('core.manage', 'com_installer') || ! $UTILITIES_DIR ) { return; } // Load Vector iCicons Font JHtml::stylesheet( 'media/com_icagenda/icicons/style.css' ); // Load iCagenda Live Update require_once JPATH_ADMINISTRATOR . '/components/com_icagenda/liveupdate/liveupdate.php'; $updateInfo = LiveUpdate::getUpdateInformation(); // Initialize the array of button options $button = array(); // Not supported if ( ! $updateInfo->supported) { $button['text'] = JText::_('PLG_QUICKICON_ICAGENDAUPDATE_LIVEUPDATE') . ' ' . JText::_('PLG_QUICKICON_ICAGENDAUPDATE_NOT_SUPPORTED') . ''; $button['icon'] = version_compare(JVERSION, '3.0', 'ge') ? 'iclogo' : JUri::root() . 'media/com_icagenda/images/logo_joomlic.png'; } // Crash elseif ($updateInfo->stuck) { $button['text'] = JText::_('PLG_QUICKICON_ICAGENDAUPDATE_LIVEUPDATE') . ' ' . JText::_('PLG_QUICKICON_ICAGENDAUPDATE_CRASHED') . ''; $button['icon'] = version_compare(JVERSION, '3.0', 'ge') ? 'iclogo' : JUri::root() . 'media/com_icagenda/images/logo_joomlic.png'; } // Has updates elseif ($updateInfo->hasUpdates) { $button['text'] = '' . JText::sprintf('PLG_QUICKICON_ICAGENDAUPDATE_UPDATEFOUND', $updateInfo->version) . ''; $button['icon'] = version_compare(JVERSION, '3.0', 'ge') ? 'iclogo' : JUri::root() . 'media/com_icagenda/images/logo_joomlic.png'; } // Already in the latest release else { $button['text'] = JText::_('PLG_QUICKICON_ICAGENDAUPDATE_UPTODATE'); $button['icon'] = version_compare(JVERSION, '3.0', 'ge') ? 'iclogo' : JUri::root() . 'media/com_icagenda/images/logo_joomlic.png'; } $token = JSession::getFormToken() . '=' . 1; // Joomla 3 only if (version_compare(JVERSION, '3.0', 'ge')) { $script = array(); $script[]= 'jQuery(document).ready(function(){'; $script[]= ' jQuery(".icon-iclogo").addClass("iCicon-iclogo").removeClass("icon-iclogo");'; $script[]= ' jQuery(".iCicon-iclogo").css("margin-right", "9px");'; if ($updateInfo->hasUpdates) { $script[]= ' jQuery("#system-message-container").prepend("' . '
' . JText::sprintf('PLG_QUICKICON_ICAGENDAUPDATE_UPDATEFOUND_MESSAGE', $updateInfo->version) . ' ' . '
");'; } $script[]= '});'; JFactory::getDocument()->addScriptDeclaration(implode("\n", $script)); $link = 'index.php?option=com_installer&view=update&task=update.find&' . $token; } // Joomla 2.5 else { $link = 'index.php?option=com_icagenda&view=liveupdate'; } return array( array( 'link' => $link, 'image' => $button['icon'], 'icon' => 'header/icon-48-download.png', 'text' => $button['text'], 'id' => 'plg_quickicon_icagendaupdate', 'group' => 'MOD_QUICKICON_MAINTENANCE' ) ); } }