/** * Creates a new or edits and existing user record */ function editNewsFeed($edit) { $db =& JFactory::getDBO(); $user =& JFactory::getUser(); $catid = JRequest::getVar('catid', 0, '', 'int'); $cid = JRequest::getVar('cid', array(0), '', 'array'); $option = JRequest::getCmd('option'); JArrayHelper::toInteger($cid, array(0)); $row =& JTable::getInstance('newsfeed', 'Table'); // load the row from the db table if ($edit) { $row->load($cid[0]); } if ($edit) { // do stuff for existing records $row->checkout($user->get('id')); } else { // do stuff for new records $row->ordering = 0; $row->numarticles = 5; $row->cache_time = 3600; $row->published = 1; } // build the html select list for ordering $query = 'SELECT a.ordering AS value, a.name AS text' . ' FROM #__newsfeeds AS a' . ' ORDER BY a.ordering'; if ($edit) { $lists['ordering'] = JHTML::_('list.specificordering', $row, $cid[0], $query); } else { $lists['ordering'] = JHTML::_('list.specificordering', $row, '', $query); } // build list of categories $lists['category'] = JHTML::_('list.category', 'catid', $option, intval($row->catid)); // build the html select list $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published); HTML_newsfeeds::editNewsFeed($row, $lists, $option); }
function showNewsFeeds(&$rows, &$lists, &$pageNav, $option) { global $mainframe; $user =& JFactory::getUser(); //Ordering allowed ? $ordering = $lists['order'] == 'a.ordering'; JHTML::_('behavior.tooltip'); ?> <form action="index.php?option=com_newsfeeds" method="post" name="adminForm"> <table> <tr> <td align="left" width="100%"> <?php echo JText::_('Filter'); ?> : <input type="text" name="search" id="search" value="<?php echo $lists['search']; ?> " class="text_area" onchange="document.adminForm.submit();" /> <button onclick="this.form.submit();"><?php echo JText::_('Go'); ?> </button> <button onclick="document.getElementById('search').value='';this.form.getElementById('filter_catid').value='0';this.form.getElementById('filter_state').value='';this.form.submit();"><?php echo JText::_('Reset'); ?> </button> </td> <td nowrap="nowrap"> <?php echo $lists['catid']; echo $lists['state']; ?> </td> </tr> </table> <table class="adminlist"> <thead> <tr> <th width="10"> <?php echo JText::_('NUM'); ?> </th> <th width="10"> <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($rows); ?> );" /> </th> <th class="title"> <?php echo JHTML::_('grid.sort', 'News Feed', 'a.name', @$lists['order_Dir'], @$lists['order']); ?> </th> <th width="5%"> <?php echo JHTML::_('grid.sort', 'Published', 'a.published', @$lists['order_Dir'], @$lists['order']); ?> </th> <th width="8%" nowrap="nowrap"> <?php echo JHTML::_('grid.sort', 'Order', 'a.ordering', @$lists['order_Dir'], @$lists['order']); ?> <?php echo JHTML::_('grid.order', $rows); ?> </th> <th class="title" width="10%"> <?php echo JHTML::_('grid.sort', 'Category', 'catname', @$lists['order_Dir'], @$lists['order']); ?> </th> <th width="5%" nowrap="nowrap"> <?php echo JHTML::_('grid.sort', 'Num Articles', 'a.numarticles', @$lists['order_Dir'], @$lists['order']); ?> </th> <th width="5%"> <?php echo JHTML::_('grid.sort', 'Cache time', 'a.cache_time', @$lists['order_Dir'], @$lists['order']); ?> </th> <th width="1%" nowrap="nowrap"> <?php echo JHTML::_('grid.sort', 'ID', 'a.id', @$lists['order_Dir'], @$lists['order']); ?> </th> </tr> </thead> <tfoot> <tr> <td colspan="10"> <?php echo $pageNav->getListFooter(); ?> </td> </tr> </tfoot> <tbody> <?php $k = 0; for ($i = 0, $n = count($rows); $i < $n; $i++) { $row =& $rows[$i]; $link = JRoute::_('index.php?option=com_newsfeeds&task=edit&cid[]=' . $row->id); $checked = JHTML::_('grid.checkedout', $row, $i); $published = JHTML::_('grid.published', $row, $i); $row->cat_link = JRoute::_('index.php?option=com_categories§ion=com_newsfeeds&task=edit&cid[]=' . $row->catid); ?> <tr class="<?php echo 'row' . $k; ?> "> <td align="center"> <?php echo $pageNav->getRowOffset($i); ?> </td> <td> <?php echo $checked; ?> </td> <td> <?php if (JTable::isCheckedOut($user->get('id'), $row->checked_out)) { echo $row->name; } else { ?> <span class="editlinktip hasTip" title="<?php echo JText::_('Edit Newsfeed'); ?> ::<?php echo $row->name; ?> "> <a href="<?php echo $link; ?> "> <?php echo $row->name; ?> </a></span> <?php } ?> </td> <td align="center"> <?php echo $published; ?> </td> <td class="order"> <span><?php echo $pageNav->orderUpIcon($i, $row->catid == @$rows[$i - 1]->catid, 'orderup', 'Move Up', $ordering); ?> </span> <span><?php echo $pageNav->orderDownIcon($i, $n, $row->catid == @$rows[$i + 1]->catid, 'orderdown', 'Move Down', $ordering); ?> </span> <?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> <a href="<?php echo $row->cat_link; ?> " title="<?php echo JText::_('Edit Category'); ?> "> <?php echo $row->catname; ?> </a> </td> <td align="center"> <?php echo $row->numarticles; ?> </td> <td align="center"> <?php echo $row->cache_time; ?> </td> <td align="center"> <?php echo $row->id; ?> </td> </tr> <?php $k = 1 - $k; } ?> </tbody> </table> <table class="adminform"> <tr> <td> <table align="center"> <?php $visible = 0; // check to hide certain paths if not super admin if ($user->get('gid') == 25) { $visible = 1; } HTML_newsfeeds::writableCell(JPATH_SITE . DS . 'cache', 0, '<strong>' . JText::_('Cache Directory') . '</strong> ', $visible); ?> </table> </td> </tr> </table> <input type="hidden" name="option" value="<?php echo $option; ?> " /> <input type="hidden" name="task" value="" /> <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']; ?> " /> <?php echo JHTML::_('form.token'); ?> </form> <?php }
/** * Creates a new or edits and existing user record * @param int The id of the user, 0 if a new entry * @param string The current GET/POST option */ function editNewsFeed($id, $option) { global $database, $my; $catid = intval(mosGetParam($_REQUEST, 'catid', 0)); $row = new mosNewsFeed($database); // load the row from the db table $row->load((int) $id); if ($id) { // do stuff for existing records $row->checkout($my->id); } else { // do stuff for new records $row->ordering = 0; $row->numarticles = 5; $row->cache_time = 3600; $row->published = 1; } // build the html select list for ordering $query = "SELECT a.ordering AS value, a.name AS text" . "\n FROM #__newsfeeds AS a" . "\n ORDER BY a.ordering"; $lists['ordering'] = mosAdminMenus::SpecificOrdering($row, $id, $query, 1); // build list of categories $lists['category'] = mosAdminMenus::ComponentCategory('catid', $option, intval($row->catid)); // build the html select list $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $row->published); HTML_newsfeeds::editNewsFeed($row, $lists, $option); }