Exemplo n.º 1
0
 public function purge()
 {
     // Create compile task object.
     $task = new FD50_Stylesheet_Task("Purging stylesheet cache & log files.");
     $cacheFolder = $this->folder('cache');
     if (JFolder::exists($cacheFolder)) {
         if (JFolder::delete($cacheFolder)) {
             $task->report("Deleted cache folder '{$cacheFolder}'.");
         } else {
             $task->report("Unable to delete cache folder '{$cacheFolder}'.");
         }
     }
     $logFolder = $this->folder('log');
     if (JFolder::exists($logFolder)) {
         if (JFolder::delete($logFolder)) {
             $task->report("Deleted log folder '{$logFolder}'.");
         } else {
             $task->report("Unable to delete log folder '{$logFolder}'.");
         }
     }
     return $task->resolve();
 }
Exemplo n.º 2
0
 public function writeTarget($group, $type, $mode)
 {
     $task = new FD50_Stylesheet_Task("Writing {$type} target for '{$group}'.");
     $file = $this->stylesheet->file($group, $type);
     $content = '';
     // Get manifest
     $manifest = $this->stylesheet->manifest();
     // Stop if group does not exist in stylesheet manifest.
     if (!isset($manifest[$group])) {
         return $task->reject("Group '{$group}' does not exist in stylesheet manifest.");
     }
     // Get sections
     $sections = $manifest[$group];
     // Stop if there are no sections.
     if (count($sections) < 1) {
         return $task->reject("No available sections to write target.");
     }
     switch ($mode) {
         case 'index':
             $subtask = $this->generateIndex($sections, $type);
             $task->subtasks[] = $subtask;
             if ($subtask->failed) {
                 return $task->reject();
             }
             $content = $subtask->result;
             break;
         case 'join':
             $subtask = $this->joinFiles($sections, $type);
             $task->subtasks[] = $subtask;
             if ($subtask->failed) {
                 return $task->reject();
             }
             $content = $subtask->result;
             break;
         case 'skip':
         default:
             $task->report('Nothing to do.', 'info');
             return $task;
     }
     if (!JFile::write($file, $content)) {
         return $task->reject("Unable to write to file '{$file}'");
     }
     return $task->resolve();
 }