Example #1
0
File: fen.php Project: eigentor/sbl
 /**
  * Return the arguments to pass to the uichess-chessboard widget.
  *
  * @return array
  */
 public function getWidgetArgs()
 {
     if (!isset($this->widgetArgs)) {
         $this->widgetArgs = array('position' => $this->getContent());
         $atts = $this->getAttributes();
         // Square markers
         if (isset($atts['csl']) && is_string($atts['csl'])) {
             $this->widgetArgs['squareMarkers'] = $atts['csl'];
         }
         // Arrow markers
         if (isset($atts['cal']) && is_string($atts['cal'])) {
             $this->widgetArgs['arrowMarkers'] = $atts['cal'];
         }
         // Orientation
         $value = isset($atts['flip']) ? RPBChessboardHelperValidation::validateBoolean($atts['flip']) : null;
         if (isset($value)) {
             $this->widgetArgs['flip'] = $value;
         }
         // Square size
         $value = isset($atts['square_size']) ? RPBChessboardHelperValidation::validateSquareSize($atts['square_size']) : null;
         $this->widgetArgs['squareSize'] = isset($value) ? $value : $this->getDefaultSquareSize();
         // Show coordinates
         $value = isset($atts['show_coordinates']) ? RPBChessboardHelperValidation::validateBoolean($atts['show_coordinates']) : null;
         $this->widgetArgs['showCoordinates'] = isset($value) ? $value : $this->getDefaultShowCoordinates();
     }
     return $this->widgetArgs;
 }
Example #2
0
File: pgn.php Project: eigentor/sbl
 /**
  * Return the arguments to pass to the uichess-chessboard widget.
  *
  * @return array
  */
 public function getWidgetArgs()
 {
     if (!isset($this->widgetArgs)) {
         $this->widgetArgs = array('pgn' => $this->getContent());
         $atts = $this->getAttributes();
         $chessboardOptions = array();
         // Orientation
         $value = isset($atts['flip']) ? RPBChessboardHelperValidation::validateBoolean($atts['flip']) : null;
         if (isset($value)) {
             $chessboardOptions['flip'] = $value;
         }
         // Square size
         $value = isset($atts['square_size']) ? RPBChessboardHelperValidation::validateSquareSize($atts['square_size']) : null;
         $chessboardOptions['squareSize'] = isset($value) ? $value : $this->getDefaultSquareSize();
         // Show coordinates
         $value = isset($atts['show_coordinates']) ? RPBChessboardHelperValidation::validateBoolean($atts['show_coordinates']) : null;
         $chessboardOptions['showCoordinates'] = isset($value) ? $value : $this->getDefaultShowCoordinates();
         // Animation speed
         $value = isset($atts['animation_speed']) ? RPBChessboardHelperValidation::validateAnimationSpeed($atts['animation_speed']) : null;
         $chessboardOptions['animationSpeed'] = isset($value) ? $value : $this->getDefaultAnimationSpeed();
         // Move arrow
         $value = isset($atts['show_move_arrow']) ? RPBChessboardHelperValidation::validateBoolean($atts['show_move_arrow']) : null;
         $chessboardOptions['showMoveArrow'] = isset($value) ? $value : $this->getDefaultShowMoveArrow();
         // Piece symbols
         $value = isset($atts['piece_symbols']) ? RPBChessboardHelperValidation::validatePieceSymbols($atts['piece_symbols']) : null;
         $this->widgetArgs['pieceSymbols'] = isset($value) ? $value : $this->getDefaultPieceSymbols();
         // Navigation board
         $value = isset($atts['navigation_board']) ? RPBChessboardHelperValidation::validateNavigationBoard($atts['navigation_board']) : null;
         $this->widgetArgs['navigationBoard'] = isset($value) ? $value : $this->getDefaultNavigationBoard();
         // Use the same aspect parameters for the navigation board and the text comment diagrams.
         $this->widgetArgs['navigationBoardOptions'] = $chessboardOptions;
         $this->widgetArgs['diagramOptions'] = $chessboardOptions;
     }
     return $this->widgetArgs;
 }
 /**
  * Whether the compatibility mode is activated or not for the [pgn][/pgn] shortcode
  * (which means that [pgn_compat][/pgn_compat] would be used instead).
  *
  * @return boolean
  */
 public function getPGNCompatibilityMode()
 {
     if (!isset(self::$pgnCompatibilityMode)) {
         $value = RPBChessboardHelperValidation::validateBooleanFromInt(get_option('rpbchessboard_pgnCompatibilityMode'));
         self::$pgnCompatibilityMode = isset($value) ? $value : false;
     }
     return self::$pgnCompatibilityMode;
 }
