private function __construct() { $app = tfProgram::get(); // Load outputs $list = $app->fs->listDirectory('outputs/', true, false); foreach ($list as &$item) { if (strpos($item, '.php') !== false) { $item = substr($item, 0, strlen($item) - 4); } } $this->outputs = $list; }
This file is part of TypeFriendly. TypeFriendly is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. TypeFriendly is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with TypeFriendly. If not, see <http://www.gnu.org/licenses/>. */ define('TF_DIR', dirname(__FILE__) . '/'); define('TF_INCLUDES', TF_DIR . 'includes/'); define('TF_VENDOR', TF_DIR . 'vendor/'); define('TF_OUTPUTS', TF_DIR . 'outputs/'); define('TF_TPL', TF_DIR . 'templates/'); require_once TF_INCLUDES . 'console.php'; require_once TF_INCLUDES . 'resources.php'; require_once TF_INCLUDES . 'tags.php'; require_once TF_INCLUDES . 'filesystem.php'; require_once TF_INCLUDES . 'markdown.php'; if (version_compare(phpversion(), '5.3.0-dev', '<')) { require_once TF_INCLUDES . 'php52.php'; } $app = tfProgram::get(); $app->loadModule('main'); $app->run();
/** * Generates the output document. * * @staticvar standardOutput $lastOutput The last output used. */ public function generate() { static $lastOutput = NULL; $prog = tfProgram::get(); $reparse = false; if ($lastOutput != $this->output) { $lastOutput = $this->output; $reparse = true; } $this->fs->safeMkDir('output/' . $this->output, TF_READ | TF_WRITE | TF_EXEC); $this->fs->cleanUpDirectory('output/' . $this->output); $this->copyMedia(); $this->outputObj = $out = $this->prog->fs->loadObject('outputs/' . $this->output . '.php', $this->output); if ($reparse) { $parsers = tfParsers::get(); $refs = array(); $refTitles = array(); foreach ($this->pages as &$page) { $refs[$page['Id']] = $this->outputObj->toAddress($page['Id']); $refTitles[$page['Id']] = ($this->config['showNumbers'] ? $page['FullNumber'] . '. ' : '') . (!isset($page['Tags']['ShortTitle']) ? $page['Tags']['Title'] : $page['Tags']['ShortTitle']); } $parsers->getParser()->predef_urls = $refs; $parsers->getParser()->predef_titles = $refTitles; } foreach ($this->pages as &$page) { if (!tfTags::validateTags($page['Tags'])) { throw new Exception('Tag validation error in "' . $page['Id'] . '": ' . PHP_EOL . tfTags::getError()); } } $out->init($this, 'output/' . $this->output . '/'); foreach ($this->pages as &$page) { if (!$this->parsed) { $page['Markdown'] = $page['Content']; } $parsers->getParser()->fn_id_prefix = str_replace('.', '_', $page['Id']) . ':'; $parsers->getParser()->page_id = $page['Id']; $page['Content'] = $parsers->parse($page['Markdown']); $out->generate($page); $prog->console->stderr->write('.'); } $prog->console->stderr->write(PHP_EOL); $this->parsed = true; $out->close(); }
/** * Handles "Arguments" tag. * * @param Array $list The argument list * @return String */ public function _tagArguments($list) { $output = tfProgram::get()->console->stderr; $typeOk = true; foreach ($list as $item) { if (!isset($item['Type']) && !isset($item['EType'])) { $typeOk = false; } // Do some validation here. if (!isset($item['Desc'])) { $output->writeln('Missing Arguments:Desc tag in ' . $this->_currentPage['Id']); return; } if (!isset($item['Name'])) { $output->writeln('Missing Arguments:Name tag in ' . $this->_currentPage['Id']); return; } } $code = '<tr><th>' . $this->translate->_('tags', 'arg_list') . '</th><td>'; //.$this->translate->_('tags', 'arg_name').'</th>'; $code .= '<dl>'; foreach ($list as $item) { $code .= '<dt><code>' . $item['Name'] . '</code>'; if ($typeOk) { $code .= ' <small>- '; if (isset($item['Type'])) { $pp = $this->project->getMetaInfo($item['Type'], false); if (!is_null($pp)) { $code .= '<a href="' . $this->toAddress($pp['Id']) . '">' . $pp['Tags']['ShortTitle'] . '</a>'; } } elseif (isset($item['EType'])) { $code .= '' . $item['EType'] . ''; } $code .= '</small>'; } $code .= '</dt><dd>' . $item['Desc'] . '</dd>'; } return $code . '</dl></td></tr>'; }
private function __construct() { $program = tfProgram::get(); $this->parsers = tfParsers::get(); $this->fs = $program->fs; }
public static function get() { if (is_null(tfProgram::$instance)) { tfProgram::$instance = new tfProgram(); } return tfProgram::$instance; }