Beispiel #1
0
 public function markup(Markup $model, $arg, $bool)
 {
     $tags = $model->parseTags();
     $item = [];
     if (array_key_exists('name', $tags)) {
         $item['name'] = $tags['name'];
         $item['static'] = Config::getInstance()->app_root . $model->config['static'] . '/' . preg_replace('/\\.[^.\\s]{2,4}$/', '', basename($model->config['path']));
     }
     return $item;
 }
Beispiel #2
0
 public function markup(Markup $model, $arg)
 {
     $body = '<div class="preview"><div class="text">' . $model->parse($arg) . '</div></div>';
     $body = '<div class="row content-item"><div class="col-md-12">' . $body . '</div></div>';
     if (array_key_exists('static', $model->config) && $model->config['static']) {
         $href = Config::getInstance()->app_root . $model->config['static'] . '/' . preg_replace('/\\.[^.\\s]{2,4}$/', '', basename($model->config['path']));
         // social
         $social = '';
         $general = Config::getInstance()->getGeneralArray('general');
         // TODO description
         if (array_key_exists('social', $general) && $general['social']) {
             $buttons = Social::getInstance()->socialButtons('https://' . $_SERVER['HTTP_HOST'] . $href, Head::getInstance()->getTitle());
             $span = floor(6 / count($buttons));
             foreach ($buttons as $b) {
                 $social .= '<div class="col-xs-2 col-md-' . $span . ' text-center">' . $b . '</div>';
             }
         }
         $static = '<a class="btn" href="' . $href . '">More <i class="fa fa-angle-double-right"></i></a>';
         $body .= '<div class="row socials"><div class="col-md-5"><div class="row">' . $social . '</div></div><div class="col-md-7 text-right">' . $static . '</div></div>';
     }
     return self::head($model->parseTags($model->config['path'])) . $body;
 }
Beispiel #3
0
 public function markup(Markup $model, $arg, $bool)
 {
     $tags = $model->parseTags();
     foreach ($arg as $key => $value) {
         if (isset($tags[$key])) {
             if (is_array($tags[$key])) {
                 if (in_array($value, $tags[$key])) {
                     continue;
                     // check next criteria
                 }
             } else {
                 if ($tags[$key] == $value) {
                     continue;
                     // check next criteria
                 }
             }
         }
         return false;
         // at least one criteria does not match
     }
     return true;
 }
 /**
  * {@inheritdoc}
  */
 public function createPlaceholder(array $element)
 {
     $placeholder_render_array = array_intersect_key($element, ['#lazy_builder' => TRUE, '#cache' => TRUE]);
     // Generate placeholder markup. Note that the only requirement is that this
     // is unique markup that isn't easily guessable. The #lazy_builder callback
     // and its arguments are put in the placeholder markup solely to simplify<<<
     // debugging.
     $callback = $placeholder_render_array['#lazy_builder'][0];
     $arguments = UrlHelper::buildQuery($placeholder_render_array['#lazy_builder'][1]);
     $token = hash('crc32b', serialize($placeholder_render_array));
     $placeholder_markup = '<drupal-render-placeholder callback="' . Html::escape($callback) . '" arguments="' . Html::escape($arguments) . '" token="' . Html::escape($token) . '"></drupal-render-placeholder>';
     // Build the placeholder element to return.
     $placeholder_element = [];
     $placeholder_element['#markup'] = Markup::create($placeholder_markup);
     $placeholder_element['#attached']['placeholders'][$placeholder_markup] = $placeholder_render_array;
     return $placeholder_element;
 }
 public function markup(Markup $model, $arg, $bool)
 {
     // parse head
     $head = '';
     $tags = $model->parseTags();
     if (!empty($tags)) {
         $left = '';
         if (isset($tags['published'])) {
             $left .= $tags['published'];
         }
         if (isset($tags['author'])) {
             $left = $left ? $left . ' | ' . $tags['author'] : $tags['author'];
         }
         $left = $left ? '<div class="col-md-7"><p>' . $left . '</p></div>' : '';
         $right = '';
         if (isset($tags['category'])) {
             $href = Config::getInstance()->app_root . URLs::getInstance()->getURI() . '?' . QueryString::removeAll(['tag', 'page'], $_SERVER['QUERY_STRING']);
             foreach ($tags['category'] as $c) {
                 $right .= ' | <a href="' . $href . '&tag=' . $c . '">#' . trim($c) . '</a>';
                 // $right .= ' | #' . trim($c);
             }
             $right = '<div class="col-md-5 pull-right text-right">' . substr($right, 3) . '</div>';
         }
         $head = $left . $right ? '<div class="row content-head">' . $left . $right . '</div>' : '';
     }
     // parse body
     $body = '<div class="row content-body"><div class="col-md-12">' . $model->parse($arg) . '</div></div>';
     if (array_key_exists('static', $model->config) && $model->config['static']) {
         $href = Config::getInstance()->app_root . URLs::getInstance()->getURI() . '/' . preg_replace('/\\.[^.\\s]{2,4}$/', '', basename($model->config['path']));
         // social
         $social = '';
         $general = Config::getInstance()->getGeneralArray('general');
         // TODO description
         if (array_key_exists('social', $general) && $general['social']) {
             $buttons = Social::getInstance()->socialButtons('https://' . $_SERVER['HTTP_HOST'] . $href, Head::getInstance()->getTitle());
             $span = floor(6 / count($buttons));
             foreach ($buttons as $b) {
                 $social .= '<div class="col-xs-2 col-md-' . $span . ' text-center">' . $b . '</div>';
             }
         }
         $static = '<a class="btn btn-default" href="' . $href . '" role="button">Static <i class="fa fa-share-alt"></i></a>';
         $body .= '<div class="row content-foot"><div class="col-md-5"><div class="row">' . $social . '</div></div><div class="col-md-7 text-right">' . $static . '</div></div>';
     }
     return '<div class="row content-item"><div class="col-md-12">' . $head . $body . '</div></div>';
 }
