protected function OnSuccess()
 {
     File::CreateWithText($this->file, $this->Value('Contents', false));
     $logger = new Logger(self::Guard()->GetUser());
     $logger->ReportLayoutAction($this->layout, Action::Update());
     Response::Redirect($this->BackLink());
 }
Example #2
0
 /**
  * 
  * @param type $progress
  * @param type $progressCount
  */
 function Report($progress, $progressCount)
 {
     $this->data['progress'] = $progress;
     $this->data['progressCount'] = $progressCount;
     if ($this->descriptionLabel) {
         $this->data['progressDescription'] = Worder::ReplaceArgs($this->descriptionLabel, array($progress, $progressCount));
     }
     IO\File::CreateWithText($this->targetFile, json_encode($this->data));
 }
Example #3
0
 private function UpdateHtaccess($file)
 {
     $rewriter = new Rewriter(new Writer());
     $text = File::GetContents($file);
     $startPos = strpos($text, (string) $rewriter->PageStartComment($this->item));
     $endPos = false;
     if ($startPos !== false) {
         $endPos = strpos($text, (string) $rewriter->PageEndComment($this->item));
         if ($endPos !== false) {
             $endPos += strlen((string) $rewriter->PageEndComment($this->item));
         }
     }
     if ($startPos === false || $endPos === false) {
         return;
     }
     $newText = substr($text, 0, $startPos) . substr($text, $endPos);
     File::CreateWithText($file, $newText);
 }
Example #4
0
 /**
  * Saves the template into the given file name
  */
 protected function OnSuccess()
 {
     $newTemplate = $this->Value('Name');
     $action = Action::Create();
     if ($this->template) {
         $action = Action::Update();
         $this->UpdateUsages($newTemplate);
         $oldFile = $this->CalcFile($this->template);
         if (File::Exists($oldFile)) {
             File::Delete($oldFile);
         }
     }
     $logger = new Logger(self::Guard()->GetUser());
     $logger->ReportTemplateAction($this->module->MyType(), $newTemplate, $action);
     if (!Folder::Exists($this->folder)) {
         Folder::Create($this->folder);
     }
     File::CreateWithText($this->CalcFile($newTemplate), $this->Value('Contents', false));
     Response::Redirect($this->BackLink());
 }
Example #5
0
 /**
  * Adds necessary rewrite commands
  */
 private function AdjustHtaccess()
 {
     $file = Path::Combine(PHINE_PATH, 'Public/.htaccess');
     if (!File::Exists($file)) {
         return;
     }
     $writer = new Writer();
     $rewriter = new Rewriter($writer);
     $text = File::GetContents($file);
     $startPos = strpos($text, (string) $rewriter->PageStartComment($this->page));
     $endPos = false;
     $pageFound = false;
     if ($startPos === false) {
         $startPos = strpos($text, (string) $rewriter->EndComment());
         $endPos = $startPos;
     } else {
         $endPos = strpos($text, (string) $rewriter->PageEndComment($this->page));
         if ($endPos !== false) {
             $pageFound = true;
             $endPos += strlen((string) $rewriter->PageEndComment($this->page));
         }
     }
     if ($startPos === false || $endPos === false) {
         return;
     }
     $rewriter->AddPageCommands($this->page);
     $newText = substr($text, 0, $startPos) . $writer->ToString() . substr($text, $endPos);
     File::CreateWithText($file, $newText);
 }
Example #6
0
 private function UpdateFiles($oldFile)
 {
     $newFile = PathUtil::LayoutTemplate($this->layout);
     if ($oldFile == $newFile) {
         return;
     } else {
         if ($oldFile) {
             File::Move($oldFile, $newFile);
         } else {
             File::CreateWithText($newFile, $this->TemplateContent());
         }
     }
 }
Example #7
0
 /**
  * Stores the content in the cache file
  * @param string $content The content to cache
  */
 function StoreToCache($content)
 {
     File::CreateWithText($this->file, $content);
 }