Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added Disqus as plugin

  • Loading branch information...
commit bb598563ca50d3ce2bbacf885dbd036b5db85160 1 parent 089392d
@marcoraddatz authored
View
83 Disqus/Disqus.controller.php
@@ -0,0 +1,83 @@
+<?php
+
+/**
+ * Insert Disqus instead of normal comments.
+ *
+ * @link http://github.com/marcoraddatz/candyCMS
+ * @author Marco Raddatz <http://marcoraddatz.com>
+ * @license MIT
+ * @since 3.0
+ *
+ */
+
+namespace candyCMS\Plugins;
+
+use candyCMS\Core\Helpers\Helper;
+use candyCMS\Core\Helpers\SmartySingleton;
+
+final class Disqus {
+
+ /**
+ * Identifier for Template Replacements
+ *
+ * @var constant
+ *
+ */
+ const IDENTIFIER = 'Disqus';
+
+ /**
+ * @var array
+ * @access protected
+ *
+ */
+ protected $_aRequest;
+
+ /**
+ * @var array
+ * @access protected
+ *
+ */
+ protected $_aSession;
+
+ /**
+ * Initialize the plugin and register all needed events.
+ *
+ * @access public
+ * @param array $aRequest alias for the combination of $_GET and $_POST
+ * @param array $aSession alias for $_SESSION
+ * @param object $oPlugins the PluginManager
+ *
+ */
+ public function __construct(&$aRequest, &$aSession, &$oPlugins) {
+ $this->_aRequest = & $aRequest;
+ $this->_aSession = & $aSession;
+
+ # Now register some events with the pluginmanager
+ $oPlugins->registerSimplePlugin($this);
+ }
+
+ /**
+ * Register HTML code to display.
+ *
+ * @final
+ * @access public
+ * @return string HTML content
+ *
+ */
+ public final function show() {
+ $sTemplateDir = Helper::getPluginTemplateDir(self::IDENTIFIER, 'show');
+ $sTemplateFile = Helper::getTemplateType($sTemplateDir, 'show');
+
+ $oSmarty = SmartySingleton::getInstance();
+ $oSmarty->setTemplateDir($sTemplateDir);
+ $oSmarty->setCaching(SmartySingleton::CACHING_LIFETIME_SAVED);
+
+ $sCacheId = WEBSITE_MODE . '|plugins|' . WEBSITE_LOCALE . '|' . self::IDENTIFIER;
+ if (!$oSmarty->isCached($sTemplateFile, $sCacheId)) {
+ $oSmarty->assign('WEBSITE_MODE', WEBSITE_MODE);
+ $oSmarty->assign('PLUGIN_DISQUS_SHORTNAME', PLUGIN_DISQUS_SHORTNAME);
+ }
+
+ return $oSmarty->fetch($sTemplateFile, $sCacheId);
+ }
+}
View
14 Disqus/views/show.tpl
@@ -0,0 +1,14 @@
+<div id='disqus_thread'></div>
+<script type="text/javascript">
+ /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
+ var disqus_shortname = '{$PLUGIN_DISQUS_SHORTNAME}'; // required: replace example with your forum shortname
+
+ /* * * DON'T EDIT BELOW THIS LINE * * */
+ (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>
+<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
+<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
View
11 LanguageChooser/LanguageChooser.controller.php
@@ -6,7 +6,7 @@
* @link http://github.com/marcoraddatz/candyCMS
* @author Hauke Schade <http://hauke-schade.de>
* @license MIT
- * @since 2.2
+ * @since 3.0
*
*/
@@ -78,15 +78,16 @@ public function __construct(&$aRequest, &$aSession, &$oPlugins) {
$aLangs = array();
$sLanguagesPath = PATH_STANDARD . '/app/languages/';
$oDir = opendir($sLanguagesPath);
+
while ($sFile = readdir($oDir)) {
if (substr($sFile, -4) != '.yml')
continue;
$sLang = substr($sFile, 0, -4);
$aLangs[] = array(
- 'lang' => $sLang,
- 'selected' => WEBSITE_LANGUAGE == substr($sLang, 0, 2),
- 'title' => I18n::get('languagechooser.' . $sLang));
+ 'lang' => $sLang,
+ 'selected' => WEBSITE_LANGUAGE == substr($sLang, 0, 2),
+ 'title' => I18n::get('languagechooser.' . $sLang));
}
closedir($sLanguagesPath);
$oSmarty->assign('languages', $aLangs);
@@ -94,4 +95,4 @@ public function __construct(&$aRequest, &$aSession, &$oPlugins) {
return $oSmarty->fetch($sTemplateFile, $sCacheId);
}
-}
+}
View
24 Markdown/Markdown.controller.php
@@ -53,9 +53,7 @@ public function __construct(&$aRequest, &$aSession, &$oPlugins) {
$this->_aRequest = & $aRequest;
$this->_aSession = & $aSession;
- # now register some events with the pluginmanager
- #$oPlugins->registerSimplePlugin($this);
- #$oPlugins->registerContentDisplayPlugin($this);
+ # Register some events to the plugin manager
$oPlugins->registerEditorPlugin($this);
}
@@ -70,7 +68,7 @@ public function __construct(&$aRequest, &$aSession, &$oPlugins) {
* @todo caching?
*
*/
- public final function prepareContent(&$sStr) {
+ public static final function prepareContent(&$sStr) {
$oMarkdown = new \dflydev\markdown\MarkdownParser();
return $oMarkdown->transformMarkdown($sStr);
}
@@ -79,26 +77,28 @@ public function __construct(&$aRequest, &$aSession, &$oPlugins) {
* Show nothing, since this plugin does not need to output additional javascript.
*
* @final
+ * @static
* @access public
* @return string HTML
* @todo add markdowneditor: https://github.com/samwillis/pagedown-bootstrap ??
*
*/
- public final function show() {
+ public static final function show() {
return '';
}
/**
- * Generate an Info Array ('url' => '', 'iconurl' => '', 'description' => '')
+ * Generate an info array ('url' => '', 'iconurl' => '', 'description' => '')
*
* @final
+ * @static
* @access public
- * @return array|boolean infor array or false
+ * @return array
*
*/
- public final function getInfo() {
- return array('url' => 'http://daringfireball.net/projects/markdown/syntax',
- 'description' => 'Markdown',
- 'iconurl' => '/vendor/candyCMS/plugins/Markdown/assets/icon39x24.png');
+ public static final function getInfo() {
+ return array( 'url' => 'http://daringfireball.net/projects/markdown/syntax',
+ 'description' => 'Markdown',
+ 'iconurl' => '/vendor/candyCMS/plugins/Markdown/assets/icon39x24.png');
}
-}
+}
View
9 Recaptcha/Recaptcha.controller.php
@@ -145,6 +145,7 @@ public function __construct(&$aRequest, &$aSession, &$oPlugins) {
* @access public
* @param array $aError
* @return
+ * @todo doc; test: captcha might be broken before
*
*/
public final function check(&$aError) {
@@ -156,12 +157,14 @@ public function __construct(&$aRequest, &$aSession, &$oPlugins) {
$this->_aRequest['recaptcha_challenge_field'],
$this->_aRequest['recaptcha_response_field']);
- if (!$this->_oRecaptchaResponse->is_valid)
+ if (!$this->_oRecaptchaResponse->is_valid) {
$this->_sErrorMessage = I18n::get('error.captcha.incorrect');
+ return false;
+ }
}
else
$this->_sErrorMessage = I18n::get('error.captcha.loading');
- $aError['captcha'] = $this->_sErrorMessage;
+ return $this->_sErrorMessage;
}
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.