PageRenderTime 65ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/subscriptions/code/trunk/components/com_artofsubs/views/products/tmpl/rokfeaturetable.php

https://bitbucket.org/eddieajau/the-art-of-joomla-archive
PHP | 164 lines | 114 code | 27 blank | 23 comment | 15 complexity | 48be06d0172b5bba6d50b82ac57a9fc5 MD5 | raw file
  1. <?php
  2. /**
  3. * @version $Id: rokfeaturetable.php 567 2011-01-24 06:02:23Z eddieajau $
  4. * @package NewLifeInIT
  5. * @subpackage com_artofsubs
  6. * @copyright Copyright 2010 New Life in IT Pty Ltd. All rights reserved.
  7. * @license GNU General Public License version 2 or later.
  8. */
  9. // No direct access
  10. defined('_JEXEC') or die;
  11. // Include dependancies.
  12. JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
  13. JHtml::stylesheet('components/com_artofsubs/media/css/rokfeaturetable.css');
  14. JHtml::_('behavior.framework');
  15. JHtml::script('components/com_artofsubs/media/js/rokfeaturetable.js');
  16. // Preprocess the product items into a format that RokFeatureTable expects
  17. $data = array();
  18. $isGuest = $this->user->get('guest');
  19. // Guest need to register/login to subscribe
  20. if ($isGuest) {
  21. $uri = JFactory::getURI();
  22. $guestLink = JRoute::_('index.php?option=com_users&view=login&return='.base64_encode($uri));
  23. }
  24. $highlightCol = 0;
  25. $showDuration = $this->params->get('products-show_duration', 1);
  26. $showPromoPrice = $this->params->get('products-show_promo_price', 1);
  27. $showPromo1 = $this->params->get('products-show_promo_text1', 1);
  28. $showPromo2 = $this->params->get('products-show_promo_text2');
  29. $showPromo3 = $this->params->get('products-show_promo_text3');
  30. foreach ($this->items as $i => $item)
  31. {
  32. // Check if the user is subscribed to this product.
  33. $subscribed = isset($this->subscriptions[$item->id]);
  34. // If the product is featured, make this the highlighted column.
  35. if ($item->featured) {
  36. $highlightCol = $i + 1;
  37. }
  38. // Start a new column array.
  39. $col = array();
  40. // Product title.
  41. $row =
  42. $col['name'] = (object ) array(
  43. // Use the promo title first, and default to the real title.
  44. 'data' => $this->escape($item->params->get('promo_title', $item->title)),
  45. 'style' => 'font-size:150%'
  46. );
  47. // Product price.
  48. $col['price'] = (object ) array(
  49. 'data' => JHtml::_('currency.format', $item->price_buy).
  50. ($item->price_full > $item->price_buy ? ' <s>'.JHtml::_('currency.format', $item->price_full).'</s>' : null),
  51. 'sub' => $showPromoPrice ? $item->params->get('promo_text_price', '&nbsp;') : null
  52. );
  53. // Promo duration (row-3)
  54. if ($showDuration) {
  55. $col['row-3'] = (object ) array(
  56. 'data' => JText::sprintf('COM_ARTOFSUBS_SUBSCRIPTION_N_DAYS_ACCESS', $item->duration)
  57. );
  58. }
  59. // Promo text 1 (row-4)
  60. if ($showPromo1) {
  61. $col['row-4'] = (object ) array(
  62. 'data' => $item->params->get('promo_text1')
  63. );
  64. }
  65. // Subscribe button.
  66. $col['button-text'] = (object ) array(
  67. 'data' => $subscribed
  68. ? JText::_('COM_ARTOFSUBS_SUBSCRIPTION_RENEW_BUTTON')
  69. : JText::_('COM_ARTOFSUBS_SUBSCRIBE_BUTTON'),
  70. 'link' => $isGuest
  71. ? $guestLink
  72. : ($subscribed
  73. // ? JRoute::_(ArtofSubsHelperRoute::renew($this->subscriptions[$item->product_id]))
  74. ? JRoute::_(ArtofSubsHelperRoute::addToCart($item->id, $item->alias))
  75. : JRoute::_(ArtofSubsHelperRoute::addToCart($item->id, $item->alias))
  76. )
  77. );
  78. $data[] = $col;
  79. }
  80. // Make some variable shortcuts.
  81. $pageClass = $this->params->get('pageclass_sfx');
  82. ?>
  83. <?php if ($this->params->get('show_page_heading', 1)) : ?>
  84. <h1>
  85. <?php echo $this->escape($this->params->get('page_heading')); ?>
  86. </h1>
  87. <?php endif; ?>
  88. <?php if ($this->category) : ?>
  89. <h2><?php echo $this->escape($this->category->title); ?></h2>
  90. <?php echo $this->category->description; ?>
  91. <?php endif; ?>
  92. <?php
  93. // The following code is based on RokFeatureTable Copyright (C) 2007 - 2010 RocketTheme, LLC.
  94. $counter_col = 0;
  95. $counter_row = 0;
  96. $total_columns = count($data);
  97. ?>
  98. <div class="rokfeaturetable <?php echo $pageClass;?><?php echo ' col' . $total_columns;?>">
  99. <?php
  100. foreach ($data as $col):
  101. $counter_col++;
  102. $col_oddeven = !($counter_col % 2) ? ' ft-column-even' : ' ft-column-odd';
  103. $first = ($counter_col == 1) ? ' ft-column-first' : '';
  104. $last = ($counter_col == $total_columns) ? ' ft-column-last' : '';
  105. $highlight = ($counter_col == $this->params->get('highlight-col', 3)) ? ' ft-highlight' : '';
  106. ?>
  107. <div class="featuretable-col <?php echo $col_oddeven; ?><?php echo $first;?><?php echo $last;?><?php echo $highlight; ?>">
  108. <?php
  109. $counter_row = 0;
  110. foreach ($col as $cls => $row) :
  111. $counter_row++;
  112. $row_oddeven = (!($counter_row % 2) ? ' ft-row-even' : ' ft-row-odd');
  113. $top = $counter_row == 1 ? ' ft-row-top' : '';
  114. $bottom = $counter_row == sizeof($col) ? ' ft-row-bottom' : '';
  115. $cell_cls = " ft-cell-".$cls;
  116. if (isset($row->style)) $styles = " style='".$row->style."'";
  117. else $styles = "";
  118. ?>
  119. <div class="featuretable-cell<?php echo $row_oddeven;?><?php echo $top;?><?php echo $bottom;?><?php echo $cell_cls; ?>"<?php echo $styles; ?>>
  120. <div class="featuretable-cell-inner">
  121. <div class="featuretable-cell-data">
  122. <?php if (isset($row->link)): ?>
  123. <a href="<?php echo $row->link; ?>"><?php echo $row->data; ?></a>
  124. <?php else: ?>
  125. <?php echo $row->data; ?>
  126. <?php endif; ?>
  127. </div>
  128. <?php if (isset($row->sub)): ?>
  129. <div class="featuretable-cell-sub"><?php echo $row->sub; ?></div>
  130. <?php endif; ?>
  131. </div>
  132. </div>
  133. <?php endforeach; ?>
  134. </div>
  135. <?php endforeach; ?>
  136. </div>
  137. <div class="clear"></div>