Esempio n. 1
0
 /**
  * Draw list
  *
  * @return  boolean
  */
 public function drawList($attachments, $element, $elementId, $pub, $blockParams, $authorized)
 {
     // Get configs
     $configs = $this->getConfigs($element->params, $elementId, $pub, $blockParams);
     $html = '';
     // Is handler assigned?
     $handler = $configs->handler;
     if ($handler) {
         // Handler will draw list
         $html = $handler->drawList($attachments, $configs, $pub, $authorized);
         if ($html) {
             return $html;
         }
     }
     $notice = $authorized ? ' (' . Lang::txt('unavailable') . ')' : '';
     // Draw bundles
     if ($configs->multiZip && $attachments && count($attachments) > 1) {
         $title = $configs->bundleTitle ? $configs->bundleTitle : 'Bundle';
         $pop = Lang::txt('Download') . ' ' . $title;
         $fpath = $this->bundle($attachments, $configs, false);
         // File model
         $file = new \Components\Projects\Models\File(trim($fpath));
         // Get file icon
         $icon = '<img src="' . $file->getIcon() . '" alt="' . $file->get('ext') . '" />';
         // Serve as bundle
         $html .= '<li>';
         $html .= $file->exists() && $authorized ? '<a href="' . Route::url($pub->link('serve') . '&el=' . $elementId) . '" title="' . $pop . '">' . $icon . ' ' . $title . '</a>' : $icon . ' ' . $title . $notice;
         $html .= '<span class="extras">';
         $html .= $file->get('ext') ? '(' . strtoupper($file->get('ext')) : '';
         $html .= $file->getSize() ? ' | ' . $file->getSize('formatted') : '';
         $html .= $file->get('ext') ? ')' : '';
         if ($authorized === 'administrator') {
             $html .= ' <span class="edititem"><a href="index.php?option=com_publications&controller=items&task=editcontent&id=' . $pub->get('id') . '&el=' . $elementId . '&v=' . $pub->get('version_number') . '">' . Lang::txt('COM_PUBLICATIONS_EDIT') . '</a></span>';
         }
         $html .= '</span>';
         $html .= '</li>';
     } elseif ($attachments) {
         // Serve individually
         foreach ($attachments as $attach) {
             // Get file path
             $fpath = $this->getFilePath($attach->path, $attach->id, $configs, $attach->params);
             // File model
             $file = new \Components\Projects\Models\File(trim($fpath));
             $title = $attach->title ? $attach->title : $configs->title;
             $title = $title ? $title : basename($attach->path);
             $pop = Lang::txt('Download') . ' ' . $title;
             $icon = '<img src="' . $file->getIcon() . '" alt="' . $file->get('ext') . '" />';
             $html .= '<li>';
             $html .= $file->exists() && $authorized ? '<a href="' . Route::url($pub->link('serve') . '&el=' . $elementId . '&a=' . $attach->id . '&download=1') . '" title="' . $pop . '">' . $icon . ' ' . $title . '</a>' : $icon . ' ' . $title . $notice;
             $html .= '<span class="extras">';
             $html .= $file->get('ext') ? '(' . strtoupper($file->get('ext')) : '';
             $html .= $file->getSize() ? ' | ' . $file->getSize('formatted') : '';
             $html .= $file->get('ext') ? ')' : '';
             if ($authorized === 'administrator') {
                 $html .= ' <span class="edititem"><a href="index.php?option=com_publications&controller=items&task=editcontent&id=' . $pub->id . '&el=' . $elementId . '&v=' . $pub->version_number . '">' . Lang::txt('COM_PUBLICATIONS_EDIT') . '</a></span>';
             }
             $html .= '</span>';
             $html .= '</li>';
         }
     }
     return $html;
 }