| Current Path : /proc/self/root/proc/self/root/var/tmp/ |
| Current File : //proc/self/root/proc/self/root/var/tmp/phpALRDfM |
ControllerAjaxStyle.php 0000644 00000000474 15241432360 0011232 0 ustar 00 <?php
namespace Nextend\Framework\Style;
use Nextend\Framework\Controller\Admin\AdminVisualManagerAjaxController;
class ControllerAjaxStyle extends AdminVisualManagerAjaxController {
protected $type = 'style';
public function getModel() {
return new ModelStyle($this);
}
} ModelCss.php 0000644 00000002332 15241432361 0006767 0 ustar 00 <?php
namespace Nextend\Framework\Style;
use Nextend\Framework\Model\AbstractModel;
use Nextend\Framework\Model\StorageSectionManager;
class ModelCss extends AbstractModel {
public $storage;
protected function init() {
$this->storage = StorageSectionManager::getStorage('system');
}
public function addVisual($type, $visual) {
$visualId = $this->storage->add($type, '', $visual);
$visual = $this->storage->getById($visualId, $type);
if (!empty($visual) && $visual['section'] == $type) {
return $visual;
}
return false;
}
public function deleteVisual($type, $id) {
$visual = $this->storage->getById($id, $type);
if (!empty($visual) && $visual['section'] == $type) {
$this->storage->deleteById($id);
return $visual;
}
return false;
}
public function changeVisual($type, $id, $value) {
if ($this->storage->setById($id, $value)) {
return $this->storage->getById($id, $type);
}
return false;
}
public function getVisuals($type) {
return $this->storage->getAll($type);
}
} ModelStyle.php 0000644 00000005762 15241432361 0007351 0 ustar 00 <?php
namespace Nextend\Framework\Style;
use Nextend\Framework\Form\Container\ContainerTable;
use Nextend\Framework\Form\Element\Button;
use Nextend\Framework\Form\Element\MarginPadding;
use Nextend\Framework\Form\Element\MixedField;
use Nextend\Framework\Form\Element\Tab;
use Nextend\Framework\Form\Element\Text\Color;
use Nextend\Framework\Form\Element\Text\NumberAutoComplete;
use Nextend\Framework\Form\Element\Textarea;
use Nextend\Framework\Form\Element\Unit;
use Nextend\Framework\Form\Form;
use Nextend\Framework\Visual\ModelVisual;
class ModelStyle extends ModelVisual {
protected $type = 'style';
public function renderForm() {
$form = new Form($this, 'n2-style-editor');
$table = new ContainerTable($form->getContainer(), 'style', n2_('Style settings'));
$table->setFieldsetPositionEnd();
new Button($table->getFieldsetLabel(), 'style-clear-tab', false, n2_('Clear tab'));
new Tab($table->getFieldsetLabel(), 'style-state');
$row1 = $table->createRow('style-row-1');
new Color($row1, 'backgroundcolor', n2_('Background color'), '000000FF', array(
'alpha' => true
));
new NumberAutoComplete($row1, 'opacity', n2_('Opacity'), '100', array(
'values' => array(
0,
50,
90,
100
),
'unit' => '%',
'wide' => 3
));
$padding = new MarginPadding($row1, 'padding', n2_('Padding'), '0|*|0|*|0|*|0|*|px');
for ($i = 1; $i < 5; $i++) {
new NumberAutoComplete($padding, 'padding-' . $i, false, '', array(
'values' => array(
0,
5,
10,
20,
30
),
'wide' => 3
));
}
new Unit($padding, 'padding-5', '', '', array(
'units' => array(
'px',
'em',
'%'
)
));
new MixedField\Border($row1, 'border', n2_('Border'), '0|*|solid|*|000000ff');
new NumberAutoComplete($row1, 'borderradius', n2_('Border radius'), '0', array(
'values' => array(
0,
3,
5,
10,
99
),
'unit' => 'px',
'wide' => 3
));
new MixedField\BoxShadow($row1, 'boxshadow', n2_('Box shadow'), '0|*|0|*|0|*|0|*|000000ff');
new Textarea($row1, 'extracss', 'CSS', '', array(
'width' => 200,
'height' => 26
));
$previewTable = new ContainerTable($form->getContainer(), 'style-preview', n2_('Preview'));
$previewTable->setFieldsetPositionEnd();
new Color($previewTable->getFieldsetLabel(), 'preview-background', false, 'ced3d5');
$form->render();
}
} Style.php 0000644 00000005432 15241432362 0006363 0 ustar 00 <?php
namespace Nextend\Framework\Style;
use Nextend\Framework\Parser\Color;
use Nextend\Framework\Sanitize;
class Style {
/**
* @param string $tab
*
* @return string
*/
public function style($tab) {
$style = '';
$extra = '';
if (isset($tab['extra'])) {
$extra = $tab['extra'];
unset($tab['extra']);
}
foreach ($tab as $k => $v) {
$style .= $this->parse($k, $v);
}
$style .= $this->parse('extra', $extra);
return $style;
}
/**
* @param $property
* @param $value
*
* @return mixed
*/
public function parse($property, $value) {
$fn = 'parse' . $property;
return $this->$fn($value);
}
public function parseBackgroundColor($v) {
$hex = Color::hex82hex($v);
if ($hex[1] == 'ff') {
return 'background: #' . $hex[0] . ';';
}
$rgba = Color::hex2rgba($v);
return 'background: RGBA(' . $rgba[0] . ',' . $rgba[1] . ',' . $rgba[2] . ',' . round($rgba[3] / 127, 2) . ');';
}
public function parseOpacity($v) {
return 'opacity:' . (intval($v) / 100) . ';';
}
public function parsePadding($v) {
$padding = array_map(array(
Sanitize::class,
'esc_css_value'
), explode('|*|', $v));
$unit = array_pop($padding);
$padding[] = '';
return 'padding:' . implode($unit . ' ', $padding) . ';';
}
public function parseBoxShadow($v) {
$boxShadow = array_map(array(
Sanitize::class,
'esc_css_value'
), explode('|*|', $v));
if ($boxShadow[0] == '0' && $boxShadow[1] == '0' && $boxShadow[2] == '0' && $boxShadow[3] == '0') {
return 'box-shadow: none;';
} else {
$rgba = Color::hex2rgba($boxShadow[4]);
return 'box-shadow: ' . $boxShadow[0] . 'px ' . $boxShadow[1] . 'px ' . $boxShadow[2] . 'px ' . $boxShadow[3] . 'px RGBA(' . $rgba[0] . ',' . $rgba[1] . ',' . $rgba[2] . ',' . round($rgba[3] / 127, 2) . ');';
}
}
public function parseBorder($v) {
$border = array_map(array(
Sanitize::class,
'esc_css_value'
), explode('|*|', $v));
$rgba = Color::hex2rgba($border[2]);
return 'border: ' . $border[0] . 'px ' . $border[1] . ' RGBA(' . $rgba[0] . ',' . $rgba[1] . ',' . $rgba[2] . ',' . round($rgba[3] / 127, 2) . ');';
}
public function parseBorderRadius($v) {
return 'border-radius:' . Sanitize::esc_css_value($v) . 'px;';
}
public function parseExtra($v) {
return Sanitize::esc_css_string($v);
}
} StyleManager.php 0000644 00000000572 15241432363 0007657 0 ustar 00 <?php
namespace Nextend\Framework\Style;
use Nextend\Framework\Pattern\VisualManagerTrait;
use Nextend\Framework\Style\Block\StyleManager\BlockStyleManager;
class StyleManager {
use VisualManagerTrait;
public function display() {
$fontManagerBlock = new BlockStyleManager($this->MVCHelper);
$fontManagerBlock->display();
}
} StyleParser.php 0000644 00000002540 15241432364 0007537 0 ustar 00 <?php
namespace Nextend\Framework\Style;
use Nextend\Framework\Misc\Base64;
use Nextend\Framework\Model\Section;
class StyleParser {
/**
* @param $data
*
* @return string
*/
public static function parse($data) {
if (empty($data)) {
return '';
} else if (is_numeric($data)) {
/**
* Linked style
*/
$style = Section::getById($data, 'style');
if (!$style) {
/**
* Linked style not exists anymore
*/
return '';
}
if (is_string($style['value'])) {
/**
* Old format when value stored as Base64
*/
$decoded = $style['value'];
if ($decoded[0] != '{') {
$decoded = Base64::decode($decoded);
}
return $decoded;
}
/**
* Value stored as array
*/
$value = json_encode($style['value']);
if ($value == false) {
return '';
}
return $value;
} else if ($data[0] != '{') {
return Base64::decode($data);
}
return $data;
}
} StyleStorage.php 0000644 00000004647 15241432365 0007722 0 ustar 00 <?php
namespace Nextend\Framework\Style;
use Nextend\Framework\Pattern\SingletonTrait;
use Nextend\Framework\Plugin;
class StyleStorage {
use SingletonTrait;
private $sets = array();
private $styles = array();
private $stylesBySet = array();
private $stylesById = array();
protected function init() {
Plugin::addAction('systemstyleset', array(
$this,
'styleSet'
));
Plugin::addAction('systemstyle', array(
$this,
'styles'
));
Plugin::addAction('style', array(
$this,
'style'
));
}
private function load() {
static $loaded;
if (!$loaded) {
Plugin::doAction('styleStorage', array(
&$this->sets,
&$this->styles
));
for ($i = 0; $i < count($this->styles); $i++) {
if (!isset($this->stylesBySet[$this->styles[$i]['referencekey']])) {
$this->stylesBySet[$this->styles[$i]['referencekey']] = array();
}
$this->stylesBySet[$this->styles[$i]['referencekey']][] = &$this->styles[$i];
$this->stylesById[$this->styles[$i]['id']] = &$this->styles[$i];
}
$loaded = true;
}
}
public function styleSet($referenceKey, &$sets) {
$this->load();
for ($i = count($this->sets) - 1; $i >= 0; $i--) {
$this->sets[$i]['isSystem'] = 1;
$this->sets[$i]['editable'] = 0;
array_unshift($sets, $this->sets[$i]);
}
}
public function styles($referenceKey, &$styles) {
$this->load();
if (isset($this->stylesBySet[$referenceKey])) {
$_styles = &$this->stylesBySet[$referenceKey];
for ($i = count($_styles) - 1; $i >= 0; $i--) {
$_styles[$i]['isSystem'] = 1;
$_styles[$i]['editable'] = 0;
array_unshift($styles, $_styles[$i]);
}
}
}
public function style($id, &$style) {
$this->load();
if (isset($this->stylesById[$id])) {
$this->stylesById[$id]['isSystem'] = 1;
$this->stylesById[$id]['editable'] = 0;
$style = $this->stylesById[$id];
}
}
} StyleRenderer.php 0000644 00000017736 15241432366 0010070 0 ustar 00 <?php
namespace Nextend\Framework\Style;
use Nextend\Framework\Settings;
class StyleRenderer {
public static $pre = '';
/**
* @var Style
*/
public static $style;
public static $mode;
public static function render($style, $mode, $pre = '') {
self::$pre = $pre;
if (!empty($style)) {
$value = json_decode($style, true);
if ($value) {
$selector = 'n2-style-' . md5($style) . '-' . $mode;
return array(
$selector . ' ',
self::renderStyle($mode, $pre, $selector, $value['data'])
);
}
}
return false;
}
private static function renderStyle($mode, $pre, $selector, $tabs) {
$search = array(
'@pre',
'@selector'
);
$replace = array(
$pre,
'.' . $selector
);
$tabs[0] = array_merge(array(
'backgroundcolor' => 'ffffff00',
'opacity' => 100,
'padding' => '0|*|0|*|0|*|0|*|px',
'boxshadow' => '0|*|0|*|0|*|0|*|000000ff',
'border' => '0|*|solid|*|000000ff',
'borderradius' => '0',
'extra' => '',
), $tabs[0]);
foreach ($tabs as $k => $tab) {
$search[] = '@tab' . $k;
$replace[] = self::$style->style($tab);
}
$template = '';
foreach (self::$mode[$mode]['selectors'] as $s => $style) {
$key = array_search($style, $search);
if (is_numeric($key) && !empty($replace[$key])) {
$template .= $s . "{" . $style . "}";
}
}
return str_replace($search, $replace, $template);
}
}
$frontendAccessibility = intval(Settings::get('frontend-accessibility', 1));
StyleRenderer::$mode = array(
'0' => array(
'id' => '0',
'label' => n2_('Single'),
'tabs' => array(
n2_('Text')
),
'renderOptions' => array(
'combined' => false
),
'preview' => '<div class="{styleClassName}">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>',
'selectors' => array(
'@pre@selector' => '@tab'
)
),
'simple' => array(
'id' => 'simple',
'label' => n2_('Simple'),
'tabs' => array(
n2_('Normal')
),
'renderOptions' => array(
'combined' => true
),
'preview' => '<div class="{styleClassName}" style="width: 200px; height:100px;"></div>',
'selectors' => array(
'@pre@selector' => '@tab0'
)
),
'box' => array(
'id' => 'box',
'label' => n2_('Box'),
'tabs' => array(
n2_('Normal'),
n2_('Hover')
),
'renderOptions' => array(
'combined' => true
),
'preview' => '<div class="{styleClassName}" style="width: 200px; height:100px;"></div>',
'selectors' => array(
'@pre@selector' => '@tab0',
'@pre@selector:HOVER' => '@tab1'
)
),
'button' => array(
'id' => 'button',
'label' => n2_('Button'),
'tabs' => array(
n2_('Normal'),
n2_('Hover')
),
'renderOptions' => array(
'combined' => true
),
'preview' => '<div><a style="display:inline-block; margin:20px;" class="{styleClassName}" href="#" onclick="return false;">Button</a></div>',
'selectors' => $frontendAccessibility ? array(
'@pre@selector' => '@tab0',
'@pre@selector:Hover, @pre@selector:ACTIVE, @pre@selector:FOCUS' => '@tab1'
) : array(
'@pre@selector, @pre@selector:FOCUS' => '@tab0',
'@pre@selector:Hover, @pre@selector:ACTIVE' => '@tab1'
)
),
'heading' => array(
'id' => 'heading',
'label' => n2_('Heading'),
'tabs' => array(
n2_('Normal'),
n2_('Hover')
),
'renderOptions' => array(
'combined' => true
),
'preview' => '<div class="{styleClassName}">Heading</div>',
'selectors' => $frontendAccessibility ? array(
'@pre@selector' => '@tab0',
'@pre@selector:Hover, @pre@selector:ACTIVE, @pre@selector:FOCUS' => '@tab1'
) : array(
'@pre@selector, @pre@selector:FOCUS' => '@tab0',
'@pre@selector:Hover, @pre@selector:ACTIVE' => '@tab1'
)
),
'heading-active' => array(
'id' => 'heading-active',
'label' => n2_('Heading active'),
'tabs' => array(
n2_('Normal'),
n2_('Active')
),
'renderOptions' => array(
'combined' => true
),
'preview' => '<div class="{styleClassName}">Heading</div>',
'selectors' => array(
'@pre@selector' => '@tab0',
'@pre@selector.n2-active' => '@tab1'
)
),
'dot' => array(
'id' => 'dot',
'label' => n2_('Dot'),
'tabs' => array(
n2_('Normal'),
n2_('Active')
),
'renderOptions' => array(
'combined' => true
),
'preview' => '<div><div class="{styleClassName}" style="display: inline-block; margin: 3px;"></div><div class="{styleClassName} n2-active" style="display: inline-block; margin: 3px;"></div><div class="{styleClassName}" style="display: inline-block; margin: 3px;"></div></div>',
'selectors' => array(
'@pre@selector' => '@tab0',
'@pre@selector.n2-active, @pre@selector:HOVER, @pre@selector:FOCUS' => '@tab1'
)
),
'highlight' => array(
'id' => 'highlight',
'label' => n2_('Highlight'),
'tabs' => array(
n2_('Normal'),
n2_('Highlight'),
n2_('Hover')
),
'renderOptions' => array(
'combined' => true
),
'preview' => '<div class="{fontClassName}">' . n2_('Button') . '</div>',
'selectors' => $frontendAccessibility ? array(
'@pre@selector' => '@tab0',
'@pre@selector .n2-highlighted' => '@tab1',
'@pre@selector .n2-highlighted:HOVER, @pre@selector .n2-highlighted:ACTIVE, @pre@selector .n2-highlighted:FOCUS' => '@tab2'
) : array(
'@pre@selector' => '@tab0',
'@pre@selector .n2-highlighted, @pre@selector .n2-highlighted:FOCUS' => '@tab1',
'@pre@selector .n2-highlighted:HOVER, @pre@selector .n2-highlighted:ACTIVE' => '@tab2'
)
),
);
StyleRenderer::$style = new Style(); Block/StyleManager/Index.php 0000644 00000001532 15241432370 0011753 0 ustar 00 <?php
namespace Nextend\Framework\Style\Block\StyleManager;
/**
* @var BlockStyleManager $this
*/
?>
<div id="n2-lightbox-style" class="n2_fullscreen_editor">
<div class="n2_fullscreen_editor__overlay"></div>
<div class="n2_fullscreen_editor__window">
<div class="n2_fullscreen_editor__nav_bar">
<div class="n2_fullscreen_editor__nav_bar_label">
<?php n2_e('Style manager'); ?>
</div>
<div class="n2_fullscreen_editor__nav_bar_actions">
<?php $this->displayTopBar(); ?>
</div>
</div>
<div class="n2_fullscreen_editor__content">
<div class="n2_fullscreen_editor__content_content n2_container_scrollable">
<?php $this->displayContent(); ?>
</div>
</div>
</div>
</div>