designer module, widgets url, fixes

This commit is contained in:
Dro1d.Ru 2017-10-28 00:55:39 +05:00
parent a0e0a9e134
commit 4b8483cbcf
46 changed files with 1677 additions and 39 deletions

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,40 @@
.colorpicker-2x .colorpicker-saturation {
width: 200px;
height: 200px;
}
.colorpicker-2x .colorpicker-hue,
.colorpicker-2x .colorpicker-alpha {
width: 30px;
height: 200px;
}
.colorpicker-2x .colorpicker-color,
.colorpicker-2x .colorpicker-color div {
height: 30px;
}
.designer_colorpicker {
position: absolute;
width: 42px;
height: 42px;
border: 1px solid #ffffff;
border-radius: 3px;
box-shadow: 0px 0px 10px #ffffff;
background: #005599 url(../../images/designer/colorpicker.jpg);
z-index: 2500;
cursor: pointer;
animation: colorpicker 20s linear infinite;
}
@keyframes colorpicker {
0% {
-webkit-transform: rotate(-360deg);
transform: rotate(-360deg);
},
50% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
},
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
assets/images/designer/image.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

File diff suppressed because one or more lines are too long

View file

@ -5,10 +5,14 @@ var dash_widget_load = function() {
var input = $(this.element).find('.dash_form_widget_record_input');
var hidden = $(this.element).find('.dash_form_widget_record_hidden');
var input2 = $(this.element).find('.dash_form_widget_url_input');
if ($(hidden).val().length==0) {
$(this.element).find('.dash_form_widget_record_container').css('display', 'none');
}
if ($(input2).val().length==0) {
$(this.element).find('.dash_form_widget_url_container').css('display', 'none');
}
$(this.element).find('.dash_form_widget_record_select').trigger('change');
@ -134,18 +138,29 @@ var dash_widget_page_input_select = function() {
$(this).parents('form').find('.dash_form_widget_record_input').val('');
$(this).parents('form').find('.dash_form_widget_record_hidden').val('');
}
if ($(this).val()!='-3') {
$(this).parents('form').find('.dash_form_widget_url_input').val('');
}
if ($(this).val()=='0') {
$(this).parents('form').find('.language-select').removeAttr('disabled');
$(this).parents('form').find('.filter-select').attr('disabled','disabled');
$(this).parents('form').find('.dash_form_widget_record_container').css('display', 'none');
$(this).parents('form').find('.dash_form_widget_url_container').css('display', 'none');
} else if ($(this).val()=='-2') {
$(this).parents('form').find('.language-select').attr('disabled','disabled');
$(this).parents('form').find('.filter-select').attr('disabled','disabled');
$(this).parents('form').find('.dash_form_widget_record_container').css('display', 'block');
$(this).parents('form').find('.dash_form_widget_url_container').css('display', 'none');
} else if ($(this).val()=='-3') {
$(this).parents('form').find('.language-select').removeAttr('disabled');
$(this).parents('form').find('.filter-select').removeAttr('disabled');
$(this).parents('form').find('.dash_form_widget_record_container').css('display', 'none');
$(this).parents('form').find('.dash_form_widget_url_container').css('display', 'block');
} else {
$(this).parents('form').find('.language-select').removeAttr('disabled');
$(this).parents('form').find('.filter-select').removeAttr('disabled');
$(this).parents('form').find('.dash_form_widget_record_container').css('display', 'none');
$(this).parents('form').find('.dash_form_widget_url_container').css('display', 'none');
}
};

220
assets/js/designer/dash.js Normal file
View file

@ -0,0 +1,220 @@
var designer_styles_load = function() {
for (var i=0; i<this.options.bodyItems.length; i++) {
if (typeof(this.options.bodyItems[i].inactive)!="undefined" && this.options.bodyItems[i].inactive) {
$(this.options.bodyItems[i].element).addClass('inactive');
}
}
};
var designer_styles_copy = function() {
var selected = this.getSelectedContentItems();
if (selected && selected.length==1) {
desk_prompt(t('Enter title'), this.bind(this, function(name){
if (name.length==0) return;
desk_window_request(this, url('designer/dash/copy'),{'title':name, 'item':selected[0].data});
}));
$('#zira-prompt-dialog input[name=modal-input]').val(selected[0].title);
}
};
var designer_style_load = function() {
desk_window_form_init(this);
$(this.element).find('.dash_form_designer_record_select').change(designer_style_page_input_select);
var input = $(this.element).find('.dash_form_designer_record_input');
var hidden = $(this.element).find('.dash_form_designer_record_hidden');
var input2 = $(this.element).find('.dash_form_designer_url_input');
if ($(hidden).val().length==0) {
$(this.element).find('.dash_form_designer_record_container').css('display', 'none');
}
if ($(input2).val().length==0) {
$(this.element).find('.dash_form_designer_url_container').css('display', 'none');
}
$(this.element).find('.dash_form_designer_record_select').trigger('change');
$(input).unbind('keyup').keyup(zira_bind(this, function(e){
if (typeof(e.keyCode)=="undefined") return;
try {
window.clearTimeout(this.autocomplete_timer);
} catch(e){}
if (e.keyCode == 13) return;
if (e.keyCode == 37 || e.keyCode == 38 || e.keyCode == 39 || e.keyCode == 40 || e.keyCode == 13) return;
if (this.isDisabled()) return;
$(input).data('autocomplete_id',null);
$(input).data('autocomplete_text',null);
$(hidden).val('');
if ($(input).val().length == 0) {
designer_style_autocomplete_close.call();
return;
}
this.autocomplete_timer = window.setTimeout(zira_bind(this, function(){
var text = $(input).val();
if (this.isDisabled()) return;
try {
window.clearTimeout(this.autocomplete_timer);
} catch(e){}
if (text.length == 0) return;
desk_window_request(this, designer_style_autocomplete_url, {'search': text}, zira_bind(this, function(items){
if (!items) return;
designer_style_autocomplete_close.call();
$('body').append('<ul class="zira-autocomplete-wnd"></ul>');
for (var i in items) {
$('.zira-autocomplete-wnd').append('<li><a href="javascript:void(0)" data-id="'+items[i].record_id+'" data-title="'+items[i].record_title+'">'+items[i].title+'</a></li>');
}
$('.zira-autocomplete-wnd').css({
'position': 'absolute',
'top': $(input).offset().top + $(input).outerHeight(),
'left': $(input).offset().left,
'z-index': this.getZ()+1
});
designer_style_autocomplete_click.input = $(input).get(0);
designer_style_autocomplete_click.hidden = $(hidden).get(0);
$('body').mousedown(designer_style_autocomplete_click);
$('body').keyup(designer_style_autocomplete_press);
$('.zira-autocomplete-wnd a').click(designer_style_autocomplete_select);
}));
}),500);
}));
};
var designer_style_autocomplete_close = function() {
$('.zira-autocomplete-wnd').remove();
$('body').unbind('mousedown',designer_style_autocomplete_click);
$('body').unbind('keyup',designer_style_autocomplete_press);
};
var designer_style_autocomplete_click = function(e) {
if (typeof(e.originalEvent)=="undefined" || typeof(e.originalEvent.target)=="undefined") return;
if ($(e.originalEvent.target).parents('.zira-autocomplete-wnd').length==0 &&
!$(e.originalEvent.target).is(designer_style_autocomplete_click.input)
) {
designer_style_autocomplete_close.call();
} else {
$('.zira-autocomplete-wnd').css('z-index', parseInt($('.zira-autocomplete-wnd').css('z-index'))+1);
}
};
var designer_style_autocomplete_select = function(e) {
var text = $(this).data('title');
var id = $(this).data('id');
$(designer_style_autocomplete_click.input).val(text);
$(designer_style_autocomplete_click.input).data('autocomplete_id',id);
$(designer_style_autocomplete_click.input).data('autocomplete_text',text);
$(designer_style_autocomplete_click.hidden).val(id);
designer_style_autocomplete_close.call();
};
var designer_style_autocomplete_press = function(e) {
if (e.keyCode == 40) { // arrow down
e.stopPropagation();
e.preventDefault();
var active = $('.zira-autocomplete-wnd li a.active');
if ($(active).length==0) {
$('.zira-autocomplete-wnd li:first-child a').addClass('active');
} else {
$(active).removeClass('active');
var next = $(active).parent('li').next('li');
if ($(next).length==0) {
$('.zira-autocomplete-wnd li:first-child a').addClass('active');
} else {
$(next).children('a').addClass('active');
}
}
} else if (e.keyCode == 38) { // arrow up
e.stopPropagation();
e.preventDefault();
var active = $('.zira-autocomplete-wnd li a.active');
if ($(active).length==0) {
$('.zira-autocomplete-wnd li:last-child a').addClass('active');
} else {
$(active).removeClass('active');
var prev = $(active).parent('li').prev('li');
if ($(prev).length==0) {
$('.zira-autocomplete-wnd li:last-child a').addClass('active');
} else {
$(prev).children('a').addClass('active');
}
}
} else if (e.keyCode == 13 || e.keyCode == 39) { // enter or arrow right
var active = $('.zira-autocomplete-wnd li a.active');
if ($(active).length!=0) {
e.stopPropagation();
e.preventDefault();
designer_style_autocomplete_select.call($(active));
}
}
};
var designer_style_page_input_select = function() {
if ($(this).val()!='-2') {
$(this).parents('form').find('.dash_form_designer_record_input').val('');
$(this).parents('form').find('.dash_form_designer_record_hidden').val('');
}
if ($(this).val()!='-3') {
$(this).parents('form').find('.dash_form_designer_url_input').val('');
}
if ($(this).val()=='0') {
$(this).parents('form').find('.language-select').removeAttr('disabled');
$(this).parents('form').find('.filter-select').attr('disabled','disabled');
$(this).parents('form').find('.dash_form_designer_record_container').css('display', 'none');
$(this).parents('form').find('.dash_form_designer_url_container').css('display', 'none');
} else if ($(this).val()=='-2') {
$(this).parents('form').find('.language-select').attr('disabled','disabled');
$(this).parents('form').find('.filter-select').attr('disabled','disabled');
$(this).parents('form').find('.dash_form_designer_record_container').css('display', 'block');
$(this).parents('form').find('.dash_form_designer_url_container').css('display', 'none');
} else if ($(this).val()=='-3') {
$(this).parents('form').find('.language-select').removeAttr('disabled');
$(this).parents('form').find('.filter-select').removeAttr('disabled');
$(this).parents('form').find('.dash_form_designer_record_container').css('display', 'none');
$(this).parents('form').find('.dash_form_designer_url_container').css('display', 'block');
} else {
$(this).parents('form').find('.language-select').removeAttr('disabled');
$(this).parents('form').find('.filter-select').removeAttr('disabled');
$(this).parents('form').find('.dash_form_designer_record_container').css('display', 'none');
$(this).parents('form').find('.dash_form_designer_url_container').css('display', 'none');
}
};
var designer_designer_open = function() {
if (typeof(designerWindows)=="undefined") designerWindows = {};
designerWindows[this.getId()] = this;
};
var designer_designer_load = function() {
if (typeof(this.options.data.items)=="undefined" || this.options.data.items.length!=1) return;
var item = this.options.data.items[0];
this.setBodyFullContent('<iframe src="'+designer_layout_url+'&id='+item+'#'+this.getId()+'" width="100%" height="100%" style="border:none;margin:0;padding:0"></iframe><form style="display:none"><textarea name="content"></textarea><input type="hidden" name="item" /></form>');
};
var designer_designer_close = function() {
if (typeof(designerWindows)=="undefined") return;
designerWindows[this.getId()] = null;
};
var designer_designer_onsave = function() {
if (typeof(designerEditorWindow) == "undefined") return;
$(this.content).find('form textarea').val(designerEditorWindow.editorStyle());
if (typeof(this.options.data.items)!="undefined" && this.options.data.items.length==1) {
var item = this.options.data.items[0];
$(this.content).find('form input[type=hidden]').val(item);
}
};
var designer_designer_wnd = function() {
var selected = this.getSelectedContentItems();
if (selected && selected.length==1) {
var data = {'items':[selected[0].data]};
desk_call(designer_editor_wnd, null, {
'data':data
});
}
};

