/subscriptions/code/trunk/components/com_artofsubs/views/products/tmpl/rokfeaturetable.php
PHP | 164 lines | 114 code | 27 blank | 23 comment | 15 complexity | 48be06d0172b5bba6d50b82ac57a9fc5 MD5 | raw file
- <?php
- /**
- * @version $Id: rokfeaturetable.php 567 2011-01-24 06:02:23Z eddieajau $
- * @package NewLifeInIT
- * @subpackage com_artofsubs
- * @copyright Copyright 2010 New Life in IT Pty Ltd. All rights reserved.
- * @license GNU General Public License version 2 or later.
- */
- // No direct access
- defined('_JEXEC') or die;
- // Include dependancies.
- JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
- JHtml::stylesheet('components/com_artofsubs/media/css/rokfeaturetable.css');
- JHtml::_('behavior.framework');
- JHtml::script('components/com_artofsubs/media/js/rokfeaturetable.js');
- // Preprocess the product items into a format that RokFeatureTable expects
- $data = array();
- $isGuest = $this->user->get('guest');
- // Guest need to register/login to subscribe
- if ($isGuest) {
- $uri = JFactory::getURI();
- $guestLink = JRoute::_('index.php?option=com_users&view=login&return='.base64_encode($uri));
- }
- $highlightCol = 0;
- $showDuration = $this->params->get('products-show_duration', 1);
- $showPromoPrice = $this->params->get('products-show_promo_price', 1);
- $showPromo1 = $this->params->get('products-show_promo_text1', 1);
- $showPromo2 = $this->params->get('products-show_promo_text2');
- $showPromo3 = $this->params->get('products-show_promo_text3');
- foreach ($this->items as $i => $item)
- {
- // Check if the user is subscribed to this product.
- $subscribed = isset($this->subscriptions[$item->id]);
- // If the product is featured, make this the highlighted column.
- if ($item->featured) {
- $highlightCol = $i + 1;
- }
- // Start a new column array.
- $col = array();
- // Product title.
- $row =
- $col['name'] = (object ) array(
- // Use the promo title first, and default to the real title.
- 'data' => $this->escape($item->params->get('promo_title', $item->title)),
- 'style' => 'font-size:150%'
- );
- // Product price.
- $col['price'] = (object ) array(
- 'data' => JHtml::_('currency.format', $item->price_buy).
- ($item->price_full > $item->price_buy ? ' <s>'.JHtml::_('currency.format', $item->price_full).'</s>' : null),
- 'sub' => $showPromoPrice ? $item->params->get('promo_text_price', ' ') : null
- );
- // Promo duration (row-3)
- if ($showDuration) {
- $col['row-3'] = (object ) array(
- 'data' => JText::sprintf('COM_ARTOFSUBS_SUBSCRIPTION_N_DAYS_ACCESS', $item->duration)
- );
- }
- // Promo text 1 (row-4)
- if ($showPromo1) {
- $col['row-4'] = (object ) array(
- 'data' => $item->params->get('promo_text1')
- );
- }
- // Subscribe button.
- $col['button-text'] = (object ) array(
- 'data' => $subscribed
- ? JText::_('COM_ARTOFSUBS_SUBSCRIPTION_RENEW_BUTTON')
- : JText::_('COM_ARTOFSUBS_SUBSCRIBE_BUTTON'),
- 'link' => $isGuest
- ? $guestLink
- : ($subscribed
- // ? JRoute::_(ArtofSubsHelperRoute::renew($this->subscriptions[$item->product_id]))
- ? JRoute::_(ArtofSubsHelperRoute::addToCart($item->id, $item->alias))
- : JRoute::_(ArtofSubsHelperRoute::addToCart($item->id, $item->alias))
- )
- );
- $data[] = $col;
- }
- // Make some variable shortcuts.
- $pageClass = $this->params->get('pageclass_sfx');
- ?>
- <?php if ($this->params->get('show_page_heading', 1)) : ?>
- <h1>
- <?php echo $this->escape($this->params->get('page_heading')); ?>
- </h1>
- <?php endif; ?>
- <?php if ($this->category) : ?>
- <h2><?php echo $this->escape($this->category->title); ?></h2>
- <?php echo $this->category->description; ?>
- <?php endif; ?>
- <?php
- // The following code is based on RokFeatureTable Copyright (C) 2007 - 2010 RocketTheme, LLC.
- $counter_col = 0;
- $counter_row = 0;
- $total_columns = count($data);
- ?>
- <div class="rokfeaturetable <?php echo $pageClass;?><?php echo ' col' . $total_columns;?>">
- <?php
- foreach ($data as $col):
- $counter_col++;
- $col_oddeven = !($counter_col % 2) ? ' ft-column-even' : ' ft-column-odd';
- $first = ($counter_col == 1) ? ' ft-column-first' : '';
- $last = ($counter_col == $total_columns) ? ' ft-column-last' : '';
- $highlight = ($counter_col == $this->params->get('highlight-col', 3)) ? ' ft-highlight' : '';
- ?>
- <div class="featuretable-col <?php echo $col_oddeven; ?><?php echo $first;?><?php echo $last;?><?php echo $highlight; ?>">
- <?php
- $counter_row = 0;
- foreach ($col as $cls => $row) :
- $counter_row++;
- $row_oddeven = (!($counter_row % 2) ? ' ft-row-even' : ' ft-row-odd');
- $top = $counter_row == 1 ? ' ft-row-top' : '';
- $bottom = $counter_row == sizeof($col) ? ' ft-row-bottom' : '';
- $cell_cls = " ft-cell-".$cls;
- if (isset($row->style)) $styles = " style='".$row->style."'";
- else $styles = "";
- ?>
- <div class="featuretable-cell<?php echo $row_oddeven;?><?php echo $top;?><?php echo $bottom;?><?php echo $cell_cls; ?>"<?php echo $styles; ?>>
- <div class="featuretable-cell-inner">
- <div class="featuretable-cell-data">
- <?php if (isset($row->link)): ?>
- <a href="<?php echo $row->link; ?>"><?php echo $row->data; ?></a>
- <?php else: ?>
- <?php echo $row->data; ?>
- <?php endif; ?>
- </div>
- <?php if (isset($row->sub)): ?>
- <div class="featuretable-cell-sub"><?php echo $row->sub; ?></div>
- <?php endif; ?>
- </div>
- </div>
- <?php endforeach; ?>
- </div>
- <?php endforeach; ?>
- </div>
- <div class="clear"></div>