示例#1
0
    public function writeText(StreamInterface $stream)
    {
        $text = $this->text;
        foreach ($this->themeInfos as $themeInfo) {
            $stream->write(<<<HTML
                <h3>{$text->e($themeInfo->getDisplayName())}</h3>
                <p>
                    {$text->e($themeInfo->getDescription())}
                    {$text->tReplaced("themes.created_by", '<a href="' . $text->e($themeInfo->getAuthorWebsite()) . '">' . $text->e($themeInfo->getAuthor()) . '</a>')}.
                    <a href="{$text->e($themeInfo->getThemeWebsite())}" class="arrow">{$this->text->t("themes.view_more_information")}</a>
                </p>
                <p>
                    <form method="post" action="{$text->url("switch_theme")}">
                        <input type="hidden" name="theme" value="{$text->e($themeInfo->getDirectoryName())}" />
                        <input type="hidden" name="{$text->e(RequestToken::FIELD_NAME)}" value="{$text->e($this->requestToken->getTokenString())}" />
                        <input type="submit" class="button" value="{$text->t("themes.switch_to_this")}" />
                    </form>
                    </a>
                </p>
HTML
);
        }
        $stream->write(<<<HTML
            <p>
                <a class="arrow" href="{$text->url("admin")}">{$text->t("main.admin")}</a>         
            </p>
HTML
);
    }
 public function writeUnauthorized()
 {
     $this->response = $this->response->withStatus(401);
     $apiResponse = new ApiResponse();
     $apiResponse->setStatusFail();
     $apiResponse->setData("Unauthorized");
     $this->body->write($apiResponse->toJSON());
 }
示例#3
0
 public function writeText(StreamInterface $stream)
 {
     if ($this->newUser === null) {
         $stream->write($this->getErrorText());
     } else {
         $stream->write($this->getSuccessText());
     }
 }
示例#4
0
 public function writeText(StreamInterface $stream)
 {
     foreach ($this->comments as $comment) {
         $stream->write($this->getSingleComment($comment));
     }
     if (count($this->comments) == 0) {
         $stream->write("<p><em>" . $this->text->t("errors.nothing_found") . "</em></p>\n");
     }
 }
示例#5
0
文件: main.php 项目: rutgerkok/rCMS
 public function writeText(StreamInterface $stream, Website $website, $id, $data)
 {
     if (!isset($data["text"]) || !isset($data["title"])) {
         return;
     }
     if (strLen($data["title"]) > 0) {
         $stream->write("<h2>" . htmlSpecialChars($data["title"]) . "</h2>\n");
     }
     $stream->write($data["text"]);
 }
示例#6
0
 public function writeText(StreamInterface $stream)
 {
     if (empty($this->documents)) {
         $stream->write($this->getEmptyPage());
     } else {
         $stream->write($this->getDocumentIntros($this->documents));
     }
     if ($this->editLinks) {
         $stream->write($this->getCreateNewDocumentLink());
     }
 }
示例#7
0
 /**
  * Reads a file and write in the body.
  * 
  * @param string          $file
  * @param StreamInterface $body
  */
 private static function readFile($file, StreamInterface $body)
 {
     if (filesize($file) <= 4096) {
         $body->write(file_get_contents($file));
         return;
     }
     $stream = fopen($file, 'r');
     while (!feof($stream)) {
         $body->write(fread($stream, 4096));
     }
     fclose($stream);
 }
