Beispiel #1
0
 /**
  * Create new instance.
  */
 public function __construct()
 {
     parent::__construct();
     $language = Config::language();
     $variables = array('targetBaseUri', 'feedBaseUri', 'idprefix');
     foreach ($variables as $varname) {
         $this->{$varname} = str_replace('{language}', $language, $this->{$varname});
     }
 }
Beispiel #2
0
    /**
     * Create the file header.
     *
     * @param string $id XML ID of node being rendered.
     *
     * @return string Generated file header
     *
     * @usedby writeChunk()
     */
    public function header($id)
    {
        $title = htmlspecialchars($this->getLongDescription($id));
        $date = $this->date;
        $lang = Config::language();
        $selflink = $this->createLink($id);
        $htmllink = $this->createTargetLink($id);
        $author = htmlspecialchars($this->author);
        $atomid = $this->idprefix . 'file/' . $id;
        return <<<XML
<?xml version="1.0" encoding="utf-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="{$lang}">
 <title>{$title}</title>
 <updated>{$date}</updated>
 <id>{$atomid}</id>
 <link rel="self" type="application/atom+xml" href="{$selflink}" />
 <link rel="alternate" type="text/html" href="{$htmllink}" />
 <generator uri="https://doc.php.net/phd/">PhD</generator>
 <author>
  <name>{$author}</name>
 </author>


XML;
    }
