slider urls

This commit is contained in:
Dro1d.Ru 2018-05-07 16:30:52 +05:00
parent 8641b6fc63
commit a6fe87b43e
12 changed files with 104 additions and 8 deletions

View file

@ -21,6 +21,10 @@
*zoom: 1;
}
.bx-wrapper a {
display: block;
}
.bx-wrapper img {
max-width: 100%;
display: block;

View file

@ -37,4 +37,14 @@ var dash_recordslides_add = function() {
if (images.length==0) return;
desk_window_request(this, url('dash/records/addslide'),{'images':images, 'item':this.options.data.items[0]});
}));
};
var dash_recordslides_link = function() {
var selected = this.getSelectedContentItems();
if (selected && selected.length==1 && typeof(selected[0].link)!="undefined") {
desk_prompt(t('Enter URL address'), this.bind(this, function(link){
desk_window_request(this, url('dash/records/slidelink'),{'link':link, 'item':selected[0].data});
}));
$('#zira-prompt-dialog input[name=modal-input]').val(selected[0].link);
}
};

View file

@ -995,9 +995,7 @@
} else {
try {
grecaptcha.render($('#zira-auth-dialog .g-recaptcha').get(0));
} catch(e) {
console.log(e)
}
} catch(e) {}
}
} else if ($('.captcha-refresh-btn').length>0) {
zira_init_captcha();

View file

@ -154,6 +154,15 @@ class Records extends Dash\Controller {
}
}
public function slidelink() {
if (Zira\Request::isPost()) {
$link = Zira\Request::post('link');
$id = Zira\Request::post('item');
$response = $this->getSlidesModel()->saveLink($id, $link);
Zira\Page::render($response);
}
}
public function addfile() {
if (Zira\Request::isPost()) {
$files = Zira\Request::post('files');

View file

@ -65,6 +65,25 @@ class Recordslides extends Model {
return array('reload' => $this->getJSClassName(),'message'=>Zira\Locale::t('Successfully saved'));
}
public function saveLink($id, $link) {
if (empty($id)) return array('error' => Zira\Locale::t('An error occurred'));
if (!Permission::check(Permission::TO_CREATE_RECORDS) || !Permission::check(Permission::TO_EDIT_RECORDS)) {
return array('error'=>Zira\Locale::t('Permission denied'));
}
$slide = new Zira\Models\Slide($id);
if (!$slide->loaded()) {
return array('error' => Zira\Locale::t('An error occurred'));
}
$slide->link = strip_tags($link);
$slide->save();
Zira\Cache::clear();
return array('reload' => $this->getJSClassName(),'message'=>Zira\Locale::t('Successfully saved'));
}
public function delete($data) {
if (empty($data) || !is_array($data)) return array('error' => Zira\Locale::t('An error occurred'));

View file

@ -30,6 +30,9 @@ class Recordslides extends Window {
$this->addDefaultMenuDropdownItem(
$this->createMenuDropdownItem(Zira\Locale::t('Description'), 'glyphicon glyphicon-list-alt', 'desk_window_edit_item(this);', 'edit', true)
);
$this->addDefaultMenuDropdownItem(
$this->createMenuDropdownItem(Zira\Locale::t('URL address'), 'glyphicon glyphicon-link', 'desk_call(dash_recordslides_link, this);', 'edit', true)
);
$this->addDefaultContextMenuItem(
$this->createContextMenuItem(Zira\Locale::t('Add image'), 'glyphicon glyphicon-plus-sign', 'desk_call(dash_recordslides_add, this);', 'create')
@ -37,6 +40,9 @@ class Recordslides extends Window {
$this->addDefaultContextMenuItem(
$this->createContextMenuItem(Zira\Locale::t('Description'), 'glyphicon glyphicon-list-alt', 'desk_window_edit_item(this);', 'edit', true)
);
$this->addDefaultContextMenuItem(
$this->createContextMenuItem(Zira\Locale::t('URL address'), 'glyphicon glyphicon-link', 'desk_call(dash_recordslides_link, this);', 'edit', true)
);
$this->setDeleteActionEnabled(true);
}
@ -92,7 +98,7 @@ class Recordslides extends Window {
foreach($images as $image) {
$name = Zira\Helper::basename($image->image);
$inactive = file_exists(ROOT_DIR . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $image->image)) ? 0 : 1;
$items []= $this->createBodyItem(Zira\Helper::html($name), Zira\Helper::html($image->description), Zira\Helper::baseUrl($image->thumb), $image->id, null, false, array('description'=>$image->description,'inactive'=>$inactive));
$items []= $this->createBodyItem(Zira\Helper::html($name), Zira\Helper::html($image->description), Zira\Helper::baseUrl($image->thumb), $image->id, null, false, array('description'=>$image->description,'link'=>$image->link,'inactive'=>$inactive));
}
$this->setBodyItems($items);

View file

@ -2,7 +2,15 @@
<div class="slider-wrapper">
<ul id="slider" class="slider">
<?php foreach($images as $_image): ?>
<li><img class="image zira-lightbox" src="<?php echo Zira\Helper::urlencode(Zira\Helper::baseUrl($_image->image)) ?>" title="<?php echo Zira\Helper::html($_image->description) ?>" alt="<?php echo Zira\Helper::html($_image->description) ?>" /></li>
<li>
<?php if ($_image->link): ?>
<a href="<?php echo Zira\Helper::html(Zira\Menu::parseURL($_image->link)); ?>" title="<?php echo Zira\Helper::html($_image->description) ?>">
<?php endif; ?>
<img class="image<?php if (!$_image->link) echo ' zira-lightbox'; ?>" src="<?php echo Zira\Helper::urlencode(Zira\Helper::baseUrl($_image->image)) ?>" title="<?php echo Zira\Helper::html($_image->description) ?>" alt="<?php echo Zira\Helper::html($_image->description) ?>" />
<?php if ($_image->link): ?>
</a>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>

View file

@ -2,7 +2,15 @@
<div class="slider-wrapper">
<ul id="slider" class="slider">
<?php foreach($images as $_image): ?>
<li><img class="image zira-lightbox" src="<?php echo Zira\Helper::urlencode(Zira\Helper::baseUrl($_image->image)) ?>" title="<?php echo Zira\Helper::html($_image->description) ?>" alt="<?php echo Zira\Helper::html($_image->description) ?>" /></li>
<li>
<?php if ($_image->link): ?>
<a href="<?php echo Zira\Helper::html(Zira\Menu::parseURL($_image->link)); ?>" title="<?php echo Zira\Helper::html($_image->description) ?>">
<?php endif; ?>
<img class="image<?php if (!$_image->link) echo ' zira-lightbox'; ?>" src="<?php echo Zira\Helper::urlencode(Zira\Helper::baseUrl($_image->image)) ?>" title="<?php echo Zira\Helper::html($_image->description) ?>" alt="<?php echo Zira\Helper::html($_image->description) ?>" />
<?php if ($_image->link): ?>
</a>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>

View file

@ -2,7 +2,15 @@
<div class="slider-wrapper">
<ul id="slider" class="slider">
<?php foreach($images as $_image): ?>
<li><img class="image zira-lightbox" src="<?php echo Zira\Helper::urlencode(Zira\Helper::baseUrl($_image->image)) ?>" title="<?php echo Zira\Helper::html($_image->description) ?>" alt="<?php echo Zira\Helper::html($_image->description) ?>" /></li>
<li>
<?php if ($_image->link): ?>
<a href="<?php echo Zira\Helper::html(Zira\Menu::parseURL($_image->link)); ?>" title="<?php echo Zira\Helper::html($_image->description) ?>">
<?php endif; ?>
<img class="image<?php if (!$_image->link) echo ' zira-lightbox'; ?>" src="<?php echo Zira\Helper::urlencode(Zira\Helper::baseUrl($_image->image)) ?>" title="<?php echo Zira\Helper::html($_image->description) ?>" alt="<?php echo Zira\Helper::html($_image->description) ?>" />
<?php if ($_image->link): ?>
</a>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>

View file

@ -5,3 +5,8 @@ if (!defined('ZIRA_UPDATE') || !ZIRA_UPDATE) exit;
$alterRecords = new \Update\V4\Record();
$alterRecords->execute();
Zira\Log::write('Updated records table');
// adding new fields to slides table
$alterSlides = new \Update\V4\Slide();
$alterSlides->execute();
Zira\Log::write('Updated slides table');

20
update/v4/slide.php Normal file
View file

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

View file

@ -23,7 +23,8 @@ class Slide extends Table {
'record_id' => Field::int(true, true),
'description' => Field::string(),
'thumb' => Field::string(true),
'image' => Field::string(true)
'image' => Field::string(true),
'link' => Field::string()
);
}