Exemplo n.º 1
0
    /**
     * Returns in <help_book_page_comments> tag
     *
     * @param Element $element
     * @return string
     */
    function renderComments(Element $element)
    {
        list($disqus_account_id, $disqus_url_prefix, $disqus_identifier_prefix) = $this->getSettings();
        if ($disqus_account_id && $disqus_url_prefix) {
            if ($element instanceof BookPage) {
                $url = $disqus_url_prefix . '/books/' . $element->getBookName() . '/' . $element->getSlug() . '.html';
                $identifier = $disqus_identifier_prefix . '/books/' . $element->getBookName() . '/' . $element->getSlug();
            } elseif ($element instanceof WhatsNewArticle) {
                $url = $disqus_url_prefix . '/whats-new/' . $element->getShortName() . '.html';
                $identifier = $disqus_identifier_prefix . '/whats-new/' . $element->getShortName();
            } else {
                return '';
            }
            $title = var_export($element->getTitle(), true);
            return <<<EOS
<div id="disqus_thread"></div>
<script type="text/javascript">
  var disqus_shortname = "{$disqus_account_id}";
  var disqus_identifier = "{$identifier}";
  var disqus_title = {$title};
  var disqus_url = "{$url}";

  (function() {
    var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
    dsq.src = "//" + disqus_shortname + ".disqus.com/embed.js";
    (document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0]).appendChild(dsq);
  })();
</script>
EOS;
        } else {
            return '';
        }
    }
Exemplo n.º 2
0
 /**
  * Return book page URL
  *
  * @param string $book_name
  * @param string $page_slug
  * @return string
  */
 private static function getBookPageUrl($book_name, $page_slug)
 {
     return self::pageLevelToPrefix(self::$current_element->getPageLevel()) . 'books/' . $book_name . '/' . $page_slug . '.html';
 }
Exemplo n.º 3
0
 /**
  * Construct and load help element
  *
  * @param Project $project
  * @param string  $version_number
  * @param string  $path
  * @param bool    $load
  */
 public function __construct(Project $project, $version_number, $path, $load = true)
 {
     $this->version_number = $version_number;
     parent::__construct($project, $path, $load);
 }
Exemplo n.º 4
0
 /**
  * Construct and load help element
  *
  * @param string $module
  * @param string $version_number
  * @param string $path
  * @param bool   $load
  */
 public function __construct($module, $version_number, $path, $load = true)
 {
     $this->version_number = $version_number;
     parent::__construct($module, $path, $load);
 }
Exemplo n.º 5
0
 /**
  * Method that is used for collecting to-do items
  *
  * @param string $message
  * @param Project|Element $element
  */
 public static function recordTodo($message, $element)
 {
     if ($element instanceof Element) {
         $path = $element->getPath();
     } elseif ($element instanceof Project) {
         $path = $element->getPath();
     } else {
         $path = '-UNKNOWN-';
     }
     self::$todo[] = ['message' => $message, 'file' => $path];
 }
Exemplo n.º 6
0
 /**
  * Construct and load help element
  *
  * @param string      $module
  * @param Book|string $book
  * @param string      $path
  * @param bool        $load
  */
 public function __construct($module, $book, $path, $load = true)
 {
     $this->book_name = $book instanceof Book ? $book->getShortName() : $book;
     parent::__construct($module, $path, $load);
 }