protected function render_inner_html()
    {
        $html = parent::render_inner_html();
        $value = $this['value'] ?: $this[self::DEFAULT_VALUE];
        $value = json_decode($value, true);
        $input = new Element('input', array('name' => $this['name'], 'type' => 'hidden', 'value' => $value ? json_encode($value) : ''));
        $content = '';
        if ($value) {
            $value += array('w' => null, 'h' => null, 'no-upscale' => false, 'method' => 'fill', 'format' => 'jpeg', 'interlace' => false);
            $options = array();
            $w = $value['w'] ?: '<em>auto</em>';
            $h = $value['h'] ?: '<em>auto</em>';
            $method = $value['method'];
            $format = '.' . $value['format'];
            /*
            if ($value['no-upscale'])
            {
            	$options[] = 'ne pas agrandir';
            }
            */
            if ($options) {
                $options = '&ndash; ' . implode(', ', $options);
            } else {
                $options = '';
            }
            $content = <<<EOT
{$w}×{$h} {$method} {$format} <span class="small light">{$options}</span>
EOT;
        }
        $placeholder = 'Version non définie';
        return <<<EOT
{$input} <span class="spinner-content">{$content}</span> <em class="spinner-placeholder">{$placeholder}</em> {$html}
EOT;
    }
Пример #2
0
 protected function render_inner_html()
 {
     global $core;
     $rc = parent::render_inner_html();
     $constructor = $this[self::T_CONSTRUCTOR];
     $value = $this['value'] ?: $this[self::DEFAULT_VALUE];
     $record = null;
     if ($value) {
         $model = $core->models[$constructor];
         try {
             $record = is_numeric($value) ? $model[$value] : $this->getEntry($model, $value);
         } catch (\Exception $e) {
             \ICanBoogie\log_error('Missing record %nid', ['%nid' => $value]);
         }
     }
     if (!$record) {
         $this->add_class('placeholder');
         $value = null;
     }
     $rc .= new Element('input', ['type' => 'hidden', 'name' => $this['name'], 'value' => $value]);
     $placeholder = $this['placeholder'];
     if ($placeholder) {
         $rc .= '<em class="spinner-placeholder">' . \ICanBoogie\escape($placeholder) . '</em>';
     }
     $rc .= '<span class="spinner-content">' . $this->getPreview($record) . '</span>';
     return $rc;
 }
Пример #3
0
 protected function render_inner_html()
 {
     global $core;
     $slug = $this->slug_el['value'];
     $tease = '<strong>Slug&nbsp;:</strong> ';
     $tease .= '<a href="#slug-edit" title="' . I18n\t('edit', [], ['scope' => 'titleslugcombo.element']) . '">' . ($slug ? \ICanBoogie\escape(\ICanBoogie\shorten($slug)) : $this->dataset['auto-label']) . '</a>';
     $tease .= ' <span>&ndash; <a href="slug-delete" class="warn">' . I18n\t('reset', [], ['scope' => 'titleslugcombo.element']) . '</a></span>';
     $this->slug_tease->inner_html = $tease;
     $rc = parent::render_inner_html();
     $nid = $this[self::T_NODEID];
     if ($nid) {
         $node = $core->models['nodes'][$nid];
         if ($node && $node->url && $node->url[0] != '#') {
             $url = $node->url;
             $url_label = \ICanBoogie\shorten($url, 64);
             $rc .= '<p class="small light">';
             $rc .= '<strong>URL&nbsp;:</strong> ' . $url_label;
         }
     }
     return $rc;
 }
Пример #4
0
 public function offsetSet($attribute, $value)
 {
     if ($attribute == 'value') {
         if (preg_match('/\\/api\\/images\\/(\\d+)(\\/(\\d*)x(\\d*)(\\/([a-z\\-]+))?)?/', $value, $matches)) {
             list($path, $nid, , $width, $height, , $method) = $matches + array(3 => null, 4 => null, 6 => null);
             $options = array();
             $qs = strpos($value, '?');
             if ($qs) {
                 parse_str(substr($value, $qs + 1), $options);
             }
             $options['width'] = $width;
             $options['height'] = $height;
             if ($method) {
                 $options['method'] = $method;
             }
             $this->adjust_image['value'] = $nid;
             $this->adjust_thumbnail_options['value'] = $options;
         }
     }
     parent::offsetSet($attribute, $value);
 }