To participate you must create an account on apostrophenow.org. If you have already done so, click Login.

Show
Ignore:
Timestamp:
04/30/10 11:15:17 (2 years ago)
Author:
dordille
Message:

Improvements for displaying images with blogSlots. #302.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • plugins/apostropheBlogPlugin/trunk/lib/model/doctrine/PluginaBlogItem.class.php

    r1066 r1102  
    9595      foreach($this->Page->getArea($area) as $slot) 
    9696      { 
    97         if(method_exists($slot, 'getSearchText')) 
     97        if(method_exists($slot, 'getText')) 
    9898        { 
    99           $text .= strip_tags($slot->getValue()); 
     99          $text .= strip_tags($slot->getText()); 
    100100        } 
    101101      } 
     
    119119    return $this->getTextForAreas(array($area), $limit); 
    120120  } 
     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  } 
    121154   
    122155  public function getFeedText() 
     
    125158    foreach($this->Page->getArea('blog-body') as $slot) 
    126159    { 
    127       if(method_exists($slot, 'getSearchText')) 
    128       { 
    129         $text .= $slot->getSearchText(); 
     160      if(method_exists($slot, 'getText')) 
     161      { 
     162        $text .= $slot->getText(); 
    130163      } 
    131164    }