Exemplo n.º 1
0
 public function bGenBrief($sDest, $sBriefTag)
 {
     $sBriefTag = trim($sBriefTag, '.');
     if (0 == strlen($sBriefTag)) {
         return true;
     }
     list($type, $brief) = explode('.', $sBriefTag, 2);
     assert(isset($this->_aBriefConf[$type][$brief]));
     $master = Ko_Tool_Singleton::OInstance('SaeStorage')->read($this->_sDomain, $sDest);
     if (false === $master) {
         return false;
     }
     $sExt = pathinfo($sDest, PATHINFO_EXTENSION);
     $method = $this->_aBriefConf[$type][$brief]['crop'] ? 'VCrop' : 'VResize';
     $slave = Ko_Tool_Image::$method($master, '1.' . $sExt, $this->_aBriefConf[$type][$brief]['width'], $this->_aBriefConf[$type][$brief]['height'], Ko_Tool_Image::FLAG_SRC_BLOB | Ko_Tool_Image::FLAG_DST_BLOB);
     if (false === $slave) {
         return false;
     }
     list($name, $ext) = explode('.', $sDest, 2);
     $ret = Ko_Tool_Singleton::OInstance('SaeStorage')->write($this->_sDomain, $name . '.' . $sBriefTag . '.' . $ext, $slave);
     if (false === $ret) {
         return false;
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * @param Smarty|Ko_View_Smarty $oSmarty 
  */
 public function __construct($oSmarty = null)
 {
     if (null === $oSmarty) {
         $this->_oSmarty = Ko_Tool_Singleton::OInstance('Ko_View_Smarty');
     } else {
         $this->_oSmarty = $oSmarty;
     }
 }
Exemplo n.º 3
0
Arquivo: Rest.php Projeto: AllenLyu/ko
 public static function VInvoke($sApp, $sMethod, $sUri, $vInput = null, &$iErrno = 0, &$sError = '')
 {
     $uri = $sApp . '/' . $sUri;
     $rest = Ko_Tool_Singleton::OInstance('Ko_Apps_Rest');
     $ret = $rest->aCall($sMethod, $uri, $vInput);
     $iErrno = $ret['errno'];
     $sError = $ret['error'];
     return $ret['data'];
 }
Exemplo n.º 4
0
 public static function __callStatic($sName, $aArgs)
 {
     $class = get_called_class();
     if ('Facade' === substr($class, -6)) {
         $apiClass = substr($class, 0, -6) . 'Api';
         $api = Ko_Tool_Singleton::OInstance($apiClass);
         return call_user_func_array(array($api, lcfirst($sName)), $aArgs);
     }
     assert(0);
 }
Exemplo n.º 5
0
Arquivo: Base.php Projeto: AllenLyu/ko
 /**
  * 自动创建魔法函数
  *
  * 自动创建 $_smarty 对象 <code>Ko_View_Smarty</code>
  * 自动创建 $xxxApi 对象
  *
  * @return mixed
  */
 public function __get($sName)
 {
     if ($sName == '_smarty') {
         $this->_smarty = Ko_Tool_Singleton::OInstance('Ko_View_Smarty');
         return $this->_smarty;
     } else {
         if (substr($sName, -3) === 'Api') {
             $this->{$sName} = Ko_Tool_Object::OCreateFromRoot($this, $sName);
             return $this->{$sName};
         }
     }
     return null;
 }
Exemplo n.º 6
0
 /**
  * 创建对象,可以创建 $sFromModule 下的任意对象
  *
  * @return object
  */
 public static function OCreateFromModule($sFromModule, $sName)
 {
     // 分析子模块名和文件名
     list($sModule, $sFile) = Ko_Tool_Module::AGetSubModule($sName);
     // 构造类名
     if ($sModule !== '') {
         $sModule = Ko_Tool_Module::SGetRegularModuleName($sModule);
         $sClassName = 'K' . $sFromModule . '_' . $sModule . '_' . $sFile;
     } else {
         $sClassName = 'K' . $sFromModule . '_' . $sFile;
     }
     // 创建对象
     return Ko_Tool_Singleton::OInstance($sClassName);
 }
Exemplo n.º 7
0
 public function aGetMenuIdByAdminUid($iAdminUid)
 {
     $menuIds = array();
     $aRids = Ko_Tool_Singleton::OInstance('KShequ_Menu_roleUserApi')->aGetRidsIdBuyAdminUid($iAdminUid);
     if (!empty($aRids)) {
         $aRids = Ko_Tool_Utils::AObjs2ids(array_filter($this->aGetRoles($aRids), function ($v) {
             return $v['flag'] == KShequ_Menu_roleApi::FLAG_NORMAL;
         }), 'rid');
         if (!empty($aRids)) {
             foreach ($aRids as $iRid) {
                 $menuIds = array_merge($menuIds, Ko_Tool_Singleton::OInstance('KShequ_Menu_rolePrivacyApi')->aGetMenuIdsByRid($iRid));
             }
         }
         $menuIds = array_unique(Ko_Tool_Utils::AObjs2ids($menuIds, 'menu_id'));
     }
     return $menuIds;
 }
Exemplo n.º 8
0
 public static function AAdapter($datalist)
 {
     $newdatalist = array();
     $uids = array();
     foreach ($datalist as $v) {
         $uids[] = $v[0];
     }
     $infos = Ko_Tool_Singleton::OInstance('KUser_baseinfoApi')->aGetListByKeys($uids);
     $contentApi = new KContent_Api();
     $nicknames = $contentApi->aGetText(KContent_Api::USER_NICKNAME, $uids);
     foreach ($datalist as $k => $v) {
         $newdatalist[$k] = isset($infos[$v[0]]) ? $infos[$v[0]] : array();
         if (!empty($newdatalist[$k])) {
             $newdatalist[$k]['nickname'] = $nicknames[$v[0]];
             self::_VFillMoreInfo($newdatalist[$k], $v[1]);
         }
     }
     return $newdatalist;
 }
Exemplo n.º 9
0
Arquivo: Rest.php Projeto: AllenLyu/ko
 private function _aCall($sMethod, $sUri, $aInput)
 {
     $items = explode('/', $sUri);
     $this->_vKey = $this->_sId = array_pop($items);
     $this->_sResource = array_pop($items);
     $this->_sModule = implode('/', $items);
     $resConf = $this->_aLoadConf($this->_sModule, $this->_sResource);
     if ('' !== $this->_sId && !isset($resConf['unique'])) {
         throw new Exception('唯一键类型未定义', self::ERROR_UNIQUE_NOT_DEFINED);
     }
     $classname = $this->_sGetClassname($this->_sModule, $this->_sResource);
     if (!class_exists($classname)) {
         throw new Exception('资源还没有实现', self::ERROR_RESOURCE_NOT_IMPLEMENTED);
     }
     $api = Ko_Tool_Singleton::OInstance($classname);
     if ('' !== $this->_sId && method_exists($api, 'str2key')) {
         $this->_vKey = $api->str2key($this->_sId);
     }
     $funcname = $this->_sGetFuncInfo($sMethod, $resConf, $aInput, $para);
     $data = $this->_vGetData($api, $funcname, $aInput, $para);
     return $this->_vAdapterData($data, $funcname, $resConf, $aInput);
 }
Exemplo n.º 10
0
 /**
  * 创建对象,可以创建 $sFromModule 下的任意对象
  *
  * @return object
  */
 public static function OCreateFromModule($sFromModule, $sName)
 {
     // 分析子模块名和文件名
     list($sModule, $sFile) = Ko_Tool_Module::AGetSubModule($sName);
     // 构造类名
     $pos = strrpos($sFromModule, '\\');
     if (false !== $pos) {
         if ($sModule !== '') {
             $sModule = Ko_Tool_Module::SGetRegularModuleName($sModule);
             if ('\\' === substr($sFromModule, -1)) {
                 $sClassName = substr($sFromModule, 0, $pos + 1) . 'M' . $sModule . '_' . $sFile;
             } else {
                 $sClassName = substr($sFromModule, 0, $pos + 1) . 'M' . substr($sFromModule, $pos + 1) . '_' . $sModule . '_' . $sFile;
             }
         } else {
             if ('\\' === substr($sFromModule, -1)) {
                 $sClassName = substr($sFromModule, 0, $pos + 1) . 'M' . $sFile;
             } else {
                 $sClassName = substr($sFromModule, 0, $pos + 1) . 'M' . substr($sFromModule, $pos + 1) . '_' . $sFile;
             }
         }
     } else {
         if ($sModule !== '') {
             $sModule = Ko_Tool_Module::SGetRegularModuleName($sModule);
             $sClassName = 'K' . $sFromModule . '_' . $sModule . '_' . $sFile;
         } else {
             $sClassName = 'K' . $sFromModule . '_' . $sFile;
         }
     }
     // 创建对象
     return Ko_Tool_Singleton::OInstance($sClassName);
 }
Exemplo n.º 11
0
 private function _vPreAutoFetch($sFilePath)
 {
     if (empty($this->_aAutoInfo)) {
         return;
     }
     $aArr = $this->_aGetAutoArr($sFilePath);
     foreach ($aArr as $k => $v) {
         if ('L' === substr($k, -1)) {
             continue;
         }
         list($sRegName, $sFuncName, $aViewPara) = Ko_View_Str::AParseAutoStr($k);
         if (!class_exists($this->_aAutoInfo[$sRegName]['class'])) {
             continue;
         }
         $viewobj = Ko_Tool_Singleton::OInstance($this->_aAutoInfo[$sRegName]['class']);
         $funcname = 'vAuto_' . $sFuncName;
         if (!method_exists($viewobj, $funcname)) {
             continue;
         }
         $realk = Ko_View_Str::SAssembleAutoStr($sRegName, $sFuncName, $aViewPara);
         $aRegPara = isset($this->_aAutoInfo[$sRegName]['func'][$sFuncName]) ? $this->_aAutoInfo[$sRegName]['func'][$sFuncName] : null;
         $viewobj->{$funcname}($this, $k, isset($aArr[$realk]) ? $aArr[$realk] : array(), $aRegPara, $aViewPara);
     }
 }