Example #1
0
 protected function buildOptions(\Model\Collection $collection)
 {
     while ($collection->next()) {
         $theme = \ThemeModel::findByPk($collection->pid);
         switch ($collection->type) {
             case 'code':
                 $label = $collection->code_snippet_title;
                 break;
             case 'url':
                 $label = preg_replace('#/([^/]+)$#', '/<strong>$1</strong>', $collection->url);
                 break;
             case 'file':
                 if ($collection->filesource == $GLOBALS['TL_CONFIG']['uploadPath'] && version_compare(VERSION, '3', '>=')) {
                     $file = version_compare(VERSION, '3.2', '>=') ? \FilesModel::findByUuid($collection->file) : \FilesModel::findByPk($collection->file);
                     if ($file) {
                         $label = preg_replace('#/([^/]+)$#', '/<strong>$1</strong>', $file->path);
                         break;
                     }
                 } else {
                     $label = preg_replace('#/([^/]+)$#', '/<strong>$1</strong>', $collection->file);
                     break;
                 }
                 // no break
             // no break
             default:
                 $label = '?';
         }
         if (strlen($collection->cc)) {
             $label .= ' <span style="padding-left: 3px; color: #B3B3B3;">[' . $collection->cc . ']</span>';
         }
         $filterRules = File::renderFilterRules($collection->row());
         if ($filterRules) {
             $label .= ' <span style="padding-left: 3px; color: #B3B3B3;">' . $filterRules . '</span>';
         }
         $image = 'assets/theme-plus/images/' . $collection->type . '.png';
         $options[$theme->name][$collection->id] = ($image ? $this->generateImage($image, $label, 'style="vertical-align:-3px"') . ' ' : '') . $label;
     }
     return $options;
 }