/** * @desc Visualiza todos los albums **/ function showAlbums() { global $tpl, $xoopsModule, $mc, $xoopsSecurity; define('RMSUBLOCATION', 'sets'); $db = Database::getInstance(); $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1; $limit = 15; $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'id_set'; $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 1; $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : ''; $query = "search={$search}&page={$page}&sort={$sort}&mode={$mode}"; //Barra de Navegación $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_sets'); $sql1 = ''; $words = array(); if ($search) { //Separamos en palabras $words = explode(" ", $search); foreach ($words as $k) { $k = trim($k); if (strlen($k) <= 2) { continue; } $sql1 .= $sql1 == '' ? " WHERE (title LIKE '%{$k}%' OR uname LIKE '%{$k}%')" : " OR (title LIKE '%{$k}%' OR uname LIKE '%{$k}%')"; } } list($num) = $db->fetchRow($db->query($sql . $sql1)); $start = $num <= 0 ? 0 : ($page - 1) * $limit; $tpages = ceil($num / $limit); $nav = new RMPageNav($num, $limit, $page, 5); $nav->target_url("sets.php?page={PAGE_NUM}&sort={$sort}&mode={$mode}&search={$search}"); //Fin de barra de navegación $sql = str_replace('COUNT(*)', '*', $sql); $sql2 = $sort ? " ORDER BY {$sort} " . ($mode ? "DESC" : "ASC ") : ''; $sql2 .= " LIMIT {$start},{$limit}"; $result = $db->query($sql . $sql1 . $sql2); $sets = array(); while ($rows = $db->fetchArray($result)) { foreach ($words as $k) { $rows['title'] = eregi_replace("({$k})", "<span class='searchResalte'>\\1</span>", $rows['title']); $rows['uname'] = eregi_replace("({$k})", "<span class='searchResalte'>\\1</span>", $rows['uname']); } $set = new GSSet(); $set->assignVars($rows); $sets[] = array('id' => $set->id(), 'title' => $set->title(), 'owner' => $set->uname(), 'public' => $set->isPublic(), 'date' => formatTimeStamp($set->date(), 'c'), 'pics' => $set->pics(), 'url' => $set->url()); } GSFunctions::toolbar(); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » " . __('Albums Management', 'galleries')); RMTemplate::get()->assign('xoops_pagetitle', 'Albums Management'); RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.checkboxes.js'); RMTemplate::get()->add_head("<script type='text/javascript'>\n\n var delete_warning='" . __('Do you really wish to delete selected albums?', 'galleries') . "';\n\n var delete_formats='" . __('Do you really wish to delete all images formats for this album?\\nOnly deletes formats for albums, search and others, except normal thumbnails.', 'galleries') . "';\n\n </script>"); RMTemplate::get()->add_script('../include/js/gsscripts.php?file=sets'); $cHead = '<link href="' . XOOPS_URL . '/modules/galleries/styles/admin.css" media="all" rel="stylesheet" type="text/css" />'; xoops_cp_header($cHead); include RMTemplate::get()->get_template('admin/gs_albums.php', 'module', 'galleries'); xoops_cp_footer(); }
public function get_item_url($params, $com) { 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])) { $ret = $csets[$set]->url() . '#comment-' . $com->id(); return $ret; } $sobj = new GSSet($set); if ($sobj->isNew()) { return ''; } $ret = $sobj->url() . '#comment-' . $com->id(); $csets[$set] = $sobj; return $ret; } elseif (isset($image) && $image > 0) { if (isset($cimgs[$image])) { $ret = $cimgs[$image]->permalink() . '#comment-' . $com->id(); return $ret; } $img = new GSImage($image); if ($img->isNew()) { return ''; } $ret = $img->permalink() . '#comment-' . $com->id(); $cimgs[$image] = $img; 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])) { $ret = '<a href="' . $csets[$set]->url() . '#comment-' . $com->id() . '">' . $csets[$set]->title() . '</a>'; return $ret; } $sobj = new GSSet($set); if ($sobj->isNew()) { return __('Unknow element', 'galleries'); } $ret = '<a href="' . $sobj->url() . '#comment-' . $com->id() . '">' . $sobj->title() . '</a>'; $csets[$set] = $sobj; return $ret; } elseif (isset($image) && $image > 0) { if (isset($cimgs[$image])) { $ret = '<a href="' . $cimgs[$image]->permalink() . '#comment-' . $com->id() . '">' . $cresources[$res]->getVar('title') . '</a>'; return $ret; } $img = new GSImage($image); if ($img->isNew()) { return __('Unknow element', 'docs'); } $ret = '<a href="' . $img->permalink() . '#comment-' . $com->id() . '">' . $img->title(true) . '</a>'; $cimgs[$image] = $img; return $ret; } }
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; }
/** * 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; }
/** * @desc Visualiza todos los albumes existentes del usuario **/ function showSets($edit = 0) { global $xoopsOption, $tpl, $db, $xoopsUser, $xoopsModuleConfig, $page, $xoopsConfig, $id; $xoopsOption['template_main'] = 'gs_panel_sets.html'; include 'header.php'; $mc =& $xoopsModuleConfig; $limit = rmc_server_var($_REQUEST, 'limit', 15); GSFunctions::makeHeader(); $link = GSFunctions::get_url() . ($mc['urlmode'] ? '/cpanel/sets/pag/' . $page : '/cpanel.php?s=cpanel/sets/' . $page); if ($edit) { //Verificamos que el album sea válido if ($id <= 0) { redirect_header($link, 1, __('Album ID is not valid!', 'galleries')); die; } //Verificamos que el album exista $set = new GSSet($id); if ($set->isNew()) { redirect_header($link, 1, __('Specified album does not exists!', 'galleries')); die; } $tpl->assign('title', $set->title()); $tpl->assign('public', $set->isPublic()); $tpl->assign('edit', $edit); $tpl->assign('id', $id); $tpl->assign('action_editset', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/saveeditset/pag/' . $page . '/' : '?cp=saveeditset&pag=' . $page)); } //Barra de Navegación $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_sets') . " WHERE owner='" . $xoopsUser->uid() . "'"; list($num) = $db->fetchRow($db->query($sql)); $page = $page <= 0 ? 1 : $page; list($num) = $db->fetchRow($db->query($sql)); $start = $num <= 0 ? 0 : ($page - 1) * $limit; $tpages = ceil($num / $limit); $nav = new RMPageNav($num, $limit, $page, 5); $nav->target_url(GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/sets/pag/{PAGE_NUM}/' : '?cp=sets&pag={PAGE_NUM}')); //Fin de barra de navegación $sql = "SELECT * FROM " . $db->prefix('gs_sets') . " WHERE owner='" . $xoopsUser->uid() . "'"; $sql .= " LIMIT {$start},{$limit}"; $result = $db->query($sql); while ($rows = $db->fetchArray($result)) { $set = new GSSet(); $set->assignVars($rows); $tpl->append('sets', array('id' => $set->id(), 'name' => $set->title(), 'owner' => $set->owner(), 'uname' => $set->uname(), 'public' => $set->isPublic(), 'date' => formatTimeStamp($set->date(), 's'), 'pics' => $set->pics(), 'link' => $set->url())); } $tpl->assign('lang_setexists', __('My Albums', 'galleries')); $tpl->assign('lang_id', __('ID', 'galleries')); $tpl->assign('lang_name', __('Name', 'galleries')); $tpl->assign('lang_date', __('Date', 'galleries')); $tpl->assign('lang_public', __('Privacy:', 'galleries')); $tpl->assign('lang_options', _OPTIONS); $tpl->assign('lang_edit', _EDIT); $tpl->assign('lang_del', _DELETE); $tpl->assign('lang_confirm', __('Do you really wish to delete specified album?', 'galleries')); $tpl->assign('lang_confirms', __('Do you really wish to delete selected albums?', 'galleries')); $tpl->assign('lang_newset', __('Add Album', 'galleries')); $tpl->assign('lang_editset', __('Edit Album', 'galleries')); $tpl->assign('lang_yes', __('Yes', 'galleries')); $tpl->assign('lang_no', __('No', 'galleries')); $tpl->assign('lang_pics', __('Pictures', 'galleries')); $tpl->assign('lang_privateme', __('Private', 'galleries')); $tpl->assign('lang_privatef', __('Friends', 'galleries')); $tpl->assign('lang_publicset', __('Public', 'galleries')); RMTemplate::get()->add_style('panel.css', 'galleries'); $tpl->assign('action_addset', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/saveset/pag/' . $page . '/' : '?cp=saveset')); $tpl->assign('pag', $page); $tpl->assign('action_delset', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/deleteset/pag/' . $page . '/' : '?cp=deleteset')); $tpl->assign('edit_link', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/editset/pag/' . $page . '/id/' : '?cp=editset&pag=' . $page . '&id=')); createLinks(); include 'footer.php'; }