private function buildSortAttribute($nsTitle, $nsId){ if ( $this->sortPageById ){ return curNS($nsId); } else { return $nsTitle; } }
public function createTOCFiles($data) { global $conf; // Split Tree for translation $translationHSFiles = array(); for ($i = 0; $i < count($data); $i++) { $lang = ''; if ($this->translation) { $this->translation->tns = $this->translation->setupTNS($data[$i]['id']); $lang = $this->translation->getLangPart($data[$i]['id']); } // get all the relative URLs $translationHSFiles[$lang][] = $data[$i]; } $toc = new siteexport_toc($this->functions); if ($this->translation) { $translationRoot = curNS($this->translation->tns); } $hsPrename = curNS(getNS($this->translation->tns)) . '_' . $translationRoot; $check = array(); foreach ($translationHSFiles as $lang => $data) { if (count($translationHSFiles) == 1 && $lang == $conf['lang']) { // If there is only one language and it is the system language - there is no language $lang = ''; } // Prepare Translations if (!empty($lang)) { $toc->translation =& $this->translation; $rootNode = cleanID($this->translation->tns . $lang) . ':'; } else { $toc->translation = null; $rootNode = ''; } $tsRootPath = $this->translationRootPath($translationRoot); // Create toc and map for each lang list($tocData, $mapData, $startPageID) = $toc->__getJavaHelpTOCXML($data, $tsRootPath); $this->functions->debug->message("Generating JavaHelpDocZip for language '{$lang}'", null, 2); $this->filewriter->__moveDataToZip($tocData, $tsRootPath . $lang . '/' . $this->tocName); $this->filewriter->__moveDataToZip($mapData, $tsRootPath . $lang . '/' . $this->mapName); // Create HS File // array_shift($toc->getMapID($rootNode, &$check)) $HS = $this->getHSXML($startPageID, $this->functions->getSiteTitle($rootNode), $lang, $tsRootPath); $this->filewriter->__moveDataToZip($HS, $hsPrename . '_' . $lang . '.hs'); // Default Lang if ($lang == $conf['lang']) { $this->filewriter->__moveDataToZip($HS, $hsPrename . '.hs'); } } }
/** * Returns the ID without the namespace or current namespace for 'start' pages * * @author Nathan Fritz <*****@*****.**> * * @param string $id * @return string */ function noNSorNS($id) { global $conf; $p = noNS($id); if ($p == $conf['start'] || $p == false) { $p = curNS($id); if ($p == false) { return $conf['start']; } } return $p; }
function _404managerProcess(&$e, $param) { global $ID; global $QUERY; global $conf; global $lang; $INFO = $this->getInfo(); $Vl_PageName = noNS($ID); $Vl_PageNameSpace = getNS($ID); // If the page does not exist and the action is show if (!page_exists($ID) && $e->data == 'show') { $this->Vc_Is404Fired = 'Y'; // Redirect if a redirection is set require_once dirname(__FILE__) . '/admin.php'; $RedirectManager = new admin_plugin_404manager(); if ($RedirectManager->IsRedirectionPresent($ID)) { $TargetPage = $RedirectManager->GetTargetPage($ID); // The Target page can be moved if (page_exists($TargetPage)) { $RedirectManager->SetRedirectionActionData($ID); if ($RedirectManager->IsValidURL($TargetPage)) { header('Location: ' . $TargetPage); exit; } else { if ($RedirectManager->GetIsValidate($ID) == 'N') { $this->Vc_Message = $this->lang['message_redirected_by_redirect']; $this->Vc_TypeMessage = 'Warning'; } $this->RedirectToId($TargetPage); } return; } } //Search same page name require_once DOKU_INC . 'inc/fulltext.php'; $Vl_SamePageName = array(); $Vl_SamePageNamesId = ft_pageLookup($Vl_PageName); //If the user have right to edit if ($_SERVER['REMOTE_USER']) { $perm = auth_quickaclcheck($ID); } else { $perm = auth_aclcheck($ID, '', null); } // Action for a writer user if ($perm >= AUTH_EDIT && $this->getConf('GoToEditMode') == 1) { $e->data = 'edit'; if ($this->getConf('ShowMessageClassic') == 1) { $this->Vc_Message = $this->lang['message_redirected_to_edit_mode']; $this->Vc_TypeMessage = 'Classic'; } // If Param show page name unique and it's not a start page if ($this->getConf('ShowPageNameIsNotUnique') == 1 && $Vl_PageName != $conf['start']) { if (count($Vl_SamePageNamesId) > 0) { $this->Vc_TypeMessage = 'Warning'; if ($this->Vc_Message != '') { $this->Vc_Message = $this->Vc_Message . '<br/><br/>'; } $this->Vc_Message = $this->Vc_Message . $this->lang['message_pagename_exist_one']; $this->Vc_Message = $this->Vc_Message . '<ul>'; foreach ($Vl_SamePageNamesId as $PageId) { if ($conf['useheading']) { $title = p_get_first_heading($PageId); } if (!$title) { $title = $PageId; } $this->Vc_Message = $this->Vc_Message . '<li class="level1"><div class="li"><a href="' . wl($PageId) . '" rel="nofollow" class="wikilink1" title="' . wl($PageId) . '">' . $title . '</a></div></li>'; } $this->Vc_Message = $this->Vc_Message . '</ul>'; $this->Vc_Message = $this->Vc_Message . $this->lang['message_pagename_exist_two'] . curNS($ID) . '_' . $Vl_PageName . ' ).'; } } return; } // User not allowed to edit the page (public of other) if ($perm < AUTH_EDIT && $this->getConf('ActionReaderFirst') != 'Nothing') { $Vl_ActionToPerform = array(); $Vl_ActionToPerform[0] = $this->getConf('ActionReaderFirst'); $Vl_ActionToPerform[1] = $this->getConf('ActionReaderSecond'); $Vl_ActionToPerform[2] = $this->getConf('ActionReaderThird'); $i = 0; while (isset($Vl_ActionToPerform[$i])) { switch ($Vl_ActionToPerform[$i]) { case 'Nothing': return; break; case 'GoToNsStartPage': $Vl_IdStartPage = getNS($ID) . ':' . $conf['start']; if (page_exists($Vl_IdStartPage)) { $this->Vc_Message = $this->lang['message_redirected_to_startpage']; $this->Vc_TypeMessage = 'Warning'; $this->RedirectToId($Vl_IdStartPage); return; } $Vl_IdStartPage = getNS($ID) . ':' . curNS($ID); if (page_exists($Vl_IdStartPage)) { $this->Vc_Message = $this->lang['message_redirected_to_startpage']; $this->Vc_TypeMessage = 'Warning'; $this->RedirectToId($Vl_IdStartPage); return; } break; case 'GoToBestPageName': $Vl_ScorePageName = 0; $Vl_BestPageId = ''; //Get Score from a page if (count($Vl_SamePageNamesId) > 0) { // Search same namespace in the page found than in the Id page asked. $Vl_BestNbWordFound = 0; $Vl_BestPageId = ''; $Vl_IdToExplode = str_replace('_', ':', $ID); $Vl_WordsInId = explode(':', $Vl_IdToExplode); foreach ($Vl_SamePageNamesId as $Vl_PageId) { $Vl_NbWordFound = 0; foreach ($Vl_WordsInId as $Vl_Word) { $Vl_NbWordFound = $Vl_NbWordFound + substr_count($Vl_PageId, $Vl_Word); } if ($Vl_NbWordFound >= $Vl_BestNbWordFound) { $Vl_BestNbWordFound = $Vl_NbWordFound; $Vl_BestPageId = $Vl_PageId; } } $Vl_ScorePageName = $this->getConf('WeightFactorForSamePageName') + $Vl_BestNbWordFound * $this->getConf('WeightFactorForSameNamespace'); } // Get Score from a Namespace $Vl_ScoreNamespace = 0; $Vl_BestNamespaceId = ''; list($Vl_BestNamespaceId, $Vl_ScoreNamespace) = explode(" ", $this->getBestNamespace($ID)); // Compare the two score if ($Vl_ScorePageName > 0 or $Vl_ScoreNamespace > 0) { if ($Vl_ScorePageName > $Vl_ScoreNamespace) { $this->RedirectToId($Vl_BestPageId); } else { $this->RedirectToId($Vl_BestNamespaceId); } $this->Vc_Message = $this->lang['message_redirected_to_bestpagename']; $this->Vc_TypeMessage = 'Warning'; return; } break; case 'GoToBestNamespace': $Vl_Score = 0; $Vl_BestNamespaceId = ''; list($Vl_BestNamespaceId, $Vl_Score) = explode(" ", $this->getBestNamespace($ID)); if ($Vl_Score > 0) { $this->Vc_Message = $this->lang['message_redirected_to_bestnamespace']; $this->Vc_TypeMessage = 'Warning'; $this->RedirectToId($Vl_BestNamespaceId); return; } break; case 'GoToSearchEngine': //do fulltext search $this->Vc_Message = $this->lang['message_redirected_to_searchengine']; $this->Vc_TypeMessage = 'Warning'; $QUERY = str_replace(':', '_', $ID); $e->data = 'search'; break; // End Switch Action } $i++; // End While Action } // End if not connected } // End if page exist } //End Fonction }