/** * * Get details of the "Uncategorized" category for a given extension, * storing the result in a cache variable * * @param string $extension full name of extension, ie "com_content" */ public static function getSh404sefContentCat() { // if not already in cache if (is_null(self::$_sh404sefContentCat)) { try { // read details from database self::$_sh404sefContentCat = ShlDbHelper::selectObject('#__categories', '*', array('parent_id' => 1, 'extension' => 'com_content', 'path' => 'sh404sef-custom-content', 'level' => 1)); } catch (Exception $e) { self::$_sh404sefContentCat = null; } } return self::$_sh404sefContentCat; }
public function getCategorySlugArray($extension, $id, $whichCat, $useAlias, $insertId, $uncategorizedPath = '', $requestedLanguage = '*', $separator = '') { // special case for the "uncategorised" category $unCat = Sh404sefHelperCategories::getUncategorizedCat($extension); if (!empty($unCat) && $id == $unCat->id) { $slugArray = empty($uncategorizedPath) ? array() : array($uncategorizedPath); return $slugArray; } // regular category, build the path to the cat $separator = empty($separator) ? Sh404sefFactory::getConfig()->replacement : $separator; $pathArray = $this->getCategoryPathArray($extension, $id, $whichCat, $useAlias, $insertId, $requestedLanguage, $separator); $slugArray = array(); foreach ($pathArray as $catObject) { $slugArray[] = $catObject->slug; } return $slugArray; }
/** * Insert an intro text into the content table * * @param strng $shIntroText * @return boolean, true if success */ function shInsertContent( $pageTitle, $shIntroText) { jimport('joomla.database.table'); try { $catid = Sh404sefHelperCategories::getUncategorizedCat(); if(empty($catid)) { $this->setError( JText::_('COM_SH404SEF_CANNOT_SAVE_404_NO_UNCAT')); return; } $contentTable = JTable::getInstance( 'content'); $content = array( 'title' => $pageTitle, 'alias' => $pageTitle, 'title_alias' => $pageTitle, 'introtext' => $shIntroText, 'state' => 1 , 'catid' => $catid, 'attribs' => '{"menu_image":"-1","show_title":"0","show_section":"0","show_category":"0","show_vote":"0","show_author":"0","show_create_date":"0","show_modify_date":"0","show_pdf_icon":"0","show_print_icon":"0","show_email_icon":"0","pageclass_sfx":""'); $status = $contentTable->save( $content); } catch (Sh404sefExceptionDefault $e) { $status = false; } return $status; }
/** * Prepare saving of Error documents configuration options set */ private function _saveErrordocs() { // update 404 error page $quoteGPC = get_magic_quotes_gpc(); $shIntroText = empty($_POST) ? '' : ($quoteGPC ? stripslashes($_POST['introtext']) : $_POST['introtext']); try { // is there already a 404 page article? $id = Sh404sefHelperDb::selectResult('#__content', 'id', array('title' => '__404__', 'language' => '*')); if (!empty($id)) { // yes, update it Sh404sefHelperDb::update('#__content', array('introtext' => $shIntroText, 'modified' => date("Y-m-d H:i:s")), array('id' => $id)); } else { $catid = Sh404sefHelperCategories::getSh404sefContentCat(); if (empty($catid)) { $this->setError(JText::_('COM_SH404SEF_CANNOT_SAVE_404_NO_UNCAT')); return; } $contentTable = JTable::getInstance('content'); $content = array('title' => '__404__', 'alias' => '__404__', 'title_alias' => '__404__', 'introtext' => $shIntroText, 'state' => 1, 'catid' => $catid, 'attribs' => '{"menu_image":"-1","show_title":"0","show_section":"0","show_category":"0","show_vote":"0","show_author":"0","show_create_date":"0","show_modify_date":"0","show_pdf_icon":"0","show_print_icon":"0","show_email_icon":"0","pageclass_sfx":""', 'language' => '*'); $saved = $contentTable->save($content); if (!$saved) { $this->setError($contentTable->getError()); } } } catch (Sh404sefExceptionDefault $e) { $this->setError($e->getMEssage()); } // prevent from being added later on to $sefConfig unset($_POST['introtext']); }
/** * Push current error documents content * values into the view for edition */ private function _pushConfigDataErrorDocs() { // get configuration object $sefConfig =& Sh404sefFactory::getConfig(); // push it into to the view $this->assignRef('sefConfig', $sefConfig); // special check for Joomfish 2.0 : must be sure href are not cached in language selection module // otherwise new SEF urls will not be created shDisableJFModuleCaching(); $database =& JFactory::getDBO(); $std_opt = 'class="inputbox" size="2"'; // find about "uncategorized" category $unCat = Sh404sefHelperCategories::getUncategorizedCat(); // get a list of the static content items for 404 page $query = "SELECT id, title" . "\n FROM #__content" . "\n WHERE title != '__404__'" . "\n AND catid = " . intval($unCat->id) . "\n ORDER BY ordering"; $database->setQuery($query); $items = $database->loadObjectList(); $options = array(JHTML::_('select.option', 0, "(" . JText::_('COM_SH404SEF_DEF_404_PAGE') . ")")); //$options[] = JHTML::_('select.option', 9999999, "(Front Page)" ); // 1.2.4.t // assemble menu items to the array foreach ($items as $item) { $options[] = JHTML::_('select.option', $item->id, $item->title); } $lists['page404'] = JHTML::_('select.genericlist', $options, 'page404', 'class="inputbox" size="1"', 'value', 'text', $sefConfig->page404); $sql = 'SELECT id,introtext FROM #__content WHERE `title`="__404__"'; $row = null; $database->setQuery($sql); $row = $database->loadObject(); if (!empty($row) && !empty($row->introtext)) { // V 1.2.4.t $txt404 = $row->introtext; } else { $txt404 = JText::_('COM_SH404SEF_DEF_404_MSG'); } //push params in to view $this->assign('lists', $lists); $this->assign('txt404', $txt404); }