/**
  * 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();
 }
Ejemplo n.º 2
0
 /**
  * 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');
 }
Ejemplo n.º 3
0
 function RenderEndScript()
 {
     $templateDir = Path::Combine(__DIR__, 'Templates');
     $templateFile = Path::FilenameNoExtension($this->ClassFile()) . '.endscript.phtml';
     $template = Path::Combine($templateDir, $templateFile);
     if (File::Exists($template)) {
         ob_start();
         require $template;
         return ob_get_clean();
     }
     return '';
 }
Ejemplo n.º 4
0
 /**
  * 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);
 }
Ejemplo n.º 5
0
 /**
  * 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;
 }
Ejemplo n.º 6
0
 private function CalcFile($template)
 {
     return Path::AddExtension(Path::Combine($this->folder, $template), 'phtml');
 }
Ejemplo n.º 7
0
 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);
 }
Ejemplo n.º 8
0
 /**
  * 
  * @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}"));
 }
Ejemplo n.º 9
0
 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;
 }
Ejemplo n.º 10
0
 /**
  * The simple template with "echo result"
  * @return string
  */
 public function TemplateFile()
 {
     $dir = PathUtil::BundleFolder('Core');
     return Path::Combine($dir, 'Templates/EchoResult.phtml');
 }
Ejemplo n.º 11
0
 static function FullUrl()
 {
     return Path::Combine(self::BaseUrl(), self::Uri());
 }
Ejemplo n.º 12
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);
 }
Ejemplo n.º 13
0
 /**
  * 
  * @return string
  * @throws \Exception Raises exception if engine is not supported
  */
 private function FindEngineFolder()
 {
     $bundle = $this->manifest->BundleName();
     $sqlFolder = PathUtil::InstallationSqlFolder($bundle);
     if (!Folder::Exists($sqlFolder) || Folder::IsEmpty($sqlFolder)) {
         return '';
     }
     $engine = (string) $this->connection->Engine();
     $engineFolder = Path::Combine($sqlFolder, $engine);
     if (!Folder::Exists($engineFolder)) {
         throw new \Exception("Bundle {$bundle} doesn't support your database engine '{$engine}'");
     }
     return $engineFolder;
 }
Ejemplo n.º 14
0
 /**
  * Gets the database folder
  * @return string The database folder
  */
 static function DatabaseFolder()
 {
     return Path::Combine(PHINE_PATH, 'Database');
 }
Ejemplo n.º 15
0
 /**
  * Loads Code not available to autoload
  */
 protected function LoadFrontendCode()
 {
     require_once Path::Combine(__DIR__, 'Globals/Functions.php');
 }