/** * @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'; }
/** * @desc Visualiza la postal **/ function viewPostcard() { global $tpl, $xoopsModule, $xoopsModuleConfig, $xoopsModuleConfig, $mc, $xoopsUser, $id; include_once XOOPS_ROOT_PATH . '/class/template.php'; $tpl = new XoopsTpl(); $mc =& $xoopsModuleConfig; if (!$xoopsUser) { redirect_header(XOOPS_URL . '/user.php#register', 1, _MS_GS_ERRUSR); die; } //Verificamos si la postal existe $post = new GSPostcard($id); if ($post->isNew()) { redirect_header(XOOPS_URL . '/modules/galleries/', 1, _MS_GS_ERRPOSTEXIST); die; } $img = new GSImage($post->image()); if ($img->isNew()) { redirect_header(XOOPS_URL . '/modules/galleries/', 1, _MS_GS_ERRIMG); die; } $user = new GSUser($img->owner(), 1); $file = $user->filesPath() . '/' . $img->image(); list($ancho, $alto) = getimagesize($file); $tpl->assign('gs_url', XOOPS_URL . '/modules/galleries'); $tpl->assign('img', array('id' => $img->id(), 'width' => $ancho, 'height' => $alto, 'url' => $user->filesURL() . '/' . $img->image(), 'link' => $user->userURL() . 'img/' . $img->id() . '/')); $tpl->assign('title', $post->title()); $tpl->assign('message', $post->message()); $tpl->assign('lang_says', sprintf(_MS_GS_SAYS, $post->name())); $tpl->assign('xoops_pagetitle', sprintf(_MS_GS_PTITLE, $post->title()) . ' » ' . $mc['section_title']); $tpl->assign('lang_see', _MS_GS_SEE); $tpl->assign('user_link', $user->userURL() . 'browse/' . $img->id() . '/'); $tpl->assign('lang_seeuser', _MS_GS_SEEUSER); $tpl->assign('preview', 0); RMTemplate::get()->add_xoops_style('postcard.css', 'galleries'); //Actualizar datos de postal $post->setViewed(1); $post->save(); echo $tpl->fetch("db:gs_postcard.html"); }
/** * @desc Formulario de creación/edición de imágenes **/ function formImages($edit = 0) { global $xoopsModule, $mc, $xoopsUser, $db; $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1; $limit = isset($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 10; $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : ''; $owner = isset($_REQUEST['owner']) ? $_REQUEST['owner'] : ''; $uid = isset($_REQUEST['uid']) ? intval($_REQUEST['uid']) : 0; $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'created'; $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 0; $ruta = "page={$page}&limit={$limit}&search={$search}&owner={$owner}&sort={$sort}&mode={$mode}"; if ($edit) { //Verificamos si la imagen es válida if ($id <= 0) { redirectMsg('./images.php?' . $ruta, __('Image ID not valid!', 'galleries'), 1); die; } //Verificamos si la imagen existe $img = new GSImage($id); if ($img->isNew()) { redirectMsg('./images.php?' . $ruta, __('Specified image does not exists!', 'galleries'), 1); die; } } GSFunctions::toolbar(); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » <a href='./images.php'>" . __('Images', 'galleries') . "</a> » " . ($edit ? __('Edit image', 'galleries') : __('Add image', 'galleries'))); xoops_cp_header(); $form = new RMForm($edit ? __('Editing image', 'galleries') : __('Add image', 'galleries'), 'frmimg', 'images.php'); $form->setExtra("enctype='multipart/form-data'"); if (!$edit) { $ele = new RMFormUser(__('User', 'galleries'), 'uid', 0, $uid ? array($uid) : ($edit ? array($img->owner()) : array($xoopsUser->uid())), 50); $ele->onChange("\$('op').value='" . ($edit ? 'edit' : 'new') . "'; \$('frmimg').submit();"); $form->addElement($ele); } else { $xu = new XoopsUser($img->owner()); $form->addElement(new RMFormLabel(__('User', 'galleries'), $xu->uname())); $form->addElement(new RMFormHidden('uid', $img->owner())); } $form->addElement(new RMFormText(__('Title', 'galleries'), 'title', 50, 100, $edit ? $img->title() : '')); $form->addElement(new RMFormFile(__('Image file', 'galleries'), 'image', 45, $mc['size_image'] * 1024)); if ($edit) { $user = new GSUser($img->owner(), 1); $url = $user->filesURL(); $form->addElement(new RMFormLabel(__('Current image', 'galleries'), "<img src='" . $url . "/ths/" . $img->image() . "' />")); } $form->addElement(new RMFormTextArea(__('Description', 'galleries'), 'desc', 4, 50, $edit ? $img->desc() : '')); $ele = new RMFormSelect(__('Privacy', 'galleries'), 'public'); $ele->addOption(0, __('Private', 'galleries'), $edit ? $img->isPublic() == 0 ? 1 : 0 : 0); $ele->addOption(1, __('Visible for friends', 'galleries'), $edit ? $img->isPublic() == 1 ? 1 : 0 : 0); $ele->addOption(2, __('Visible for all', 'galleries'), $edit ? $img->isPublic() == 2 ? 1 : 0 : 1); $form->addElement($ele, true); $db = Database::getInstance(); //Albumes if ($edit) { $albums = $img->sets(false); foreach ($albums as $k => $v) { $sets[] = $v['id_set']; } } $ele = new RMFormSelect(__('Albums', 'galleries'), 'albums[]', 1, $edit ? $sets : ''); $sql = "SELECT * FROM " . $db->prefix('gs_sets') . " WHERE owner='" . ($uid ? $uid : ($edit ? $img->owner() : $xoopsUser->uid())) . "'"; $result = $db->query($sql); while ($rows = $db->fetchArray($result)) { $ele->addOption($rows['id_set'], $rows['title']); } $form->addElement($ele); $ele = new RMFormText(__('Tags', 'galleries'), 'tags', 50, 100, $edit ? implode(", ", $img->tags(false, 'tag')) : ''); $ele->setDescription(__('Separate each tag with a comma (,)', 'galleries')); $form->addElement($ele, true); $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save')); if ($edit) { $form->addElement(new RMFormHidden('id', $id)); } $form->addElement(new RMFormHidden('page', $page)); $form->addElement(new RMFormHidden('limit', $limit)); $form->addElement(new RMFormHidden('search', $search)); $form->addElement(new RMFormHidden('owner', $owner)); $form->addElement(new RMFormHidden('sort', $sort)); $form->addElement(new RMFormHidden('mode', $mode)); $buttons = new RMFormButtonGroup(); $buttons->addButton('sbt', $edit ? __('Save changes', 'galleries') : __('Add image', 'galleries'), 'submit'); $buttons->addButton('cancel', __('Cancel', 'galleries'), 'button', 'onclick="window.location=\'images.php?' . $ruta . '\'"'); $form->addElement($buttons); $form->display(); xoops_cp_footer(); }
/** * @desc Visualiza la postal **/ function viewPostcard() { global $tpl, $xoopsModule, $xoopsModuleConfig, $xoopsModuleConfig, $mc, $xoopsUser, $id; include_once XOOPS_ROOT_PATH . '/class/template.php'; $tpl = new XoopsTpl(); $mc =& $xoopsModuleConfig; //Verificamos si la postal existe $post = new GSPostcard($id); if ($post->isNew()) { redirect_header(XOOPS_URL . '/modules/galleries/', 1, __('Specified E_Card does not exists!', 'galleries')); die; } $img = new GSImage($post->image()); if ($img->isNew()) { redirect_header(XOOPS_URL . '/modules/galleries/', 1, __('Sorry, there are some problems with this e-card!', 'galleries')); die; } $user = new GSUser($img->owner(), 1); $file = $user->filesPath() . '/' . $img->image(); list($ancho, $alto) = getimagesize($file); $tpl->assign('gs_url', XOOPS_URL . '/modules/galleries'); $tpl->assign('img', array('id' => $img->id(), 'width' => $ancho, 'height' => $alto, 'url' => $user->filesURL() . '/' . $img->image(), 'link' => $user->userURL() . 'img/' . $img->id() . '/')); $tpl->assign('title', $post->title()); $tpl->assign('message', $post->message()); $tpl->assign('lang_says', sprintf(__('%s says:'), $post->name())); $tpl->assign('xoops_pagetitle', sprintf(__('%s, E-Card', 'galleries'), $post->title()) . ' » ' . $mc['section_title']); $tpl->assign('lang_see', __('View Picture', 'galleries')); $tpl->assign('user_link', $user->userURL() . 'browse/' . $img->id() . '/'); $tpl->assign('lang_seeuser', __('View User Pictures', 'galleries')); $tpl->assign('preview', 0); RMTemplate::get()->add_xoops_style('postcard.css', 'galleries'); //Actualizar datos de postal $post->setViewed(1); $post->save(); echo $tpl->fetch("db:gs_postcard.html"); }
/** * @desc Formulario de imágenes **/ function formImages($edit = 0) { global $xoopsOption, $tpl, $db, $xoopsUser, $xoopsModuleConfig, $xoopsUser, $xoopsConfig, $id, $referer, $page; $mc =& $xoopsModuleConfig; if (!$referer) { $referer = GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/images/pag/' . $page . '/' : '?cp=images&pag=' . $page); } else { $referer = base64_decode($referer); } if ($edit) { //Verificamos si la imagen es válida if ($id <= 0) { redirect_header($referer, 1, __('Sepecified images is not valid!', 'galleries')); die; } //Verificamos si la imagen existe $img = new GSImage($id); if ($img->isNew()) { redirect_header($referer, 1, __('Sepecified image does not exists!', 'galleries')); die; } //Verificamos que el usuario se el dueño de la imagen if ($img->owner() != $xoopsUser->uid()) { redirect_header($referer, 1, __('You are not authorized!', 'galleries')); die; } } $xoopsOption['template_main'] = 'gs_formpics.html'; include 'header.php'; GSFunctions::makeHeader(); $form = new RMForm($edit ? __('Edit Image', 'galleries') : __('New Image', 'galleries'), 'frmimg', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/saveedit/' : '?cp=saveedit')); $form->setExtra("enctype='multipart/form-data'"); $form->addElement(new RMFormText(__('Image title', 'galleries'), 'title', 50, 100, $edit ? $img->title(false) : '')); if ($edit) { $user = new GSUser($img->owner(), 1); $url = $user->filesURL(); $form->addElement(new RMFormLabel(__('Current picture', 'galleries'), "<img src='" . $url . "/ths/" . $img->image() . "' />")); } else { $form->addElement(new RMFormFile(__('Image file', 'galleries'), 'image', 45, $mc['size_image'] * 1024)); } $form->addElement(new RMFormTextArea(__('Description', 'galleries'), 'desc', 4, 50, $edit ? $img->desc() : '')); $ele = new RMFormSelect(__('Access level', 'galleries'), 'public'); $ele->addOption(0, __('Private', 'galleries'), $edit ? $img->isPublic() == 0 ? 1 : 0 : 0); $ele->addOption(1, __('Public for friends', 'galleries'), $edit ? $img->isPublic() == 1 ? 1 : 0 : 0); $ele->addOption(2, __('Public for all', 'galleries'), $edit ? $img->isPublic() == 2 ? 1 : 0 : 0); $form->addElement($ele, true); //Albumes if ($edit) { $albums = $img->sets(false); foreach ($albums as $k => $v) { $sets[] = $v['id_set']; } } $ele = new RMFormSelect(__('Albums', 'galleries'), 'albums[]', 1, $edit ? $sets : ''); $sql = "SELECT * FROM " . $db->prefix('gs_sets') . " WHERE owner='" . $xoopsUser->uid() . "'"; $result = $db->query($sql); while ($rows = $db->fetchArray($result)) { $ele->addOption($rows['id_set'], $rows['title']); } $form->addElement($ele); $ele = new RMFormText(__('Tags', 'galleries'), 'tags', 50, 255, $edit ? implode(", ", $img->tags(false, 'tag')) : ''); $ele->setDescription(__('Separe each tag with commas.', 'galleries')); $form->addElement($ele, true); $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save')); $form->addElement(new RMFormHidden('id', $id)); $form->addElement(new RMFormHidden('page', $page)); $form->addElement(new RMFormHidden('referer', $referer)); $buttons = new RMFormButtonGroup(); $buttons->addButton('sbt', $edit ? __('Save Changes', 'galleries') : __('Create Image', 'galleries'), 'submit'); $buttons->addButton('cancel', __('Cancel', 'galleries'), 'button', 'onclick="window.location=\'' . $referer . '\'"'); $form->addElement($buttons); $tpl->assign('form_pics', $form->render()); createLinks(); RMTemplate::get()->add_style('panel.css', 'galleries'); include 'footer.php'; }