Source for file file.php

Documentation is available at file.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Libraries
  4.  * @subpackage  Installer
  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
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die;
  11.  
  12. jimport('joomla.base.adapterinstance');
  13. jimport('joomla.filesystem.folder');
  14.  
  15. /**
  16.  * File installer
  17.  *
  18.  * @package     Joomla.Libraries
  19.  * @subpackage  Installer
  20.  * @since       3.1
  21.  */
  22. {
  23.     /**
  24.      * Install function routing
  25.      *
  26.      * @var    string 
  27.      * @since  3.1
  28.      */
  29.     protected $route = 'install';
  30.  
  31.     /**
  32.      * <scriptfile> element of the extension manifest
  33.      *
  34.      * @var    object 
  35.      * @since  3.1
  36.      */
  37.     protected $scriptElement = null;
  38.  
  39.     /**
  40.      * Custom loadLanguage method
  41.      *
  42.      * @param   string  $path  The path on which to find language files.
  43.      *
  44.      * @return  void 
  45.      *
  46.      * @since   3.1
  47.      */
  48.     public function loadLanguage($path)
  49.     {
  50.         $this->manifest $this->parent->getManifest();
  51.         $extension 'files_' str_replace('files_'''strtolower(JFilterInput::getInstance()->clean((string) $this->manifest->name'cmd')));
  52.         $lang JFactory::getLanguage();
  53.         $source $path;
  54.         $lang->load($extension '.sys'$sourcenullfalsetrue)
  55.             || $lang->load($extension '.sys'JPATH_SITEnullfalsetrue);
  56.     }
  57.  
  58.     /**
  59.      * Custom install method
  60.      *
  61.      * @return  boolean  True on success
  62.      *
  63.      * @since   3.1
  64.      */
  65.     public function install()
  66.     {
  67.         // Get the extension manifest object
  68.         $this->manifest $this->parent->getManifest();
  69.  
  70.         /*
  71.          * ---------------------------------------------------------------------------------------------
  72.          * Manifest Document Setup Section
  73.          * ---------------------------------------------------------------------------------------------
  74.          */
  75.  
  76.         // Set the extension's name
  77.         $name JFilterInput::getInstance()->clean((string) $this->manifest->name'string');
  78.         $this->set('name'$name);
  79.  
  80.         // Set element
  81.         $manifestPath JPath::clean($this->parent->getPath('manifest'));
  82.         $element preg_replace('/\.xml/'''basename($manifestPath));
  83.         $this->set('element'$element);
  84.  
  85.         // Get the component description
  86.         $description = (string) $this->manifest->description;
  87.  
  88.         if ($description)
  89.         {
  90.             $this->parent->set('message'JText::_($description));
  91.         }
  92.         else
  93.         {
  94.             $this->parent->set('message''');
  95.         }
  96.  
  97.         // Check if the extension by the same name is already installed
  98.         if ($this->extensionExistsInSystem($element))
  99.         {
  100.             // Package with same name already exists
  101.             if (!$this->parent->isOverwrite())
  102.             {
  103.                 // We're not overwriting so abort
  104.                 $this->parent->abort(JText::_('JLIB_INSTALLER_ABORT_FILE_SAME_NAME'));
  105.  
  106.                 return false;
  107.             }
  108.             else
  109.             {
  110.                 // Swap to the update route
  111.                 $this->route = 'update';
  112.             }
  113.         }
  114.         // Set the file root path
  115.         if ($name == 'files_joomla')
  116.         {
  117.             // If we are updating the Joomla core, set the root path to the root of Joomla
  118.             $this->parent->setPath('extension_root'JPATH_ROOT);
  119.         }
  120.         else
  121.         {
  122.             $this->parent->setPath('extension_root'JPATH_MANIFESTS '/files/' $this->get('element'));
  123.         }
  124.  
  125.         /**
  126.          * ---------------------------------------------------------------------------------------------
  127.          * Installer Trigger Loading
  128.          * ---------------------------------------------------------------------------------------------
  129.          */
  130.  
  131.         // If there is an manifest class file, lets load it; we'll copy it later (don't have dest yet)
  132.         $this->scriptElement = $this->manifest->scriptfile;
  133.         $manifestScript = (string) $this->manifest->scriptfile;
  134.  
  135.         if ($manifestScript)
  136.         {
  137.             $manifestScriptFile $this->parent->getPath('source''/' $manifestScript;
  138.  
  139.             if (is_file($manifestScriptFile))
  140.             {
  141.                 // Load the file
  142.                 include_once $manifestScriptFile;
  143.             }
  144.  
  145.             // Set the class name
  146.             $classname $element 'InstallerScript';
  147.  
  148.             if (class_exists($classname))
  149.             {
  150.                 // Create a new instance
  151.                 $this->parent->manifestClass new $classname($this);
  152.  
  153.                 // And set this so we can copy it later
  154.                 $this->set('manifest_script'$manifestScript);
  155.             }
  156.         }
  157.  
  158.         // Run preflight if possible (since we know we're not an update)
  159.         ob_start();
  160.         ob_implicit_flush(false);
  161.  
  162.         if ($this->parent->manifestClass && method_exists($this->parent->manifestClass'preflight'))
  163.         {
  164.             if ($this->parent->manifestClass->preflight($this->route$this=== false)
  165.             {
  166.                 // Install failed, rollback changes
  167.                 $this->parent->abort(JText::_('JLIB_INSTALLER_ABORT_FILE_INSTALL_CUSTOM_INSTALL_FAILURE'));
  168.  
  169.                 return false;
  170.             }
  171.         }
  172.  
  173.         // Create msg object; first use here
  174.         $msg ob_get_contents();
  175.         ob_end_clean();
  176.  
  177.         // Populate File and Folder List to copy
  178.         $this->populateFilesAndFolderList();
  179.  
  180.         /*
  181.          * ---------------------------------------------------------------------------------------------
  182.          * Filesystem Processing Section
  183.          * ---------------------------------------------------------------------------------------------
  184.          */
  185.  
  186.         // Now that we have folder list, lets start creating them
  187.         foreach ($this->folderList as $folder)
  188.         {
  189.             if (!JFolder::exists($folder))
  190.             {
  191.  
  192.                 if (!$created JFolder::create($folder))
  193.                 {
  194.                     JLog::add(JText::sprintf('JLIB_INSTALLER_ABORT_FILE_INSTALL_FAIL_SOURCE_DIRECTORY'$folder)JLog::WARNING'jerror');
  195.  
  196.                     // If installation fails, rollback
  197.                     $this->parent->abort();
  198.  
  199.                     return false;
  200.                 }
  201.  
  202.                 // Since we created a directory and will want to remove it if we have to roll back.
  203.                 // The installation due to some errors, let's add it to the installation step stack.
  204.  
  205.                 if ($created)
  206.                 {
  207.                     $this->parent->pushStep(array('type' => 'folder''path' => $folder));
  208.                 }
  209.             }
  210.  
  211.         }
  212.  
  213.         // Now that we have file list, let's start copying them
  214.         $this->parent->copyFiles($this->fileList);
  215.  
  216.         // Parse optional tags
  217.         $this->parent->parseLanguages($this->manifest->languages);
  218.  
  219.         /**
  220.          * ---------------------------------------------------------------------------------------------
  221.          * Finalization and Cleanup Section
  222.          * ---------------------------------------------------------------------------------------------
  223.          */
  224.  
  225.         // Get a database connector object
  226.         $db $this->parent->getDbo();
  227.  
  228.         /*
  229.          * Check to see if a file extension by the same name is already installed
  230.          * If it is, then update the table because if the files aren't there
  231.          * we can assume that it was (badly) uninstalled
  232.          * If it isn't, add an entry to extensions
  233.          */
  234.         $query $db->getQuery(true)
  235.             ->select($db->quoteName('extension_id'))
  236.             ->from($db->quoteName('#__extensions'))
  237.             ->where($db->quoteName('type'' = ' $db->quote('file'))
  238.             ->where($db->quoteName('element'' = ' $db->quote($element));
  239.         $db->setQuery($query);
  240.  
  241.         try
  242.         {
  243.             $db->execute();
  244.         }
  245.         catch (RuntimeException $e)
  246.         {
  247.             // Install failed, roll back changes
  248.             $this->parent->abort(
  249.                 JText::sprintf('JLIB_INSTALLER_ABORT_FILE_ROLLBACK'JText::_('JLIB_INSTALLER_' $this->route)$db->stderr(true))
  250.             );
  251.  
  252.             return false;
  253.         }
  254.         $id $db->loadResult();
  255.         $row JTable::getInstance('extension');
  256.  
  257.         if ($id)
  258.         {
  259.             // Load the entry and update the manifest_cache
  260.             $row->load($id);
  261.  
  262.             // Update name
  263.             $row->set('name'$this->get('name'));
  264.  
  265.             // Update manifest
  266.             $row->manifest_cache $this->parent->generateManifestCache();
  267.  
  268.             if (!$row->store())
  269.             {
  270.                 // Install failed, roll back changes
  271.                 $this->parent->abort(
  272.                     JText::sprintf('JLIB_INSTALLER_ABORT_FILE_ROLLBACK'JText::_('JLIB_INSTALLER_' $this->route)$db->stderr(true))
  273.                 );
  274.  
  275.                 return false;
  276.             }
  277.         }
  278.         else
  279.         {
  280.             // Add an entry to the extension table with a whole heap of defaults
  281.             $row->set('name'$this->get('name'));
  282.             $row->set('type''file');
  283.             $row->set('element'$this->get('element'));
  284.  
  285.             // There is no folder for files so leave it blank
  286.             $row->set('folder''');
  287.             $row->set('enabled'1);
  288.             $row->set('protected'0);
  289.             $row->set('access'0);
  290.             $row->set('client_id'0);
  291.             $row->set('params''');
  292.             $row->set('system_data''');
  293.             $row->set('manifest_cache'$this->parent->generateManifestCache());
  294.  
  295.             if (!$row->store())
  296.             {
  297.                 // Install failed, roll back changes
  298.                 $this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT_FILE_INSTALL_ROLLBACK'$db->stderr(true)));
  299.  
  300.                 return false;
  301.             }
  302.  
  303.             // Since we have created a module item, we add it to the installation step stack
  304.             // so that if we have to rollback the changes we can undo it.
  305.             $this->parent->pushStep(array('type' => 'extension''extension_id' => $row->extension_id));
  306.         }
  307.  
  308.         // Let's run the queries for the file
  309.         if (strtolower($this->route== 'install')
  310.         {
  311.             $result $this->parent->parseSQLFiles($this->manifest->install->sql);
  312.  
  313.             if ($result === false)
  314.             {
  315.                 // Install failed, rollback changes
  316.                 $this->parent->abort(
  317.                     JText::sprintf('JLIB_INSTALLER_ABORT_FILE_INSTALL_SQL_ERROR'JText::_('JLIB_INSTALLER_' $this->route)$db->stderr(true))
  318.                 );
  319.  
  320.                 return false;
  321.             }
  322.  
  323.             // Set the schema version to be the latest update version
  324.             if ($this->manifest->update)
  325.             {
  326.                 $this->parent->setSchemaVersion($this->manifest->update->schemas$row->extension_id);
  327.             }
  328.         }
  329.         elseif (strtolower($this->route== 'update')
  330.         {
  331.             if ($this->manifest->update)
  332.             {
  333.                 $result $this->parent->parseSchemaUpdates($this->manifest->update->schemas$row->extension_id);
  334.  
  335.                 if ($result === false)
  336.                 {
  337.                     // Install failed, rollback changes
  338.                     $this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT_FILE_UPDATE_SQL_ERROR'$db->stderr(true)));
  339.  
  340.                     return false;
  341.                 }
  342.             }
  343.         }
  344.  
  345.         // Try to run the script file's custom method based on the route
  346.         ob_start();
  347.         ob_implicit_flush(false);
  348.  
  349.         if ($this->parent->manifestClass && method_exists($this->parent->manifestClass$this->route))
  350.         {
  351.             if ($this->parent->manifestClass->{$this->route}($this=== false)
  352.             {
  353.                 // Install failed, rollback changes
  354.                 $this->parent->abort(JText::_('JLIB_INSTALLER_ABORT_FILE_INSTALL_CUSTOM_INSTALL_FAILURE'));
  355.  
  356.                 return false;
  357.             }
  358.         }
  359.  
  360.         // Append messages
  361.         $msg .= ob_get_contents();
  362.         ob_end_clean();
  363.  
  364.         // Lastly, we will copy the manifest file to its appropriate place.
  365.         $manifest array();
  366.         $manifest['src'$this->parent->getPath('manifest');
  367.         $manifest['dest'JPATH_MANIFESTS '/files/' basename($this->parent->getPath('manifest'));
  368.  
  369.         if (!$this->parent->copyFiles(array($manifest)true))
  370.         {
  371.             // Install failed, rollback changes
  372.             $this->parent->abort(JText::_('JLIB_INSTALLER_ABORT_FILE_INSTALL_COPY_SETUP'));
  373.  
  374.             return false;
  375.         }
  376.  
  377.         // If there is a manifest script, let's copy it.
  378.         if ($this->get('manifest_script'))
  379.         {
  380.             // First, we have to create a folder for the script if one isn't present
  381.             if (!file_exists($this->parent->getPath('extension_root')))
  382.             {
  383.                 JFolder::create($this->parent->getPath('extension_root'));
  384.             }
  385.  
  386.             $path['src'$this->parent->getPath('source''/' $this->get('manifest_script');
  387.             $path['dest'$this->parent->getPath('extension_root''/' $this->get('manifest_script');
  388.  
  389.             if (!file_exists($path['dest']|| $this->parent->isOverwrite())
  390.             {
  391.                 if (!$this->parent->copyFiles(array($path)))
  392.                 {
  393.                     // Install failed, rollback changes
  394.                     $this->parent->abort(JText::_('JLIB_INSTALLER_ABORT_PACKAGE_INSTALL_MANIFEST'));
  395.  
  396.                     return false;
  397.                 }
  398.             }
  399.         }
  400.         // Clobber any possible pending updates
  401.         $update JTable::getInstance('update');
  402.         $uid $update->find(
  403.             array('element' => $this->get('element')'type' => 'file''client_id' => (int) '''folder' => '')
  404.         );
  405.  
  406.         if ($uid)
  407.         {
  408.             $update->delete($uid);
  409.         }
  410.  
  411.         // And now we run the postflight
  412.         ob_start();
  413.         ob_implicit_flush(false);
  414.  
  415.         if ($this->parent->manifestClass && method_exists($this->parent->manifestClass'postflight'))
  416.         {
  417.             $this->parent->manifestClass->postflight($this->route$this);
  418.         }
  419.  
  420.         // Append messages
  421.         $msg .= ob_get_contents();
  422.         ob_end_clean();
  423.  
  424.         if ($msg != '')
  425.         {
  426.             $this->parent->set('extension_message'$msg);
  427.         }
  428.  
  429.         return $row->get('extension_id');
  430.     }
  431.  
  432.     /**
  433.      * Custom update method
  434.      *
  435.      * @return  boolean  True on success
  436.      *
  437.      * @since   3.1
  438.      */
  439.     public function update()
  440.     {
  441.         // Set the overwrite setting
  442.         $this->parent->setOverwrite(true);
  443.         $this->parent->setUpgrade(true);
  444.         $this->route = 'update';
  445.  
  446.         // ...and adds new files
  447.         return $this->install();
  448.     }
  449.  
  450.     /**
  451.      * Custom uninstall method
  452.      *
  453.      * @param   string  $id  The id of the file to uninstall
  454.      *
  455.      * @return  boolean  True on success
  456.      *
  457.      * @since   3.1
  458.      */
  459.     public function uninstall($id)
  460.     {
  461.         $row JTable::getInstance('extension');
  462.  
  463.         if (!$row->load($id))
  464.         {
  465.             JLog::add(JText::_('JLIB_INSTALLER_ERROR_FILE_UNINSTALL_LOAD_ENTRY')JLog::WARNING'jerror');
  466.  
  467.             return false;
  468.         }
  469.  
  470.         if ($row->protected)
  471.         {
  472.             JLog::add(JText::_('JLIB_INSTALLER_ERROR_FILE_UNINSTALL_WARNCOREFILE')JLog::WARNING'jerror');
  473.  
  474.             return false;
  475.         }
  476.  
  477.         $retval true;
  478.         $manifestFile JPATH_MANIFESTS '/files/' $row->element '.xml';
  479.  
  480.         // Because files may not have their own folders we cannot use the standard method of finding an installation manifest
  481.         if (file_exists($manifestFile))
  482.         {
  483.             // Set the files root path
  484.             $this->parent->setPath('extension_root'JPATH_MANIFESTS '/files/' $row->element);
  485.  
  486.             $xml simplexml_load_file($manifestFile);
  487.  
  488.             // If we cannot load the XML file return null
  489.             if (!$xml)
  490.             {
  491.                 JLog::add(JText::_('JLIB_INSTALLER_ERROR_FILE_UNINSTALL_LOAD_MANIFEST')JLog::WARNING'jerror');
  492.  
  493.                 return false;
  494.             }
  495.  
  496.             // Check for a valid XML root tag.
  497.             if ($xml->getName(!= 'extension')
  498.             {
  499.                 JLog::add(JText::_('JLIB_INSTALLER_ERROR_FILE_UNINSTALL_INVALID_MANIFEST')JLog::WARNING'jerror');
  500.  
  501.                 return false;
  502.             }
  503.  
  504.             $this->manifest $xml;
  505.  
  506.             // If there is an manifest class file, let's load it
  507.             $this->scriptElement = $this->manifest->scriptfile;
  508.             $manifestScript = (string) $this->manifest->scriptfile;
  509.  
  510.             if ($manifestScript)
  511.             {
  512.                 $manifestScriptFile $this->parent->getPath('extension_root''/' $manifestScript;
  513.  
  514.                 if (is_file($manifestScriptFile))
  515.                 {
  516.                     // Load the file
  517.                     include_once $manifestScriptFile;
  518.                 }
  519.  
  520.                 // Set the class name
  521.                 $classname $row->element 'InstallerScript';
  522.  
  523.                 if (class_exists($classname))
  524.                 {
  525.                     // Create a new instance
  526.                     $this->parent->manifestClass new $classname($this);
  527.  
  528.                     // And set this so we can copy it later
  529.                     $this->set('manifest_script'$manifestScript);
  530.                 }
  531.             }
  532.  
  533.             ob_start();
  534.             ob_implicit_flush(false);
  535.  
  536.             // Run uninstall if possible
  537.             if ($this->parent->manifestClass && method_exists($this->parent->manifestClass'uninstall'))
  538.             {
  539.                 $this->parent->manifestClass->uninstall($this);
  540.             }
  541.  
  542.             $msg ob_get_contents();
  543.             ob_end_clean();
  544.  
  545.             if ($msg != '')
  546.             {
  547.                 $this->parent->set('extension_message'$msg);
  548.             }
  549.  
  550.             $db JFactory::getDbo();
  551.  
  552.             // Let's run the uninstall queries for the extension
  553.             $result $this->parent->parseSQLFiles($this->manifest->uninstall->sql);
  554.  
  555.             if ($result === false)
  556.             {
  557.                 // Install failed, rollback changes
  558.                 JLog::add(JText::sprintf('JLIB_INSTALLER_ERROR_FILE_UNINSTALL_SQL_ERROR'$db->stderr(true))JLog::WARNING'jerror');
  559.                 $retval false;
  560.             }
  561.  
  562.             // Remove the schema version
  563.             $query $db->getQuery(true)
  564.                 ->delete('#__schemas')
  565.                 ->where('extension_id = ' $row->extension_id);
  566.             $db->setQuery($query);
  567.             $db->execute();
  568.  
  569.             // Loop through all elements and get list of files and folders
  570.             foreach ($xml->fileset->files as $eFiles)
  571.             {
  572.                 $target = (string) $eFiles->attributes()->target;
  573.  
  574.                 // Create folder path
  575.                 if (empty($target))
  576.                 {
  577.                     $targetFolder JPATH_ROOT;
  578.                 }
  579.                 else
  580.                 {
  581.                     $targetFolder JPATH_ROOT '/' $target;
  582.                 }
  583.  
  584.                 $folderList array();
  585.  
  586.                 // Check if all children exists
  587.                 if (count($eFiles->children()) 0)
  588.                 {
  589.                     // Loop through all filenames elements
  590.                     foreach ($eFiles->children(as $eFileName)
  591.                     {
  592.                         if ($eFileName->getName(== 'folder')
  593.                         {
  594.                             $folderList[$targetFolder '/' $eFileName;
  595.  
  596.                         }
  597.                         else
  598.                         {
  599.                             $fileName $targetFolder '/' $eFileName;
  600.                             JFile::delete($fileName);
  601.                         }
  602.                     }
  603.                 }
  604.  
  605.                 // Delete any folders that don't have any content in them.
  606.                 foreach ($folderList as $folder)
  607.                 {
  608.                     $files JFolder::files($folder);
  609.  
  610.                     if (!count($files))
  611.                     {
  612.                         JFolder::delete($folder);
  613.                     }
  614.                 }
  615.             }
  616.  
  617.             JFile::delete($manifestFile);
  618.  
  619.             // Lastly, remove the extension_root
  620.             $folder $this->parent->getPath('extension_root');
  621.  
  622.             if (JFolder::exists($folder))
  623.             {
  624.                 JFolder::delete($folder);
  625.             }
  626.         }
  627.         else
  628.         {
  629.             JLog::add(JText::_('JLIB_INSTALLER_ERROR_FILE_UNINSTALL_INVALID_NOTFOUND_MANIFEST')JLog::WARNING'jerror');
  630.  
  631.             // Delete the row because its broken
  632.             $row->delete();
  633.  
  634.             return false;
  635.         }
  636.  
  637.         $this->parent->removeFiles($xml->languages);
  638.  
  639.         $row->delete();
  640.  
  641.         return $retval;
  642.     }
  643.  
  644.     /**
  645.      * Function used to check if extension is already installed
  646.      *
  647.      * @param   string  $extension  The element name of the extension to install
  648.      *
  649.      * @return  boolean  True if extension exists
  650.      *
  651.      * @since   3.1
  652.      */
  653.     protected function extensionExistsInSystem($extension null)
  654.     {
  655.         // Get a database connector object
  656.         $db $this->parent->getDBO();
  657.  
  658.         $query $db->getQuery(true)
  659.             ->select($db->quoteName('extension_id'))
  660.             ->from($db->quoteName('#__extensions'))
  661.             ->where($db->quoteName('type'' = ' $db->quote('file'))
  662.             ->where($db->quoteName('element'' = ' $db->quote($extension));
  663.         $db->setQuery($query);
  664.  
  665.         try
  666.         {
  667.             $db->execute();
  668.         }
  669.         catch (RuntimeException $e)
  670.         {
  671.             // Install failed, roll back changes
  672.             $this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT_FILE_ROLLBACK'$db->stderr(true)));
  673.  
  674.             return false;
  675.         }
  676.         $id $db->loadResult();
  677.  
  678.         if (empty($id))
  679.         {
  680.             return false;
  681.         }
  682.  
  683.         return true;
  684.  
  685.     }
  686.  
  687.     /**
  688.      * Function used to populate files and folder list
  689.      *
  690.      * @return  boolean  none
  691.      *
  692.      * @since   3.1
  693.      */
  694.     protected function populateFilesAndFolderList()
  695.     {
  696.         // Initialise variable
  697.         $this->folderList array();
  698.         $this->fileList array();
  699.  
  700.         // Set root folder names
  701.         $packagePath $this->parent->getPath('source');
  702.         $jRootPath JPath::clean(JPATH_ROOT);
  703.  
  704.         // Loop through all elements and get list of files and folders
  705.         foreach ($this->manifest->fileset->files as $eFiles)
  706.         {
  707.             // Check if the element is files element
  708.             $folder = (string) $eFiles->attributes()->folder;
  709.             $target = (string) $eFiles->attributes()->target;
  710.  
  711.             // Split folder names into array to get folder names. This will help in creating folders
  712.             $arrList preg_split("#/|\\/#"$target);
  713.  
  714.             $folderName $jRootPath;
  715.  
  716.             foreach ($arrList as $dir)
  717.             {
  718.                 if (empty($dir))
  719.                 {
  720.                     continue;
  721.                 }
  722.  
  723.                 $folderName .= '/' $dir;
  724.  
  725.                 // Check if folder exists, if not then add to the array for folder creation
  726.                 if (!JFolder::exists($folderName))
  727.                 {
  728.                     array_push($this->folderList$folderName);
  729.                 }
  730.             }
  731.  
  732.             // Create folder path
  733.             $sourceFolder empty($folder$packagePath $packagePath '/' $folder;
  734.             $targetFolder empty($target$jRootPath $jRootPath '/' $target;
  735.  
  736.             // Check if source folder exists
  737.             if (!JFolder::exists($sourceFolder))
  738.             {
  739.                 JLog::add(JText::sprintf('JLIB_INSTALLER_ABORT_FILE_INSTALL_FAIL_SOURCE_DIRECTORY'$sourceFolder)JLog::WARNING'jerror');
  740.  
  741.                 // If installation fails, rollback
  742.                 $this->parent->abort();
  743.  
  744.                 return false;
  745.             }
  746.  
  747.             // Check if all children exists
  748.             if (count($eFiles->children()))
  749.             {
  750.                 // Loop through all filenames elements
  751.                 foreach ($eFiles->children(as $eFileName)
  752.                 {
  753.                     $path['src'$sourceFolder '/' $eFileName;
  754.                     $path['dest'$targetFolder '/' $eFileName;
  755.                     $path['type''file';
  756.  
  757.                     if ($eFileName->getName(== 'folder')
  758.                     {
  759.                         $folderName $targetFolder '/' $eFileName;
  760.                         array_push($this->folderList$folderName);
  761.                         $path['type''folder';
  762.                     }
  763.  
  764.                     array_push($this->fileList$path);
  765.                 }
  766.             }
  767.             else
  768.             {
  769.                 $files JFolder::files($sourceFolder);
  770.  
  771.                 foreach ($files as $file)
  772.                 {
  773.                     $path['src'$sourceFolder '/' $file;
  774.                     $path['dest'$targetFolder '/' $file;
  775.  
  776.                     array_push($this->fileList$path);
  777.                 }
  778.  
  779.             }
  780.         }
  781.     }
  782.  
  783.     /**
  784.      * Refreshes the extension table cache
  785.      *
  786.      * @return  boolean result of operation, true if updated, false on failure
  787.      *
  788.      * @since   3.1
  789.      */
  790.     public function refreshManifestCache()
  791.     {
  792.         // Need to find to find where the XML file is since we don't store this normally
  793.         $manifestPath JPATH_MANIFESTS '/files/' $this->parent->extension->element '.xml';
  794.         $this->parent->manifest $this->parent->isManifest($manifestPath);
  795.         $this->parent->setPath('manifest'$manifestPath);
  796.  
  797.         $manifest_details JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
  798.         $this->parent->extension->manifest_cache json_encode($manifest_details);
  799.         $this->parent->extension->name $manifest_details['name'];
  800.  
  801.         try
  802.         {
  803.             return $this->parent->extension->store();
  804.         }
  805.         catch (RuntimeException $e)
  806.         {
  807.             JLog::add(JText::_('JLIB_INSTALLER_ERROR_PACK_REFRESH_MANIFEST_CACHE')JLog::WARNING'jerror');
  808.  
  809.             return false;
  810.         }
  811.     }
  812. }
  813.  
  814. /**
  815.  * Deprecated class placeholder. You should use JInstallerAdapterFile instead.
  816.  *
  817.  * @package     Joomla.Libraries
  818.  * @subpackage  Installer
  819.  * @since       3.1
  820.  * @deprecated  4.0
  821.  * @codeCoverageIgnore
  822.  */
  823. {
  824. }

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