예제 #1
0
파일: helper.php 프로젝트: ngxuanmui/hp3
 static function getList(&$params)
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('a.*')->from('#__hp_albums a')->where('a.state = 1')->order('a.id DESC');
     $db->setQuery($query, 0, 12);
     $rs = $db->loadObjectList();
     $thumb = true;
     if ($thumb) {
         foreach ($rs as &$item) {
             $tmp = explode('/', $item->images);
             $image_name = end($tmp);
             $imagePath = JPATH_ROOT . DS . 'images' . DS . 'albums' . DS . $item->id;
             // shift an el (image folder) in $tmp
             array_shift($tmp);
             // remove last el (file name) in $tmp
             array_pop($tmp);
             $image_path = $imagePath;
             $thumb_path = $imagePath . '/thumbs/';
             $thumb_image_path = $thumb_path . DS . $image_name;
             @unlink($thumb_path);
             @JFolder::create($thumb_path);
             $thumbW = 100;
             $thumbH = 100;
             // create thumb if not exist
             //if (!file_exists($thumb_image_path) && file_exists($image_path . DS . $image_name))
             JEUtil::thumbnail($image_path, $thumb_path, $image_name, $thumbW, $thumbH);
             $item->thumb = JURI::root() . 'images/albums/' . $item->id . '/thumbs/' . 't-' . $thumbW . 'x' . $thumbH . '-' . $image_name;
         }
     }
     // 		var_dump($rs);
     return $rs;
 }
예제 #2
0
파일: helper.php 프로젝트: ngxuanmui/hp3
 static function getList(&$params)
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('a.*')->from('#__hp_albums a')->where('a.state = 1')->order('a.id DESC');
     $arrViews = array('services', 'service');
     $userId = JRequest::getInt('user', 0);
     $view = JRequest::getString('view');
     if ($userId && in_array($view, $arrViews)) {
         $query->where('a.created_by = ' . (int) $userId);
     } else {
         return false;
     }
     $db->setQuery($query, 0, 15);
     $rs = $db->loadObjectList();
     $thumb = true;
     if ($thumb) {
         foreach ($rs as &$item) {
             $tmp = explode('/', $item->images);
             $image_name = end($tmp);
             $imagePath = JPATH_ROOT . DS . 'images' . DS . 'albums' . DS . $item->id;
             // shift an el (image folder) in $tmp
             array_shift($tmp);
             // remove last el (file name) in $tmp
             array_pop($tmp);
             $image_path = $imagePath;
             $thumb_path = $imagePath . '/thumbs/';
             $thumb_image_path = $thumb_path . DS . $image_name;
             @JFolder::create($thumb_path);
             $thumbW = CFG_THUMBNAIL_WIDTH;
             $thumbH = CFG_THUMBNAIL_HEIGHT;
             // create thumb if not exist
             if (!file_exists($thumb_image_path) && file_exists($image_path . DS . $image_name)) {
                 JEUtil::thumbnail($image_path, $thumb_path, $image_name, $thumbW, $thumbH);
             }
             $item->thumb = JURI::root() . 'images/albums/' . $item->id . '/thumbs/' . 't-' . $thumbW . 'x' . $thumbH . '-' . $image_name;
         }
     }
     // 		var_dump($rs);
     return $rs;
 }
예제 #3
0
파일: album.php 프로젝트: ngxuanmui/hp3
 public function getOtherImages($type = 'albums')
 {
     if (!$type) {
         $type = $this->itemType;
     }
     $item = $this->getItem($type, false);
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('*')->from('#__hp_images')->where('item_type = "' . $type . '"')->where('item_id = ' . (int) $item->id)->order('id ASC');
     $db->setQuery($query);
     $rs = $db->loadObjectList();
     if ($db->getErrorMsg()) {
         die($db->getErrorMsg());
     }
     $thumb = true;
     if ($thumb) {
         foreach ($rs as &$item) {
             //$tmp = explode('/', $item->images);
             $image_name = $item->images;
             $imagePath = JPATH_ROOT . DS . 'images' . DS . 'albums' . DS . $item->item_id;
             // shift an el (image folder) in $tmp
             // 				array_shift($tmp);
             // remove last el (file name) in $tmp
             // 				array_pop($tmp);
             $image_path = $imagePath;
             $thumb_path = $imagePath . '/thumbs/';
             $thumb_image_path = $thumb_path . DS . $image_name;
             @JFolder::create($thumb_path);
             $thumbW = CFG_THUMBNAIL_WIDTH;
             $thumbH = CFG_THUMBNAIL_HEIGHT;
             // create thumb if not exist
             if (!file_exists($thumb_image_path) && file_exists($image_path . DS . $image_name)) {
                 JEUtil::thumbnail($image_path, $thumb_path, $image_name, $thumbW, $thumbH);
             }
             $item->thumb = JURI::root() . 'images/albums/' . $item->item_id . '/thumbs/' . 't-' . $thumbW . 'x' . $thumbH . '-' . $image_name;
         }
     }
     return $rs;
 }