| | 121 | |
| | 122 | public function getMediaForArea($area, $type = null, $limit = null) |
| | 123 | { |
| | 124 | return $this->getMediaForAreas(array($area), $type, $limit); |
| | 125 | } |
| | 126 | |
| | 127 | /** |
| | 128 | * Given an array of array this function returns the mediaItems in those areas. |
| | 129 | * @param aArea $areas |
| | 130 | * @param $type Set the type of media to return (image, video, pdf, etc...) |
| | 131 | * @param $limit Limit the number of mediaItems returned |
| | 132 | * @return array aMediaItems |
| | 133 | */ |
| | 134 | public function getMediaForAreas($areas, $type = null, $limit = 9999) |
| | 135 | { |
| | 136 | $aMediaItems = array(); |
| | 137 | foreach($areas as $area) |
| | 138 | { |
| | 139 | foreach($this->Page->getArea($area) as $slot) |
| | 140 | { |
| | 141 | foreach($slot->MediaItems as $aMediaItem) |
| | 142 | { |
| | 143 | if(is_null($type) || $aMediaItem['type'] == $type) |
| | 144 | { |
| | 145 | $limit = $limit - 1; |
| | 146 | $aMediaItems[] = $aMediaItem; |
| | 147 | if($limit == 0) return $aMediaItems; |
| | 148 | } |
| | 149 | } |
| | 150 | } |
| | 151 | } |
| | 152 | return $aMediaItems; |
| | 153 | } |