Exemple #1
0
 /**
  * @return string 获取文本内容
  */
 public function getTextContent()
 {
     $self = $this;
     return Lazy::init($this->_textContent, function () use($self) {
         return file_get_contents($self->path);
     });
 }
 public function getTitle()
 {
     return Lazy::init($this->_title, function () {
         $textContent = $this->getTextContent();
         foreach (explode("\n", $textContent) as $line) {
             $line = trim($line);
             if ($line[0] != '#') {
                 return ltrim($line, '*');
             }
         }
         return $this->name;
     });
 }
Exemple #3
0
 /**
  * @return Config
  */
 public static function instance()
 {
     return Lazy::init(self::$_instance, function () {
         return new Config();
     });
 }
Exemple #4
0
 /**
  * @return User|null 当前登录的用户;若未登录,则为空
  */
 public static function getCurrentLoginUser()
 {
     /**@var $webUser CWebUser */
     $webUser = Yii::app()->user;
     if ($webUser->isGuest) {
         return null;
     }
     return Lazy::init(self::$_loginUser, function () use($webUser) {
         return User::model()->findByPk($webUser->id);
     });
 }
 /**
  * @return array 所有支持的文件类型
  */
 public static function getAvailableFileTypes()
 {
     return Lazy::init(self::$_supportedPageFileTypes, function () {
         return explode('|', WIKI_AVAILABLE_FILE_TYPES);
     });
 }