PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://gitlab.com/ppapadatis/Videolearn
PHP | 189 lines | 137 code | 10 blank | 42 comment | 47 complexity | 7fe8c82d9b978c78ef1640a2b7ef59bf MD5 | raw file
  1. <?php
  2. //
  3. class NSP_GK4_Portal_Mode_5 {
  4. //
  5. var $parent;
  6. //
  7. function init($parent_obj) {
  8. $this->parent = $parent_obj;
  9. }
  10. //
  11. function output() {
  12. $renderer = new NSP_GK4_Layout_Parts();
  13. // detecting mode - com_content or K2
  14. $k2_mode = false;
  15. $vm_mode = false;
  16. //check the source
  17. if( $this->parent->config["data_source"] == 'k2_categories' ||
  18. $this->parent->config["data_source"] == 'k2_articles' ||
  19. $this->parent->config["data_source"] == 'all_k2_articles' ||
  20. $this->parent->config["data_source"] == 'k2_tags') {
  21. if($this->parent->config['k2_categories'] != -1){
  22. $k2_mode = true;
  23. }else{ // exception when K2 is not installed
  24. $this->parent->content = array(
  25. "ID" => array(),
  26. "alias" => array(),
  27. "CID" => array(),
  28. "title" => array(),
  29. "text" => array(),
  30. "date" => array(),
  31. "date_publish" => array(),
  32. "author" => array(),
  33. "cat_name" => array(),
  34. "cat_alias" => array(),
  35. "hits" => array(),
  36. "news_amount" => 0,
  37. "rating_sum" => 0,
  38. "rating_count" => 0,
  39. "plugins" => ''
  40. );
  41. }
  42. } elseif($this->parent->config["data_source"] == 'vm_categories' ||
  43. $this->parent->config["data_source"] == 'vm_products') {
  44. if($this->parent->config['vm_categories'] != -1){
  45. $vm_mode = true;
  46. }else{ // exception when VirtueMart is not installed
  47. $this->parent->content = array(
  48. "ID" => array(),
  49. "CID" => array(),
  50. "title" => array(),
  51. "text" => array(),
  52. "date" => array(),
  53. "date_publish" => array(),
  54. "price" => array(),
  55. "price_currency" => array(),
  56. "discount_amount" => array(),
  57. "discount_is_percent" => array(),
  58. "discount_start" => array(),
  59. "discount_end" => array(),
  60. "tax" => array(),
  61. "cat_name" => array(),
  62. "manufacturer" => array(),
  63. "manufacturer_id" => array(),
  64. "product_image" => array(),
  65. "news_amount" => 0
  66. );
  67. }
  68. }
  69. // tables which will be used in generated content
  70. $news_image_tab = array();
  71. $news_title_tab = array();
  72. // Generating content
  73. $uri =& JURI::getInstance();
  74. //
  75. for($i = 0; $i < count($this->parent->content["ID"]); $i++) {
  76. // GENERATING NEWS CONTENT
  77. if($k2_mode == FALSE && $vm_mode == FALSE){
  78. $news_header = $renderer->header($this->parent->config, $this->parent->content['ID'][$i], $this->parent->content['CID'][$i], $this->parent->content['title'][$i]);
  79. // GENERATING IMAGE
  80. $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]);
  81. }else if($vm_mode == FALSE){
  82. // GENERATING HEADER
  83. $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]);
  84. // GENERATING IMAGE
  85. $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]);
  86. } else {
  87. // GENERATING HEADER
  88. $news_header = $renderer->header_vm($this->parent->config, $this->parent->content['ID'][$i], $this->parent->content['CID'][$i], $this->parent->content['title'][$i]);
  89. // GENERATING IMAGE
  90. $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]);
  91. }
  92. // PARSING PLUGINS
  93. if($this->parent->config['parse_plugins'] == TRUE) {
  94. $news_textt = JHTML::_('content.prepare', $news_textt);
  95. }
  96. // CLEANING PLUGINS
  97. if($this->parent->config['clean_plugins'] == TRUE) {
  98. $news_textt = preg_replace("/\{.+?\}/", "", $news_textt);
  99. }
  100. // GENERATE CONTENT FOR TAB
  101. $news_image_content = '<div class="nspImageGallery">' . $news_image . '</div>';
  102. $news_generated_content = '<div class="nspHeadline">' . $news_header . '</div>';
  103. // creating table with news content
  104. if($news_image !== '') {
  105. array_push($news_image_tab, $news_image_content);
  106. array_push($news_title_tab, $news_generated_content);
  107. }
  108. }
  109. /** GENERATING FINAL XHTML CODE START **/
  110. // create instances of basic Joomla! classes
  111. $document = JFactory::getDocument();
  112. $uri = JURI::getInstance();
  113. // add stylesheets to document header
  114. if($this->parent->config["useCSS"] == 1) {
  115. $document->addStyleSheet( $uri->root().'modules/mod_news_pro_gk4/interface/css/style.portal.mode.5.css', 'text/css' );
  116. }
  117. // init $headData variable
  118. $headData = false;
  119. // add scripts with automatic mode to document header
  120. if($this->parent->config['useScript'] == 2) {
  121. // getting module head section datas
  122. unset($headData);
  123. $headData = $document->getHeadData();
  124. // generate keys of script section
  125. $headData_keys = array_keys($headData["scripts"]);
  126. // set variable for false
  127. $engine_founded = false;
  128. // searching phrase mootools in scripts paths
  129. if(array_search($uri->root().'modules/mod_news_pro_gk4/interface/scripts/engine.portal_mode_5.js', $headData_keys) > 0) {
  130. $engine_founded = true;
  131. }
  132. // if mootools file doesn't exists in document head section
  133. if(!$engine_founded){
  134. // add new script tag connected with mootools from module
  135. $document->addScript($uri->root().'modules/mod_news_pro_gk4/interface/scripts/engine.portal.mode.5.js');
  136. }
  137. }
  138. //
  139. require(JModuleHelper::getLayoutPath('mod_news_pro_gk4', 'content.portal.mode.5'));
  140. require(JModuleHelper::getLayoutPath('mod_news_pro_gk4', 'default.portal.mode.5'));
  141. }
  142. }
  143. //
  144. function Portal_Mode_5_getData($parent) {
  145. $db =& JFactory::getDBO();
  146. $output = array();
  147. if( $parent->config["data_source"] == "com_categories" ||
  148. $parent->config["data_source"] == "com_articles" ||
  149. $parent->config["data_source"] == "com_all_articles"){
  150. // getting instance of Joomla! com_content source class
  151. $newsClass = new NSP_GK4_Joomla_Source();
  152. // Getting list of categories
  153. $categories = ($parent->config["data_source"] != "com_all_articles") ? $newsClass->getSources($parent->config) : false;
  154. // getting content
  155. $amountOfArts = $parent->config['news_portal_mode_5_amount'];
  156. $output = $newsClass->getArticles($categories, $parent->config, $amountOfArts);
  157. } else if( $parent->config["data_source"] == "k2_categories" ||
  158. $parent->config["data_source"] == "k2_tags" ||
  159. $parent->config["data_source"] == "k2_articles" ||
  160. $parent->config["data_source"] == "all_k2_articles") {
  161. // getting insance of K2 source class
  162. $newsClass = new NSP_GK4_K2_Source();
  163. // Getting list of categories
  164. $categories = ($parent->config["data_source"] != "all_k2_articles") ? $newsClass->getSources($parent->config) : false;
  165. // getting content
  166. $amountOfArts = $parent->config['news_portal_mode_5_amount'];
  167. $output = $newsClass->getArticles($categories, $parent->config, $amountOfArts);
  168. } else {
  169. // getting insance of VM source class
  170. $newsClass = new NSP_GK4_VM_Source();
  171. // Getting list of categories
  172. $categories = $newsClass->getSources($parent->config);
  173. // getting content
  174. $amountOfProducts = $parent->config['news_portal_mode_5_amount'];
  175. $output = $newsClass->getProducts($categories, $parent->config, $amountOfProducts);
  176. }
  177. return $output;
  178. }
  179. /* EOF */