Source for file gallery.inc.php
Documentation is available at gallery.inc.php
* @author Matthias Reuter ($LastChangedBy: matthias $)
* @version $LastChangedDate: 2009-01-18 03:52:31 +0000 (So, 18 Jan 2009) $
* @copyright 2007-2010 IPBWI development team
* @link http://ipbwi.com/examples/topic.php
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License
* @desc Loads and checks different vars when class is initiating
* @author Matthias Reuter
public function __construct($ipbwi){
// check if IP.gallery is installed
$query = $this->ipbwi->ips_wrapper->DB->query('SELECT conf_value,conf_default FROM '. $this->ipbwi->board['sql_tbl_prefix']. 'core_sys_conf_settings WHERE conf_key="gallery_images_url"');
if($this->ipbwi->ips_wrapper->DB->getTotalRows($query) != 0){
$data = $this->ipbwi->ips_wrapper->DB->fetch($query);
$this->url = (($data['conf_value'] != '') ? $data['conf_value'] : $data['conf_default']). '/';
* @desc Returns categories readable by the current member.
* @return array Readable category IDs
* @author Matthias Reuter
* @author Pita <peter@randomnity.com>
* $ipbwi->gallery->getViewable();
if($cache = $this->ipbwi->cache->get('galleryGetViewable', $this->ipbwi->member->myInfo['member_id'])){
$this->ipbwi->ips_wrapper->DB->query('SELECT * FROM '. $this->ipbwi->board['sql_tbl_prefix']. 'gallery_categories');
while($row = $this->ipbwi->ips_wrapper->DB->fetch()){
if($this->ipbwi->group->isInGroup($row['perms_view'])){
$cats[$row['id']] = $row['id'];
$this->ipbwi->cache->save('galleryGetViewable', $this->ipbwi->member->myInfo['member_id'], $cats);
* @desc lists latest images from IP.gallery.
* @return array Image-Informations as multidimensional array
* @author Matthias Reuter
$catquery = ' AND (category_id="'. implode('" OR category_id="',$viewable). '")';
}elseif(intval($catIDs) != 0){
$catquery = ' AND category_id="'. $catIDs. '"';
if(empty($settings['start'])){
if(empty($settings['limit'])){
if(empty($settings['memberid'])){
$fromMember = ' AND member_id = "'. $settings['memberid']. '"';
$query = $this->ipbwi->ips_wrapper->DB->query('SELECT * FROM '. $this->ipbwi->board['sql_tbl_prefix']. 'gallery_images WHERE approved="1"'. $catquery. $fromMember. ' ORDER BY id DESC LIMIT '. intval($settings['start']). ','. intval($settings['limit']));
if($this->ipbwi->ips_wrapper->DB->getTotalRows($query) == 0){
while($row = $this->ipbwi->ips_wrapper->DB->fetch($query)){
$row['caption'] = $this->ipbwi->properXHTML($this->ipbwi->bbcode->bbcode2html($this->ipbwi->bbcode->html2bbcode($row['caption']),false));
$row['description'] = $this->ipbwi->properXHTML($this->ipbwi->bbcode->bbcode2html($this->ipbwi->bbcode->html2bbcode($row['description']),false));
$row['copyright'] = $this->ipbwi->properXHTML($this->ipbwi->bbcode->bbcode2html($this->ipbwi->bbcode->html2bbcode($row['copyright']),false));
* @desc Returns all subcategories of the delivered cats.
* @param mixed $forums category IDs as int or array
* @param string $outputType The following output types are supported:<br>
* 'html_form' to get a list of <option>-tags<br>
* 'array' (default) for an array-list<br>
* 'array_ids_only' for an array-list with forum IDs only<br>
* 'name_id_with_indent' for an array list of names with indent according to the forum structure
* @param string $indentString The string for indent, default is '-'
* @return mixed List of all subcategories
* @author Matthias Reuter
* $ipbwi->gallery->getAllSubs(array(55,22,77),'html_form');
public function getAllSubs($cats,$outputType= 'array',$indentString= '—',$indent= false,$selectedID= false){
// get all categories, if needed
// get forum information of requested category
$cats = array($this->info($cats));
// save original indent string
// grab all forums from every delivered cat-id
if($outputType == 'html_form'){ // give every forum its own option-tag
$output .= '<option'. (($selectedID == $i['id']) ? ' selected="selected"' : ''). (($i['parent'] == '0') ? ' style="background-color:#2683AE;color:#FFF;font-weight:bold;"' : ' style="color:#666;"'). ' value="'. $i['id']. '"> '. $indent. ' '. $i['name']. '</option>';
}elseif($outputType == 'array'){ // merge all forum-data in one, big array
}elseif($outputType == 'array_ids_only'){ // merge all forum-data in one, big array
$output[$i['id']] = $i['id'];
}elseif($outputType == 'name_id_with_indent'){ // return name and id, with indent
$output[$i['id']]['name'] = $indent. $i['name'];
// grab all subforums from each delivered cat-id
if($subqery = $this->ipbwi->ips_wrapper->DB->query('SELECT '. $select. ' FROM '. $this->ipbwi->board['sql_tbl_prefix']. 'gallery_categories WHERE parent = '. $i['id']. ' ORDER BY c_order ASC')){
$indent = $indent. $indentString;
// get all subforums in an array
while($row = $this->ipbwi->ips_wrapper->DB->fetch($subqery)){
if($outputType == 'array_ids_only'){
$subforums[$row['id']] = $row['id'];
$row['last_pic_name'] = $this->ipbwi->properXHTML($row['last_pic_name']);
$row['name'] = $this->ipbwi->properXHTML($row['name']);
$row['description'] = $this->ipbwi->properXHTML($row['description']);
if(isset ($subforums) && is_array($subforums) && count($subforums) > 0){
if($outputType == 'html_form'){
// give every forum its own option-tag
$output .= $this->getAllSubs($subforums,$outputType,$indentString,$indent,$selectedID);
}elseif($outputType == 'array' || $outputType == 'array_ids_only'){
// merge all forum-data in one, big array
$output = $output+ $this->getAllSubs($subforums,$outputType,$indentString,$indent,$selectedID);
}elseif($outputType == 'name_id_with_indent'){
$output = $output+ $this->getAllSubs($subforums,$outputType,$indentString,$indent,$selectedID);
* @return array Gallery's Categories
* @author Matthias Reuter
* $ipbwi->forum->catList();
if($cache = $this->ipbwi->cache->get('listGalleryCategories', '1')){
$this->ipbwi->ips_wrapper->DB->query('SELECT * FROM '. $this->ipbwi->board['sql_tbl_prefix']. 'gallery_categories WHERE parent = "0"');
while($row = $this->ipbwi->ips_wrapper->DB->fetch()){
$row['last_pic_name'] = $this->ipbwi->properXHTML($row['last_pic_name']);
$row['name'] = $this->ipbwi->properXHTML($row['name']);
$row['description'] = $this->ipbwi->properXHTML($row['description']);
$this->ipbwi->cache->save('listGalleryCategories', '1', $cat);
public function info($imgID){
$query = $this->ipbwi->ips_wrapper->DB->query('SELECT * FROM '. $this->ipbwi->board['sql_tbl_prefix']. 'gallery_images WHERE id="'. intval($imgID). '"');
if($this->ipbwi->ips_wrapper->DB->getTotalRows($query) == 0){
while($row = $this->ipbwi->ips_wrapper->DB->fetch($query)){
$row['caption'] = $this->ipbwi->properXHTML($this->ipbwi->bbcode->bbcode2html($this->ipbwi->bbcode->html2bbcode($row['caption']),false));
$row['description'] = $this->ipbwi->properXHTML($this->ipbwi->bbcode->bbcode2html($this->ipbwi->bbcode->html2bbcode($row['description']),false));
$row['copyright'] = $this->ipbwi->properXHTML($this->ipbwi->bbcode->bbcode2html($this->ipbwi->bbcode->html2bbcode($row['copyright']),false));
|