-
Notifications
You must be signed in to change notification settings - Fork 0
/
slider.php
108 lines (81 loc) · 2.23 KB
/
slider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
/**
* @package Unite Horizontal Carousel for Joomla 1.7-2.5
* @author UniteCMS.net
* @copyright (C) 2012 Unite CMS, All Rights Reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
**/
// No direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.modeladmin');
class UniteHCarouselModelSlider extends UniteHCarModel{
public function getTable($type = 'Sliders', $prefix = 'UniteHCarouselTable', $config = array())
{
$table = JTable::getInstance($type, $prefix, $config);
return $table;
}
/**
*
* get item override
*/
public function getItem($pk = null){
$item = parent::getItem($pk);
if(property_exists($item, "visual") && is_array($item->visual) == false){
$registry = new JRegistry();
$registry->loadString($item->visual,'JSON');
$item->visual = $registry->toArray();
}
return($item);
}
/**
*
* get the form
*/
public function getForm($data = array(), $loadData = true)
{
jimport('joomla.form.form');
// Get the form.
$form = $this->loadForm('com_unitehcarousel.slider', 'slider', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
/**
*
* load the form data
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState('com_unitehcarousel.edit.slider.data', array());
if (empty($data)) {
$data = $this->getItem();
}
return $data;
}
/**
*
* prepare table for saving
*/
protected function prepareTableReal(&$table)
{
jimport('joomla.filter.output');
$date = JFactory::getDate();
$user = JFactory::getUser();
$table->title = htmlspecialchars_decode($table->title, ENT_QUOTES);
$table->alias = JApplication::stringURLSafe($table->alias);
if (empty($table->alias)) {
$table->alias = JApplication::stringURLSafe($table->title);
}
if (empty($table->id)) {
// Set ordering to the last item if not set
if (empty($table->ordering)) {
$db = JFactory::getDbo();
$db->setQuery('SELECT MAX(ordering) FROM #__unitehcarousel_sliders');
$max = $db->loadResult();
$table->ordering = $max+1;
}
}
}
}