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; } }
/** * This function deletes all image formats, except thumbnails, for specified albums. * This is useful when you need to regenerate images */ function delete_formats() { global $xoopsModuleConfig; $id = rmc_server_var($_GET, 'id', 0); $page = rmc_server_var($_GET, 'page', 1); if ($id <= 0) { redirectMsg("sets.php?page={$page}", __('Sorry, this is not a valid album!', 'galleries'), 1); die; } $set = new GSSet($id); if ($set->isNew()) { redirectMsg("sets.php?page={$page}", __('Specified Album does not exists!', 'galleries'), 1); die; } $db = Database::getInstance(); $t1 = $db->prefix("gs_images"); $t2 = $db->prefix("gs_setsimages"); $sql = "SELECT a.image FROM {$t1} a, {$t2} b WHERE b.id_set={$id} AND a.id_image=b.id_image"; $result = $db->query($sql); $dir = rtrim($xoopsModuleConfig['storedir'], '/'); if ($set->uname() == '') { $user = new XoopsUser($set->owner()); $uname = $user->uname(); } else { $uname = $set->uname(); } if ($uname == '') { redirectMsg('sets.php?page=' . $page, __('Sorry, we were unable to find the album owner!', 'galleries'), 1); break; } $dir .= '/' . $uname . '/formats'; if (!is_dir($dir)) { redirectMsg('sets.php?page=' . $page, __('There are not image formats for this album.', 'galleries'), 0); die; } while (list($image) = $db->fetchRow($result)) { @unlink($dir . '/bigset_' . $image); @unlink($dir . '/set_' . $image); @unlink($dir . '/user_' . $image); @unlink($dir . '/srh_' . $image); } $pics = $set->getPics(); $sql = "UPDATE {$t1} SET user_format=0, set_format=0, bigset_format=0, search_format=0 WHERE id_image IN (" . implode(",", $pics) . ")"; $db->queryF($sql); redirectMsg('sets.php?page=' . $page, __('Image formats deleted!', 'galleries'), 0); }
/** * @desc Busca la posición exacta de una etiqueta */ function browsePic() { global $usr, $mc, $xoopsModuleConfig, $xoopsConfig, $xoopsUser, $pag, $set, $browse; $mc =& $xoopsModuleConfig; $user = new GSUser($usr); if ($user->isNew()) { redirect_header(XOOPS_URL . '/modules/galleries', 0, _MS_GS_ERRUSR); die; } $image = new GSImage($browse); if ($image->isNew()) { redirect_header(XOOPS_URL . '/modules/galleries', 0, _MS_GS_ERRIMG); die; } if (isset($set)) { $set = new GSSet($set); if ($set->isNew()) { redirect_header(XOOPS_URL . '/modules/galleries', 0, _MS_GS_ERRSET); die; } } $page = GSFunctions::pageFromPic($image, $user, $set > 0 ? $set : 0); header('location: ' . $user->userURL() . 'pag/' . $page); }
/** * 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 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 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'; }