示例#8
0
    public function writeText(StreamInterface $stream)
    {
        $text = $this->text;
        $errorMessage = $this->errorMessage;
        $formUrl = $this->destination;
        $loginText = $text->t("users.please_log_in");
        if (!empty($errorMessage)) {
            $stream->write(<<<EOT
                <div class="error">
                    <p>{$errorMessage}</p>
                </div>
EOT
);
        }
        $stream->write(<<<EOT
            <div id="login">
                <form method="post" action="{$text->e($formUrl)}">
                    <h3>{$loginText}</h3>
                    <p>
                        <label for="user">{$text->t('users.username_or_email')}:</label> <br />
                        <input type="text" name="user" id="user" autofocus="autofocus" /> <br />
                        <label for="pass">{$text->t('users.password')}:</label> <br />
                        <input type="password" name="pass" id="pass" /> <br />

                        <input type="submit" value="{$text->t('main.log_in')}" class="button primary_button" />

EOT
);
        // Repost all POSTed variables (GET variables will be part of the URL above)
        foreach ($this->postVars as $key => $value) {
            if ($key != "user" && $key != "pass") {
                $stream->write('<input type="hidden" name="' . $text->e($key) . '" value="' . $text->e($value) . '" />');
            }
        }
        // End form and return it
        $stream->write(<<<EOT
                    </p>
                </form>
EOT
);
        if ($this->showCreateAccountLinks) {
            $stream->write(<<<HTML
                <p>
                    <a class="arrow" href="{$text->url("create_account")}">
                        {$text->t("main.create_account")}
                    </a>
                </p>
HTML
);
        }
        $stream->write("</div>");
    }
示例#9
0
 protected function writeCalendars(StreamInterface $stream)
 {
     $text = $this->text;
     for ($i = 1; $i <= 12; $i++) {
         $month = DateTime::createFromFormat("Y n j", $this->year->format("Y") . ' ' . $i . ' 1');
         $calendarTemplate = new CalendarTemplate($text, $month, $this->articlesInYear, $this->createLinks);
         $monthName = ucFirst($calendarTemplate->getMonthName($month));
         $yearNumber = $month->format("Y");
         $stream->write('<div class="calender_month_wrapper">');
         $stream->write("<h3>{$monthName} {$yearNumber}</h3>");
         $calendarTemplate->writeText($stream);
         $stream->write('</div>');
     }
 }
 /**
  * {@inheritdoc}
  */
 public function write($string)
 {
     if ($this->tell() < 0) {
         throw new RuntimeException('Invalid pointer position');
     }
     return $this->decoratedStream->write($string);
 }
示例#11
0
 public function send(StreamInterface $stream)
 {
     if (!$stream->isWritable()) {
         throw new \InvalidArgumentException('Output stream must be writable');
     }
     $stream->write($this->contents);
 }
示例#12
0
    public function writeText(StreamInterface $stream)
    {
        $text = $this->text;
        $editorHtml = $this->installedWidgets->getEditor($this->editWidget);
        $actionUrl = $text->getUrlPage("edit_widget", $this->editWidget->getId());
        $documentEditUrl = $text->getUrlPage("edit_document", $this->editWidget->getDocumentId());
        $tokenNameHtml = $text->e(RequestToken::FIELD_NAME);
        $tokenValueHtml = $text->e($this->requestToken->getTokenString());
        $stream->write(<<<EDITOR
            <p>{$this->text->t("main.fields_required")}</p>
            <form method="POST" action="{$text->e($actionUrl)}">
                {$editorHtml}

                <p>
                    <input type="hidden" name="{$tokenNameHtml}" value="{$tokenValueHtml}" />
                    <input type="hidden" name="document_id" value="{$this->editWidget->getDocumentId()}" />
                    <input type="hidden" name="directory_name" value="{$this->editWidget->getDirectoryName()}" />
                    <input class="button primary_button" 
                        type="submit" 
                        name="submit"
                        value="{$this->text->t("editor.save")}" />
                    <a class="button" href="{$text->e($documentEditUrl)}">
                        {$this->text->t("main.cancel")}
                    </a>
                </p>
            </form>
EDITOR
);
    }
