Ejemplo n.º 1
0
 public function text_editor()
 {
     // auth
     Auth::isAdminAuthorized($this->signedUser, 'admin.media.image', true, '/media');
     // check
     $info = null;
     $generate = Converter::bool('generate');
     $imageListPath = \Rebond\Config::getPath('admin') . 'js/tinymce/imageList.js';
     // action
     if ($generate) {
         $url = \Rebond\Config::getPath('siteUrl') . \Rebond\Config::getPath('mediaFolder');
         $list = '[';
         $options = [];
         $options['clearSelect'] = true;
         $options['select'][] = \Rebond\Core\Media\Data::getList(['id', 'title', 'path', 'upload']);
         $options['where'][] = 'media.status = 1';
         $options['where'][] = 'media.extension IN ("png", "gif", "jpg", "jpeg")';
         $options['order'][] = 'media.title';
         $medium = \Rebond\Core\Media\Data::loadAll($options);
         foreach ($medium as $media) {
             $list .= '{title:"' . $media->getTitle() . '", value:"http://' . $url . $media->getPath() . $media->getUpload() . '"},' . chr(10);
         }
         if (count($medium) > 0) {
             $list = substr($list, 0, -2);
         }
         $list .= ']';
         File::save($imageListPath, 'w', $list);
         $info = '<p class="bg-success">' . count($medium) . ' ' . Lang::lang('photosGenerated') . '</p>';
     }
     // view
     $this->setTpl();
     // main
     $tplMain = new Template(Template::SITE, ['admin', 'media']);
     $tplMain->set('info', $info);
     if (file_exists($imageListPath)) {
         $tplMain->set('date', \Rebond\Util\Format::smartDate(filemtime($imageListPath)));
         $tplMain->set('link', '/js/tinymce/imageList.js');
     } else {
         $tplMain->set('date', 'n/a');
     }
     // layout
     $this->tplLayout->set('column1', $tplMain->render('text-editor'));
     // master
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col'));
     return $this->tplMaster->render('tpl-default');
 }