Initial commit
This commit is contained in:
commit
65e0da7e11
1397 changed files with 596542 additions and 0 deletions
75
site/OFF_plugins/embed/field/embed.php
Normal file
75
site/OFF_plugins/embed/field/embed.php
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
class EmbedField extends UrlField {
|
||||
|
||||
public $preview = true;
|
||||
public $info = true;
|
||||
public $cheatsheet = false;
|
||||
public $height = 'none';
|
||||
|
||||
public static $assets = [
|
||||
'css' => [
|
||||
'../../../assets/css/embed.css',
|
||||
'field.css'
|
||||
],
|
||||
'js' => [
|
||||
'../../../assets/js/embed.js',
|
||||
'field.js'
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
$this->type = 'embed';
|
||||
$this->icon = 'object-group';
|
||||
|
||||
$this->translations();
|
||||
}
|
||||
|
||||
public function input() {
|
||||
$input = parent::input();
|
||||
$input->data('field', 'embedfield');
|
||||
$input->data('ajax', url('api/plugin/embed/'));
|
||||
return $input;
|
||||
}
|
||||
|
||||
public function template() {
|
||||
$template = parent::template();
|
||||
|
||||
if($this->preview) {
|
||||
$template->append($this->tpl('preview', [
|
||||
'height' => $this->height,
|
||||
]));
|
||||
}
|
||||
|
||||
if($this->info) $template->append($this->tpl('info'));
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
public function label() {
|
||||
$label = parent::label();
|
||||
|
||||
if($this->cheatsheet) $label->append($this->tpl('cheatsheet'));
|
||||
|
||||
return $label;
|
||||
}
|
||||
|
||||
protected function translations() {
|
||||
$root = dirname(__DIR__) . DS . 'translations' . DS;
|
||||
|
||||
// Default (English)
|
||||
require($root . 'en.php');
|
||||
|
||||
// Current panel language
|
||||
if(file_exists($root . panel()->language()->code() . '.php')) {
|
||||
require($root . panel()->language()->code() . '.php');
|
||||
}
|
||||
}
|
||||
|
||||
protected function tpl($file, $args = []) {
|
||||
return tpl::load(__DIR__ . DS . 'templates' . DS . $file . '.php', $args);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue