function dgCategories($catid) { $app = JFactory::getApplication('site'); require JPATH_COMPONENT_ADMINISTRATOR . DS . 'config.datsogallery.php'; $db = JFactory::getDBO(); $user = JFactory::getUser(); $menu = JSite::getMenu(); $ids = $menu->getItems('link', 'index.php?option=com_datsogallery&view=datsogallery'); $itemid = isset($ids[0]) ? '&Itemid=' . $ids[0]->id : ''; $na = $ad_na ? '#dgtop' : ''; $filter_order = $app->getUserStateFromRequest('com_datsogallery.filter_order', 'filter_order', 'd.ordering', 'cmd'); $filter_order_Dir = $app->getUserStateFromRequest('com_datsogallery.filter_order_Dir', 'filter_order_Dir', '', 'word'); $limit = JRequest::getVar('limit', $ad_catsperpage); $limitstart = JRequest::getVar('limitstart', 0); if (!in_array($filter_order, array('d.name', 'd.ordering'))) { $filter_order = 'd.ordering'; } if (!in_array(strtoupper($filter_order_Dir), array('ASC', 'DESC'))) { $filter_order_Dir = $ad_sortby; } $orderby = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir; $par = "SELECT COUNT(*) FROM #__datsogallery_catg AS cid" . " WHERE parent = " . $catid . " AND approved = 1" . " AND published = 1"; $db->setQuery($par); $total = $db->loadResult(); jimport('joomla.html.pagination'); $pageNav = new JPagination($total, $limitstart, $limit); $query = "SELECT d.*, u.id AS uid, u.name AS usercat FROM #__datsogallery_catg AS d" . " LEFT JOIN #__users AS u ON u.id = d.user_id" . " WHERE d.parent = " . $catid . " AND d.approved = 1" . " AND d.published = 1" . $orderby; $db->setQuery($query, $pageNav->limitstart, $pageNav->limit); $rows = $db->loadObjectList(); $num_rows = count($rows); $index = 0; if ($ad_ncsc > $num_rows) { $ad_ncsc = $num_rows; } else { $ad_ncsc = $ad_ncsc; } if ($ad_ncsc) { $cw = 100 / $ad_ncsc . "%"; $colspan = $ad_ncsc; } ?> <script language="javascript" type="text/javascript"> function tableOrdering( order, dir, task ) { var form = document.viewCategories; form.filter_order.value = order; form.filter_order_Dir.value = dir; document.viewCategories.submit( task ); } </script> <?php $output = ""; $output .= '<form method="post" name="viewCategories">'; if (@$rows[0]->parent) { $parcid = $rows[0]->parent; if ($total > $ad_catsperpage) { $output .= '<div class="datso_pgn">'; $output .= $pageNav->getPagesLinks("index.php?option=com_datsogallery&task=category&catid=" . $parcid . $itemid); $output .= '</div><div style="clear:both"></div>'; } } elseif (@$rows[0]->cid) { if ($total > $ad_catsperpage) { $output .= '<div class="datso_pgn">'; $output .= $pageNav->getPagesLinks(); $output .= '</div><div style="clear:both"></div>'; } } if (@$rows[0]->parent) { if ($show_grid) { $output .= ' <div class="dg_head_background">' . str_replace('Joomla.tableOrdering', 'tableOrdering', JHTML::_('grid.sort', JText::_('COM_DATSOGALLERY_SUBCATEGORIES') . ' ', 'd.ordering', $filter_order_Dir, $filter_order)) . '</div>'; } else { $output .= ' <div class="dg_head_background">' . JText::_('COM_DATSOGALLERY_SUBCATEGORIES') . '</div>'; } } else { if (@$rows[0]->cid) { if ($show_grid) { $output .= ' <div class="dg_head_background">' . str_replace('Joomla.tableOrdering', 'tableOrdering', JHTML::_('grid.sort', JText::_('COM_DATSOGALLERY_CATEGORIES') . ' ', 'd.name', $filter_order_Dir, $filter_order)); $output .= ' <span class="grid_txt"><div class="grid_border">' . str_replace('Joomla.tableOrdering', 'tableOrdering', JHTML::_('grid.sort', JText::_('COM_DATSOGALLERY_ORDER') . ' ', 'd.ordering', $filter_order_Dir, $filter_order)) . '</div></span></div>'; } else { $output .= ' <div class="dg_head_background">' . JText::_('COM_DATSOGALLERY_CATEGORIES') . '</div>'; } } } $output .= '<table width="100%" cellspacing="1" cellpadding="0" border="0" class="dg_body_background">'; if ($num_rows) { for ($row_count = 0; $row_count < $num_rows / $ad_ncsc; $row_count++) { $output .= ' <tr>'; for ($i = 0; $i < $ad_ncsc; $i++) { $cur_name = @$rows[$index]; $output .= ' <td class="dg_body_background_td" align="center" valign="top" width="' . $cw . '">'; if (@$cur_name->cid) { if (GetThumbsInCats(@$cur_name->cid)) { $output .= '<a href="' . JRoute::_("index.php?option=com_datsogallery&task=category&catid=" . $cur_name->cid . $itemid) . $na . '">'; } } if (!@$cur_name->cid) { $output .= ''; } else { $catid = $cur_name->cid; $query = "SELECT p.*" . " FROM #__datsogallery AS p" . " LEFT JOIN #__datsogallery_catg AS c ON c.cid = p.catid" . " WHERE " . ($catid ? " ( p.catid IN (" . $catid . ") )" : '') . " AND p.published = 1 AND p.approved = 1" . " OR " . ($catid ? " ( c.parent IN (" . $catid . ") )" : '') . " AND p.published = 1 AND p.approved = 1 AND c.approved = 1" . " ORDER BY p.id " . @$ad_catimg . " LIMIT 1"; $db->setQuery($query); $rows2 = $db->loadObjectList(); $count = count($rows2); $row2 =& $rows2[0]; $db->setQuery($query); if ($count > 0) { $output .= ' <img src="' . resize($row2->imgoriginalname, $ad_thumbwidth, $ad_thumbheight, $ad_crop, $ad_cropratio, 0, $cur_name->cid) . '" class="dgimg" title="' . JText::_('COM_DATSOGALLERY_VIEW_CATEGORY') . '" alt="" /></a>'; $output .= ' <p style="width:' . $ad_thumbwidth . 'px;margin:5px auto 0 auto;text-align:left">'; } else { if (GetThumbsInCats($cur_name->cid)) { $output .= ' <img src="' . resize(GetThumbsInCats($cur_name->cid), $ad_thumbwidth, $ad_thumbheight, $ad_crop, $ad_cropratio, 0, $cur_name->cid) . '" class="dgimg" title="' . JText::_('COM_DATSOGALLERY_VIEW_CATEGORY') . '" alt="" /></a>'; $output .= ' <p style="width:' . $ad_thumbwidth . 'px;margin:5px auto 0 auto;text-align:left">'; } else { if (!$count) { $output .= ' <img src="' . resize("blank.jpg", $ad_thumbwidth, $ad_thumbheight, $ad_crop, $ad_cropratio, 0) . '" class="dgimg" title="' . JText::_('COM_DATSOGALLERY_NO_IMAGES') . '" alt="" />'; $output .= ' <p style="width:' . $ad_thumbwidth . 'px;margin:5px auto 0 auto;text-align:left">'; } } } } if ($cur_name && $count) { $output .= ' <a href="' . JRoute::_("index.php?option=com_datsogallery&task=category&catid=" . $cur_name->cid . $itemid) . $na . '">'; $output .= '<span style="text-transform: uppercase">' . $cur_name->name . '</span></a>'; if ($ad_showimgauthor) { $output .= '<br /><span style="text-transform: uppercase">' . JText::_('COM_DATSOGALLERY_OWNER') . ': <a href="' . JRoute::_('index.php?option=com_datsogallery&task=owner&op=' . $cur_name->uid . $itemid) . '">' . $cur_name->usercat . '</a></span>'; } } else { if ($cur_name && !$count) { $output .= '<span style="text-transform: uppercase">' . $cur_name->name . '</span>'; if ($ad_showimgauthor) { $output .= '<br /><span style="text-transform: uppercase">' . JText::_('COM_DATSOGALLERY_OWNER') . ': <a href="' . JRoute::_('index.php?option=com_datsogallery&task=owner&op=' . $cur_name->uid . $itemid) . '">' . $cur_name->usercat . '</a></span>'; } } } if (@$cur_name->name) { $output .= ' <br /><span style="text-transform: uppercase">' . GetNumberOfLinks($cur_name->cid); if ($ad_showinformer) { $output .= ' ' . GetNewPics($cur_name->cid); } $output .= '</span>'; } $output .= '<br /><span><em>' . @$cur_name->description . '</em></span></p></td>'; $index++; } $output .= ' </tr>'; } } $output .= '</table>'; if (@$rows[0]->parent) { $parcid = $rows[0]->parent; if ($total > $ad_catsperpage) { $output .= '<div class="datso_pgn">'; $output .= $pageNav->getPagesLinks("index.php?option=com_datsogallery&task=category&catid=" . $parcid . $itemid); $output .= "</div>"; } } elseif (@$rows[0]->cid) { if ($total > $ad_catsperpage) { $output .= '<div class="datso_pgn">'; $output .= $pageNav->getPagesLinks(); $output .= "</div>"; } } $output .= '<input type="hidden" name="filter_order" value="' . $filter_order . '" />'; $output .= '<input type="hidden" name="filter_order_Dir" value="' . $filter_order_Dir . '" />'; $output .= JHTML::_('form.token'); $output .= '</form>'; return $output; }
function removeCatg($cid) { $app = JFactory::getApplication('administrator'); $db = JFactory::getDBO(); if (count($cid)) { $cids = implode(',', $cid); foreach ($cid as $id) { $parents = GetNumberOfParents($id); $images = GetNumberOfLinks($id); if ($images) { $app->redirect('index.php?option=com_datsogallery&task=showcatg', JText::_('COM_DATSOGALLERY_ERROR_DELETE_CATEGORY'), 'error'); } elseif ($parents) { $app->redirect('index.php?option=com_datsogallery&task=showcatg', JText::_('COM_DATSOGALLERY_ERROR_DELETE_SUBCATEGORY'), 'error'); } else { $db->setQuery('DELETE FROM #__datsogallery_catg WHERE cid = ' . $id); if (!$db->query()) { echo "<script> alert('" . $db->getErrorMsg() . "'); window.history.go(-1); </script>\n"; } } } } $app->redirect('index.php?option=com_datsogallery&task=showcatg', JText::_('COM_DATSOGALLERY_CATEGORY_DELETED'), 'note'); }
function showCatgs(&$cats, &$lists, &$search, &$pagination) { $app = JFactory::getApplication('administrator'); $db = JFactory::getDBO(); $uri = JFactory::getURI(); $ordering = $lists['order'] == 'c.ordering'; ?> <form action="index.php" method="post" name="adminForm"> <table> <tr> <td align="left" width="100%"><?php echo JText::_('COM_DATSOGALLERY_FILTER'); ?> : <input type="text" name="search" id="search" value="<?php echo $search; ?> " class="text_area" onchange="document.adminForm.submit();" /> <input class="button" type="button" onclick="this.form.submit();" value="<?php echo JText::_('COM_DATSOGALLERY_GO'); ?> " /> <input class="button" type="button" onclick="document.getElementById('search').value='';this.form.submit();" value="<?php echo JText::_('COM_DATSOGALLERY_RESET'); ?> " /> </td> </tr> </table> <table class="adminlist"> <thead> <tr> <th width="1%" nowrap="nowrap"> <?php echo JText::_('COM_DATSOGALLERY_NUM'); ?> </th> <th width="1%" nowrap="nowrap"> <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($cats); ?> );" /> </th> <th class="title"> <?php echo JHTML::_('grid.sort', JText::_('COM_DATSOGALLERY_CATEGORY'), 'title', $lists['order_Dir'], $lists['order']); ?> </th> <th width="5%" nowrap="nowrap"> <?php echo JHTML::_('grid.sort', JText::_('COM_DATSOGALLERY_CATEGORY_OWNER'), 'owner', $lists['order_Dir'], $lists['order']); ?> </th> <th width="4%" nowrap="nowrap"> <?php echo JHTML::_('grid.sort', JText::_('COM_DATSOGALLERY_PUBLISHED'), 'c.published', $lists['order_Dir'], $lists['order']); ?> </th> <th width="4%" nowrap="nowrap"> <?php echo JHTML::_('grid.sort', JText::_('COM_DATSOGALLERY_APPROVED'), 'c.approved', $lists['order_Dir'], $lists['order']); ?> </th> <th width="4%"> <?php echo JHTML::_('grid.sort', JText::_('COM_DATSOGALLERY_ORDER'), 'c.ordering', $lists['order_Dir'], $lists['order']); if ($ordering) { echo JHTML::_('grid.order', $cats, '', 'savecatorder'); } ?> </th> <th width="3%" nowrap="nowrap"> <?php echo JText::_('COM_DATSOGALLERY_FILES_IN_CATEGORY'); ?> </th> <th width="5%" nowrap="nowrap"> <?php echo JHTML::_('grid.sort', JText::_('COM_DATSOGALLERY_ACCESS'), 'groupname', $lists['order_Dir'], $lists['order']); ?> </th> <th width="5%" nowrap="nowrap"> <?php echo JHTML::_('grid.sort', JText::_('COM_DATSOGALLERY_DATE_ADD'), 'c.date', $lists['order_Dir'], $lists['order']); ?> </th> <th width="1%" nowrap="nowrap"> <?php echo JHTML::_('grid.sort', JText::_('COM_DATSOGALLERY_ID'), 'id', $lists['order_Dir'], $lists['order']); ?> </th> </tr> </thead> <tfoot> <tr> <td colspan="11"><?php echo $pagination->getListFooter(); ?> </td> </tr> </tfoot> <tbody> <?php $k = 0; $rows = $cats; for ($i = 0, $n = count($rows); $i < $n; $i++) { $row =& $rows[$i]; $task1 = $row->published ? 'unpublishcatg' : 'publishcatg'; $img1 = $row->published ? 'dg-accept-icon.png' : 'dg-pending-icon.png'; $task2 = $row->approved ? 'unapprovecatg' : 'approvecatg'; $img2 = $row->approved ? 'dg-accept-icon.png' : 'dg-pending-icon.png'; ?> <tr class="row<?php echo $k; ?> "> <td align="center"> <?php echo $pagination->getRowOffset($i); ?> </td> <td align="center"> <input type="checkbox" id="cb<?php echo $i; ?> " name="cid[]" value="<?php echo $row->cid; ?> " onclick="isChecked(this.checked);"> </td> <td align="left" width="25%"> <a href="#edit" onclick="return listItemTask('cb<?php echo $i; ?> ','editcatg')"><?php echo $row->treename; ?> </a> </td> <td align="center"> <a href="index.php?option=com_users&task=user.edit&id=<?php echo $row->user_id; ?> "><?php echo $row->owner; ?> </a> </td> <td align="center"> <a href="javascript: void(0);" onclick="return listItemTask('cb<?php echo $i; ?> ','<?php echo $task1; ?> ')"> <img src="<?php echo $uri->root(); ?> components/com_datsogallery/images/<?php echo $img1; ?> " border="0" alt="" /></a> </td> <td align="center"> <a href="javascript: void(0);" onclick="return listItemTask('cb<?php echo $i; ?> ','<?php echo $task2; ?> ')"> <img src="<?php echo $uri->root(); ?> components/com_datsogallery/images/<?php echo $img2; ?> " border="0" alt="" /></a> </td> <td class="order"> <?php if ($ordering) { if ($lists['order_Dir'] == 'asc') { $dirup = 'orderupcatg'; $dirdown = 'orderdowncatg'; } else { $dirup = 'orderdowncatg'; $dirdown = 'orderupcatg'; } ?> <span><?php echo $pagination->orderUpIcon($i, $row->parent == 0 || $row->parent == @$rows[$i - 1]->parent, $dirup, JText::_('COM_DATSOGALLERY_MOVE_UP'), $row->ordering); ?> </span> <span><?php echo $pagination->orderDownIcon($i, $n, $row->parent == 0 || $row->parent == @$rows[$i + 1]->parent, $dirdown, JText::_('COM_DATSOGALLERY_MOVE_DOWN'), $row->ordering); ?> </span> <?php } ?> <?php $disabled = $ordering ? '' : 'disabled="disabled"'; ?> <input type="text" name="order[]" size="5" value="<?php echo $row->ordering; ?> " <?php echo $disabled; ?> class="text_area" style="text-align: center" /> </td> <td align="center"> <?php echo GetNumberOfLinks($row->cid); ?> </td> <td align="center"> <?php echo $row->groupname; ?> </td> <td align="center"> <?php echo $row->date; ?> </td> <td align="center"> <?php echo $row->cid; ?> </td> </tr> <?php $k = 1 - $k; } ?> </tbody> </table> <input type="hidden" name="option" value="com_datsogallery" /> <input type="hidden" name="boxchecked" value="0" /> <input type="hidden" name="filter_order" value="<?php echo $lists['order']; ?> " /> <input type="hidden" name="filter_order_Dir" value="<?php echo $lists['order_Dir']; ?> " /> <input type="hidden" name="task" value="showcatg" /> <?php echo JHTML::_('form.token'); ?> </form> <?php }