function &gs_rssshow($limit) { global $util, $mc; $db =& Database::getInstance(); include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsimage.class.php'; include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsset.class.php'; include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsuser.class.php'; foreach ($_GET as $k => $v) { ${$k} = $v; } $feed = array(); // Información General $items = array(); $mc =& $util->moduleConfig('galleries'); if ($show == 'imgs') { $feed['title'] = htmlspecialchars(_MI_GS_RSSNAME); $feed['link'] = htmlspecialchars(XOOPS_URL . '/modules/galleries/' . ($mc['urlmode'] ? 'explore/photos/' : 'explore.php?by=explore/photos')); $feed['description'] = htmlspecialchars(_MI_GS_RSSIMGS_DESC); $sql = "SELECT * FROM " . $db->prefix("gs_images") . " WHERE public='2' ORDER BY created DESC LIMIT 0,15"; $result = $db->query($sql); $users = array(); while ($row = $db->fetchArray($result)) { $pic = new GSImage(); $pic->assignVars($row); if (!isset($users[$pic->owner()])) { $users[$pic->owner()] = new GSUser($pic->owner(), 1); } $user =& $users[$pic->owner()]; $rtn = array(); $rtn['title'] = htmlspecialchars($pic->title()); $rtn['link'] = $user->userURL() . 'img/' . $pic->id() . '/'; $rtn['description'] = htmlspecialchars('<img src="' . $user->filesURL() . '/ths/' . $pic->image() . '" alt="" /><br />' . sprintf(_MI_GS_RSSIMGDESC, $pic->desc(), formatTimestamp($pic->created(), 'string'), $user->uname(), $pic->views())); $rtn['date'] = formatTimestamp($pic->created()); $items[] = $rtn; } } elseif ($show == 'sets') { $feed['title'] = htmlspecialchars(_MI_GS_RSSSETS); $feed['link'] = htmlspecialchars(XOOPS_URL . '/modules/galleries/' . ($mc['urlmode'] ? 'explore/sets/' : 'explore.php?by=explore/sets')); $feed['description'] = htmlspecialchars(_MI_GS_RSSSETS_DESC); $sql = "SELECT * FROM " . $db->prefix("gs_sets") . " WHERE public='2' ORDER BY date DESC LIMIT 0,15"; $result = $db->query($sql); $users = array(); while ($row = $db->fetchArray($result)) { $set = new GSSet(); $set->assignVars($row); if (!isset($users[$set->owner()])) { $users[$set->owner()] = new GSUser($set->owner(), 1); } $user =& $users[$set->owner()]; $rtn = array(); $rtn['title'] = htmlspecialchars($set->title()); $rtn['link'] = $user->userURL() . 'set/' . $set->id() . '/'; $rtn['description'] = htmlspecialchars(sprintf(_MI_GS_RSSSETDESC, $user->uname(), formatTimestamp($set->date(), 'string'), $set->pics())); $rtn['date'] = formatTimestamp($set->date()); $items[] = $rtn; } } $ret = array('feed' => $feed, 'items' => $items); return $ret; }
public function get_item($params, $com, $url = false) { static $cimgs; static $csets; $params = urldecode($params); parse_str($params); include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsfunctions.class.php'; include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsimage.class.php'; include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gstag.class.php'; include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsset.class.php'; if (isset($set) && $set > 0) { if (isset($csets[$set])) { return $csets[$set]->title(); } $sobj = new GSSet($set); if ($sobj->isNew()) { return __('Unknow element', 'galleries'); } $ret = $sobj->title(); $csets[$set] = $sobj; return $ret; } elseif (isset($image) && $image > 0) { if (isset($cimgs[$image])) { $ret = $cresources[$res]->getVar('title'); return $ret; } $img = new GSImage($image); if ($img->isNew()) { return __('Unknow element', 'docs'); } $ret = $img->title(true); $cimgs[$image] = $img; return $ret; } }
/** * @desc Formulario de creación/edición de albums **/ function formAlbums($edit = 0) { global $xoopsModule, $xoopsUser; define('RMSUBLOCATION', 'newalbum'); $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; $page = isset($_REQUEST['pag']) ? $_REQUEST['pag'] : ''; $limit = isset($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 15; $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'id_set'; $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 0; $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : ''; $ruta = "pag={$page}&sort={$sort}&mode={$mode}&search={$search}"; if ($edit) { //Verificamos que el album sea válido if ($id <= 0) { redirectMsg('./sets.php?' . $ruta, __('Please provide a valid ID!', 'galleries'), 1); die; } //Verificamos que el album exista $set = new GSSet($id); if ($set->isNew()) { redirectMsg('./sets.php?' . $ruta, __('Specified album does not exists!', 'galleries'), 1); die; } } GSFunctions::toolbar(); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » <a href='./sets.php'>" . __('Albums management', 'galleries') . "</a> » " . ($edit ? __('Edit album', 'galleries') : __('New album', 'galleries'))); xoops_cp_header(); $form = new RMForm($edit ? __('Edit album', 'galleries') : __('New Album', 'galleries'), 'frmsets', 'sets.php'); $form->addElement(new RMFormText(__('Album title', 'galleries'), 'title', 50, 100, $edit ? $set->title() : ''), true); $form->addElement(new RMFormEditor(__('Description', 'galleries'), 'description', '99%', '250px', $edit ? $set->getVar('description', 'e') : '')); $ele = new RMFormSelect(__('Privacy level', 'galleries'), 'public'); $ele->addOption(0, __('Private', 'galleries'), $edit ? $set->isPublic() == 0 ? 1 : 0 : 0); $ele->addOption(1, __('Public for friends', 'galleries'), $edit ? $set->isPublic() == 1 ? 1 : 0 : 0); $ele->addOption(2, __('Public', 'galleries'), $edit ? $set->isPublic() == 2 ? 1 : ($set->isPublic() == 0 ? 1 : 0) : 1); $form->addElement($ele, true); $form->addElement(new RMFormUser(__('Owner', 'galleries'), 'owner', 0, $edit ? array($set->owner()) : array($xoopsUser->uid()), 30)); $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save')); $form->addElement(new RMFormHidden('id', $id)); $form->addElement(new RMFormHidden('page', $page)); $form->addElement(new RMFormHidden('limit', $limit)); $form->addElement(new RMFormHidden('sort', $sort)); $form->addElement(new RMFormHidden('mode', $mode)); $form->addElement(new RMFormHidden('search', $search)); $buttons = new RMFormButtonGroup(); $buttons->addButton('sbt', $edit ? __('Save Changes!', 'galleries') : __('Create Album!', 'galleries'), 'submit'); $buttons->addButton('cancel', __('Cancel', 'galleries'), 'button', 'onclick="window.location=\'sets.php?' . $ruta . '\'"'); $form->addElement($buttons); $form->display(); xoops_cp_footer(); }
function send_sets() { global $xoopsLogger, $xoopsModuleConfig; $xoopsLogger->renderingEnabled = false; error_reporting(0); $xoopsLogger->activated = false; $mc =& $xoopsModuleConfig; $db = Database::getInstance(); $limit = rmc_server_var($_GET, 'limit', 5); // recent pictures $sql = "SELECT * FROM " . $db->prefix("gs_sets") . " ORDER BY `date` DESC LIMIT 0,{$limit}"; $result = $db->query($sql); $sets = array(); $users = array(); while ($row = $db->fetchArray($result)) { $set = new GSSet(); $set->assignVars($row); $pics = $set->getPics('RAND()'); $img = new GSImage($pics[0]); if (!isset($users[$img->owner()])) { $users[$img->owner()] = new GSUser($img->owner(), 1); } if ($img->isNew()) { $image = array('title' => __('Empty album', 'galleries'), 'link' => '', 'thumbnail' => GS_URL . '/images/empty.jpg'); } else { $image = array('title' => $img->title(), 'link' => $users[$img->owner()]->userURL() . ($mc['urlmode'] ? 'img/' . $img->id() . '/' : '&img=' . $img->id()), 'thumbnail' => $users[$img->owner()]->filesURL() . '/ths/' . $img->image()); } $sets[] = array('title' => $set->title(), 'link' => $set->url(), 'image' => $image); } ob_start(); ?> <?php foreach ($sets as $set) { ?> <a href="<?php echo $set['link']; ?> " target="_blank" title="<?php echo $set['title']; ?> "><img src="<?php echo $set['image']['thumbnail']; ?> " alt="<?php echo $set['title']; ?> " /></a> <?php } ?> <?php $recents = ob_get_clean(); echo $recents; die; }
//Obtenemos una imagen del album $sql = "SELECT b.* FROM " . $db->prefix('gs_setsimages') . " a, " . $db->prefix('gs_images') . " b WHERE"; $sql .= " a.id_set='" . $set->id() . "' AND b.id_image=a.id_image AND b.public=2 AND b.owner='" . $set->owner() . "' ORDER BY RAND() LIMIT 0,4"; $resimg = $db->query($sql); if (!isset($users[$set->owner()])) { $users[$set->owner()] = new GSUser($set->owner(), 1); } $imgs = '<a href="' . $users[$set->owner()]->userURL() . ($mc['urlmode'] ? 'set/' . $set->id() . '/' : '&set=' . $set->id()) . '">'; while ($rowimg = $db->fetchArray($resimg)) { $img = new GSImage(); $img->assignVars($rowimg); $urlimg = $users[$set->owner()]->filesURL() . '/' . ($config['set_format_mode'] ? 'formats/set_' : 'ths/') . $img->image(); // Conversion de los formatos if (!$img->setFormat() && $config['set_format_mode']) { GSFunctions::resizeImage($crop, $users[$set->owner()]->filesPath() . '/' . $img->image(), $users[$set->owner()]->filesPath() . '/formats/set_' . $img->image(), $width, $height); $img->setSetFormat(1, 1); } $imgs .= '<img src="' . $urlimg . '" alt="' . $set->title() . '" /> '; } $imgs .= '</a>'; $desc = $imgs . '<br />'; $desc .= sprintf(__('By: <strong>%s</strong>', 'galleries'), $set->uname()); $item = array(); $item['title'] = $set->title(); $item['link'] = $users[$set->owner()]->userURL() . ($mc['urlmode'] ? 'set/' . $set->id() . '/' : '&set=' . $set->id()); $item['description'] = XoopsLocal::convert_encoding(htmlspecialchars($desc, ENT_QUOTES)); $item['pubdate'] = formatTimestamp($set->date(), 'rss'); $item['guid'] = $users[$set->owner()]->userURL() . ($mc['urlmode'] ? 'set/' . $set->id() . '/' : '&set=' . $set->id()); $rss_items[] = $item; } }
/** * @desc Mostramos el contenido de un Álbum */ function showSetContent() { global $usr, $db, $xoopsModule, $mc, $xoopsModuleConfig, $xoopsConfig, $xoopsUser, $xoopsOption, $tpl, $page; global $pag, $set; $mc =& $xoopsModuleConfig; $user = new GSUser($usr); if ($user->isNew()) { redirect_header(GSFunctions::get_url(), 0, __('Specified users does not exists!', 'galleries')); die; } $set = new GSSet($set); if ($set->isNew()) { redirect_header(GSFunctions::get_url(), 0, __('Specified album does not exists!', 'galleries')); die; } //Verificamos la privacidad del album if (!$set->ispublic()) { if (!$xoopsUser || $xoopsUser->uid() != $set->owner()) { redirect_header(GSFunctions::get_url(), 1, __('You can not view this private album!', 'galleries')); die; } } else { if (!$xoopsUser && $set->isPublic() == 1 && !$user->isFriend($xoopsUser->uid())) { redirect_header(GSFunctions::get_url(), 1, sprintf(__('You must be a friend of %s in order to see this album!', 'galleries'), $user->uname())); die; } } //Incrementamos el número de hits del album if (!isset($_SESSION['vsets'])) { $set->addHit(); $_SESSION['vsets'] = array($set->id()); } elseif (!in_array($set->id(), $_SESSION['vsets'])) { $set->addHit(); $_SESSION['vsets'][] = $set->id(); } $xoopsOption['template_main'] = $mc['set_format_mode'] ? 'gs_setpics.html' : 'gs_userpics.html'; $xoopsOption['module_subpage'] = 'userset'; include 'header.php'; GSFunctions::makeHeader(); // Información del Usuario $tpl->assign('lang_picsof', sprintf(__('Pictures in %s'), $set->title())); $tpl->assign('user', array('id' => $user->uid(), 'uname' => $user->uname(), 'avatar' => RMEvents::get()->run_event('rmcommon.get.avatar', $user->userVar('email'), 0, $user->userVar('user_avatar')), 'link' => $user->userURL())); $tpl->assign('set', array('title' => $set->title(), 'description' => $set->getVar('description', 's'))); // Lenguaje $tpl->assign('lang_bmark', __('Favorites', 'galleries')); $tpl->assign('lang_pics', __('Pictures', 'galleries')); $tpl->assign('sets_link', GSFunctions::get_url() . ($mc['urlmode'] ? "explore/sets/usr/" . $user->uname() . '/' : "?explore=sets&usr="******"explore/tags/usr/" . $user->uname() . '/' : "?explore=tags&usr="******"cp/bookmarks/" : "?cp=bookmarks")); $tpl->assign('xoops_pagetitle', sprintf(__('Pictures in %s'), $set->title()) . ' » ' . $mc['section_title']); $tpl->assign('lang_numpics', sprintf(__('Pictures: %s', 'galleries'), $set->pics())); $tpl->assign('lang_numviews', sprintf(__('Hits: %s'), $set->hits())); global $xoTheme; if ($set->getVar('description') != '') { $xoTheme->addMeta('meta', 'description', TextCleaner::clean_disabled_tags($set->getVar('description'))); } //Verificamos la privacidad de las imágenes if ($xoopsUser && $xoopsUser->uid() == $user->uid()) { $public = ''; } else { if ($xoopsUser && $user->isFriend($xoopsUser->uid())) { $public = " AND public<>0"; } else { $public = "AND public='2'"; } } $tbl1 = $db->prefix("gs_images"); $tbl2 = $db->prefix("gs_setsimages"); $sql = "SELECT COUNT(*) FROM {$tbl1} a, {$tbl2} b WHERE b.id_set='" . $set->id() . "' AND a.id_image=b.id_image {$public} AND owner='" . $user->uid() . "'"; $page = $page > 0 ? $page : 1; /** * @desc Formato para el manejo de las imágenes */ if ($mc['set_format_mode']) { $format = $mc['set_format_values']; $crop = $format[0]; // 0 = Redimensionar, 1 = Cortar $width = $format[1]; $height = $format[2]; $limit = $format[3]; $cols = $format[4]; @($showdesc = $format[5]); // Imágenes Grandes $format = $mc['setbig_format_values']; $bcrop = $format[0]; $bwidth = $format[1]; $bheight = $format[2]; $blimit = $format[3]; $bcols = $format[4]; @($bshowdesc = $format[5]); // Medidas $tpl->assign('big_width', $bwidth + 15); } else { $limit = $mc['limit_pics']; $cols = $mc['cols_pics']; $showdesc = 0; } list($num) = $db->fetchRow($db->query($sql)); if ($page > 0) { $page -= 1; } $start = $page * $limit; $tpages = (int) ($num / $limit); if ($num % $limit > 0) { $tpages++; } $pactual = $page + 1; if ($pactual > $tpages) { $pactual = $tpages; $start = ($tpages - 1) * $limit; } $urlnav = ''; if ($tpages > 1) { $urlnav .= $mc['urlmode'] ? 'usr/' . $user->uname() . '/set/' . $set->id() : '?usr='******'&set=' . $set->id(); $nav = new RMPageNav($num, $limit, $pactual, 5); $nav->target_url(GSFunctions::get_url() . $urlnav . ($mc['urlmode'] ? '/pag/{PAGE_NUM}/' : '&pag={PAGE_NUM}')); $tpl->assign('upNavPage', $nav->render(false)); } $showmax = $start + $limit; $showmax = $showmax > $num ? $num : $showmax; $tpl->assign('lang_showing', sprintf(__('Showing pictures %u to %u out of %u.', 'galleries'), $start + 1, $showmax, $num)); $tpl->assign('limit', $limit); $tpl->assign('pag', $pactual); //Fin de barra de navegación $sql = str_replace("COUNT(*)", '*', $sql); $sql .= " ORDER BY a.id_image ASC, a.modified DESC LIMIT {$start}, {$limit}"; $result = $db->query($sql); while ($row = $db->fetchArray($result)) { $img = new GSImage(); $img->assignVars($row); $imglink = $user->userURL() . ($mc['urlmode'] ? 'img/' . $img->id() . '/set/' . $set->id() . '/' : '&img=' . $img->id() . '&set=' . $set->id()); $imgfile = $user->filesURL() . '/' . ($mc['set_format_mode'] ? 'formats/set_' : 'ths/') . $img->image(); // Conversion de los formatos if (!$img->setFormat() && $mc['set_format_mode']) { GSFunctions::resizeImage($crop, $user->filesPath() . '/' . $img->image(), $user->filesPath() . '/formats/set_' . $img->image(), $width, $height); $img->setSetFormat(1, 1); } $tpl->append('images', array('id' => $img->id(), 'title' => $img->title(), 'thumbnail' => $imgfile, 'link' => $imglink, 'bigimage' => $user->filesURL() . '/' . $img->image())); } // Imagen grande del album $sql = "SELECT * FROM {$tbl1} a, {$tbl2} b WHERE b.id_set='" . $set->id() . "' AND a.id_image=b.id_image {$public} AND owner='" . $user->uid() . "' \n\t\t\tORDER BY a.id_image DESC LIMIT 0,{$blimit}"; $result = $db->query($sql); $bi = 0; $tf = new RMTimeFormatter(0, __('%m%/%d%/%Y% %h%:%i%', 'galleries')); // cremos la imagen grande para los albumes while ($row = $db->fetchArray($result)) { $img = new GSImage(); $img->assignVars($row); if ($mc['set_format_mode'] && !$img->bigSetFormat()) { GSFunctions::resizeImage($bcrop, $user->filesPath() . '/' . $img->image(), $user->filesPath() . '/formats/bigset_' . $img->image(), $bwidth, $bheight); $img->setBigSetFormat(1, 1); } if ($mc['set_format_mode']) { list($ancho, $altura, $tipo, $atr) = getimagesize($user->filesPath() . '/formats/bigset_' . $img->image()); $tpl->assign('big_width', $ancho); } $imglink = $user->userURL() . 'img/' . $img->id() . '/set/' . $set->id() . '/'; // ASignamos las imagenes grandes para los albumes $imgfile = $user->filesURL() . '/' . ($mc['set_format_mode'] ? 'formats/bigset_' : 'ths/') . $img->image(); if ($bi == 0) { $tpl->assign('lang_updated', sprintf(__('Updated on %s', 'galleries'), $tf->format($img->created()))); } $tpl->append('bigs', array('id' => $img->id(), 'title' => $img->title(), 'image' => $imgfile, 'link' => $imglink)); } RMFunctions::get_comments('galleries', 'set=' . $set->id()); // Comments form RMFunctions::comments_form('galleries', 'set=' . $set->id(), 'module', GS_PATH . '/class/galleriescontroller.php'); // Datos para el formato $tpl->assign('max_cols', $cols); include 'footer.php'; }
/** * Load images according to given parameters. * Util for images inclusion * @param int Set ID * @param int Number of results per page * @param * @return array */ public function load_images($set, $limit, $page) { global $xoopsUser; if ($set <= 0) { return; } include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsset.class.php'; include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsuser.class.php'; include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsimage.class.php'; include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gstag.class.php'; $set = new GSSet($set); if ($set->isNew()) { return; } $user = new GSUser($set->owner()); if (!$set->ispublic()) { if (!$xoopsUser || $xoopsUser->uid() != $set->owner()) { return; } } else { if (!$xoopsUser && $set->isPublic() == 1 && !$user->isFriend($xoopsUser->uid())) { return; } } //Verificamos la privacidad de las imágenes if ($xoopsUser && $xoopsUser->uid() == $user->uid()) { $public = ''; } else { if ($xoopsUser && $user->isFriend($xoopsUser->uid())) { $public = " AND public<>0"; } else { $public = "AND public='2'"; } } $db = XoopsDatabaseFactory::getDatabaseConnection(); $tbl1 = $db->prefix("gs_images"); $tbl2 = $db->prefix("gs_setsimages"); $sql = "SELECT COUNT(*) FROM {$tbl1} a, {$tbl2} b WHERE b.id_set='" . $set->id() . "' AND a.id_image=b.id_image {$public} AND owner='" . $user->uid() . "'"; list($num) = $db->fetchRow($db->query($sql)); $start = $page * $limit - $limit; $sql = str_replace("COUNT(*)", '*', $sql); $sql .= " ORDER BY a.id_image ASC, a.modified DESC LIMIT {$start}, {$limit}"; $result = $db->query($sql); if ($db->getRowsNum($result) <= 0) { return; } $ret['images'] = self::process_image_data($result); $ret['total'] = $num; $ret['start'] = $start; $ret['limit'] = $limit; $ret['current'] = $page; $ret['set'] = array('id' => $set->id(), 'title' => $set->title(), 'link' => $set->url()); return $ret; }
function gs_sets_show($options) { global $xoopsUser, $xoopsModuleConfig; $db = Database::getInstance(); $wo = ''; $tsets = $db->prefix("gs_sets"); $tfriends = $db->prefix("gs_friends"); $mc = RMUtilities::module_config('galleries'); $format = $mc['set_format_values']; $crop = $format[0]; // 0 = Redimensionar, 1 = Cortar $width = $format[1]; $height = $format[2]; if ($xoopsUser) { $wo = "{$tsets}.owner='" . $xoopsUser->uid() . "' OR"; } $sql = "SELECT * FROM {$tsets} WHERE owner='1' OR public='2' ORDER BY `date` DESC LIMIT 0,{$options['0']}"; $result = $db->query($sql); include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsset.class.php'; include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsuser.class.php'; include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsimage.class.php'; include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsfunctions.class.php'; $block = array(); $users = array(); $tf = new RMTimeFormatter(0, '%T% %d%, %Y%'); while ($row = $db->fetchArray($result)) { $rtn = array(); $set = new GSSet(); $set->assignVars($row); if (!isset($users[$set->owner()])) { $users[$set->owner()] = new GSUser($set->owner(), 1); } // Si se ha seleccionado la opción para mostrar imágenes entonces... if ($options[1]) { //Obtenemos una imagen del album $sql = "SELECT b.* FROM " . $db->prefix('gs_setsimages') . " a, " . $db->prefix('gs_images') . " b WHERE"; $sql .= " a.id_set='" . $set->id() . "' AND b.id_image=a.id_image AND b.public=2 AND b.owner='" . $set->owner() . "' ORDER BY b.created DESC LIMIT 0,1"; $resimg = $db->query($sql); if ($db->getRowsNum($resimg) > 0) { $rowimg = $db->fetchArray($resimg); $img = new GSImage(); $img->assignVars($rowimg); $urlimg = $users[$set->owner()]->filesURL() . '/' . ($mc['set_format_mode'] ? 'formats/set_' : 'ths/') . $img->image(); // Conversion de los formatos if (!$img->setFormat() && $mc['set_format_mode']) { GSFunctions::resizeImage($crop, $users[$set->owner()]->filesPath() . '/' . $img->image(), $users[$set->owner()]->filesPath() . '/formats/set_' . $img->image(), $width, $height); $img->setSetFormat(1, 1); } } else { $urlimg = ''; } $rtn['img'] = $urlimg; } $rtn['id'] = $set->id(); $rtn['title'] = $set->title(); $rtn['owner'] = $set->owner(); $rtn['link'] = $users[$set->owner()]->userURL() . ($mc['urlmode'] ? 'set/' . $set->id() . '/' : '&set=' . $set->id()); if ($options[2]) { $rtn['date'] = $tf->format($set->date()); $rtn['pics'] = $set->pics(); $rtn['uname'] = $set->uname(); $rtn['linkuser'] = $users[$set->owner()]->userURL(); } $block['sets'][] = $rtn; } $block['showimg'] = $options[1]; $block['showinfo'] = $options[2]; $block['item_width'] = $options[3]; RMTemplate::get()->add_xoops_style('blocks.css', 'galleries'); RMTemplate::get()->add_local_script('blocks.js', 'galleries'); return $block; }
if (!isset($users[$set->owner()])) { $users[$set->owner()] = new GSUser($set->owner(), 1); } $images = array(); if (!empty($imgs)) { // Obtenemos las primeras 4 imágenes foreach ($imgs as $k) { $img = new GSImage($k); if ($img->isPublic() != 2) { continue; } if (!isset($users[$img->owner()])) { $users[$img->owner()] = new GSUser($img->owner(), 1); } $imglink = $users[$img->owner()]->userURL() . 'img/' . $img->id() . '/'; $images[] = array('id' => $img->id(), 'title' => $img->title(), 'thumbnail' => $users[$img->owner()]->filesURL() . '/ths/' . $img->image(), 'image' => $users[$img->owner()]->filesURL() . '/' . $img->image(), 'by' => sprintf(__('by %s', 'galleries'), '<a href="' . $users[$img->owner()]->userUrl() . '">' . $users[$img->owner()]->uname() . '</a>'), 'link' => $imglink); } } $tpl->append('sets', array('id' => $set->id(), 'title' => $set->title(), 'images' => $images, 'link' => $users[$set->owner()]->userUrl() . ($mc['urlmode'] ? 'set/' . $set->id() : '&set=' . $set->id()), 'date' => formatTimestamp($set->date(), 'c'), 'by' => '<a href="' . $users[$set->owner()]->userUrl() . '">' . $users[$set->owner()]->uname() . '</a>', 'picsnum' => count($pics))); } $result = $db->query("SELECT * FROM " . $db->prefix("gs_sets") . " WHERE public='2' ORDER BY date DESC LIMIT {$mc['sets_num']}," . ($mc['sets_num'] > 0 ? $mc['sets_num'] : 5)); while ($row = $db->fetchArray($result)) { $set = new GSSet(); $set->assignVars($row); if (!isset($users[$set->owner()])) { $users[$set->owner()] = new GSUser($set->owner(), 1); } $tpl->append('other_sets', array('id' => $set->id(), 'title' => $set->title(), 'link' => $users[$set->owner()]->userUrl() . ($mc['urlmode'] ? 'set/' . $set->id() : '&set=' . $set->id()), 'date' => formatTimestamp($set->date(), 'c'), 'by' => '<a href="' . $users[$set->owner()]->userUrl() . '">' . $users[$set->owner()]->uname() . '</a>', 'picsnum' => count($pics))); } RMTemplate::get()->add_style('index.css', 'galleries'); include 'footer.php';
/** * @desc Elimina de la base de datos la información del album especificado **/ function deleteSets() { global $util, $xoopsModule, $db, $xoopsModuleConfig, $page; $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0; $mc =& $xoopsModuleConfig; $link = GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/sets/pag/' . $pag . '/' : '?cp=sets&pag=' . $pag); //Verificamos si nos proporcionaron al menos un imagen para eliminar if (!is_array($ids)) { redirect_header($link, 2, __('You must selecte one album at least!', 'galleries')); die; } $errors = ''; foreach ($ids as $k) { //Verificamos si el album es válido if ($k <= 0) { $errors .= sprintf(__('Album id %u is not valid!', 'galleries'), $k); continue; } //Verificamos si el album existe $set = new GSSet($k); if ($set->isNew()) { $errors .= sprintf(__('Album with id %u does not exists!', 'galleries'), $k); continue; } if (!$set->delete()) { $errors .= sprintf(__('Album "%s" could not be deleted!', 'galleries'), $set->title()); } } if ($errors != '') { redirect_header($link, 2, __('Errors ocurred while trying to delete albums', 'galleries') . '<br />' . $errors); die; } else { redirect_header($link, 1, __('Abums deleted successfully!', 'galleries')); die; } }
/** * @desc Visualiza todos los albumes existentes **/ function sets() { global $tpl, $xoopsOption, $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $db, $pag, $usr; $mc =& $xoopsModuleConfig; $xoopsOption['template_main'] = 'gs_sets.html'; $xoopsOption['module_subpage'] = 'exploresets'; include 'header.php'; //Verificamos si el usuario proporcionado existe if ($usr) { $owner = new GSUser($usr); if ($owner->isNew()) { redirect_header(GSFunctions::get_url(), 1, __('Specified user does not exists!', 'galleries')); die; } } GSFunctions::makeHeader(); //Verificamos si el usuario es dueño o amigo if ($usr && $xoopsUser) { if ($owner->uid() == $xoopsUser->uid()) { $public = ''; } else { if ($owner->isFriend($xoopsUser->uid())) { $public = " WHERE public<>'0'"; } else { $public = " WHERE public='2'"; } } } else { $public = " WHERE public='2'"; } //Barra de Navegación $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_sets') . " {$public} "; $sql .= isset($usr) ? ($public ? " AND " : " WHERE ") . " uname='" . $usr . "'" : ''; $page = isset($pag) ? $pag : ''; $limit = $mc['limit_sets']; /** * @desc Formato para el manejo de las imágenes */ if ($mc['set_format_mode']) { $format = $mc['set_format_values']; $crop = $format[0]; // 0 = Redimensionar, 1 = Cortar $width = $format[1]; $height = $format[2]; $limit = $mc['limit_sets']; $cols = $format[4]; $showdesc = @$format[5]; } else { $limit = $mc['limit_sets']; $cols = $mc['cols_sets']; $showdesc = 0; $width = $mc['image_ths'][0]; } list($num) = $db->fetchRow($db->query($sql)); if ($page > 0) { $page -= 1; } $start = $page * $limit; $tpages = (int) ($num / $limit); if ($num % $limit > 0) { $tpages++; } $pactual = $page + 1; if ($pactual > $tpages) { $rest = $pactual - $tpages; $pactual = $pactual - $rest + 1; $start = ($pactual - 1) * $limit; } if ($tpages > 1) { if ($mc['urlmode']) { $urlnav = 'explore/sets/'; $urlnav .= isset($usr) ? 'usr/' . $usr . '/' : ''; } else { $urlnav = '?explore=sets'; $urlnav .= isset($usr) ? '&usr='******''; } $nav = new RMPageNav($num, $limit, $pactual, 5); $nav->target_url(GSFunctions::get_url() . $urlnav . ($mc['urlmode'] ? 'pag/{PAGE_NUM}/' : '&pag={PAGE_NUM}')); $tpl->assign('setsNavPage', $nav->render(false)); } $showmax = $start + $limit; $showmax = $showmax > $num ? $num : $showmax; $tpl->assign('lang_showing', sprintf(__('Albums %u to %u from %u', 'galleries'), $start + 1, $showmax, $num)); $tpl->assign('limit', $limit); $tpl->assign('pag', $pactual); //Fin de barra de navegación $sql = "SELECT * FROM " . $db->prefix('gs_sets') . " {$public}"; $sql .= isset($usr) ? ($public ? " AND " : " WHERE ") . "uname='" . $usr . "'" : ''; $sql .= " ORDER BY date desc"; $sql .= " LIMIT {$start},{$limit}"; $result = $db->query($sql); $users = array(); $tf = new RMTimeFormatter(0, __("%M% %d%, %Y%", 'galleries')); while ($rows = $db->fetchArray($result)) { $set = new GSSet(); $set->assignVars($rows); //Obtenemos una imagen del album $sql = "SELECT b.* FROM " . $db->prefix('gs_setsimages') . " a, " . $db->prefix('gs_images') . " b WHERE"; $sql .= " a.id_set='" . $set->id() . "' AND b.id_image=a.id_image AND b.public=2 AND b.owner='" . $set->owner() . "' ORDER BY b.created DESC LIMIT 0,1"; $resimg = $db->query($sql); if (!isset($users[$set->owner()])) { $users[$set->owner()] = new GSUser($set->owner(), 1); } if ($db->getRowsNum($resimg) > 0) { $rowimg = $db->fetchArray($resimg); $img = new GSImage(); $img->assignVars($rowimg); $urlimg = $users[$set->owner()]->filesURL() . '/' . ($mc['set_format_mode'] ? 'formats/set_' : 'ths/') . $img->image(); // Conversion de los formatos if (!$img->setFormat() && $mc['set_format_mode']) { GSFunctions::resizeImage($crop, $users[$set->owner()]->filesPath() . '/' . $img->image(), $users[$set->owner()]->filesPath() . '/formats/set_' . $img->image(), $width, $height); $img->setSetFormat(1, 1); } } else { $urlimg = ''; } $tpl->append('sets', array('id' => $set->id(), 'title' => $set->title(), 'date' => $tf->format($set->date()), 'owner' => $set->owner(), 'uname' => $set->uname(), 'pics' => $set->pics(), 'img' => $urlimg, 'link' => $users[$set->owner()]->userURL() . ($mc['urlmode'] ? 'set/' . $set->id() . '/' : '&set=' . $set->id()), 'linkuser' => $users[$set->owner()]->userURL())); } $tpl->assign('lang_date', __('Created on:', 'galleries')); $tpl->assign('lang_by', __('Owned by:', 'galleries')); $tpl->assign('margin', $width + 20); $tpl->assign('lang_imgs', __('Images:', 'galleries')); $tpl->assign('usr', isset($owner) ? 1 : 0); $tpl->assign('lang_setsexist', __('Existing Albums', 'galleries')); if (isset($owner)) { $tpl->assign('user', array('id' => $owner->uid(), 'uname' => $owner->uname(), 'avatar' => RMEvents::get()->run_event('rmcommon.get.avatar', $owner->userVar('email'), 0, $owner->userVar('user_avatar')))); $tpl->assign('lang_setsof', sprintf(__('Sets of %s', 'galleries'), $owner->uname())); $tpl->assign('pics_link', GSFunctions::get_url() . ($mc['urlmode'] ? "usr/" . $owner->uname() . '/' : "?usr="******"explore/sets/usr/" . $owner->uname() . '/' : "?explore=sets&usr="******"explore/tags/usr/" . $owner->uname() . '/' : "?explore=tags&usr="******"cp/booksmarks/" : "?cp=bookmarks")); } include 'footer.php'; }
/** * @desc Visualiza todas las imágenes pertenecientes del usuario **/ function showImages() { global $xoopsOption, $tpl, $db, $xoopsUser, $xoopsModuleConfig, $set, $xoopsConfig, $cp; $mc =& $xoopsModuleConfig; $xoopsOption['template_main'] = 'gs_panel.html'; include 'header.php'; GSFunctions::makeHeader(); if ($set) { //Verificamos si el album es válido if ($set <= 0) { redirect_header(GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/sets/' : '?cp=sets'), 1, __('Specified album is not valid!', 'galleries')); die; } //Verificamos que el album exista $album = new GSSet($set); if ($album->isNew()) { redirect_header(GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/sets/' : '?cp=sets'), 1, __('Specified album does not exists!', 'galleries')); die; } } //Barra de Navegación $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_images') . " a "; $sql .= $set ? " INNER JOIN " . $db->prefix('gs_setsimages') . " b ON (a.id_image=b.id_image AND b.id_set='" . $set . "' AND a.owner='" . $xoopsUser->uid() . "') " : " WHERE a.owner=" . $xoopsUser->uid(); global $page; $page = $page <= 0 ? 1 : $page; $limit = isset($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 10; $limit = $limit <= 0 ? 10 : $limit; $user = new GSUser($xoopsUser->uid(), 1); list($num) = $db->fetchRow($db->query($sql)); if ($page > 0) { $page -= 1; } $start = $page * $limit; $tpages = (int) ($num / $limit); if ($num % $limit > 0) { $tpages++; } $pactual = $page + 1; if ($pactual > $tpages) { $rest = $pactual - $tpages; $pactual = $pactual - $rest + 1; $start = ($pactual - 1) * $limit; } if ($tpages > 1) { $nav = new RMPageNav($num, $limit, $pactual, 5); $nav->target_url(GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/' . $cp . '/pag/{PAGE_NUM}/' : '?cp=' . $cp . '&pag={PAGE_NUM}')); $tpl->assign('picsNavPage', $nav->render(false)); } $showmax = $start + $limit; $showmax = $showmax > $num ? $num : $showmax; $tpl->assign('lang_showing', sprintf(__('Showing images %u to %u of %u'), $start + 1, $showmax, $num)); $tpl->assign('limit', $limit); $tpl->assign('pag', $pactual); //Fin de barra de navegación $sql = "SELECT a.* FROM " . $db->prefix('gs_images') . " a "; $sql .= $set ? " INNER JOIN " . $db->prefix('gs_setsimages') . " b ON (a.id_image=b.id_image AND b.id_set='" . $set . "' AND a.owner='" . $xoopsUser->uid() . "') GROUP BY a.id_image" : " WHERE a.owner=" . $xoopsUser->uid(); $sql .= " ORDER BY created DESC LIMIT {$start},{$limit}"; $result = $db->query($sql); $tpl->assign('images', GSFunctions::process_image_data($result)); $tpl->assign('lang_exists', $set ? sprintf(__('Existing images for user "%s" in album "%s"', 'galleries'), $xoopsUser->uname(), $album->title()) : sprintf(__('Existing images for user "%s"', 'galleries'), $xoopsUser->uname())); $tpl->assign('lang_id', __('ID', 'galleries')); $tpl->assign('lang_title', __('Title', 'galleries')); $tpl->assign('lang_image', __('Image', 'galleries')); $tpl->assign('lang_public', __('Public', 'galleries')); $tpl->assign('lang_created', __('Created', 'galleries')); $tpl->assign('lang_edit', __('Edit', 'galleries')); $tpl->assign('lang_del', __('Delete', 'galleries')); $tpl->assign('lang_options', __('Options', 'galleries')); $tpl->assign('lang_set', __('Add to Album...', 'galleries')); $tpl->assign('lang_confirm', __('Do you really wish to delete specified picture?', 'galleries')); $tpl->assign('lang_confirms', __('Do you really wish to deleted selected pictures?', 'galleries')); $tpl->assign('lang_save', __('Save Changes', 'galleries')); $tpl->assign('lang_changename', __('Change name', 'galleries')); $tpl->assign('lang_changedesc', __('Change description', 'galleries')); $tpl->assign('lang_adddesc', __('Add Description', 'galleries')); //Links de menu $tpl->assign('link_sets', GSFunctions::get_url() . ($mc['urlmode'] ? "cp/sets" : "?cp=sets")); $tpl->assign('edit_link', GSFunctions::get_url() . ($mc['urlmode'] ? "cp/edit/pag/{$pactual}/id/" : "?cp=edit&pag={$page}&id=")); $tpl->assign('delete_link', GSFunctions::get_url() . ($mc['urlmode'] ? "cp/delete/pag/{$pactual}/ids/" : "?cp=delete&pag={$page}&ids=")); RMTemplate::get()->add_local_script('panel.js', 'galleries'); RMTemplate::get()->add_local_script('jquery.checkboxes.js', 'rmcommon', 'include'); RMTemplate::get()->add_style('panel.css', 'galleries'); createLinks(); include 'footer.php'; }