public function page(Page $page) { $this->tocBuilder = new TocBuilder(); $page->setContent(parent::text($page->getContent())); $page->setToc($this->tocBuilder->getToc()); $this->tocBuilder = null; }
/** * @return bool */ public function doWork() { global $wgUseFileCache; // @todo several of the methods called on $this->page are not declared in Page, but present // in WikiPage and delegated by Article. $isCurrent = $this->revid === $this->page->getLatest(); if ($this->content !== null) { $content = $this->content; } elseif ($isCurrent) { // XXX: why use RAW audience here, and PUBLIC (default) below? $content = $this->page->getContent(Revision::RAW); } else { $rev = Revision::newFromTitle($this->page->getTitle(), $this->revid); if ($rev === null) { $content = null; } else { // XXX: why use PUBLIC audience here (default), and RAW above? $content = $rev->getContent(); } } if ($content === null) { return false; } // Reduce effects of race conditions for slow parses (bug 46014) $cacheTime = wfTimestampNow(); $time = -microtime(true); $this->parserOutput = $content->getParserOutput($this->page->getTitle(), $this->revid, $this->parserOptions); $time += microtime(true); // Timing hack if ($time > 3) { // TODO: Use Parser's logger (once it has one) $logger = MediaWiki\Logger\LoggerFactory::getInstance('slow-parse'); $logger->info('{time} {title}', array('time' => number_format($time, 2), 'title' => $this->page->getTitle()->getPrefixedDBkey())); } if ($this->cacheable && $this->parserOutput->isCacheable() && $isCurrent) { ParserCache::singleton()->save($this->parserOutput, $this->page, $this->parserOptions, $cacheTime, $this->revid); } // Make sure file cache is not used on uncacheable content. // Output that has magic words in it can still use the parser cache // (if enabled), though it will generally expire sooner. if (!$this->parserOutput->isCacheable()) { $wgUseFileCache = false; } if ($isCurrent) { $this->page->triggerOpportunisticLinksUpdate($this->parserOutput); } return true; }
/** * @return bool */ public function doWork() { global $wgUseFileCache; // @todo several of the methods called on $this->page are not declared in Page, but present // in WikiPage and delegated by Article. $isCurrent = $this->revid === $this->page->getLatest(); if ($this->content !== null) { $content = $this->content; } elseif ($isCurrent) { // XXX: why use RAW audience here, and PUBLIC (default) below? $content = $this->page->getContent(Revision::RAW); } else { $rev = Revision::newFromTitle($this->page->getTitle(), $this->revid); if ($rev === null) { $content = null; } else { // XXX: why use PUBLIC audience here (default), and RAW above? $content = $rev->getContent(); } } if ($content === null) { return false; } // Reduce effects of race conditions for slow parses (bug 46014) $cacheTime = wfTimestampNow(); $time = -microtime(true); $this->parserOutput = $content->getParserOutput($this->page->getTitle(), $this->revid, $this->parserOptions); $time += microtime(true); // Timing hack if ($time > 3) { wfDebugLog('slow-parse', sprintf("%-5.2f %s", $time, $this->page->getTitle()->getPrefixedDBkey())); } if ($this->cacheable && $this->parserOutput->isCacheable() && $isCurrent) { ParserCache::singleton()->save($this->parserOutput, $this->page, $this->parserOptions, $cacheTime, $this->revid); } // Make sure file cache is not used on uncacheable content. // Output that has magic words in it can still use the parser cache // (if enabled), though it will generally expire sooner. if (!$this->parserOutput->isCacheable() || $this->parserOutput->containsOldMagic()) { $wgUseFileCache = false; } if ($isCurrent) { $this->page->doCascadeProtectionUpdates($this->parserOutput); } return true; }
$view->setTitle("Viewing Page"); try { $page = new Page($id); } catch (Exception $e) { if ($e->getCode() == PAGE_NOT_EXIST) { header("Location: " . orongoURL("orongo-admin/manage.php?msg=0&obj=pages")); exit; } else { header("Location: " . orongoURL("orongo-admin/index.php?msg=2")); exit; } } $form = new AdminFrontendForm(100, l("Page") . ": " . $page->getTitle(), "GET", "", false); $form->addInput("ID", "id", "text", $page->getID(), false, true); $form->addInput("Page Title", "title", "text", $page->getTitle(), false, true); $form->addInput("Page Content", "content", "ckeditor", $page->getContent(), false, true); $form->addButton("Delete", false, orongoURL("orongo-admin/delete.php?page." . $id)); $form->addButton("Edit", false, orongoURL("orongo-admin/edit.php?page." . $id)); $view->addObject($form); $view->render(); break; case "user": if ($id != getUser()->getID() && getUser()->getRank() != RANK_ADMIN) { header("Location: " . orongoURL("orongo-admin/index.php?msg=0")); exit; } $user = null; $view->setTitle("Viewing User"); try { $user = new User($id); } catch (Exception $e) {
include_once "modules/classes/{$name}.class.php"; } session_start(); $profil = new Profil(); $page = new Page(); if (!isset($_SESSION['kvh_login']) || $_SESSION['kvh_login'] == "" || $_SESSION['kvh_login'] == 0 || !$profil->checkIDLogin($_SESSION['kvh_login'])) { $page->setTitle("KVH Ústí nad Labem"); $page->addToDrobeckovaNavigace('<a href="index.php">kvhusti.cz</a>'); $page->setNavigation(include_once 'views/navigation.php'); $page->setContent(include_once "controllers/admin/badName.php"); $page->setAdminLog(include 'controllers/login/form.php'); print (include_once 'views/page.php'); return; } $page->addScript('<script src="js/ajax.js"></script>'); $page->addScript('<script src="js/admin.js"></script>'); $page->addScript('<script src="js/jquery-ui-1.8.18.custom.min.js"></script>'); if (isset($_GET['page'])) { $getPage = $_GET['page']; } else { $getPage = "home"; } $page->setTitle("KVH Ústí nad Labem"); $page->addToDrobeckovaNavigace('<a href="admin.php">kvhusti.cz</a>'); $page->setNavigation(include_once 'views/admin/navigation.php'); $page->setContent(include_once "controllers/admin/{$getPage}.php"); if ($page->getContent() == "") { $page->setContent(include_once "controllers/404.php"); } $page->setAdminLog(include 'controllers/login/activeMember.php'); print (include_once 'views/page.php');
public function testPage() { $date = new \DateTime(); $page = new Page(123, 1, 'A page', 'Some content', 2, $date, 0, 25); $this->assertEquals(123, $page->getID()); $this->assertEquals('A page', $page->getTitle()); $this->assertEquals('Some content', $page->getContent()); $this->assertEquals(2, $page->getVisibility()); $this->assertEquals($date, $page->getDate()); $this->assertEquals(25, $page->getPosition()); }