/**
  * Load (if necessary) and return the view.
  */
 public function getView()
 {
     if (!isset($this->view)) {
         $this->view = RPBChessboardHelperLoader::loadView($this->getModel());
     }
     return $this->view;
 }
 public static function register()
 {
     // Compatibility information -> describe which shortcode should be used to insert FEN diagrams,
     // which one to insert PGN games, etc...
     $compatibility = RPBChessboardHelperLoader::loadTrait('Compatibility');
     $fenShortcode = $compatibility->getFENShortcode();
     $pgnShortcode = $compatibility->getPGNShortcode();
     self::$noTexturizeShortcodes = array($fenShortcode, $pgnShortcode);
     self::$lowLevelShortcodes = array($pgnShortcode);
     // Register the shortcodes
     add_shortcode($fenShortcode, array(__CLASS__, 'callbackShortcodeFEN'));
     add_shortcode($pgnShortcode, array(__CLASS__, 'callbackShortcodePGN'));
     add_shortcode('pgndiagram', array(__CLASS__, 'callbackShortcodePGNDiagram'));
     // Register the no-texturize shortcodes
     add_filter('no_texturize_shortcodes', array(__CLASS__, 'registerNoTexturizeShortcodes'));
     // A high-priority filter is required to prevent the WP engine to perform some nasty operations
     // (e.g. wptexturize, wpautop, etc...) on the text enclosed by the shortcodes.
     //
     // The priority level 8 what is used by the WP engine to process the special [embed] shortcode.
     // As the same type of low-level operation is performed here, using this priority level seems to be a good choice.
     // However, having "official" guidelines or core methods to achieve this would be desirable.
     //
     add_filter('the_content', array(__CLASS__, 'preprocessLowLevelShortcodes'), 8);
     add_filter('comment_text', array(__CLASS__, 'preprocessLowLevelShortcodes'), 8);
 }
 public static function callbackInlinedStyleSheets()
 {
     $model = RPBChessboardHelperLoader::loadTrait('SmallScreens');
     if ($model->getSmallScreenCompatibility()) {
         include RPBCHESSBOARD_ABSPATH . 'templates/smallscreens.php';
     }
 }
Example #4
0
 /**
  * Process a shortcode.
  *
  * @param string $shortcodeName
  * @param boolean $lowLevel
  * @param array $atts
  * @param string $content
  * @return string
  */
 private static function runShortcode($shortcodeName, $lowLevel, $atts, $content)
 {
     // The content of low-level shortcodes is supposed to have been saved in `self::$lowLevelShortcodeContent`.
     if ($lowLevel && isset($content) && isset(self::$lowLevelShortcodeContent[$content])) {
         $content = self::$lowLevelShortcodeContent[$content];
     }
     // Print the shortcode.
     $model = RPBChessboardHelperLoader::loadModel('Shortcode/' . $shortcodeName, $atts, $content);
     return RPBChessboardHelperLoader::printTemplateOffScreen('Shortcode/' . $shortcodeName, $model);
 }
Example #5
0
 /**
  * Write a file into the cache. Nothing happens if the file already exists.
  *
  * @param string $fileName File name, relative to the cache root.
  * @param string $templateName Template to use to generate the file, if necessary.
  * @param string $modelName Model to use to generate the file, if necessary.
  */
 public static function ensureExists($fileName, $templateName, $modelName)
 {
     $fullFileName = self::getFullFileName($fileName);
     if (file_exists($fullFileName)) {
         return;
     }
     $model = RPBChessboardHelperLoader::loadModel($modelName);
     $text = RPBChessboardHelperLoader::printTemplateOffScreen($templateName, $model);
     $dirName = dirname($fullFileName);
     if (!file_exists($dirName)) {
         mkdir($dirName, 0777, true);
     }
     file_put_contents($fullFileName, $text);
     update_option('rpbchessboard_cache_' . $fileName, uniqid());
 }
Example #6
0
 public static function callbackInlinedScripts()
 {
     $model = RPBChessboardHelperLoader::loadModel('Common/Compatibility');
     RPBChessboardHelperLoader::printTemplate('Localization', $model);
 }