示例#13
0
    public function writeText(StreamInterface $stream)
    {
        $text = $this->text;
        $stream->write(<<<HTML
            <p>
                {$text->t("main.fields_required")}
            </p>
            <form method="post" action="{$text->url("edit_category", $this->category->getId())}">
                <p>
                    <label for="category_name">{$text->t("categories.name")}:</label>
                    <span class="required">*</span>
                    <br />
                    <input type="text" id="category_name" name="category_name"
                        maxlength="{$text->e(CategoryRepository::NAME_MAX_LENGTH)}"
                        value="{$text->e($this->category->getName())}" />
                </p>
                <p>
                    <label for="category_description">{$text->t("categories.description")}:</label>
                    <br />
                    {$this->richEditor->getEditor("category_description", $this->category->getDescriptionHtml())}
                </p>
                <p>
                    <input type="hidden" name="{$text->e(RequestToken::FIELD_NAME)}"
                        value="{$text->e($this->requestToken->getTokenString())}" />
                    <input type="submit" class="button primary_button" value="{$text->t("editor.save")}" />
                    <a class="button" href="{$text->url("category_list")}">
                        {$text->t("main.cancel")}
                    </a>
                </p>
            </form>
HTML
);
    }
 /**
  * @return  void
  */
 protected function dumpSql()
 {
     $connection = $this->container->get('Repository')->getConnection();
     if (!$connection instanceof Connection) {
         return;
     }
     $logger = $connection->getConfiguration()->getSQLLogger();
     if (!$logger instanceof DebugStack) {
         return;
     }
     $queries = $logger->queries;
     $table = '<table class="debug"><tr><th>#</th><th>SQL</th><th>Time</th></tr>';
     foreach ($queries as $index => $query) {
         $sql = $query['sql'];
         $params = $query['params'];
         ksort($params);
         $sql = preg_replace_callback('~\\?~', function () use(&$params) {
             return array_shift($params);
         }, $sql);
         $sql = preg_replace('~(WHERE|LIMIT|INNER\\s+JOIN|LEFT\\s+JOIN)~', "\n  \\1", $sql);
         $sql = preg_replace('~(AND|OR)~', "\n    \\1", $sql);
         $time = sprintf('%.3f ms', 1000 * $query['executionMS']);
         $table .= "<tr><td>{$index}</td><td><pre>{$sql}</pre></td><td>{$time}</td></tr>";
     }
     $table .= '</table>';
     $this->output->write($table);
 }
示例#15
0
    public function writeText(StreamInterface $stream)
    {
        $text = $this->text;
        $menu = $this->menu;
        $token = $this->requestToken;
        $stream->write(<<<HTML
            <form method="post" action="{$text->e($text->getUrlPage("rename_menu", $menu->getId()))}">
                <p>
                    {$text->t("main.fields_required")}
                </p>
                <p>
                    <label for="menu_name">
                        {$text->t("links.menu.name")}: <span class="required">*</span>
                    </label> <br />
                    <input type="text" name="menu_name" id="menu_name" value="{$text->e($menu->getName())}" size="20"
                            maxlength="{$text->e(MenuRepository::NAME_MAX_LENGTH)}" />
                </p>
                <p>
                    <input type="hidden" name="{$text->e(RequestToken::FIELD_NAME)}" value="{$text->e($token->getTokenString())}" />
                    <input class="button primary_button" type="submit" value="{$text->t("editor.save")}" />
                    <a class="button" href="{$text->e($text->getUrlPage("edit_menu", $menu->getId()))}">
                        {$text->t("main.cancel")}
                    </a>
                </p>
            </form>
HTML
);
    }
示例#16
0
 public function send(StreamInterface $stream)
 {
     if (!$stream->isWritable()) {
         throw new \InvalidArgumentException('Output stream must be writable');
     }
     if (is_array($this->callback)) {
         $ref = (new \ReflectionClass(is_object($this->callback[0]) ? get_class($this->callback[0]) : $this->callback[0]))->getMethod($this->callback[1]);
     } elseif (is_object($this->callback) && !$this->callback instanceof \Closure) {
         $ref = new \ReflectionMethod(get_class($this->callback), '__invoke');
     } else {
         $ref = new \ReflectionFunction($this->callback);
     }
     if ($ref->isGenerator()) {
         foreach (call_user_func($this->callback) as $chunk) {
             $stream->write($chunk);
         }
         return;
     }
     foreach ($ref->getParameters() as $param) {
         if (NULL !== ($type = $param->getClass())) {
             if ($type->name === StreamInterface::class || $type->implementsInterface(StreamInterface::class)) {
                 call_user_func($this->callback, $stream);
                 return;
             }
         }
         break;
     }
     $stream->write((string) call_user_func($this->callback));
 }
