Пример #1
0
 public function renderDocViewFile($viewFile)
 {
     $md = new CMarkdown();
     $str = $this->renderFile($viewFile, array(), true);
     $str = $md->transform($str);
     $this->render('tmpl', array('content' => $str));
 }
Пример #2
0
 public function actionIndex($view, $folder = '')
 {
     $md = new CMarkdown();
     if ($folder) {
         $view = $folder . '/' . $view;
     }
     $str = $this->renderPartial($view, array(), true);
     $str = $md->transform($str);
     $this->render('tmpl', array('content' => $this->compileDocSyntax($str)));
 }
 public function actionIndex($alias = 'index', $folder = '')
 {
     $md = new CMarkdown();
     if ($folder) {
         $view = $folder . '/' . $alias;
     } else {
         $view = $alias;
     }
     //        $content = Documentation::model()->findByAttributes(array('alias'=>$alias))->content;
     $content = $this->renderPartial($view, array(), true);
     $str = $md->transform($content);
     $this->render('tmpl', array('content' => $this->compileDocSyntax($str)));
 }
Пример #4
0
 public function run()
 {
     $module = Yii::app()->controller->module->id;
     $path = Yii::getPathOfAlias("mod.{$module}.manual") . "/manual.md";
     if (file_exists($path)) {
         $text = file_get_contents($path);
         $markdown = new CMarkdown();
         echo CHtml::openTag('div', array('id' => 'manual'));
         echo $markdown->transform($text);
         echo CHtml::closeTag('div');
         echo CHtml::link('<span class="icon-medium icon-info-2 "></span> ' . $this->title, 'javascript:void(0)', array('onClick' => '$("#manual").dialog("open")'));
     }
 }
Пример #5
0
 public function transform($output)
 {
     // toc process
     $toc = '';
     $output = parent::transform($output);
     if (preg_match_all('/<h2(?: id=".+")?>(.+?)<\\/h2>/', $output, $match, PREG_PATTERN_ORDER) > 1) {
         $toc = CHtml::openTag('div', array('class' => 'toc')) . CHtml::openTag('ol');
         for ($i = 0; $i < count($match[0]); $i++) {
             $text = $i + 1 . '. ' . $match[1][$i] . CHtml::link('¶', null, array('name' => 'ch' . $i, 'class' => 'anchor'));
             $html = CHtml::tag('h2', array('id' => 'ch' . $i), $text);
             $toc .= Chtml::tag('li', array(), CHtml::link($match[1][$i], '#ch' . $i));
             $output = str_replace($match[0][$i], $html, $output);
         }
         $toc .= CHtml::closeTag('ol') . CHtml::closeTag('div');
     }
     // image process
     $output = preg_replace_callback('#<img\\s+src=".+?"\\s+alt="(.+?)"(?:\\s+title="(.+?)")?\\s+/>#s', array(&$this, '_doImages_callback_format'), $output);
     return $toc . $output;
 }
Пример #6
0
 /**
  * Метод отрисовки и кеширования документации:
  *
  * @param string $fileName - файл к отрисовке
  *
  * @return возвращаем отрисованный контент
  **/
 public function renderMarkdown($fileName = null)
 {
     /**
      * нет смысла обрабатывать несушествующий файл:
      */
     if ($fileName == null || !file_exists($fileName)) {
         return null;
     }
     /**
      * Получаем контент из кеша, если файл не изменился и не пуст
      * или рендерим:
      */
     if (($content = Yii::app()->cache->get('docs_content_' . $fileName)) === false || empty($content)) {
         $md = new CMarkdown();
         $content = $md->transform(file_get_contents($fileName));
         Yii::app()->cache->set('docs_content_' . $fileName, $content, 0, new CFileCacheDependency($fileName));
     }
     return $content;
 }
Пример #7
0
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title"
                id="myModalLabel"><?php 
echo Yii::t('AdminModule.views_module_info', 'More information: <strong>%moduleName%</strong>', array('%moduleName%' => $name));
?>
</h4>
        </div>
        <div class="modal-body">

            <?php 
if ($content != "") {
    ?>

                <?php 
    $md = new CMarkdown();
    echo $md->transform($content);
    ?>

            <?php 
} else {
    ?>
                <?php 
    echo $description;
    ?>
                <br />
                <br />

                <?php 
    echo Yii::t('AdminModule.views_module_info', 'This module doesn\'t provide further informations.');
    ?>