View file

@ -0,0 +1,64 @@
(function($){
$(document).ready(function(){
$('body').append('<div style="position:fixed;width:100%;height:100%;top:0;left:0;z-index:2499"></div>');
var container_left = $('#content').offset().left;
var colorpicker_size = 42;
// header bg color
if ($('header').length>0 && $('header').css('backgroundColor')!='transparent') {
var header_bg = $('header').css('backgroundColor');
var header_cx = $('header').offset().left+($('header').outerWidth()-colorpicker_size)/2;
var header_cy = $('header').offset().top+($('header').outerHeight()-colorpicker_size)/2;
$('body').append('<div class="designer_colorpicker" id="header-designer-colorpicker" title="'+t('Header background color')+'"></div>');
$('#header-designer-colorpicker').css({'left':header_cx,'top':header_cy});
$('#header-designer-colorpicker').tooltip();
designer_colorpicker($('#header-designer-colorpicker'), header_bg, function(color){
$('header').css('backgroundColor', color);
setBackgroundColorStyle('header', color);
});
}
});
var designer_colorpicker = function(element, init_color, callback) {
$(element).colorpicker({
customClass: 'colorpicker-2x',
sliders: {
saturation: { maxLeft: 200, maxTop: 200 },
hue: { maxTop: 200 },
alpha: { maxTop: 200 }
},
color: init_color
}).on('changeColor', zira_bind($(element), function(e) {
var color = e.color.toString('rgba');
if (typeof(callback)!="undefined") {
callback.call(this, color);
}
}));
};
var setBackgroundColorStyle = function(element, value) {
window.editorStyles[element] = 'background-color:' + value + ';';
};
$(window).keydown(function(e){
if (e.keyCode == 83 && e.ctrlKey) {
e.preventDefault();
e.stopPropagation();
var parentDesignerWindowId = window.location.hash.replace('#','');
if (parentDesignerWindowId.length>0 && typeof(parent.designerWindows[parentDesignerWindowId])!="undefined") {
parent.designerWindows[parentDesignerWindowId].saveBody();
}
}
});
window.editorStyles = {};
window.editorStyle = function() {
var content = '';
for (var prop in window.editorStyles) {
content += prop + '{' + window.editorStyles[prop] + '}';
}
return content;
};
parent.designerEditorWindow = window;
})(jQuery);

View file

