示例#1
0
 /**
  * Displays the application output in the canvas.
  *
  * @since   1.0
  * @access  public
  * @param   int   The user id that is currently being viewed.
  * @return  string  Layout path
  */
 public function display($userId = null, $docType = null)
 {
     $lang = JFactory::getLanguage();
     $lang->load('plg_app_user_q2c_boughtproducts', JPATH_ADMINISTRATOR);
     $path = JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'helper.php';
     if (!class_exists('comquick2cartHelper')) {
         JLoader::register('comquick2cartHelper', $path);
         JLoader::load('comquick2cartHelper');
     }
     $product_path = JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'helpers' . DS . 'product.php';
     if (!class_exists('productHelper')) {
         JLoader::register('productHelper', $product_path);
         JLoader::load('productHelper');
     }
     // Get the user params
     $params = $this->getUserParams($userId);
     // Get the app params
     $appParams = $this->app->getParams();
     // Get the blog model
     $no_of_porducts = $params->get('total', '10');
     $privacy = $params->get('profile_show_friends', 'onlyme');
     $pin_width = (int) $appParams->get('pin_width', 145);
     $pin_padding = (int) $appParams->get('pin_padding', 3);
     // Get profile id
     $model = new productHelper();
     // $target_data = $model->getUserStores($user->id,$no_of_stores);
     $no_authorize = '';
     $target_data = '';
     $my = Foundry::user();
     $logged_id = $my->id;
     if ($privacy === 'onlyme') {
         if ($logged_id == $userId) {
             $target_data = $model->getUserRecentlyBoughtproducts($userId, $no_of_porducts);
         } else {
             $no_authorize = 'no';
             $this->set('no_authorize', $no_authorize);
         }
     } elseif ($privacy === 'friend') {
         $check = Foundry::model('Friends')->isFriends($logged_id, $userId);
         if ($check == 1 || $logged_id == $userId) {
             $target_data = $model->getUserRecentlyBoughtproducts($userId, $no_of_porducts);
         } else {
             $no_authorize = 'no';
             $this->set('no_authorize', $no_authorize);
         }
     } elseif ($privacy === 'fof') {
         // $my = Foundry::user($userId);
         $check_friend = Foundry::model('Friends')->isFriends($logged_id, $userId);
         $friendlist = Foundry::model('Friends')->getFriends($userId);
         foreach ($friendlist as $ids) {
             $check_fof = Foundry::model('Friends')->isFriends($logged_id, $ids->id);
             if ($check_fof == 1 || $logged_id == $userId) {
                 $check_friendoffriend = 1;
             }
         }
         if ($check_friend == 1 || $logged_id == $userId && $check_friendoffriend == 1) {
             $target_data = $model->getUserRecentlyBoughtproducts($userId, $no_of_porducts);
         } else {
             $no_authorize = 'no';
             $this->set('no_authorize', $no_authorize);
         }
     } elseif ($privacy === 'all') {
         $target_data = $model->getUserRecentlyBoughtproducts($userId, $no_of_porducts);
     } else {
         $target_data = '';
     }
     $this->set('no_authorize', $no_authorize);
     $this->set('target_data', $target_data);
     $this->set('userId', $userId);
     $this->set('privacy', $privacy);
     $this->set('pin_width', $pin_width);
     $this->set('pin_padding', $pin_padding);
     echo parent::display('profile/default');
 }
    /**
     * This function get html from quick2cart layout and make html as per requirments.
     *
     * @since   1.0
     * @access  public
     * @return  string   page html return.
     */
    public function _getquick2cartiboughtHTML()
    {
        jimport('joomla.filesystem.file');
        if (JFile::exists(JPATH_SITE . '/components/com_quick2cart/quick2cart.php')) {
            $lang = JFactory::getLanguage();
            $lang->load('com_quick2cart', JPATH_SITE);
            $path = JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'helper.php';
            if (!class_exists('comquick2cartHelper')) {
                JLoader::register('comquick2cartHelper', $path);
                JLoader::load('comquick2cartHelper');
            }
            // Load assets
            comquick2cartHelper::loadQuicartAssetFiles();
            $product_path = JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'helpers' . DS . 'product.php';
            if (!class_exists('productHelper')) {
                JLoader::register('productHelper', $product_path);
                JLoader::load('productHelper');
            }
            $params = $this->params;
            $no_of_prod = $params->get('no_of_prod', '2');
            $user = CFactory::getRequestUser();
            $model = new productHelper();
            $target_data = $model->getUserRecentlyBoughtproducts($user->id, $no_of_prod);
            if (!empty($target_data)) {
                $random_container = 'q2c_pc_js_products_ibought';
                $html = "\n\t\t\t\t\t<div class='" . Q2C_WRAPPER_CLASS . "' >\n\t\t\t\t\t\t<div class='row-fluid'>\n\t\t\t\t\t\t\t<div id='q2c_pc_js_products_ibought'>";
                foreach ($target_data as $data) {
                    $path = JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'views' . DS . 'product' . DS . 'tmpl' . DS . 'product.php';
                    ob_start();
                    include $path;
                    $html .= ob_get_contents();
                    ob_end_clean();
                }
                $html .= "\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>";
                ob_start();
                ?>
					<?php 
                // Get pin width
                $pin_width = $params->get('pin_width');
                if (empty($pin_width)) {
                    $pin_width = 170;
                }
                // Get pin padding
                $pin_padding = $params->get('pin_padding');
                if (empty($pin_padding)) {
                    $pin_padding = 7;
                }
                // Calulate columnWidth (columnWidth = pin_width+pin_padding)
                $columnWidth = $pin_width + $pin_padding;
                ?>

					<style type="text/css">
						.q2c_pin_item_<?php 
                echo $random_container;
                ?>
 { width: <?php 
                echo $pin_width . 'px';
                ?>
 !important; }
					</style>

					<script type="text/javascript">
						var pin_container_<?php 
                echo $random_container;
                ?>
 = 'q2c_pc_js_products_ibought';

						techjoomla.jQuery(document).ready(function()
						{
							var container_<?php 
                echo $random_container;
                ?>
 = document.getElementById(pin_container_<?php 
                echo $random_container;
                ?>
);
							var msnry = new Masonry( container_<?php 
                echo $random_container;
                ?>
, {
								columnWidth: <?php 
                echo $columnWidth;
                ?>
,
								itemSelector: '.q2c_pin_item_<?php 
                echo $random_container;
                ?>
',
								gutter: <?php 
                echo $pin_padding;
                ?>
});

							setTimeout(function(){
								var container_<?php 
                echo $random_container;
                ?>
 = document.getElementById(pin_container_<?php 
                echo $random_container;
                ?>
);
								var msnry = new Masonry( container_<?php 
                echo $random_container;
                ?>
, {
									columnWidth: <?php 
                echo $columnWidth;
                ?>
,
									itemSelector: '.q2c_pin_item_<?php 
                echo $random_container;
                ?>
',
									gutter: <?php 
                echo $pin_padding;
                ?>
});
							}, 1000);

							setTimeout(function(){
								var container_<?php 
                echo $random_container;
                ?>
 = document.getElementById(pin_container_<?php 
                echo $random_container;
                ?>
);
								var msnry = new Masonry( container_<?php 
                echo $random_container;
                ?>
, {
									columnWidth: <?php 
                echo $columnWidth;
                ?>
,
									itemSelector: '.q2c_pin_item_<?php 
                echo $random_container;
                ?>
',
									gutter: <?php 
                echo $pin_padding;
                ?>
});
							}, 3000);
						});
					</script>
				<?php 
                $pin_html .= ob_get_contents();
                ob_end_clean();
                $html .= $pin_html;
                return $html;
            }
        }
    }