Source for file messages.php

Documentation is available at messages.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_postinstall
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. /**
  13.  * Model class to manage postinstall messages
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_postinstall
  17.  * @since       3.2
  18.  */
  19. {
  20.     /**
  21.      * Builds the SELECT query
  22.      *
  23.      * @param   boolean  $overrideLimits  Are we requested to override the set limits?
  24.      *
  25.      * @return  JDatabaseQuery 
  26.      *
  27.      * @since   3.2
  28.      */
  29.     public function buildQuery($overrideLimits false)
  30.     {
  31.         $query parent::buildQuery($overrideLimits);
  32.  
  33.         $db $this->getDbo();
  34.  
  35.         // Add a forced extension filtering to the list
  36.         $eid $this->input->getInt('eid'700);
  37.         $query->where($db->qn('extension_id'' = ' $db->q($eid));
  38.  
  39.         // Force filter only enabled messages
  40.         $published $this->input->getInt('published'1);
  41.         $query->where($db->qn('enabled'' = ' $db->q($published));
  42.  
  43.         return $query;
  44.     }
  45.  
  46.     /**
  47.      * Returns the name of an extension, as registered in the #__extensions table
  48.      *
  49.      * @param   integer  $eid  The extension ID
  50.      *
  51.      * @return  string  The extension name
  52.      *
  53.      * @since   3.2
  54.      */
  55.     public function getExtensionName($eid)
  56.     {
  57.         // Load the extension's information from the database
  58.         $db $this->getDbo();
  59.  
  60.         $query $db->getQuery(true)
  61.             ->select(array('name''element''client_id'))
  62.             ->from($db->qn('#__extensions'))
  63.             ->where($db->qn('extension_id'' = ' $db->q((int) $eid));
  64.  
  65.         $db->setQuery($query01);
  66.  
  67.         $extension $db->loadObject();
  68.  
  69.         if (!is_object($extension))
  70.         {
  71.             return '';
  72.         }
  73.  
  74.         // Load language files
  75.         $basePath JPATH_ADMINISTRATOR;
  76.  
  77.         if ($extension->client_id == 0)
  78.         {
  79.             $basePath JPATH_SITE;
  80.         }
  81.  
  82.         $lang JFactory::getLanguage();
  83.         $lang->load($extension->element$basePath);
  84.  
  85.         // Return the localised name
  86.         return JText::_($extension->name);
  87.     }
  88.  
  89.     /**
  90.      * Resets all messages for an extension
  91.      *
  92.      * @param   integer  $eid  The extension ID whose messages we'll reset
  93.      *
  94.      * @return  mixed  False if we fail, a db cursor otherwise
  95.      *
  96.      * @since   3.2
  97.      */
  98.     public function resetMessages($eid)
  99.     {
  100.         $db $this->getDbo();
  101.  
  102.         $query $db->getQuery(true)
  103.             ->update($db->qn('#__postinstall_messages'))
  104.             ->set($db->qn('enabled'' = ' $db->q(1))
  105.             ->where($db->qn('extension_id'' = ' $db->q($eid));
  106.         $db->setQuery($query);
  107.  
  108.         return $db->execute();
  109.     }
  110.  
  111.     /**
  112.      * List post-processing. This is used to run the programmatic display
  113.      * conditions against each list item and decide if we have to show it or
  114.      * not.
  115.      *
  116.      * Do note that this a core method of the RAD Layer which operates directly
  117.      * on the list it's being fed. A little touch of modern magic.
  118.      *
  119.      * @param   array  $resultArray  A list of items to process
  120.      *
  121.      * @return  void 
  122.      *
  123.      * @since   3.2
  124.      */
  125.     protected function onProcessList(&$resultArray)
  126.     {
  127.         $unset_keys array();
  128.         $language_extensions array();
  129.  
  130.         foreach ($resultArray as $key => $item)
  131.         {
  132.             // Filter out messages based on dynamically loaded programmatic conditions
  133.             if (!empty($item->condition_file&& !empty($item->condition_method))
  134.             {
  135.                 jimport('joomla.filesystem.file');
  136.  
  137.                 $file FOFTemplateUtils::parsePath($item->condition_filetrue);
  138.  
  139.                 if (JFile::exists($file))
  140.                 {
  141.                     require_once $file;
  142.  
  143.                     $result call_user_func($item->condition_method);
  144.  
  145.                     if ($result === false)
  146.                     {
  147.                         $unset_keys[$key;
  148.                     }
  149.                 }
  150.             }
  151.  
  152.             // Load the necessary language files
  153.             if (!empty($item->language_extension))
  154.             {
  155.                 $hash $item->language_client_id '-' $item->language_extension;
  156.  
  157.                 if (!in_array($hash$language_extensions))
  158.                 {
  159.                     $language_extensions[$hash;
  160.                     JFactory::getLanguage()->load($item->language_extension$item->language_client_id == JPATH_SITE JPATH_ADMINISTRATOR);
  161.                 }
  162.             }
  163.         }
  164.  
  165.         if (!empty($unset_keys))
  166.         {
  167.             foreach ($unset_keys as $key)
  168.             {
  169.                 unset($resultArray[$key]);
  170.             }
  171.         }
  172.     }
  173. }

Documentation generated on Tue, 19 Nov 2013 15:08:08 +0100 by phpDocumentor 1.4.3