@ -66,6 +66,13 @@ class Category extends Form
protected function _validate()
{
$name = trim($this->getValue('name'));
$title = trim($this->getValue('title'));
$this->updateValues(array(
'name' => $name,
'title' => $title
));
$validator = $this->getValidator();
$validator->registerCustom(array(get_class(), 'checkRoot'), 'root', Locale::t('An error occurred'));
$validator->registerString('name', null, 255, true, Locale::t('Invalid value "%s"',Locale::t('System name')));

View file

@ -76,6 +76,13 @@ class Record extends Form
protected function _validate()
{
$name = trim($this->getValue('name'));
$title = trim($this->getValue('title'));
$this->updateValues(array(
'name' => $name,
'title' => $title
));
$validator = $this->getValidator();
$validator->registerCustom(array(get_class(), 'checkLanguage'), 'language', Locale::t('An error occurred'));
$validator->registerCustom(array(get_class(), 'checkCategory'), 'category_id', Locale::t('An error occurred'));

View file

@ -38,14 +38,12 @@ class Widget extends Form
$_categories = array(
-1 => Locale::t('All pages'),
-2 => Locale::t('Choose page...'),
-3 => Locale::t('Set URL...'),
Zira\Category::ROOT_CATEGORY_ID => Locale::t('Home page')
);
$categories = $_categories + $categories;
$filter_attr = array('class'=>'form-control filter-select');
// if ($this->getValue('category_id') == Zira\Category::ROOT_CATEGORY_ID) {
// $filter_attr['disabled'] = 'disabled';
// }
$filters = array_merge(array(
'' => Locale::t('Do not apply filter')
@ -61,6 +59,10 @@ class Widget extends Form
$html .= $this->input(Locale::t('Choose page'),'record',array('class'=>'form-control dash_form_widget_record_input', 'placeholder'=>Zira\Locale::t('Enter page title or system name')));
$html .= Zira\Helper::tag_close('div');
$html .= Zira\Helper::tag_open('div', array('class'=>'dash_form_widget_url_container'));
$html .= $this->input(Locale::t('URL address'),'url',array('class'=>'form-control dash_form_widget_url_input'));
$html .= Zira\Helper::tag_close('div');
if (count(Zira\Config::get('languages'))<2) {
$html .= $this->hidden('language');
} else {
@ -82,6 +84,8 @@ class Widget extends Form
$validator->registerCustom(array(get_class(), 'checkPlaceholder'), 'placeholder', Locale::t('Invalid value "%s"',Locale::t('Placeholder')));
$validator->registerCustom(array(get_class(), 'checkCategory'), 'category_id', Locale::t('Invalid value "%s"',Locale::t('Page').' / '.Locale::t('Category')));
$validator->registerCustom(array(get_class(), 'checkFilter'), 'filter', Locale::t('Invalid value "%s"',Locale::t('Filter')));
$validator->registerNumber('record_id',null,null,false, Locale::t('Invalid value "%s"',Locale::t('Page').' / '.Locale::t('Category')));
$validator->registerString('url', null, 255, false, Locale::t('Invalid value "%s"',Locale::t('Page').' / '.Locale::t('Category')));
}
public static function checkLanguage($language) {
@ -97,7 +101,7 @@ class Widget extends Form
public static function checkCategory($category_id) {
$category_id = intval($category_id);
$categories = Zira\Models\Category::getArray();
return $category_id===-1 || $category_id===-2 || $category_id===0 || array_key_exists($category_id, $categories);
return $category_id===-1 || $category_id===-2 || $category_id===-3 || $category_id===0 || array_key_exists($category_id, $categories);
}
public static function checkFilter($filter) {

View file

@ -59,6 +59,9 @@ class Widget extends Model {
$record_id = intval($form->getValue('record_id'));
if ($record_id<=0) $record_id = null;
$widget->record_id = $record_id;
$url = trim($form->getValue('url'));
if (strlen($url)==0) $url = null;
$widget->url = $url;
$widget->placeholder = $form->getValue('placeholder');
$widget->active = intval($form->getValue('active')) ? Zira\Models\Widget::STATUS_ACTIVE : Zira\Models\Widget::STATUS_NOT_ACTIVE;
$widget->filter = $form->getValue('filter') ? $form->getValue('filter') : null;

View file

@ -33,7 +33,7 @@ class Widget extends Window {
);
$this->addVariables(array(
'dash_widget_autocomplete_url' => Zira\Helper::url('dash/widgets/autocompletepage'),
'dash_widget_autocomplete_url' => Zira\Helper::url('dash/widgets/autocompletepage')
));
$this->includeJS('dash/widget');
@ -66,6 +66,8 @@ class Widget extends Window {
$values['category_id'] = -2;
$record = new Zira\Models\Record($values['record_id']);
if ($record->loaded()) $values['record'] = $record->title;
} else if (strlen($values['url'])>0) {
$values['category_id'] = -3;
}
if ($values['language']!==null && !in_array($values['language'],Zira\Config::get('languages'))) {
$values['language'] = null;

View file

@ -92,6 +92,9 @@ abstract class Window {
public function __construct() {
$this->_js_name = Dash\Dash::getInstance()->getWindowJSName(self::getClass());
if (empty($this->_js_name)) throw new \Exception('Failed to construct window: ' . self::getClass());
$maximized = (bool)Config::get('dashwindow_maximized');
$this->setMaximized($maximized);
}
public function build() {
@ -204,9 +207,6 @@ abstract class Window {
$classic_mode = (bool)Config::get('dashwindow_mode');
$this->setOption('classic_mode', $classic_mode);
$maximized = (bool)Config::get('dashwindow_maximized');
$this->setMaximized($maximized);
$this->create();

View file

@ -0,0 +1,91 @@
<?php
/**
* Zira project.
* dash.php
* (c)2017 http://dro1d.ru
*/
namespace Designer\Controllers;
use Zira;
use Designer;
class Dash extends \Dash\Controller {
public function _before() {
parent::_before();
Zira\View::setAjax(true);
}
public function layout() {
if (!\Dash\Dash::isFrame()) Zira\Response::forbidden();
if (!Zira\Permission::check(Zira\Permission::TO_CHANGE_LAYOUT)) {
return array('error' => Zira\Locale::t('Permission denied'));
}
$id = (int)Zira\Request::get('id');
if (!$id) Zira\Response::notFound();
$style = new Designer\Models\Style($id);
if (!$style->loaded()) Zira\Response::notFound();
Zira\View::setAjax(false);
Zira\View::setRenderDbWidgets(false);
Zira\Assets::setActive(false);
$layout_data = &Zira\View::getLayoutDataArray();
unset($layout_data[Zira\View::VAR_STYLES]);
unset($layout_data[Zira\View::VAR_SCRIPTS]);
$body_bottom_scrips = &Zira\View::getBodyBottomScriptsArray();
$body_bottom_scrips = array();
Zira\View::addStyle('bootstrap.min.css');
Zira\View::addStyle('bootstrap-theme.min.css');
Zira\View::addScript('jquery.min.js');
Zira\View::addScript('bootstrap.min.js');
Zira\View::addCoreStyles();
Zira\View::addCoreScripts();
Zira\View::addStyle('designer/editor.css');
Zira\View::addScript('designer/editor.js');
Zira\View::addSlider('slider', array(
'auto' => true,
'speed' => 500,
'pause' => 8000,
'captions' => true,
'slideMargin' => 0,
'adaptiveHeight' => false
));
Zira\View::addColorpickerAssets();
$css = Zira\Helper::tag_open('style');
$css .= $style->content;
$css .= Zira\Helper::tag_close('style');
Zira\View::addHTML($css, Zira\View::VAR_HEAD_BOTTOM);
Zira\Router::setModule(DEFAULT_MODULE);
Zira\Router::setController(DEFAULT_CONTROLLER);
Zira\Router::setAction(DEFAULT_ACTION);
Zira\View::render(array(), 'designer/page', 'designer/layout');
}
public function autocompletepage() {
if (Zira\Request::isPost()) {
$search = Zira\Request::post('search');
$window = new Designer\Windows\Style();
$windowModel = new Designer\Models\Styles($window);
$response = $windowModel->autoCompletePage($search);
Zira\Page::render($response);
}
}
public function copy() {
if (Zira\Request::isPost()) {
$title = Zira\Request::post('title');
$item = Zira\Request::post('item');
$window = new Designer\Windows\Styles();
$windowModel = new Designer\Models\Styles($window);
$response = $windowModel->copy($item, $title);
Zira\Page::render($response);
}
}
}

119
designer/designer.php Normal file
View file

@ -0,0 +1,119 @@
<?php
/**
* Zira project.
* designer.php
* (c)2017 http://dro1d.ru
*/
namespace Designer;
use Zira;
use Dash;
class Designer {
private static $_instance;
const CACHE_KEY = 'designer';
public static function getInstance() {
if (self::$_instance === null) {
self::$_instance = new self();
}
return self::$_instance;
}
public function bootstrap() {
if (ENABLE_CONFIG_DATABASE && Dash\Dash::getInstance()->isPanelEnabled() && Zira\Permission::check(Zira\Permission::TO_ACCESS_DASHBOARD) && Zira\Permission::check(Zira\Permission::TO_CHANGE_LAYOUT)) {
Dash\Dash::loadDashLanguage();
Dash\Dash::getInstance()->addPanelModulesGroupItem('glyphicon glyphicon-picture', Zira\Locale::tm('Themes designer', 'designer', null, Dash\Dash::getDashLanguage()), null, 'stylesWindow()');
Dash\Dash::getInstance()->registerModuleWindowClass('stylesWindow', 'Designer\Windows\Styles', 'Designer\Models\Styles');
Dash\Dash::getInstance()->registerModuleWindowClass('styleWindow', 'Designer\Windows\Style', 'Designer\Models\Styles');
Dash\Dash::getInstance()->registerModuleWindowClass('designerWindow', 'Designer\Windows\Designer', 'Designer\Models\Designer');
Dash\Dash::unloadDashLanguage();
}
if (Zira\Router::getModule() != 'designer' && Zira\Router::getModule() != 'dash') {
Zira\View::registerRenderHook($this, 'applyStyle');
}
}
public static function applyStyle() {
$styles = Zira\Cache::getObject(self::CACHE_KEY.'.'.Zira\Locale::getLanguage());
if (!$styles) {
$styles = \Designer\Models\Style::getCollection()
->open_query()
->where('language','is',null)
->and_where('active', '=', 1)
->order_by('date_created', 'DESC')
->close_query()
->union()
->open_query()
->where('language','=',Zira\Locale::getLanguage())
->and_where('active', '=', 1)
->order_by('date_created', 'DESC')
->close_query()
->merge()
->order_by('date_created', 'DESC')
->get();
Zira\Cache::setObject(self::CACHE_KEY.'.'.Zira\Locale::getLanguage(), $styles);
}
$active_style = null;
$category_id = null;
if (!Zira\Router::getRequest()) {
$category_id = Zira\Category::ROOT_CATEGORY_ID;
} else if (Zira\Category::current()) {
$chain = Zira\Category::chain();
$category_id = array();
foreach($chain as $row) {
$category_id[]=$row->id;
}
}
foreach ($styles as $style) {
if ($style->category_id!==null) {
if (!is_array($category_id) && $style->category_id!=$category_id) continue;
else if (is_array($category_id) && !in_array($style->category_id,$category_id)) continue;
}
if ($style->record_id && $style->record_id!=Zira\Page::getRecordId()) continue;
if ($style->url && strlen($style->url)>0) {
$request = urldecode(Zira\Router::getRequest());
if ($style->url != $request && (
strlen($style->url)<=2 ||
substr($style->url, -2) != '/*'
)) continue;
if ($style->url != $request && (
strlen($style->url)<=2 ||
substr($style->url, -2) != '/*' ||
mb_strpos($request.'/', substr($style->url, 0, strlen($style->url)-1), 0, CHARSET)!==0
)) continue;
}
if ($style->filter && ((
$style->filter == \Designer\Models\Style::STATUS_FILTER_RECORD &&
Zira\Page::getRecordId()===null
) || (
$style->filter == \Designer\Models\Style::STATUS_FILTER_CATEGORY &&
(!Zira\Category::current() || Zira\Category::param() || Zira\Page::getRecordId()!==null)
) || (
$style->filter == \Designer\Models\Style::STATUS_FILTER_CATEGORY_AND_RECORD &&
!Zira\Category::current() && Zira\Page::getRecordId()===null
))) {
continue;
}
$active_style = $style;
break;
}
if (!$active_style) return;
$html = Zira\Helper::tag_open('style');
$html .= $active_style->content;
$html .= Zira\Helper::tag_close('style');
Zira\View::addHTML($html, Zira\View::VAR_HEAD_BOTTOM);
}
}

105
designer/forms/style.php Normal file
View file

@ -0,0 +1,105 @@
<?php
/**
* Zira project.
* style.php
* (c)2017 http://dro1d.ru
*/
namespace Designer\Forms;
use Zira;
use Zira\Form;
use Zira\Locale;
class Style extends Form
{
protected $_id = 'designer-style-form';
protected $_label_class = 'col-sm-4 control-label';
protected $_input_wrap_class = 'col-sm-8';
protected $_input_offset_wrap_class = 'col-sm-offset-4 col-sm-8';
protected $_select_wrapper_class = 'col-sm-8';
public function __construct()
{
parent::__construct($this->_id);
}
protected function _init()
{
$this->setRenderPanel(false);
$this->setFormClass('form-horizontal dash-window-form');
}
protected function _render()
{
$categories = Zira\Models\Category::getArray();
$_categories = array(
-1 => Locale::t('All pages'),
-2 => Locale::t('Choose page...'),
-3 => Locale::t('Set URL...'),
Zira\Category::ROOT_CATEGORY_ID => Locale::t('Home page')
);
$categories = $_categories + $categories;
$filter_attr = array('class'=>'form-control filter-select');
$filters = array_merge(array(
'' => Locale::t('Do not apply filter')
), \Designer\Models\Style::getFiltersArray());
$html = $this->open();
$html .= $this->hidden('id');
$html .= $this->input(Locale::t('Title') . '*', 'title');
$html .= $this->select(Locale::t('Page').' / '.Locale::t('Category').'*','category_id',$categories, array('class'=>'form-control dash_form_designer_record_select'));
$html .= $this->hidden('record_id', array('class'=>'dash_form_designer_record_hidden'));
$html .= Zira\Helper::tag_open('div', array('class'=>'dash_form_designer_record_container'));
$html .= $this->input(Locale::t('Choose page'),'record',array('class'=>'form-control dash_form_designer_record_input', 'placeholder'=>Zira\Locale::t('Enter page title or system name')));
$html .= Zira\Helper::tag_close('div');
$html .= Zira\Helper::tag_open('div', array('class'=>'dash_form_designer_url_container'));
$html .= $this->input(Locale::t('URL address'),'url',array('class'=>'form-control dash_form_designer_url_input'));
$html .= Zira\Helper::tag_close('div');
if (count(Zira\Config::get('languages'))<2) {
$html .= $this->hidden('language');
} else {
$languagesArr = array_merge(array(''=>Locale::t('All languages')), Locale::getLanguagesArray());
$html .= $this->select(Locale::t('Language').'*','language',$languagesArr, array('class'=>'form-control language-select'));
}
$html .= $this->select(Locale::t('Filter'),'filter',$filters, $filter_attr);
$html .= $this->checkbox(Locale::t('active'), 'active', null, false);
$html .= $this->close();
return $html;
}
protected function _validate()
{
$validator = $this->getValidator();
$validator->registerString('title', null, 255, true, Locale::t('Invalid value "%s"',Locale::t('Title')));
$validator->registerUtf8('title', Locale::t('Invalid value "%s"',Locale::t('Title')));
$validator->registerCustom(array(get_class(), 'checkLanguage'), 'language', Locale::t('An error occurred'));
$validator->registerNumber('category_id',null,null,true, Locale::t('Invalid value "%s"',Locale::t('Page').' / '.Locale::t('Category')));
$validator->registerCustom(array(get_class(), 'checkCategory'), 'category_id', Locale::t('Invalid value "%s"',Locale::t('Page').' / '.Locale::t('Category')));
$validator->registerCustom(array(get_class(), 'checkFilter'), 'filter', Locale::t('Invalid value "%s"',Locale::t('Filter')));
$validator->registerNumber('record_id',null,null,false, Locale::t('Invalid value "%s"',Locale::t('Page').' / '.Locale::t('Category')));
$validator->registerString('url', null, 255, false, Locale::t('Invalid value "%s"',Locale::t('Page').' / '.Locale::t('Category')));
}
public static function checkLanguage($language) {
if (empty($language)) return true;
return in_array($language , Zira\Config::get('languages'));
}
public static function checkCategory($category_id) {
$category_id = intval($category_id);
$categories = Zira\Models\Category::getArray();
return $category_id===-1 || $category_id===-2 || $category_id===-3 || $category_id===0 || array_key_exists($category_id, $categories);
}
public static function checkFilter($filter) {
if (empty($filter)) return true;
return array_key_exists($filter, \Designer\Models\Style::getFiltersArray());
}
}

View file

@ -0,0 +1,53 @@
<?php
/**
* Zira project.
* style.php
* (c)2017 http://dro1d.ru
*/
namespace Designer\Install;
use Zira\Db\Table;
use Zira\Db\Field;
class Style extends Table {
protected $_table = 'styles';
public function __construct() {
parent::__construct($this->_table);
}
public function getFields() {
return array(
'id' => Field::primary(),
'creator_id' => Field::int(true, true),
'title' => Field::string(true),
'content' => Field::text(),
'language' => Field::string(),
'category_id' => Field::int(false, true),
'record_id' => Field::int(false, true),
'url' => Field::string(),
'filter' => Field::string(),
'date_created' => Field::datetime(true),
'active' => Field::tinyint(true, true, 1)
);
}
public function getKeys() {
return array(
'search' => array('language', 'active', 'date_created')
);
}
public function getUnique() {
return array(
);
}
public function getDefaults() {
return array(
);
}
}

View file

@ -0,0 +1,35 @@
<?php
/**
* Zira project.
* designer.php
* (c)2017 http://dro1d.ru
*/
namespace Designer\Models;
use Zira;
use Dash;
use Zira\Permission;
class Designer extends Dash\Models\Model {
public function save($data) {
if (!Permission::check(Permission::TO_CHANGE_LAYOUT)) {
return array('error' => Zira\Locale::t('Permission denied'));
}
$id = (int)Zira\Request::post('item');
if (!$id) return array('error' => Zira\Locale::t('An error occurred'));
$content = trim(strip_tags(Zira\Request::post('content')));
$style = new \Designer\Models\Style($id);
if (!$style->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
$style->content = $content;
$style->save();
Zira\Cache::clear();
return array('message'=>Zira\Locale::t('Successfully saved'));
}
}

45
designer/models/style.php Normal file
View file

@ -0,0 +1,45 @@
<?php
/**
* Zira project.
* style.php
* (c)2017 http://dro1d.ru
*/
namespace Designer\Models;
use Zira\Orm;
use Zira\Locale;
class Style extends Orm {
public static $table = 'styles';
public static $pk = 'id';
public static $alias = 'stls';
const STATUS_FILTER_RECORD = 'record';
const STATUS_FILTER_CATEGORY = 'category';
const STATUS_FILTER_CATEGORY_AND_RECORD = 'category_record';
public static function getTable() {
return self::$table;
}
public static function getPk() {
return self::$pk;
}
public static function getAlias() {
return self::$alias;
}
public static function getReferences() {
return array();
}
public static function getFiltersArray() {
return array(
self::STATUS_FILTER_CATEGORY => Locale::t('Display on category page only'),
self::STATUS_FILTER_RECORD => Locale::t('Display on record page only'),
self::STATUS_FILTER_CATEGORY_AND_RECORD => Locale::t('Display on category and record pages only')
);
}
}

139
designer/models/styles.php Normal file
View file

@ -0,0 +1,139 @@
<?php
/**
* Zira project.
* styles.php
* (c)2017 http://dro1d.ru
*/
namespace Designer\Models;
use Zira;
use Dash;
use Designer;
use Zira\Permission;
class Styles extends Dash\Models\Model {
public function save($data) {
if (!Permission::check(Permission::TO_CHANGE_LAYOUT)) {
return array('error' => Zira\Locale::t('Permission denied'));
}
$form = new Designer\Forms\Style();
if ($form->isValid()) {
$id = (int)$form->getValue('id');
if ($id) {
$style = new Designer\Models\Style($id);
if (!$style->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
} else {
$style = new Designer\Models\Style();
$style->creator_id = Zira\User::getCurrent()->id;
$style->date_created = date('Y-m-d H:i:s');
}
$style->title = $form->getValue('title');
$language = $form->getValue('language');
if (empty($language)) $language = null;
$style->language = $language;
$category_id = intval($form->getValue('category_id'));
if ($category_id<0) $category_id = null;
else if ($category_id==0) $category_id = Zira\Category::ROOT_CATEGORY_ID;
$style->category_id = $category_id;
$record_id = intval($form->getValue('record_id'));
if ($record_id<=0) $record_id = null;
$style->record_id = $record_id;
$url = trim($form->getValue('url'));
if (strlen($url)==0) $url = null;
$style->url = $url;
$style->filter = $form->getValue('filter') ? $form->getValue('filter') : null;
$style->active = (int)$form->getValue('active') ? 1 : 0;
$style->save();
Zira\Cache::clear();
return array('message'=>Zira\Locale::t('Successfully saved'), 'close'=>true);
} else {
return array('error'=>$form->getError());
}
}
public function delete($data) {
if (empty($data) || !is_array($data)) return array('error' => Zira\Locale::t('An error occurred'));
if (!Permission::check(Permission::TO_CHANGE_LAYOUT)) {
return array('error'=>Zira\Locale::t('Permission denied'));
}
foreach($data as $style_id) {
$style = new Designer\Models\Style($style_id);
if (!$style->loaded()) {
return array('error' => Zira\Locale::t('An error occurred'));
}
$style->delete();
}
Zira\Cache::clear();
return array('reload' => $this->getJSClassName());
}
public function copy($id, $title) {
if (!Permission::check(Permission::TO_CHANGE_LAYOUT)) {
return array('error' => Zira\Locale::t('Permission denied'));
}
$style = new Designer\Models\Style($id);
if (!$style->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
$values = $style->toArray();
unset($values['id']);
$values['title'] = $title;
$values['active'] = 0;
$newStyle = new Designer\Models\Style();
$newStyle->loadFromArray($values);
$newStyle->save();
return array('reload'=>$this->getJSClassName());
}
public function autoCompletePage($search) {
if (empty($search)) return array();
if (!Permission::check(Permission::TO_CHANGE_LAYOUT)) {
return array('error'=>Zira\Locale::t('Permission denied'));
}
$records = Zira\Models\Record::getCollection()
->open_query()
->select('id', 'title')
->left_join(Zira\Models\Category::getClass(), array('category_title'=>'title'))
->where('title', 'like', $search.'%')
->limit(5)
->order_by('id', 'DESC')
->close_query()
->union()
->open_query()
->select('id', 'title')
->left_join(Zira\Models\Category::getClass(), array('category_title'=>'title'))
->where('name', 'like', $search.'%')
->limit(5)
->order_by('id', 'DESC')
->close_query()
->merge()
->limit(5)
->order_by('id', 'DESC')
->get();
$results = array();
foreach($records as $record) {
$title = $record->title;
if (!empty($record->category_title)) $title = $record->category_title.' / '.$record->title;
$results []= array(
'record_id' => $record->id,
'record_title' => $record->title,
'title' => $title
);
}
return $results;
}
}

5
designer/module.meta Normal file
View file

@ -0,0 +1,5 @@
[meta]
name = Themes designer
description = Create your own theme
author = Zira
version = 1.0

View file

@ -0,0 +1,71 @@
<?php
/**
* Zira project.
* designer.php
* (c)2017 http://dro1d.ru
*/
namespace Designer\Windows;
use Zira;
use Dash;
use Zira\Permission;
class Designer extends Dash\Windows\Window {
protected static $_icon_class = 'glyphicon glyphicon-picture';
protected static $_title = 'Style editor';
//protected $_help_url = 'zira/help/designer';
public $item;
public function init() {
$this->setIconClass(self::$_icon_class);
$this->setTitle(Zira\Locale::t(self::$_title));
$this->setSidebarEnabled(false);
$this->setMaximized(true);
$this->setSaveActionEnabled(true);
}
public function create() {
$this->setOnOpenJSCallback(
$this->createJSCallback(
'desk_call(designer_designer_open, this);'
)
);
$this->setOnLoadJSCallback(
$this->createJSCallback(
'desk_call(designer_designer_load, this);'
)
);
$this->setOnUpdateContentJSCallback(
$this->createJSCallback(
'desk_call(designer_designer_onsave, this);'
)
);
$this->setOnCloseJSCallback(
$this->createJSCallback(
'desk_call(designer_designer_close, this);'
)
);
}
public function load() {
if (!empty($this->item)) $this->item=intval($this->item);
else return array('error' => Zira\Locale::t('An error occurred'));
if (!Permission::check(Permission::TO_CHANGE_LAYOUT)) {
return array('error' => Zira\Locale::t('Permission denied'));
}
$style = new \Designer\Models\Style($this->item);
if (!$style->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
$this->setTitle(Zira\Locale::tm(self::$_title,'designer').' - '.$style->title);
$content = '';
$this->setBodyContent($content);
}
}

View file

@ -0,0 +1,77 @@
<?php
/**
* Zira project.
* style.php
* (c)2017 http://dro1d.ru
*/
namespace Designer\Windows;
use Zira;
use Dash;
use Zira\Permission;
class Style extends Dash\Windows\Window {
protected static $_icon_class = 'glyphicon glyphicon-picture';
protected static $_title = 'Style';
//protected $_help_url = 'zira/help/style';
public $item;
public function init() {
$this->setIconClass(self::$_icon_class);
$this->setTitle(Zira\Locale::t(self::$_title));
$this->setSidebarEnabled(false);
$this->setSaveActionEnabled(true);
}
public function create() {
$this->setOnLoadJSCallback(
$this->createJSCallback(
'desk_call(designer_style_load, this);'
)
);
}
public function load() {
if (!empty($this->item)) $this->item=intval($this->item);
if (!Permission::check(Permission::TO_CHANGE_LAYOUT)) {
return array('error' => Zira\Locale::t('Permission denied'));
}
$form = new \Designer\Forms\Style();
if (!empty($this->item)) {
$style = new \Designer\Models\Style($this->item);
if (!$style->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
$values = $style->toArray();
if ($values['category_id']===null) {
$values['category_id'] = -1;
}
if ($values['record_id']>0) {
$values['category_id'] = -2;
$record = new Zira\Models\Record($values['record_id']);
if ($record->loaded()) $values['record'] = $record->title;
} else if (strlen($values['url'])>0) {
$values['category_id'] = -3;
}
if ($values['language']!==null && !in_array($values['language'],Zira\Config::get('languages'))) {
$values['language'] = null;
}
$form->setValues($values);
$this->setTitle(Zira\Locale::tm(self::$_title,'designer').' - '.$style->title);
} else {
$form->setValues(array(
'category_id' => -1,
'active' => 1
));
$this->setTitle(Zira\Locale::tm('New style','designer'));
}
$this->setBodyContent($form);
}
}

View file

@ -0,0 +1,89 @@
<?php
/**
* Zira project.
* styles.php
* (c)2017 http://dro1d.ru
*/
namespace Designer\Windows;
use Dash;
use Zira;
use Designer;
use Zira\Permission;
class Styles extends Dash\Windows\Window {
protected static $_icon_class = 'glyphicon glyphicon-picture';
protected static $_title = 'Themes designer';
//protected $_help_url = 'zira/help/styles';
public function init() {
$this->setIconClass(self::$_icon_class);
$this->setTitle(Zira\Locale::t(self::$_title));
$this->setViewSwitcherEnabled(false);
$this->setSelectionLinksEnabled(true);
$this->setBodyViewListVertical(true);
$this->setCreateActionWindowClass(Designer\Windows\Style::getClass());
$this->setEditActionWindowClass(Designer\Windows\Style::getClass());
$this->setDeleteActionEnabled(true);
}
public function create() {
$this->addDefaultMenuDropdownItem(
$this->createMenuDropdownSeparator()
);
$this->addDefaultMenuDropdownItem(
$this->createMenuDropdownItem(Zira\Locale::t('Copy'), 'glyphicon glyphicon-duplicate', 'desk_call(designer_styles_copy, this);', 'edit', true)
);
$this->addDefaultMenuDropdownItem(
$this->createMenuDropdownSeparator()
);
$this->addDefaultMenuDropdownItem(
$this->createMenuDropdownItem(Zira\Locale::t('Style editor'), 'glyphicon glyphicon-eye-open', 'desk_call(designer_designer_wnd, this);', 'edit', true)
);
$this->addDefaultContextMenuItem(
$this->createContextMenuSeparator()
);
$this->addDefaultContextMenuItem(
$this->createContextMenuItem(Zira\Locale::t('Copy'), 'glyphicon glyphicon-duplicate', 'desk_call(designer_styles_copy, this);', 'edit', true)
);
$this->addDefaultContextMenuItem(
$this->createContextMenuSeparator()
);
$this->addDefaultContextMenuItem(
$this->createContextMenuItem(Zira\Locale::t('Style editor'), 'glyphicon glyphicon-eye-open', 'desk_call(designer_designer_wnd, this);', 'edit', true)
);
$this->addDefaultOnLoadScript('desk_call(designer_styles_load, this);');
$this->addStrings(array(
'Enter title'
));
$this->addVariables(array(
'designer_style_autocomplete_url' => Zira\Helper::url('designer/dash/autocompletepage'),
'designer_layout_url' => Zira\Helper::url('designer/dash/layout?'.Dash\Dash::GET_FRAME_PARAM.'='.Dash\Dash::GET_FRAME_VALUE),
'designer_editor_wnd' => Dash\Dash::getInstance()->getWindowJSName(Designer\Windows\Designer::getClass())
));
$this->includeJS('designer/dash');
}
public function load() {
if (!Permission::check(Permission::TO_CHANGE_LAYOUT)) {
$this->setBodyItems(array());
return array('error'=>Zira\Locale::t('Permission denied'));
}
$styles = Designer\Models\Style::getCollection()->get();
$items = array();
foreach($styles as $style) {
$items[]=$this->createBodyFileItem($style->title, $style->url, $style->id, 'desk_call(designer_designer_wnd, this);', false, array('type'=>'html', 'inactive'=>$style->active ? 0 : 1));
}
$this->setBodyItems($items);
}
}

View file

@ -401,5 +401,6 @@ return array(
'Check for updates' => 'Проверять обновления',
'Choose page...' => 'Выбрать страницу...',
'Choose page' => 'Выберите страницу',
'Set URL...' => ' Задать URL...',
'Enter page title or system name' => 'Введите название страницы или системное имя'
);

View file

@ -0,0 +1,6 @@
<?php
return array(
'Header background color' => 'Цвет фона шапки'
);

10
languages/ru/designer.php Normal file
View file

@ -0,0 +1,10 @@
<?php
return array(
'Themes designer' => 'Дизайнер тем',
'Create your own theme' => 'Создайте свою собственную тему',
'Style' => 'Стиль',
'New style' => 'Новый стиль',
'Style editor' => 'Редактор стиля',
'Enter title' => 'Введите заголовок'
);

View file

@ -200,17 +200,6 @@ dt {
.alert a:visited {
color: #0A3241;
}
.alert-dark {
border-color: #323350;
background: #313458;
background-image: linear-gradient(to bottom,#446a77 0,#313458 100%);
filter: none;
color: #eee;
}
.alert-dark a:link,
.alert-dark a:visited {
color: #A0C4EC;
}
#main-container .btn-default {
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
text-shadow: none;

View file

@ -60,7 +60,7 @@
<?php endif; ?>
<?php if (empty($urls) && empty($embeds) && empty($access_allowed)): ?>
<div class="alert alert-warning alert-dark" role="alert">
<div class="alert alert-warning" role="alert">
<?php if (!Zira\User::isAuthorized()): ?>
<?php echo t('%s to listen to audio', '<a href="'.Zira\Helper::url('user/login?redirect='.Zira\Page::getRedirectUrl()).'">'.t('Login').'</a>') ?>
<?php else: ?>

View file

@ -40,7 +40,7 @@
<?php endif; ?>
<?php if (empty($files) && empty($access_allowed)): ?>
<div class="alert alert-warning alert-dark" role="alert">
<div class="alert alert-warning" role="alert">
<?php if (!Zira\User::isAuthorized()): ?>
<?php echo t('%s to download files', '<a href="'.Zira\Helper::url('user/login?redirect='.Zira\Page::getRedirectUrl()).'">'.t('Login').'</a>') ?>
<?php else: ?>

View file

@ -10,7 +10,7 @@
<?php endif; ?>
<?php if (empty($images) && empty($access_allowed)): ?>
<div class="alert alert-warning alert-dark" role="alert">
<div class="alert alert-warning" role="alert">
<?php if (!Zira\User::isAuthorized()): ?>
<?php echo t('%s to view gallery', '<a href="'.Zira\Helper::url('user/login?redirect='.Zira\Page::getRedirectUrl()).'">'.t('Login').'</a>') ?>
<?php else: ?>

View file

@ -70,7 +70,7 @@
<?php endif; ?>
<?php if (empty($urls) && empty($embeds) && empty($access_allowed)): ?>
<div class="alert alert-warning alert-dark" role="alert">
<div class="alert alert-warning" role="alert">
<?php if (!Zira\User::isAuthorized()): ?>
<?php echo t('%s to view video', '<a href="'.Zira\Helper::url('user/login?redirect='.Zira\Page::getRedirectUrl()).'">'.t('Login').'</a>') ?>
<?php else: ?>

View file

@ -0,0 +1,47 @@
<!DOCTYPE html>
<html itemscope itemtype="http://schema.org/WebPage" lang="<?php echo Zira\Locale::getLanguage() ?>">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="<?php echo Zira\Helper::baseUrl('favicon.ico') ?>" type="image/x-icon"/>
<link href="<?php echo Zira\Helper::url('rss', true, true) ?>" title="RSS" type="application/rss+xml" rel="alternate" />
<?php layout_head() ?>
</head>
<body>
<?php layout_body_top() ?>
<div id="main-container-wrapper"><div id="main-container">
<header>
<div class="container">
<div class="row">
<?php layout_header() ?>
</div>
</div>
</header>
<div class="container">
<div class="row">
<div id="content" class="col-sm-8">
<?php breadcrumbs(); ?>
<?php layout_content_top() ?>
<?php layout_content() ?>
<?php layout_content_bottom() ?>
</div>
<div class="col-sm-4 sidebar">
<aside>
<?php Zira\View::renderView(array(), 'designer/sidebar'); ?>
<?php layout_sidebar_right() ?>
</aside>
</div>
</div>
</div>
<footer>
<div class="container">
<div class="row">
<?php layout_footer() ?>
<a href="<?php echo Zira\Helper::url('rss'); ?>" target="_blank" class="rss-link" title="<?php echo t('RSS') ?>"></a>
</div>
</div>
</footer>
</div></div><!--/main-container-wrapper-->
<a href="javascript:void(0)" class="scroll-top" title="<?php echo t('Up') ?>"></a>
<?php layout_body_bottom() ?>
</body>
</html>

View file

@ -0,0 +1,246 @@
<!--record page-->
<main>
<article>
<div class="slider-wrapper">
<ul id="slider" class="slider">
<li><img class="image zira-lightbox" src="<?php echo Zira\Helper::baseUrl('assets/images/designer/image.jpg') ?>" title="Lorem ipsum dolor sit amet" /></li>
<li><img class="image zira-lightbox" src="<?php echo Zira\Helper::baseUrl('assets/images/designer/image.jpg') ?>" title="Lorem ipsum dolor sit amet" /></li>
</ul>
</div>
<div class="page-header">
<h1>Lorem ipsum dolor sit amet</h1>
</div>
<div class="article-info">
<div class="datetime">
<?php echo t('Last updated').': ' ?>
<time datetime="<?php echo date(DATE_W3C, time()) ?>" itemprop="dateModified"><?php echo date(Zira\Config::get('date_format'), time()) ?></time>
</div>
<div class="author">
<?php echo t('Author').': ' ?>
<?php echo Zira\Helper::tag('a', Zira\User::getProfileName(), array('href'=>Zira\Helper::url('user/'.Zira\User::getCurrent()->id))); ?>
</div>
</div>
<div class="article">
<p><a href="<?php echo Zira\Helper::url(''); ?>">Lorem ipsum</a> dolor sit amet, consectetur adipiscing elit. Etiam tempus nec eros in auctor. Fusce porttitor elementum enim, eu commodo tortor laoreet ac. Proin sed efficitur urna. Praesent non ex efficitur, accumsan diam id, mattis ipsum. Proin eget arcu sapien. Nulla pretium blandit rhoncus. Aenean mollis odio id ante imperdiet venenatis. Maecenas sed pulvinar est.</p>
<p>Donec laoreet lobortis tellus. Nullam iaculis in lacus non eleifend. Duis imperdiet odio eget nibh pulvinar eleifend vitae vitae tortor. Praesent ullamcorper lorem quis dictum blandit. Nulla id facilisis nunc, ut tempus neque. Aenean aliquet neque lorem, sit amet porttitor libero tincidunt id. Nulla ac orci eu sem dictum tincidunt. Phasellus volutpat odio et nunc porta, eget cursus odio viverra.</p>
</div>
<div id="rating" class="rating">
<a href="javascript:void(0)" class="like">
<span class="glyphicon glyphicon-thumbs-up"></span> <span class="rating-value">5</span>
</a>
</div>
</article>
</main>
<!--gallery-->
<div class="gallery-wrapper">
<h2><?php echo t('Gallery') ?></h2>
<ul class="gallery">
<li><a href="<?php echo Zira\Helper::baseUrl('assets/images/designer/image.jpg') ?>"><img src="<?php echo Zira\Helper::baseUrl('assets/images/designer/thumb.jpg') ?>" width="<?php echo Zira\Config::get('thumbs_width') ?>" height="<?php echo Zira\Config::get('thumbs_height') ?>" /></a></li>
<li><a href="<?php echo Zira\Helper::baseUrl('assets/images/designer/image.jpg') ?>"><img src="<?php echo Zira\Helper::baseUrl('assets/images/designer/thumb.jpg') ?>" width="<?php echo Zira\Config::get('thumbs_width') ?>" height="<?php echo Zira\Config::get('thumbs_height') ?>" /></a></li>
<li><a href="<?php echo Zira\Helper::baseUrl('assets/images/designer/image.jpg') ?>"><img src="<?php echo Zira\Helper::baseUrl('assets/images/designer/thumb.jpg') ?>" width="<?php echo Zira\Config::get('thumbs_width') ?>" height="<?php echo Zira\Config::get('thumbs_height') ?>" /></a></li>
<li><a href="<?php echo Zira\Helper::baseUrl('assets/images/designer/image.jpg') ?>"><img src="<?php echo Zira\Helper::baseUrl('assets/images/designer/thumb.jpg') ?>" width="<?php echo Zira\Config::get('thumbs_width') ?>" height="<?php echo Zira\Config::get('thumbs_height') ?>" /></a></li>
<li><a href="<?php echo Zira\Helper::baseUrl('assets/images/designer/image.jpg') ?>"><img src="<?php echo Zira\Helper::baseUrl('assets/images/designer/thumb.jpg') ?>" width="<?php echo Zira\Config::get('thumbs_width') ?>" height="<?php echo Zira\Config::get('thumbs_height') ?>" /></a></li>
<li><a href="<?php echo Zira\Helper::baseUrl('assets/images/designer/image.jpg') ?>"><img src="<?php echo Zira\Helper::baseUrl('assets/images/designer/thumb.jpg') ?>" width="<?php echo Zira\Config::get('thumbs_width') ?>" height="<?php echo Zira\Config::get('thumbs_height') ?>" /></a></li>
<li><a href="<?php echo Zira\Helper::baseUrl('assets/images/designer/image.jpg') ?>"><img src="<?php echo Zira\Helper::baseUrl('assets/images/designer/thumb.jpg') ?>" width="<?php echo Zira\Config::get('thumbs_width') ?>" height="<?php echo Zira\Config::get('thumbs_height') ?>" /></a></li>
<li><a href="<?php echo Zira\Helper::baseUrl('assets/images/designer/image.jpg') ?>"><img src="<?php echo Zira\Helper::baseUrl('assets/images/designer/thumb.jpg') ?>" width="<?php echo Zira\Config::get('thumbs_width') ?>" height="<?php echo Zira\Config::get('thumbs_height') ?>" /></a></li>
</ul>
</div>
<!--files-->
<div class="files-wrapper">
<ul class="files">
<li><a href="<?php echo Zira\Helper::url('') ?>"><?php echo t('File') ?></a> 1 kB</li>
<li><a href="<?php echo Zira\Helper::url('') ?>"><?php echo t('File') ?></a> 2 kB</li>
<li><a href="<?php echo Zira\Helper::url('') ?>"><?php echo t('File') ?></a> 3 kB</li>
<li><a href="<?php echo Zira\Helper::url('') ?>"><?php echo t('File') ?></a> 4 kB</li>
<li><a href="<?php echo Zira\Helper::url('') ?>"><?php echo t('File') ?></a> 5 kB</li>
</ul>
</div>
<!--messages-->
<div class="alert alert-warning" role="alert"><a href="<?php echo Zira\Helper::url('') ?>">Lorem ipsum</a> dolor sit amet, consectetur adipiscing elit. Etiam tempus nec eros in auctor.</div>
<div class="alert alert-danger" role="alert"><a href="<?php echo Zira\Helper::url('') ?>">Lorem ipsum</a> dolor sit amet, consectetur adipiscing elit. Etiam tempus nec eros in auctor.</div>
<!--comments-->
<div class="comments-wrapper">
<div class="btn-group comment-btn-group" role="group">
<button class="btn btn-primary comment-btn scroll-down" data-target="#comments-form"><?php echo t('Leave a comment') ?></button>
<button class="btn btn-default comments-reload" type="button"><span class="glyphicon glyphicon-refresh"></span></button>
</div>
<h2 id="comments"><?php echo t('Comments') ?>(99)</h2>
<ul class="comments">
<li class="comments-item">
<?php echo Zira\User::generateUserProfileThumb(null, null, array('class'=>'comment-avatar')) ?>
<span class="comment-head">
<a href="<?php echo Zira\Helper::url('') ?>"><?php echo t('Guest') ?></a></span>
<p class="comment-text parse-content parsed-content emoji-parsed-content">Lorem ipsum dolor sit amet</p>
<span class="comment-info">
<span class="glyphicon glyphicon-time"></span> <?php echo date(Zira\Config::get('date_format'), time()) ?> &nbsp;
<a href="javascript:void(0)" class="comment-rating comment-like">
<span class="glyphicon glyphicon-thumbs-up"></span>
<span class="rating-value">0</span>
</a> &nbsp;
<a href="javascript:void(0)" class="comment-rating comment-dislike">
<span class="glyphicon glyphicon-thumbs-down"></span>
<span class="rating-value">0</span>
</a> &nbsp;
</span>
</li>
<li class="comments-item comments-item-nested-1">
<?php echo Zira\User::generateUserProfileThumb(null, null, array('class'=>'comment-avatar')) ?>
<span class="comment-head">
<a href="<?php echo Zira\Helper::url('') ?>"><?php echo t('Guest') ?></a></span>
<p class="comment-text parse-content parsed-content emoji-parsed-content">Lorem ipsum dolor sit amet</p>
<span class="comment-info">
<span class="glyphicon glyphicon-time"></span> <?php echo date(Zira\Config::get('date_format'), time()) ?> &nbsp;
<a href="javascript:void(0)" class="comment-rating comment-like">
<span class="glyphicon glyphicon-thumbs-up"></span>
<span class="rating-value">0</span>
</a> &nbsp;
<a href="javascript:void(0)" class="comment-rating comment-dislike">
<span class="glyphicon glyphicon-thumbs-down"></span>
<span class="rating-value">0</span>
</a> &nbsp;
</span>
</li>
</ul>
<div class="comments-view-more-wrapper">
<button class="btn btn-primary comments-view-more" type="button" ><?php echo t('View more') ?>&nbsp;&rsaquo;&rsaquo;</button>
</div>
<div id="comments-form" class="comment-form-wrapper">
<?php echo new Zira\Forms\Comment(); ?>
</div>
</div>
<!--home page-->
<div class="home-category-wrapper grid-category-wrapper">
<div class="page-header">
<h2 class="home-category-title"><span class="glyphicon glyphicon-link"></span> Lorem ipsum</h2>
</div>
<ul class="list home-list">
<li class="list-item with-thumb">
<div class="list-title-wrapper">
<a class="list-title" href="<?php echo Zira\Helper::url('') ?>">Lorem ipsum dolor sit amet</a>
</div>
<div class="list-content-wrapper">
<a class="list-thumb" href="<?php echo Zira\Helper::url('') ?>">
<img src="<?php echo Zira\Helper::baseUrl('assets/images/designer/thumb.jpg') ?>" width="<?php echo Zira\Config::get('thumbs_width') ?>" height="<?php echo Zira\Config::get('thumbs_height') ?>" />
</a>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam tempus nec eros in auctor.</p>
</div>
<div class="list-info-wrapper">
<span class="list-info date"><span class="glyphicon glyphicon-time"></span> <?php echo date(Zira\Config::get('date_format'), time()) ?></span>
<span class="list-info comments-count"><span class="glyphicon glyphicon-comment"></span> 5</span>
<span class="list-info likes-count"><span class="glyphicon glyphicon-thumbs-up"></span> 5</span>
<span class="list-info category"><span class="glyphicon glyphicon-tag"></span> <a href="<?php echo Zira\Helper::url('') ?>">Lorem ipsum</a></span>
</div>
</li>
<li class="list-item with-thumb">
<div class="list-title-wrapper">
<a class="list-title" href="<?php echo Zira\Helper::url('') ?>">Lorem ipsum dolor sit amet</a>
</div>
<div class="list-content-wrapper">
<a class="list-thumb" href="<?php echo Zira\Helper::url('') ?>">
<img src="<?php echo Zira\Helper::baseUrl('assets/images/designer/thumb.jpg') ?>" width="<?php echo Zira\Config::get('thumbs_width') ?>" height="<?php echo Zira\Config::get('thumbs_height') ?>" />
</a>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam tempus nec eros in auctor.</p>
</div>
<div class="list-info-wrapper">
<span class="list-info date"><span class="glyphicon glyphicon-time"></span> <?php echo date(Zira\Config::get('date_format'), time()) ?></span>
<span class="list-info comments-count"><span class="glyphicon glyphicon-comment"></span> 5</span>
<span class="list-info likes-count"><span class="glyphicon glyphicon-thumbs-up"></span> 5</span>
<span class="list-info category"><span class="glyphicon glyphicon-tag"></span> <a href="<?php echo Zira\Helper::url('') ?>">Lorem ipsum</a></span>
</div>
</li>
<li class="list-item with-thumb">
<div class="list-title-wrapper">
<a class="list-title" href="<?php echo Zira\Helper::url('') ?>">Lorem ipsum dolor sit amet</a>
</div>
<div class="list-content-wrapper">
<a class="list-thumb" href="<?php echo Zira\Helper::url('') ?>">
<img src="<?php echo Zira\Helper::baseUrl('assets/images/designer/thumb.jpg') ?>" width="<?php echo Zira\Config::get('thumbs_width') ?>" height="<?php echo Zira\Config::get('thumbs_height') ?>" />
</a>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam tempus nec eros in auctor.</p>
</div>
<div class="list-info-wrapper">
<span class="list-info date"><span class="glyphicon glyphicon-time"></span> <?php echo date(Zira\Config::get('date_format'), time()) ?></span>
<span class="list-info comments-count"><span class="glyphicon glyphicon-comment"></span> 5</span>
<span class="list-info likes-count"><span class="glyphicon glyphicon-thumbs-up"></span> 5</span>
<span class="list-info category"><span class="glyphicon glyphicon-tag"></span> <a href="<?php echo Zira\Helper::url('') ?>">Lorem ipsum</a></span>
</div>
</li>
<li class="list-item with-thumb">
<div class="list-title-wrapper">
<a class="list-title" href="<?php echo Zira\Helper::url('') ?>">Lorem ipsum dolor sit amet</a>
</div>
<div class="list-content-wrapper">
<a class="list-thumb" href="<?php echo Zira\Helper::url('') ?>">
<img src="<?php echo Zira\Helper::baseUrl('assets/images/designer/thumb.jpg') ?>" width="<?php echo Zira\Config::get('thumbs_width') ?>" height="<?php echo Zira\Config::get('thumbs_height') ?>" />
</a>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam tempus nec eros in auctor.</p>
</div>
<div class="list-info-wrapper">
<span class="list-info date"><span class="glyphicon glyphicon-time"></span> <?php echo date(Zira\Config::get('date_format'), time()) ?></span>
<span class="list-info comments-count"><span class="glyphicon glyphicon-comment"></span> 5</span>
<span class="list-info likes-count"><span class="glyphicon glyphicon-thumbs-up"></span> 5</span>
<span class="list-info category"><span class="glyphicon glyphicon-tag"></span> <a href="<?php echo Zira\Helper::url('') ?>">Lorem ipsum</a></span>
</div>
</li>
</ul>
</div>
<!--category page-->
<div class="home-category-wrapper">
<div class="page-header">
<h2 class="home-category-title"><span class="glyphicon glyphicon-link"></span> Lorem ipsum</h2>
</div>
<ul class="list">
<li class="list-item with-thumb">
<div class="list-title-wrapper">
<a class="list-title" href="<?php echo Zira\Helper::url('') ?>">Lorem ipsum dolor sit amet</a>
</div>
<div class="list-content-wrapper">
<a class="list-thumb" href="<?php echo Zira\Helper::url('') ?>">
<img src="<?php echo Zira\Helper::baseUrl('assets/images/designer/thumb.jpg') ?>" width="<?php echo Zira\Config::get('thumbs_width') ?>" height="<?php echo Zira\Config::get('thumbs_height') ?>" />
</a>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam tempus nec eros in auctor.</p>
</div>
<div class="list-info-wrapper">
<span class="list-info date"><span class="glyphicon glyphicon-time"></span> <?php echo date(Zira\Config::get('date_format'), time()) ?></span>
<span class="list-info comments-count"><span class="glyphicon glyphicon-comment"></span> 5</span>
<span class="list-info likes-count"><span class="glyphicon glyphicon-thumbs-up"></span> 5</span>
<span class="list-info category"><span class="glyphicon glyphicon-tag"></span> <a href="<?php echo Zira\Helper::url('') ?>">Lorem ipsum</a></span>
</div>
</li>
<li class="list-item with-thumb">
<div class="list-title-wrapper">
<a class="list-title" href="<?php echo Zira\Helper::url('') ?>">Lorem ipsum dolor sit amet</a>
</div>
<div class="list-content-wrapper">
<a class="list-thumb" href="<?php echo Zira\Helper::url('') ?>">
<img src="<?php echo Zira\Helper::baseUrl('assets/images/designer/thumb.jpg') ?>" width="<?php echo Zira\Config::get('thumbs_width') ?>" height="<?php echo Zira\Config::get('thumbs_height') ?>" />
</a>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam tempus nec eros in auctor.</p>
</div>
<div class="list-info-wrapper">
<span class="list-info date"><span class="glyphicon glyphicon-time"></span> <?php echo date(Zira\Config::get('date_format'), time()) ?></span>
<span class="list-info comments-count"><span class="glyphicon glyphicon-comment"></span> 5</span>
<span class="list-info likes-count"><span class="glyphicon glyphicon-thumbs-up"></span> 5</span>
<span class="list-info category"><span class="glyphicon glyphicon-tag"></span> <a href="<?php echo Zira\Helper::url('') ?>">Lorem ipsum</a></span>
</div>
</li>
</ul>
<div class="list-pagination-wrapper">
<nav>
<ul class="pagination">
<li class="disabled"><span>«</span></li>
<li class="active"><span>1</span></li>
<li><a href="<?php echo Zira\Helper::url('') ?>">2</a></li>
<li><a href="<?php echo Zira\Helper::url('') ?>">3</a></li>
<li><a href="<?php echo Zira\Helper::url('') ?>">4</a></li>
<li><a href="<?php echo Zira\Helper::url('') ?>">5</a></li>
<li><a href="<?php echo Zira\Helper::url('') ?>">6</a></li>
<li><a href="<?php echo Zira\Helper::url('') ?>">7</a></li>
<li><a href="<?php echo Zira\Helper::url('') ?>">8</a></li>
<li><a href="<?php echo Zira\Helper::url('') ?>">9</a></li>
<li><a href="<?php echo Zira\Helper::url('') ?>">10</a></li>
<li><a href="<?php echo Zira\Helper::url('') ?>"><span>»</span></a></li>
</ul>
</nav>
</div>
</div>

View file

@ -0,0 +1,48 @@
<!--child menu-->
<div id="secondary-menu-wrapper">
<nav>
<ul class="nav nav-pills nav-stacked">
<li class="menu-item"><a href="<?php echo Zira\Helper::url('') ?>" class="menu-link">Lorem ipsum</a></li>
<li class="menu-item active"><a href="<?php echo Zira\Helper::url('') ?>" class="menu-link">Lorem ipsum</a></li>
<li class="menu-item"><a href="<?php echo Zira\Helper::url('') ?>" class="menu-link">Lorem ipsum</a></li>
</ul>
</nav>
</div>
<!--category widget-->
<div class="block">
<div class="page-header">
<h2 class="widget-title">Lorem ipsum</h2>
</div>
<ul class="widget-list list">
<li class="list-item with-thumb">
<h3 class="list-title-wrapper">
<a class="list-title" href="<?php echo Zira\Helper::url('') ?>">Lorem ipsum</a>
</h3>
<div class="list-content-wrapper">
<a class="list-thumb" href="<?php echo Zira\Helper::url('') ?>">
<img src="<?php echo Zira\Helper::baseUrl('assets/images/designer/thumb.jpg') ?>" width="<?php echo Zira\Config::get('thumbs_width') ?>" height="<?php echo Zira\Config::get('thumbs_height') ?>">
</a>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam tempus nec eros in auctor.</p>
</div>
<div class="list-info-wrapper">
<span class="list-info comments-count"><span class="glyphicon glyphicon-comment"></span> 5</span>
</div>
</li>
<li class="list-item with-thumb">
<h3 class="list-title-wrapper">
<a class="list-title" href="<?php echo Zira\Helper::url('') ?>">Lorem ipsum</a>
</h3>
<div class="list-content-wrapper">
<a class="list-thumb" href="<?php echo Zira\Helper::url('') ?>">
<img src="<?php echo Zira\Helper::baseUrl('assets/images/designer/thumb.jpg') ?>" width="<?php echo Zira\Config::get('thumbs_width') ?>" height="<?php echo Zira\Config::get('thumbs_height') ?>">
</a>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam tempus nec eros in auctor.</p>
</div>
<div class="list-info-wrapper">
<span class="list-info comments-count"><span class="glyphicon glyphicon-comment"></span> 5</span>
</div>
</li>
</ul>
</div>
<!--calendar widget-->
<?php echo (new Zira\Widgets\Calendar())->render(); ?>

7
update/v3/index.php Normal file
View file

@ -0,0 +1,7 @@
<?php
if (!defined('ZIRA_UPDATE') || !ZIRA_UPDATE) exit;
// adding new fields to widgets table
$alterWidgets = new \Update\V3\Widget();
$alterWidgets->execute();
Zira\Log::write('Updated widgets table');

20
update/v3/widget.php Normal file
View file

@ -0,0 +1,20 @@
<?php
namespace Update\V3;
use Zira\Db\Alter;
use Zira\Db\Field;
class Widget extends Alter {
protected $_table = 'widgets';
public function __construct() {
parent::__construct($this->_table);
}
public function getFieldsToAdd() {
return array(
'url' => Field::string()
);
}
}

View file

@ -30,7 +30,7 @@ class Xml extends Zira\Controller {
->where('language','=',Zira\Locale::getLanguage())
->and_where('published','=',Zira\Models\Record::STATUS_PUBLISHED)
->order_by('id','desc')
->limit(50000)
->limit(10000)
->get();
$urls = array();

View file

@ -137,9 +137,9 @@ class Validator {
protected function validateNumber(array $field) {
$value = $this->getValue($field);
if ($field['required'] && $value===null) return false;
if ($value!==null && !is_numeric($value)) return false;
if ($value!==null && $field['min']!==null && $value<$field['min']) return false;
if ($value!==null && $field['max']!==null && $value>$field['max']) return false;
if (!empty($value) && !is_numeric($value)) return false;
if (!empty($value) && $field['min']!==null && $value<$field['min']) return false;
if (!empty($value) && $field['max']!==null && $value>$field['max']) return false;
return true;
}

View file

@ -27,6 +27,7 @@ class Widget extends Table {
'language' => Field::string(),
'category_id' => Field::int(false, true),
'record_id' => Field::int(false, true),
'url' => Field::string(),
'sort_order' => Field::int(true, false, 0),
'active' => Field::tinyint(true, true, 0),
'filter' => Field::string()

View file

@ -20,7 +20,7 @@ class Category extends Orm {
public static $pk = 'id';
public static $alias = 'cat';
const REGEXP_NAME = '/^[a-zа]+[a-zа-я0-9_-]*$/u';
const REGEXP_NAME = '/^[a-zаё0-9_-]*[a-zа-яё]+[a-zаё0-9_-]*$/u';
public static function getTable() {
return self::$table;

View file

@ -15,7 +15,7 @@ class Record extends Orm {
const STATUS_FRONT_PAGE = 1;
const STATUS_NOT_FRONT_PAGE = 0;
const REGEXP_NAME = '/^[a-zа-яё]+[a-zа-яё0-9\._-]*$/ui';
const REGEXP_NAME = '/^[a-zа-яё0-9\._-]*[a-zа-яё]+[a-zа-яё0-9\._-]*$/ui';
public static $table = 'records';
public static $pk = 'id';

View file

@ -65,6 +65,8 @@ class View {
protected static $_codemirror_assets_added = false;
protected static $_codemirror_added = false;
protected static $_jplayer_assets_added = false;
protected static $_colorpicker_assets_added = false;
protected static $_colorpicker_added = false;
protected static $_render_js_strings = true;
protected static $_render_breadcrumbs = true;
@ -82,6 +84,7 @@ class View {
protected static $_db_widget_objects = null;
protected static $_body_bottom_scripts = array();
protected static $_before_render_callbacks = array();
public static function isInitialized() {
return self::$_theme !== null;
@ -180,9 +183,21 @@ class View {
public static function setDescriptionAdded($value) {
self::$_description_added = (bool)$value;
}
public static function registerRenderHook($object, $method) {
self::$_before_render_callbacks []= array($object, $method);
}
public static function render(array $data, $view=null, $layout=null) {
require_once(ROOT_DIR . DIRECTORY_SEPARATOR . 'zira' . DIRECTORY_SEPARATOR . 'tpl.php');
foreach(self::$_before_render_callbacks as $callback) {
try {
call_user_func($callback);
} catch (Exception $e) {
// ignore
}
}
if (!$view) {
$view = Router::getModule() . DIRECTORY_SEPARATOR .
@ -216,6 +231,13 @@ class View {
self::$_theme . DIRECTORY_SEPARATOR .
$layout . '.php';
if (self::$_theme!=DEFAULT_THEME && !file_exists($layout_file)) {
$layout_file = ROOT_DIR . DIRECTORY_SEPARATOR .
THEMES_DIR . DIRECTORY_SEPARATOR .
DEFAULT_THEME . DIRECTORY_SEPARATOR .
$layout . '.php';
}
$default_layouts = self::getDefaultLayouts();
if (!file_exists($layout_file) && !array_key_exists($layout, $default_layouts)) {
$layout_file = ROOT_DIR . DIRECTORY_SEPARATOR .
@ -224,13 +246,6 @@ class View {
self::LAYOUT_ALL_SIDEBARS . '.php';
}
if (self::$_theme!=DEFAULT_THEME && !file_exists($layout_file)) {
$layout_file = ROOT_DIR . DIRECTORY_SEPARATOR .
THEMES_DIR . DIRECTORY_SEPARATOR .
DEFAULT_THEME . DIRECTORY_SEPARATOR .
$layout . '.php';
}
self::$data = $data;
self::$view = $view_file;
self::$layout = $layout_file;
@ -426,6 +441,10 @@ class View {
if (empty(self::$_body_bottom_scripts)) return '';
return implode("\r\n", self::$_body_bottom_scripts);
}
public static function &getBodyBottomScriptsArray() {
return self::$_body_bottom_scripts;
}
public static function getTheme() {
return self::$_theme;
@ -557,7 +576,7 @@ class View {
self::addSliderAssets();
$script = Helper::tag_open('script',array('type'=>'text/javascript'));
$script .= 'jQuery(document).ready(function(){ ';
$script .= '$(\'#'.Helper::html($id).'\').bxSlider({';
$script .= 'jQuery(\'#'.Helper::html($id).'\').bxSlider({';
if ($options) {
$_options = array();
foreach($options as $k=>$v) {
@ -589,7 +608,7 @@ class View {
self::addCropperAssets();
$script = Helper::tag_open('script',array('type'=>'text/javascript'));
$script .= 'jQuery(document).ready(function(){ ';
$script .= '$(\'img#'.Helper::html($id).'\').cropper({';
$script .= 'jQuery(\'img#'.Helper::html($id).'\').cropper({';
if ($options) {
$_options = array();
foreach($options as $k=>$v) {
@ -782,6 +801,32 @@ class View {
self::addBodyBottomScript($script);
}
public static function addColorpickerAssets() {
if (self::$_colorpicker_assets_added) return;
self::addStyle('bootstrap-colorpicker.min.css');
self::addScript('bootstrap-colorpicker.min.js');
self::$_colorpicker_assets_added = true;
}
public static function addColorpicker() {
if (self::$_colorpicker_added) return;
self::addColorpickerAssets();
$script = Helper::tag_open('script',array('type'=>'text/javascript'));
$script .= 'jQuery(document).ready(function(){ ';
$script .= 'jQuery(\'.zira-colorpicker\').each(function(){';
$script .= 'jQuery(this).colorpicker().on(\'changeColor\', zira_bind(this, function(e) {';
$script .= 'var color = e.color.toString(\'rgba\');';
$script .= 'jQuery(this).data(\'color\', color);';
$script .= 'jQuery(this).trigger(\'change\');';
$script .= '}));';
$script .= '});';
$script .= '});';
$script .= Helper::tag_close('script');
//self::addHTML($script, self::VAR_HEAD_BOTTOM);
self::addBodyBottomScript($script);
self::$_colorpicker_added = true;
}
protected static function _generateJPlayerPlaylist($files, $media_type, &$formats, $poster = null) {
$media = array();
foreach($files as $file) {
@ -989,6 +1034,18 @@ class View {
try {
if (!self::$_render_db_widgets && !in_array($_widget->name, $defaultDbWidgets)) continue;
if ($_widget->record_id && $_widget->record_id!=Page::getRecordId()) continue;
if ($_widget->url && strlen($_widget->url)>0) {
$request = urldecode(Router::getRequest());
if ($_widget->url != $request && (
strlen($_widget->url)<=2 ||
substr($_widget->url, -2) != '/*'
)) continue;
if ($_widget->url != $request && (
strlen($_widget->url)<=2 ||
substr($_widget->url, -2) != '/*' ||
mb_strpos($request.'/', substr($_widget->url, 0, strlen($_widget->url)-1), 0, CHARSET)!==0
)) continue;
}
if ($_widget->filter && ((
$_widget->filter == Models\Widget::STATUS_FILTER_RECORD &&
Page::getRecordId()===null

View file

@ -10,7 +10,7 @@ namespace Zira;
use Dash\Dash;
class Zira {
const VERSION = '1.0.1';
const VERSION = '1.1.0';
private static $_instance;
public static function getInstance() {