Beispiel #6
0
<link rel="alternate" type="application/rss+xml" title="Recent changes (RSS 2.0)" href="<?php 
echo Config::PATH;
?>
/:rss20" />
<? endif; ?>
</head>
<body>
<div id="page">
<div id="linkpane">
    <? if ($user): ?>
    <div id="userinfo">
        <span id="uid"><?php 
echo Markup::escape($user->name);
?>
        &lt;<?php 
echo Markup::escape($user->email);
?>
&gt;</span>
        <a href="<?php 
echo Config::PATH;
?>
/:profile">change password/email</a>
        <a href="<?php 
echo Config::PATH;
?>
/:logout">logout</a>
    </div>
    <? endif; ?>
    <? if (!Config::REQUIRE_LOGIN || $user): ?>
    <div id="globallinks">
        <a href="<?php 
Beispiel #7
0
 public function format()
 {
     return str_replace("\n", "<br />\n", $this->object->data);
     return Markup::format($this->object->data);
 }
Beispiel #8
0
<div class="par">
    Summary of changes:
    <input type="text" name="summary" class="text" value="<?php 
echo htmlspecialchars($summary, 0, 'UTF-8');
?>
" />
    <div class="submit">
        <input type="submit" class="submit" id="edit-preview" name="preview" value="Preview" />
        <input type="submit" class="submit" value="Save changes" />
    </div>
</div>
</form>
<? else: ?>
<div class="par view-source">
    <? if (!$page_type): ?>
    This page does not exist.
    <? elseif ($page_type == WikiPage::TYPE_PAGE): ?>
    Page source:
    <div>
        <textarea rows="30" cols="80" readonly="readonly"><?php 
echo Markup::escape($content);
?>
</textarea>
    </div>
    <? else: ?>
    Sorry, no page source available.
    <? endif; ?>
</div>
<? endif; ?>
<? include('footer.php'); ?>
 /**
  * {@inheritdoc}
  */
 public function getCacheableRenderArray(array $elements)
 {
     $data = ['#markup' => $elements['#markup'], '#attached' => $elements['#attached'], '#cache' => ['contexts' => $elements['#cache']['contexts'], 'tags' => $elements['#cache']['tags'], 'max-age' => $elements['#cache']['max-age']]];
     // Preserve cacheable items if specified. If we are preserving any cacheable
     // children of the element, we assume we are only interested in their
     // individual markup and not the parent's one, thus we empty it to minimize
     // the cache entry size.
     if (!empty($elements['#cache_properties']) && is_array($elements['#cache_properties'])) {
         $data['#cache_properties'] = $elements['#cache_properties'];
         // Extract all the cacheable items from the element using cache
         // properties.
         $cacheable_items = array_intersect_key($elements, array_flip($elements['#cache_properties']));
         $cacheable_children = Element::children($cacheable_items);
         if ($cacheable_children) {
             $data['#markup'] = '';
             // Cache only cacheable children's markup.
             foreach ($cacheable_children as $key) {
                 // We can assume that #markup is safe at this point.
                 $cacheable_items[$key] = ['#markup' => Markup::create($cacheable_items[$key]['#markup'])];
             }
         }
         $data += $cacheable_items;
     }
     $data['#markup'] = Markup::create($data['#markup']);
     return $data;
 }
