示例#1
0
 /**
  * 获取一条数据
  * 
  * @param int   $uid  用户UID,默认为当前登录用户UID
  * 
  * @return array
  */
 public static function show($uid = false)
 {
     !$uid && ($uid = \Yaf_Registry::get('current_uid'));
     $result = parent::show($uid);
     isset($result['data']) && ($result['data'] = self::decodeData($result['data']));
     return $result;
 }
示例#2
0
 /**
  * 根据用户UID获取一条数据
  * 
  * @param int $id 用户UID,不传则为当前登录用户
  * 
  * @return \array
  */
 public static function show($id = false)
 {
     $id || ($id = \Yaf_Registry::get('current_uid'));
     $sdata_key = sprintf('user_%s', $id);
     return \Comm\Sdata::getValue($sdata_key, function () use($id) {
         return parent::show($id);
     });
 }
示例#3
0
 public static function url($sUrl, $sPort = null)
 {
     // AP: Not sure why I ever added this, but it causes port 80 being added to https
     // Talk to me if you must add this back
     // if (!$sPort) {
     // 	if (preg_match("|^https://|", $sUrl)) {
     // 		$sPort = M::HTTPS_PORT();
     // 	} else {
     // 		$sPort = M::HTTP_PORT();
     // 	}
     // }
     return Abs::absolutize($sUrl, $sPort);
 }
示例#4
0
 /**
  * 设置计数数器
  * 
  * @param int   $category_id 分类ID
  * @param int   $uid         用户UID(不传则为当前登录用户)
  * @param int   $total_number 计数器值
  * 
  * @return \int|\boolean
  */
 public static function set($category_id, $uid = null, $total_number)
 {
     return parent::setValue(self::_showKey($uid, $category_id), $total_number);
 }
示例#5
0
文件: Arg.php 项目: chaoyanjie/HiBlog
 /**
  * 构造方法
  * 
  * @param string $message  消息
  * @param int    $code     错误代码
  * @param string $arg_name 参数名称
  */
 public function __construct($message, $code, $arg_name)
 {
     $this->_ori_message = $message;
     $message = $message .= " ({$arg_name})";
     parent::__construct($message, $code, ['arg_name' => $arg_name]);
 }
示例#6
0
 /**
  * 删除一篇文章
  * 
  * @param int $id
  * 
  * @throws \Exception\Msg
  * 
  * @return int
  */
 public static function destory($id)
 {
     $data = self::show($id);
     if (empty($data)) {
         throw new \Exception\Msg(_('文章不存在'));
     }
     User::validateAuth($data['uid']);
     //发布至Github中
     try {
         $publish_result = Publish::articleDestroy($id);
     } catch (\Exception\Api $e) {
         if ($e->getCode() != 404) {
             throw $e;
         }
     }
     $result = parent::destory($id);
     if ($result) {
         //计数器-1
         Counter\Article::decr($data['category_id']);
         Counter\Article::decr(0);
     }
     return $result;
 }
示例#7
0
 /**
  * 初始化对象
  *
  * @return \Api\Github\Respositories
  */
 public static function init()
 {
     return parent::init();
 }