Exemplo n.º 1
0
 public function read($len = null)
 {
     $p = new Project();
     $toFile = Register::getSlot("task.copy.currentFromFile")->getValue();
     if ($toFile) {
         if (file_exists($toFile)) {
             actionQueueTask::getInstance()->registerFile($toFile);
         }
     }
     return parent::read();
 }
 /**
  * (non-PHPdoc)
  * @see lib/phing/classes/phing/Task#main()
  */
 public function main()
 {
     if (!file_exists($this->file)) {
         return false;
     }
     $snippets = unserialize(file_get_contents($this->file));
     if (!$snippets) {
         echo "Invalid snippet file";
         return null;
     }
     foreach ($snippets as $snippet) {
         $file = str_replace("%PATH_Icinga%", $this->project->getUserProperty("PATH_Icinga"), $snippet["file"]);
         $mark;
         $name = $snippet["mark"];
         $ext = preg_replace("/.*\\.(\\w{1,5})\$/", "\$1", $file);
         // check the comment type
         switch ($ext) {
             case 'txt':
             case 'ini':
             case 'pl':
                 $mark = "#MODULE[" . $name . "]";
                 break;
             case 'xml':
             case 'html:':
                 $mark = "<!-- MODULE[" . $name . "] -->";
                 break;
             case 'css':
             case 'php':
             case 'js':
                 $mark = "/*MODULE[" . $name . "]*/";
                 break;
             default:
                 throw new BuildException("Unknown filetype " . $ext);
         }
         $snippetFileContent = file_get_contents($file);
         // remove previous snippets
         $snippetFileContent = preg_replace("/.*MODULE\\[" . $name . "\\].*[\r\n]+([\\w\\W\r\n]+)[\r\n]+.*?MODULE\\[" . $name . "\\].*?[\r\n]+/", "", $snippetFileContent);
         // append this snippet
         $snippetText = "\n" . $mark . "\n" . $snippet["content"] . "\n" . $mark . "\n";
         // save original file
         $actionQueue = actionQueueTask::getInstance();
         $actionQueue->registerFile($file);
         file_put_contents($file, $snippetFileContent . $snippetText);
     }
 }
 public function main()
 {
     // open folder
     $icingaPath = $this->getProject()->getUserProperty("PATH_Icinga");
     $recovery = actionQueueTask::getInstance();
     $files = scandir($this->getFolder());
     foreach ($files as $file) {
         if (substr($file, -4, 4) != '.xml') {
             continue;
         }
         $path = str_replace("_", "/", str_replace("%PATH_Icinga%", $icingaPath . "/", $file));
         $recovery->registerFile($path);
         echo "\nMerging " . $path;
         $xmlMerger = new xmlMergerTask();
         $xmlMerger->setSource($this->getFolder() . "/" . $file);
         $xmlMerger->setTarget($path);
         $xmlMerger->setOverwrite(false);
         $xmlMerger->setProject($this->getProject());
         $xmlMerger->setLocation($this->getLocation());
         $xmlMerger->perform();
     }
 }
Exemplo n.º 4
0
 public function getActionQueue()
 {
     return actionQueueTask::getInstance();
 }
Exemplo n.º 5
0
 /**
  * Creates a new instance and restores the state if the restore flag is set
  */
 public function main()
 {
     self::$instance = $this;
     if ($this->isRestore()) {
         $this->restoreState();
     }
 }