/** * @param array $params * @return string */ public function getIntroduction(array $params = array()) { $docbook = FrontController::getInstance(); $md_parser = $docbook->getMarkdownParser(); $md_content = $md_parser->transformSource($this->getRealPath()); return $md_content->getBody(); }
public function __construct($path = null) { $this->docbook = FrontController::getInstance(); if (!empty($path)) { $this->setPath($path); } $this->init(); }
public function fallbackFinder($filename, $filetype = 'template') { $docbook = FrontController::getInstance(); $base_path = 'template' === $filetype ? FrontController::TEMPLATES_DIR : FrontController::CONFIG_DIR; $file_path = DirectoryHelper::slashDirname($base_path) . $filename; // user first $user_path = $docbook->getPath('user_dir'); if (!empty($user_path)) { $user_file_path = DirectoryHelper::slashDirname($docbook->getPath('user_dir')) . $file_path; if (file_exists($user_file_path)) { return $user_file_path; } } // default $def_file_path = DirectoryHelper::slashDirname($docbook->getPath('base_dir')) . $file_path; if (file_exists($def_file_path)) { return $def_file_path; } // else false return false; }
public function getDocBookRouting() { $docbook = FrontController::getInstance(); $original_page_type = $docbook->getAction(); $page_type = !empty($original_page_type) ? $original_page_type : 'default'; $input_file = $docbook->getInputFile(); if (empty($input_file)) { $input_path = $docbook->getInputPath(); if (!empty($input_path)) { $input_file = DirectoryHelper::slashDirname($docbook->getPath('base_dir_http')) . trim($input_path, '/'); } } $ctrl_infos = $docbook->getLocator()->findController($page_type); if ($ctrl_infos) { $this->setRouting($ctrl_infos); } else { if (!empty($original_page_type)) { throw new NotFoundException(sprintf('The requested "%s" action was not found!', $original_page_type)); } else { throw new NotFoundException(sprintf('The requested page was not found (searching "%s")!', $input_file)); } } return $this->getRouting(); }
public function sitemapAction($path) { $this->setPath($path); $dbfile = new DocBookFile($this->getpath()); FrontController::getInstance()->getResponse()->setContentType('xml'); $contents = Helper::getFlatDirscans($dbfile->getDocBookScanStack(true)); $rss_content = $this->docbook->display('', 'sitemap', array('page' => $dbfile->getDocBookStack(), 'contents' => $contents)); return array('layout_empty_xml', $rss_content); }
/** * Show errors at least initially * * `E_ALL` => for hard dev * `E_ALL & ~E_STRICT` => for hard dev in PHP5.4 avoiding strict warnings * `E_ALL & ~E_NOTICE & ~E_STRICT` => classic setting */ //@ini_set('display_errors','1'); @error_reporting(E_ALL); //@ini_set('display_errors','1'); @error_reporting(E_ALL & ~E_STRICT); @ini_set('display_errors', '1'); @error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT); // Set a default timezone to avoid PHP5 warnings $dtmz = @date_default_timezone_get(); @date_default_timezone_set($dtmz ?: 'Europe/London'); // uncomment in dev mode //define('DOCBOOK_MODE', 'dev'); // ----------------------------------- // Get Composer autoloader // ----------------------------------- $composerAutoLoader = __DIR__ . '/../src/vendor/autoload.php'; if (@file_exists($composerAutoLoader)) { require_once $composerAutoLoader; } else { die("You need to run Composer on the project to build dependencies and auto-loading" . " (see: <a href=\"http://getcomposer.org/doc/00-intro.md#using-composer\">http://getcomposer.org/doc/00-intro.md#using-composer</a>)!"); } // ----------------------------------- // PROCESS // ----------------------------------- // the application \DocBook\FrontController::getInstance()->distribute(); // Endfile
public static function getIcon($type = null, $class = '') { if (!empty($type)) { $docbook = FrontController::getInstance(); $icons = $docbook->getRegistry()->get('icons', array(), 'docbook'); return '<span class="glyphicon glyphicon-' . (isset($icons[$type]) ? $icons[$type] : $icons['default']) . (!empty($class) ? ' ' . $class : '') . '"></span>'; } return ''; }
/** * @param array $params * @return string */ public function viewFileInfos(array $params = array()) { return FrontController::getInstance()->display('', 'default_content', $params); }
/** * Get an array of the default parameters for all views */ public function getDefaultViewParams() { $docbook = FrontController::getInstance(); return array('DB' => $docbook, 'app_cfg' => $docbook->getRegistry()->getConfig('html', array(), 'docbook'), 'app' => $docbook->getRegistry()->getConfig('app', array(), 'docbook'), 'langs' => $docbook->getRegistry()->getConfig('languages', array(), 'docbook'), 'manifest' => $docbook->getRegistry()->getConfig('manifest', array()), 'assets' => '/' . FrontController::DOCBOOK_ASSETS . '/', 'vendor_assets' => '/' . FrontController::DOCBOOK_ASSETS . '/vendor/', 'chapters' => $docbook->getChapters(), 'search_str' => $docbook->getRequest()->getGet('s')); }
public function getDescription() { if (!isset($this->cache['docbook_description'])) { $docbook = FrontController::getInstance(); $name = strtolower($this->getBasename()); $cfg_esc = $docbook->getRegistry()->get('descriptions', array(), 'docbook'); if (!empty($cfg_esc) && is_array($cfg_esc) && array_key_exists($name, $cfg_esc)) { return _T($cfg_esc[$name]); } $extension = strtolower($this->getExtension()); $cfg_ext = $docbook->getRegistry()->get('descriptions_extensions', array(), 'docbook'); if (!empty($cfg_ext) && is_array($cfg_ext) && array_key_exists($extension, $cfg_ext)) { $this->cache['docbook_description'] = _T($cfg_ext[$extension]); } else { $this->cache['docbook_description'] = ''; } } return $this->cache['docbook_description']; }
/** * @param array $params * @return string */ public function viewFileInfos(array $params = array()) { return FrontController::getInstance()->display(file_get_contents($this->getRealPath()), 'file_content', $params); }
/** * @param array $params * @return string */ public function viewFileInfos(array $params = array()) { $img = new WebImage($this->getRealPath()); $params = array_merge($params, array('height' => $this->getHeight(), 'width' => $this->getWidth())); return FrontController::getInstance()->display($this->getBase64Content(true), 'embed_content', $params); }