PageRenderTime 26ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/textyle/textyle.mobile.php

http://xe-textyle.googlecode.com/
PHP | 260 lines | 206 code | 51 blank | 3 comment | 40 complexity | 1b7f5f5ac9bf6cc9b487b8f73ce808be MD5 | raw file
  1. <?php
  2. require_once(_XE_PATH_ . 'modules/textyle/textyle.view.php');
  3. class textyleMobile extends textyleView {
  4. function init() {
  5. parent::init();
  6. $oTextyleModel = &getModel('textyle');
  7. if((preg_match("/TextyleTool/",$this->act) || $oTextyleModel->isAttachedMenu($this->act))) {
  8. Context::addJsFile("./common/js/jquery.js", true, '', -100000);
  9. Context::addJsFile("./common/js/x.js", true, '', -100000);
  10. Context::addJsFile("./common/js/common.js", true, '', -100000);
  11. Context::addJsFile("./common/js/js_app.js", true, '', -100000);
  12. Context::addJsFile("./common/js/xml_handler.js", true, '', -100000);
  13. Context::addJsFile("./common/js/xml_js_filter.js", true, '', -100000);
  14. Context::addCSSFile("./common/css/default.css", true, 'all', '', -100000);
  15. Context::addCSSFile("./common/css/button.css", true, 'all', '', -100000);
  16. }else{
  17. $template_path = sprintf("%sm.skins/%s/",$this->module_path, $this->module_info->mskin);
  18. if(!is_dir($template_path)||!$this->module_info->mskin) {
  19. $this->module_info->mskin = 'default';
  20. $template_path = sprintf("%sm.skins/%s/",$this->module_path, $this->module_info->mskin);
  21. }
  22. $this->setTemplatePath($template_path);
  23. }
  24. }
  25. function initService(&$oModule, $is_other_module = false)
  26. {
  27. parent::initService($oModule, true, true);
  28. $template_path = sprintf("%sm.skins/%s/",$this->module_path, $this->module_info->mskin);
  29. if(!is_dir($template_path)||!$this->module_info->mskin) {
  30. $this->module_info->mskin = 'default';
  31. $template_path = sprintf("%sm.skins/%s/",$this->module_path, $this->module_info->mskin);
  32. }
  33. $oTemplateHandler = &TemplateHandler::getInstance();
  34. $html = $oTemplateHandler->compile($oModule->getTemplatePath(), $oModule->getTemplateFile());
  35. Context::set('content', $html);
  36. $oModule->setTemplatePath($template_path);
  37. $oModule->setTemplateFile('textyle');
  38. }
  39. function dispTextyle(){
  40. $oTextyleModel = &getModel('textyle');
  41. $oTextyleController = &getController('textyle');
  42. $oDocumentModel = &getModel('document');
  43. $args->category_srl = Context::get('category_srl');
  44. $args->search_target = Context::get('search_target');
  45. $args->search_keyword = Context::get('search_keyword');
  46. $args->module_srl = $this->module_srl;
  47. $args->site_srl = $this->site_srl;
  48. $args->page = Context::get('page');
  49. $args->page = $args->page>0 ? $args->page : 1;
  50. Context::set('page',$args->page);
  51. // set category
  52. $category_list = $oDocumentModel->getCategoryList($this->module_srl);
  53. Context::set('category_list', $category_list);
  54. $document_srl = Context::get('document_srl');
  55. if($document_srl) {
  56. $oDocument = $oDocumentModel->getDocument($document_srl,false,false);
  57. if($oDocument->isExists()) {
  58. if($oDocument->get('module_srl')!=$this->module_info->module_srl ) return $this->stop('msg_invalid_request');
  59. Context::setBrowserTitle($this->textyle->get('browser_title') . ' Â? ' . $oDocument->getTitle());
  60. // meta keywords category + tag
  61. $tag_array = $oDocument->get('tag_list');
  62. if($tag_array) {
  63. $tag = htmlspecialchars(join(', ',$tag_array));
  64. } else {
  65. $tag = '';
  66. }
  67. $category_srl = $oDocument->get('category_srl');
  68. if($tag && $category_srl >0) $tag = $category_list[$category_srl]->title .', ' . $tag;
  69. Context::addHtmlHeader(sprintf('<meta name="keywords" content="%s" />',$tag));
  70. if($this->grant->manager) $oDocument->setGrant();
  71. } else {
  72. Context::set('document_srl','',true);
  73. $oDocument = $oDocumentModel->getDocument(0,false,false);
  74. }
  75. }
  76. if(!$document_srl){
  77. if($args->category_srl || ($args->search_target && $args->search_keyword)){
  78. $args->list_count = 10;
  79. $output = $oDocumentModel->getDocumentList($args, false, false);
  80. $document_list = $output->data;
  81. Context::set('page_navigation', $output->page_navigation);
  82. Context::set('document_list', $document_list);
  83. $this->setTemplateFile('list');
  84. }
  85. }
  86. if((!$oDocument || !$oDocument->isExists()) && !$document_list){
  87. $args->list_count = 1;
  88. $output = $oDocumentModel->getDocumentList($args, false, false);
  89. if($output->data && count($output->data)) $oDocument = array_pop($output->data);
  90. }
  91. if($oDocument && $oDocument->isExists()){
  92. $args->document_srl = $oDocument->document_srl;
  93. $output = executeQuery('textyle.getNextDocument', $args);
  94. if($output->data->document_srl) Context::set('prev_document', new documentItem($output->data->document_srl,false));
  95. $output = executeQuery('textyle.getPrevDocument', $args);
  96. if($output->data->document_srl) Context::set('next_document', new documentItem($output->data->document_srl,false));
  97. Context::set('oDocument', $oDocument);
  98. $this->setTemplateFile('read');
  99. Context::addJsFilter($this->module_path.'tpl/filter', 'insert_comment.xml');
  100. }
  101. }
  102. function dispTextyleProfile() {
  103. parent::dispTextyleProfile();
  104. $this->setTemplateFile('profile');
  105. }
  106. function dispTextyleCommentReply() {
  107. parent::dispTextyleCommentReply();
  108. $this->setTemplateFile('comment_form');
  109. }
  110. function dispTextylePasswordForm() {
  111. $type = Context::get('type');
  112. if($type=='delete_comment'){
  113. $callback_url = getUrl('','document_srl',Context::get('document_srl'
  114. ));
  115. }elseif($type=='delete_guestbook'){
  116. $callback_url = getUrl('','act','dispTextyleGuestbook','mid',$this->mid);
  117. }
  118. Context::set('callback_url', $callback_url);
  119. $this->setTemplateFile('input_password_form');
  120. }
  121. function dispTextyleGuestbookWrite() {
  122. $textyle_guestbook_srl = Context::get('textyle_guestbook_srl');
  123. if($textyle_guestbook_srl){
  124. $oTextyleModel = &getModel('textyle');
  125. $output = $oTextyleModel->getTextyleGuestbook($textyle_guestbook_srl);
  126. $guestbook_list = $output->data;
  127. if(is_array($guestbook_list) && count($guestbook_list)){
  128. if(!$guestbook_list[0]->parent_srl) Context::set('guestbook',$guestbook_list[0]);
  129. }
  130. }
  131. Context::addJsFilter($this->module_path.'tpl/filter', 'insert_guestbook.xml');
  132. $this->setTemplateFile('guestbook_form');
  133. }
  134. function dispTextyleGuestbook() {
  135. $page = Context::get('page');
  136. $page = $page ? $page : 1;
  137. Context::set('page',$page);
  138. $args->module_srl = $this->module_srl;
  139. $args->search_text = Context::get('search_text');
  140. $args->page = $page;
  141. $args->list_count = $this->textyle->getGuestbookListCount();
  142. $oTextyleModel = &getModel('textyle');
  143. $output = $oTextyleModel->getTextyleGuestbookList($args);
  144. Context::set('guestbook_list',$output->data);
  145. Context::set('page_navigation', $output->page_navigation);
  146. $this->setTemplateFile('guestbook');
  147. }
  148. function dispTextyleCategory() {
  149. $oDocumentModel = &getModel('document');
  150. $category_list = $oDocumentModel->getCategoryList($this->module_srl);
  151. Context::set('category_list', $category_list);
  152. $this->setTemplateFile('category');
  153. }
  154. function getTextyleCommentPage() {
  155. $document_srl = Context::get('document_srl');
  156. $oDocumentModel =& getModel('document');
  157. if(!$document_srl) return new Object(-1, "msg_invalid_request");
  158. $oDocument = $oDocumentModel->getDocument($document_srl);
  159. if(!$oDocument->isExists()) return new Object(-1, "msg_invalid_request");
  160. Context::set('oDocument', $oDocument);
  161. $oTemplate = new TemplateHandler;
  162. $html = $oTemplate->compile($this->getTemplatePath(), "comment.html");
  163. $this->add("html", $html);
  164. }
  165. function dispTextylePostWrite(){
  166. $oDocumentModel = &getModel('document');
  167. $document_srl = Context::get('document_srl');
  168. if($document_srl){
  169. $oDocument = $oDocumentModel->getDocument($document_srl,false,false);
  170. }
  171. if(!$oDocument || $oDocument->isExists()){
  172. $oDocument = $oDocumentModel->getDocument(0,false,false);
  173. }
  174. Context::set('oDocument',$oDocument);
  175. $category_list = $oDocumentModel->getCategoryList($this->module_srl);
  176. Context::set('category_list', $category_list);
  177. $this->setTemplateFile('post_form');
  178. Context::addJsFilter($this->template_path.'filter', 'insert_mpost.xml');
  179. }
  180. function dispTextyleMenu(){
  181. $menu = array();
  182. $menu['Home'] = getFullSiteUrl($this->textyle->domain);
  183. $menu['Profile'] = getSiteUrl($this->textyle->domain,'','mid',$this->module_info->mid,'act','dispTextyleProfile');
  184. $menu['Guestbook'] = getSiteUrl($this->textyle->domain,'','mid',$this->module_info->mid,'act','dispTextyleGuestbook');
  185. //$menu['Tags'] = getSiteUrl($this->textyle->domain,'','mid',$this->module_info->mid,'act','dispTextyleTag');
  186. $args->site_srl = $this->site_srl;
  187. $output = executeQueryArray('textyle.getExtraMenus',$args);
  188. if($output->toBool() && $output->data){
  189. foreach($output->data as $v){
  190. $menu[$v->name] = getUrl('','mid',$v->mid);
  191. }
  192. }
  193. $logged_info = Context::get('logged_info');
  194. if($logged_info->is_site_admin) $menu['Write Post'] = getSiteUrl($this->textyle->domain,'','mid',$this->module_info->mid,'act','dispTextylePostWrite');
  195. Context::set('menu',$menu);
  196. $this->setTemplateFile('menu');
  197. }
  198. function procTextylePostWrite(){
  199. $logged_info = Context::get('logged_info');
  200. if(!$logged_info->is_site_admin) return new Object(-1,'msg_invalid_request');
  201. $args = Context::getRequestVars();
  202. $args->content = $args->content_text;
  203. $args->module_srl = $this->module_srl;
  204. $oTextyleController = &getController('textyle');
  205. $output = $oTextyleController->insertPost($args);
  206. return $output;
  207. }
  208. }
  209. ?>