<?php
/**
 * @name          : Joomla Social Pinboard
 * * @version	  : 2.0
 * @package       : apptha
 * @since         : Joomla 1.5
 * @author        : Apptha - http://www.apptha.com
 * @copyright     : Copyright (C) 2011 Powered by Apptha
 * @license       : http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
 * @abstract      : Social Pinboard Component categories view
 * @Creation Date : March 2013
 * @Modified Date : March 2013
 * */
// No direct Access
defined('_JEXEC') or die('Restricted access');
$document = JFactory::getDocument();
//add the scripts and stylesheets
$document->addStyleSheet('components/com_wishlogue/css/facebox.css');
$document->addStyleSheet('components/com_wishlogue/css/style.css');
$document->addStyleSheet('components/com_wishlogue/css/reset.css');
$document->addStyleSheet('components/com_wishlogue/css/pinboard.css');

//get the builtin function values
$app = JFactory::getApplication();
$config = JFactory::getConfig();
$templateparams = $app->getTemplate(true)->params; // get the tempalte
$sitetitle = $templateparams->get('sitetitle');
if (isset($sitetitle)) {
    $document->setDescription($sitetitle);
    $document->setTitle($sitetitle);
} else {
    $sitetitle = $config->get('sitename');
    $document->setDescription($sitetitle);
    $document->setTitle($sitetitle);
}
$user = JFactory::getUser();
//declare variables
$userid = $user->id;
$categories = $this->categories;
?>
<script>var scr = jQuery.noConflict();</script>
<div id="CategoryIndex">
    <div class="header">
        <h2 class="catetittle"> <?php echo JText::_('COM_WISHLOGUE_DISCOVER_IMAGES_TO_PIN'); ?></h2>
        <!-- <p><?php //echo JText::_('COM_WISHLOGUE_BROWSE_CATEGORIES'); ?></p> -->
    </div>
    <ul class="categories">
        <?php
        for ($i = 0; $i < count($categories); $i++) {
            if ($i % 2 == 0) {
                $class_type = "odd";
            } else {
                $class_type = "even";
            }
            $catid = $categories[$i]->category_id;
            //$resultuserfollow = wishlogueModelallcatalogues::getPins($catid);
            $getBoardPins = wishlogueModelallcatalogues::getPins($catid);

            ?>
            <li class="category <?php echo $class_type; ?>">
                    <div class="title">
                        <h3>
                           <a href="<?php echo JRoute::_('index.php?option=com_wishlogue&amp;view=home&cat_id=' . $categories[$i]->category_id, true); ?>"> <?php echo strtoupper($categories[$i]->category_name . '<font>*</font>' . JText::_('COM_WISHLOGUE_LOGUES')); ?></a>
                        </h3>
                    </div>
                
				
				<div class="images_pin_no_img_new">
                    <?php

                                $j = 0;
                                foreach ($getBoardPins as $pin) {
									$wishLink = JRoute::_('index.php?option=com_wishlogue&view=wish&pinid=' . $pin->pin_id);
									$wishLinkHREF = '';
									if( $pin->pin_id > 0 ) {
										$wishLinkHREF = " href='$wishLink' ";
									}
									$jmgSrc = '';
                                    $jmgSrc1 = '';
                                    if ($pin->link_type == 'youtube' || $pin->link_type == 'vimeo') {
                                        $jmgSrc = ' src = "' . $pin->pin_image . '" ';
                                        $jmgSrc1 = $pin->pin_image;
                                    } else if($pin->pin_image != ''){
                                        $jmgSrc = ' src = "' . JURI::base() . 'images/wishlogue/wish_medium/' . rawurlencode($pin->pin_image) . '" ';
                                        $jmgSrc1 = JURI::base() . 'images/wishlogue/wish_medium/' . rawurlencode($pin->pin_image);
                                    }
                                    $j++;
									if( $j == 1 ) {
										echo '<div class="board-img-display-firstbox">';
									} else if( $j == 5 ) {
										echo '<div class="board-img-display-secondbox">';
									}
                                    if ( $j%4 == 1) {
										
										if ( $pin->pin_id != 0 ) {
										
										$img_Res = wishlogueModelallcatalogues::getImageResolution($jmgSrc1, 170, 112);
									?>
                                        <a class="new-img-big-new" <?php echo $wishLinkHREF; ?>>
                                            <img height="<?php echo $img_Res['height']; ?>" width="<?php echo $img_Res['width']; ?>" <?php echo $jmgSrc; ?> alt="" />
                                        </a>
											
										<?php } else { ?>
											<span class="no-image-found"><?php echo JText::_('COM_WISHLOGUE_NO_IMAGE_FOUND'); ?></span>
											<?php }
										}
										
										
										else {
										$img_Res = wishlogueModelallcatalogues::getImageResolution($jmgSrc1, 55, 55);
                                    if ($j%4 == 2) {
                                        echo '<div class="new-img-small-class">';
                                    } ?>
                                        <a class="new-img-small-new" <?php echo $wishLinkHREF; ?>>
                                            <img height="<?php echo $img_Res['height']; ?>" width="<?php echo $img_Res['width']; ?>" <?php echo $jmgSrc; ?> alt="" />
                                        </a><?php
                                    if ( $j%4 == 0 || $j == count($getBoardPins) ) {
                                        echo '</div>';
                                    }
                                    }

									if( $j == 4 || $j == 8 || $j == count($getBoardPins) ) {
										echo '</div>';
									}

									} ?>
				</div>
				
				
				
				
				
				
                <div class="catelogues-names"> 
                    <div class="tabelcell">
                    <?php
                    //rgs.
                    $getBoardNames = wishlogueModelallcatalogues::getBoardNames($categories[$i]->category_id);
                    $ij = 0;
                    foreach ($getBoardNames as $getBoardName)
					{
						if( $getBoardName->section_type == 1 ) {
							$url = JRoute::_( 'index.php?option=com_wishlogue&amp;view=sectiondisplay&amp;section=' . $getBoardName->subcatalogue_id, true);
						} else {
							$url = JRoute::_( 'index.php?option=com_wishlogue&amp;view=cataloguepage&amp;bId=' . $getBoardName->subcatalogue_id, true);
						}
                        ?>
                        <input type='button' value='<?php echo $getBoardName->subcatalogue_name; ?>' onclick="window.location = '<?php echo $url; ?>'">
                        <?php
                        if (++$ij <= count($getBoardNames) - 1) {
                            echo '<font>*</font>';
                        }
                    }
                    //rgs..
                    ?>
                        </div>
                </div>	
            </li>
        <?php } ?>
    </ul>
</div>