Exemple #1
0
 /**
  * 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;
 }
Exemple #2
0
 private static function processAnimationSpeed()
 {
     if (isset($_POST['animationSpeed'])) {
         $value = RPBChessboardHelperValidation::validateAnimationSpeed($_POST['animationSpeed']);
         if (isset($value)) {
             update_option('rpbchessboard_animationSpeed', $value);
         }
     }
 }
Exemple #3
0
 /**
  * Default animation speed.
  *
  * @return int
  */
 public function getDefaultAnimationSpeed()
 {
     if (!isset(self::$animationSpeed)) {
         $value = RPBChessboardHelperValidation::validateAnimationSpeed(get_option('rpbchessboard_animationSpeed'));
         self::$animationSpeed = isset($value) ? $value : self::DEFAULT_ANIMATION_SPEED;
     }
     return self::$animationSpeed;
 }