Example #1
0
 /**
  * md文件解析
  */
 public function md()
 {
     $file = $this->get('file');
     $p = $this->get('p');
     // 目录
     $directory = MD_FILE_ROOT_PATH . $p . '/';
     // 如果不存在自动创建
     filesystem::mkdir($directory);
     // 遍历文件夹所有内容
     $path = array();
     $dir = filesystem::ls($directory);
     usort($dir, 'compare');
     foreach ($dir as $d) {
         $path[] = trim($d);
     }
     //  解析mk文件
     $file = $directory . $file;
     if (is_file($file)) {
         $md = new markdown($file);
         $html = $md->parse();
         view::assign('html', $html);
     }
     view::assign('path', $path);
     view::assign('p', $p);
     view::assign('file', str_replace($directory, '', $file));
 }
Example #2
0
 public static function instance($name = null)
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #3
0
 /**
  * Returns the value of a view ane merges the config with any data passed to it
  *
  * @param   string        name of view
  * @param   boolean|array optional array of data to pass to the view
  * @param   string        file extension
  * @param   boolean|int   lifetime of cache. if set to true it will use the default
  *                            cache from the pages config or use an int if it is passed one
  * @return  string        contents of view or cache file
  */
 public static function view($view, $config = FALSE, $type = FALSE, $lifetime = FALSE)
 {
     $page = Pages::instance();
     // Setup caching and return the cache file it it works
     if ($lifetime) {
         $cache = new Cache();
         $cache_name = $page->getCacheIdForView($view . $type . serialize($data));
         if ($output = $cache->get($cache_name)) {
             return $output;
         }
     }
     // Load the view
     $view = new View($view, $config, $type);
     $output = $view->render();
     // Convert to markdown automatically
     if ($type == 'markdown' || $type == 'mdown' || $type == 'md') {
         $output = markdown::to_html($output);
     }
     // Store into cache
     if ($lifetime) {
         // Setup lifetime
         if ($lifetime === TRUE) {
             $lifetime = $page->cache_lifetime;
         } else {
             $lifetime = (int) $lifetime;
         }
         // Store the cache
         $cache->set($cache_name, $output, NULL, $lifetime);
     }
     return $output;
 }
Example #4
0
 public function markdown($text)
 {
     return markdown::instance()->convert($text);
 }
Example #5
0
    ?>
						<a href="<?php 
    echo url::backend('addons', ['subpage' => 'overview']);
    ?>
" class="btn btn-sm btn-default"><?php 
    echo lang::get('back');
    ?>
</a>
					</div>
					<div class="clearfix"></div>
				</div>
                <div class="panel-body">              
					<?php 
    $file = dir::addon($addon, 'README.md');
    if (file_exists($file)) {
        echo markdown::parse(file_get_contents($file));
    } else {
        echo lang::get('addon_no_readme');
    }
    ?>
                </div>
			</div>
		</div>
	</div>
<?php 
} else {
    $table = table::factory();
    $table->addCollsLayout('20,*,215');
    $table->addRow()->addCell('')->addCell(lang::get('name'))->addCell(lang::get('actions'));
    $table->addSection('tbody');
    $addons = scandir(dir::backend('addons' . DIRECTORY_SEPARATOR));
Example #6
0
<?php
/**
 * news.disp.php
 * 
 * @version $Id$
 * @copyright 2008
 */
$md = new markdown();
if (isset($safeGet['name']))
{
	# This code will break in the year 2100 (due to their choice of date format) but we will probably have been
	# eaten by robots by then anyway so it doesn't matter.
	$name = $safeGet['name'];
	$query = new query();
	$query->select('id')->from('articles')->where('name', $name)->limit('1');
	$result = $this->db->query($query);
	$row = $this->db->assoc($result);
	$article = metaclass::load('article', $row['id']);
	$this->dOutput['article']['header'] = $article->getProperty('title');
	$this->dOutput['article']['date'] = janitor::formatMysqlDateTime($article->getProperty('date'), 'l jS F, Y');
	$this->dOutput['article']['fulltext'] = $md->process($article->getProperty('fulltext'));
	$this->dOutput['pageTitle'] = $article->getProperty('title');
} else
{
	$query = new query();
	$query->select(array (
		'id' , 
		'name' , 
		'date' , 
		'title' , 
		'preview'
Example #7
0
 private static function parse_code()
 {
     self::$file_content = preg_replace("/(\t.*\n?)+/", "<pre><code>\$0</code></pre>\n", self::$file_content);
 }
 protected function teardown()
 {
     #
     # Clearing Extra-specific variables.
     #
     $this->footnotes = array();
     $this->footnotes_ordered = array();
     $this->footnotes_ref_count = array();
     $this->footnotes_numbers = array();
     $this->abbr_desciptions = array();
     $this->abbr_word_re = '';
     parent::teardown();
 }