示例#17
0
 public function writeText(StreamInterface $stream)
 {
     // Link to manage widgets
     $stream->write($this->getWidgetsEditLinks());
     // Output widgets
     foreach ($this->placedWidgets as $widget) {
         $this->widgetLoader->writeOutput($stream, $widget);
     }
 }
示例#18
0
 /**
  * Copy stream to another stream.
  *
  * @param   StreamInterface  $src   Source stream.
  * @param   StreamInterface  $dest  Target stream.
  *
  * @return  void
  */
 public static function copy(StreamInterface $src, StreamInterface $dest)
 {
     if ($src->isSeekable()) {
         $src->rewind();
     }
     while (!$src->eof()) {
         $dest->write($src->read(4096));
     }
 }
示例#19
0
 public function send(StreamInterface $stream)
 {
     if (!$stream->isWritable()) {
         throw new \InvalidArgumentException('Output stream must be writable');
     }
     while (!$this->stream->eof()) {
         $stream->write($this->stream->read(4096));
     }
 }
示例#20
0
文件: main.php 项目: rutgerkok/rCMS
 public function writeText(StreamInterface $stream, Website $website, $id, $data)
 {
     $title = htmlSpecialChars($data["title"]);
     $amount = (int) $data["amount"];
     $commentLookup = new CommentRepository($website->getDatabase());
     $latestComments = $commentLookup->getCommentsLatest($amount);
     $view = new CommentsSmallTemplate($website->getText(), $latestComments);
     $stream->write('<h2>' . $title . "</h2>\n");
     $view->writeText($stream);
 }
示例#21
0
 public function writeText(StreamInterface $stream)
 {
     switch ($this->state) {
         case self::STATE_CONFIRMATION:
             $stream->write($this->getConfirmationText());
             break;
         case self::STATE_ERROR:
             $stream->write($this->getErrorText());
             break;
         case self::STATE_HIDDEN:
             $stream->write($this->getMadeHiddenText());
             break;
         case self::STATE_DELETED:
             $stream->write($this->getDeletedText());
             break;
         default:
             throw new BadMethodCallException("Unknown display state " . $this->state);
     }
 }
示例#22
0
 public function writeText(StreamInterface $stream)
 {
     $text = $this->text;
     $resultcount = $this->totalNumberOfArticles;
     if (count($this->articles) > 0) {
         // Display result count
         if ($resultcount == 1) {
             $stream->write("<p>" . $text->t('articles.search.result_found') . "</p>");
         } else {
             $stream->write("<p>" . $text->tReplaced('articles.search.results_found', $resultcount) . "</p>");
         }
         // Display articles
         $stream->write($this->getMenuBar());
         parent::writeText($stream);
         $stream->write($this->getMenuBar());
     } else {
         $stream->write('<p><em>' . $text->t('articles.search.no_results_found') . '</em></p>');
     }
 }
示例#23
0
 public function testReadAndWrite()
 {
     $this->assertEquals(0, $this->stream->getSize());
     $this->stream->write("Hello World, And All Developers!");
     $this->assertEquals(32, $this->stream->getSize());
     // size
     $this->assertEquals(32, $this->stream->tell());
     // pointer
     $this->stream->rewind();
     $this->assertEquals(0, $this->stream->tell());
     $this->assertFalse($this->stream->eof());
     $this->assertEquals("Hell", $this->stream->read(4));
     $this->assertEquals("o World, ", $this->stream->read(9));
     $this->assertEquals("And All Developers!", $this->stream->getContents());
     $this->assertTrue($this->stream->eof());
     $this->stream->seek(12);
     $this->assertEquals(6, $this->stream->write('Hum...'));
     $this->assertEquals("ll Developers!", $this->stream->getContents());
     $this->assertEquals("Hello World,Hum...ll Developers!", $this->stream->__toString());
 }
