Ejemplo n.º 1
0
function saveRectangle()
{
    if (!isset($_POST['topA']) || !isset($_POST['topB']) || !isset($_POST['leftA']) || !isset($_POST['leftB'])) {
        return array("success" => false, "error" => "Wrong formatted request");
    }
    $rectangle = new Rectangle((int) $_POST['topA'], (int) $_POST['leftA'], (int) $_POST['topB'], (int) $_POST['leftB']);
    if ($rectangle->save()) {
        return array("success" => true);
    }
    return array("success" => false, "error" => $rectangle->isValid() ? "Oops, something went wrong when saving the rectangle" : "Rectangle with no width and height cannot be registered.");
}
Ejemplo n.º 2
0
 /**
  * Add rectangle to map
  * @param string $value
  * @return boolean
  */
 public function addElementRectangle($value)
 {
     $return = true;
     $stringsrectangle = explode($GLOBALS['egMultiMaps_SeparatorItems'], $value);
     foreach ($stringsrectangle as $rectanglevalue) {
         if (trim($rectanglevalue) == '') {
             continue;
         }
         $rectangle = new Rectangle();
         if (!$rectangle->parse($rectanglevalue, $this->classname)) {
             $return = false;
             $this->errormessages = array_merge($this->errormessages, $rectangle->getErrorMessages());
         }
         if (!$rectangle->isValid()) {
             continue;
         }
         $this->rectangles[] = $rectangle;
         $this->elementsBounds->extend($rectangle->pos);
     }
     return $return;
 }