PageRenderTime 46ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/mod_news_pro_gk4/gk_classes/portal_modes/gk.portal_mode_1.php

https://gitlab.com/ppapadatis/Videolearn
PHP | 237 lines | 144 code | 10 blank | 83 comment | 64 complexity | 9d4f29b51683bc105c54049c4665a611 MD5 | raw file
  1. <?php
  2. class NSP_GK4_Portal_Mode_1 {
  3. var $parent;
  4. function init($parent_obj) {
  5. $this->parent = $parent_obj;
  6. }
  7. function output() {
  8. $renderer = new NSP_GK4_Layout_Parts();
  9. // detecting mode - com_content or K2
  10. $k2_mode = false;
  11. $vm_mode = false;
  12. //check the source
  13. if($this->parent->config["data_source"] == 'k2_categories' ||
  14. $this->parent->config["data_source"] == 'k2_articles' ||
  15. $this->parent->config["data_source"] == 'k2_all_articles' ||
  16. $this->parent->config["data_source"] == 'k2_tags') {
  17. if($this->parent->config['k2_categories'] != -1){
  18. $k2_mode = true;
  19. } else { // exception when K2 is not installed
  20. $this->parent->content = array(
  21. "ID" => array(),
  22. "alias" => array(),
  23. "CID" => array(),
  24. "title" => array(),
  25. "text" => array(),
  26. "date" => array(),
  27. "date_publish" => array(),
  28. "author" => array(),
  29. "cat_name" => array(),
  30. "cat_alias" => array(),
  31. "hits" => array(),
  32. "news_amount" => 0,
  33. "rating_sum" => 0,
  34. "rating_count" => 0,
  35. "plugins" => ''
  36. );
  37. }
  38. } elseif($this->parent->config["data_source"] == 'vm_categories' ||
  39. $this->parent->config["data_source"] == 'vm_products') {
  40. if($this->parent->config['vm_categories'] != -1){
  41. $vm_mode = true;
  42. } else { // exception when VirtueMart is not installed
  43. $this->parent->content = array(
  44. "ID" => array(),
  45. "CID" => array(),
  46. "title" => array(),
  47. "text" => array(),
  48. "date" => array(),
  49. "date_publish" => array(),
  50. "price" => array(),
  51. "price_currency" => array(),
  52. "discount_amount" => array(),
  53. "discount_is_percent" => array(),
  54. "discount_start" => array(),
  55. "discount_end" => array(),
  56. "tax" => array(),
  57. "cat_name" => array(),
  58. "manufacturer" => array(),
  59. "manufacturer_id" => array(),
  60. "product_image" => array(),
  61. "news_amount" => 0
  62. );
  63. }
  64. }
  65. // tables which will be used in generated content
  66. $news_html_tab = array();
  67. // Generating content
  68. $uri = JURI::getInstance();
  69. $news_k2store = '';
  70. //
  71. for($i = 0; $i < count($this->parent->content["ID"]); $i++) {
  72. // GENERATING NEWS CONTENT
  73. if($k2_mode == FALSE){
  74. // GENERATING HEADER
  75. $news_header = $renderer->header($this->parent->config, $this->parent->content['ID'][$i], $this->parent->content['CID'][$i], $this->parent->content['title'][$i]);
  76. // GENERATING IMAGE
  77. $news_image = $renderer->image($this->parent->config, $uri, $this->parent->content['ID'][$i], $this->parent->content['IID'][$i], $this->parent->content['CID'][$i], $this->parent->content['text'][$i], $this->parent->content['title'][$i], $this->parent->content['images'][$i]) ;
  78. // GENERATE NEWS INFO
  79. $news_readmore = $renderer->readMore($this->parent->config, $this->parent->content['ID'][$i], $this->parent->content['CID'][$i]);
  80. // GENERATING TEXT
  81. $news_textt = $renderer->text($this->parent->config, $this->parent->content['ID'][$i], $this->parent->content['CID'][$i], $this->parent->content['text'][$i], $news_readmore);
  82. // GENERATE NEWS INFO
  83. $news_infoo = $renderer->info($this->parent->config, $this->parent->content['catname'][$i], $this->parent->content['CID'][$i], $this->parent->content['author'][$i], $this->parent->content['email'][$i], ($this->parent->config['date_publish'] == TRUE) ? $this->parent->content['date_publish'][$i] : $this->parent->content['date'][$i], $this->parent->content['hits'][$i], $this->parent->content['ID'][$i], $this->parent->content['rating_count'][$i], $this->parent->content['rating_sum'][$i]);
  84. // GENERATE NEWS INFO2
  85. $news_infoo2 = $renderer->info($this->parent->config, $this->parent->content['catname'][$i], $this->parent->content['CID'][$i], $this->parent->content['author'][$i], $this->parent->content['email'][$i], ($this->parent->config['date_publish'] == TRUE) ? $this->parent->content['date_publish'][$i] : $this->parent->content['date'][$i], $this->parent->content['hits'][$i], $this->parent->content['ID'][$i], $this->parent->content['rating_count'][$i], $this->parent->content['rating_sum'][$i], 2);
  86. } else {
  87. // GENERATING HEADER
  88. $news_header = $renderer->header_k2($this->parent->config, $this->parent->content['ID'][$i], $this->parent->content['alias'][$i], $this->parent->content['CID'][$i], $this->parent->content['cat_alias'][$i], $this->parent->content['title'][$i]);
  89. // GENERATING IMAGE
  90. $news_image = $renderer->image_k2($this->parent->config, $uri, $this->parent->content['ID'][$i], $this->parent->content['alias'][$i], $this->parent->content['CID'][$i], $this->parent->content['cat_alias'][$i], $this->parent->content['text'][$i], $this->parent->content['title'][$i]);
  91. // GENERATING READMORE
  92. $news_readmore = $renderer->readMore_k2($this->parent->config, $this->parent->content['ID'][$i], $this->parent->content['alias'][$i], $this->parent->content['CID'][$i], $this->parent->content['cat_alias'][$i]);
  93. // GENERATING TEXT
  94. $news_textt = $renderer->text_k2($this->parent->config, $this->parent->content['ID'][$i], $this->parent->content['alias'][$i], $this->parent->content['CID'][$i], $this->parent->content['cat_alias'][$i], $this->parent->content['text'][$i], $news_readmore);
  95. // GENERATE NEWS INFO
  96. $news_infoo = $renderer->info_k2($this->parent->config, $this->parent->content['cat_name'][$i], $this->parent->content['CID'][$i], $this->parent->content['cat_alias'][$i], $this->parent->content['author'][$i], $this->parent->content['author_id'][$i], $this->parent->content['email'][$i], ($this->parent->config['date_publish'] == TRUE) ? $this->parent->content['date_publish'][$i] : $this->parent->content['date'][$i], $this->parent->content['hits'][$i], $this->parent->content['ID'][$i], $this->parent->content['alias'][$i], $this->parent->content['comments'], $this->parent->content['rating_count'][$i], $this->parent->content['rating_sum'][$i]);
  97. // GENERATE NEWS INFO2
  98. $news_infoo2 = $renderer->info_k2($this->parent->config, $this->parent->content['cat_name'][$i], $this->parent->content['CID'][$i], $this->parent->content['cat_alias'][$i], $this->parent->content['author'][$i], $this->parent->content['author_id'][$i], $this->parent->content['email'][$i], ($this->parent->config['date_publish'] == TRUE) ? $this->parent->content['date_publish'][$i] : $this->parent->content['date'][$i], $this->parent->content['hits'][$i], $this->parent->content['ID'][$i], $this->parent->content['alias'][$i], $this->parent->content['comments'], $this->parent->content['rating_count'][$i], $this->parent->content['rating_sum'][$i], 2);
  99. } /*else {
  100. // GENERATING HEADER
  101. $news_header = $renderer->header_vm($this->parent->config, $this->parent->content['ID'][$i], $this->parent->content['CID'][$i], $this->parent->content['title'][$i]);
  102. // GENERATING IMAGE
  103. $news_image = $renderer->image_vm($this->parent->config, $this->parent->content['ID'][$i], $this->parent->content['CID'][$i], $this->parent->content['product_image'][$i], $this->parent->content['title'][$i]);
  104. // GENERATING READMORE
  105. $news_readmore = $renderer->readMore_vm($this->parent->config, $this->parent->content['ID'][$i], $this->parent->content['CID'][$i]);
  106. // GENERATING TEXT
  107. $news_textt = $renderer->text_vm($this->parent->config, $this->parent->content['ID'][$i], $this->parent->content['CID'][$i], $this->parent->content['text'][$i], $news_readmore);
  108. // GENERATE NEWS INFO
  109. $news_infoo = $renderer->info_vm($this->parent->config, $this->parent->content['ID'][$i], $this->parent->content['cat_name'][$i], $this->parent->content['CID'][$i], $this->parent->content['manufacturer'][$i], ($this->parent->config['date_publish'] == TRUE) ? $this->parent->content['date_publish'][$i] : $this->parent->content['date'][$i], $this->parent->content['comments']);
  110. // GENERATE NEWS INFO2
  111. $news_infoo2 = $renderer->info_vm($this->parent->config, $this->parent->content['ID'][$i], $this->parent->content['cat_name'][$i], $this->parent->content['CID'][$i], $this->parent->content['manufacturer'][$i], ($this->parent->config['date_publish'] == TRUE) ? $this->parent->content['date_publish'][$i] : $this->parent->content['date'][$i], $this->parent->content['comments'], 2);
  112. $news_k2store = $renderer->store_vm($this->parent->config, $this->parent->content['ID'][$i], $this->parent->content['CID'][$i], $this->parent->content['price'][$i], $this->parent->content['price_currency'][$i], $this->parent->content['discount_amount'][$i], $this->parent->content['discount_is_percent'][$i], $this->parent->content['discount_start'][$i], $this->parent->content['discount_end'][$i], $this->parent->content['tax'][$i], $this->parent->content['manufacturer_id'][$i]);
  113. } */
  114. // PARSING PLUGINS
  115. if($this->parent->config['parse_plugins'] == TRUE) {
  116. $news_textt = JHTML::_('content.prepare', $news_textt);
  117. }
  118. // CLEANING PLUGINS
  119. if($this->parent->config['clean_plugins'] == TRUE) {
  120. $news_textt = preg_replace("/\{.+?\}/", "", $news_textt);
  121. }
  122. // GENERATE CONTENT FOR TAB
  123. $news_generated_content = ''; // initialize variable
  124. //
  125. for($j = 1;$j < 7;$j++) {
  126. if($this->parent->config['news_header_order'] == $j) $news_generated_content .= $news_header;
  127. if($this->parent->config['news_image_order'] == $j) $news_generated_content .= $news_image;
  128. if($this->parent->config['news_text_order'] == $j) $news_generated_content .= $news_textt;
  129. if($this->parent->config['news_info_order'] == $j) $news_generated_content .= $news_infoo;
  130. if($this->parent->config['news_info2_order'] == $j) $news_generated_content .= $news_infoo2;
  131. if($this->parent->config['k2store_support'] == 1) {
  132. if($this->parent->config['k2store_order'] == $j) $news_generated_content .= $news_k2store;
  133. }
  134. }
  135. //
  136. if($this->parent->config['news_content_readmore_pos'] != 'after') {
  137. $news_generated_content .= $news_readmore;
  138. }
  139. // creating table with news content
  140. array_push($news_html_tab, $news_generated_content);
  141. }
  142. /** GENERATING FINAL XHTML CODE START **/
  143. // create instances of basic Joomla! classes
  144. $document = JFactory::getDocument();
  145. $uri = JURI::getInstance();
  146. // add stylesheets to document header
  147. if($this->parent->config["useCSS"] == 1) $document->addStyleSheet( $uri->root().'modules/mod_news_pro_gk4/interface/css/style.portal.mode.1.css', 'text/css' );
  148. // init $headData variable
  149. $headData = false;
  150. // add scripts with automatic mode to document header
  151. if($this->parent->config['useScript'] == 2) {
  152. // getting module head section datas
  153. unset($headData);
  154. $headData = $document->getHeadData();
  155. // generate keys of script section
  156. $headData_keys = array_keys($headData["scripts"]);
  157. // set variable for false
  158. $engine_founded = false;
  159. // searching phrase mootools in scripts paths
  160. if(array_search($uri->root().'modules/mod_news_pro_gk4/interface/scripts/engine.portal_mode_1.js', $headData_keys) > 0) $engine_founded = true;
  161. // if mootools file doesn't exists in document head section
  162. if(!$engine_founded){
  163. // add new script tag connected with mootools from module
  164. $headData["scripts"][$uri->root().'modules/mod_news_pro_gk4/interface/scripts/engine.portal.mode.1.js'] = "text/javascript";
  165. $document->setHeadData($headData);
  166. }
  167. }
  168. /*
  169. if($this->parent->config['k2store_support'] == 1) {
  170. // getting module head section datas
  171. $headData = $document->getHeadData();
  172. $headData_keys = array_keys($headData["scripts"]);
  173. $k2store_founded = false;
  174. // searching phrase mootools in scripts paths
  175. if(array_search($uri->root().'components/com_k2store/js/k2store.js', $headData_keys) > 0) $k2store_founded = true;
  176. // if mootools file doesn't exists in document head section
  177. if(!$k2store_founded){
  178. // add new script tag connected with mootools from module
  179. $headData["scripts"][$uri->root().'components/com_k2store/js/k2store.js'] = "text/javascript";
  180. $document->setHeadData($headData);
  181. }
  182. }
  183. */
  184. //
  185. require(JModuleHelper::getLayoutPath('mod_news_pro_gk4', 'content.portal.mode.1'));
  186. require(JModuleHelper::getLayoutPath('mod_news_pro_gk4', 'default.portal.mode.1'));
  187. }
  188. }
  189. function Portal_Mode_1_getData($parent) {
  190. $db = JFactory::getDBO();
  191. $output = array();
  192. if( $parent->config["data_source"] == "com_categories" ||
  193. $parent->config["data_source"] == "com_articles" ||
  194. $parent->config["data_source"] == "com_all_articles"){
  195. // getting instance of Joomla! com_content source class
  196. $newsClass = new NSP_GK4_Joomla_Source();
  197. // Getting list of categories
  198. $categories = ($parent->config["data_source"] != "com_all_articles") ? $newsClass->getSources($parent->config) : false;
  199. // getting content
  200. $amountOfArts = $parent->config['news_portal_mode_1_amount'];
  201. $output = $newsClass->getArticles($categories, $parent->config, $amountOfArts);
  202. } else if( $parent->config["data_source"] == "k2_categories" ||
  203. $parent->config["data_source"] == "k2_tags" ||
  204. $parent->config["data_source"] == "k2_articles" ||
  205. $parent->config["data_source"] == "all_k2_articles") {
  206. // getting insance of K2 source class
  207. $newsClass = new NSP_GK4_K2_Source();
  208. // Getting list of categories
  209. $categories = ($parent->config["data_source"] != "all_k2_articles") ? $newsClass->getSources($parent->config) : false;
  210. // getting content
  211. $amountOfArts = $parent->config['news_portal_mode_1_amount'];
  212. $output = $newsClass->getArticles($categories, $parent->config, $amountOfArts);
  213. $output['comments'] = $newsClass->getComments($parent->content, $parent->config);
  214. } /*else {
  215. // getting insance of K2 source class
  216. $newsClass = new NSP_GK4_VM_Source();
  217. // Getting list of categories
  218. $categories = $newsClass->getSources($parent->config);
  219. // getting content
  220. $amountOfProducts = $parent->config['news_portal_mode_1_amount'];
  221. $output = $newsClass->getProducts($categories, $parent->config, $amountOfProducts);
  222. $output['comments'] = $newsClass->getComments($parent->content, $parent->config);
  223. }
  224. */
  225. return $output;
  226. }
  227. /* EOF */