Beispiel #3
0
    protected function headerChm()
    {
        $lang = Config::language();
        fwrite($this->hhpStream, '[OPTIONS]
Binary TOC=Yes
Compatibility=1.1 or later
Compiled file=pear_manual_' . $lang . '.chm
Contents file=pear_manual_' . $lang . '.hhc
Default Font=' . ($this->LANGUAGES[$lang]["preferred_font"] ? $this->LANGUAGES[$lang]["preferred_font"] : self::DEFAULT_FONT) . '
Default topic=res\\index.html
Default Window=doc
Display compile progress=Yes
Enhanced decompilation=Yes
Full-text search=Yes
Index file=pear_manual_' . $lang . '.hhk
Language=' . $this->LANGUAGES[$lang]["langcode"] . '
Title=' . (isset($this->LANGUAGES[$lang]["title"]) ? $this->LANGUAGES[$lang]["title"] : self::DEFAULT_TITLE) . '

[WINDOWS]
doc="' . (isset($this->LANGUAGES[$lang]["title"]) ? $this->LANGUAGES[$lang]["title"] : self::DEFAULT_TITLE) . '","pear_manual_' . $lang . '.hhc","pear_manual_' . $lang . '.hhk","res\\index.html","res\\index.html",,,,,0x33520,,0x70386e,,,,,,,,0

[FILES]
res\\reset-fonts.css
res\\style.css
res\\manual.css
');
        fwrite($this->hhcStream, '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
  <head>
    <meta name="generator" content="PhD">
    <!-- Sitemap 1.0 -->
  </head>
  <body>
    <object type="text/site properties">
      <param name="Window Styles" value="0x800227">
    </object>
    <ul>
');
        fwrite($this->hhkStream, '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
  <head>
    <meta name="generator" content="PhD">
    <!-- Sitemap 1.0 -->
  </head>
  <body>
    <object type="text/site properties">
      <param name="Window Styles" value="0x800227">
    </object>
    <ul>
');
    }
Beispiel #4
0
    public function header($id)
    {
        static $written_toc = array();
        $ext = $this->getExt();
        $parent = Format::getParent($id);
        $filename = "toc" . DIRECTORY_SEPARATOR . $parent . ".inc";
        $up = array(0 => null, 1 => null);
        $incl = '';
        $next = $prev = array(null, null);
        if ($parent && $parent != "ROOT") {
            $siblings = Format::getChildren($parent);
            if (!isset($written_toc[$filename])) {
                $written_toc[$filename] = true;
                $toc = $toc_deprecated = array();
                foreach ($siblings as $sid) {
                    $sibling_short_desc = Format::getShortDescription($sid);
                    $entry = array(Format::getFilename($sid) . $ext, $sibling_short_desc);
                    if (isset($this->deprecated[$sibling_short_desc])) {
                        $toc_deprecated[] = $entry;
                    } else {
                        $toc[] = $entry;
                    }
                }
                $parents = array();
                $p = $parent;
                while (($p = Format::getParent($p)) && $p != "ROOT") {
                    $parents[] = array(Format::getFilename($p) . $ext, Format::getShortDescription($p));
                }
                $content = '<?php
$TOC = ' . var_export($toc, true) . ';
$TOC_DEPRECATED = ' . var_export($toc_deprecated, true) . ';
$PARENTS = ' . var_export($parents, true) . ';';
                file_put_contents($this->getOutputDir() . $filename, $content);
                v("Wrote TOC (%s)", $this->getOutputDir() . $filename, VERBOSE_TOC_WRITING);
            }
            $incl = 'include_once dirname(__FILE__) ."/toc/' . $parent . '.inc";';
            $up = array(Format::getFilename($parent) . $ext, Format::getShortDescription($parent));
            if ($prevId = Format::getPrevious($id)) {
                $prev = array(Format::getFilename($prevId) . $ext, Format::getShortDescription($prevId));
            }
            if ($nextId = Format::getNext($id)) {
                $next = array(Format::getFilename($nextId) . $ext, Format::getShortDescription($nextId));
            }
        }
        $setup = array("home" => array('index' . $ext, $this->getTitle()), "head" => array("UTF-8", $this->lang), "this" => array($id . $ext, Format::getShortDescription($id)), "up" => $up, "prev" => $prev, "next" => $next, "alternatives" => $this->cchunk["alternatives"]);
        if ($this->getChildren($id)) {
            $lang = Config::language();
            $setup["extra_header_links"] = array("rel" => "alternate", "href" => "/manual/{$lang}/feeds/{$id}.atom", "type" => "application/atom+xml");
        }
        $var = var_export($setup, true);
        return '<?php
include_once $_SERVER[\'DOCUMENT_ROOT\'] . \'/include/shared-manual.inc\';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
' . $incl . '
$setup = ' . $var . ';
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
';
    }
    public function header($id)
    {
        $title = $this->getLongDescription($id);
        $lang = Config::language();
        $root = Format::getRootIndex();
        static $cssLinks = null;
        if ($cssLinks === null) {
            $cssLinks = $this->createCSSLinks();
        }
        $prev = $next = $parent = array("href" => null, "desc" => null);
        if ($parentId = $this->getParent($id)) {
            $parent = array("href" => $this->getFilename($parentId) . $this->getExt(), "desc" => $this->getShortDescription($parentId));
        }
        if ($prevId = Format::getPrevious($id)) {
            $prev = array("href" => Format::getFilename($prevId) . $this->getExt(), "desc" => $this->getShortDescription($prevId));
        }
        if ($nextId = Format::getNext($id)) {
            $next = array("href" => Format::getFilename($nextId) . $this->getExt(), "desc" => $this->getShortDescription($nextId));
        }
        $navBar = $this->createNavBar($id);
        return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $lang . '" lang="' . $lang . '">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>' . ($title != $root["ldesc"] ? $root["ldesc"] . ': ' : "") . $title . '</title>
' . $cssLinks . '
</head>
<body>
<table width="100%">
    <tr valign="top">
        <td style="font-size: smaller;" width="15%">
' . $navBar . '
        </td>
        <td width="85%">
            <div style="text-align: center;">
                ' . ($prevId ? '<div class="prev" style="text-align: left; float: left;"><a href="' . $prev["href"] . '">' . $prev["desc"] . '</a></div>' : '') . '
                ' . ($nextId ? '<div class="next" style="text-align: right; float: right;"><a href="' . $next["href"] . '">' . $next["desc"] . '</a></div>' : '') . '
                ' . ($parentId ? '<div class="up"><a href="' . $parent["href"] . '">' . $parent["desc"] . '</a></div>' : '') . '
                <div class="home"><a href="' . $root["filename"] . $this->getExt() . '">' . $root["ldesc"] . '</a></div>
            </div><hr/>
';
    }
Beispiel #6
0
 public static final function autogen($text, $lang = null)
 {
     if ($lang == NULL) {
         $lang = Config::language();
     }
     if (isset(self::$autogen[$lang])) {
         if (isset(self::$autogen[$lang][$text])) {
             return self::$autogen[$lang][$text];
         }
         if ($lang == Config::fallback_language()) {
             throw new \InvalidArgumentException("Cannot autogenerate text for '{$text}'");
         }
         return self::autogen($text, Config::fallback_language());
     }
     $filename = Config::lang_dir() . $lang . ".ini";
     self::$autogen[$lang] = parse_ini_file($filename);
     return self::autogen($text, $lang);
 }
Beispiel #7
0
 protected function initInfo()
 {
     $root = parent::getRootIndex();
     $lang = Config::language();
     return array('book_id' => 'php-manual', 'title' => $root['ldesc'], 'identifier' => 'http://www.php.net/manual/' . $lang, 'creator' => 'PHP Documentation Team', 'lang' => $lang, 'opf_file' => strtolower($this->getFormatName()) . '.opf', 'ncx_file' => strtolower($this->getFormatName()) . '.ncx', 'epub_file' => 'php-manual.epub');
 }
Beispiel #8
0
 public static final function autogen($text, $lang)
 {
     if ($lang == NULL) {
         $lang = Config::language();
     }
     if (isset(self::$autogen[$lang])) {
         if (isset(self::$autogen[$lang][$text])) {
             return self::$autogen[$lang][$text];
         }
         if ($lang == Config::fallback_language()) {
             throw new \InvalidArgumentException("Cannot autogenerate text for '{$text}'");
         }
         return self::autogen($text, Config::fallback_language());
     }
     $filename = Config::lang_dir() . $lang . ".xml";
     $r = new \XMLReader();
     if (!file_exists($filename) || !$r->open($filename)) {
         if ($lang == Config::fallback_language()) {
             throw new \Exception("Cannot open {$filename}");
         }
         return self::autogen($text, Config::fallback_language());
     }
     $autogen = array();
     while ($r->read()) {
         if ($r->nodeType != \XMLReader::ELEMENT) {
             continue;
         }
         if ($r->name == "term") {
             $r->read();
             $k = $r->value;
             $autogen[$k] = "";
         } else {
             if ($r->name == "simpara") {
                 $r->read();
                 $autogen[$k] = $r->value;
             }
         }
     }
     self::$autogen[$lang] = $autogen;
     return self::autogen($text, $lang);
 }
Beispiel #9
0
 public function format_varlistentry($open, $name, $attrs)
 {
     if ($open) {
         $this->collectContent($attrs);
         $charset = $this->LANGUAGES[Config::language()]["preferred_charset"];
         $content = htmlspecialchars(iconv('UTF-8', $charset, $this->lastContent["name"]), ENT_QUOTES);
         if ($content) {
             fwrite($this->hhkStream, "      <LI><OBJECT type=\"text/sitemap\">\n" . "        <param name=\"Local\" value=\"{$this->lastContent["reference"]}\">\n" . "        <param name=\"Name\" value=\"{$content}\">\n" . "      </OBJECT>\n");
         }
     }
     return parent::format_varlistentry($open, $name, $attrs);
 }
Beispiel #10
0
    /**
     * Generates the header HTML for the given ID.
     * Full doctype, html head, begin of body tag and top navigation.
     *
     * @param string $id Page ID
     *
     * @return string Header HTML
     */
    public function header($id)
    {
        $title = $this->getShortDescription($id);
        $lang = Config::language();
        static $cssLinks = null;
        if ($cssLinks === null) {
            $cssLinks = $this->createCSSLinks();
        }
        $this->prev = $this->next = $this->up = array("href" => null, "desc" => null);
        $strPrev = $strNext = '';
        if ($parentId = $this->getParent($id)) {
            $this->up = array("href" => $this->getFilename($parentId) . $this->ext, "desc" => $this->getShortDescription($parentId));
        }
        if ($prevId = Format::getPrevious($id)) {
            $this->prev = array("href" => Format::getFilename($prevId) . $this->ext, "desc" => $this->getShortDescription($prevId));
        }
        if ($nextId = Format::getNext($id)) {
            $this->next = array("href" => Format::getFilename($nextId) . $this->ext, "desc" => $this->getShortDescription($nextId));
        }
        $header = '<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
  <title>' . $title . '</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
  <meta name="generator" content="PhD" />
' . $cssLinks . '
  <link rel="start" href="index.html" title="' . $this->title . '" />
';
        if ($this->up["href"]) {
            $header .= '  <link rel="up" href="' . $this->up["href"] . '" title="' . $this->up["desc"] . '" />
';
        }
        if ($this->prev["href"]) {
            $strPrev = '<a href="' . $this->prev["href"] . '" title="' . $this->prev["desc"] . '">Prev</a>';
            $header .= '  <link rel="prev" href="' . $this->prev["href"] . '" title="' . $this->prev["desc"] . '" />
';
        }
        if ($this->next["href"]) {
            $strNext = '<a href="' . $this->next["href"] . '" title="' . $this->next["desc"] . '">Next</a>';
            $header .= '  <link rel="next" href="' . $this->next["href"] . '" title="' . $this->next["desc"] . '" />
';
        }
        $header .= ' </head>
 <body>
';
        $nav = <<<NAV
<div class="navheader">
 <table style="width: 100%;">
  <tr><th colspan="3" style="text-align: center">{$title}</th></tr>
  <tr>
   <td style="width: 40%; text-align: left;">{$strPrev}</td>
   <td style="width: 20%;"></td>
   <td style="width: 40%; text-align: right;">{$strNext}</td>
  </tr>
 </table>
 <hr/>
</div>

NAV;
        $header .= $nav . "<div id=\"body\">\n";
        return $header;
    }
Beispiel #11
0
            }
            $data2 = fread($fd, filesize($file));
            if ($data == $data2) {
                $GLOBALS['status_message'] = $GLOBALS[$GLOBALS['language']]["ok"];
                $GLOBALS['status'] = 1;
            }
            fclose($fd);
        }
    }
    function status()
    {
        return $GLOBALS['status'];
    }
    function status_message()
    {
        return $GLOBALS['status_message'];
    }
}
$config = new Config();
$config->language('slovenian');
$config->showClass(1);
$config->showOther(1);
$config->comment('test');
$config->set('display_offline_message', 1, '');
$config->set('offline', '1', 2);
$config->comment('testek');
$config->set('offline_message', 'hej', 'nej');
$config->set('offline_message2', 'hej', 'nej');
$data = $config->toString('Config', '//addclass', '//addnoclass');
$config->toFile('config.php', $data);
echo $config->status_message();