Example #4
0
 /**
  * Load the small-screen mode specifications.
  */
 private static function loadSmallScreenModes()
 {
     // Load the raw data
     $data = RPBChessboardHelperValidation::validateSmallScreenModes(get_option('rpbchessboard_smallScreenModes'));
     $data = isset($data) ? $data : array(240 => (object) array('squareSize' => 18, 'hideCoordinates' => true), 320 => (object) array('squareSize' => 24, 'hideCoordinates' => true), 480 => (object) array('squareSize' => 32, 'hideCoordinates' => false), 768 => (object) array('squareSize' => 56, 'hideCoordinates' => false));
     // Format the mode entries
     self::$smallScreenModes = array();
     $previousScreenWidthBound = 0;
     foreach ($data as $screenWidthBound => $mode) {
         $mode->minScreenWidth = $previousScreenWidthBound;
         $mode->maxScreenWidth = $screenWidthBound;
         array_push(self::$smallScreenModes, $mode);
         $previousScreenWidthBound = $screenWidthBound;
     }
 }
Example #5
0
 /**
  * Options specific to the current diagram, that may override the settings defined either
  * at the [pgn][/pgn] shortcode level or at the global level.
  *
  * @return array
  */
 public function getDiagramOptions()
 {
     if (!isset($this->diagramOptions)) {
         $this->diagramOptions = array();
         $atts = $this->getAttributes();
         // Orientation
         $value = isset($atts['flip']) ? RPBChessboardHelperValidation::validateBoolean($atts['flip']) : null;
         if (isset($value)) {
             $this->diagramOptions['flip'] = $value;
         }
         // Square size
         $value = isset($atts['square_size']) ? RPBChessboardHelperValidation::validateSquareSize($atts['square_size']) : null;
         if (isset($value)) {
             $this->diagramOptions['squareSize'] = $value;
         }
         // Show coordinates
         $value = isset($atts['show_coordinates']) ? RPBChessboardHelperValidation::validateBoolean($atts['show_coordinates']) : null;
         if (isset($value)) {
             $this->diagramOptions['showCoordinates'] = $value;
         }
     }
     return $this->diagramOptions;
 }
 /**
  * Default navigation board position.
  *
  * @return string
  */
 public function getDefaultNavigationBoard()
 {
     if (!isset(self::$navigationBoard)) {
         $value = RPBChessboardHelperValidation::validateNavigationBoard(get_option('rpbchessboard_navigationBoard'));
         self::$navigationBoard = isset($value) ? $value : self::DEFAULT_NAVIGATION_BOARD;
     }
     return self::$navigationBoard;
 }
 /**
  * Load and validate a boolean post parameter with the given name.
  *
  * @param string $fieldName
  * @return boolean
  */
 private static function loadBooleanParameter($fieldName)
 {
     return isset($_POST[$fieldName]) ? RPBChessboardHelperValidation::validateBooleanFromInt($_POST[$fieldName]) : null;
 }
Example #8
0
 /**
  * Load and validate the small-screen mode corresponding to the given index.
  *
  * @param int $index
  * @return string
  */
 private static function loadSmallScreenMode($index)
 {
     $screenWidthKey = 'smallScreenMode' . $index . '-screenWidth';
     $squareSizeKey = 'smallScreenMode' . $index . '-squareSize';
     $hideCoordinatesKey = 'smallScreenMode' . $index . '-hideCoordinates';
     if (isset($_POST[$screenWidthKey]) && isset($squareSizeKey) && isset($hideCoordinatesKey)) {
         $screenWidth = RPBChessboardHelperValidation::validateInteger($_POST[$screenWidthKey], 1);
         $squareSize = RPBChessboardHelperValidation::validateSquareSize($_POST[$squareSizeKey]);
         $hideCoordinates = RPBChessboardHelperValidation::validateBooleanFromInt($_POST[$hideCoordinatesKey]);
         if (isset($screenWidth) && isset($squareSize) && isset($hideCoordinates)) {
             return $screenWidth . ':' . $squareSize . ':' . ($hideCoordinates ? 'true' : 'false');
         }
     }
     return null;
 }
Example #9
0
 /**
  * Default show-move-arrow parameter.
  *
  * @return boolean
  */
 public function getDefaultShowMoveArrow()
 {
     if (!isset(self::$showMoveArrow)) {
         $value = RPBChessboardHelperValidation::validateBooleanFromInt(get_option('rpbchessboard_showMoveArrow'));
         self::$showMoveArrow = isset($value) ? $value : self::DEFAULT_SHOW_MOVE_ARROW;
     }
     return self::$showMoveArrow;
 }