yiiapi/docs/viewer/controllers/GuideController.php
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
class GuideController extends CController
{
public $defaultAction='view';
public $languageNames=array(
'de'=>'German',
'en'=>'English',
'es'=>'Spanish',
'fr'=>'French',
'he'=>'Hebrew',
'hu'=>'Hungarian',
'id'=>'Indonesian',
'it'=>'Italian',
'nl'=>'Dutch',
'no'=>'Norwegian',
'ja'=>'Japanese',
'pl'=>'Polish',
'pt'=>'Portuguese',
'pt_br'=>'Portuguese (Brazilian)',
'ru'=>'Russian',
'sv'=>'Swedish',
'ta_in'=>'Tamil',
'vi'=>'Vietnamese',
'uk' => 'Ukrainian',
'zh_cn'=>'Simplified Chinese',
'zh_tw'=>'Traditional Chinese',
);
private $_languages;
private $_language;
private $_topics;
public function actionView()
{
$topic=$this->getTopic();
$file=Yii::getPathOfAlias("docs.guide.{$this->language}").DIRECTORY_SEPARATOR.$topic.'.txt';
if(!is_file($file))
$file=Yii::getPathOfAlias("docs.guide").DIRECTORY_SEPARATOR.$topic.'.txt';
if(!strcasecmp($topic,'toc') || !is_file($file))
throw new CHttpException(404,'The page you looked for does not exist.');
$content=file_get_contents($file);
$markdown=new MarkdownParser;
$content=$markdown->safeTransform($content);
$imageUrl=Yii::app()->baseUrl.'/guide/images';
$content=preg_replace('/<p>\s*<img(.*?)src="(.*?)"\s+alt="(.*?)"\s*\/>\s*<\/p>/',
"<div class=\"image\"><p>\\3</p><img\\1src=\"$imageUrl/\\2\" alt=\"\\3\" /></div>",$content);
$content=preg_replace_callback('/href="\/doc\/guide\/(.*?)\/?"/',array($this,'replaceGuideLink'),$content);
$content=preg_replace('/href="(\/doc\/api\/.*?)"/','href="http://www.yiiframework.com$1"',$content);
$this->pageTitle='The Definitive Guide to Yii';
if($topic!=='index' && preg_match('/<h1[^>]*>(.*?)</',$content,$matches))
$this->pageTitle.=' - '.CHtml::encode($matches[1]);
$this->render('view',array('content'=>$content));
}
后面还有 74 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
