Page MenuHomeDevCentral

No OneTemporary

diff --git a/workspaces/src/apps/mediawikimirror/MediaWikiMirrorApplication.php b/workspaces/src/apps/mediawikimirror/MediaWikiMirrorApplication.php
index a048b84..532a0fe 100644
--- a/workspaces/src/apps/mediawikimirror/MediaWikiMirrorApplication.php
+++ b/workspaces/src/apps/mediawikimirror/MediaWikiMirrorApplication.php
@@ -1,72 +1,76 @@
<?php
/**
* _, __, _, _ __, _ _, _, _
* / \ |_) (_ | | \ | /_\ |\ |
* \ / |_) , ) | |_/ | | | | \|
* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
*
* MediaWiki mirror application class
*
* @package ObsidianWorkspaces
* @subpackage MediaWikiMirror
* @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @filesource
*/
use Waystone\Workspaces\Engines\Apps\Application;
/**
* MediaWiki mirror application class
*/
class MediaWikiMirrorApplication extends Application {
/**
* Gets rendered version URL
*
* @return string the URL
*/
public function getRenderUrl () {
return
$this->context->configuration->url[0] .
$this->context->configuration->url[1] .
"/index.php?action=render&title=". $this->context->configuration->page;
}
/**
* Fixes links in the content
*
* @param string $content The page content
* @return string The page content, with updated links
*/
public function fixLinks ($content) {
$fullUrl = $this->context->configuration->url[0] . $this->context->configuration->url[1];
$content = str_replace('<a href="' . $this->context->configuration->url[1], '<a href="' . $fullUrl, $content);
$content = str_replace(' src="' . $this->context->configuration->url[1], ' src="' . $fullUrl, $content);
return $content;
}
/**
* Handles controller request
*/
public function handleRequest () {
$smarty = $this->context->templateEngine;
- //Gets content
- $url = $this->getRenderUrl();
+ // Header
$title = $this->context->configuration->page;
- $content = file_get_contents($url);
- $content = $this->fixLinks($content);
-
- //Serves header
$smarty->assign('PAGE_TITLE', $title);
HeaderController::run($this->context);
- //Serves body
- $smarty->assign('Content', $content);
- $smarty->display('apps/mediawikimirror/page.tpl');
+ // Body
+ $url = $this->getRenderUrl();
+ try {
+ $content = file_get_contents($url);
+ $content = $this->fixLinks($content);
+ $smarty->assign("Content", $content);
+ $smarty->display("apps/mediawikimirror/page.tpl");
+ } catch (Exception $ex) {
+ $smarty->assign("alert_level", "danger");
+ $smarty->assign("alert_note", $ex->getMessage());
+ $smarty->display("apps/_blocks/alert.tpl");
+ }
- //Serves footer
+ // Footer
FooterController::run($this->context);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Feb 2, 15:11 (21 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3410423
Default Alt Text
(3 KB)

Event Timeline