public function renderUsername($withAvatar = false, $withLevel = true, $withLink = true, $withCountry = true) { $html = ''; if ($withAvatar) { $src = Util\Media::showFromModel($this->getAvatar(), 32, 32); $html .= '<img src="' . $src . '" alt="' . $this->username . '" title="' . $this->username . '" /> '; } if ($withCountry) { $html .= '<img src="' . \Own\Bus\Country::toArray(false)[$this->getCountry()] . '" alt="' . $this->getCountryValue() . '" title="' . $this->getCountryValue() . '" /> '; } if ($withLink) { $html .= '<a href="#" class="modal-player" data-id="' . $this->id . '">'; } if ($this->userId != 0) { $html .= '<b>' . $this->username . '</b>'; } else { $html .= $this->username; } if ($withLink) { $html .= '</a>'; } if (is_int($withLevel) && $withLevel != 0) { $html .= ' <span class="enum level">' . $withLevel . '</span>'; } else { if ($withLevel !== false) { $html .= ' <span class="enum level">' . $this->calculateLevel() . '</span>'; } } return $html; }
public static function buildMedia($field, \Rebond\Core\Media\Model $media) { $html = '<div class="input-media" data-field="' . $field . '">'; $html .= '<img src="' . \Rebond\Util\Media::showFromModel($media) . '" alt="media" />'; $html .= '<input type="text" class="input" id="media-' . $field . '" disabled value="' . $media->getTitle() . '">'; $html .= '<a href="#" class="button media-select" id="media-select-' . $field . '" data-field="' . $field . '">' . Lang::lang('select') . '</a>'; $html .= '<a href="#" class="button media-clear" id="media-clear-' . $field . '" data-field="' . $field . '">' . Lang::lang('clear') . '</a>'; $html .= '<input type="hidden" id="' . $field . '" name="' . $field . '" value="' . $media->getId() . '">'; $html .= '</div>'; return $html; }
public function crop() { // auth Auth::isAdminAuthorized($this->signedUser, 'admin.media.crop', true, '/media'); // action $id = Converter::int('id'); $x = Converter::int('x', 'post'); $y = Converter::int('y', 'post'); $w = Converter::int('w', 'post'); $h = Converter::int('h', 'post'); $media = \Rebond\Core\Media\Data::loadById($id); if (!isset($media)) { Session::adminError('itemNotFound', [$id], '/media'); } // action if (isset($_POST['save'])) { $file = \Rebond\Util\Media::showFromModel($media, 920, 900, \Rebond\Core\RatioType::KEEP_MIN); $filename = \Rebond\Util\File::getFilename($file); $upload = \Rebond\Util\Media::crop(\Rebond\Config::getPath('media'), $media->getPath(), $filename, $x, $y, $w, $h); // add Media // copy media by setting MediaId to 0 $fullPathFile = \Rebond\Config::getPath('media') . $media->getPath() . $upload; $media->setId(0); $media->setOriginalFilename($upload); $media->setWidth($_POST['w']); $media->setHeight($_POST['h']); $media->setFilesize(filesize($fullPathFile)); $media->setUpload($upload); $media->setCreatedDate('now'); $media->save(); Session::adminSuccess('saved', '/media'); } // view $this->setTpl(); // media $tplMain = new Template(Template::SITE, ['admin', 'media']); $tplMain->set('model', $media); // layout $this->tplLayout->add('column1', $tplMain->render('crop')); //master $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col')); $this->tplMaster->set('jsLauncher', 'mediaCrop'); return $this->tplMaster->render('tpl-default'); }
public function getMedia() { if (!$this->hasPrivilege('admin.media')) { return $this->noPrivilege('admin.media'); } $json = []; $json['result'] = ResultType::ERROR; // check $id = Converter::int('id', 'post', 0); $mediaModel = \Rebond\Core\Media\Data::loadById($id); if (!isset($mediaModel)) { $json['message'] = Lang::lang('mediaInvalid'); return json_encode($json); } $json['result'] = ResultType::SUCCESS; $json['html'] = \Rebond\Util\Media::showFromModel($mediaModel, 512, 512, \Rebond\Core\RatioType::KEEP_MAX); return json_encode($json); }