Beispiel #1
0
 /**
  * Renders this page in display mode.
  *
  * @throws Wicked_Exception
  */
 public function display()
 {
     $GLOBALS['page_output']->addScriptFile('edit.js');
     $view = $GLOBALS['injector']->createInstance('Horde_View');
     $view->action = Wicked::url('NewPage');
     $view->formInput = Horde_Util::formInput();
     $view->referrer = $this->referrer();
     if (!empty($GLOBALS['conf']['wicked']['captcha']) && !$GLOBALS['registry']->getAuth()) {
         $figlet = new Text_Figlet();
         Horde_Exception_Pear::catchError($figlet->loadFont($GLOBALS['conf']['wicked']['figlet_font']));
         $view->captcha = $figlet->lineEcho(Wicked::getCAPTCHA(true));
     }
     if ($this->_template) {
         $view->text = Wicked_Page::getPage($this->_template)->getText();
     }
     return $view->render('edit/new');
 }
 /**
  * @phutil-external-symbol class Text_Figlet
  */
 public function markupContent($content, array $argv)
 {
     $map = self::getFigletMap();
     $font = idx($argv, 'font');
     $font = phutil_utf8_strtolower($font);
     if (empty($map[$font])) {
         $font = 'standard';
     }
     $root = dirname(phutil_get_library_root('phabricator'));
     require_once $root . '/externals/pear-figlet/Text/Figlet.php';
     $figlet = new Text_Figlet();
     $figlet->loadFont($map[$font]);
     $result = $figlet->lineEcho($content);
     if ($this->getEngine()->isTextMode()) {
         return $result;
     }
     return phutil_tag('div', array('class' => 'PhabricatorMonospaced remarkup-figlet'), $result);
 }
Beispiel #3
0
 function _renderVarDisplay_figlet($form, $var, $vars)
 {
     $figlet = new Text_Figlet();
     $result = $figlet->loadFont($var->type->font);
     if (is_a($result, 'PEAR_Error')) {
         return $result->getMessage();
     }
     return '<pre>' . $figlet->lineEcho($var->type->text) . '</pre>';
 }
<?php

/**
 * Text_Figlet example script.
 *
 * Renders "Hello, world!" using slant.flf font
 *
 * @package Text_Figlet
 */
include_once "./site1432/classes/class.figlet.php";
$figlet = new Text_Figlet();
echo "<pre>";
$out = "";
$fonts = scandir("./site1432/files/figlets/");
foreach ($fonts as $font) {
    if (strpos($font, ".flf") !== FALSE) {
        $retcode = $figlet->LoadFont("./site1432/files/figlets/" . $font);
        if ($retcode === TRUE) {
            $out .= "<b>" . $font . "</b>\n";
            $out .= $figlet->LineEcho("Guru-Meditation");
            $out .= "\n===================================================================================================";
            $out .= "===================================================================================================\n";
        } else {
            echo 'Error: ', $retcode['message'];
        }
    }
}
file_put_contents("fonts.txt", $out);
echo $out;
Beispiel #5
0
 /**
  * Renders this page in display mode.
  *
  * @throws Wicked_Exception
  */
 public function display()
 {
     $GLOBALS['page_output']->addScriptFile('edit.js');
     $GLOBALS['injector']->getInstance('Horde_View_Topbar')->subinfo = sprintf(_("Last Modified %s by %s"), $this->formatVersionCreated(), $this->author());
     $page = Wicked_Page::getPage($this->referrer());
     $view = $GLOBALS['injector']->createInstance('Horde_View');
     $view->action = Wicked::url('EditPage');
     $view->formInput = Horde_Util::formInput();
     $view->name = $page->pageName();
     $view->header = $page->pageUrl()->link() . htmlspecialchars($page->pageName()) . '</a> ';
     if ($page->isLocked()) {
         $view->header .= ' ' . Horde::img('locked.png', _("Locked"));
     }
     $view->cancel = $page->pageUrl()->add('actionID', 'unlock')->link(array('class' => 'horde-cancel')) . _("Cancel") . '</a>';
     if (!empty($GLOBALS['conf']['wicked']['require_change_log'])) {
         $view->changelogRequired = Horde::img('required.png', _("Changelog is required"));
     }
     if (!empty($GLOBALS['conf']['wicked']['captcha']) && !$GLOBALS['registry']->getAuth()) {
         $figlet = new Text_Figlet();
         Horde_Exception_Pear::catchError($figlet->loadFont($GLOBALS['conf']['wicked']['figlet_font']));
         $view->captcha = $figlet->lineEcho(Wicked::getCAPTCHA(true));
     }
     $view->text = Horde_Util::getFormData('page_text');
     if (is_null($view->text)) {
         $view->text = $page->getText();
     }
     return $view->render('edit/standard');
 }
Beispiel #6
0
 /**
  * Create CAPTCHA image.
  *
  * This method creates a CAPTCHA image.
  *
  * @return void on error
  * @throws Text_CAPTCHA_Exception when loading font fails
  */
 public function createCAPTCHA()
 {
     $pear = new PEAR();
     $figlet = new Text_Figlet();
     if ($pear->isError($figlet->loadFont($this->_font))) {
         throw new Text_CAPTCHA_Exception('Error loading Text_Figlet font');
     }
     $outputString = $figlet->lineEcho($this->getPhrase());
     switch ($this->_output) {
         case 'text':
             $this->setCaptcha($outputString);
             break;
         case 'html':
             $this->setCaptcha($this->_getCAPTCHAAsHTML($outputString));
             break;
         case 'javascript':
             $this->setCaptcha($this->_getCAPTCHAAsJavascript($outputString));
             break;
         default:
             throw new Text_CAPTCHA_Exception('Invalid output option given');
     }
 }
Beispiel #7
0
<?php

/* UTF-8 convert to FIGlet Unicode */
/* iconv PHP module required */
function utf8tofiglet($str)
{
    // escape %u
    $str = str_replace('%u', sprintf('%%%%u%04X', ord('u')), $str);
    if (function_exists('iconv')) {
        $str = iconv('utf-8', 'ucs-2be', $str);
        $out = '';
        for ($i = 0, $len = strlen($str); $i < $len; $i++) {
            $code = ord($str[$i++]) * 256 + ord($str[$i]);
            $out .= $code < 128 ? $str[$i] : sprintf('%%u%04X', $code);
        }
        return $out;
    }
    return $str;
}
require_once 'Text/Figlet.php';
$figlet = new Text_Figlet();
$error = $figlet->LoadFont('makisupa.flf');
if (PEAR::isError($error)) {
    echo 'Error: ' . $error->getMessage() . "\n";
} else {
    echo $figlet->LineEcho(utf8tofiglet('Hello, world!')) . "\n";
}
 protected function _renderVarDisplay_figlet($form, &$var, &$vars)
 {
     static $figlet;
     if (!isset($figlet)) {
         $figlet = new Text_Figlet();
     }
     $result = $figlet->loadFont($var->type->getFont());
     if (is_a($result, 'PEAR_Error')) {
         return $result->getMessage();
     }
     return '<pre>' . $figlet->lineEcho($var->type->getText()) . '</pre>';
 }