示例#1
0
 private function processDocument($path, $filename)
 {
     $basePath = Yii::getPathOfAlias('ext') . '/';
     $filePath = $basePath . $path . '/' . $filename;
     if (!file_exists($filePath)) {
         echo "File {$filePath} does not exist. Skipping.\n";
         return;
     }
     echo "Processing {$filePath}.\n";
     $markdownParser = new CMarkdownParser();
     $layout = Yii::getPathOfAlias('application.views.layouts') . '/documentation.php';
     if ($f = fopen($filePath, "r")) {
         $title = $in = fgets($f);
         while (!feof($f)) {
             $in .= fgets($f, 4096);
         }
     }
     fclose($f);
     $out = $markdownParser->transform($in);
     $out = $this->renderFile($layout, array('content' => $out, 'title' => $title), true);
     $docsPath = Yii::getPathOfAlias('application.docs') . '/';
     if (!file_exists($docsPath . $path)) {
         mkdir($docsPath . $path, 0777, true);
     }
     $outFileName = $docsPath . $path . '/' . str_replace('.txt', '.html', $filename);
     file_put_contents($outFileName, $out);
     return $outFileName;
 }
示例#2
0
 /**
  * Render response value
  * @param string value to render
  */
 protected function renderResponse($value)
 {
     if ($this->markdown) {
         $parser = new CMarkdownParser();
         echo $parser->transform($value);
     } else {
         echo $value;
     }
 }
 public function transform($text)
 {
     $text = preg_replace_callback('~\\[\\[(.*?)(?:\\|(.*?))?\\]\\]~', array($this, 'processWikiLinks'), $text);
     return parent::transform($text);
 }
示例#4
0
 /**
  * Process a string with markup
  *
  * @abstract
  * @param string $input
  * @return string $output
  */
 protected function processMarkup($input)
 {
     $md = new CMarkdownParser();
     return $md->transform($input);
 }
示例#5
0
 /**
  * Prepares comment before performing validation.
  */
 protected function beforeValidate()
 {
     $parser = new CMarkdownParser();
     $this->md_comment = $parser->transform($this->comment);
     return true;
 }
 /**
  * Prepare content
  * @return string content
  */
 protected function prepareContent($value)
 {
     if ($this->markdown) {
         $parser = new CMarkdownParser();
         return $this->safeTransform ? $parser->safeTransform($value) : $parser->transform($value);
     } else {
         return CHtml::encode($value);
     }
 }
示例#7
0
文件: rss.php 项目: xl602/CiiMS
        continue;
    }
    ?>
			<item>
				<title><?php 
    echo htmlspecialchars(str_replace('/', '', $v['title']), ENT_QUOTES, "utf-8");
    ?>
</title>
				<link><?php 
    echo $url . '/' . htmlspecialchars(str_replace('/', '', $v['slug']), ENT_QUOTES, "utf-8");
    ?>
</link>
				<description>
					<?php 
    $md = new CMarkdownParser();
    echo htmlspecialchars(strip_tags($md->transform($v['extract'])), ENT_QUOTES, "utf-8");
    ?>
				</description>
				<category><?php 
    echo htmlspecialchars(Categories::model()->findByPk($v['category_id'])->name, ENT_QUOTES, "utf-8");
    ?>
</category>
				<author><?php 
    echo Users::model()->findByPk($v['author_id'])->email;
    ?>
 (<?php 
    echo Users::model()->findByPk($v['author_id'])->username;
    ?>
)</author>
				<pubDate><?php 
    echo date('D, d M Y H:i:s T', strtotime($v['created']));
示例#8
0
 /**
  * @var string $string 内容
  * @var boolean $purifyOutput 是否过滤HTML
  * 格式化数据内容,过滤html
  */
 static function CMarkdown($string, $purifyOutput = false)
 {
     $m = new CMarkdownParser();
     $output = $m->transform($string);
     if ($purifyOutput) {
         $purifier = new CHtmlPurifier();
         $output = $purifier->purify($output);
     }
     return $output;
     Yii::app()->controller->beginWidget('CMarkdown', array('purifyOutput' => $purifyOutput));
     echo $string;
     Yii::app()->controller->endWidget();
 }
 protected function beforeValidate()
 {
     $parser = new CMarkdownParser();
     $this->html = $parser->transform($this->text);
     return parent::beforeValidate();
 }