示例#24
0
    public function writeText(StreamInterface $stream)
    {
        $text = $this->text;
        $stream->write(<<<HTML
            <p>{$text->t("install.no_tables_yet")}</p>
            <a href="{$text->e($text->getUrlPage("install", null, ["action" => "install_database"]))}" class="button primary_button">
                {$text->t("install.create_tables")}
            </a>
HTML
);
    }
示例#25
0
    public function writeText(StreamInterface $stream)
    {
        $text = $this->text;
        $stream->write("<p>{$text->t("widgets.delete.confirm")}</p>");
        $stream->write("<blockquote>");
        $this->installedWidgets->writeOutput($stream, $this->placedWidget);
        $stream->write("</blockquote>");
        $stream->write(<<<HTML
            <form method="post" action="{$text->url("delete_widget", $this->placedWidget->getId())}">
                <p>
                    <input type="hidden" name="{$text->e(RequestToken::FIELD_NAME)}"
                        value="{$text->e($this->requestToken->getTokenString())}" />
                    <input type="submit" value="{$text->t("main.delete")}" class="button dangerous_button" />
                    <a class="button" href="{$text->url("edit_document", $this->placedWidget->getDocumentId())}">
                        {$text->t("main.cancel")}
                    </a>
                </p>
            </form>
HTML
);
    }
示例#26
0
    public function writeText(StreamInterface $stream)
    {
        $text = $this->text;
        $stream->write(<<<EOT
            <h3>{$text->t('users.logged_out')}</h3>
            <p>{$text->t('users.succesfully_logged_out')}</p>
            <p>
                <a href="{$text->e($text->getUrlMain())}" class="arrow">{$text->t("main.home")}</a>
            </p>
EOT
);
    }
示例#27
0
    public function writeText(StreamInterface $stream)
    {
        $text = $this->text;
        $stream->write(<<<HTML
            <p>
                <a class="arrow" href="{$text->e($text->getUrlMain())}">{$text->t("main.home")}</a><br />
                <a href="{$text->e($text->getUrlPage("document_list"))}" class="arrow">{$text->t("documents.list.title")}</a><br />
                <a href="{$text->e($text->getUrlPage("admin"))}" class="arrow">{$text->t("main.admin")}</a>
            </p>
HTML
);
    }
    public function writeText(StreamInterface $stream)
    {
        $text = $this->text;
        $stream->write(<<<HTML
            <p>{$text->t("install.no_database_connection_explained")}</p>
            <p>
                <a class="button primary_button" href="{$text->e($text->getUrlPage("install"))}">
                    {$text->t("install.retry_connection")}
                </a>
            </p>
HTML
);
    }
示例#29
0
    public function writeText(StreamInterface $stream)
    {
        $text = $this->text;
        $stream->write(<<<HTML
            <p>{$text->t("install.thanks_for_updating")}</p>
            <p>         
                <a href="{$text->e($text->getUrlMain())}" class="arrow">
                {$text->t("main.home")}
                </a>
            </p>
HTML
);
    }
示例#30
0
    public function writeText(StreamInterface $stream)
    {
        $text = $this->text;
        $stream->write(<<<SEARCHFORM
            <p>
                <form action="{$text->e($text->getUrlPage("search"))}" method="GET">
                    <input name="searchbox" id="searchbox-big" value="{$text->e($this->keyword)}" />
                    <input type="submit" class="button primary_button" value="{$text->t("main.search")}" />
                </form>
            </p>
            <p>{$text->t("articles.search.explained")}</p>
SEARCHFORM
);
    }