1 SDK Class 1.1 상속관계 1.1.1 Is-a 관계 Controller_Type_ Parent_Base Controller_Type_ Rest Controller_Type_ Parent_Template Controller_ Api Controller_Type_ View Controller_Type_ Xans Controller_ Admin Controller_Type_ Exec Controller_ Front Controller_ AdminExec Controller_ FrontExec 1.1.2 Has-a 관계 ApplicationInterface Request ApplicationInterface Response Service Controller_Type_ Parent_Base Storage RedisSdk Language Upload 1
Controller_Type_ Parent_Template C_T_P_T Fetcher C_T_P_T UIPackage 1.2 Function Library 1.2.1 class Controller_Type_Parent_Base getargs mixed getargs( $sname ) URL 매개변수값을반환합니다. string $sname 반환할매개변수의값의키를입력합니다. [ URL ] http://cafe24.com?no=3 $ino = $this->getargs('no'); $ino -> 3 setstatuscode object setstatuscode( $istatuscode ) 현재페이지의상태값을설정합니다. integer $istatuscode 설정할상태값을입력합니다. $this->setstatuscode(200); StatusCode -> 200 getstatuscode 2
int getstatuscode() 현재페이지의상태값을인트형으로반환합니다. $istatuscode = $this->getstatuscode(); $istatuscode -> 200 setmessage object setmessage( $smessage ) HTTP 메시지를설정합니다. string $smessage 설정할 HTTP 메시지를입력합니다. $this->setmessage('interface Error!'); Message -> Interface Error! getmessage string getmessage() HTTP 메시지를가져옵니다. $this->setmessage('ok.'); $smessage = $this->getmessage(); $smessage -> 'Ok.' getinterface string getinterface() 현재페이지의 Interface 를반환합니다. $sinterface = $this->getinterface(); $sinterface -> 'Index' 3
getlangcode string getlangcode() 현재페이지의 Language Code 를반환합니다. $slangcode = $this->getlangcode(); $slangcode -> 'ko' 1.2.2 class Controller_Type_Rest get get( $args ) Rest Api 의 GET Method array $args URL 매개변수 post post( $args ) Rest Api 의 POST Method array $args URL 매개변수 put put( $args ) Rest Api 의 PUT Method array $args URL 매개변수 delete 4
delete( $args ) Rest Api 의 DELETe Method array $args URL 매개변수 1.2.3 class Controller_Type_Parent_Template assign object assign( $sassign, $mdata ) php 데이터를뷰로 fetch 합니다. string $sassign 설정할키를입력합니다. mixed $mdata fetch 할데이터를입력합니다. [ tpl ] <div><?php echo $title?></div> $this->assign( 'title', 'Assign Func' ); Output -> 'Assign Func' writejs object writejs( $scontent ) JavaScript 를 php 에서직접사용합니다. string $scontent 사용할 JavaScript를문자열로입력합니다. $this->writejs( 'alert("sdk writejs")' ); JS -> alert('sdk writejs'); writecss object writecss( $scontent ) CSS 를 php 에서직접사용합니다. 5
string $scontent 사용할 CSS를문자열로입력합니다. $this->writecss( '#SDK{ color : blue; }' ); CSS -> #SDK{ color : blue; }; importjs object importjs ( $sfile, $afetchdata=false, $sappendtype='main', $spath=sdk_dir_app_resource_js ) resource/js 경로의 js 파일을 import 합니다. string $sfile import 하고자하는 resource/js 경로에위치한 js 파일의이름을입력합니다. array $afetchdata js 파일에서사용할 php 데이터를 key, value 의배열로입력합니다. string $sappendtype append type을구분합니다. ( before main after ) String $spath 기본경로를설정합니다. $this->importjs('sample1'); resource/js/sample1.js import [ js/sample2.js ] var sdata = <?php echo $key?> [ js ] $this->importjs('sample2', array( 'key'=>'value'), 'main' ); resource/js/sample2.js import, fetchdata use sdata -> 'value' importcss object importcss( $sfile, $sappendtype='main', $spath=sdk_dir_app_resource_css ) resource/css 경로의 css 파일을 import 합니다. string $sfile import 하고자하는 resource/css 경로에위치한 css 파일의이름을입력합니다. string $sappendtype append type을구분합니다. ( before main after ) String $spath 6
기본경로를설정합니다. $this->importcss('sample'); resource/js/sample.css import externaljs object externaljs( $surl, $sappendtype='main', $scharset='utf-8' ) 외부 URL의 js파일을 import 합니다. string $sfile import 하고자하는 js URL을입력합니다. string $sappendtype append type을구분합니다. ( before main after ) String $scharset Content Character Set을입력합니다. $this->externaljs('http://www.google.com/jsapi'); 'http://www.google.com/jsapi' import $this->externaljs('http://code.jquery.com/ui/1.9.2/jquery-ui.js'); 'http://code.jquery.com/ui/1.9.2/jquery-ui.js' import externalcss object externalcss( $surl, $sappendtype='main', $scharset='utf-8' ) 외부 URL의 js파일을 import 합니다. string $sfile import 하고자하는 CSS URL을입력합니다. string $sappendtype append type을구분합니다. ( before main after ) String $scharset Content Character Set을입력합니다. $this->externalcss('http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css'); 'http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css' import 7
setlocation object setlocation( $slocation ) 현재페이지를설정한 Location으로 redirect 합니다. string $slocation redirect 할 Location URL을입력합니다. $this->setlocation('http://cafe24.com'); redirect -> 'http://cafe24.com' $this->setlocation('index'); redirect -> 'http:// 앱아이디.app-sdk-xxx.cafe24.com/ 현재컨트롤러 /index' getlocation string getlocation() 설정한 Location 을가져옵니다. $this->setlocation('http://cafe24.com'); $slocation = $this->getlocation(); $slocation -> 'http://cafe24.com' 1.2.4 class Controller_Type_Parent_Template UIPackage setdriver object setdriver( $sdriver=self::driver_default ) UIPackage Driver 를설정합니다. string $sdriver 설정할 Driver를입력합니다. ( 현재 JQUERY 만지원합니다.) $this->uipackage->setdirver('user_driver'); UI Driver -> 'User_Driver' 8
getdiver string getdriver() 설정한 Driver를가져옵니다. $sdriver = $this->uipackage->getdriver(); $sdriver -> 'Jquery addplugin object addplugin( $splugin ) UIPackage 플러그인을추가합니다. string $splugin 추가할플러그인을입력합니다. Available Popup, DragDrop, Calendar, ColorPicker, Tooltip, Treeview, Paging, NumberFormat, Flash, DateUtil, Effect, Accordian, Tab, Dialog, Slider, Sortable, Selectable, Resizable, Autocomplete, DatePicker, $this->uipackage->addplugin('popup'); Popup 플러그인추가 getplugin array getplugin() 추가한플러그인배열로반환합니다. $this->uipackage->addplugin('calendar'); $aplugin = $this->uipackage->getplugin(); $aplugin-> array( 'Calendar'=>'Calendar' ) 9
removeplugin object removeplugin( $splugin ) 추가한플러그인을삭제합니다. string $splugin 삭제할 Plugin을입력합니다. $this->uipackage->addplugin('popup'); $this->uipackage->removeplugin('popup'); $aplugin = $this->uipackage->getplugin(); $aplugin -> array() removeall object removeall() 추가한플러그인을전부삭제합니다. $this->uipackage->addplugin('slider'); $this->uipackage->addplugin('tab'); $this->uipackage->removeall(); Plugin -> null 1.2.5 class Controller_Type_View setlayout object setlayout( $sfile ) Layout을설정합니다. string $sfile 설정하고자하는 resource/layout/ 위치의 tpl파일의이름을입력합니다. $this->setlayout('default'); resource/layout/default.tpl layout setting 10
view boolean view( $sfile=null, $slayout=false, $afetchdata=array() ) 해당 tpl을화면에출력합니다. string $sfile 설정하고자하는 resource/layout/ 위치의 tpl파일의이름을입력합니다. string $slayout 설정한 Layout에서사용하는 Key를입력합니다. setlayout 함수와사용할때적용됩니다. array $afetchdata tpl 파일에서사용할 php 데이터를 key, value 의배열로입력합니다. $this->view('index'); resource/tpl/index.tpl view setting class adminregister $this->view(); resource/tpl/register.tpl view setting [ layout/default.tpl ] <?php echo $menu;?> [ layout ] [ tpl/headermenu.tpl ] <ul> <li>menu1</li> <li>menu2</li> <li>menu3</li> </ul> [ tpl ] $this->setlayout('default'); $this->view('headermenu', 'menu'); default.tpl layout setting, layout assign key->'menu', value->headermenu.tpl [ tpl/index.tpl ] <p> <?php echo $title?> </p> [ tpl ] $this->view('index', false, array('title'=>'view Function') ); index.tpl view setting, fetchdata use 11
1.2.6 class Controller_Type_Xans isloop boolean isloop() Front 스마트디자인에반복문을검사합니다. [ SDE demo.html ] <ul module="appid_action"> <li>{$sample}</li> <li>{$sample}</li> <li>{$sample}</li> </ul> [ SDE ] $bloop = $this->isloop(); $bloop -> true getloop integer getloop() Front 스마트디자인에반복문의개수를반환합니다. [ SDE demo.html ] <ul module="appid_action"> <li>{$sample}</li> <li>{$sample}</li> <li>{$sample}</li> </ul> [ SDE ] $iloopcount = $this->getloop(); $iloopcount -> 3 getsequence integer getsequence() Front 스마트디자인에모듈 Seq를반환합니다. [ SDE demo.html ] <div module="appid_action_7"> {$sample} </div> 12
[ SDE ] $isequence = $this->getsequence(); $isequence -> 7 getoption mixed getoption( $sname=null ) Front 스마트디자인에주석옵션을반환합니다. [ SDE demo.html ] <div module="appid_action"> <!-- $count = 5 $title = Option Func --> {$sample} </div> [ SDE ] $icount = $this->getoption('count'); $aoption = $this->getoption(); $icount -> '5', $aoption -> array( 'count' => '5', 'title' => 'Option Func' ) loopfetch object loopfetch( $aloopdata=array() ) Front 스마트디자인에반복데이터 ( 2차원배열 ) 을 fetch 합니다. array $sloopdata fetch 할데이터를 2차원배열형태로입력합니다. [ SDE demo.html ] <table> <tbody module="appid_action"> <tr> <td>{$no}</td> <td>{$title}</td> <td>{$name}</td> </tr> <tr> <td>{$no}</td> <td>{$title}</td> <td>{$name}</td> 13
</tr> <tr> <td>{$no}</td> <td>{$title}</td> <td>{$name}</td> </tr> </tbody> </table> [ SDE ] $aloopdata = array( array ( 'no'=>'1', 'title'=>'title1', 'name'=>'name1'), array ( 'no'=>'2', 'title'=>'title2', 'name'=>'name2'), array ( 'no'=>'3', 'title'=>'title3', 'name'=>'name3'), array ( 'no'=>'4', 'title'=>'title4', 'name'=>'name4') ); $this->loopfetch( $aloopdata ); Output -> 1 Title1 Name1 2 Title2 Name2 3 Title3 Name3 4 Title4 Name4 1.2.7 class ApplicationInterfaceRequest gethttpserverenv mixed gethttpserverenv( $sname=null ) Server 환경을배열형태로반환합니다. string $sname 반환받을 Server 환경의항목을입력합니다. null 입력시서버환경전부를반환합니다. Available 'QUERY_STRING', 'UNIQUE_ID', 'HTTP_HOST', 'HTTP_REFERER', 'HTTP_USER_AGENT', 'REQUEST_URI', 'REQUEST_TIME', 'SCRIPT_URL', 'SCRIPT_URI', 'SERVER_NAME', 'SERVER_ADDR', 'SERVER_PORT', 'REMOTE_ADDR', 'REMOTE_HOST', 'REMOTE_PORT' $aserver = $this->request->gethttpserverenv(); $sserver_port = $this->request->gethttpserverenv( 'SERVER_PORT' ); $aserver -> array ( 'QUERY_STRING' => '_INTERFACE_TYPE=admin&_INTERFACE_CLASS=index', 'UNIQUE_ID' => 'UPrt1X8WWEEATCEvEpMAWDW0' 'REMOTE_PORT' => '54496' ) $sserver_port -> '80' 14
getsession mixed getsession( ) 세션을반환합니다. $_SESSION['title'] = 'getsession Func'; ( Save session ) $asession = $this->request->getsession(); $asession -> array ( 'title' => 'getsession Func' ) gettimezone string gettimezone() TimeZone을반환합니다. $stimezone = $this->request->gettimezone(); $stimezone -> Asia/Seoul getmethod string getmethod() Method를반환합니다. $smethod = $this->request->getmethod(); $smethod -> GET getappid string getappid() 앱아이디를반환합니다. $aappid = $this->request->getappid(); $aappid -> 해당앱의앱아이디 getargs array getargs() Argument 배열을반환합니다. 15
[ URL ] http://cafe24.com?no=1&title=getargsfunc $aargument = $this->request->getargs(); $aargument -> array( 'No' => '1', 'Title' => 'getargsfunc' ) getlang array getlang() Language를반환합니다. $slang = $this->request->getargs(); $slang -> 'ko' getservice ApplicationInterfaceRequest Service_Parent getservice() ApplicationInterfaceRequest Service_Parent 객체를반환합니다. $oservice = $this->request->getservice(); $oservice -> array( "ServiceUserSeq":protected => '3', "ServiceUserID":protected => 'guest', "ServiceType":protected => 'ec19' ); gettype ApplicationInterfaceRequest Type_Parent gettype() ApplicationInterfaceRequest Type_Parent 객체를반환합니다. $otype = $this->request->gettype(); $otype -> array( "Request":protected => object(applicationinterfacerequest)( ){ }, "sclasstype":protected => 'admin', "sclassname":protected => 'index' ); isverify boolean isverify() 앱의 verify 유무를검사합니다. $bverify = $this->request->isverify(); $bverify -> false true 16
getdomain string getdomain() 현재도메인을반환합니다. $sdomain = $this->request->getdomain(); $sdomain -> 도메인이름 1.2.8 class Service api mixed Api( $suri, $a=array() ) Api를호출합니다. string $suri 호출하고자하는 Api의 URI를입력합니다. array $a Api에맞는파라미터를입력합니다. $ashopcategorydata = $this->service->api('sdk/category'); $ashopcategorydata -> Shopping Mall Data $aproductdata = $this->service->api('sdk/categoryproduct', array('category_no'=>3) ); $aproductdata -> Product Data by Category_No 3 islogin boolean islogin() 로그인유무를검사합니다. Logged in as 'Guest1234' $blogin = $this->service->islogin(); $blogin -> true 17
getuserid mixed getuserid() 로그인되어있는 User ID를반환합니다. Logged in as 'Guest1234' $suserid = $this->service->getuserid(); $suserid -> 'Guest1234' getcategoryurl mixed getcategoryurl($scategoryno, $sdomain=null) 서비스카테고리 URL을반환합니다. string $scategoryno 서비스카테고리번호 String $sdomain 지정된도메인. 값이지정되지않을경우 ID.cafe24.com 으로처리 $scategoryurl = $this->service->getcategoryurl('5'); $scategoryurl -> //devsdk01.cafe24.com/product/list.html?cate_no=5 $scategoryurl = $this->service->getcategoryurl('5', aaa.com ); $scategoryurl -> //aaa.com/product/list.html?cate_no=5 getproducturl mixed getproducturl($sproductno, $sdomain=null) 서비스상품상세 URL을반환합니다. string $sproductno 서비스상품번호 String $sdomain 지정된도메인. 값이지정되지않을경우 ID.cafe24.com 으로처리 $sproducturl = $this->service->getproducturl('7'); $sproducturl -> //devsdk01.cafe24.com/product/detail.html?product_no=7 $sproducturl = $this->service->getproducturl('7', aaa.com ); $sproducturl -> //aaa.com/product/detail.html?product_no=7 18
getuserseq mixed getuserseq() 로그인되어있는 User Seq를반환합니다. Logged in as 'Guest1234' $iuserseq = $this->service->getuserseq(); $iuserseq -> '24' 1.2.9 class Upload isupload boolean isupload() 파일업로드의유무를검사합니다. uploaded file name 'file_5' $bupload = $this->upload->isupload(); $bupload -> true uploadedfile mixed uploadedfile( $sfilename ) 업로드된파일데이터를반환합니다. string $sname 업로드파일데이터를얻을파일이름을입력합니다. uploaded file name 'file_5' $afile = $this->upload->uploadedfile('file_5'); $afile -> Data by 'file_5' 19
uploadedfiles mixed uploadedfiles( $sname=null ) 업로드된파일데이터를전부를반환합니다. string $sname 하나의업로드파일데이터를얻을때파일이름을입력합니다. null 입력시업로드된파일데이터전부를반환합니다. uploaded file name 'file_5' $afile = $this->upload->uploadedfiles(); $afile -> Data by 'file_5' removeuploadedfiles boolean removeuploadedfiles() 업로드된파일데이터를삭제합니다. uploaded file name 'file_5' $this->upload->removeuploadedfiles(); uploadedfiles removed removeuploadedall boolean removeuploadedall() 업로드된모든것을삭제합니다. $this->upload->removeuploadedall(); Upload everything removed 20
moveuploadedfile mixed moveuploadedfile( $stmpname, $spath, $sname ) 업로드된파일을 Storage에이동 ( 생성 ) 합니다. string $stmpname 업로드된파일의 TmpName을입력합니다. string $spath Storage에생성할경로를입력합니다. string $sname Storage에생성할파일이름을입력합니다. uploaded file name 'file_5' $afile = $this->upload->uploadedfiles(); $auploadedfile = $afile['file_5']; $this->upload->moveuploadedfile( $auploadedfile['tmpname'], 'myfile/', 'newfile.txt' ); storage/myfile/newfile.txt has been created Info jpg,jpeg,gif,png,bmp,tif,raw,psd,pdd,pdf,swi,swf,fla,ai,flv,avi,asf,wav,wmv,wma,mid,mp3,m p4,mpeg,xls,xlsx,csv 스토리지에는위에표시된확장자의파일만사용할수있습니다. 1.2.10 class Storage Storage 클래스는 php Storage 연관함수를제공합니다. Available Function file, file_exists, file_get_contents, file_put_contents, fileatime, filectime, filemtime, filesize, filetype, getimagesize, is_dir, is_file, mkdir, rmdir, scandir, stat, tmpfile, unlink $this->storage->function( $param1, $param2 ); Reference http://php.net/ jpg,jpeg,gif,png,bmp,tif,raw,psd,pdd,pdf,swi,swf,fla,ai,flv,avi,asf,wav,wmv,wma,mid,mp3,m p4,mpe,xls,xlsx,csv 스토리지에는표시된확장자의파일만사용할수있습니다. 21
1.2.11 class RedisSdk RedisSdk 클래스는 Redis Commands를제공합니다. Available Function SET, GET, INCR, DEL, RPUSH, LRANGE, LINDEX, LSET, LLEN, LREM more function exist $this->redis->function( $param1, $param2 ); Reference http://redis.io/commands 22
23