Example #1
0
        break;
    case "showupload":
        if (!$user->id) {
            $app->redirect($url, JText::_('You must login first'));
        }
        showUpload();
        break;
    case "upload":
        batchUpload();
        break;
    case "userpanel":
        userPanel();
        break;
    case "send2friend":
        send2friend();
        break;
    case 'captcha':
        captcha();
        break;
    case 'checkcatname':
        require_once JPATH_COMPONENT . DS . 'includes' . DS . 'datso.usercategory.php';
        break;
    default:
        GalleryHeader();
        echo dgCategories($catid);
        GalleryFooter();
        break;
}
$tasks = array('showupload', 'editpic');
$gravity = in_array($task, $tasks) ? 'w' : 's';
echo "<script type=\"text/javascript\">datso(\".dgtip\").dgtooltip({gravity: '" . $gravity . "', fade: true, html: true});</script> ";
Example #2
0
function viewCategory()
{
    $app = JFactory::getApplication('site');
    $db = JFactory::getDBO();
    $user = JFactory::getUser();
    $groups = implode(',', $user->getAuthorisedViewLevels());
    $document = JFactory::getDocument();
    $filter_order = $app->getUserStateFromRequest('com_datsogallery.filter_order', 'filter_order', 'a.ordering', 'cmd');
    $filter_order_Dir = $app->getUserStateFromRequest('com_datsogallery.filter_order_Dir', 'filter_order_Dir', '', 'word');
    $catid = JRequest::getVar('catid', 0, '', 'int');
    $menu = JSite::getMenu();
    $ids = $menu->getItems('link', 'index.php?option=com_datsogallery&view=datsogallery');
    $itemid = isset($ids[0]) ? '&Itemid=' . $ids[0]->id : '';
    $is_editor = strtolower($user->usertype) == 'editor' || strtolower($user->usertype) == 'administrator' || strtolower($user->usertype) == 'super administrator';
    GalleryHeader();
    $db->setQuery("select count(*) from #__datsogallery_catg where cid = " . $catid . " AND access IN (" . $groups . ")");
    $is_allowed = $db->loadResult();
    if (!$is_allowed) {
        $app->redirect(JRoute::_('index.php?option=com_datsogallery' . $itemid, false), JText::_('COM_DATSOGALLERY_NOT_ACCESS_THIS_CATEGORY'), 'notice');
    }
    //echo dgCategories($catid);
    require JPATH_COMPONENT_ADMINISTRATOR . DS . 'config.datsogallery.php';
    if ($ad_sbcat) {
        $ssa = !$ad_slideshow_auto ? ',onOpen:function(currentImage){Shadowbox.play();Shadowbox.pause();}' : '';
        $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 COUNT(*)" . " FROM #__datsogallery AS a" . " LEFT JOIN #__datsogallery_catg AS c" . " ON c.cid = a.catid" . " WHERE a.published = 1" . " AND a.catid = " . $catid . " AND a.approved = 1" . " AND c.access IN (" . $groups . ")");
    $count = $db->loadResult();
    if (!in_array($filter_order, array('a.imgcounter', 'a.imgdownloaded', 'a.imgtitle', 'a.imgdate', 'a.ordering'))) {
        $filter_order = 'a.ordering';
    }
    if (!in_array(strtoupper($filter_order_Dir), array('ASC', 'DESC'))) {
        $filter_order_Dir = $ad_sortby;
    }
    $orderby = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir;
    if ($ad_picincat && $count > 0) {
        echo JText::sprintf('COM_DATSOGALLERY_CATEGORY_IMAGES', $count);
    }
    ?>
        <form method="post" id="adminForm">
        <?php 
    $query = "SELECT count(*) AS count" . " FROM #__datsogallery" . " WHERE catid = " . $catid . " AND published = 1" . " AND approved = 1";
    $db->setQuery($query);
    $row = $db->LoadObject();
    $total = $row->count;
    jimport('joomla.html.pagination');
    $limit = JRequest::getVar('limit', $ad_perpage, '', 'int');
    $limitstart = JRequest::getVar('limitstart', 0, '', 'int');
    $pagination = new JPagination($total, $limitstart, $limit);
    if ($count > $ad_perpage) {
        $page_nav_links = $pagination->getPagesLinks();
        ?>
        <div class="datso_pgn"><?php 
        echo $page_nav_links;
        ?>
</div>
        <div style="clear:both"></div>
        <?php 
    }
    $db->setQuery("SELECT * FROM #__datsogallery_catg WHERE cid = " . $catid);
    $rows = $db->loadObjectList();
    $catname = $rows[0]->name;
    if ($show_grid) {
        echo '<div class="dg_head_background">' . str_replace('Joomla.tableOrdering', 'tableOrdering', JHTML::_('grid.sort', $catname . ' ', 'a.imgtitle', $filter_order_Dir, $filter_order));
        echo '<span class="grid_txt"><div class="grid_border">' . str_replace('Joomla.tableOrdering', 'tableOrdering', JHTML::_('grid.sort', JText::_('COM_DATSOGALLERY_ORDER') . ' ', 'a.ordering', $filter_order_Dir, $filter_order)) . '</div>';
        echo '<div class="grid_border">' . str_replace('Joomla.tableOrdering', 'tableOrdering', JHTML::_('grid.sort', JText::_('COM_DATSOGALLERY_DATE_ADD') . ' ', 'a.imgdate', $filter_order_Dir, $filter_order)) . '</div>';
        echo '<div class="grid_border">' . str_replace('Joomla.tableOrdering', 'tableOrdering', JHTML::_('grid.sort', JText::_('COM_DATSOGALLERY_HITS') . ' ', 'a.imgcounter', $filter_order_Dir, $filter_order)) . '</div>';
        echo '<div class="grid_border">' . str_replace('Joomla.tableOrdering', 'tableOrdering', JHTML::_('grid.sort', JText::_('COM_DATSOGALLERY_DOWNLOADS') . ' ', 'a.imgdownloaded', $filter_order_Dir, $filter_order)) . '</div>';
        echo '</span></div>';
    } else {
        echo '<div class="dg_head_background">' . $catname . '</div>';
    }
    echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" class=\"dg_body_background\">\n";
    if ($count > $ad_perpage) {
        $addspace = ' - ';
    } else {
        $addspace = '';
    }
    $pages = $pagination->getPagesCounter();
    $document->setTitle($catname . $addspace . $pages);
    if ($ad_metagen) {
        if ($rows[0]->description) {
            $document->setTitle($catname . $addspace . $pages);
            $document->setDescription(limit_words($rows[0]->description, 25));
            $document->setMetadata('keywords', metaGen($rows[0]->description));
        }
    }
    $query = 'SELECT a.*' . ' FROM #__datsogallery AS a' . ' LEFT JOIN #__datsogallery_catg AS c' . ' ON c.cid = a.catid' . ' WHERE a.published = 1' . ' AND a.catid = ' . $catid . ' AND a.approved = 1' . ' AND c.access IN (' . $groups . ')' . $orderby;
    $db->setQuery($query, $pagination->limitstart, $pagination->limit);
    $rows = $db->loadObjectList();
    $rowcounter = 0;
    if (count($rows) > 0) {
        foreach ($rows as $row1) {
            if ($ad_ncsc) {
                $cw = 100 / $ad_cp . "%";
            }
            if ($rowcounter % $ad_cp == 0) {
                echo " <tr>\n";
            }
            echo "  <td width=\"" . $cw . "\" class=\"dg_body_background_td\" align=\"center\" valign=\"top\">\n";
            $tle = jsspecialchars($row1->imgtitle);
            if ($ad_showdetail) {
                $picdate = strftime($ad_datef, $row1->imgdate);
            }
            $na = $ad_na ? '#dgtop' : '';
            $ld = "<a href='" . JRoute::_("index.php?option=com_datsogallery&task=image&catid=" . $catid . "&id=" . $row1->id . $itemid) . $na . "' title='" . $tle . "'>";
            if ($ad_sbcat) {
                echo "   <a rel='shadowbox[screenshots];player=img' href='" . JURI::root() . "index.php?option=com_datsogallery&task=sbox&catid=" . $catid . "&id=" . $row1->id . "&format=raw' title='" . $tle . "'>";
            } else {
                echo $ld;
            }
            echo "   <img src=\"" . resize($row1->imgoriginalname, $ad_thumbwidth, $ad_thumbheight, $ad_crop, $ad_cropratio, 0, $row1->catid) . "\" " . get_width_height($row1->imgoriginalname, $ad_thumbwidth, $ad_thumbheight, $catid, $ad_cropratio) . " class=\"dgimg\" title=\"" . $tle . "\" alt=\"" . $tle . "\" /></a>";
            if ($ad_showdetail) {
                echo "   <div style=\"width:" . $ad_thumbwidth . "px;margin:10px auto 0 auto;text-align:left;text-transform: uppercase;\">";
                echo $ad_showimgtitle ? $ld . '<span>' . $row1->imgtitle . '</span></a><br />' : '';
                echo "   <span>";
                echo $ad_showfimgdate ? '<strong>' . JText::_('COM_DATSOGALLERY_DATE_ADD') . '</strong>: ' . $picdate . '<br />' : '';
                echo $ad_showimgcounter ? '<strong>' . JText::_('COM_DATSOGALLERY_HITS') . '</strong>: ' . $row1->imgcounter . '<br />' : '';
                echo $ad_showdownloads ? '<strong>' . JText::_('COM_DATSOGALLERY_DOWNLOADS') . '</strong>: ' . $row1->imgdownloaded . '<br />' : '';
                echo $ad_showrating ? showVote($row1->id, $row1->imgvotes, $row1->imgvotesum) : '';
                if ($ad_showcomments) {
                    $and = $is_editor ? '' : ' AND published = 1';
                    $db->setQuery('SELECT COUNT(cmtid) FROM #__datsogallery_comments WHERE cmtpic = ' . $row1->id . $and);
                    $comments = $db->loadResult();
                    echo "<strong>" . JText::_('COM_DATSOGALLERY_COMMENTS') . "</strong>: {$comments}";
                }
                echo "   </span>";
                echo "   </div>";
            }
            echo "  </td>\n";
            $rowcounter++;
        }
    } else {
        echo "  <td width=\"" . @$cw . "\" class=\"dg_body_background_td\">" . JText::_('COM_DATSOGALLERY_NO_RESULTS') . "</td>\n";
    }
    if ($rowcounter % $ad_cp != 0) {
        for ($i = 1; $i <= $ad_cp - $rowcounter % $ad_cp; $i++) {
            echo "  <td width=\"" . @$cw . "\" class=\"dg_body_background_td\"> </td>\n";
        }
    }
    echo " </tr>\n";
    echo "</table>\n";
    if ($count > $ad_perpage) {
        $page_nav_links = $pagination->getPagesLinks();
        ?>
          <div class="datso_pgn"><?php 
        echo $page_nav_links;
        ?>
</div>
      <?php 
    }
    ?>
      <input type="hidden" name="filter_order" value="<?php 
    echo $filter_order;
    ?>
" />
      <input type="hidden" name="filter_order_Dir" value="<?php 
    echo $filter_order_Dir;
    ?>
" />
      <?php 
    echo JHTML::_('form.token');
    ?>
      </form>
      <?php 
    echo dgCategories($catid);
    GalleryFooter();
}