1: <?php
2: /**
3: * QSlider Base File
4: *
5: * The QSliderBase class defined here provides an interface between the generated
6: * QSliderGen class, and QCubed. This file is part of the core and will be overwritten
7: * when you update QCubed. To override, make your changes to the QSlider.class.php file in
8: * the controls folder instead.
9: *
10: */
11:
12:
13: /**
14: *
15: * Implements a JQuery UI Slider
16: *
17: * A slider can have one or two handles to represent a range of things, similar to a scroll bar.
18: *
19: * Use the inherited properties to manipulate it. Call Value or Values to get the values.
20: *
21: * @link http://jqueryui.com/slider/
22: * @package Controls\Base
23: *
24: */
25: class QSliderBase extends QSliderGen {
26:
27: /** Constants to use for setting Orientation */
28: const Vertical = 'vertical';
29: const Horizontal = 'horizontal';
30:
31: public function GetEndScript() {
32: $strJS = parent::GetEndScript();
33: QApplication::ExecuteJsFunction('qcubed.slider', $this->GetJqControlId(), QJsPriority::High);
34: return $strJS;
35: }
36:
37: /**
38: * Returns the state data to restore later.
39: * @return mixed
40: */
41: protected function GetState() {
42: if ($this->mixRange === true) {
43: return ['values'=>$this->Values];
44: }
45: else {
46: return ['value'=>$this->Value];
47: }
48: }
49:
50: /**
51: * Restore the state of the control.
52: * @param mixed $state
53: */
54: protected function PutState($state) {
55: if (isset($state['values'])) {
56: $this->Values = $state['values'];
57: }
58: elseif (isset($state['value'])) {
59: $this->Value = $state['value'];
60: }
61: }
62:
63:
64: public function __set($strName, $mixValue) {
65:
66: switch ($strName) {
67: case '_Value': // Internal Only. Used by JS above. Do Not Call.
68: try {
69: $this->intValue = QType::Cast($mixValue, QType::Integer);
70: } catch (QCallerException $objExc) {
71: $objExc->IncrementOffset();
72: throw $objExc;
73: }
74: break;
75:
76: case '_Values': // Internal Only. Used by JS above. Do Not Call.
77: try {
78: $aValues = explode (',', $mixValue);
79: $aValues[0] = QType::Cast( $aValues[0], QType::Integer); // important to make sure JS sends values as ints instead of strings
80: $aValues[1] = QType::Cast($aValues[1], QType::Integer); // important to make sure JS sends values as ints instead of strings
81: $this->arrValues = $aValues;
82: } catch (QCallerException $objExc) {
83: $objExc->IncrementOffset();
84: throw $objExc;
85: }
86: break;
87:
88: default:
89: try {
90: parent::__set($strName, $mixValue);
91: } catch (QCallerException $objExc) {
92: $objExc->IncrementOffset();
93: throw $objExc;
94: }
95: break;
96: }
97: }
98:
99:
100: }