Exemplo n.º 1
0
 /**
  * Calculates the image container properties so that it can be rendered correctly.
  * @param int $imagecontainerwidth The width of the container.
  * @param int $imagecontainerratio The ratio array index of the container, see: $imagecontainerratios.
  * @param int $borderwidth The width of the border.
  * @return array with the key => value of 'height' for the container and 'margin-top' and 'margin-left' for the new activity
  *               image.
  */
 public function calculate_image_container_properties($imagecontainerwidth, $imagecontainerratio, $borderwidth)
 {
     if ($imagecontainerwidth !== self::$currentwidth || $imagecontainerratio !== self::$currentratio || $borderwidth !== self::$currentborderwidth) {
         $height = $this->calculate_height($imagecontainerwidth, $imagecontainerratio);
         // margin-top = image holder height - ( image height - border width)).
         // margin-left = (image holder width - image width) + border width.
         $result = array('height' => $height, 'margin-top' => $height - (42 - $borderwidth), 'margin-left' => $imagecontainerwidth - 95 + $borderwidth);
         // Store:...
         self::$currentwidth = $imagecontainerwidth;
         self::$currentratio = $imagecontainerratio;
         self::$currentborderwidth = $borderwidth;
         self::$currentheight = $result['height'];
         self::$activitymargintop = $result['margin-top'];
         self::$activitymarginleft = $result['margin-left'];
     } else {
         $result = array('height' => self::$currentheight, 'margin-top' => self::$activitymargintop, 'margin-left' => self::$activitymarginleft);
     }
     return $result;
 }