예제 #1
0
 function Parse($file)
 {
     $contents = File::GetContents($file);
     foreach ($this->replacements as $placeholder => $text) {
         $contents = String::Replace($this->phStart . $placeholder . $this->phEnd, $text, $contents);
     }
     return $contents;
 }
예제 #2
0
 /**
  * Gets the current status
  * @return \stdClass Returns an object with progress, progressCount and optional progressDescription
  */
 function GetStatus()
 {
     if (IO\File::Exists($this->targetFile)) {
         $json = IO\File::GetContents($this->targetFile);
         return json_decode($json);
     }
     return null;
 }
예제 #3
0
 protected function BeforeInit()
 {
     $this->layout = Layout::Schema()->ByID(Request::GetData('layout'));
     if (!$this->layout) {
         //TODO: Message
         Response::Redirect($this->BackLink());
     }
     $this->file = PathUtil::LayoutTemplate($this->layout);
     if (!File::Exists($this->file)) {
         //TODO: Message
         Response::Redirect($this->BackLink());
     }
     $this->contents = File::GetContents($this->file);
     return parent::BeforeInit();
 }
예제 #4
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);
 }
예제 #5
0
 /**
  * Executes all necessary scripts in the engine folder
  * @param  string $engineFolder The folder
  * @throws \Exception Raises error if any of the scripts fail
  */
 private function ExecuteScripts($engineFolder)
 {
     $files = $this->SortFilesByVersion(Folder::GetFiles($engineFolder));
     $completeSql = '';
     foreach ($files as $file) {
         $sqlFile = Path::Combine($engineFolder, $file);
         $completeSql .= "\r\n" . File::GetContents($sqlFile);
     }
     try {
         $this->CleanAllForeignKeys();
         //$this->connection->StartTransaction();
         $this->connection->ExecuteMultiQuery($completeSql);
     } catch (\Exception $exc) {
         //$this->connection->RollBack();
         throw $exc;
         //throw new \Exception("Error executing SQL in folder $engineFolder: " . $completeSql, null, $exc);
     }
     //$this->connection->Commit();
 }
예제 #6
0
 private function AddContentsField()
 {
     $name = 'Contents';
     $value = '';
     if ($this->template) {
         $file = $this->CalcFile($this->template);
         $value = File::Exists($file) ? File::GetContents($file) : '';
     } else {
         $value = File::GetContents($this->module->BuiltInTemplateFile());
     }
     $this->AddField(new Textarea($name, $value));
 }
예제 #7
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);
 }
예제 #8
0
 private function TemplateContent()
 {
     $areaCodes = '';
     $writer = new Writer();
     $this->InitAreas();
     $template = PathUtil::CodeTemplate($this->MyBundle(), 'Layout.phtml');
     $templateCode = File::GetContents($template);
     $indent = $this->GetIndent($templateCode, '_{areas}_');
     for ($idx = 0; $idx < count($this->areaNames); ++$idx) {
         $name = $this->areaNames[$idx];
         $writer->StartPhpInline();
         $writer->AddCommandInline('echo $this->RenderArea(\'' . $name . '\')');
         if ($idx < count($this->areaNames) - 1) {
             $writer->EndPhp();
         } else {
             $writer->EndPhpInline();
         }
         if ($idx > 0) {
             $areaCodes .= $indent;
         }
         $areaCodes .= $writer->Flush();
     }
     return str_replace('_{areas}_', $areaCodes, $templateCode);
 }
예제 #9
0
 /**
  * Pulls content from the cache
  * @return string Gets the contents of the cache file
  */
 function GetFromCache()
 {
     return File::GetContents($this->file);
 }