Example #7
0
 /**
  * Load the model `$postModelName`, and execute the method `$methodName` supposingly defined by this model.
  *
  * @param object $model
  * @param string $postModelName
  * @param string $methodName
  * @param string $capability Required capability to execute the action. Default is `'manage_options'`.
  */
 private static function executeAction($model, $postModelName, $methodName, $capability = 'manage_options')
 {
     if (!current_user_can($capability)) {
         return;
     }
     $postModel = RPBChessboardHelperLoader::loadModel('Post/' . $postModelName);
     $model->setPostMessage($postModel->{$methodName}());
 }
Example #8
0
 *                                                                            *
 *    This program is free software: you can redistribute it and/or modify    *
 *    it under the terms of the GNU General Public License as published by    *
 *    the Free Software Foundation, either version 3 of the License, or       *
 *    (at your option) any later version.                                     *
 *                                                                            *
 *    This program is distributed in the hope that it will be useful,         *
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
 *    GNU General Public License for more details.                            *
 *                                                                            *
 *    You should have received a copy of the GNU General Public License       *
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.   *
 *                                                                            *
 ******************************************************************************/
?>

<?php 
RPBChessboardHelperLoader::printTemplate($model->getSubPageTemplateName(), $model);
?>

<script type="text/javascript">
	jQuery(document).ready(function($) {
		$('.rpbchessboard-outline a').click(function(e) {
			e.preventDefault();
			var target = $(this).attr('href');
			$('html').animate({ scrollTop: $(target).offset().top - 50 }, 500);
		});
	});
</script>
Example #9
0
?>
	</p>

	<ol class="rpbchessboard-outline">
		<li><a href="#rpbchessboard-fenAttributeFlip"><?php 
_e('Board flipping', 'rpbchessboard');
?>
</a></li>
		<li><a href="#rpbchessboard-fenAttributeSquareSize"><?php 
_e('Square size', 'rpbchessboard');
?>
</a></li>
		<li><a href="#rpbchessboard-fenAttributeShowCoordinates"><?php 
_e('Show coordinates', 'rpbchessboard');
?>
</a></li>
		<li><a href="#rpbchessboard-fenAttributeMarkers"><?php 
_e('Square and arrow markers', 'rpbchessboard');
?>
</a></li>
	</ol>

	<?php 
RPBChessboardHelperLoader::printTemplate('AdminPage/Help/FENAttributes/Flip', $model);
RPBChessboardHelperLoader::printTemplate('AdminPage/Help/FENAttributes/SquareSize', $model);
RPBChessboardHelperLoader::printTemplate('AdminPage/Help/FENAttributes/ShowCoordinates', $model);
RPBChessboardHelperLoader::printTemplate('AdminPage/Help/FENAttributes/Markers', $model);
?>

</div>
Example #10
0
		<li><a href="#rpbchessboard-pgnDiagram"><?php 
_e('Diagrams', 'rpbchessboard');
?>
</a></li>
		<li><a href="#rpbchessboard-pgnMarker"><?php 
_e('Square and arrow markers', 'rpbchessboard');
?>
</a></li>
		<li><a href="#rpbchessboard-pgnCustomStartingPosition"><?php 
_e('Custom starting position', 'rpbchessboard');
?>
</a></li>
		<li><a href="#rpbchessboard-pgnNullMove"><?php 
_e('Null moves', 'rpbchessboard');
?>
</a></li>
	</ol>

	<?php 
RPBChessboardHelperLoader::printTemplate('AdminPage/Help/PGNSyntax/Example', $model);
RPBChessboardHelperLoader::printTemplate('AdminPage/Help/PGNSyntax/NAG', $model);
RPBChessboardHelperLoader::printTemplate('AdminPage/Help/PGNSyntax/Comment', $model);
RPBChessboardHelperLoader::printTemplate('AdminPage/Help/PGNSyntax/Variation', $model);
RPBChessboardHelperLoader::printTemplate('AdminPage/Help/PGNSyntax/Diagram', $model);
RPBChessboardHelperLoader::printTemplate('AdminPage/Help/PGNSyntax/Marker', $model);
RPBChessboardHelperLoader::printTemplate('AdminPage/Help/PGNSyntax/CustomStartingPosition', $model);
RPBChessboardHelperLoader::printTemplate('AdminPage/Help/PGNSyntax/NullMove', $model);
?>

</div>
Example #11
0
 *    This program is free software: you can redistribute it and/or modify    *
 *    it under the terms of the GNU General Public License as published by    *
 *    the Free Software Foundation, either version 3 of the License, or       *
 *    (at your option) any later version.                                     *
 *                                                                            *
 *    This program is distributed in the hope that it will be useful,         *
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
 *    GNU General Public License for more details.                            *
 *                                                                            *
 *    You should have received a copy of the GNU General Public License       *
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.   *
 *                                                                            *
 ******************************************************************************/
