/** * Renders the rich text editor. * @param string $name * @param string $value */ function Render($name, $value = '') { $baseUrl = $this->baseUrl; $grantResult = $this->guard->Grant(Action::UseIt(), $this); $disabled = (string) $grantResult != (string) GrantResult::Allowed(); $_SESSION['KCFINDER']['disabled'] = $disabled; $_SESSION['KCFINDER']['uploadURL'] = $this->uploadUrl; $_SESSION['KCFINDER']['uploadDir'] = $this->uploadDir; $oCKeditor = new \CKEditor(); $oCKeditor->basePath = IO\Path::Combine($baseUrl, 'ckeditor/'); $oCKeditor->config['skin'] = 'v2'; $oCKeditor->config['filebrowserBrowseUrl'] = IO\Path::Combine($baseUrl, 'kcfinder/browse.php?type=files'); $oCKeditor->config['filebrowserImageBrowseUrl'] = IO\Path::Combine($baseUrl, 'kcfinder/browse.php?type=images'); $oCKeditor->config['filebrowserFlashBrowseUrl'] = IO\Path::Combine($baseUrl, 'kcfinder/browse.php?type=flash'); $oCKeditor->config['filebrowserUploadUrl'] = IO\Path::Combine($baseUrl, 'kcfinder/upload.php?type=files'); $oCKeditor->config['filebrowserImageUploadUrl'] = IO\Path::Combine($baseUrl, 'kcfinder/upload.php?type=images'); $oCKeditor->config['filebrowserFlashUploadUrl'] = IO\Path::Combine($baseUrl, 'kcfinder/upload.php?type=flash'); foreach ($this->config as $key => $val) { $oCKeditor->config[$key] = $val; } ob_start(); echo '<div class="phine-cke">'; $oCKeditor->editor($name, $value); echo '</div>'; return ob_get_clean(); }
/** * Returns the template file * @return string */ protected function TemplateFile() { $class = new \ReflectionClass($this); $classFile = String::Replace('\\', '/', $class->getFileName()); $templatePath = String::Replace('/Snippets/', '/Templates/Snippets/', $classFile); return Path::AddExtension($templatePath, 'phtml', true); }
/** * Gets the csv file path for the given language * @param string $basePath * @return string */ private function LanguageCsvFile($basePath) { $ext = IO\Path::Extension($basePath); $baseFile = IO\Path::RemoveExtension($basePath); $langFile = IO\Path::AddExtension($baseFile, $this->language); return IO\Path::AddExtension($langFile, $ext); }
/** * The template file * @return string */ public function TemplateFile() { if (!$this->AllowCustomTemplates() || !$this->content || !$this->content->GetTemplate()) { return $this->BuiltInTemplateFile(); } $file = Path::Combine(PathUtil::ModuleCustomTemplatesFolder($this), $this->content->GetTemplate()); return Path::AddExtension($file, 'phtml'); }
/** * Renders a block by name * @param string $block * @return string */ public function RenderBlock($block) { $templateFile = $this->BuiltInTemplateFile(); $blockFile = Path::AddExtension($templateFile, $block, true); $blockFileExt = Path::AddExtension($blockFile, 'phtml'); if (!File::Exists($blockFileExt)) { return ''; } ob_start(); require $blockFileExt; return ob_get_clean(); }
/** * Remove htaccess page commands before page is deleted */ protected function BeforeDelete() { foreach (self::$deleteHooks as $hook) { $hook->BeforeDelete($this->item); } $logger = new Logger(BackendModule::Guard()->GetUser()); $logger->ReportPageAction($this->item, Action::Delete()); $file = Path::Combine(PHINE_PATH, 'Public/.htaccess'); if (!File::Exists($file)) { return; } $this->UpdateHtaccess($file); }
/** * Returns the url of a page with parameters and fragment * @param Page $page The page * @param array $params All parameters * @return string Return the page url */ static function PageUrl(Page $page, array $params = array(), $fragment = '') { $siteUrl = $page->GetSite()->GetUrl(); $pageUrl = $page->GetUrl(); if ($pageUrl == 'index.html') { $url = $siteUrl; } else { $url = Path::Combine($siteUrl, $pageUrl); } $oblParams = self::GatherParams($url); $urlObl = self::AttachObligatoryParams($url, $oblParams, $params); $urlAllParams = self::AttachMoreParams($urlObl, $oblParams, $params); return $fragment ? $urlAllParams . '#' . $fragment : $urlAllParams; }
/** * Checks if the file given in the value doesn't exist yet * @param string $value The value to check * @return boolean True id check passed */ public function Check($value) { $this->error = ''; if ($this->currentFile && $value == $this->currentFile) { return true; } if (!Folder::Exists($this->folder)) { return true; } $files = Folder::GetFiles($this->folder); if ($this->fileExtension) { $value = Path::AddExtension($value, $this->fileExtension); } if (in_array($value, $files)) { $this->error = self::ExistsInFolder; } return $this->error == ''; }
/** * Redirects to the next step */ function GotoNext() { $next = Page::NextStep($this->Step()); Response::Redirect(Path::AddExtension($next, 'php')); }
private function CalcFile($template) { return Path::AddExtension(Path::Combine($this->folder, $template), 'phtml'); }
private function GetConfirmMessage() { $replacements = array(); $replacements['Text1'] = $this->register->GetMailText1(); $replacements['Text2'] = $this->register->GetMailText2(); $replacements['Title'] = Html($this->register->GetMailSubject()); $replacements['Styles'] = Html($this->register->GetMailStyles()); $confirmUrl = $this->register->GetConfirmUrl(); if ($confirmUrl) { $replacements['ConfirmUrl'] = Html(Confirmer::CalcUrl($this->member, $confirmUrl)); } $template = Path::Combine(PathUtil::BundleFolder($this->MyBundle()), 'MailTemplates/Confirm.phtml'); $parser = new TemplateParser($replacements); return $parser->Parse($template); }
/** * * @copyright Thanks to "Unsigned", posted on stackoverflow, * from BSD-licensed SoloAdmin * @param string $path * @return int|string Gets the file size in bytes as string or integer */ static function GetSize($path) { // If the platform is Windows... if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { // Try using the NT substition modifier %~z $size = trim(exec("for %F in (\"" . $path . "\") do @echo %~zF")); // If the return is blank, zero, or not a number if (!$size || !ctype_digit($size)) { // Use the Windows COM interface $fsobj = new COM('Scripting.FileSystemObject'); if (dirname($path) == '.') { $path = Path::Combine(getcwd(), Path::Filename($path)); } $f = $fsobj->GetFile($path); return $f->Size; } // Otherwise, return the result of the 'for' command return $size; } // If the platform is not Windows, use the stat command (should work for *nix and MacOS) return trim(exec("stat -c%s {$path}")); }
/** * Loads Code not available to autoload */ protected function LoadFrontendCode() { require_once Path::Combine(__DIR__, 'Globals/Functions.php'); }
private function RemoveTemplate() { $id = Request::PostData('delete'); if (!$id) { return false; } $idParts = \explode('/', $id); $module = $this->RemovalTemplateModule($idParts); $templateName = trim($idParts[1]); if (!$module || !$templateName) { return false; } $logger = new Logger(self::Guard()->GetUser()); $logger->ReportTemplateAction($module->MyType(), $templateName, Action::Delete()); $folder = PathUtil::ModuleCustomTemplatesFolder($module); $template = Path::Combine($folder, Path::AddExtension($templateName, 'phtml')); if (File::Exists($template)) { File::Delete($template); } $this->DeleteUsages($module, $templateName); return true; }
/** * The simple template with "echo result" * @return string */ public function TemplateFile() { $dir = PathUtil::BundleFolder('Core'); return Path::Combine($dir, 'Templates/EchoResult.phtml'); }
/** * Adds the template select field * @param FrontendModule $module The module for template selection */ protected final function AddTemplateField() { $name = 'Template'; $field = new Select($name, (string) $this->Content()->GetTemplate()); $field->AddOption('', Trans("Core.ContentForm.{$name}.Default")); $folder = PathUtil::ModuleCustomTemplatesFolder($this->FrontendModule()); if (Folder::Exists($folder)) { $files = Folder::GetFiles($folder); foreach ($files as $file) { $value = Path::FilenameNoExtension($file); $field->AddOption($value, $value); } } $this->AddField($field, false, Trans("Core.ContentForm.{$name}")); }
static function FullUrl() { return Path::Combine(self::BaseUrl(), self::Uri()); }
/** * Gets the database folder * @return string The database folder */ static function DatabaseFolder() { return Path::Combine(PHINE_PATH, 'Database'); }
/** * Renderst necessary javascript * @return string Returns javascript for html output */ function RenderScript() { $templateFile = Path::RemoveExtension($this->TemplateFile()); $scriptFile = Path::AddExtension($templateFile, 'Script'); ob_start(); require Path::AddExtension($scriptFile, 'phtml'); return ob_get_clean(); }
/** * 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); }
/** * Sorts files by version * @param string[] $files The files * @return string[] Returns the sorted files */ private function SortFilesByVersion(array $files) { $result = array(); $foreignKeysFile = ''; foreach ($files as $file) { if ($file == 'foreign-keys.sql') { $foreignKeysFile = $file; continue; } $version = Path::RemoveExtension($file); if ($this->installedVersion && version_compare($version, $this->installedVersion) <= 0) { continue; } $result[$version] = $file; } uksort($result, "version_compare"); if ($foreignKeysFile) { $result[] = $foreignKeysFile; } return $result; }