Beispiel #10
0
    </script>
</div>

<div class="par">
    Summary of changes:
    <input type="text" name="summary" class="text" value="<?= htmlspecialchars($summary, 0, 'UTF-8') ?>" />
    <div class="submit">
        <input type="submit" class="submit" id="edit-preview" name="preview" value="Preview" />
        <input type="submit" class="submit" value="Save changes" />
    </div>
</div>
</form>
<? else: ?>
<div class="par view-source">
    <? if (!$page_type): ?>
    This page does not exist.
    <? elseif ($page_type == WikiPage::TYPE_PAGE): ?>
    Page source:
    <div>
        <textarea rows="30" cols="80" readonly="readonly"><?= Markup::escape($content) ?></textarea>
    </div>



    <? else: ?>
    Sorry, no page source available.
    <? endif; ?>
</div>
<? endif; ?>
<? include('footer.php'); ?>
Beispiel #11
0
<?php

$title = 'Login';
include 'header.php';
?>
<h1 id="pagetitle"><?php 
echo Markup::escape($title);
?>
</h1>
<?php 
if ($wrong) {
    ?>
<div class="error">
Sorry, wrong username or password.
</div>
<?php 
}
?>
<form accept-charset="UTF-8" method="post" action="<?php 
echo Config::PATH;
?>
/:login<?php 
echo htmlspecialchars($goto, 0, 'UTF-8');
?>
">
<p>
    Username:
    <input type="text" name="user" class="text" />
</p>
<p>
    Password:
Beispiel #12
0
 function writeCompile()
 {
     $file = $this->getPath();
     $node = new Markup();
     $node->setTemplix($this);
     $node->parse(file_get_contents($file));
     $node->triggerLoaded();
     ksort($this->compile);
     foreach ($this->compile as $callback) {
         call_user_func($callback, $node);
     }
     $this->removeTmp($node);
     $this->childNodes[] = $node;
     $this->compilePHP($this->dirCompile . $this->dirCompileSuffix . $file, (string) $node);
 }
Beispiel #13
0
    echo 'http://' . $_SERVER['SERVER_NAME'] . Config::PATH . '/:recent/' . $maxentries . '#commit-' . $commit->commit_id;
    ?>
</link>
            <?php 
    if ($commit->detail) {
        ?>
                <description><?php 
        echo Markup::escape($commit->detail);
        ?>
</description>
            <?php 
    }
    ?>
            <author><?php 
    echo Markup::escape($commit->email);
    ?>
 (<?php 
    echo Markup::escape($commit->author);
    ?>
)</author>
            <guid isPermaLink="false"><?php 
    echo $commit->commit_id;
    ?>
</guid>
        </item>
        <?php 
}
?>
  </channel>
</rss>
Beispiel #14
0
 public static function stylize($string)
 {
     return Markup::stylize($string);
 }
Beispiel #15
0
 protected function mklink($ref, $label = NULL)
 {
     list($url, $label2, $valid) = Markup::parseLinkTarget($ref);
     if ($label === NULL) {
         $label = $label2;
     }
     return $this->fmt_labeled_link($url, $label, !$valid);
 }
Beispiel #16
0
function edit_preview($content)
{
    $view = new View('page-edit-preview.php');
    $view->contents = Markup::format($content);
    return $view->display(TRUE);
}
Beispiel #17
0
?>
?action=image&amp;commit=<?php 
echo $commit_id;
?>
&amp;width=<?php 
echo Config::IMAGE_WIDTH;
?>
&amp;height=<?php 
echo Config::IMAGE_HEIGHT;
?>
" alt="<?php 
echo Markup::escape($page->getName());
?>
" />
    </a>
</p>
<p>
    <a href="<?php 
echo $page->getURL();
?>
?action=get&amp;commit=<?php 
echo $commit_id;
?>
">
        View full size: “<?php 
echo Markup::escape($page->getName());
?>
”
    </a>
</p>
Beispiel #18
0
<?php

