Example #1
0
 static function init($context)
 {
     self::$data = gb::data('plugins/' . gb_filenoext(basename(__FILE__)), array('notify_new_comment' => true, 'notify_pending_comment' => true, 'notify_spam_comment' => false, 'recipient' => 'author'));
     gb::observe('did-add-comment', array(__CLASS__, 'did_add_comment'));
     gb::observe('did-spam-comment', array(__CLASS__, 'did_spam_comment'));
     return true;
 }
Example #2
0
 static function init($context)
 {
     if ($context !== 'rebuild') {
         return false;
     }
     self::$conf = gb::data('plugins/' . gb_filenoext(basename(__FILE__)), array('classname' => 'codeblock', 'tabsize' => 2, 'pygmentize' => 'pygmentize'));
     gb_cfilter::add('body.html', array(__CLASS__, 'filter'), 0);
     return true;
 }
Example #3
0
 static function init($context)
 {
     self::$conf = gb::data('plugins/' . gb_filenoext(basename(__FILE__)), array('url' => ''));
     if (!self::$conf['url']) {
         gb::log(LOG_WARNING, 'missing "url" in configuration');
         return false;
     }
     gb::observe('will-handle-request', array(__CLASS__, 'will_handle_req'));
     return true;
 }
Example #4
0
 static function init($context)
 {
     $default_conf = array('api_key' => '', 'delete_spam' => true);
     self::$conf = gb::data('plugins/' . gb_filenoext(basename(__FILE__)), $default_conf);
     if (!self::$key) {
         self::$key = self::$conf['api_key'];
     }
     if (!self::$key) {
         gb::log(LOG_WARNING, 'akismet not loaded since "api_key" is not set in %s', self::$conf->file);
         return false;
     }
     if ($context === 'admin') {
         gb_cfilter::add('pre-comment', array(__CLASS__, 'check_comment'));
         return true;
     }
     return false;
 }
Example #5
0
 $added = $cdb->append($comment, $input['reply-to'] ? $input['reply-to'] : null);
 # duplicate?
 if ($added === false) {
     gb::log('skipped duplicate comment from ' . var_export($comment->email, 1));
     gb::event('was-duplicate-comment', $comment);
     if ($referrer) {
         $referrer->fragment = 'comments';
         $referrer['comment-status'] = 'duplicate';
         header('HTTP/1.1 304 Not Modified');
         header('Location: ' . $referrer);
         exit(0);
     } else {
         exit2("duplicate comment\n", '200 OK');
     }
 }
 gb::log('added comment from %s to %s', var_export($comment->email, 1), gb_filenoext($post->cachename()));
 gb::event('did-add-comment', $comment);
 # done
 if ($referrer) {
     $referrer->fragment = 'comment-' . $comment->id;
     if (!$comment->approved) {
         $referrer->fragment = 'comments';
         $referrer['comment-status'] = 'pending';
     } else {
         unset($referrer['comment-status']);
     }
     header('HTTP/1.1 303 See Other');
     header('Location: ' . $referrer);
     exit(0);
 } else {
     exit2("new comment: {$comment->id}\n", '200 OK');
Example #6
0
 function render_menu($menu_disabled = false, $items = null, $baseurl = null, $currurlpath = null, $liststart = '<ul>', $listend = '</ul>')
 {
     if ($items === null) {
         $items = self::$menu;
     }
     if ($baseurl === null) {
         $baseurl = gb_admin::$url;
     }
     if ($currurlpath === null) {
         $currurlpath = gb::url()->path;
     }
     $accesskey_prefix = '';
     $is_osx = isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac OS X') !== false;
     if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false) {
         if ($is_osx) {
             $accesskey_prefix = '&#x2303;&#x2325;';
         }
     }
     $s = $liststart;
     foreach ($items as $k => $item) {
         $uri = $url = '';
         $is_curr = $is_todo = false;
         $accesskey = is_string($k) ? strtoupper($k) : '';
         if (isset($item[1]) && is_string($item[1])) {
             $uri = $item[1];
             $url = $uri && ($uri[0] === '/' || strpos($uri, '://') !== false) ? $uri : $baseurl . $uri;
             $url_st = GBURL::parse($url);
             $actual_currpath = $url_st->path;
             $is_todo = strpos($url_st->fragment, 'todo:') === 0;
             $is_curr = !$is_todo && $actual_currpath === substr($currurlpath, 0, strlen($actual_currpath));
             if ($uri === '') {
                 $is_curr = gb::url()->path === GBURL::parse(gb_admin::$url)->path;
             }
         }
         $dom_id = $uri ? gb_strtodomid(gb_filenoext($item[1])) : $k;
         $s .= '<li id="menu-item-' . $dom_id . '"';
         $css_class = '';
         if ($is_curr) {
             $css_class .= 'selected';
             self::$current_domid = $dom_id;
         }
         if ($is_todo) {
             $css_class .= ' todo';
         }
         if ($css_class) {
             $s .= ' class="' . $css_class . '"';
         }
         $s .= '><a';
         if ($url && !$is_todo && !$menu_disabled) {
             $s .= ' href="' . h($url) . '"';
         }
         if ($accesskey && !$menu_disabled) {
             $s .= ' accesskey="' . $accesskey . '"';
         }
         $s .= '><span class="title">' . h($item[0]) . '</span>';
         if ($accesskey && !$menu_disabled) {
             $s .= '<span class="accesskey-hint">' . $accesskey_prefix . $accesskey . '</span>';
         }
         $s .= '</a>';
         if (isset($item[2]) && $item[2]) {
             $s .= self::render_menu($menu_disabled, $item[2], $baseurl, $currurlpath, $liststart, $listend);
         }
         $s .= '</li>';
     }
     $s .= $listend;
     return $s;
 }
Example #7
0
 function onObject(GBComments $commentObject)
 {
     $i = 0;
     foreach ($commentObject->getIterator(false) as $c) {
         if ($c->approved === false) {
             $this->index[] = array($c, gb_filenoext($commentObject->name));
         }
     }
 }
Example #8
0
 function _bounceURL($relpath, $post = null, $include_referrer = true)
 {
     $post = $this->_post($post);
     if ($this->id === null) {
         throw new UnexpectedValueException('$this->id is null');
     }
     $object = strpos(gb::$content_cache_fnext, '.') !== false ? gb_filenoext($post->cachename()) : $post->cachename();
     return gb::$site_url . $relpath . 'object=' . urlencode($object) . '&comment=' . $this->id . ($include_referrer ? '&referrer=' . urlencode(gb::url()) : '');
 }