コード例 #1
0
 /**
  * Check if module can be moved horizontally
  *
  * @param array $module_data Module's module data
  * @param int $direction Direction to move the module
  *
  * @return bool True if module can be moved, false if not
  */
 public function can_move_horizontally($module_data, $direction)
 {
     if (isset($module_data['module_column'])) {
         return $direction === database_handler::MOVE_DIRECTION_RIGHT ? $module_data['module_column'] < $this->portal_columns->string_to_number('right') : $module_data['module_column'] > $this->portal_columns->string_to_number('left');
     } else {
         return false;
     }
 }
コード例 #2
0
ファイル: manager.php プロジェクト: alhitary/Board3-Portal
 /**
  * Get the horizontal move action (columns to move)
  *
  * @param array $module_data Array containing the module data
  * @param int $direction Direction to move; 1 for right, -1 for left
  *
  * @return int|null Move action if module can be moved, calls
  *		handle_after_move() if it can't be moved
  */
 public function get_horizontal_move_action($module_data, $direction)
 {
     if ($this->constraints_handler->can_move_horizontally($module_data, $direction)) {
         if ($this->module->get_allowed_columns() & $this->portal_columns->string_to_constant($this->portal_columns->number_to_string($module_data['module_column'] + $direction))) {
             return $direction;
             // we move 1 column
         } else {
             if ($this->module->get_allowed_columns() & $this->portal_columns->string_to_constant($this->portal_columns->number_to_string($module_data['module_column'] + $direction * 2)) && $module_data['module_column'] != $this->portal_columns->string_to_number('center')) {
                 return 2 * $direction;
                 // we move 2 columns
             }
         }
     }
     $this->handle_after_move(false);
 }