require_once __DIR__ . '/markuplite.class.php';
require_once __DIR__ . '/../../src/luminous.php';
class Markup
{
    public $linker = null;
    private $obj = null;
    function linker($url)
    {
        return false;
    }
    public function __construct()
    {
        $this->linker = array($this, 'linker');
    }
    function format($str)
    {
        $m = new MarkupLite();
        $m->linkifier_cb = $this->linker;
        $m->highlight_cb = create_function('$code,$lang', 'return luminous::highlight($lang, $code);');
        return $m->Format($str);
    }
}
$m = new Markup();
$in = '';
while (($line = fgets(STDIN)) !== false) {
    $in .= $line;
}
echo $m->format($in);
Beispiel #19
0
 /**
  * Escapes #plain_text or filters #markup as required.
  *
  * Drupal uses Twig's auto-escape feature to improve security. This feature
  * automatically escapes any HTML that is not known to be safe. Due to this
  * the render system needs to ensure that all markup it generates is marked
  * safe so that Twig does not do any additional escaping.
  *
  * By default all #markup is filtered to protect against XSS using the admin
  * tag list. Render arrays can alter the list of tags allowed by the filter
  * using the #allowed_tags property. This value should be an array of tags
  * that Xss::filter() would accept. Render arrays can escape text instead
  * of XSS filtering by setting the #plain_text property instead of #markup. If
  * #plain_text is used #allowed_tags is ignored.
  *
  * @param array $elements
  *   A render array with #markup set.
  *
  * @return \Drupal\Component\Render\MarkupInterface|string
  *   The escaped markup wrapped in a Markup object. If
  *   SafeMarkup::isSafe($elements['#markup']) returns TRUE, it won't be
  *   escaped or filtered again.
  *
  * @see \Drupal\Component\Utility\Html::escape()
  * @see \Drupal\Component\Utility\Xss::filter()
  * @see \Drupal\Component\Utility\Xss::adminFilter()
  */
 protected function ensureMarkupIsSafe(array $elements)
 {
     if (empty($elements['#markup']) && empty($elements['#plain_text'])) {
         return $elements;
     }
     if (!empty($elements['#plain_text'])) {
         $elements['#markup'] = Markup::create(Html::escape($elements['#plain_text']));
     } elseif (!SafeMarkup::isSafe($elements['#markup'])) {
         // The default behaviour is to XSS filter using the admin tag list.
         $tags = isset($elements['#allowed_tags']) ? $elements['#allowed_tags'] : Xss::getAdminTagList();
         $elements['#markup'] = Markup::create(Xss::filter($elements['#markup'], $tags));
     }
     return $elements;
 }
Beispiel #20
0
    if ($fresh) {
        ?>
you just submitted
<?php 
    } else {
        ?>
that was submitted later on
<?php 
    }
    ?>
(right). Then you try to combine the changes: if you see a
new text passage on the left, you also add it on the right, and so on. As soon
as you are finished, click the “Save” button and <strong>the right version will become
the new
“<?php 
    echo Markup::escape($page_name);
    ?>
” page.</strong>
</p>
<p><em>
Please do NOT simply edit the page again, use this page instead.
</em></p>
<h2>This is too complicated / too much work / ...</h2>
<p>
If you do not want to perform the merge yourself—because you do not understand
what you should do here, because the page is rather long and it would be much
work, ...—you can simply leave this page and go on with what you wanted to do
next. An administrator will resolve the conflict later on.
</p>
<?php 
    if ($fresh) {
Beispiel #21
0
<?php

$title = $page->getName();
include 'header.php';
?>
<h1 id="pagetitle"><?php 
echo Markup::escape($page->getName());
?>
</h1>
<table class="history">
<?php 
foreach ($history as $entry) {
    printf('<tr><td><a href="%s?commit=%s">%s</a></td><td>%s</td><td>%s</td></tr>', $page->getURL(), $entry->commit, Markup::escape(strftime('%Y-%m-%d %H:%M', $entry->time)), Markup::escape($entry->author), Markup::escape($entry->summary));
}
?>
</table>
<?php 
include 'footer.php';
Beispiel #22
0
      no matches in file content
    <?php 
    } elseif ($result->page->getPageType() != WikiPage::TYPE_PAGE) {
        ?>
      match in binary data
    <?php 
    } else {
        ?>
      <?php 
        foreach ($result->matches as $match) {
            ?>
        <div class="match">
          <?php 
            $css_classes = array('before-match', 'match', 'after-match');
            for ($i = 0; $i < 3; $i++) {
                echo sprintf('<span class="%s">%s</span>', $css_classes[$i], Markup::escape($match->env[$i]));
            }
            ?>
        </div>
      <?php 
        }
        ?>
    <?php 
    }
    ?>
  </div>
