Example #1
0
 /**
  * Removes redundant files and directories from previous versions that no
  * longer apply to the new version.
  */
 private function removeRedundantFiles($oldPath, $newPath, $exclude = array())
 {
     foreach (JFolder::files($oldPath, '.', true, true, $exclude) as $file) {
         if (JFile::exists($file)) {
             if (!JFile::exists(str_replace($oldPath, $newPath, $file))) {
                 Jfile::delete($file);
             }
         }
     }
     foreach (JFolder::folders($oldPath, '.', true, true, $exclude) as $folder) {
         if (JFolder::exists($folder)) {
             if (!JFolder::exists(str_replace($oldPath, $newPath, $folder))) {
                 JFolder::delete($folder);
             }
         }
     }
 }
Example #2
0
 public function compileLessFile($file, $outputDir = 'css', $cssFile = NULL)
 {
     //import joomla filesystem classes
     jimport('joomla.filesystem.folder');
     //Template less path
     $tmplPath = $this->templatePath . '/less/';
     $inputFile = $tmplPath . $file;
     //if less file is missing eject
     if (!file_exists($inputFile)) {
         echo JText::_('LESS_ERROR_LESS_FILE_MISSING') . "<br/>";
         return;
     }
     //If output dir is set to null set output dir to default css folder
     if ($outputDir == NULL) {
         $outputDir = 'css';
     }
     //define output path
     $outputPath = $this->templatePath . '/' . $outputDir;
     //Create output directory if not exist
     if (!@JFolder::exists($outputPath)) {
         @JFolder::create($outputPath);
     }
     if ($cssFile == NULL) {
         $outputFile = substr($file, 0, strpos($file, '.')) . '.css';
     } else {
         $outputFile = $cssFile;
     }
     $outputFilePath = $outputPath . '/' . $outputFile;
     // load the cache
     $cacheFile = md5($file) . ".cache";
     $cacheFilePath = JPATH_CACHE . '/expose';
     if (!@JFolder::exists($cacheFilePath)) {
         @JFolder::create($cacheFilePath);
     }
     $cacheFilePath = $cacheFilePath . '/' . $cacheFile;
     $runcompile = $this->get('less-enabled', 0);
     //If less is turned OFF and appropriate css file is missing we'll compile the LESS once
     if (!$this->get('less-enabled', 0) and !file_exists($outputFilePath)) {
         //remove the cache file first for re-compiling
         if (@JFile::exists($cacheFilePath)) {
             @Jfile::delete($cacheFilePath);
         }
         $runcompile = TRUE;
     }
     if ($runcompile) {
         //create less instance
         $less = new lessc();
         //compress the output
         if ($this->get('less-compression', 'compressed')) {
             $compress = $this->get('less-compression', 'compressed');
         } else {
             $compress = 'compressed';
         }
         $less->setFormatter($compress);
         if (file_exists($cacheFilePath)) {
             $cache = unserialize(file_get_contents($cacheFilePath));
         } else {
             $cache = $inputFile;
         }
         // create a new cache object, and compile
         try {
             $newCache = $less->cachedCompile($cache);
             if (!is_array($cache) || $newCache["updated"] > $cache["updated"]) {
                 file_put_contents($cacheFilePath, serialize($newCache));
                 file_put_contents($outputFilePath, $newCache['compiled']);
             }
         } catch (Exception $ex) {
             echo "LESS ERROR : " . $ex->getMessage();
         }
     }
     return $outputFile;
 }
Example #3
0
 /**
  *     *
  * @param string $file
  * @throws SPException
  * @return bool
  */
 public static function delete($file)
 {
     $file = self::fixPath($file);
     if (is_dir($file)) {
         if ($file == SOBI_ROOT || dirname($file) == SOBI_ROOT) {
             throw new SPException(SPLang::e('Fatal error. Trying to delete not allowed path "%s"', $file));
         }
         return Jfolder::delete($file);
     } else {
         return Jfile::delete($file);
     }
 }
* @package CQI - Custom Quick Icons 2.1.0
* @author michael (mic) pagler
* @copyright (C) 2006/7/8 mic [ http://ww.joomx.com ]
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
// load the component language file
$language =& JFactory::getLanguage();
$language->load('com_customquickicons');
$database =& JFactory::getDBO();
$dir = JPATH_ADMINISTRATOR . DS . 'modules' . DS;
$msg = '';
// delete module files
JFile::delete($dir . 'mod_customquickicons' . DS . 'mod_customquickicons.php');
Jfile::delete($dir . 'mod_customquickicons' . DS . 'mod_customquickicons.xml');
JFolder::delete($dir . 'mod_customquickicons');
// delete db.entry
$query = 'DELETE FROM #__modules' . ' WHERE module = \'mod_customquickicons\'';
$database->setQuery($query);
$database->query();
// set original module active (if not deleted)
$query = 'SELECT id' . ' FROM #__modules' . ' WHERE module = \'mod_quickicon\'';
$database->setQuery($query);
$id = $database->loadResult();
if ($id) {
    $query = 'UPDATE #__modules' . ' SET published = \'1\'' . ' WHERE id = ' . $id . ' LIMIT 1';
    $database->setQuery($query);
    if ($database->query()) {
        $msg .= JTEXT::_('Original module activated');
    }