?>

<div id="rpbchessboard-memoPage">

	<p>
		<?php 
_e('This short reminder presents through examples the features provided by the RPB Chessboard plugin, ' . 'namely the insertion of chess diagrams and games in WordPress websites. ' . 'On the left is the code written in posts and pages, while the right column shows the corresponding rendering.', 'rpbchessboard');
?>
	</p>

	<?php 
RPBChessboardHelperLoader::printTemplate('AdminPage/Memo/FEN', $model);
RPBChessboardHelperLoader::printTemplate('AdminPage/Memo/PGN', $model);
?>

</div>
Example #12
0
 public static function callbackInlinedScripts()
 {
     $model = RPBChessboardHelperLoader::loadTrait('Compatibility');
     include RPBCHESSBOARD_ABSPATH . 'templates/localization.php';
 }
Example #13
0
?>
	</p>

	<ol class="rpbchessboard-outline">
		<li><a href="#rpbchessboard-pgnAttributePieceSymbols"><?php 
_e('Piece symbols', 'rpbchessboard');
?>
</a></li>
		<li><a href="#rpbchessboard-pgnAttributeNavigationBoard"><?php 
_e('Navigation board', 'rpbchessboard');
?>
</a></li>
		<li><a href="#rpbchessboard-pgnAttributeMoveAnimation"><?php 
_e('Move animation', 'rpbchessboard');
?>
</a></li>
		<li><a href="#rpbchessboard-pgnAttributeBoardAspect"><?php 
_e('Chessboard aspect', 'rpbchessboard');
?>
</a></li>
	</ol>

	<?php 
RPBChessboardHelperLoader::printTemplate('AdminPage/Help/PGNAttributes/PieceSymbols', $model);
RPBChessboardHelperLoader::printTemplate('AdminPage/Help/PGNAttributes/NavigationBoard', $model);
RPBChessboardHelperLoader::printTemplate('AdminPage/Help/PGNAttributes/MoveAnimation', $model);
RPBChessboardHelperLoader::printTemplate('AdminPage/Help/PGNAttributes/BoardAspect', $model);
?>

</div>
Example #14
0
 *    This file is part of RPB Chessboard, a WordPress plugin.                *
 *    Copyright (C) 2013-2016  Yoann Le Montagner <yo35 -at- melix.net>       *
 *                                                                            *
 *    This program is free software: you can redistribute it and/or modify    *
 *    it under the terms of the GNU General Public License as published by    *
 *    the Free Software Foundation, either version 3 of the License, or       *
 *    (at your option) any later version.                                     *
 *                                                                            *
 *    This program is distributed in the hope that it will be useful,         *
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
 *    GNU General Public License for more details.                            *
 *                                                                            *
 *    You should have received a copy of the GNU General Public License       *
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.   *
 *                                                                            *
 ******************************************************************************/
?>

<p>
	<?php 
echo sprintf(__('These settings control the default aspect and behavior of the chess diagrams and games ' . 'inserted in posts and pages with the %1$s[%3$s][/%3$s]%2$s and %1$s[%4$s][/%4$s]%2$s tags. ' . 'They can be overridden at each tag by passing appropriate tag attributes: ' . 'see %5$shelp on FEN diagram attributes%7$s and %6$shelp on PGN game attributes%7$s for more details.', 'rpbchessboard'), '<span class="rpbchessboard-sourceCode">', '</span>', htmlspecialchars($model->getFENShortcode()), htmlspecialchars($model->getPGNShortcode()), '<a href="' . htmlspecialchars($model->getHelpOnFENAttributesURL()) . '">', '<a href="' . htmlspecialchars($model->getHelpOnPGNAttributesURL()) . '">', '</a>');
?>
</p>

<?php 
RPBChessboardHelperLoader::printTemplate('AdminPage/Options/General/BoardAspect', $model);
RPBChessboardHelperLoader::printTemplate('AdminPage/Options/General/PieceSymbols', $model);
RPBChessboardHelperLoader::printTemplate('AdminPage/Options/General/NavigationBoard', $model);
RPBChessboardHelperLoader::printTemplate('AdminPage/Options/General/MoveAnimation', $model);