Beispiel #1
0
 protected function getColectionThumb(&$item)
 {
     $model_images = new Helper_Images();
     if (!empty($item['photo'])) {
         $height = JO_Registry::forceGet('user_public_collection_height');
         $thumb = $model_images->resizeWidth($item['photo'], JO_Registry::forceGet('user_public_collection_width'));
         $thumb_size = getimagesize($thumb);
         if ($thumb_size[1] > $height) {
             $image = new JO_GDThumb($thumb);
             $image->crop(0, 0, $thumb_size[0], $height);
             $image->save($thumb);
         }
         $item['photo'] = $thumb;
     } else {
         $item['photo'] = 'data/themes/images/no_collection_image.png';
     }
 }
Beispiel #2
0
 public function indexAction()
 {
     $request = $this->getRequest();
     $model_images = new Model_Images();
     $this->view->usersCount = Model_Users::countUsers();
     $this->view->itemsCount = Model_Items::countItems();
     /* LAST ITEM */
     $lastItem = Model_Items::getLastItem();
     if ($lastItem) {
         $thumb = $model_images->resizeWidth($lastItem['theme_preview_thumbnail'], 200);
         $thumb_size = getimagesize($thumb);
         if ($thumb_size[1] > 161) {
             $image = new JO_GDThumb($thumb);
             $image->crop(0, 0, $thumb_size[0], 161);
             $image->save($thumb);
         }
         $this->view->lastItem = array('name' => $lastItem['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?module=' . $lastItem['module'] . '&controller=items&item_id=' . $lastItem['id'] . '&name=' . $lastItem['name']), 'thumb' => $thumb);
     }
     /* FREE ITEM */
     $this->view->freeItems = '';
     $freeItems = Model_Items::getFreeFiles();
     if ($freeItems) {
         foreach ($freeItems as $fi) {
             $cats = explode(',', $fi['categories']);
             $cat_name = Helper_Items::getCategory($cats[1]);
             $thumb = $model_images->resizeWidth($fi['theme_preview_thumbnail'], JO_Registry::forceGet($fi['module'] . '_items_thumb_width'));
             $thumb_size = getimagesize($thumb);
             if ($thumb_size[1] > JO_Registry::forceGet($fi['module'] . '_items_thumb_height')) {
                 $image = new JO_GDThumb($thumb);
                 $image->crop(0, 0, $thumb_size[0], JO_Registry::forceGet($fi['module'] . '_items_thumb_height'));
                 $image->save($thumb);
             }
             $this->view->freeItems[] = array('href' => WM_Router::create($request->getBaseUrl() . '?controller=items&item_id=' . $fi['id'] . '&name=' . WM_Router::clearName($fi['name'])), 'thumb' => $thumb, 'cat_name' => $cat_name['name'], 'name' => $fi['name']);
         }
     }
     /* ITEMS */
     $this->view->items = array();
     $listType = $request->getParam('list_type');
     if (is_null($listType)) {
         $listType = 'recent';
     }
     $this->view->all_items = array('name' => $this->view->translate('View all items'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=categories&action=' . $listType));
     switch ($listType) {
         case 'featured':
             JO_Session::set('redirect', $request->getBaseUrl() . $request->getUri());
             $this->view->title_items = $this->view->translate('Featured Items');
             $featuredItems = Model_Items::getWeekly($request->getParam('category_filter'));
             if ($featuredItems) {
                 foreach ($featuredItems as $n => $item) {
                     if (!empty($item['demo_url'])) {
                         $item['demo_url'] = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=preview&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
                     }
                     $this->view->items[] = Helper_Items::returnViewIndex($item);
                 }
             }
             break;
         case 'author':
             JO_Session::set('redirect', $request->getBaseUrl() . $request->getUri());
             $this->view->title_items = $this->view->translate('Featured Author');
             $this->view->author = Model_Users::getFeatUser();
             if ($this->view->author) {
                 $this->view->author['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username']);
                 $this->view->author['userhref_pf'] = WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username']);
                 if ($this->view->author['avatar']) {
                     $this->view->author['avatar'] = $model_images->resize($this->view->author['avatar'], JO_Registry::forceGet('user_avatar_width'), JO_Registry::forceGet('user_avatar_height'), true);
                 } else {
                     $this->view->author['avatar'] = 'data/themes/images/avatar-author.png';
                 }
                 $this->view->items = array();
                 $items = Model_Items::getByUser($this->view->author['user_id'], 0, 11, false);
                 if (empty($items)) {
                     $items = array(0 => array('no_items' => true, 'thumbnail' => 'data/themes/images/missing-item.png', 'module' => 'themes'));
                 }
                 if ($items) {
                     foreach ($items as $n => $item) {
                         if (!empty($item['demo_url'])) {
                             $item['demo_url'] = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=preview&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
                         }
                         $this->view->items[] = Helper_Items::returnViewIndex($item);
                     }
                 }
             }
             $this->view->all_items = array('name' => $this->view->translate('View portfolio'), 'href' => $this->view->author['userhref_pf']);
             break;
         default:
             /* RECENT ITEMS */
             JO_Session::set('redirect', $request->getBaseUrl());
             $this->view->title_items = $this->view->translate('Recent Items');
             $recentItems = Model_Items::getRecent($request->getParam('category_filter'));
             if ($recentItems) {
                 foreach ($recentItems as $n => $item) {
                     if (!empty($item['demo_url'])) {
                         $item['demo_url'] = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=preview&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
                     }
                     $this->view->items[] = Helper_Items::returnViewIndex($item);
                 }
             }
             shuffle($this->view->items);
     }
     $this->view->listType = $listType;
     $this->view->recent_items = WM_Router::create($request->getBaseUrl() . '?controller=recent');
     $this->view->featured = WM_Router::create($request->getBaseUrl() . '?controller=featured');
     $this->view->featuredAuthor = WM_Router::create($request->getBaseUrl() . '?controller=author');
     /* CATEGORIES */
     $this->view->categories = Model_Categories::getMain();
     $this->view->top_categories = $this->view->categories;
     if ($this->view->categories) {
         if ($this->view->categories) {
             foreach ($this->view->categories as $k => $v) {
                 $this->view->categories[$k]['href'] = WM_Router::create($request->getBaseUrl() . '?controller=' . $listType . '&category_filter=' . $v['id']);
             }
         }
     }
     if ($this->view->top_categories) {
         foreach ($this->view->top_categories as $k => $v) {
             $this->view->top_categories[$k]['href'] = WM_Router::create($request->getBaseUrl() . '?controller=categories&category_id=' . $v['id'] . '&name=' . $v['name']);
         }
         shuffle($this->view->top_categories);
         $this->view->top_categories = array_slice($this->view->top_categories, 0, 4);
     }
     $this->view->all_categories = WM_Router::create($request->getBaseUrl() . '?controller=categories&category_id=' . $listType);
     $this->view->children = array();
     $this->view->children['header_part'] = 'layout/header_part';
     $this->view->children['footer_part'] = 'layout/footer_part';
 }
Beispiel #3
0
 public static function returnViewIndex($item, $view_name = 'index')
 {
     if (!isset($item['module']) || !$item['module']) {
         return;
     }
     $view = JO_View::getInstance();
     if (!isset($item['no_items'])) {
         static $results = array();
         $model_images = new Helper_Images();
         $request = JO_Request::getInstance();
         if (mb_strlen($item['name'], 'UTF-8') > 35) {
             $item['name'] = JO_Utf8::mb_cut_text($item['name'], 0, 35, ' ');
         }
         $item['price'] = WM_Currency::format($item['price']);
         switch ($view_name) {
             case 'category':
                 $height = JO_Registry::forceGet($item['module'] . '_items_preview_height');
                 $item['thumbnail'] = $model_images->resizeWidth($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_preview_width'));
                 if (!empty($item['thumbnail'])) {
                     $thumb_size = getimagesize($item['thumbnail']);
                     if ($thumb_size[1] > $height) {
                         $image = new JO_GDThumb($item['thumbnail']);
                         $image->crop(0, 0, $thumb_size[0], $height);
                         $image->save($item['thumbnail']);
                     }
                 }
                 /* CATEGORIES */
                 $cats = array();
                 $categories = Model_Categories::getCategoriesByIds($item['categories']);
                 foreach ($categories as $v) {
                     $cats[] = array('name' => $v['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=categories&category_id=' . $v['id'] . '&name=' . WM_Router::clearName($v['name'])));
                 }
                 $item['categories'] = $cats;
                 break;
             case 'downloads':
                 $height = JO_Registry::forceGet($item['module'] . '_items_preview_height');
                 $item['thumbnail'] = $model_images->resizeWidth($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_preview_width'));
                 if (!empty($item['thumbnail'])) {
                     $thumb_size = getimagesize($item['thumbnail']);
                     if ($thumb_size[1] > $height) {
                         $image = new JO_GDThumb($item['thumbnail']);
                         $image->crop(0, 0, $thumb_size[0], $height);
                         $image->save($item['thumbnail']);
                     }
                 }
                 $item['rate'] = Model_Items::isRate($item['id']);
                 break;
             default:
                 $height = JO_Registry::forceGet($item['module'] . '_items_thumb_height');
                 $item['thumbnail'] = $model_images->resizeWidth($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_thumb_width'), $height);
                 if (!empty($item['thumbnail'])) {
                     $thumb_size = getimagesize($item['thumbnail']);
                     if ($thumb_size[1] > $height) {
                         $image = new JO_GDThumb($item['thumbnail']);
                         $image->crop(0, 0, $thumb_size[0], $height);
                         $image->save($item['thumbnail']);
                     }
                 }
         }
         $item['href'] = WM_Router::create($request->getBaseUrl() . '?controller=items&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
         $item['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username']));
     }
     $view->item = $item;
     return $view->renderByModule('single_items/' . $view_name, 'items', $item['module']);
 }