<?php defined('_JEXEC') or die('Restricted access'); GalleryHeader(); $na = $ad_na ? '#dgtop' : ''; $ssa = !$ad_slideshow_auto ? ',onOpen:function(currentImage){Shadowbox.play();Shadowbox.pause();}' : ''; if ($ad_shadowbox) { $document->addStyleSheet(JURI::base(true) . '/components/com_datsogallery/libraries/shadowbox/shadowbox.css'); $document->addScript(JURI::base(true) . '/components/com_datsogallery/libraries/shadowbox/shadowbox.js'); $sbinit = 'Shadowbox.init({slideshowDelay:' . $ad_slideshow_delay . $ssa . '});'; $document->addScriptDeclaration($sbinit); } $db->setQuery('SELECT c.access' . ' FROM #__datsogallery_catg AS c' . ' LEFT JOIN #__datsogallery AS a' . ' ON a.catid = c.cid' . ' WHERE a.id = ' . (int) $id . ' AND a.published = 1' . ' AND a.approved = 1' . ' AND c.approved = 1' . ' AND c.published = 1' . ' AND c.access IN (' . $groups . ')'); $access = $db->loadObject(); if (!$access) { $app->redirect(JRoute::_("index.php?option=com_datsogallery&view=datsogallery" . $itemid), JText::_('COM_DATSOGALLERY_NOT_ACCESS_THIS_IMAGE')); } $db->setQuery('SELECT a.*' . ' FROM #__datsogallery AS a' . ' WHERE a.id = ' . (int) $id); $obj = $db->loadObject(); if (count($obj) < 1) { $app->redirect(JRoute::_("index.php?option=com_datsogallery&view=datsogallery" . $itemid, false), JText::_('COM_DATSOGALLERY_PICSLAD')); } $document->setTitle($obj->imgtitle); if ($ad_metagen) { if ($obj->imgtext) { $document->setDescription(limit_words($obj->imgtext, 25)); $document->setMetadata('keywords', metaGen($obj->imgtext)); } } $obj->id_cache = array(); $db->setQuery('SELECT *' . ' FROM #__datsogallery' . ' WHERE catid = ' . $obj->catid . ' AND published = 1' . ' AND approved = 1' . ' ORDER BY ordering');
function userPanel() { $app = JFactory::getApplication('site'); require JPATH_COMPONENT_ADMINISTRATOR . DS . 'config.datsogallery.php'; $db = JFactory::getDBO(); $user = JFactory::getUser(); $doc = JFactory::getDocument(); $menu = JSite::getMenu(); $ids = $menu->getItems('link', 'index.php?option=com_datsogallery&view=datsogallery'); $itemid = isset($ids[0]) ? '&Itemid=' . $ids[0]->id : ''; $uri = JFactory::getURI(); $return = $uri->toString(); $url = 'index.php?option=com_users&view=login'; $url .= '&return=' . base64_encode($return); if (!$user->id) { $app->redirect($url, JText::_('You must login first')); } $doc->setTitle(JText::_('COM_DATSOGALLERY_USER_PANEL')); $limit = JRequest::getVar('limit', 15, '', 'int'); $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); $filter_order = $app->getUserStateFromRequest('com_datsogallery.filter_order', 'filter_order', 'a.id', 'cmd'); $filter_order_Dir = $app->getUserStateFromRequest('com_datsogallery.filter_order_Dir', 'filter_order_Dir', '', 'word'); $where = array(); if (!in_array($filter_order, array('a.id', 'a.imgtitle', 'a.imgdate', 'a.approved', 'a.notify', 'category'))) { $filter_order = 'a.id'; } if (!in_array(strtoupper($filter_order_Dir), array('ASC', 'DESC'))) { $filter_order_Dir = ''; } $orderby = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir; $db->setQuery('SELECT count(*) FROM #__datsogallery as a WHERE a.owner_id = ' . $user->id); $total = $db->loadResult(); jimport('joomla.html.pagination'); $pagination = new JPagination($total, $limitstart, $limit); GalleryHeader(); echo "<div class=\"datso_pgn\">"; echo $pagination->getPagesLinks(); echo "</div><div style=\"clear:both\"></div>"; echo "<form method=\"post\" name=\"adminForm\">"; echo "<table class=\"dguserpanel\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">\n"; echo " <thead><tr>"; echo " <th width=\"1%\" nowrap=\"nowrap\">" . str_replace('Joomla.tableOrdering', 'tableOrdering', JHTML::_('grid.sort', JText::_('COM_DATSOGALLERY_ID'), 'a.id', $filter_order_Dir, $filter_order)) . "</th>\n"; echo " <th class=\"title\">" . str_replace('Joomla.tableOrdering', 'tableOrdering', JHTML::_('grid.sort', JText::_('COM_DATSOGALLERY_PIC_NAME') . ' ', 'a.imgtitle', $filter_order_Dir, $filter_order)) . "</th>\n"; echo " <th class=\"title\">" . str_replace('Joomla.tableOrdering', 'tableOrdering', JHTML::_('grid.sort', JText::_('COM_DATSOGALLERY_CATEGORY') . ' ', 'category', $filter_order_Dir, $filter_order)) . "</th>\n"; echo " <th width=\"16%\" nowrap=\"nowrap\">" . str_replace('Joomla.tableOrdering', 'tableOrdering', JHTML::_('grid.sort', JText::_('COM_DATSOGALLERY_DATE_ADD') . ' ', 'a.imgdate', $filter_order_Dir, $filter_order)) . "</th>\n"; if ($ad_approve) { echo " <th width=\"6%\" nowrap=\"nowrap\">" . str_replace('Joomla.tableOrdering', 'tableOrdering', JHTML::_('grid.sort', JText::_('COM_DATSOGALLERY_APPROWED') . ' ', 'a.approved', $filter_order_Dir, $filter_order)) . "</th>\n"; } if ($ad_comment_notify) { echo " <th width=\"6%\" nowrap=\"nowrap\">" . str_replace('Joomla.tableOrdering', 'tableOrdering', JHTML::_('grid.sort', JText::_('COM_DATSOGALLERY_COMMENT_NOTIFY') . ' ', 'a.notify', $filter_order_Dir, $filter_order)) . "</th>\n"; } echo " <th colspan=\"2\" width=\"10%\" nowrap=\"nowrap\">" . JText::_('COM_DATSOGALLERY_ACTION') . "</th>\n"; echo " </tr>\n"; echo "</thead>\n"; echo "<tbody>\n"; $where[] = 'a.catid = cc.cid'; $where[] = 'a.owner_id = ' . $user->id; $pics = count($where) ? ' WHERE ' . implode(' AND ', $where) : ''; $query = "SELECT a.*, cc.name AS category FROM #__datsogallery AS a, #__datsogallery_catg AS cc" . $pics . $orderby; $db->setQuery($query, $pagination->limitstart, $pagination->limit); $rows = $db->loadObjectList(); $k = 0; if (count($rows)) { foreach ($rows as $row) { $k = 1 - $k; $kp = $k + 1; $imgprev = resize($row->imgoriginalname, 120, 120, $ad_crop, $ad_cropratio, 0, $row->catid); $db->setQuery("SELECT COUNT(cmtid) FROM #__datsogallery_comments WHERE cmtpic = " . $row->id); $comments = $db->loadResult(); $overlib = '<table>'; $overlib .= '<tr>'; $overlib .= '<td>'; $overlib .= JText::_('COM_DATSOGALLERY_DATE_ADD'); $overlib .= '</td>'; $overlib .= '<td>: '; $overlib .= strftime($ad_datef, $row->imgdate); $overlib .= '</td>'; $overlib .= '</tr>'; $overlib .= '<tr>'; $overlib .= '<td>'; $overlib .= JText::_('COM_DATSOGALLERY_HITS'); $overlib .= '</td>'; $overlib .= '<td>: '; $overlib .= $row->imgcounter; $overlib .= '</td>'; $overlib .= '</tr>'; $overlib .= '<tr>'; $overlib .= '<td>'; $overlib .= JText::_('COM_DATSOGALLERY_DOWNLOADS'); $overlib .= '</td>'; $overlib .= '<td>: '; $overlib .= $row->imgdownloaded; $overlib .= '</td>'; $overlib .= '</tr>'; if ($row->imgvotes > 0) { $fimgvotesum = number_format($row->imgvotesum / $row->imgvotes, 2, ",", "."); $dgvotes = "{$fimgvotesum} / {$row->imgvotes}"; } else { $dgvotes = JText::_('COM_DATSOGALLERY_NO_VOTES'); } $overlib .= '<tr>'; $overlib .= '<td>'; $overlib .= JText::_('COM_DATSOGALLERY_RATING'); $overlib .= '</td>'; $overlib .= '<td>: '; $overlib .= $dgvotes; $overlib .= '</td>'; $overlib .= '</tr>'; $overlib .= '<tr>'; $overlib .= '<td>'; $overlib .= JText::_('COM_DATSOGALLERY_COMMENT1'); $overlib .= '</td>'; $overlib .= '<td>: '; $overlib .= $comments; $overlib .= '</td>'; $overlib .= '</tr>'; $overlib .= '</table>'; echo " <tr class=\"row" . $k . "\">\n"; echo " <td align=\"center\">" . $row->id . "</td>\n"; echo " <td><a href=\"" . JRoute::_('index.php?option=com_datsogallery&task=editpic&uid=' . $row->id . $itemid) . "\" id=\"<strong>" . jsspecialchars($row->imgtitle) . "</strong><br /><br /><div style='text-align:center'><img src='" . $imgprev . "' class='dgimg' /></div><br />" . $overlib . "\" class=\"dgtip\">" . $row->imgtitle . "</a></td>\n"; echo " <td>" . catNameById($row->catid) . "</td>\n"; echo " <td align=\"center\" style=\"font-size: 10px\">" . strftime($ad_datef, $row->imgdate) . "</td>\n"; if ($ad_approve) { $a_pic = $row->approved ? dgTip(JText::_('COM_DATSOGALLERY_PIC_APPROVED'), 'dg-accept-icon.png') : dgTip(JText::_('COM_DATSOGALLERY_PIC_PENDING'), 'dg-pending-icon.png'); echo " <td align=\"center\">" . $a_pic . "</td>\n"; } if ($ad_comment_notify) { $notify = $row->notify ? dgTip(JText::_('COM_DATSOGALLERY_COMMENT_NOTIFY_EMAIL_ICON'), 'email.png') : dgTip(JText::_('COM_DATSOGALLERY_COMMENT_NOTIFY_NO_EMAIL_ICON'), 'no_email.png'); echo " <td align=\"center\">" . $notify . "</td>\n"; } echo " <td align=\"center\">"; echo "<a href='" . JRoute::_("index.php?option=com_datsogallery&task=editpic&uid=" . $row->id . $itemid) . "'>"; echo "<img src='" . JURI::base(true) . "/components/com_datsogallery/images/" . $dg_theme . "/edit.png' width='16' height='16' border='0' title='" . JText::_('COM_DATSOGALLERY_EDIT') . "' /></a>"; echo " </td>\n"; echo " <td align=\"center\">"; echo "<a href=\"javascript:if (confirm('" . JText::_('COM_DATSOGALLERY_SURE_DELETE_SELECT_ITEM') . "')){ location.href='" . JRoute::_("index.php?option=com_datsogallery&task=deletepic&uid=" . $row->id . $itemid) . "';}\" title='" . JText::_('COM_DATSOGALLERY_DELETE') . "'>"; echo "<img src='" . JURI::base(true) . "/components/com_datsogallery/images/" . $dg_theme . "/dg-delete-image-icon.png' width='16' border='0' /></a>\n"; echo " </td>\n"; echo " </tr>\n"; } } else { echo " <tr class=\"row" . $k . "\">"; echo " <td colspan=\"7\">" . JText::_('COM_DATSOGALLERY_NOT_HAVE_PIC') . "</td>\n"; echo " </tr>\n"; } echo "</tbody>\n"; echo "</table>\n"; echo "<input type=\"hidden\" name=\"filter_order\" value=\"" . $filter_order . "\" />\n"; echo "<input type=\"hidden\" name=\"filter_order_Dir\" value=\"" . $filter_order_Dir . "\" />"; echo JHTML::_('form.token'); echo "</form>\n"; echo '<div class="datso_pgn">'; echo $pagination->getPagesLinks(); echo "</div>"; GalleryFooter(); }