Example #1
0
 /**
  * Draw launcher
  *
  * @return  string HTML
  */
 public function drawLauncher($element, $elementId, $pub, $blockParams, $elements, $authorized)
 {
     // Get configs
     $configs = $this->getConfigs($element->params, $elementId, $pub, $blockParams);
     $attachments = $pub->_attachments;
     $attachments = isset($attachments['elements'][$elementId]) ? $attachments['elements'][$elementId] : NULL;
     // Sort out attachments for this element
     $attachments = $this->_parent->getElementAttachments($elementId, $attachments, $this->_name);
     $disabled = 0;
     $pop = NULL;
     if ($pub->isUnpublished() || $pub->isDown()) {
         $pop = Lang::txt('COM_PUBLICATIONS_STATE_UNPUBLISHED_POP');
         $disabled = 1;
     } elseif (!$authorized) {
         $pop = $pub->access == 1 ? Lang::txt('COM_PUBLICATIONS_STATE_REGISTERED_POP') : Lang::txt('COM_PUBLICATIONS_STATE_RESTRICTED_POP');
         $disabled = 1;
     } elseif (!$attachments) {
         $disabled = 1;
         $pop = Lang::txt('COM_PUBLICATIONS_ERROR_CONTENT_UNAVAILABLE');
     }
     $pop = $pop ? '<p class="warning">' . $pop . '</p>' : '';
     $html = '';
     // Which role?
     $role = $element->params->role;
     $url = Route::url('index.php?option=com_publications&task=serve&id=' . $pub->id . '&v=' . $pub->version_number) . '?el=' . $elementId;
     // Primary button
     if ($role == 1) {
         $attach = $attachments[0];
         if (count($attachments) > 1) {
             // TBD
         }
         // One launcher for all items
         $label = Lang::txt('View publication');
         $class = 'btn btn-primary active icon-next';
         $class .= $disabled ? ' link_disabled' : '';
         $title = $configs->title ? $configs->title : Lang::txt('View publication');
         $html = \Components\Publications\Helpers\Html::primaryButton($class, $url, $label, NULL, $title, 'rel="external"', $disabled, $pop);
     } elseif ($role == 2 && $attachments) {
         $html .= '<ul>';
         $html .= self::drawList($attachments, $element, $elementId, $pub, $blockParams, $authorized);
         $html .= '</ul>';
     }
     return $html;
 }
Example #2
0
 /**
  * Draw launcher
  *
  * @return  boolean
  */
 public function drawLauncher($element, $elementId, $pub, $blockParams, $elements, $authorized)
 {
     // Get configs
     $configs = $this->getConfigs($element->params, $elementId, $pub, $blockParams);
     $attachments = $pub->_attachments;
     $attachments = isset($attachments['elements'][$elementId]) ? $attachments['elements'][$elementId] : NULL;
     $showArchive = isset($pub->_curationModel->_manifest->params->show_archival) ? $pub->_curationModel->_manifest->params->show_archival : 0;
     // Sort out attachments for this element
     $attachments = $this->_parent->getElementAttachments($elementId, $attachments, $this->_name);
     $disabled = 0;
     $pop = NULL;
     if ($pub->isUnpublished() || $pub->isDown()) {
         $pop = Lang::txt('COM_PUBLICATIONS_STATE_UNPUBLISHED_POP');
         $disabled = 1;
     } elseif (!$authorized) {
         $pop = $pub->access == 1 ? Lang::txt('COM_PUBLICATIONS_STATE_REGISTERED_POP') : Lang::txt('COM_PUBLICATIONS_STATE_RESTRICTED_POP');
         $disabled = 1;
     } elseif (!$attachments) {
         $disabled = 1;
         $pop = Lang::txt('COM_PUBLICATIONS_ERROR_CONTENT_UNAVAILABLE');
     }
     $pop = $pop ? '<p class="warning">' . $pop . '</p>' : '';
     // Is default handler assigned?
     $handler = $configs->handler;
     if ($handler) {
         // TBD
         // Handler will draw launch link
     }
     $html = '';
     // Which role?
     $role = $element->params->role;
     $url = Route::url('index.php?option=com_publications&task=serve&id=' . $pub->id . '&v=' . $pub->version_number) . '?el=' . $elementId;
     // Primary button
     if ($role == 1) {
         if (count($attachments) > 1) {
             $fpath = $this->bundle($attachments, $configs, false);
             $title = $configs->bundleTitle;
         } elseif ($attachments) {
             $attach = $attachments[0];
             $fpath = $this->getFilePath($attach->path, $attach->id, $configs, $attach->params);
             $title = $configs->title ? $configs->title : Lang::txt('Download content');
         } else {
             $fpath = NULL;
             $title = NULL;
         }
         if ($configs->fancyLauncher) {
             $html = \Components\Publications\Helpers\Html::drawLauncher('ic-download', $pub, $url, $title, $disabled, $pop, 'download', $showArchive);
         } else {
             $label = Lang::txt('Download');
             // Link to bundle
             if ($showArchive == 1 || $showArchive == 2 && count($attachments) > 1) {
                 $url = Route::url('index.php?option=com_publications&id=' . $pub->id . '&task=serve&v=' . $pub->version_number . '&render=archive');
                 $label .= ' ' . Lang::txt('Bundle');
                 $title = $pub->title . ' ' . Lang::txt('Bundle');
             } else {
                 // Get ext
                 $parts = explode('.', $fpath);
                 $ext = count($parts) > 1 ? array_pop($parts) : NULL;
                 $ext = strtolower($ext);
                 $label .= $ext ? ' <span class="caption">(' . strtoupper($ext) . ')</span>' : '';
             }
             $class = 'btn btn-primary active icon-next';
             $class .= $disabled ? ' link_disabled' : '';
             $html = \Components\Publications\Helpers\Html::primaryButton($class, $url, $label, NULL, $title, '', $disabled, $pop);
         }
     } elseif ($role == 2 && $attachments) {
         $html .= '<ul>';
         $html .= self::drawList($attachments, $element, $elementId, $pub, $blockParams, $authorized);
         $html .= '</ul>';
     }
     return $html;
 }