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; }
/** * 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; }
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(); }
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); }
/** * 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(); }
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)); }
/** * 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); }
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); }
/** * Pulls content from the cache * @return string Gets the contents of the cache file */ function GetFromCache() { return File::GetContents($this->file); }