Beispiel #1
0
 /**
  * Entry point for the script
  *
  * @return  void
  *
  * @since   3.0
  */
 public function doExecute()
 {
     $templates = array(JPATH_ADMINISTRATOR . '/templates/isis/less/template.less' => JPATH_ADMINISTRATOR . '/templates/isis/css/template.css', JPATH_ADMINISTRATOR . '/templates/isis/less/template-rtl.less' => JPATH_ADMINISTRATOR . '/templates/isis/css/template-rtl.css', JPATH_ADMINISTRATOR . '/templates/hathor/less/template.less' => JPATH_ADMINISTRATOR . '/templates/hathor/css/template.css', JPATH_ADMINISTRATOR . '/templates/hathor/less/colour_blue.less' => JPATH_ADMINISTRATOR . '/templates/hathor/css/colour_blue.css', JPATH_ADMINISTRATOR . '/templates/hathor/less/colour_brown.less' => JPATH_ADMINISTRATOR . '/templates/hathor/css/colour_brown.css', JPATH_ADMINISTRATOR . '/templates/hathor/less/colour_standard.less' => JPATH_ADMINISTRATOR . '/templates/hathor/css/colour_standard.css', JPATH_SITE . '/templates/protostar/less/template.less' => JPATH_SITE . '/templates/protostar/css/template.css', __DIR__ . '/less/bootstrap-extended.less' => JPATH_SITE . '/media/jui/css/bootstrap-extended.css', __DIR__ . '/less/bootstrap-rtl.less' => JPATH_SITE . '/media/jui/css/bootstrap-rtl.css');
     // Load the RAD layer
     if (!defined('FOF_INCLUDED')) {
         require_once JPATH_LIBRARIES . '/fof/include.php';
     }
     $less = new FOFLess();
     $less->setFormatter(new FOFLessFormatterJoomla());
     foreach ($templates as $source => $output) {
         try {
             $less->compileFile($source, $output);
         } catch (Exception $e) {
             echo $e->getMessage();
         }
     }
 }
Beispiel #2
0
 /**
  * Compile less using the less compiler under /build.
  *
  * @param   string  $input  The relative location of the less file.
  *
  * @return  boolean  true if compilation is successful, false otherwise
  *
  * @since   3.2
  */
 public function compileLess($input)
 {
     if ($template = $this->getTemplate()) {
         $app = JFactory::getApplication();
         $client = JApplicationHelper::getClientInfo($template->client_id);
         $path = JPath::clean($client->path . '/templates/' . $template->element . '/');
         $inFile = urldecode(base64_decode($input));
         $explodeArray = explode('/', $inFile);
         $fileName = end($explodeArray);
         $outFile = reset(explode('.', $fileName));
         // Load the RAD layer to use its LESS compiler
         if (!defined('FOF_INCLUDED')) {
             require_once JPATH_LIBRARIES . '/fof/include.php';
         }
         $less = new FOFLess();
         $less->setFormatter(new FOFLessFormatterJoomla());
         try {
             $less->compileFile($path . $inFile, $path . 'css/' . $outFile . '.css');
             return true;
         } catch (Exception $e) {
             $app->enqueueMessage($e->getMessage(), 'error');
         }
     }
 }