Exemplo n.º 1
0
 /**
  * Render an HTML checkbox control for the current record.
  *
  * @param string $idPrefix Prefix for checkbox HTML ids
  *
  * @return string
  */
 public function getCheckbox($idPrefix = '')
 {
     static $checkboxCount = 0;
     $id = $this->driver->getResourceSource() . '|' . $this->driver->getUniqueId();
     $context = ['id' => $id, 'count' => $checkboxCount++, 'prefix' => $idPrefix];
     return $this->contextHelper->renderInContext('record/checkbox.phtml', $context);
 }
Exemplo n.º 2
0
 /**
  * Get the rendered cover plus some useful parameters.
  *
  * @param string $context Context of code being generated
  * @param string $default The default size of the cover
  * @param string $link    The link for the anchor
  *
  * @return array
  */
 public function getCoverDetails($context, $default, $link = false)
 {
     $details = compact('link', 'context') + ['driver' => $this->driver, 'cover' => false, 'size' => false, 'linkPreview' => $this->getPreviewCoverLinkSetting($context)];
     $preferredSize = $this->getCoverSize($context, $default);
     if (empty($preferredSize)) {
         // covers disabled entirely
         $details['html'] = '';
     } else {
         // Find best option if more than one size is defined (e.g. small:medium)
         foreach (explode(':', $preferredSize) as $size) {
             if ($details['cover'] = $this->getThumbnail($size)) {
                 $details['size'] = $size;
                 break;
             }
         }
         $details['html'] = $this->contextHelper->renderInContext('record/cover.phtml', $details);
     }
     return $details;
 }
Exemplo n.º 3
0
 /**
  * Render a cover for the current record.
  *
  * @param string $context Context of code being genarated
  * @param string $default The default size of the cover
  * @param string $link    The link for the anchor
  *
  * @return string
  */
 public function getCover($context, $default, $link = false)
 {
     if (isset($this->config->Content->coversize) && !$this->config->Content->coversize) {
         // covers disabled entirely
         $preferredSize = false;
     } else {
         // check for context-specific overrides
         $preferredSize = isset($this->config->Content->coversize[$context]) ? $this->config->Content->coversize[$context] : $default;
     }
     if (empty($preferredSize)) {
         return '';
     }
     // Find best option if more than one size is defined (e.g. small:medium)
     $cover = false;
     // assume invalid until good size found below
     foreach (explode(':', $preferredSize) as $size) {
         if ($cover = $this->getThumbnail($size)) {
             break;
         }
     }
     $driver = $this->driver;
     // for convenient use in compact()
     return $this->contextHelper->renderInContext('record/cover.phtml', compact('cover', 'link', 'context', 'driver'));
 }