Beispiel #1
0
 /**
  * Get a list of attachments on this comment
  *
  * @param      string  $rtrn    What data to return
  * @param      array   $filters Filters to build query from
  * @param      boolean $clear   Clear cached data or not?
  * @return     object  \Hubzero\Base\ItemList
  */
 public function attachments($rtrn = 'list', $filters = array(), $clear = false)
 {
     if (!isset($filters['comment_id'])) {
         $filters['comment_id'] = $this->get('id');
     }
     switch (strtolower($rtrn)) {
         case 'count':
             return $this->attachments('list')->total();
             break;
         case 'first':
             return $this->attachments('list')->first();
             break;
         case 'list':
         case 'results':
         default:
             if (!$this->_cache['attachments'] instanceof ItemList || $clear) {
                 $tbl = new File($this->_db);
                 if ($results = $tbl->find($filters)) {
                     foreach ($results as $key => $result) {
                         $results[$key] = new Attachment($result);
                     }
                 } else {
                     $results = array();
                 }
                 $this->_cache['attachments'] = new ItemList($results);
             }
             return $this->_cache['attachments'];
             break;
     }
 }