From 8f1c4682edd7013fa3bb513885f1e4f8acf314c4 Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Mon, 17 May 2010 22:02:59 -0400 Subject: [PATCH] Pastie: Fix list of valid syntaxes when calling highlighters --- pastie/lib/Forms/Paste.php | 14 +++++++++++++- pastie/paste.php | 2 +- pastie/view.php | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/pastie/lib/Forms/Paste.php b/pastie/lib/Forms/Paste.php index 4a4fdbeab..b13db186b 100644 --- a/pastie/lib/Forms/Paste.php +++ b/pastie/lib/Forms/Paste.php @@ -16,7 +16,19 @@ class PasteForm extends Horde_Form { parent::Horde_Form($vars, _("New Paste")); - $types = array('none', 'php'); + $engine = 'Pastie_Highlighter_' . $GLOBALS['conf']['highlighter']['engine']; + $tmp = call_user_func(array($engine, 'getSyntaxes')); + $types = array(); + foreach ($tmp as $type) { + $types[$type] = $type; + } + + // Some highlighters have a long list of supported languages. + // Default to PHP if one is not already specified + $curtype = $vars->get('syntax'); + if (empty($curtype)) { + $vars->set('syntax', 'php'); + } $this->addVariable(_("Title"), 'title', 'text', false); diff --git a/pastie/paste.php b/pastie/paste.php index b8e15d85b..a7baa7311 100644 --- a/pastie/paste.php +++ b/pastie/paste.php @@ -28,7 +28,7 @@ if ($form->validate($vars)) { $notification->push(sprintf('Paste saved. %s', $uuid), 'horde.success'); - $url = Horde::applicationUrl('view/' . $uuid, true); + $url = Horde::applicationUrl('uuid/' . $uuid, true); header('Location: ' . $url); exit; } catch (Exception $e) { diff --git a/pastie/view.php b/pastie/view.php index 4bb5afceb..ab2be4c36 100644 --- a/pastie/view.php +++ b/pastie/view.php @@ -14,7 +14,7 @@ require_once dirname(__FILE__) . '/lib/Application.php'; $pastie = Horde_Registry::appInit('pastie'); require_once PASTIE_BASE . '/lib/Forms/Paste.php'; -$uuid = trim(Horde_Util::getPathInfo(), '/'); +$uuid = Horde_Util::getFormData('uuid'); if (!empty($uuid)) { try { @@ -31,7 +31,7 @@ $form = new PasteForm($vars); try { $engine = 'Pastie_Highlighter_' . $GLOBALS['conf']['highlighter']['engine']; - $output = $engine::output($paste['paste'], $paste['syntax']); + $output = call_user_func_array(array($engine, 'output'), array($paste['paste'], $paste['syntax'])); } catch (Pastie_Exception $e) { $output = _("Error parsing the paste."); } -- 2.11.0