<?php 
}
?>
</div>
<?php 
Beispiel #23
0
 public function format()
 {
     return Markup::format($this->object->data);
 }
Beispiel #24
0
<? endif; ?>
<? if (Config::ALLOW_EDIT): ?>
<link rel="alternate" type="application/x-wiki" title="Edit this page!" href="<?= $page->getUrl() ?>?action=edit" />
<? endif; ?>
<? endif; ?>
<? if (isset($recent_changes_feeds)): ?>
<link rel="alternate" type="application/rss+xml" title="Recent changes (RSS 2.0)" href="<?= Config::PATH ?>/:rss20" />
<? endif; ?>
</head>
<body>
<div id="page">
<div id="linkpane">
    <? if ($user): ?>
    <div id="userinfo">
        <span id="uid"><?= Markup::escape($user->name) ?>
        &lt;<?= Markup::escape($user->email) ?>&gt;</span>
        <a href="<?= Config::PATH ?>/:profile">change password/email</a>
        <a href="<?= Config::PATH ?>/:logout">logout</a>
    </div>
    <? endif; ?>
    <? if (!Config::REQUIRE_LOGIN || $user): ?>
    <div id="globallinks">
        <a href="<?= Config::PATH ?>/">home</a>
        <a href="<?= Config::PATH ?>/:recent">recent changes</a>
        <a href="<?= Config::PATH ?>/:conflicts">unmerged conflicts (<?= $n_conflicts ?>)</a>
    </div>
    <? if (isset($page)): ?>
        <div id="pagelinks">
        <? foreach (array('view' => 'view', 'edit' => (Config::ALLOW_EDIT ? 'edit' : 'source'), 'history' => 'history') as $i => $label): ?>
            <a
                href="<?= $page->getURL() ?><?= $i == 'view' ? '' : '?action='.$i ?>"
 /**
  * Renders placeholders (#attached['placeholders']).
  *
  * First, the HTML response object is converted to an equivalent render array,
  * with #markup being set to the response's content and #attached being set to
  * the response's attachments. Among these attachments, there may be
  * placeholders that need to be rendered (replaced).
  *
  * Next, RendererInterface::renderRoot() is called, which renders the
  * placeholders into their final markup.
  *
  * The markup that results from RendererInterface::renderRoot() is now the
  * original HTML response's content, but with the placeholders rendered. We
  * overwrite the existing content in the original HTML response object with
  * this markup. The markup that was rendered for the placeholders may also
  * have attachments (e.g. for CSS/JS assets) itself, and cacheability metadata
  * that indicates what that markup depends on. That metadata is also added to
  * the HTML response object.
  *
  * @param \Drupal\Core\Render\HtmlResponse $response
  *   The HTML response whose placeholders are being replaced.
  *
  * @return \Drupal\Core\Render\HtmlResponse
  *   The updated HTML response, with replaced placeholders.
  *
  * @see \Drupal\Core\Render\Renderer::replacePlaceholders()
  * @see \Drupal\Core\Render\Renderer::renderPlaceholder()
  */
 protected function renderPlaceholders(HtmlResponse $response)
 {
     $build = ['#markup' => Markup::create($response->getContent()), '#attached' => $response->getAttachments()];
     // RendererInterface::renderRoot() renders the $build render array and
     // updates it in place. We don't care about the return value (which is just
     // $build['#markup']), but about the resulting render array.
     // @todo Simplify this when https://www.drupal.org/node/2495001 lands.
     $this->renderer->renderRoot($build);
     // Update the Response object now that the placeholders have been rendered.
     $placeholders_bubbleable_metadata = BubbleableMetadata::createFromRenderArray($build);
     $response->setContent($build['#markup'])->addCacheableDependency($placeholders_bubbleable_metadata)->setAttachments($placeholders_bubbleable_metadata->getAttachments());
     return $response;
 }
Beispiel #26
0
        }
        ?>
            <?php 
        foreach ($commit->changes as $change) {
            ?>
                <tr class="change">
                    <td class="type"><?php 
            echo $change->type;
            ?>
</td>
                    <td class="subject">
                        <a href="<?php 
            echo Markup::escape($change->subject_url);
            ?>
"><?php 
            echo Markup::escape($change->subject);
            ?>
</a>
                    </td>
                </tr>
            <?php 
        }
        ?>
            </table>
        <?php 
    }
    ?>
        <div style="clear: both"></div>
    </div>
<?php 
}