Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

实战Ecos

4,554 views

Published on

从一个具体的实例开始讲解ecos

Published in: Technology
  • 下载文件和slide显示的不符啊?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

实战Ecos

  1. 1. ECOS shopex
  2. 2. • svn co http://svn.ecos.shopex.cn/ecos/ trunk/app/base base
  3. 3. • base/cmd • windows basecmd.bat
  4. 4. install uninstall search update createproject trace / man ... base:queue list base:task list base:task exec
  5. 5. createproject base/cmd createproject bookstore
  6. 6. index.php rpc.txt ecos app config config.php mapper.php URL - APP data
  7. 7. • app/notebook/dbschema/item.php <?php $columns = array( 'item_id' => array ('type' => 'number','required' => true ,'extra' =>'auto_increment','pkey' => true), 'item_subject' => array ('type' => 'varchar(100)'), 'item_content' => array ('type' => 'text'), 'item_posttime' => array ('type' => 'time'), 'item_email' => array ('type' => 'email'), ); $db['item'] = array('columns'=>$columns);
  8. 8. update base/cmd update
  9. 9. • app/notebook/controller/default.php public function index(){ $this->pagedata['items'] = $this->app->model('item')->getList('*'); $this->display('list.html'); }
  10. 10. • app/notebook/controller/default.php public function addnew(){ $this->begin(array('ctl'=>'default','act'=>'index')); $data = array( 'item_subject'=>$_POST['subject'], 'item_content'=>$_POST['content'], 'item_email'=>$_POST['email'], 'item_posttime'=>time(), ); $result = $this->app->model('item')->insert($data); $this->end($result); }
  11. 11. • app/notebook/controller/default.php public function index(){ $this->pagedata['items'] = $this->app->model('item')->getList('*'); // $gravatar = new notebook_gravatar; foreach($this->pagedata['items'] as $k=>$item){ $this->pagedata['items'][$k]['avatar'] = $gravatar->get_avatar($item['item_email']); } // $this->display('list.html'); }
  12. 12. • app/notebook/lib/gravatar.php <?php class notebook_gravatar{ function get_avatar($email){ return sprintf('http://www.gravatar.com/avatar/%s?s=48&r=x',md5 ($email)); } }
  13. 13. include ? • php5 , Autoload • , __autoload .
  14. 14. ECOS class class ABC AAA_BBB_CCC_DDD App app app/AAA /base /BBB /lib /CCC /statics /DDD.php /ABC.php
  15. 15. • app/notebook/view/list.html <dd> <!-- --> <img src="<{$item.avatar}>" style="float:left;margin- right:10px" /> <!-- --> <{$item.item_content}> </dd>
  16. 16. • ?
  17. 17. Service
  18. 18. Service • App • App
  19. 19. Service • kernel::service('service_name')->method() • foreach(kernel::servicelist('service_name') as $service_object){ ....
  20. 20. Service • $this->pagedata['items'] = $this->app->model('item')->getList('*'); // foreach(kernel::servicelist('notebook_addon') as $object){ foreach($this->pagedata['items'] as $k=>$item){ $this->pagedata['items'][$k]['addon'][] = $object->get_output($item); } } // $this->display('list.html');
  21. 21. Service • <{foreach from=$items item=item}> <dt> <{$item.item_subject}> <span class="date"> : <{$item.item_posttime|cdate}></span> </dt> <dd> <!-- --> <{foreach from=$item.addon item=block}> <{$block}> <{/foreach}> <!-- --> <{$item.item_content}> </dd> <{/foreach}>
  22. 22. Service • app/notebook/service.xml <services> <service id="notebook_addon"> <class>notebook_gravatar</class> </service> </services>
  23. 23. Service • base/app/cmd update
  24. 24. • app, notebook • app/alertnote
  25. 25. • app/alertnote/app.xml <app> <name> </name> <description> ...</description> <author> <name>somebody</name> <email>somebody@example.com</email> <url>http://www.example.com</url> </author> <depends> <app>notebook</app> </depends> </app>
  26. 26. • app/alertnote/services.xml <services> <service id="notebook_addon"> <class>alertnote_tools</class> </service> </services>
  27. 27. • app/alertnote/lib/tools.php <?php class alertnote_tools{ function get_output($item){ return '<span style="color:red" onclick="alert(' ! ! ! ')"> </span>'; } }
  28. 28. app/base/cmd install alertnote Installing... alertnote Installing service notebook_addon Application alertnote installed... ok.
  29. 29. : Rewrite Querystring index.php ?/part1/part2/part3
  30. 30. : Rewrite ECOS PATHINFO / index.php part1/part2/part3
  31. 31. app
  32. 32. App Base • • • • • key-value •
  33. 33. App setup • • config/deploy.xml
  34. 34. App dbeav • Entity-attribute-value model • • model::getList
  35. 35. App site • •
  36. 36. App content • CMS • Site
  37. 37. App image • • service ,
  38. 38. App desktop • • pam
  39. 39. App ectools • , , •
  40. 40. App b2c • , • pam
  41. 41. App pam • Pluggable Authentication Modules • • •
  42. 42. App b2c content site ectools image desktop pam dev dbeav base
  43. 43. ECOS • • • • ,
  44. 44. FAQ

×