/** * Compiles information to add or edit a section * @param database A database connector object * @param string The name of the category section * @param integer The unique id of the category to edit (0 if new) * @param string The name of the current user */ function editSection($edit) { global $mainframe; $db =& JFactory::getDBO(); $user =& JFactory::getUser(); $option = JRequest::getCmd('option'); $scope = JRequest::getCmd('scope'); $cid = JRequest::getVar('cid', array(0), '', 'array'); JArrayHelper::toInteger($cid, array(0)); $row =& JTable::getInstance('section'); // load the row from the db table if ($edit) { $row->load($cid[0]); } // fail if checked out not by 'me' if ($row->isCheckedOut($user->get('id'))) { $msg = JText::sprintf('DESCBEINGEDITTED', JText::_('The section'), $row->title); $mainframe->redirect('index.php?option=' . $option . '&scope=' . $row->scope, $msg); } if ($edit) { $row->checkout($user->get('id')); } else { $row->scope = $scope; $row->published = 1; } // build the html select list for ordering $query = 'SELECT ordering AS value, title AS text' . ' FROM #__sections' . ' WHERE scope=' . $db->Quote($row->scope) . ' ORDER BY ordering'; if ($edit) { $lists['ordering'] = JHTML::_('list.specificordering', $row, $cid[0], $query); } else { $lists['ordering'] = JHTML::_('list.specificordering', $row, '', $query); } // build the select list for the image positions $active = $row->image_position ? $row->image_position : 'left'; $lists['image_position'] = JHTML::_('list.positions', 'image_position', $active, NULL, 0); // build the html select list for images $lists['image'] = JHTML::_('list.images', 'image', $row->image); // build the html select list for the group access $lists['access'] = JHTML::_('list.accesslevel', $row); // build the html radio buttons for published $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published); sections_html::edit($row, $option, $lists); }
/** * Compiles information to add or edit a section * @param database A database connector object * @param string The name of the category section * @param integer The unique id of the category to edit (0 if new) * @param string The name of the current user */ function editSection($uid = 0, $scope = '', $option) { global $database, $my, $adminLanguage; global $mosConfig_absolute_path, $mosConfig_live_site; $row = new mosSection($database); // load the row from the db table $row->load($uid); // fail if checked out not by 'me' if ($row->checked_out && $row->checked_out != $my->id) { $msg = $adminLanguage->A_COMP_SECT_THE . " " . $row->title . " " . $adminLanguage->A_COMP_ANOTHER_ADMIN; mosRedirect('index2.php?option=' . $option . '&scope=' . $row->scope . '&mosmsg=' . $msg); } if ($uid) { $row->checkout($my->id); if ($row->id > 0) { $query = "SELECT *" . "\n FROM #__menu" . "\n WHERE componentid = " . $row->id . "\n AND ( type = 'content_archive_section' OR type = 'content_blog_section' OR type = 'content_section' )"; $database->setQuery($query); $menus = $database->loadObjectList(); $count = count($menus); for ($i = 0; $i < $count; $i++) { switch ($menus[$i]->type) { case 'content_section': $menus[$i]->type = 'Section Table'; break; case 'content_blog_section': $menus[$i]->type = 'Section Blog'; break; case 'content_archive_section': $menus[$i]->type = 'Section Blog Archive'; break; } } } else { $menus = array(); } } else { $row->scope = $scope; $row->published = 1; $menus = array(); } // build the html select list for section types $types[] = mosHTML::makeOption('', $adminLanguage->A_COMP_CATEG_SELECT_TYPE); $types[] = mosHTML::makeOption('content_section', $adminLanguage->A_COMP_SECT_LIST); $types[] = mosHTML::makeOption('content_blog_section', $adminLanguage->A_COMP_SECT_BLOG); $types[] = mosHTML::makeOption('content_archive_section', $adminLanguage->A_COMP_SECT_ARCHIVE_BLOG); $lists['link_type'] = mosHTML::selectList($types, 'link_type', 'class="inputbox" size="1"', 'value', 'text'); // build the html select list for ordering $query = "SELECT ordering AS value, title AS text" . "\n FROM #__sections" . "\n WHERE scope='{$row->scope}' ORDER BY ordering"; $lists['ordering'] = mosAdminMenus::SpecificOrdering($row, $uid, $query); // build the select list for the image positions $active = $row->image_position ? $row->image_position : 'left'; $lists['image_position'] = mosAdminMenus::Positions('image_position', $active, NULL, 0); // build the html select list for images $lists['image'] = mosAdminMenus::Images('image', $row->image); // build the html select list for the group access $lists['access'] = mosAdminMenus::Access($row); // build the html radio buttons for published $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $row->published); // build the html select list for menu selection $lists['menuselect'] = mosAdminMenus::MenuSelect(); sections_html::edit($row, $option, $lists, $menus); }
/** * Compiles information to add or edit a section * @param database A database connector object * @param string The name of the category section * @param integer The unique id of the category to edit (0 if new) * @param string The name of the current user */ function editSection($uid = 0, $scope = '', $option) { global $database, $my, $mainframe; $row = new mosSection($database); // load the row from the db table $row->load((int) $uid); // fail if checked out not by 'me' if ($row->isCheckedOut($my->id)) { $msg = 'The section ' . $row->title . ' is currently being edited by another administrator'; mosRedirect('index2.php?option=' . $option . '&scope=' . $row->scope . '&mosmsg=' . $msg); } $selected_folders = NULL; if ($uid) { $row->checkout($my->id); if ($row->id > 0) { $query = "SELECT *" . "\n FROM #__menu" . "\n WHERE componentid = " . (int) $row->id . "\n AND ( type = 'content_archive_section' OR type = 'content_blog_section' OR type = 'content_section' )"; $database->setQuery($query); $menus = $database->loadObjectList(); $count = count($menus); for ($i = 0; $i < $count; $i++) { switch ($menus[$i]->type) { case 'content_section': $menus[$i]->type = 'Section Table'; break; case 'content_blog_section': $menus[$i]->type = 'Section Blog'; break; case 'content_archive_section': $menus[$i]->type = 'Section Blog Archive'; break; } } } else { $menus = array(); } // handling for MOSImage directories if (trim($row->params)) { // get params definitions $params = new mosParameters($row->params, $mainframe->getPath('com_xml', 'com_sections'), 'component'); $temps = $params->get('imagefolders', ''); $temps = explode(',', $temps); foreach ($temps as $temp) { $selected_folders[] = mosHTML::makeOption($temp, $temp); } } else { $selected_folders[] = mosHTML::makeOption('*1*'); } } else { $row->scope = $scope; $row->published = 1; $menus = array(); // handling for MOSImage directories $selected_folders[] = mosHTML::makeOption('*1*'); } // build the html select list for section types $types[] = mosHTML::makeOption('', 'Select Type'); $types[] = mosHTML::makeOption('content_section', 'Section List'); $types[] = mosHTML::makeOption('content_blog_section', 'Section Blog'); $types[] = mosHTML::makeOption('content_archive_section', 'Section Archive Blog'); $lists['link_type'] = mosHTML::selectList($types, 'link_type', 'class="inputbox" size="1"', 'value', 'text'); // build the html select list for ordering $query = "SELECT ordering AS value, title AS text" . "\n FROM #__sections" . "\n WHERE scope=" . $database->Quote($row->scope) . " ORDER BY ordering"; $lists['ordering'] = mosAdminMenus::SpecificOrdering($row, $uid, $query); // build the select list for the image positions $active = $row->image_position ? $row->image_position : 'left'; $lists['image_position'] = mosAdminMenus::Positions('image_position', $active, NULL, 0); // build the html select list for images $lists['image'] = mosAdminMenus::Images('image', $row->image); // build the html select list for the group access $lists['access'] = mosAdminMenus::Access($row); // build the html radio buttons for published $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $row->published); // build the html select list for menu selection $lists['menuselect'] = mosAdminMenus::MenuSelect(); // list of folders in images/stories/ $imgFiles = recursive_listdir(COM_IMAGE_BASE); $len = strlen(COM_IMAGE_BASE); // handling for MOSImage directories $folders[] = mosHTML::makeOption('*1*', 'All'); $folders[] = mosHTML::makeOption('*0*', 'None'); $folders[] = mosHTML::makeOption('*#*', '---------------------'); $folders[] = mosHTML::makeOption('/'); foreach ($imgFiles as $file) { $folders[] = mosHTML::makeOption(substr($file, $len)); } $lists['folders'] = mosHTML::selectList($folders, 'folders[]', 'class="inputbox" size="17" multiple="multiple"', 'value', 'text', $selected_folders); sections_html::edit($row, $option, $lists, $menus); }
/** * Compiles information to add or edit a section * @param database A database connector object * @param string The name of the category section * @param integer The unique id of the category to edit (0 if new) * @param string The name of the current user */ function editSection($uid = 0, $scope = '', $option) { global $database, $my; $row = new mosSection($database); // load the row from the db table $row->load($uid); $row->title = htmlspecialchars(str_replace('&', '&', $row->title)); $row->name = htmlspecialchars(str_replace('&', '&', $row->name)); // fail if checked out not by 'me' if ($row->checked_out && $row->checked_out != $my->id) { $msg = sprintf(T_('The section %s is currently being edited by another administrator'), $row->title); mosRedirect('index2.php?option=' . $option . '&scope=' . $row->scope . '&mosmsg=' . $msg); } if ($uid) { $row->checkout($my->id); if ($row->id > 0) { $query = "SELECT *" . "\n FROM #__menu" . "\n WHERE componentid = " . $row->id . "\n AND ( type = 'content_archive_section' OR type = 'content_blog_section' OR type = 'content_section' )"; $database->setQuery($query); $menus = $database->loadObjectList(); $count = count($menus); for ($i = 0; $i < $count; $i++) { switch ($menus[$i]->type) { case 'content_section': $menus[$i]->type = T_('Section Table'); break; case 'content_blog_section': $menus[$i]->type = T_('Section Blog'); break; case 'content_archive_section': $menus[$i]->type = T_('Section Blog Archive'); break; } } } else { $menus = array(); } } else { $row->scope = $scope; $row->published = 1; $menus = array(); } // build the html select list for section types $types[] = mosHTML::makeOption('', T_('Select Type')); $types[] = mosHTML::makeOption('content_section', T_('Section List')); $types[] = mosHTML::makeOption('content_blog_section', T_('Section Blog')); $types[] = mosHTML::makeOption('content_archive_section', T_('Section Archive Blog')); $lists['link_type'] = mosHTML::selectList($types, 'link_type', 'class="inputbox" size="1"', 'value', 'text'); // build the html select list for ordering $query = "SELECT ordering AS value, title AS text" . "\n FROM #__sections" . "\n WHERE scope='{$row->scope}' ORDER BY ordering"; $lists['ordering'] = mosAdminMenus::SpecificOrdering($row, $uid, $query); // build the select list for the image positions $active = $row->image_position ? $row->image_position : 'left'; $lists['image_position'] = mosAdminMenus::Positions('image_position', $active, NULL, 0); // build the html select list for images $lists['image'] = mosAdminMenus::Images('image', $row->image); // build the html select list for the group access $lists['access'] = mosAdminMenus::Access($row); // build the html radio buttons for published $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $row->published); // build the html select list for menu selection $lists['menuselect'] = mosAdminMenus::MenuSelect(); sections_html::edit($row, $option, $lists, $menus); }