@@ -12,18 +12,18 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | class DataSetPager { |
| 14 | 14 | |
| 15 | - public $ds; // datasource |
|
| 15 | + public $ds; // datasource |
|
| 16 | 16 | public $pageSize; |
| 17 | 17 | public $pageNumber; |
| 18 | 18 | public $rows; |
| 19 | 19 | public $pager; |
| 20 | 20 | public $id; |
| 21 | 21 | |
| 22 | - // normal page |
|
| 22 | + // normal page |
|
| 23 | 23 | public $pageStyle; |
| 24 | 24 | public $pageClass; |
| 25 | 25 | |
| 26 | - // selected page |
|
| 26 | + // selected page |
|
| 27 | 27 | public $selPageStyle; |
| 28 | 28 | public $selPageClass; |
| 29 | 29 | public $renderRowFnc; |
@@ -32,166 +32,166 @@ discard block |
||
| 32 | 32 | public $renderPagerFncArgs; |
| 33 | 33 | |
| 34 | 34 | public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
| 35 | - global $_PAGE; // use view state object |
|
| 36 | - |
|
| 37 | - global $__DataSetPagerCnt; |
|
| 38 | - |
|
| 39 | - // set id |
|
| 40 | - $__DataSetPagerCnt++; |
|
| 41 | - $this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt; |
|
| 42 | - |
|
| 43 | - // get pagenumber |
|
| 44 | - // by setting pager to -1 cause pager to load it's last page number |
|
| 45 | - if($pageNumber == -1) { |
|
| 46 | - $pageNumber = 1; |
|
| 47 | - if(isset($_GET["dpgn" . $this->id])) { |
|
| 48 | - $pageNumber = $_GET["dpgn" . $this->id]; |
|
| 49 | - } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) { |
|
| 50 | - $pageNumber = $_PAGE['vs'][$id . '_dpgn']; |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - if(!is_numeric($pageNumber)) { |
|
| 54 | - $pageNumber = 1; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - $this->ds = $ds; // datasource |
|
| 58 | - $this->pageSize = $pageSize; |
|
| 59 | - $this->pageNumber = $pageNumber; |
|
| 60 | - $this->rows = ''; |
|
| 61 | - $this->pager = ''; |
|
| 62 | - } |
|
| 35 | + global $_PAGE; // use view state object |
|
| 36 | + |
|
| 37 | + global $__DataSetPagerCnt; |
|
| 38 | + |
|
| 39 | + // set id |
|
| 40 | + $__DataSetPagerCnt++; |
|
| 41 | + $this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt; |
|
| 42 | + |
|
| 43 | + // get pagenumber |
|
| 44 | + // by setting pager to -1 cause pager to load it's last page number |
|
| 45 | + if($pageNumber == -1) { |
|
| 46 | + $pageNumber = 1; |
|
| 47 | + if(isset($_GET["dpgn" . $this->id])) { |
|
| 48 | + $pageNumber = $_GET["dpgn" . $this->id]; |
|
| 49 | + } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) { |
|
| 50 | + $pageNumber = $_PAGE['vs'][$id . '_dpgn']; |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + if(!is_numeric($pageNumber)) { |
|
| 54 | + $pageNumber = 1; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + $this->ds = $ds; // datasource |
|
| 58 | + $this->pageSize = $pageSize; |
|
| 59 | + $this->pageNumber = $pageNumber; |
|
| 60 | + $this->rows = ''; |
|
| 61 | + $this->pager = ''; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | 64 | public function getRenderedPager() { |
| 65 | - return $this->pager; |
|
| 66 | - } |
|
| 65 | + return $this->pager; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | 68 | public function getRenderedRows() { |
| 69 | - return $this->rows; |
|
| 70 | - } |
|
| 69 | + return $this->rows; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | 72 | public function setDataSource($ds) { |
| 73 | - $this->ds = $ds; |
|
| 74 | - } |
|
| 73 | + $this->ds = $ds; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | 76 | public function setPageSize($ps) { |
| 77 | - $this->pageSize = $ps; |
|
| 78 | - } |
|
| 77 | + $this->pageSize = $ps; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | 80 | public function setRenderRowFnc($fncName, $args = "") { |
| 81 | - $this->renderRowFnc = &$fncName; |
|
| 82 | - $this->renderRowFncArgs = $args; // extra agruments |
|
| 81 | + $this->renderRowFnc = &$fncName; |
|
| 82 | + $this->renderRowFncArgs = $args; // extra agruments |
|
| 83 | 83 | |
| 84 | 84 | |
| 85 | - } |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | 87 | public function setRenderPagerFnc($fncName, $args = "") { |
| 88 | - $this->renderPagerFnc = $fncName; |
|
| 89 | - $this->renderPagerFncArgs = $args; // extra agruments |
|
| 90 | - } |
|
| 88 | + $this->renderPagerFnc = $fncName; |
|
| 89 | + $this->renderPagerFncArgs = $args; // extra agruments |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | 92 | public function render() { |
| 93 | - $modx = evolutionCMS(); global $_PAGE; |
|
| 94 | - |
|
| 95 | - $isDataset = $modx->db->isResult($this->ds); |
|
| 96 | - |
|
| 97 | - if(!$this->selPageStyle) { |
|
| 98 | - $this->selPageStyle = "font-weight:bold"; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - // get total number of rows |
|
| 102 | - $tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
|
| 103 | - |
|
| 104 | - // render: no records found |
|
| 105 | - if($tnr <= 0) { |
|
| 106 | - $fnc = $this->renderRowFnc; |
|
| 107 | - $args = $this->renderRowFncArgs; |
|
| 108 | - if(isset($fnc)) { |
|
| 109 | - if($args != "") { |
|
| 110 | - $this->rows .= $fnc(0, null, $args); |
|
| 111 | - } // if agrs was specified then we will pass three params |
|
| 112 | - else { |
|
| 113 | - $this->rows .= $fnc(0, null); |
|
| 114 | - } // otherwise two will be passed |
|
| 115 | - } |
|
| 116 | - return; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - // get total pages |
|
| 120 | - $tp = ceil($tnr / $this->pageSize); |
|
| 121 | - if($this->pageNumber > $tp) { |
|
| 122 | - $this->pageNumber = 1; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - // get page number |
|
| 126 | - $p = $this->pageNumber; |
|
| 127 | - |
|
| 128 | - // save page number to view state if available |
|
| 129 | - if(isset($_PAGE['vs'])) { |
|
| 130 | - $_PAGE['vs'][$this->id . '_dpgn'] = $p; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments=""); |
|
| 134 | - if($tp > 1) { |
|
| 135 | - $url = ''; |
|
| 136 | - $fnc = $this->renderPagerFnc; |
|
| 137 | - $args = $this->renderPagerFncArgs; |
|
| 138 | - if(!isset($fnc)) { |
|
| 139 | - if($modx->isFrontend()) { |
|
| 140 | - $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?'; |
|
| 141 | - } else { |
|
| 142 | - $url = $_SERVER['PHP_SELF'] . '?'; |
|
| 143 | - } |
|
| 144 | - $i = 0; |
|
| 145 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
| 146 | - $i++; |
|
| 147 | - $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
|
| 148 | - } |
|
| 149 | - if($i >= 1) { |
|
| 150 | - $url .= "&"; |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - for($i = 1; $i <= $tp; $i++) { |
|
| 154 | - if(isset($fnc)) { |
|
| 155 | - if($args != "") { |
|
| 156 | - $this->pager .= $fnc($p, $i, $args); |
|
| 157 | - } else { |
|
| 158 | - $this->pager .= $fnc($p, $i); |
|
| 159 | - } |
|
| 160 | - } else { |
|
| 161 | - $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> "; |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - // render row : renderRowFnc($rowNumber,$row,$arguments="") |
|
| 167 | - $fnc = $this->renderRowFnc; |
|
| 168 | - $args = $this->renderRowFncArgs; |
|
| 169 | - |
|
| 170 | - if(isset($fnc)) { |
|
| 171 | - $i = 1; |
|
| 172 | - $fncObject = is_object($fnc); |
|
| 173 | - $minitems = (($p - 1) * $this->pageSize) + 1; |
|
| 174 | - $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize; |
|
| 175 | - while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) { |
|
| 176 | - if($i >= $minitems && $i <= $maxitems) { |
|
| 177 | - if($fncObject) { |
|
| 178 | - if($args != "") { |
|
| 179 | - $this->rows .= $fnc->RenderRowFnc($i, $row, $args); |
|
| 180 | - } else { |
|
| 181 | - $this->rows .= $fnc->RenderRowFnc($i, $row); |
|
| 182 | - } |
|
| 183 | - } else { |
|
| 184 | - if($args != "") { |
|
| 185 | - $this->rows .= $fnc($i, $row, $args); |
|
| 186 | - } // if agrs was specified then we wil pass three params |
|
| 187 | - else { |
|
| 188 | - $this->rows .= $fnc($i, $row); |
|
| 189 | - } // otherwise two will be passed |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - } |
|
| 193 | - $i++; |
|
| 194 | - } |
|
| 195 | - } |
|
| 196 | - } |
|
| 93 | + $modx = evolutionCMS(); global $_PAGE; |
|
| 94 | + |
|
| 95 | + $isDataset = $modx->db->isResult($this->ds); |
|
| 96 | + |
|
| 97 | + if(!$this->selPageStyle) { |
|
| 98 | + $this->selPageStyle = "font-weight:bold"; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + // get total number of rows |
|
| 102 | + $tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
|
| 103 | + |
|
| 104 | + // render: no records found |
|
| 105 | + if($tnr <= 0) { |
|
| 106 | + $fnc = $this->renderRowFnc; |
|
| 107 | + $args = $this->renderRowFncArgs; |
|
| 108 | + if(isset($fnc)) { |
|
| 109 | + if($args != "") { |
|
| 110 | + $this->rows .= $fnc(0, null, $args); |
|
| 111 | + } // if agrs was specified then we will pass three params |
|
| 112 | + else { |
|
| 113 | + $this->rows .= $fnc(0, null); |
|
| 114 | + } // otherwise two will be passed |
|
| 115 | + } |
|
| 116 | + return; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + // get total pages |
|
| 120 | + $tp = ceil($tnr / $this->pageSize); |
|
| 121 | + if($this->pageNumber > $tp) { |
|
| 122 | + $this->pageNumber = 1; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + // get page number |
|
| 126 | + $p = $this->pageNumber; |
|
| 127 | + |
|
| 128 | + // save page number to view state if available |
|
| 129 | + if(isset($_PAGE['vs'])) { |
|
| 130 | + $_PAGE['vs'][$this->id . '_dpgn'] = $p; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments=""); |
|
| 134 | + if($tp > 1) { |
|
| 135 | + $url = ''; |
|
| 136 | + $fnc = $this->renderPagerFnc; |
|
| 137 | + $args = $this->renderPagerFncArgs; |
|
| 138 | + if(!isset($fnc)) { |
|
| 139 | + if($modx->isFrontend()) { |
|
| 140 | + $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?'; |
|
| 141 | + } else { |
|
| 142 | + $url = $_SERVER['PHP_SELF'] . '?'; |
|
| 143 | + } |
|
| 144 | + $i = 0; |
|
| 145 | + foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
| 146 | + $i++; |
|
| 147 | + $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
|
| 148 | + } |
|
| 149 | + if($i >= 1) { |
|
| 150 | + $url .= "&"; |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + for($i = 1; $i <= $tp; $i++) { |
|
| 154 | + if(isset($fnc)) { |
|
| 155 | + if($args != "") { |
|
| 156 | + $this->pager .= $fnc($p, $i, $args); |
|
| 157 | + } else { |
|
| 158 | + $this->pager .= $fnc($p, $i); |
|
| 159 | + } |
|
| 160 | + } else { |
|
| 161 | + $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> "; |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + // render row : renderRowFnc($rowNumber,$row,$arguments="") |
|
| 167 | + $fnc = $this->renderRowFnc; |
|
| 168 | + $args = $this->renderRowFncArgs; |
|
| 169 | + |
|
| 170 | + if(isset($fnc)) { |
|
| 171 | + $i = 1; |
|
| 172 | + $fncObject = is_object($fnc); |
|
| 173 | + $minitems = (($p - 1) * $this->pageSize) + 1; |
|
| 174 | + $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize; |
|
| 175 | + while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) { |
|
| 176 | + if($i >= $minitems && $i <= $maxitems) { |
|
| 177 | + if($fncObject) { |
|
| 178 | + if($args != "") { |
|
| 179 | + $this->rows .= $fnc->RenderRowFnc($i, $row, $args); |
|
| 180 | + } else { |
|
| 181 | + $this->rows .= $fnc->RenderRowFnc($i, $row); |
|
| 182 | + } |
|
| 183 | + } else { |
|
| 184 | + if($args != "") { |
|
| 185 | + $this->rows .= $fnc($i, $row, $args); |
|
| 186 | + } // if agrs was specified then we wil pass three params |
|
| 187 | + else { |
|
| 188 | + $this->rows .= $fnc($i, $row); |
|
| 189 | + } // otherwise two will be passed |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + } |
|
| 193 | + $i++; |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | 197 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | $__DataSetPagerCnt = 0; |
| 12 | 12 | |
| 13 | -class DataSetPager { |
|
| 13 | +class DataSetPager{ |
|
| 14 | 14 | |
| 15 | 15 | public $ds; // datasource |
| 16 | 16 | public $pageSize; |
@@ -31,26 +31,26 @@ discard block |
||
| 31 | 31 | public $renderPagerFnc; |
| 32 | 32 | public $renderPagerFncArgs; |
| 33 | 33 | |
| 34 | - public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
|
| 34 | + public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1){ |
|
| 35 | 35 | global $_PAGE; // use view state object |
| 36 | 36 | |
| 37 | 37 | global $__DataSetPagerCnt; |
| 38 | 38 | |
| 39 | 39 | // set id |
| 40 | 40 | $__DataSetPagerCnt++; |
| 41 | - $this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt; |
|
| 41 | + $this->id = !empty($id) ? $id : "dsp".$__DataSetPagerCnt; |
|
| 42 | 42 | |
| 43 | 43 | // get pagenumber |
| 44 | 44 | // by setting pager to -1 cause pager to load it's last page number |
| 45 | - if($pageNumber == -1) { |
|
| 45 | + if ($pageNumber == -1) { |
|
| 46 | 46 | $pageNumber = 1; |
| 47 | - if(isset($_GET["dpgn" . $this->id])) { |
|
| 48 | - $pageNumber = $_GET["dpgn" . $this->id]; |
|
| 49 | - } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) { |
|
| 50 | - $pageNumber = $_PAGE['vs'][$id . '_dpgn']; |
|
| 47 | + if (isset($_GET["dpgn".$this->id])) { |
|
| 48 | + $pageNumber = $_GET["dpgn".$this->id]; |
|
| 49 | + } elseif (isset($_PAGE['vs'][$id.'_dpgn'])) { |
|
| 50 | + $pageNumber = $_PAGE['vs'][$id.'_dpgn']; |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | - if(!is_numeric($pageNumber)) { |
|
| 53 | + if (!is_numeric($pageNumber)) { |
|
| 54 | 54 | $pageNumber = 1; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -61,40 +61,40 @@ discard block |
||
| 61 | 61 | $this->pager = ''; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - public function getRenderedPager() { |
|
| 64 | + public function getRenderedPager(){ |
|
| 65 | 65 | return $this->pager; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - public function getRenderedRows() { |
|
| 68 | + public function getRenderedRows(){ |
|
| 69 | 69 | return $this->rows; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - public function setDataSource($ds) { |
|
| 72 | + public function setDataSource($ds){ |
|
| 73 | 73 | $this->ds = $ds; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - public function setPageSize($ps) { |
|
| 76 | + public function setPageSize($ps){ |
|
| 77 | 77 | $this->pageSize = $ps; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public function setRenderRowFnc($fncName, $args = "") { |
|
| 80 | + public function setRenderRowFnc($fncName, $args = ""){ |
|
| 81 | 81 | $this->renderRowFnc = &$fncName; |
| 82 | - $this->renderRowFncArgs = $args; // extra agruments |
|
| 82 | + $this->renderRowFncArgs = $args; // extra agruments |
|
| 83 | 83 | |
| 84 | 84 | |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - public function setRenderPagerFnc($fncName, $args = "") { |
|
| 87 | + public function setRenderPagerFnc($fncName, $args = ""){ |
|
| 88 | 88 | $this->renderPagerFnc = $fncName; |
| 89 | - $this->renderPagerFncArgs = $args; // extra agruments |
|
| 89 | + $this->renderPagerFncArgs = $args; // extra agruments |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - public function render() { |
|
| 92 | + public function render(){ |
|
| 93 | 93 | $modx = evolutionCMS(); global $_PAGE; |
| 94 | 94 | |
| 95 | 95 | $isDataset = $modx->db->isResult($this->ds); |
| 96 | 96 | |
| 97 | - if(!$this->selPageStyle) { |
|
| 97 | + if (!$this->selPageStyle) { |
|
| 98 | 98 | $this->selPageStyle = "font-weight:bold"; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -102,11 +102,11 @@ discard block |
||
| 102 | 102 | $tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
| 103 | 103 | |
| 104 | 104 | // render: no records found |
| 105 | - if($tnr <= 0) { |
|
| 105 | + if ($tnr <= 0) { |
|
| 106 | 106 | $fnc = $this->renderRowFnc; |
| 107 | 107 | $args = $this->renderRowFncArgs; |
| 108 | - if(isset($fnc)) { |
|
| 109 | - if($args != "") { |
|
| 108 | + if (isset($fnc)) { |
|
| 109 | + if ($args != "") { |
|
| 110 | 110 | $this->rows .= $fnc(0, null, $args); |
| 111 | 111 | } // if agrs was specified then we will pass three params |
| 112 | 112 | else { |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | // get total pages |
| 120 | 120 | $tp = ceil($tnr / $this->pageSize); |
| 121 | - if($this->pageNumber > $tp) { |
|
| 121 | + if ($this->pageNumber > $tp) { |
|
| 122 | 122 | $this->pageNumber = 1; |
| 123 | 123 | } |
| 124 | 124 | |
@@ -126,39 +126,39 @@ discard block |
||
| 126 | 126 | $p = $this->pageNumber; |
| 127 | 127 | |
| 128 | 128 | // save page number to view state if available |
| 129 | - if(isset($_PAGE['vs'])) { |
|
| 130 | - $_PAGE['vs'][$this->id . '_dpgn'] = $p; |
|
| 129 | + if (isset($_PAGE['vs'])) { |
|
| 130 | + $_PAGE['vs'][$this->id.'_dpgn'] = $p; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments=""); |
| 134 | - if($tp > 1) { |
|
| 134 | + if ($tp > 1) { |
|
| 135 | 135 | $url = ''; |
| 136 | 136 | $fnc = $this->renderPagerFnc; |
| 137 | 137 | $args = $this->renderPagerFncArgs; |
| 138 | - if(!isset($fnc)) { |
|
| 139 | - if($modx->isFrontend()) { |
|
| 140 | - $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?'; |
|
| 138 | + if (!isset($fnc)) { |
|
| 139 | + if ($modx->isFrontend()) { |
|
| 140 | + $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full').'?'; |
|
| 141 | 141 | } else { |
| 142 | - $url = $_SERVER['PHP_SELF'] . '?'; |
|
| 142 | + $url = $_SERVER['PHP_SELF'].'?'; |
|
| 143 | 143 | } |
| 144 | 144 | $i = 0; |
| 145 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
| 145 | + foreach ($_GET as $n => $v) if ($n != 'dpgn'.$this->id) { |
|
| 146 | 146 | $i++; |
| 147 | - $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
|
| 147 | + $url .= (($i > 1) ? "&" : "")."$n=$v"; |
|
| 148 | 148 | } |
| 149 | - if($i >= 1) { |
|
| 149 | + if ($i >= 1) { |
|
| 150 | 150 | $url .= "&"; |
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | - for($i = 1; $i <= $tp; $i++) { |
|
| 154 | - if(isset($fnc)) { |
|
| 155 | - if($args != "") { |
|
| 153 | + for ($i = 1; $i <= $tp; $i++) { |
|
| 154 | + if (isset($fnc)) { |
|
| 155 | + if ($args != "") { |
|
| 156 | 156 | $this->pager .= $fnc($p, $i, $args); |
| 157 | 157 | } else { |
| 158 | 158 | $this->pager .= $fnc($p, $i); |
| 159 | 159 | } |
| 160 | 160 | } else { |
| 161 | - $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> "; |
|
| 161 | + $this->pager .= ($p == $i) ? " <span class='".$this->selPageClass."' style='".$this->selPageStyle."'>$i</span> " : " <a href='".$url."dpgn".$this->id."=$i' class='".$this->pageClass."' style='".$this->pageStyle."'>$i</a> "; |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | } |
@@ -167,21 +167,21 @@ discard block |
||
| 167 | 167 | $fnc = $this->renderRowFnc; |
| 168 | 168 | $args = $this->renderRowFncArgs; |
| 169 | 169 | |
| 170 | - if(isset($fnc)) { |
|
| 170 | + if (isset($fnc)) { |
|
| 171 | 171 | $i = 1; |
| 172 | 172 | $fncObject = is_object($fnc); |
| 173 | 173 | $minitems = (($p - 1) * $this->pageSize) + 1; |
| 174 | 174 | $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize; |
| 175 | - while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) { |
|
| 176 | - if($i >= $minitems && $i <= $maxitems) { |
|
| 177 | - if($fncObject) { |
|
| 178 | - if($args != "") { |
|
| 175 | + while ($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) { |
|
| 176 | + if ($i >= $minitems && $i <= $maxitems) { |
|
| 177 | + if ($fncObject) { |
|
| 178 | + if ($args != "") { |
|
| 179 | 179 | $this->rows .= $fnc->RenderRowFnc($i, $row, $args); |
| 180 | 180 | } else { |
| 181 | 181 | $this->rows .= $fnc->RenderRowFnc($i, $row); |
| 182 | 182 | } |
| 183 | 183 | } else { |
| 184 | - if($args != "") { |
|
| 184 | + if ($args != "") { |
|
| 185 | 185 | $this->rows .= $fnc($i, $row, $args); |
| 186 | 186 | } // if agrs was specified then we wil pass three params |
| 187 | 187 | else { |
@@ -10,7 +10,8 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | $__DataSetPagerCnt = 0; |
| 12 | 12 | |
| 13 | -class DataSetPager { |
|
| 13 | +class DataSetPager |
|
| 14 | +{ |
|
| 14 | 15 | |
| 15 | 16 | public $ds; // datasource |
| 16 | 17 | public $pageSize; |
@@ -31,7 +32,8 @@ discard block |
||
| 31 | 32 | public $renderPagerFnc; |
| 32 | 33 | public $renderPagerFncArgs; |
| 33 | 34 | |
| 34 | - public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
|
| 35 | + public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) |
|
| 36 | + { |
|
| 35 | 37 | global $_PAGE; // use view state object |
| 36 | 38 | |
| 37 | 39 | global $__DataSetPagerCnt; |
@@ -61,35 +63,42 @@ discard block |
||
| 61 | 63 | $this->pager = ''; |
| 62 | 64 | } |
| 63 | 65 | |
| 64 | - public function getRenderedPager() { |
|
| 66 | + public function getRenderedPager() |
|
| 67 | + { |
|
| 65 | 68 | return $this->pager; |
| 66 | 69 | } |
| 67 | 70 | |
| 68 | - public function getRenderedRows() { |
|
| 71 | + public function getRenderedRows() |
|
| 72 | + { |
|
| 69 | 73 | return $this->rows; |
| 70 | 74 | } |
| 71 | 75 | |
| 72 | - public function setDataSource($ds) { |
|
| 76 | + public function setDataSource($ds) |
|
| 77 | + { |
|
| 73 | 78 | $this->ds = $ds; |
| 74 | 79 | } |
| 75 | 80 | |
| 76 | - public function setPageSize($ps) { |
|
| 81 | + public function setPageSize($ps) |
|
| 82 | + { |
|
| 77 | 83 | $this->pageSize = $ps; |
| 78 | 84 | } |
| 79 | 85 | |
| 80 | - public function setRenderRowFnc($fncName, $args = "") { |
|
| 86 | + public function setRenderRowFnc($fncName, $args = "") |
|
| 87 | + { |
|
| 81 | 88 | $this->renderRowFnc = &$fncName; |
| 82 | 89 | $this->renderRowFncArgs = $args; // extra agruments |
| 83 | 90 | |
| 84 | 91 | |
| 85 | 92 | } |
| 86 | 93 | |
| 87 | - public function setRenderPagerFnc($fncName, $args = "") { |
|
| 94 | + public function setRenderPagerFnc($fncName, $args = "") |
|
| 95 | + { |
|
| 88 | 96 | $this->renderPagerFnc = $fncName; |
| 89 | 97 | $this->renderPagerFncArgs = $args; // extra agruments |
| 90 | 98 | } |
| 91 | 99 | |
| 92 | - public function render() { |
|
| 100 | + public function render() |
|
| 101 | + { |
|
| 93 | 102 | $modx = evolutionCMS(); global $_PAGE; |
| 94 | 103 | |
| 95 | 104 | $isDataset = $modx->db->isResult($this->ds); |
@@ -142,8 +151,10 @@ discard block |
||
| 142 | 151 | $url = $_SERVER['PHP_SELF'] . '?'; |
| 143 | 152 | } |
| 144 | 153 | $i = 0; |
| 145 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
| 154 | + foreach($_GET as $n => $v) { |
|
| 155 | + if($n != 'dpgn' . $this->id) { |
|
| 146 | 156 | $i++; |
| 157 | + } |
|
| 147 | 158 | $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
| 148 | 159 | } |
| 149 | 160 | if($i >= 1) { |
@@ -4,14 +4,14 @@ discard block |
||
| 4 | 4 | $site_sessionname = genEvoSessionName(); // For legacy extras not using startCMSSession |
| 5 | 5 | |
| 6 | 6 | |
| 7 | -if( ! function_exists('evolutionCMS')) {
|
|
| 7 | +if (!function_exists('evolutionCMS')) {
|
|
| 8 | 8 | /** |
| 9 | 9 | * @return DocumentParser |
| 10 | 10 | */ |
| 11 | 11 | function evolutionCMS() |
| 12 | 12 | {
|
| 13 | - if( ! defined('MODX_CLASS')) {
|
|
| 14 | - if( ! class_exists('DocumentParser')) {
|
|
| 13 | + if (!defined('MODX_CLASS')) {
|
|
| 14 | + if (!class_exists('DocumentParser')) {
|
|
| 15 | 15 | throw new RuntimeException('MODX_CLASS not defined and DocumentParser class not exists');
|
| 16 | 16 | } |
| 17 | 17 | define('MODX_CLASS', 'DocumentParser');
|
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | $_ = crc32(__FILE__); |
| 30 | 30 | $_ = sprintf('%u', $_);
|
| 31 | 31 | |
| 32 | - return 'evo' . base_convert($_, 10, 36); |
|
| 32 | + return 'evo'.base_convert($_, 10, 36); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | session_start(); |
| 51 | 51 | $key = "modx.mgr.session.cookie.lifetime"; |
| 52 | 52 | if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) {
|
| 53 | - $cookieLifetime = (int)$_SESSION[$key]; |
|
| 53 | + $cookieLifetime = (int) $_SESSION[$key]; |
|
| 54 | 54 | if ($cookieLifetime) {
|
| 55 | 55 | $cookieExpiration = $_SERVER['REQUEST_TIME'] + $cookieLifetime; |
| 56 | 56 | } |
@@ -4,14 +4,14 @@ discard block |
||
| 4 | 4 | $site_sessionname = genEvoSessionName(); // For legacy extras not using startCMSSession |
| 5 | 5 | |
| 6 | 6 | |
| 7 | -if( ! function_exists('evolutionCMS')) {
|
|
| 7 | +if( ! function_exists('evolutionCMS')) { |
|
| 8 | 8 | /** |
| 9 | 9 | * @return DocumentParser |
| 10 | 10 | */ |
| 11 | - function evolutionCMS() |
|
| 12 | - {
|
|
| 13 | - if( ! defined('MODX_CLASS')) {
|
|
| 14 | - if( ! class_exists('DocumentParser')) {
|
|
| 11 | + function evolutionCMS() |
|
| 12 | + { |
|
| 13 | + if( ! defined('MODX_CLASS')) { |
|
| 14 | + if( ! class_exists('DocumentParser')) { |
|
| 15 | 15 | throw new RuntimeException('MODX_CLASS not defined and DocumentParser class not exists');
|
| 16 | 16 | } |
| 17 | 17 | define('MODX_CLASS', 'DocumentParser');
|
@@ -24,8 +24,8 @@ discard block |
||
| 24 | 24 | /** |
| 25 | 25 | * @return string |
| 26 | 26 | */ |
| 27 | -function genEvoSessionName() |
|
| 28 | -{
|
|
| 27 | +function genEvoSessionName() |
|
| 28 | +{ |
|
| 29 | 29 | $_ = crc32(__FILE__); |
| 30 | 30 | $_ = sprintf('%u', $_);
|
| 31 | 31 | |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | /** |
| 36 | 36 | * @return void |
| 37 | 37 | */ |
| 38 | -function startCMSSession() |
|
| 39 | -{
|
|
| 38 | +function startCMSSession() |
|
| 39 | +{ |
|
| 40 | 40 | |
| 41 | 41 | global $site_sessionname, $https_port, $session_cookie_path, $session_cookie_domain; |
| 42 | 42 | |
@@ -49,14 +49,14 @@ discard block |
||
| 49 | 49 | session_set_cookie_params($cookieExpiration, $cookiePath, $cookieDomain, $secure, true); |
| 50 | 50 | session_start(); |
| 51 | 51 | $key = "modx.mgr.session.cookie.lifetime"; |
| 52 | - if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) {
|
|
| 52 | + if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) { |
|
| 53 | 53 | $cookieLifetime = (int)$_SESSION[$key]; |
| 54 | - if ($cookieLifetime) {
|
|
| 54 | + if ($cookieLifetime) { |
|
| 55 | 55 | $cookieExpiration = $_SERVER['REQUEST_TIME'] + $cookieLifetime; |
| 56 | 56 | } |
| 57 | 57 | setcookie(session_name(), session_id(), $cookieExpiration, $cookiePath, $cookieDomain, $secure, true); |
| 58 | 58 | } |
| 59 | - if (!isset($_SESSION['modx.session.created.time'])) {
|
|
| 59 | + if (!isset($_SESSION['modx.session.created.time'])) { |
|
| 60 | 60 | $_SESSION['modx.session.created.time'] = $_SERVER['REQUEST_TIME']; |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | * @param $session_name |
| 67 | 67 | * @return void |
| 68 | 68 | */ |
| 69 | -function removeInvalidCmsSessionFromStorage(&$storage, $session_name) |
|
| 70 | -{
|
|
| 71 | - if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) {
|
|
| 69 | +function removeInvalidCmsSessionFromStorage(&$storage, $session_name) |
|
| 70 | +{ |
|
| 71 | + if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) { |
|
| 72 | 72 | unset($storage[$session_name]); |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | * @param $session_name |
| 78 | 78 | * @return void |
| 79 | 79 | */ |
| 80 | -function removeInvalidCmsSessionIds($session_name) |
|
| 81 | -{
|
|
| 80 | +function removeInvalidCmsSessionIds($session_name) |
|
| 81 | +{ |
|
| 82 | 82 | // session ids is invalid iff it is empty string |
| 83 | 83 | // storage priorioty can see in PHP source ext/session/session.c |
| 84 | 84 | removeInvalidCmsSessionFromStorage($_COOKIE, $session_name); |
@@ -36,16 +36,16 @@ discard block |
||
| 36 | 36 | $action = "", |
| 37 | 37 | $itemid = "", |
| 38 | 38 | $itemname = "" |
| 39 | - ) { |
|
| 39 | + ){ |
|
| 40 | 40 | $modx = evolutionCMS(); |
| 41 | 41 | $this->entry['msg'] = $msg; // writes testmessage to the object |
| 42 | - $this->entry['action'] = empty($action) ? $modx->manager->action : $action; // writes the action to the object |
|
| 42 | + $this->entry['action'] = empty($action) ? $modx->manager->action : $action; // writes the action to the object |
|
| 43 | 43 | |
| 44 | 44 | // User Credentials |
| 45 | 45 | $this->entry['internalKey'] = $internalKey == "" ? $modx->getLoginUserID() : $internalKey; |
| 46 | 46 | $this->entry['username'] = $username == "" ? $modx->getLoginUserName() : $username; |
| 47 | 47 | |
| 48 | - $this->entry['itemId'] = (empty($itemid) && isset($_REQUEST['id'])) ? (int)$_REQUEST['id'] : $itemid; // writes the id to the object |
|
| 48 | + $this->entry['itemId'] = (empty($itemid) && isset($_REQUEST['id'])) ? (int) $_REQUEST['id'] : $itemid; // writes the id to the object |
|
| 49 | 49 | if ($this->entry['itemId'] == 0) { |
| 50 | 50 | $this->entry['itemId'] = "-"; |
| 51 | 51 | } // to stop items having id 0 |
@@ -93,10 +93,10 @@ discard block |
||
| 93 | 93 | $fields['message'] = $modx->db->escape($this->entry['msg']); |
| 94 | 94 | $insert_id = $modx->db->insert($fields, $tbl_manager_log); |
| 95 | 95 | if (!$insert_id) { |
| 96 | - $modx->messageQuit("Logging error: couldn't save log to table! Error code: " . $modx->db->getLastError()); |
|
| 96 | + $modx->messageQuit("Logging error: couldn't save log to table! Error code: ".$modx->db->getLastError()); |
|
| 97 | 97 | } else { |
| 98 | - $limit = (isset($modx->config['manager_log_limit'])) ? (int)$modx->config['manager_log_limit'] : 3000; |
|
| 99 | - $trim = (isset($modx->config['manager_log_trim'])) ? (int)$modx->config['manager_log_trim'] : 100; |
|
| 98 | + $limit = (isset($modx->config['manager_log_limit'])) ? (int) $modx->config['manager_log_limit'] : 3000; |
|
| 99 | + $trim = (isset($modx->config['manager_log_trim'])) ? (int) $modx->config['manager_log_trim'] : 100; |
|
| 100 | 100 | if (($insert_id % $trim) === 0) { |
| 101 | 101 | $modx->rotate_log('manager_log', $limit, $trim); |
| 102 | 102 | } |
@@ -1,13 +1,13 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | // PROCESSOR FIRST |
| 7 | -if($_SESSION['mgrRole'] == 1) { |
|
| 8 | - if($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) { |
|
| 7 | +if ($_SESSION['mgrRole'] == 1) { |
|
| 8 | + if ($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) { |
|
| 9 | 9 | $current = $modx->manager->getSystemChecksum($modx->config['check_files_onlogin']); |
| 10 | - if(!empty($current)) { |
|
| 10 | + if (!empty($current)) { |
|
| 11 | 11 | $modx->manager->setSystemChecksum($current); |
| 12 | 12 | $modx->clearCache('full'); |
| 13 | 13 | $modx->config['sys_files_checksum'] = $current; |
@@ -19,14 +19,14 @@ discard block |
||
| 19 | 19 | $warningspresent = 0; |
| 20 | 20 | |
| 21 | 21 | $sysfiles_check = $modx->manager->checkSystemChecksum(); |
| 22 | -if ($sysfiles_check!=='0'){ |
|
| 22 | +if ($sysfiles_check !== '0') { |
|
| 23 | 23 | $warningspresent = 1; |
| 24 | 24 | $warnings[] = array($_lang['configcheck_sysfiles_mod']); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | -if (is_writable("includes/config.inc.php")){ |
|
| 27 | +if (is_writable("includes/config.inc.php")) { |
|
| 28 | 28 | // Warn if world writable |
| 29 | - if(@fileperms('includes/config.inc.php') & 0x0002) { |
|
| 29 | + if (@fileperms('includes/config.inc.php') & 0x0002) { |
|
| 30 | 30 | $warningspresent = 1; |
| 31 | 31 | $warnings[] = array($_lang['configcheck_configinc']); |
| 32 | 32 | } |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | $warnings[] = array($_lang['configcheck_php_gdzip']); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | -if(!isset($modx->config['_hide_configcheck_validate_referer']) || $modx->config['_hide_configcheck_validate_referer'] !== '1') { |
|
| 46 | - if(isset($_SESSION['mgrPermissions']['settings']) && $_SESSION['mgrPermissions']['settings'] == '1') { |
|
| 45 | +if (!isset($modx->config['_hide_configcheck_validate_referer']) || $modx->config['_hide_configcheck_validate_referer'] !== '1') { |
|
| 46 | + if (isset($_SESSION['mgrPermissions']['settings']) && $_SESSION['mgrPermissions']['settings'] == '1') { |
|
| 47 | 47 | if ($modx->db->getValue($modx->db->select('COUNT(setting_value)', $modx->getFullTableName('system_settings'), "setting_name='validate_referer' AND setting_value='0'"))) { |
| 48 | 48 | $warningspresent = 1; |
| 49 | 49 | $warnings[] = array($_lang['configcheck_validate_referer']); |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // check for Template Switcher plugin |
| 55 | -if(!isset($modx->config['_hide_configcheck_templateswitcher_present']) || $modx->config['_hide_configcheck_templateswitcher_present'] !== '1') { |
|
| 56 | - if(isset($_SESSION['mgrPermissions']['edit_plugin']) && $_SESSION['mgrPermissions']['edit_plugin'] == '1') { |
|
| 55 | +if (!isset($modx->config['_hide_configcheck_templateswitcher_present']) || $modx->config['_hide_configcheck_templateswitcher_present'] !== '1') { |
|
| 56 | + if (isset($_SESSION['mgrPermissions']['edit_plugin']) && $_SESSION['mgrPermissions']['edit_plugin'] == '1') { |
|
| 57 | 57 | $rs = $modx->db->select('name, disabled', $modx->getFullTableName('site_plugins'), "name IN ('TemplateSwitcher', 'Template Switcher', 'templateswitcher', 'template_switcher', 'template switcher') OR plugincode LIKE '%TemplateSwitcher%'"); |
| 58 | 58 | $row = $modx->db->getRow($rs); |
| 59 | - if($row && $row['disabled'] == 0) { |
|
| 59 | + if ($row && $row['disabled'] == 0) { |
|
| 60 | 60 | $warningspresent = 1; |
| 61 | 61 | $warnings[] = array($_lang['configcheck_templateswitcher_present']); |
| 62 | 62 | $tplName = $row['name']; |
@@ -120,36 +120,36 @@ discard block |
||
| 120 | 120 | /** |
| 121 | 121 | * @return bool |
| 122 | 122 | */ |
| 123 | - function checkSiteCache() { |
|
| 123 | + function checkSiteCache(){ |
|
| 124 | 124 | $modx = evolutionCMS(); |
| 125 | - $checked= true; |
|
| 126 | - if (file_exists($modx->config['base_path'] . 'assets/cache/siteCache.idx.php')) { |
|
| 127 | - $checked= @include_once ($modx->config['base_path'] . 'assets/cache/siteCache.idx.php'); |
|
| 125 | + $checked = true; |
|
| 126 | + if (file_exists($modx->config['base_path'].'assets/cache/siteCache.idx.php')) { |
|
| 127 | + $checked = @include_once ($modx->config['base_path'].'assets/cache/siteCache.idx.php'); |
|
| 128 | 128 | } |
| 129 | 129 | return $checked; |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | -if (!is_writable(MODX_BASE_PATH . "assets/cache/")) { |
|
| 133 | +if (!is_writable(MODX_BASE_PATH."assets/cache/")) { |
|
| 134 | 134 | $warningspresent = 1; |
| 135 | 135 | $warnings[] = array($_lang['configcheck_cache']); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | if (!checkSiteCache()) { |
| 139 | 139 | $warningspresent = 1; |
| 140 | - $warnings[]= array($lang['configcheck_sitecache_integrity']); |
|
| 140 | + $warnings[] = array($lang['configcheck_sitecache_integrity']); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | -if (!is_writable(MODX_BASE_PATH . "assets/images/")) { |
|
| 143 | +if (!is_writable(MODX_BASE_PATH."assets/images/")) { |
|
| 144 | 144 | $warningspresent = 1; |
| 145 | 145 | $warnings[] = array($_lang['configcheck_images']); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | -if(strpos($modx->config['rb_base_dir'],MODX_BASE_PATH)!==0) { |
|
| 148 | +if (strpos($modx->config['rb_base_dir'], MODX_BASE_PATH) !== 0) { |
|
| 149 | 149 | $warningspresent = 1; |
| 150 | 150 | $warnings[] = array($_lang['configcheck_rb_base_dir']); |
| 151 | 151 | } |
| 152 | -if(strpos($modx->config['filemanager_path'],MODX_BASE_PATH)!==0) { |
|
| 152 | +if (strpos($modx->config['filemanager_path'], MODX_BASE_PATH) !== 0) { |
|
| 153 | 153 | $warningspresent = 1; |
| 154 | 154 | $warnings[] = array($_lang['configcheck_filemanager_path']); |
| 155 | 155 | } |
@@ -157,36 +157,36 @@ discard block |
||
| 157 | 157 | // clear file info cache |
| 158 | 158 | clearstatcache(); |
| 159 | 159 | |
| 160 | -if ($warningspresent==1) { |
|
| 160 | +if ($warningspresent == 1) { |
|
| 161 | 161 | |
| 162 | -if(!isset($modx->config['send_errormail'])) $modx->config['send_errormail']='3'; |
|
| 162 | +if (!isset($modx->config['send_errormail'])) $modx->config['send_errormail'] = '3'; |
|
| 163 | 163 | $config_check_results = "<h3>".$_lang['configcheck_notok']."</h3>"; |
| 164 | 164 | |
| 165 | -for ($i=0;$i<count($warnings);$i++) { |
|
| 165 | +for ($i = 0; $i < count($warnings); $i++) { |
|
| 166 | 166 | switch ($warnings[$i][0]) { |
| 167 | 167 | case $_lang['configcheck_configinc']; |
| 168 | 168 | $warnings[$i][1] = $_lang['configcheck_configinc_msg']; |
| 169 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']); |
|
| 169 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1], $_lang['configcheck_configinc']); |
|
| 170 | 170 | break; |
| 171 | 171 | case $_lang['configcheck_installer'] : |
| 172 | 172 | $warnings[$i][1] = $_lang['configcheck_installer_msg']; |
| 173 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']); |
|
| 173 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1], $_lang['configcheck_installer']); |
|
| 174 | 174 | break; |
| 175 | 175 | case $_lang['configcheck_cache'] : |
| 176 | 176 | $warnings[$i][1] = $_lang['configcheck_cache_msg']; |
| 177 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']); |
|
| 177 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 2, $warnings[$i][1], $_lang['configcheck_cache']); |
|
| 178 | 178 | break; |
| 179 | 179 | case $_lang['configcheck_images'] : |
| 180 | 180 | $warnings[$i][1] = $_lang['configcheck_images_msg']; |
| 181 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']); |
|
| 181 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 2, $warnings[$i][1], $_lang['configcheck_images']); |
|
| 182 | 182 | break; |
| 183 | 183 | case $_lang['configcheck_sysfiles_mod']: |
| 184 | 184 | $warnings[$i][1] = $_lang["configcheck_sysfiles_mod_msg"]; |
| 185 | - $warnings[$i][2] = '<ul><li>'. implode('</li><li>', $sysfiles_check) .'</li></ul>'; |
|
| 186 | - if($modx->hasPermission('settings')) { |
|
| 187 | - $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>'; |
|
| 185 | + $warnings[$i][2] = '<ul><li>'.implode('</li><li>', $sysfiles_check).'</li></ul>'; |
|
| 186 | + if ($modx->hasPermission('settings')) { |
|
| 187 | + $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\''.$_lang["reset_sysfiles_checksum_alert"].'\')">'.$_lang["reset_sysfiles_checksum_button"].'</a></li></ul>'; |
|
| 188 | 188 | } |
| 189 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']); |
|
| 189 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1]." ".implode(', ', $sysfiles_check), $_lang['configcheck_sysfiles_mod']); |
|
| 190 | 190 | break; |
| 191 | 191 | case $_lang['configcheck_lang_difference'] : |
| 192 | 192 | $warnings[$i][1] = $_lang['configcheck_lang_difference_msg']; |
@@ -208,18 +208,18 @@ discard block |
||
| 208 | 208 | break; |
| 209 | 209 | case $_lang['configcheck_validate_referer'] : |
| 210 | 210 | $msg = $_lang['configcheck_validate_referer_msg']; |
| 211 | - $msg .= '<br />' . sprintf($_lang["configcheck_hide_warning"], 'validate_referer'); |
|
| 211 | + $msg .= '<br />'.sprintf($_lang["configcheck_hide_warning"], 'validate_referer'); |
|
| 212 | 212 | $warnings[$i][1] = "<span id=\"validate_referer_warning_wrapper\">{$msg}</span>\n"; |
| 213 | 213 | break; |
| 214 | 214 | case $_lang['configcheck_templateswitcher_present'] : |
| 215 | 215 | $msg = $_lang["configcheck_templateswitcher_present_msg"]; |
| 216 | - if(isset($_SESSION['mgrPermissions']['save_plugin']) && $_SESSION['mgrPermissions']['save_plugin'] == '1') { |
|
| 217 | - $msg .= '<br />' . $_lang["configcheck_templateswitcher_present_disable"]; |
|
| 216 | + if (isset($_SESSION['mgrPermissions']['save_plugin']) && $_SESSION['mgrPermissions']['save_plugin'] == '1') { |
|
| 217 | + $msg .= '<br />'.$_lang["configcheck_templateswitcher_present_disable"]; |
|
| 218 | 218 | } |
| 219 | - if(isset($_SESSION['mgrPermissions']['delete_plugin']) && $_SESSION['mgrPermissions']['delete_plugin'] == '1') { |
|
| 220 | - $msg .= '<br />' . $_lang["configcheck_templateswitcher_present_delete"]; |
|
| 219 | + if (isset($_SESSION['mgrPermissions']['delete_plugin']) && $_SESSION['mgrPermissions']['delete_plugin'] == '1') { |
|
| 220 | + $msg .= '<br />'.$_lang["configcheck_templateswitcher_present_delete"]; |
|
| 221 | 221 | } |
| 222 | - $msg .= '<br />' . sprintf($_lang["configcheck_hide_warning"], 'templateswitcher_present'); |
|
| 222 | + $msg .= '<br />'.sprintf($_lang["configcheck_hide_warning"], 'templateswitcher_present'); |
|
| 223 | 223 | $warnings[$i][1] = "<span id=\"templateswitcher_present_warning_wrapper\">{$msg}</span>\n"; |
| 224 | 224 | break; |
| 225 | 225 | case $_lang['configcheck_rb_base_dir'] : |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | $warnings[$i][1] = $_lang['configcheck_default_msg']; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - $admin_warning = $_SESSION['mgrRole']!=1 ? $_lang['configcheck_admin'] : "" ; |
|
| 235 | + $admin_warning = $_SESSION['mgrRole'] != 1 ? $_lang['configcheck_admin'] : ""; |
|
| 236 | 236 | $config_check_results .= " |
| 237 | 237 | <fieldset> |
| 238 | 238 | <p><strong>".$_lang['configcheck_warning']."</strong> '".$warnings[$i][0]."'</p> |
@@ -241,11 +241,11 @@ discard block |
||
| 241 | 241 | ".(isset($warnings[$i][2]) ? '<div style="padding-left:1em">'.$warnings[$i][2].'</div>' : '')." |
| 242 | 242 | </fieldset> |
| 243 | 243 | "; |
| 244 | - if ($i!=count($warnings)-1) { |
|
| 244 | + if ($i != count($warnings) - 1) { |
|
| 245 | 245 | $config_check_results .= "<br />"; |
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | - $_SESSION["mgrConfigCheck"]=true; |
|
| 248 | + $_SESSION["mgrConfigCheck"] = true; |
|
| 249 | 249 | } else { |
| 250 | 250 | $config_check_results = $_lang['configcheck_ok']; |
| 251 | 251 | } |
@@ -19,12 +19,12 @@ discard block |
||
| 19 | 19 | $warningspresent = 0; |
| 20 | 20 | |
| 21 | 21 | $sysfiles_check = $modx->manager->checkSystemChecksum(); |
| 22 | -if ($sysfiles_check!=='0'){ |
|
| 22 | +if ($sysfiles_check!=='0') { |
|
| 23 | 23 | $warningspresent = 1; |
| 24 | 24 | $warnings[] = array($_lang['configcheck_sysfiles_mod']); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | -if (is_writable("includes/config.inc.php")){ |
|
| 27 | +if (is_writable("includes/config.inc.php")) { |
|
| 28 | 28 | // Warn if world writable |
| 29 | 29 | if(@fileperms('includes/config.inc.php') & 0x0002) { |
| 30 | 30 | $warningspresent = 1; |
@@ -120,7 +120,8 @@ discard block |
||
| 120 | 120 | /** |
| 121 | 121 | * @return bool |
| 122 | 122 | */ |
| 123 | - function checkSiteCache() { |
|
| 123 | + function checkSiteCache() |
|
| 124 | + { |
|
| 124 | 125 | $modx = evolutionCMS(); |
| 125 | 126 | $checked= true; |
| 126 | 127 | if (file_exists($modx->config['base_path'] . 'assets/cache/siteCache.idx.php')) { |
@@ -159,26 +160,36 @@ discard block |
||
| 159 | 160 | |
| 160 | 161 | if ($warningspresent==1) { |
| 161 | 162 | |
| 162 | -if(!isset($modx->config['send_errormail'])) $modx->config['send_errormail']='3'; |
|
| 163 | +if(!isset($modx->config['send_errormail'])) { |
|
| 164 | + $modx->config['send_errormail']='3'; |
|
| 165 | +} |
|
| 163 | 166 | $config_check_results = "<h3>".$_lang['configcheck_notok']."</h3>"; |
| 164 | 167 | |
| 165 | 168 | for ($i=0;$i<count($warnings);$i++) { |
| 166 | 169 | switch ($warnings[$i][0]) { |
| 167 | 170 | case $_lang['configcheck_configinc']; |
| 168 | 171 | $warnings[$i][1] = $_lang['configcheck_configinc_msg']; |
| 169 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']); |
|
| 172 | + if(!$_SESSION["mgrConfigCheck"]) { |
|
| 173 | + $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']); |
|
| 174 | + } |
|
| 170 | 175 | break; |
| 171 | 176 | case $_lang['configcheck_installer'] : |
| 172 | 177 | $warnings[$i][1] = $_lang['configcheck_installer_msg']; |
| 173 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']); |
|
| 178 | + if(!$_SESSION["mgrConfigCheck"]) { |
|
| 179 | + $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']); |
|
| 180 | + } |
|
| 174 | 181 | break; |
| 175 | 182 | case $_lang['configcheck_cache'] : |
| 176 | 183 | $warnings[$i][1] = $_lang['configcheck_cache_msg']; |
| 177 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']); |
|
| 184 | + if(!$_SESSION["mgrConfigCheck"]) { |
|
| 185 | + $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']); |
|
| 186 | + } |
|
| 178 | 187 | break; |
| 179 | 188 | case $_lang['configcheck_images'] : |
| 180 | 189 | $warnings[$i][1] = $_lang['configcheck_images_msg']; |
| 181 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']); |
|
| 190 | + if(!$_SESSION["mgrConfigCheck"]) { |
|
| 191 | + $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']); |
|
| 192 | + } |
|
| 182 | 193 | break; |
| 183 | 194 | case $_lang['configcheck_sysfiles_mod']: |
| 184 | 195 | $warnings[$i][1] = $_lang["configcheck_sysfiles_mod_msg"]; |
@@ -186,7 +197,9 @@ discard block |
||
| 186 | 197 | if($modx->hasPermission('settings')) { |
| 187 | 198 | $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>'; |
| 188 | 199 | } |
| 189 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']); |
|
| 200 | + if(!$_SESSION["mgrConfigCheck"]) { |
|
| 201 | + $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']); |
|
| 202 | + } |
|
| 190 | 203 | break; |
| 191 | 204 | case $_lang['configcheck_lang_difference'] : |
| 192 | 205 | $warnings[$i][1] = $_lang['configcheck_lang_difference_msg']; |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | function ProcessFile($file) { |
| 133 | 133 | // get the file |
| 134 | - $buffer = @file_get_contents($file); |
|
| 135 | - if ($buffer === false) $buffer = " Could not retrieve document '$file'."; |
|
| 134 | + $buffer = @file_get_contents($file); |
|
| 135 | + if ($buffer === false) $buffer = " Could not retrieve document '$file'."; |
|
| 136 | 136 | return $buffer; |
| 137 | 137 | } |
| 138 | 138 | |
@@ -168,20 +168,20 @@ discard block |
||
| 168 | 168 | function parseTvValues($param, $tvsArray) |
| 169 | 169 | { |
| 170 | 170 | $modx = evolutionCMS(); |
| 171 | - $tvsArray = is_array($modx->documentObject) ? array_merge($tvsArray, $modx->documentObject) : $tvsArray; |
|
| 172 | - if (strpos($param, '[*') !== false) { |
|
| 173 | - $matches = $modx->getTagsFromContent($param, '[*', '*]'); |
|
| 174 | - foreach ($matches[0] as $i=>$match) { |
|
| 175 | - if(isset($tvsArray[ $matches[1][$i] ])) { |
|
| 176 | - if(is_array($tvsArray[ $matches[1][$i] ])) { |
|
| 177 | - $value = $tvsArray[$matches[1][$i]]['value']; |
|
| 178 | - $value = $value === '' ? $tvsArray[$matches[1][$i]]['default_text'] : $value; |
|
| 179 | - } else { |
|
| 180 | - $value = $tvsArray[ $matches[1][$i] ]; |
|
| 181 | - } |
|
| 182 | - $param = str_replace($match, $value, $param); |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - } |
|
| 186 | - return $param; |
|
| 171 | + $tvsArray = is_array($modx->documentObject) ? array_merge($tvsArray, $modx->documentObject) : $tvsArray; |
|
| 172 | + if (strpos($param, '[*') !== false) { |
|
| 173 | + $matches = $modx->getTagsFromContent($param, '[*', '*]'); |
|
| 174 | + foreach ($matches[0] as $i=>$match) { |
|
| 175 | + if(isset($tvsArray[ $matches[1][$i] ])) { |
|
| 176 | + if(is_array($tvsArray[ $matches[1][$i] ])) { |
|
| 177 | + $value = $tvsArray[$matches[1][$i]]['value']; |
|
| 178 | + $value = $value === '' ? $tvsArray[$matches[1][$i]]['default_text'] : $value; |
|
| 179 | + } else { |
|
| 180 | + $value = $tvsArray[ $matches[1][$i] ]; |
|
| 181 | + } |
|
| 182 | + $param = str_replace($match, $value, $param); |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + } |
|
| 186 | + return $param; |
|
| 187 | 187 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * Created by Raymond Irving Feb, 2005 |
| 5 | 5 | */ |
| 6 | 6 | global $BINDINGS; // Array of supported bindings. must be upper case |
| 7 | -$BINDINGS = array ( |
|
| 7 | +$BINDINGS = array( |
|
| 8 | 8 | 'FILE', |
| 9 | 9 | 'CHUNK', |
| 10 | 10 | 'DOCUMENT', |
@@ -22,13 +22,13 @@ discard block |
||
| 22 | 22 | * @param array $tvsArray |
| 23 | 23 | * @return string |
| 24 | 24 | */ |
| 25 | -function ProcessTVCommand($value, $name = '', $docid = '', $src='docform', $tvsArray = array()) { |
|
| 25 | +function ProcessTVCommand($value, $name = '', $docid = '', $src = 'docform', $tvsArray = array()){ |
|
| 26 | 26 | $modx = evolutionCMS(); |
| 27 | - $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
|
| 27 | + $docid = (int) $docid > 0 ? (int) $docid : $modx->documentIdentifier; |
|
| 28 | 28 | $nvalue = trim($value); |
| 29 | 29 | if (substr($nvalue, 0, 1) != '@') |
| 30 | 30 | return $value; |
| 31 | - elseif(isset($modx->config['enable_bindings']) && $modx->config['enable_bindings']!=1 && $src==='docform') { |
|
| 31 | + elseif (isset($modx->config['enable_bindings']) && $modx->config['enable_bindings'] != 1 && $src === 'docform') { |
|
| 32 | 32 | return '@Bindings is disabled.'; |
| 33 | 33 | } |
| 34 | 34 | else { |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | break; |
| 55 | 55 | |
| 56 | 56 | case "SELECT" : // selects a record from the cms database |
| 57 | - $rt = array (); |
|
| 58 | - $replacementVars = array ( |
|
| 57 | + $rt = array(); |
|
| 58 | + $replacementVars = array( |
|
| 59 | 59 | 'DBASE' => $modx->db->config['dbase'], |
| 60 | 60 | 'PREFIX' => $modx->db->config['table_prefix'] |
| 61 | 61 | ); |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | break; |
| 97 | 97 | |
| 98 | 98 | case 'DIRECTORY' : |
| 99 | - $files = array (); |
|
| 100 | - $path = $modx->config['base_path'] . $param; |
|
| 99 | + $files = array(); |
|
| 100 | + $path = $modx->config['base_path'].$param; |
|
| 101 | 101 | if (substr($path, -1, 1) != '/') { |
| 102 | 102 | $path .= '/'; |
| 103 | 103 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @param $file |
| 130 | 130 | * @return string |
| 131 | 131 | */ |
| 132 | -function ProcessFile($file) { |
|
| 132 | +function ProcessFile($file){ |
|
| 133 | 133 | // get the file |
| 134 | 134 | $buffer = @file_get_contents($file); |
| 135 | 135 | if ($buffer === false) $buffer = " Could not retrieve document '$file'."; |
@@ -146,12 +146,12 @@ discard block |
||
| 146 | 146 | { |
| 147 | 147 | global $BINDINGS; |
| 148 | 148 | $binding_array = array(); |
| 149 | - foreach($BINDINGS as $cmd) |
|
| 149 | + foreach ($BINDINGS as $cmd) |
|
| 150 | 150 | { |
| 151 | - if(strpos($binding_string,'@'.$cmd)===0) |
|
| 151 | + if (strpos($binding_string, '@'.$cmd) === 0) |
|
| 152 | 152 | { |
| 153 | - $code = substr($binding_string,strlen($cmd)+1); |
|
| 154 | - $binding_array = array($cmd,trim($code)); |
|
| 153 | + $code = substr($binding_string, strlen($cmd) + 1); |
|
| 154 | + $binding_array = array($cmd, trim($code)); |
|
| 155 | 155 | break; |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -172,12 +172,12 @@ discard block |
||
| 172 | 172 | if (strpos($param, '[*') !== false) { |
| 173 | 173 | $matches = $modx->getTagsFromContent($param, '[*', '*]'); |
| 174 | 174 | foreach ($matches[0] as $i=>$match) { |
| 175 | - if(isset($tvsArray[ $matches[1][$i] ])) { |
|
| 176 | - if(is_array($tvsArray[ $matches[1][$i] ])) { |
|
| 175 | + if (isset($tvsArray[$matches[1][$i]])) { |
|
| 176 | + if (is_array($tvsArray[$matches[1][$i]])) { |
|
| 177 | 177 | $value = $tvsArray[$matches[1][$i]]['value']; |
| 178 | 178 | $value = $value === '' ? $tvsArray[$matches[1][$i]]['default_text'] : $value; |
| 179 | 179 | } else { |
| 180 | - $value = $tvsArray[ $matches[1][$i] ]; |
|
| 180 | + $value = $tvsArray[$matches[1][$i]]; |
|
| 181 | 181 | } |
| 182 | 182 | $param = str_replace($match, $value, $param); |
| 183 | 183 | } |
@@ -22,16 +22,16 @@ discard block |
||
| 22 | 22 | * @param array $tvsArray |
| 23 | 23 | * @return string |
| 24 | 24 | */ |
| 25 | -function ProcessTVCommand($value, $name = '', $docid = '', $src='docform', $tvsArray = array()) { |
|
| 25 | +function ProcessTVCommand($value, $name = '', $docid = '', $src='docform', $tvsArray = array()) |
|
| 26 | +{ |
|
| 26 | 27 | $modx = evolutionCMS(); |
| 27 | 28 | $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
| 28 | 29 | $nvalue = trim($value); |
| 29 | - if (substr($nvalue, 0, 1) != '@') |
|
| 30 | - return $value; |
|
| 31 | - elseif(isset($modx->config['enable_bindings']) && $modx->config['enable_bindings']!=1 && $src==='docform') { |
|
| 30 | + if (substr($nvalue, 0, 1) != '@') { |
|
| 31 | + return $value; |
|
| 32 | + } elseif(isset($modx->config['enable_bindings']) && $modx->config['enable_bindings']!=1 && $src==='docform') { |
|
| 32 | 33 | return '@Bindings is disabled.'; |
| 33 | - } |
|
| 34 | - else { |
|
| 34 | + } else { |
|
| 35 | 35 | list ($cmd, $param) = ParseCommand($nvalue); |
| 36 | 36 | $cmd = trim($cmd); |
| 37 | 37 | $param = parseTvValues($param, $tvsArray); |
@@ -47,10 +47,11 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | case "DOCUMENT" : // retrieve a document and process it's content |
| 49 | 49 | $rs = $modx->getDocument($param); |
| 50 | - if (is_array($rs)) |
|
| 51 | - $output = $rs['content']; |
|
| 52 | - else |
|
| 53 | - $output = "Unable to locate document $param"; |
|
| 50 | + if (is_array($rs)) { |
|
| 51 | + $output = $rs['content']; |
|
| 52 | + } else { |
|
| 53 | + $output = "Unable to locate document $param"; |
|
| 54 | + } |
|
| 54 | 55 | break; |
| 55 | 56 | |
| 56 | 57 | case "SELECT" : // selects a record from the cms database |
@@ -80,8 +81,10 @@ discard block |
||
| 80 | 81 | |
| 81 | 82 | // Grab document regardless of publish status |
| 82 | 83 | $doc = $modx->getPageInfo($parent_id, 0, 'id,parent,published'); |
| 83 | - if ($doc['parent'] != 0 && !$doc['published']) |
|
| 84 | - continue; // hide unpublished docs if we're not at the top |
|
| 84 | + if ($doc['parent'] != 0 && !$doc['published']) { |
|
| 85 | + continue; |
|
| 86 | + } |
|
| 87 | + // hide unpublished docs if we're not at the top |
|
| 85 | 88 | |
| 86 | 89 | $tv = $modx->getTemplateVar($name, '*', $doc['id'], $doc['published']); |
| 87 | 90 | |
@@ -129,10 +132,13 @@ discard block |
||
| 129 | 132 | * @param $file |
| 130 | 133 | * @return string |
| 131 | 134 | */ |
| 132 | -function ProcessFile($file) { |
|
| 135 | +function ProcessFile($file) |
|
| 136 | +{ |
|
| 133 | 137 | // get the file |
| 134 | 138 | $buffer = @file_get_contents($file); |
| 135 | - if ($buffer === false) $buffer = " Could not retrieve document '$file'."; |
|
| 139 | + if ($buffer === false) { |
|
| 140 | + $buffer = " Could not retrieve document '$file'."; |
|
| 141 | + } |
|
| 136 | 142 | return $buffer; |
| 137 | 143 | } |
| 138 | 144 | |
@@ -146,10 +152,8 @@ discard block |
||
| 146 | 152 | { |
| 147 | 153 | global $BINDINGS; |
| 148 | 154 | $binding_array = array(); |
| 149 | - foreach($BINDINGS as $cmd) |
|
| 150 | - { |
|
| 151 | - if(strpos($binding_string,'@'.$cmd)===0) |
|
| 152 | - { |
|
| 155 | + foreach($BINDINGS as $cmd) { |
|
| 156 | + if(strpos($binding_string,'@'.$cmd)===0) { |
|
| 153 | 157 | $code = substr($binding_string,strlen($cmd)+1); |
| 154 | 158 | $binding_array = array($cmd,trim($code)); |
| 155 | 159 | break; |
@@ -10,178 +10,178 @@ |
||
| 10 | 10 | Class TemplateParser {
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * @param array $config [action, tabs, toArray] |
|
| 14 | - * @param array $data |
|
| 15 | - * @return string |
|
| 16 | - */ |
|
| 17 | - public function output($config = array(), $data = array()) {
|
|
| 13 | + * @param array $config [action, tabs, toArray] |
|
| 14 | + * @param array $data |
|
| 15 | + * @return string |
|
| 16 | + */ |
|
| 17 | + public function output($config = array(), $data = array()) {
|
|
| 18 | 18 | $modx = evolutionCMS(); |
| 19 | 19 | |
| 20 | - $output = ''; |
|
| 21 | - $action = !empty($config['action']) ? $config['action'] : (!empty($_REQUEST['a']) ? $_REQUEST['a'] : ''); |
|
| 22 | - $tab = isset($config['tab']) ? ' AND tab IN(' . $config['tab'] . ')' : '';
|
|
| 20 | + $output = ''; |
|
| 21 | + $action = !empty($config['action']) ? $config['action'] : (!empty($_REQUEST['a']) ? $_REQUEST['a'] : ''); |
|
| 22 | + $tab = isset($config['tab']) ? ' AND tab IN(' . $config['tab'] . ')' : '';
|
|
| 23 | 23 | |
| 24 | - if($action) {
|
|
| 25 | - $sql = $modx->db->query('SELECT t1.*, IF(t1.alias=\'\',t1.name,t1.alias) AS alias, t2.category AS category_name
|
|
| 24 | + if($action) {
|
|
| 25 | + $sql = $modx->db->query('SELECT t1.*, IF(t1.alias=\'\',t1.name,t1.alias) AS alias, t2.category AS category_name
|
|
| 26 | 26 | FROM ' . $modx->getFullTableName('system_templates') . ' AS t1
|
| 27 | 27 | INNER JOIN ' . $modx->getFullTableName('categories') . ' AS t2 ON t2.id=t1.category
|
| 28 | 28 | WHERE t1.action IN(' . $action . ') ' . $tab . '
|
| 29 | 29 | ORDER BY t1.tab ASC, t1.rank ASC'); |
| 30 | 30 | |
| 31 | - if($modx->db->getRecordCount($sql)) {
|
|
| 32 | - $tabs = array(); |
|
| 33 | - while($row = $modx->db->getRow($sql)) {
|
|
| 34 | - if(!$row['value'] && !empty($data[$row['name']])) {
|
|
| 35 | - $row['value'] = $data[$row['name']]; |
|
| 36 | - } |
|
| 37 | - $tabs[$row['tab']]['category_name'] = $row['category_name']; |
|
| 38 | - $tabs[$row['tab']][$row['name']] = TemplateParser::render($row); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - if(!empty($config['toArray'])) {
|
|
| 42 | - $output = $tabs; |
|
| 43 | - } else {
|
|
| 44 | - $output .= '<div class="tab-pane" id="pane_' . $action . '">'; |
|
| 45 | - $output .= ' |
|
| 31 | + if($modx->db->getRecordCount($sql)) {
|
|
| 32 | + $tabs = array(); |
|
| 33 | + while($row = $modx->db->getRow($sql)) {
|
|
| 34 | + if(!$row['value'] && !empty($data[$row['name']])) {
|
|
| 35 | + $row['value'] = $data[$row['name']]; |
|
| 36 | + } |
|
| 37 | + $tabs[$row['tab']]['category_name'] = $row['category_name']; |
|
| 38 | + $tabs[$row['tab']][$row['name']] = TemplateParser::render($row); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + if(!empty($config['toArray'])) {
|
|
| 42 | + $output = $tabs; |
|
| 43 | + } else {
|
|
| 44 | + $output .= '<div class="tab-pane" id="pane_' . $action . '">'; |
|
| 45 | + $output .= ' |
|
| 46 | 46 | <script type="text/javascript"> |
| 47 | 47 | var pane_' . $action . ' = new WebFXTabPane(document.getElementById("pane_' . $action . '"), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . ');
|
| 48 | 48 | </script>'; |
| 49 | 49 | |
| 50 | - foreach($tabs as $idTab => $tab) {
|
|
| 51 | - $output .= '<div class="tab-page" id="tab_' . $action . '_' . $idTab . '">'; |
|
| 52 | - $output .= ' |
|
| 50 | + foreach($tabs as $idTab => $tab) {
|
|
| 51 | + $output .= '<div class="tab-page" id="tab_' . $action . '_' . $idTab . '">'; |
|
| 52 | + $output .= ' |
|
| 53 | 53 | <h2 class="tab">' . (!empty($config['tabs'][$idTab]) ? $config['tabs'][$idTab] : $tab['category_name']) . '</h2> |
| 54 | 54 | <script type="text/javascript">pane_' . $action . '.addTabPage(document.getElementById("tab_' . $action . '_' . $idTab . '"));</script>';
|
| 55 | - unset($tab['category_name']); |
|
| 56 | - foreach($tab as $item) {
|
|
| 57 | - $output .= $item; |
|
| 58 | - } |
|
| 59 | - $output .= '</div>'; |
|
| 60 | - } |
|
| 61 | - $output .= '</div>'; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - return $output; |
|
| 67 | - } |
|
| 55 | + unset($tab['category_name']); |
|
| 56 | + foreach($tab as $item) {
|
|
| 57 | + $output .= $item; |
|
| 58 | + } |
|
| 59 | + $output .= '</div>'; |
|
| 60 | + } |
|
| 61 | + $output .= '</div>'; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + return $output; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * @param array $data |
| 71 | 71 | * @return string |
| 72 | 72 | */ |
| 73 | - private function render($data) {
|
|
| 74 | - $modx = evolutionCMS(); global $_lang, $_country_lang; |
|
| 73 | + private function render($data) {
|
|
| 74 | + $modx = evolutionCMS(); global $_lang, $_country_lang; |
|
| 75 | 75 | |
| 76 | - $data['lang.name'] = (isset($_lang[$data['alias']]) ? $_lang[$data['alias']] : $data['alias']); |
|
| 77 | - $data['value'] = (isset($_POST[$data['name']][$data['value']]) ? $_POST[$data['name']][$data['value']] : (isset($data['value']) ? $modx->htmlspecialchars($data['value']) : '')); |
|
| 78 | - $data['readonly'] = ($data['readonly'] ? ' readonly' : ''); |
|
| 76 | + $data['lang.name'] = (isset($_lang[$data['alias']]) ? $_lang[$data['alias']] : $data['alias']); |
|
| 77 | + $data['value'] = (isset($_POST[$data['name']][$data['value']]) ? $_POST[$data['name']][$data['value']] : (isset($data['value']) ? $modx->htmlspecialchars($data['value']) : '')); |
|
| 78 | + $data['readonly'] = ($data['readonly'] ? ' readonly' : ''); |
|
| 79 | 79 | |
| 80 | - $output = ''; |
|
| 81 | - $output .= '<div class="form-group row">'; |
|
| 80 | + $output = ''; |
|
| 81 | + $output .= '<div class="form-group row">'; |
|
| 82 | 82 | |
| 83 | - switch($data['type']) {
|
|
| 83 | + switch($data['type']) {
|
|
| 84 | 84 | |
| 85 | - case 'text': |
|
| 86 | - $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
|
| 85 | + case 'text': |
|
| 86 | + $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
|
| 87 | 87 | <div class="col-sm-7"> |
| 88 | 88 | <input type="text" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
| 89 | - $output .= $data['content']; |
|
| 90 | - $output .= '</div>'; |
|
| 89 | + $output .= $data['content']; |
|
| 90 | + $output .= '</div>'; |
|
| 91 | 91 | |
| 92 | - break; |
|
| 92 | + break; |
|
| 93 | 93 | |
| 94 | - case 'textarea': |
|
| 95 | - $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
|
| 94 | + case 'textarea': |
|
| 95 | + $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
|
| 96 | 96 | <div class="col-sm-7"> |
| 97 | 97 | <textarea name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;"[+readonly+]>[+value+]</textarea>'; |
| 98 | - $output .= $data['content']; |
|
| 99 | - $output .= '</div>'; |
|
| 98 | + $output .= $data['content']; |
|
| 99 | + $output .= '</div>'; |
|
| 100 | 100 | |
| 101 | - break; |
|
| 101 | + break; |
|
| 102 | 102 | |
| 103 | - case 'date': |
|
| 104 | - $data['value'] = (isset($_POST[$data['name']][$data['value']]) ? $modx->toDateFormat($_POST[$data['name']][$data['value']]) : (isset($data['value']) ? $modx->toDateFormat($data['value']) : '')); |
|
| 105 | - $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
|
| 103 | + case 'date': |
|
| 104 | + $data['value'] = (isset($_POST[$data['name']][$data['value']]) ? $modx->toDateFormat($_POST[$data['name']][$data['value']]) : (isset($data['value']) ? $modx->toDateFormat($data['value']) : '')); |
|
| 105 | + $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
|
| 106 | 106 | <div class="col-sm-7"> |
| 107 | 107 | <input type="text" name="[+name+]" class="form-control DatePicker" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
| 108 | - $output .= $data['content']; |
|
| 109 | - $output .= '</div>'; |
|
| 110 | - |
|
| 111 | - break; |
|
| 112 | - |
|
| 113 | - case 'select': |
|
| 114 | - $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
| 115 | - $output .= '<div class="col-sm-7">'; |
|
| 116 | - $output .= '<select name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;">'; |
|
| 117 | - if($data['name'] == 'country' && isset($_country_lang)) {
|
|
| 118 | - $chosenCountry = isset($_POST['country']) ? $_POST['country'] : $data['country']; |
|
| 119 | - $output .= '<option value=""' . (!isset($chosenCountry) ? ' selected' : '') . '> </option>'; |
|
| 120 | - foreach($_country_lang as $key => $value) {
|
|
| 121 | - $output .= '<option value="' . $key . '"' . (isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '') . '>' . $value . '</option>'; |
|
| 122 | - } |
|
| 123 | - } else {
|
|
| 124 | - if($data['elements']) {
|
|
| 125 | - $elements = explode('||', $data['elements']);
|
|
| 126 | - foreach($elements as $key => $value) {
|
|
| 127 | - $value = explode('==', $value);
|
|
| 128 | - $output .= '<option value="' . $value[1] . '">' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]) . '</option>'; |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - } |
|
| 132 | - $output .= '</select>'; |
|
| 133 | - $output .= $data['content']; |
|
| 134 | - $output .= '</div>'; |
|
| 135 | - |
|
| 136 | - break; |
|
| 137 | - |
|
| 138 | - case 'checkbox': |
|
| 139 | - $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
| 140 | - $output .= '<div class="col-sm-7">'; |
|
| 141 | - $output .= '<input type="checkbox" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
|
| 142 | - if($data['elements']) {
|
|
| 143 | - $elements = explode('||', $data['elements']);
|
|
| 144 | - foreach($elements as $key => $value) {
|
|
| 145 | - $value = explode('==', $value);
|
|
| 146 | - $output .= '<br /><input type="checkbox" name="' . $value[0] . '" class="form-control" id="' . $value[0] . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - $output .= $data['content']; |
|
| 150 | - $output .= '</div>'; |
|
| 151 | - |
|
| 152 | - break; |
|
| 153 | - |
|
| 154 | - case 'radio': |
|
| 155 | - $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
| 156 | - $output .= '<div class="col-sm-7">'; |
|
| 157 | - $output .= '<input type="radio" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
|
| 158 | - if($data['elements']) {
|
|
| 159 | - $elements = explode('||', $data['elements']);
|
|
| 160 | - foreach($elements as $key => $value) {
|
|
| 161 | - $value = explode('==', $value);
|
|
| 162 | - $output .= '<br /><input type="radio" name="[+name+]" class="form-control" id="[+name+]_' . $key . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - $output .= $data['content']; |
|
| 166 | - $output .= '</div>'; |
|
| 167 | - |
|
| 168 | - break; |
|
| 169 | - |
|
| 170 | - case 'custom': |
|
| 171 | - $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
| 172 | - $output .= '<div class="col-sm-7">'; |
|
| 173 | - $output .= $data['content']; |
|
| 174 | - $output .= '</div>'; |
|
| 175 | - |
|
| 176 | - break; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - $output .= '</div>'; |
|
| 180 | - |
|
| 181 | - $output = $modx->parseText($output, $data); |
|
| 182 | - |
|
| 183 | - return $output; |
|
| 184 | - } |
|
| 108 | + $output .= $data['content']; |
|
| 109 | + $output .= '</div>'; |
|
| 110 | + |
|
| 111 | + break; |
|
| 112 | + |
|
| 113 | + case 'select': |
|
| 114 | + $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
| 115 | + $output .= '<div class="col-sm-7">'; |
|
| 116 | + $output .= '<select name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;">'; |
|
| 117 | + if($data['name'] == 'country' && isset($_country_lang)) {
|
|
| 118 | + $chosenCountry = isset($_POST['country']) ? $_POST['country'] : $data['country']; |
|
| 119 | + $output .= '<option value=""' . (!isset($chosenCountry) ? ' selected' : '') . '> </option>'; |
|
| 120 | + foreach($_country_lang as $key => $value) {
|
|
| 121 | + $output .= '<option value="' . $key . '"' . (isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '') . '>' . $value . '</option>'; |
|
| 122 | + } |
|
| 123 | + } else {
|
|
| 124 | + if($data['elements']) {
|
|
| 125 | + $elements = explode('||', $data['elements']);
|
|
| 126 | + foreach($elements as $key => $value) {
|
|
| 127 | + $value = explode('==', $value);
|
|
| 128 | + $output .= '<option value="' . $value[1] . '">' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]) . '</option>'; |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | + $output .= '</select>'; |
|
| 133 | + $output .= $data['content']; |
|
| 134 | + $output .= '</div>'; |
|
| 135 | + |
|
| 136 | + break; |
|
| 137 | + |
|
| 138 | + case 'checkbox': |
|
| 139 | + $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
| 140 | + $output .= '<div class="col-sm-7">'; |
|
| 141 | + $output .= '<input type="checkbox" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
|
| 142 | + if($data['elements']) {
|
|
| 143 | + $elements = explode('||', $data['elements']);
|
|
| 144 | + foreach($elements as $key => $value) {
|
|
| 145 | + $value = explode('==', $value);
|
|
| 146 | + $output .= '<br /><input type="checkbox" name="' . $value[0] . '" class="form-control" id="' . $value[0] . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + $output .= $data['content']; |
|
| 150 | + $output .= '</div>'; |
|
| 151 | + |
|
| 152 | + break; |
|
| 153 | + |
|
| 154 | + case 'radio': |
|
| 155 | + $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
| 156 | + $output .= '<div class="col-sm-7">'; |
|
| 157 | + $output .= '<input type="radio" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
|
| 158 | + if($data['elements']) {
|
|
| 159 | + $elements = explode('||', $data['elements']);
|
|
| 160 | + foreach($elements as $key => $value) {
|
|
| 161 | + $value = explode('==', $value);
|
|
| 162 | + $output .= '<br /><input type="radio" name="[+name+]" class="form-control" id="[+name+]_' . $key . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + $output .= $data['content']; |
|
| 166 | + $output .= '</div>'; |
|
| 167 | + |
|
| 168 | + break; |
|
| 169 | + |
|
| 170 | + case 'custom': |
|
| 171 | + $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
| 172 | + $output .= '<div class="col-sm-7">'; |
|
| 173 | + $output .= $data['content']; |
|
| 174 | + $output .= '</div>'; |
|
| 175 | + |
|
| 176 | + break; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + $output .= '</div>'; |
|
| 180 | + |
|
| 181 | + $output = $modx->parseText($output, $data); |
|
| 182 | + |
|
| 183 | + return $output; |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | 186 | } |
| 187 | 187 | |
@@ -7,53 +7,53 @@ discard block |
||
| 7 | 7 | * |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -Class TemplateParser {
|
|
| 10 | +Class TemplateParser{
|
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * @param array $config [action, tabs, toArray] |
| 14 | 14 | * @param array $data |
| 15 | 15 | * @return string |
| 16 | 16 | */ |
| 17 | - public function output($config = array(), $data = array()) {
|
|
| 17 | + public function output($config = array(), $data = array()){
|
|
| 18 | 18 | $modx = evolutionCMS(); |
| 19 | 19 | |
| 20 | 20 | $output = ''; |
| 21 | 21 | $action = !empty($config['action']) ? $config['action'] : (!empty($_REQUEST['a']) ? $_REQUEST['a'] : ''); |
| 22 | - $tab = isset($config['tab']) ? ' AND tab IN(' . $config['tab'] . ')' : '';
|
|
| 22 | + $tab = isset($config['tab']) ? ' AND tab IN('.$config['tab'].')' : '';
|
|
| 23 | 23 | |
| 24 | - if($action) {
|
|
| 24 | + if ($action) {
|
|
| 25 | 25 | $sql = $modx->db->query('SELECT t1.*, IF(t1.alias=\'\',t1.name,t1.alias) AS alias, t2.category AS category_name
|
| 26 | - FROM ' . $modx->getFullTableName('system_templates') . ' AS t1
|
|
| 27 | - INNER JOIN ' . $modx->getFullTableName('categories') . ' AS t2 ON t2.id=t1.category
|
|
| 28 | - WHERE t1.action IN(' . $action . ') ' . $tab . '
|
|
| 26 | + FROM ' . $modx->getFullTableName('system_templates').' AS t1
|
|
| 27 | + INNER JOIN ' . $modx->getFullTableName('categories').' AS t2 ON t2.id=t1.category
|
|
| 28 | + WHERE t1.action IN(' . $action.') '.$tab.'
|
|
| 29 | 29 | ORDER BY t1.tab ASC, t1.rank ASC'); |
| 30 | 30 | |
| 31 | - if($modx->db->getRecordCount($sql)) {
|
|
| 31 | + if ($modx->db->getRecordCount($sql)) {
|
|
| 32 | 32 | $tabs = array(); |
| 33 | - while($row = $modx->db->getRow($sql)) {
|
|
| 34 | - if(!$row['value'] && !empty($data[$row['name']])) {
|
|
| 33 | + while ($row = $modx->db->getRow($sql)) {
|
|
| 34 | + if (!$row['value'] && !empty($data[$row['name']])) {
|
|
| 35 | 35 | $row['value'] = $data[$row['name']]; |
| 36 | 36 | } |
| 37 | 37 | $tabs[$row['tab']]['category_name'] = $row['category_name']; |
| 38 | 38 | $tabs[$row['tab']][$row['name']] = TemplateParser::render($row); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - if(!empty($config['toArray'])) {
|
|
| 41 | + if (!empty($config['toArray'])) {
|
|
| 42 | 42 | $output = $tabs; |
| 43 | 43 | } else {
|
| 44 | - $output .= '<div class="tab-pane" id="pane_' . $action . '">'; |
|
| 44 | + $output .= '<div class="tab-pane" id="pane_'.$action.'">'; |
|
| 45 | 45 | $output .= ' |
| 46 | 46 | <script type="text/javascript"> |
| 47 | - var pane_' . $action . ' = new WebFXTabPane(document.getElementById("pane_' . $action . '"), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . ');
|
|
| 47 | + var pane_' . $action.' = new WebFXTabPane(document.getElementById("pane_'.$action.'"), '.($modx->config['remember_last_tab'] == 1 ? 'true' : 'false').');
|
|
| 48 | 48 | </script>'; |
| 49 | 49 | |
| 50 | - foreach($tabs as $idTab => $tab) {
|
|
| 51 | - $output .= '<div class="tab-page" id="tab_' . $action . '_' . $idTab . '">'; |
|
| 50 | + foreach ($tabs as $idTab => $tab) {
|
|
| 51 | + $output .= '<div class="tab-page" id="tab_'.$action.'_'.$idTab.'">'; |
|
| 52 | 52 | $output .= ' |
| 53 | - <h2 class="tab">' . (!empty($config['tabs'][$idTab]) ? $config['tabs'][$idTab] : $tab['category_name']) . '</h2> |
|
| 54 | - <script type="text/javascript">pane_' . $action . '.addTabPage(document.getElementById("tab_' . $action . '_' . $idTab . '"));</script>';
|
|
| 53 | + <h2 class="tab">' . (!empty($config['tabs'][$idTab]) ? $config['tabs'][$idTab] : $tab['category_name']).'</h2> |
|
| 54 | + <script type="text/javascript">pane_' . $action.'.addTabPage(document.getElementById("tab_'.$action.'_'.$idTab.'"));</script>';
|
|
| 55 | 55 | unset($tab['category_name']); |
| 56 | - foreach($tab as $item) {
|
|
| 56 | + foreach ($tab as $item) {
|
|
| 57 | 57 | $output .= $item; |
| 58 | 58 | } |
| 59 | 59 | $output .= '</div>'; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * @param array $data |
| 71 | 71 | * @return string |
| 72 | 72 | */ |
| 73 | - private function render($data) {
|
|
| 73 | + private function render($data){
|
|
| 74 | 74 | $modx = evolutionCMS(); global $_lang, $_country_lang; |
| 75 | 75 | |
| 76 | 76 | $data['lang.name'] = (isset($_lang[$data['alias']]) ? $_lang[$data['alias']] : $data['alias']); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $output = ''; |
| 81 | 81 | $output .= '<div class="form-group row">'; |
| 82 | 82 | |
| 83 | - switch($data['type']) {
|
|
| 83 | + switch ($data['type']) {
|
|
| 84 | 84 | |
| 85 | 85 | case 'text': |
| 86 | 86 | $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
@@ -114,18 +114,18 @@ discard block |
||
| 114 | 114 | $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
| 115 | 115 | $output .= '<div class="col-sm-7">'; |
| 116 | 116 | $output .= '<select name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;">'; |
| 117 | - if($data['name'] == 'country' && isset($_country_lang)) {
|
|
| 117 | + if ($data['name'] == 'country' && isset($_country_lang)) {
|
|
| 118 | 118 | $chosenCountry = isset($_POST['country']) ? $_POST['country'] : $data['country']; |
| 119 | - $output .= '<option value=""' . (!isset($chosenCountry) ? ' selected' : '') . '> </option>'; |
|
| 120 | - foreach($_country_lang as $key => $value) {
|
|
| 121 | - $output .= '<option value="' . $key . '"' . (isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '') . '>' . $value . '</option>'; |
|
| 119 | + $output .= '<option value=""'.(!isset($chosenCountry) ? ' selected' : '').'> </option>'; |
|
| 120 | + foreach ($_country_lang as $key => $value) {
|
|
| 121 | + $output .= '<option value="'.$key.'"'.(isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '').'>'.$value.'</option>'; |
|
| 122 | 122 | } |
| 123 | 123 | } else {
|
| 124 | - if($data['elements']) {
|
|
| 124 | + if ($data['elements']) {
|
|
| 125 | 125 | $elements = explode('||', $data['elements']);
|
| 126 | - foreach($elements as $key => $value) {
|
|
| 126 | + foreach ($elements as $key => $value) {
|
|
| 127 | 127 | $value = explode('==', $value);
|
| 128 | - $output .= '<option value="' . $value[1] . '">' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]) . '</option>'; |
|
| 128 | + $output .= '<option value="'.$value[1].'">'.(isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]).'</option>'; |
|
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
| 140 | 140 | $output .= '<div class="col-sm-7">'; |
| 141 | 141 | $output .= '<input type="checkbox" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
| 142 | - if($data['elements']) {
|
|
| 142 | + if ($data['elements']) {
|
|
| 143 | 143 | $elements = explode('||', $data['elements']);
|
| 144 | - foreach($elements as $key => $value) {
|
|
| 144 | + foreach ($elements as $key => $value) {
|
|
| 145 | 145 | $value = explode('==', $value);
|
| 146 | - $output .= '<br /><input type="checkbox" name="' . $value[0] . '" class="form-control" id="' . $value[0] . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
|
| 146 | + $output .= '<br /><input type="checkbox" name="'.$value[0].'" class="form-control" id="'.$value[0].'" value="'.$value[1].'" onChange="documentDirty=true;"[+readonly+] /> '.(isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | $output .= $data['content']; |
@@ -155,11 +155,11 @@ discard block |
||
| 155 | 155 | $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
| 156 | 156 | $output .= '<div class="col-sm-7">'; |
| 157 | 157 | $output .= '<input type="radio" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
| 158 | - if($data['elements']) {
|
|
| 158 | + if ($data['elements']) {
|
|
| 159 | 159 | $elements = explode('||', $data['elements']);
|
| 160 | - foreach($elements as $key => $value) {
|
|
| 160 | + foreach ($elements as $key => $value) {
|
|
| 161 | 161 | $value = explode('==', $value);
|
| 162 | - $output .= '<br /><input type="radio" name="[+name+]" class="form-control" id="[+name+]_' . $key . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
|
| 162 | + $output .= '<br /><input type="radio" name="[+name+]" class="form-control" id="[+name+]_'.$key.'" value="'.$value[1].'" onChange="documentDirty=true;"[+readonly+] /> '.(isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
|
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | $output .= $data['content']; |
@@ -7,53 +7,55 @@ discard block |
||
| 7 | 7 | * |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -Class TemplateParser {
|
|
| 10 | +Class TemplateParser |
|
| 11 | +{ |
|
| 11 | 12 | |
| 12 | 13 | /** |
| 13 | 14 | * @param array $config [action, tabs, toArray] |
| 14 | 15 | * @param array $data |
| 15 | 16 | * @return string |
| 16 | 17 | */ |
| 17 | - public function output($config = array(), $data = array()) {
|
|
| 18 | + public function output($config = array(), $data = array()) |
|
| 19 | + { |
|
| 18 | 20 | $modx = evolutionCMS(); |
| 19 | 21 | |
| 20 | 22 | $output = ''; |
| 21 | 23 | $action = !empty($config['action']) ? $config['action'] : (!empty($_REQUEST['a']) ? $_REQUEST['a'] : ''); |
| 22 | 24 | $tab = isset($config['tab']) ? ' AND tab IN(' . $config['tab'] . ')' : '';
|
| 23 | 25 | |
| 24 | - if($action) {
|
|
| 26 | + if($action) { |
|
| 25 | 27 | $sql = $modx->db->query('SELECT t1.*, IF(t1.alias=\'\',t1.name,t1.alias) AS alias, t2.category AS category_name
|
| 26 | 28 | FROM ' . $modx->getFullTableName('system_templates') . ' AS t1
|
| 27 | 29 | INNER JOIN ' . $modx->getFullTableName('categories') . ' AS t2 ON t2.id=t1.category
|
| 28 | 30 | WHERE t1.action IN(' . $action . ') ' . $tab . '
|
| 29 | 31 | ORDER BY t1.tab ASC, t1.rank ASC'); |
| 30 | 32 | |
| 31 | - if($modx->db->getRecordCount($sql)) {
|
|
| 33 | + if($modx->db->getRecordCount($sql)) { |
|
| 32 | 34 | $tabs = array(); |
| 33 | - while($row = $modx->db->getRow($sql)) {
|
|
| 34 | - if(!$row['value'] && !empty($data[$row['name']])) {
|
|
| 35 | + while($row = $modx->db->getRow($sql)) { |
|
| 36 | + if(!$row['value'] && !empty($data[$row['name']])) { |
|
| 35 | 37 | $row['value'] = $data[$row['name']]; |
| 36 | 38 | } |
| 37 | 39 | $tabs[$row['tab']]['category_name'] = $row['category_name']; |
| 38 | 40 | $tabs[$row['tab']][$row['name']] = TemplateParser::render($row); |
| 39 | 41 | } |
| 40 | 42 | |
| 41 | - if(!empty($config['toArray'])) {
|
|
| 43 | + if(!empty($config['toArray'])) { |
|
| 42 | 44 | $output = $tabs; |
| 43 | - } else {
|
|
| 45 | + } else { |
|
| 44 | 46 | $output .= '<div class="tab-pane" id="pane_' . $action . '">'; |
| 45 | 47 | $output .= ' |
| 46 | 48 | <script type="text/javascript"> |
| 47 | 49 | var pane_' . $action . ' = new WebFXTabPane(document.getElementById("pane_' . $action . '"), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . ');
|
| 48 | 50 | </script>'; |
| 49 | 51 | |
| 50 | - foreach($tabs as $idTab => $tab) {
|
|
| 52 | + foreach($tabs as $idTab => $tab) { |
|
| 51 | 53 | $output .= '<div class="tab-page" id="tab_' . $action . '_' . $idTab . '">'; |
| 52 | 54 | $output .= ' |
| 53 | 55 | <h2 class="tab">' . (!empty($config['tabs'][$idTab]) ? $config['tabs'][$idTab] : $tab['category_name']) . '</h2> |
| 54 | 56 | <script type="text/javascript">pane_' . $action . '.addTabPage(document.getElementById("tab_' . $action . '_' . $idTab . '"));</script>';
|
| 55 | 57 | unset($tab['category_name']); |
| 56 | - foreach($tab as $item) {
|
|
| 58 | + foreach($tab as $item) { |
|
| 57 | 59 | $output .= $item; |
| 58 | 60 | } |
| 59 | 61 | $output .= '</div>'; |
@@ -70,7 +72,8 @@ discard block |
||
| 70 | 72 | * @param array $data |
| 71 | 73 | * @return string |
| 72 | 74 | */ |
| 73 | - private function render($data) {
|
|
| 75 | + private function render($data) |
|
| 76 | + { |
|
| 74 | 77 | $modx = evolutionCMS(); global $_lang, $_country_lang; |
| 75 | 78 | |
| 76 | 79 | $data['lang.name'] = (isset($_lang[$data['alias']]) ? $_lang[$data['alias']] : $data['alias']); |
@@ -80,7 +83,7 @@ discard block |
||
| 80 | 83 | $output = ''; |
| 81 | 84 | $output .= '<div class="form-group row">'; |
| 82 | 85 | |
| 83 | - switch($data['type']) {
|
|
| 86 | + switch($data['type']) { |
|
| 84 | 87 | |
| 85 | 88 | case 'text': |
| 86 | 89 | $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
@@ -114,16 +117,16 @@ discard block |
||
| 114 | 117 | $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
| 115 | 118 | $output .= '<div class="col-sm-7">'; |
| 116 | 119 | $output .= '<select name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;">'; |
| 117 | - if($data['name'] == 'country' && isset($_country_lang)) {
|
|
| 120 | + if($data['name'] == 'country' && isset($_country_lang)) { |
|
| 118 | 121 | $chosenCountry = isset($_POST['country']) ? $_POST['country'] : $data['country']; |
| 119 | 122 | $output .= '<option value=""' . (!isset($chosenCountry) ? ' selected' : '') . '> </option>'; |
| 120 | - foreach($_country_lang as $key => $value) {
|
|
| 123 | + foreach($_country_lang as $key => $value) { |
|
| 121 | 124 | $output .= '<option value="' . $key . '"' . (isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '') . '>' . $value . '</option>'; |
| 122 | 125 | } |
| 123 | - } else {
|
|
| 124 | - if($data['elements']) {
|
|
| 126 | + } else { |
|
| 127 | + if($data['elements']) { |
|
| 125 | 128 | $elements = explode('||', $data['elements']);
|
| 126 | - foreach($elements as $key => $value) {
|
|
| 129 | + foreach($elements as $key => $value) { |
|
| 127 | 130 | $value = explode('==', $value);
|
| 128 | 131 | $output .= '<option value="' . $value[1] . '">' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]) . '</option>'; |
| 129 | 132 | } |
@@ -139,9 +142,9 @@ discard block |
||
| 139 | 142 | $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
| 140 | 143 | $output .= '<div class="col-sm-7">'; |
| 141 | 144 | $output .= '<input type="checkbox" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
| 142 | - if($data['elements']) {
|
|
| 145 | + if($data['elements']) { |
|
| 143 | 146 | $elements = explode('||', $data['elements']);
|
| 144 | - foreach($elements as $key => $value) {
|
|
| 147 | + foreach($elements as $key => $value) { |
|
| 145 | 148 | $value = explode('==', $value);
|
| 146 | 149 | $output .= '<br /><input type="checkbox" name="' . $value[0] . '" class="form-control" id="' . $value[0] . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
| 147 | 150 | } |
@@ -155,9 +158,9 @@ discard block |
||
| 155 | 158 | $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
| 156 | 159 | $output .= '<div class="col-sm-7">'; |
| 157 | 160 | $output .= '<input type="radio" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
| 158 | - if($data['elements']) {
|
|
| 161 | + if($data['elements']) { |
|
| 159 | 162 | $elements = explode('||', $data['elements']);
|
| 160 | - foreach($elements as $key => $value) {
|
|
| 163 | + foreach($elements as $key => $value) { |
|
| 161 | 164 | $value = explode('==', $value);
|
| 162 | 165 | $output .= '<br /><input type="radio" name="[+name+]" class="form-control" id="[+name+]_' . $key . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
| 163 | 166 | } |
@@ -21,320 +21,320 @@ discard block |
||
| 21 | 21 | $o = ''; |
| 22 | 22 | |
| 23 | 23 | // process any TV commands in value |
| 24 | - $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
|
| 25 | - $value = ProcessTVCommand($value, $name, $docid); |
|
| 24 | + $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
|
| 25 | + $value = ProcessTVCommand($value, $name, $docid); |
|
| 26 | 26 | |
| 27 | - $params = array(); |
|
| 28 | - if($paramstring) { |
|
| 29 | - $cp = explode("&", $paramstring); |
|
| 30 | - foreach($cp as $p => $v) { |
|
| 31 | - $v = trim($v); // trim |
|
| 32 | - $ar = explode("=", $v); |
|
| 33 | - if(is_array($ar) && count($ar) == 2) { |
|
| 34 | - $params[$ar[0]] = decodeParamValue($ar[1]); |
|
| 35 | - } |
|
| 36 | - } |
|
| 37 | - } |
|
| 27 | + $params = array(); |
|
| 28 | + if($paramstring) { |
|
| 29 | + $cp = explode("&", $paramstring); |
|
| 30 | + foreach($cp as $p => $v) { |
|
| 31 | + $v = trim($v); // trim |
|
| 32 | + $ar = explode("=", $v); |
|
| 33 | + if(is_array($ar) && count($ar) == 2) { |
|
| 34 | + $params[$ar[0]] = decodeParamValue($ar[1]); |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - $id = "tv$name"; |
|
| 40 | - switch($format) { |
|
| 41 | - case 'image': |
|
| 42 | - $images = parseInput($value, '||', 'array'); |
|
| 43 | - foreach($images as $image) { |
|
| 44 | - if(!is_array($image)) { |
|
| 45 | - $image = explode('==', $image); |
|
| 46 | - } |
|
| 47 | - $src = $image[0]; |
|
| 39 | + $id = "tv$name"; |
|
| 40 | + switch($format) { |
|
| 41 | + case 'image': |
|
| 42 | + $images = parseInput($value, '||', 'array'); |
|
| 43 | + foreach($images as $image) { |
|
| 44 | + if(!is_array($image)) { |
|
| 45 | + $image = explode('==', $image); |
|
| 46 | + } |
|
| 47 | + $src = $image[0]; |
|
| 48 | 48 | |
| 49 | - if($src) { |
|
| 50 | - // We have a valid source |
|
| 51 | - $attributes = ''; |
|
| 52 | - $attr = array( |
|
| 53 | - 'class' => $params['class'], |
|
| 54 | - 'src' => $src, |
|
| 55 | - 'id' => ($params['id'] ? $params['id'] : ''), |
|
| 56 | - 'alt' => $modx->htmlspecialchars($params['alttext']), |
|
| 57 | - 'style' => $params['style'] |
|
| 58 | - ); |
|
| 59 | - if(isset($params['align']) && $params['align'] != 'none') { |
|
| 60 | - $attr['align'] = $params['align']; |
|
| 61 | - } |
|
| 62 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 63 | - $attributes .= ' ' . $params['attrib']; |
|
| 49 | + if($src) { |
|
| 50 | + // We have a valid source |
|
| 51 | + $attributes = ''; |
|
| 52 | + $attr = array( |
|
| 53 | + 'class' => $params['class'], |
|
| 54 | + 'src' => $src, |
|
| 55 | + 'id' => ($params['id'] ? $params['id'] : ''), |
|
| 56 | + 'alt' => $modx->htmlspecialchars($params['alttext']), |
|
| 57 | + 'style' => $params['style'] |
|
| 58 | + ); |
|
| 59 | + if(isset($params['align']) && $params['align'] != 'none') { |
|
| 60 | + $attr['align'] = $params['align']; |
|
| 61 | + } |
|
| 62 | + foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 63 | + $attributes .= ' ' . $params['attrib']; |
|
| 64 | 64 | |
| 65 | - // Output the image with attributes |
|
| 66 | - $o .= '<img' . rtrim($attributes) . ' />'; |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - break; |
|
| 65 | + // Output the image with attributes |
|
| 66 | + $o .= '<img' . rtrim($attributes) . ' />'; |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + break; |
|
| 70 | 70 | |
| 71 | - case "delim": // display as delimitted list |
|
| 72 | - $value = parseInput($value, "||"); |
|
| 73 | - $p = $params['format'] ? $params['format'] : " "; |
|
| 74 | - if($p == "\\n") { |
|
| 75 | - $p = "\n"; |
|
| 76 | - } |
|
| 77 | - $o = str_replace("||", $p, $value); |
|
| 78 | - break; |
|
| 71 | + case "delim": // display as delimitted list |
|
| 72 | + $value = parseInput($value, "||"); |
|
| 73 | + $p = $params['format'] ? $params['format'] : " "; |
|
| 74 | + if($p == "\\n") { |
|
| 75 | + $p = "\n"; |
|
| 76 | + } |
|
| 77 | + $o = str_replace("||", $p, $value); |
|
| 78 | + break; |
|
| 79 | 79 | |
| 80 | - case "string": |
|
| 81 | - $value = parseInput($value); |
|
| 82 | - $format = strtolower($params['format']); |
|
| 83 | - if($format == 'upper case') { |
|
| 84 | - $o = strtoupper($value); |
|
| 85 | - } else if($format == 'lower case') { |
|
| 86 | - $o = strtolower($value); |
|
| 87 | - } else if($format == 'sentence case') { |
|
| 88 | - $o = ucfirst($value); |
|
| 89 | - } else if($format == 'capitalize') { |
|
| 90 | - $o = ucwords($value); |
|
| 91 | - } else { |
|
| 92 | - $o = $value; |
|
| 93 | - } |
|
| 94 | - break; |
|
| 80 | + case "string": |
|
| 81 | + $value = parseInput($value); |
|
| 82 | + $format = strtolower($params['format']); |
|
| 83 | + if($format == 'upper case') { |
|
| 84 | + $o = strtoupper($value); |
|
| 85 | + } else if($format == 'lower case') { |
|
| 86 | + $o = strtolower($value); |
|
| 87 | + } else if($format == 'sentence case') { |
|
| 88 | + $o = ucfirst($value); |
|
| 89 | + } else if($format == 'capitalize') { |
|
| 90 | + $o = ucwords($value); |
|
| 91 | + } else { |
|
| 92 | + $o = $value; |
|
| 93 | + } |
|
| 94 | + break; |
|
| 95 | 95 | |
| 96 | - case "date": |
|
| 97 | - if($value != '' || $params['default'] == 'Yes') { |
|
| 98 | - if(empty($value)) { |
|
| 99 | - $value = 'now'; |
|
| 100 | - } |
|
| 101 | - $timestamp = getUnixtimeFromDateString($value); |
|
| 102 | - $p = $params['format'] ? $params['format'] : "%A %d, %B %Y"; |
|
| 103 | - $o = strftime($p, $timestamp); |
|
| 104 | - } else { |
|
| 105 | - $value = ''; |
|
| 106 | - } |
|
| 107 | - break; |
|
| 96 | + case "date": |
|
| 97 | + if($value != '' || $params['default'] == 'Yes') { |
|
| 98 | + if(empty($value)) { |
|
| 99 | + $value = 'now'; |
|
| 100 | + } |
|
| 101 | + $timestamp = getUnixtimeFromDateString($value); |
|
| 102 | + $p = $params['format'] ? $params['format'] : "%A %d, %B %Y"; |
|
| 103 | + $o = strftime($p, $timestamp); |
|
| 104 | + } else { |
|
| 105 | + $value = ''; |
|
| 106 | + } |
|
| 107 | + break; |
|
| 108 | 108 | |
| 109 | - case "hyperlink": |
|
| 110 | - $value = parseInput($value, "||", "array"); |
|
| 111 | - $o = ''; |
|
| 112 | - $countValue = count($value); |
|
| 113 | - for($i = 0; $i < $countValue; $i++) { |
|
| 114 | - list($name, $url) = is_array($value[$i]) ? $value[$i] : explode("==", $value[$i]); |
|
| 115 | - if(!$url) { |
|
| 116 | - $url = $name; |
|
| 117 | - } |
|
| 118 | - if($url) { |
|
| 119 | - if($o) { |
|
| 120 | - $o .= '<br />'; |
|
| 121 | - } |
|
| 122 | - $attributes = ''; |
|
| 123 | - // setup the link attributes |
|
| 124 | - $attr = array( |
|
| 125 | - 'href' => $url, |
|
| 126 | - 'title' => $params['title'] ? $modx->htmlspecialchars($params['title']) : $name, |
|
| 127 | - 'class' => $params['class'], |
|
| 128 | - 'style' => $params['style'], |
|
| 129 | - 'target' => $params['target'], |
|
| 130 | - ); |
|
| 131 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 132 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
| 109 | + case "hyperlink": |
|
| 110 | + $value = parseInput($value, "||", "array"); |
|
| 111 | + $o = ''; |
|
| 112 | + $countValue = count($value); |
|
| 113 | + for($i = 0; $i < $countValue; $i++) { |
|
| 114 | + list($name, $url) = is_array($value[$i]) ? $value[$i] : explode("==", $value[$i]); |
|
| 115 | + if(!$url) { |
|
| 116 | + $url = $name; |
|
| 117 | + } |
|
| 118 | + if($url) { |
|
| 119 | + if($o) { |
|
| 120 | + $o .= '<br />'; |
|
| 121 | + } |
|
| 122 | + $attributes = ''; |
|
| 123 | + // setup the link attributes |
|
| 124 | + $attr = array( |
|
| 125 | + 'href' => $url, |
|
| 126 | + 'title' => $params['title'] ? $modx->htmlspecialchars($params['title']) : $name, |
|
| 127 | + 'class' => $params['class'], |
|
| 128 | + 'style' => $params['style'], |
|
| 129 | + 'target' => $params['target'], |
|
| 130 | + ); |
|
| 131 | + foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 132 | + $attributes .= ' ' . $params['attrib']; // add extra |
|
| 133 | 133 | |
| 134 | - // Output the link |
|
| 135 | - $o .= '<a' . rtrim($attributes) . '>' . ($params['text'] ? $modx->htmlspecialchars($params['text']) : $name) . '</a>'; |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - break; |
|
| 134 | + // Output the link |
|
| 135 | + $o .= '<a' . rtrim($attributes) . '>' . ($params['text'] ? $modx->htmlspecialchars($params['text']) : $name) . '</a>'; |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + break; |
|
| 139 | 139 | |
| 140 | - case "htmltag": |
|
| 141 | - $value = parseInput($value, "||", "array"); |
|
| 142 | - $tagid = $params['tagid']; |
|
| 143 | - $tagname = ($params['tagname']) ? $params['tagname'] : 'div'; |
|
| 144 | - $o = ''; |
|
| 145 | - // Loop through a list of tags |
|
| 140 | + case "htmltag": |
|
| 141 | + $value = parseInput($value, "||", "array"); |
|
| 142 | + $tagid = $params['tagid']; |
|
| 143 | + $tagname = ($params['tagname']) ? $params['tagname'] : 'div'; |
|
| 144 | + $o = ''; |
|
| 145 | + // Loop through a list of tags |
|
| 146 | 146 | $countValue = count($value); |
| 147 | - for($i = 0; $i < $countValue; $i++) { |
|
| 148 | - $tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i]; |
|
| 149 | - if(!$tagvalue) { |
|
| 150 | - continue; |
|
| 151 | - } |
|
| 147 | + for($i = 0; $i < $countValue; $i++) { |
|
| 148 | + $tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i]; |
|
| 149 | + if(!$tagvalue) { |
|
| 150 | + continue; |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - $attributes = ''; |
|
| 154 | - $attr = array( |
|
| 155 | - 'id' => ($tagid ? $tagid : $id), |
|
| 156 | - // 'tv' already added to id |
|
| 157 | - 'class' => $params['class'], |
|
| 158 | - 'style' => $params['style'], |
|
| 159 | - ); |
|
| 160 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 161 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
| 153 | + $attributes = ''; |
|
| 154 | + $attr = array( |
|
| 155 | + 'id' => ($tagid ? $tagid : $id), |
|
| 156 | + // 'tv' already added to id |
|
| 157 | + 'class' => $params['class'], |
|
| 158 | + 'style' => $params['style'], |
|
| 159 | + ); |
|
| 160 | + foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 161 | + $attributes .= ' ' . $params['attrib']; // add extra |
|
| 162 | 162 | |
| 163 | - // Output the HTML Tag |
|
| 164 | - $o .= '<' . $tagname . rtrim($attributes) . '>' . $tagvalue . '</' . $tagname . '>'; |
|
| 165 | - } |
|
| 166 | - break; |
|
| 163 | + // Output the HTML Tag |
|
| 164 | + $o .= '<' . $tagname . rtrim($attributes) . '>' . $tagvalue . '</' . $tagname . '>'; |
|
| 165 | + } |
|
| 166 | + break; |
|
| 167 | 167 | |
| 168 | - case "richtext": |
|
| 169 | - $value = parseInput($value); |
|
| 170 | - $w = $params['w'] ? $params['w'] : '100%'; |
|
| 171 | - $h = $params['h'] ? $params['h'] : '400px'; |
|
| 172 | - $richtexteditor = $params['edt'] ? $params['edt'] : ""; |
|
| 173 | - $o = '<div class="MODX_RichTextWidget"><textarea id="' . $id . '" name="' . $id . '" style="width:' . $w . '; height:' . $h . ';">'; |
|
| 174 | - $o .= $modx->htmlspecialchars($value); |
|
| 175 | - $o .= '</textarea></div>'; |
|
| 176 | - $replace_richtext = array($id); |
|
| 177 | - // setup editors |
|
| 178 | - if(!empty($replace_richtext) && !empty($richtexteditor)) { |
|
| 179 | - // invoke OnRichTextEditorInit event |
|
| 180 | - $evtOut = $modx->invokeEvent("OnRichTextEditorInit", array( |
|
| 181 | - 'editor' => $richtexteditor, |
|
| 182 | - 'elements' => $replace_richtext, |
|
| 183 | - 'forfrontend' => 1, |
|
| 184 | - 'width' => $w, |
|
| 185 | - 'height' => $h |
|
| 186 | - )); |
|
| 187 | - if(is_array($evtOut)) { |
|
| 188 | - $o .= implode("", $evtOut); |
|
| 189 | - } |
|
| 190 | - } |
|
| 191 | - break; |
|
| 168 | + case "richtext": |
|
| 169 | + $value = parseInput($value); |
|
| 170 | + $w = $params['w'] ? $params['w'] : '100%'; |
|
| 171 | + $h = $params['h'] ? $params['h'] : '400px'; |
|
| 172 | + $richtexteditor = $params['edt'] ? $params['edt'] : ""; |
|
| 173 | + $o = '<div class="MODX_RichTextWidget"><textarea id="' . $id . '" name="' . $id . '" style="width:' . $w . '; height:' . $h . ';">'; |
|
| 174 | + $o .= $modx->htmlspecialchars($value); |
|
| 175 | + $o .= '</textarea></div>'; |
|
| 176 | + $replace_richtext = array($id); |
|
| 177 | + // setup editors |
|
| 178 | + if(!empty($replace_richtext) && !empty($richtexteditor)) { |
|
| 179 | + // invoke OnRichTextEditorInit event |
|
| 180 | + $evtOut = $modx->invokeEvent("OnRichTextEditorInit", array( |
|
| 181 | + 'editor' => $richtexteditor, |
|
| 182 | + 'elements' => $replace_richtext, |
|
| 183 | + 'forfrontend' => 1, |
|
| 184 | + 'width' => $w, |
|
| 185 | + 'height' => $h |
|
| 186 | + )); |
|
| 187 | + if(is_array($evtOut)) { |
|
| 188 | + $o .= implode("", $evtOut); |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | + break; |
|
| 192 | 192 | |
| 193 | - case "unixtime": |
|
| 194 | - $value = parseInput($value); |
|
| 195 | - $o = getUnixtimeFromDateString($value); |
|
| 196 | - break; |
|
| 193 | + case "unixtime": |
|
| 194 | + $value = parseInput($value); |
|
| 195 | + $o = getUnixtimeFromDateString($value); |
|
| 196 | + break; |
|
| 197 | 197 | |
| 198 | - case "viewport": |
|
| 199 | - $value = parseInput($value); |
|
| 200 | - $id = '_' . time(); |
|
| 201 | - if(!$params['vpid']) { |
|
| 202 | - $params['vpid'] = $id; |
|
| 203 | - } |
|
| 204 | - $sTag = "<iframe"; |
|
| 205 | - $eTag = "</iframe>"; |
|
| 206 | - $autoMode = "0"; |
|
| 207 | - $w = $params['width']; |
|
| 208 | - $h = $params['height']; |
|
| 209 | - if($params['stretch'] == 'Yes') { |
|
| 210 | - $w = "100%"; |
|
| 211 | - $h = "100%"; |
|
| 212 | - } |
|
| 213 | - if($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
| 214 | - $autoMode = "3"; //both |
|
| 215 | - } else if($params['awidth'] == 'Yes') { |
|
| 216 | - $autoMode = "1"; //width only |
|
| 217 | - } else if($params['aheight'] == 'Yes') { |
|
| 218 | - $autoMode = "2"; //height only |
|
| 219 | - } |
|
| 198 | + case "viewport": |
|
| 199 | + $value = parseInput($value); |
|
| 200 | + $id = '_' . time(); |
|
| 201 | + if(!$params['vpid']) { |
|
| 202 | + $params['vpid'] = $id; |
|
| 203 | + } |
|
| 204 | + $sTag = "<iframe"; |
|
| 205 | + $eTag = "</iframe>"; |
|
| 206 | + $autoMode = "0"; |
|
| 207 | + $w = $params['width']; |
|
| 208 | + $h = $params['height']; |
|
| 209 | + if($params['stretch'] == 'Yes') { |
|
| 210 | + $w = "100%"; |
|
| 211 | + $h = "100%"; |
|
| 212 | + } |
|
| 213 | + if($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
| 214 | + $autoMode = "3"; //both |
|
| 215 | + } else if($params['awidth'] == 'Yes') { |
|
| 216 | + $autoMode = "1"; //width only |
|
| 217 | + } else if($params['aheight'] == 'Yes') { |
|
| 218 | + $autoMode = "2"; //height only |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/bin/viewport.js", array( |
|
| 222 | - 'name' => 'viewport', |
|
| 223 | - 'version' => '0', |
|
| 224 | - 'plaintext' => false |
|
| 225 | - )); |
|
| 226 | - $o = $sTag . " id='" . $params['vpid'] . "' name='" . $params['vpid'] . "' "; |
|
| 227 | - if($params['class']) { |
|
| 228 | - $o .= " class='" . $params['class'] . "' "; |
|
| 229 | - } |
|
| 230 | - if($params['style']) { |
|
| 231 | - $o .= " style='" . $params['style'] . "' "; |
|
| 232 | - } |
|
| 233 | - if($params['attrib']) { |
|
| 234 | - $o .= $params['attrib'] . " "; |
|
| 235 | - } |
|
| 236 | - $o .= "scrolling='" . ($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto")) . "' "; |
|
| 237 | - $o .= "src='" . $value . "' frameborder='" . $params['borsize'] . "' "; |
|
| 238 | - $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'" . $params['vpid'] . "\\'," . $autoMode . ")',100);\" width='" . $w . "' height='" . $h . "' "; |
|
| 239 | - $o .= ">"; |
|
| 240 | - $o .= $eTag; |
|
| 241 | - break; |
|
| 221 | + $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/bin/viewport.js", array( |
|
| 222 | + 'name' => 'viewport', |
|
| 223 | + 'version' => '0', |
|
| 224 | + 'plaintext' => false |
|
| 225 | + )); |
|
| 226 | + $o = $sTag . " id='" . $params['vpid'] . "' name='" . $params['vpid'] . "' "; |
|
| 227 | + if($params['class']) { |
|
| 228 | + $o .= " class='" . $params['class'] . "' "; |
|
| 229 | + } |
|
| 230 | + if($params['style']) { |
|
| 231 | + $o .= " style='" . $params['style'] . "' "; |
|
| 232 | + } |
|
| 233 | + if($params['attrib']) { |
|
| 234 | + $o .= $params['attrib'] . " "; |
|
| 235 | + } |
|
| 236 | + $o .= "scrolling='" . ($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto")) . "' "; |
|
| 237 | + $o .= "src='" . $value . "' frameborder='" . $params['borsize'] . "' "; |
|
| 238 | + $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'" . $params['vpid'] . "\\'," . $autoMode . ")',100);\" width='" . $w . "' height='" . $h . "' "; |
|
| 239 | + $o .= ">"; |
|
| 240 | + $o .= $eTag; |
|
| 241 | + break; |
|
| 242 | 242 | |
| 243 | - case "datagrid": |
|
| 244 | - include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; |
|
| 245 | - $grd = new DataGrid('', $value); |
|
| 243 | + case "datagrid": |
|
| 244 | + include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; |
|
| 245 | + $grd = new DataGrid('', $value); |
|
| 246 | 246 | |
| 247 | - $grd->noRecordMsg = $params['egmsg']; |
|
| 247 | + $grd->noRecordMsg = $params['egmsg']; |
|
| 248 | 248 | |
| 249 | - $grd->columnHeaderClass = $params['chdrc']; |
|
| 250 | - $grd->cssClass = $params['tblc']; |
|
| 251 | - $grd->itemClass = $params['itmc']; |
|
| 252 | - $grd->altItemClass = $params['aitmc']; |
|
| 249 | + $grd->columnHeaderClass = $params['chdrc']; |
|
| 250 | + $grd->cssClass = $params['tblc']; |
|
| 251 | + $grd->itemClass = $params['itmc']; |
|
| 252 | + $grd->altItemClass = $params['aitmc']; |
|
| 253 | 253 | |
| 254 | - $grd->columnHeaderStyle = $params['chdrs']; |
|
| 255 | - $grd->cssStyle = $params['tbls']; |
|
| 256 | - $grd->itemStyle = $params['itms']; |
|
| 257 | - $grd->altItemStyle = $params['aitms']; |
|
| 254 | + $grd->columnHeaderStyle = $params['chdrs']; |
|
| 255 | + $grd->cssStyle = $params['tbls']; |
|
| 256 | + $grd->itemStyle = $params['itms']; |
|
| 257 | + $grd->altItemStyle = $params['aitms']; |
|
| 258 | 258 | |
| 259 | - $grd->columns = $params['cols']; |
|
| 260 | - $grd->fields = $params['flds']; |
|
| 261 | - $grd->colWidths = $params['cwidth']; |
|
| 262 | - $grd->colAligns = $params['calign']; |
|
| 263 | - $grd->colColors = $params['ccolor']; |
|
| 264 | - $grd->colTypes = $params['ctype']; |
|
| 259 | + $grd->columns = $params['cols']; |
|
| 260 | + $grd->fields = $params['flds']; |
|
| 261 | + $grd->colWidths = $params['cwidth']; |
|
| 262 | + $grd->colAligns = $params['calign']; |
|
| 263 | + $grd->colColors = $params['ccolor']; |
|
| 264 | + $grd->colTypes = $params['ctype']; |
|
| 265 | 265 | |
| 266 | - $grd->cellPadding = $params['cpad']; |
|
| 267 | - $grd->cellSpacing = $params['cspace']; |
|
| 268 | - $grd->header = $params['head']; |
|
| 269 | - $grd->footer = $params['foot']; |
|
| 270 | - $grd->pageSize = $params['psize']; |
|
| 271 | - $grd->pagerLocation = $params['ploc']; |
|
| 272 | - $grd->pagerClass = $params['pclass']; |
|
| 273 | - $grd->pagerStyle = $params['pstyle']; |
|
| 274 | - $o = $grd->render(); |
|
| 275 | - break; |
|
| 266 | + $grd->cellPadding = $params['cpad']; |
|
| 267 | + $grd->cellSpacing = $params['cspace']; |
|
| 268 | + $grd->header = $params['head']; |
|
| 269 | + $grd->footer = $params['foot']; |
|
| 270 | + $grd->pageSize = $params['psize']; |
|
| 271 | + $grd->pagerLocation = $params['ploc']; |
|
| 272 | + $grd->pagerClass = $params['pclass']; |
|
| 273 | + $grd->pagerStyle = $params['pstyle']; |
|
| 274 | + $o = $grd->render(); |
|
| 275 | + break; |
|
| 276 | 276 | |
| 277 | - case 'htmlentities': |
|
| 278 | - $value = parseInput($value); |
|
| 279 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 280 | - // remove delimiter from checkbox and listbox-multiple TVs |
|
| 281 | - $value = str_replace('||', '', $value); |
|
| 282 | - } |
|
| 283 | - $o = htmlentities($value, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
| 284 | - break; |
|
| 277 | + case 'htmlentities': |
|
| 278 | + $value = parseInput($value); |
|
| 279 | + if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 280 | + // remove delimiter from checkbox and listbox-multiple TVs |
|
| 281 | + $value = str_replace('||', '', $value); |
|
| 282 | + } |
|
| 283 | + $o = htmlentities($value, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
| 284 | + break; |
|
| 285 | 285 | |
| 286 | - case 'custom_widget': |
|
| 287 | - $widget_output = ''; |
|
| 288 | - $o = ''; |
|
| 289 | - /* If we are loading a file */ |
|
| 290 | - if(substr($params['output'], 0, 5) == "@FILE") { |
|
| 291 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 6)); |
|
| 292 | - if(!file_exists($file_name)) { |
|
| 293 | - $widget_output = $file_name . ' does not exist'; |
|
| 294 | - } else { |
|
| 295 | - $widget_output = file_get_contents($file_name); |
|
| 296 | - } |
|
| 297 | - } elseif(substr($params['output'], 0, 8) == '@INCLUDE') { |
|
| 298 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 9)); |
|
| 299 | - if(!file_exists($file_name)) { |
|
| 300 | - $widget_output = $file_name . ' does not exist'; |
|
| 301 | - } else { |
|
| 302 | - /* The included file needs to set $widget_output. Can be string, array, object */ |
|
| 303 | - include $file_name; |
|
| 304 | - } |
|
| 305 | - } elseif(substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
| 306 | - $chunk_name = trim(substr($params['output'], 7)); |
|
| 307 | - $widget_output = $modx->getChunk($chunk_name); |
|
| 308 | - } elseif(substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
| 309 | - $eval_str = trim(substr($params['output'], 6)); |
|
| 310 | - $widget_output = eval($eval_str); |
|
| 311 | - } elseif($value !== '') { |
|
| 312 | - $widget_output = $params['output']; |
|
| 313 | - } else { |
|
| 314 | - $widget_output = ''; |
|
| 315 | - } |
|
| 316 | - if(is_string($widget_output)) { |
|
| 317 | - $_ = $modx->config['enable_filter']; |
|
| 318 | - $modx->config['enable_filter'] = 1; |
|
| 319 | - $widget_output = $modx->parseText($widget_output, array('value' => $value)); |
|
| 320 | - $modx->config['enable_filter'] = $_; |
|
| 321 | - $o = $modx->parseDocumentSource($widget_output); |
|
| 322 | - } else { |
|
| 323 | - $o = $widget_output; |
|
| 324 | - } |
|
| 325 | - break; |
|
| 286 | + case 'custom_widget': |
|
| 287 | + $widget_output = ''; |
|
| 288 | + $o = ''; |
|
| 289 | + /* If we are loading a file */ |
|
| 290 | + if(substr($params['output'], 0, 5) == "@FILE") { |
|
| 291 | + $file_name = MODX_BASE_PATH . trim(substr($params['output'], 6)); |
|
| 292 | + if(!file_exists($file_name)) { |
|
| 293 | + $widget_output = $file_name . ' does not exist'; |
|
| 294 | + } else { |
|
| 295 | + $widget_output = file_get_contents($file_name); |
|
| 296 | + } |
|
| 297 | + } elseif(substr($params['output'], 0, 8) == '@INCLUDE') { |
|
| 298 | + $file_name = MODX_BASE_PATH . trim(substr($params['output'], 9)); |
|
| 299 | + if(!file_exists($file_name)) { |
|
| 300 | + $widget_output = $file_name . ' does not exist'; |
|
| 301 | + } else { |
|
| 302 | + /* The included file needs to set $widget_output. Can be string, array, object */ |
|
| 303 | + include $file_name; |
|
| 304 | + } |
|
| 305 | + } elseif(substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
| 306 | + $chunk_name = trim(substr($params['output'], 7)); |
|
| 307 | + $widget_output = $modx->getChunk($chunk_name); |
|
| 308 | + } elseif(substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
| 309 | + $eval_str = trim(substr($params['output'], 6)); |
|
| 310 | + $widget_output = eval($eval_str); |
|
| 311 | + } elseif($value !== '') { |
|
| 312 | + $widget_output = $params['output']; |
|
| 313 | + } else { |
|
| 314 | + $widget_output = ''; |
|
| 315 | + } |
|
| 316 | + if(is_string($widget_output)) { |
|
| 317 | + $_ = $modx->config['enable_filter']; |
|
| 318 | + $modx->config['enable_filter'] = 1; |
|
| 319 | + $widget_output = $modx->parseText($widget_output, array('value' => $value)); |
|
| 320 | + $modx->config['enable_filter'] = $_; |
|
| 321 | + $o = $modx->parseDocumentSource($widget_output); |
|
| 322 | + } else { |
|
| 323 | + $o = $widget_output; |
|
| 324 | + } |
|
| 325 | + break; |
|
| 326 | 326 | |
| 327 | - default: |
|
| 328 | - $value = parseInput($value); |
|
| 329 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 330 | - // add separator |
|
| 331 | - $value = explode('||', $value); |
|
| 332 | - $value = implode($sep, $value); |
|
| 333 | - } |
|
| 334 | - $o = $value; |
|
| 335 | - break; |
|
| 336 | - } |
|
| 337 | - return $o; |
|
| 327 | + default: |
|
| 328 | + $value = parseInput($value); |
|
| 329 | + if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 330 | + // add separator |
|
| 331 | + $value = explode('||', $value); |
|
| 332 | + $value = implode($sep, $value); |
|
| 333 | + } |
|
| 334 | + $o = $value; |
|
| 335 | + break; |
|
| 336 | + } |
|
| 337 | + return $o; |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | /** |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | * @return string |
| 343 | 343 | */ |
| 344 | 344 | function decodeParamValue($s) { |
| 345 | - $s = str_replace("%3D", '=', $s); // = |
|
| 346 | - return str_replace("%26", '&', $s); // & |
|
| 345 | + $s = str_replace("%3D", '=', $s); // = |
|
| 346 | + return str_replace("%26", '&', $s); // & |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | /** |
@@ -357,19 +357,19 @@ discard block |
||
| 357 | 357 | */ |
| 358 | 358 | function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array |
| 359 | 359 | $modx = evolutionCMS(); |
| 360 | - if($modx->db->isResult($src)) { |
|
| 361 | - // must be a recordset |
|
| 362 | - $rows = array(); |
|
| 363 | - while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
| 364 | - return ($type == "array") ? $rows : implode($delim, $rows); |
|
| 365 | - } else { |
|
| 366 | - // must be a text |
|
| 367 | - if($type == "array") { |
|
| 368 | - return explode($delim, $src); |
|
| 369 | - } else { |
|
| 370 | - return $src; |
|
| 371 | - } |
|
| 372 | - } |
|
| 360 | + if($modx->db->isResult($src)) { |
|
| 361 | + // must be a recordset |
|
| 362 | + $rows = array(); |
|
| 363 | + while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
| 364 | + return ($type == "array") ? $rows : implode($delim, $rows); |
|
| 365 | + } else { |
|
| 366 | + // must be a text |
|
| 367 | + if($type == "array") { |
|
| 368 | + return explode($delim, $src); |
|
| 369 | + } else { |
|
| 370 | + return $src; |
|
| 371 | + } |
|
| 372 | + } |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | /** |
@@ -377,21 +377,21 @@ discard block |
||
| 377 | 377 | * @return bool|false|int |
| 378 | 378 | */ |
| 379 | 379 | function getUnixtimeFromDateString($value) { |
| 380 | - $timestamp = false; |
|
| 381 | - // Check for MySQL or legacy style date |
|
| 382 | - $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
|
| 383 | - $date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
|
| 384 | - $matches = array(); |
|
| 385 | - if(strpos($value, '-') !== false) { |
|
| 386 | - if(preg_match($date_match_1, $value, $matches)) { |
|
| 387 | - $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]); |
|
| 388 | - } elseif(preg_match($date_match_2, $value, $matches)) { |
|
| 389 | - $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
|
| 390 | - } |
|
| 391 | - } |
|
| 392 | - // If those didn't work, use strtotime to figure out the date |
|
| 393 | - if($timestamp === false || $timestamp === -1) { |
|
| 394 | - $timestamp = strtotime($value); |
|
| 395 | - } |
|
| 396 | - return $timestamp; |
|
| 380 | + $timestamp = false; |
|
| 381 | + // Check for MySQL or legacy style date |
|
| 382 | + $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
|
| 383 | + $date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
|
| 384 | + $matches = array(); |
|
| 385 | + if(strpos($value, '-') !== false) { |
|
| 386 | + if(preg_match($date_match_1, $value, $matches)) { |
|
| 387 | + $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]); |
|
| 388 | + } elseif(preg_match($date_match_2, $value, $matches)) { |
|
| 389 | + $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
|
| 390 | + } |
|
| 391 | + } |
|
| 392 | + // If those didn't work, use strtotime to figure out the date |
|
| 393 | + if($timestamp === false || $timestamp === -1) { |
|
| 394 | + $timestamp = strtotime($value); |
|
| 395 | + } |
|
| 396 | + return $timestamp; |
|
| 397 | 397 | } |
@@ -15,38 +15,38 @@ discard block |
||
| 15 | 15 | * @param string $sep |
| 16 | 16 | * @return mixed|string |
| 17 | 17 | */ |
| 18 | -function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '') { |
|
| 18 | +function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = ''){ |
|
| 19 | 19 | |
| 20 | 20 | $modx = evolutionCMS(); |
| 21 | 21 | $o = ''; |
| 22 | 22 | |
| 23 | 23 | // process any TV commands in value |
| 24 | - $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
|
| 24 | + $docid = (int) $docid > 0 ? (int) $docid : $modx->documentIdentifier; |
|
| 25 | 25 | $value = ProcessTVCommand($value, $name, $docid); |
| 26 | 26 | |
| 27 | 27 | $params = array(); |
| 28 | - if($paramstring) { |
|
| 28 | + if ($paramstring) { |
|
| 29 | 29 | $cp = explode("&", $paramstring); |
| 30 | - foreach($cp as $p => $v) { |
|
| 30 | + foreach ($cp as $p => $v) { |
|
| 31 | 31 | $v = trim($v); // trim |
| 32 | 32 | $ar = explode("=", $v); |
| 33 | - if(is_array($ar) && count($ar) == 2) { |
|
| 33 | + if (is_array($ar) && count($ar) == 2) { |
|
| 34 | 34 | $params[$ar[0]] = decodeParamValue($ar[1]); |
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | $id = "tv$name"; |
| 40 | - switch($format) { |
|
| 40 | + switch ($format) { |
|
| 41 | 41 | case 'image': |
| 42 | 42 | $images = parseInput($value, '||', 'array'); |
| 43 | - foreach($images as $image) { |
|
| 44 | - if(!is_array($image)) { |
|
| 43 | + foreach ($images as $image) { |
|
| 44 | + if (!is_array($image)) { |
|
| 45 | 45 | $image = explode('==', $image); |
| 46 | 46 | } |
| 47 | 47 | $src = $image[0]; |
| 48 | 48 | |
| 49 | - if($src) { |
|
| 49 | + if ($src) { |
|
| 50 | 50 | // We have a valid source |
| 51 | 51 | $attributes = ''; |
| 52 | 52 | $attr = array( |
@@ -56,14 +56,14 @@ discard block |
||
| 56 | 56 | 'alt' => $modx->htmlspecialchars($params['alttext']), |
| 57 | 57 | 'style' => $params['style'] |
| 58 | 58 | ); |
| 59 | - if(isset($params['align']) && $params['align'] != 'none') { |
|
| 59 | + if (isset($params['align']) && $params['align'] != 'none') { |
|
| 60 | 60 | $attr['align'] = $params['align']; |
| 61 | 61 | } |
| 62 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 63 | - $attributes .= ' ' . $params['attrib']; |
|
| 62 | + foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); |
|
| 63 | + $attributes .= ' '.$params['attrib']; |
|
| 64 | 64 | |
| 65 | 65 | // Output the image with attributes |
| 66 | - $o .= '<img' . rtrim($attributes) . ' />'; |
|
| 66 | + $o .= '<img'.rtrim($attributes).' />'; |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | break; |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | case "delim": // display as delimitted list |
| 72 | 72 | $value = parseInput($value, "||"); |
| 73 | 73 | $p = $params['format'] ? $params['format'] : " "; |
| 74 | - if($p == "\\n") { |
|
| 74 | + if ($p == "\\n") { |
|
| 75 | 75 | $p = "\n"; |
| 76 | 76 | } |
| 77 | 77 | $o = str_replace("||", $p, $value); |
@@ -80,13 +80,13 @@ discard block |
||
| 80 | 80 | case "string": |
| 81 | 81 | $value = parseInput($value); |
| 82 | 82 | $format = strtolower($params['format']); |
| 83 | - if($format == 'upper case') { |
|
| 83 | + if ($format == 'upper case') { |
|
| 84 | 84 | $o = strtoupper($value); |
| 85 | - } else if($format == 'lower case') { |
|
| 85 | + } else if ($format == 'lower case') { |
|
| 86 | 86 | $o = strtolower($value); |
| 87 | - } else if($format == 'sentence case') { |
|
| 87 | + } else if ($format == 'sentence case') { |
|
| 88 | 88 | $o = ucfirst($value); |
| 89 | - } else if($format == 'capitalize') { |
|
| 89 | + } else if ($format == 'capitalize') { |
|
| 90 | 90 | $o = ucwords($value); |
| 91 | 91 | } else { |
| 92 | 92 | $o = $value; |
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | break; |
| 95 | 95 | |
| 96 | 96 | case "date": |
| 97 | - if($value != '' || $params['default'] == 'Yes') { |
|
| 98 | - if(empty($value)) { |
|
| 97 | + if ($value != '' || $params['default'] == 'Yes') { |
|
| 98 | + if (empty($value)) { |
|
| 99 | 99 | $value = 'now'; |
| 100 | 100 | } |
| 101 | 101 | $timestamp = getUnixtimeFromDateString($value); |
@@ -110,13 +110,13 @@ discard block |
||
| 110 | 110 | $value = parseInput($value, "||", "array"); |
| 111 | 111 | $o = ''; |
| 112 | 112 | $countValue = count($value); |
| 113 | - for($i = 0; $i < $countValue; $i++) { |
|
| 113 | + for ($i = 0; $i < $countValue; $i++) { |
|
| 114 | 114 | list($name, $url) = is_array($value[$i]) ? $value[$i] : explode("==", $value[$i]); |
| 115 | - if(!$url) { |
|
| 115 | + if (!$url) { |
|
| 116 | 116 | $url = $name; |
| 117 | 117 | } |
| 118 | - if($url) { |
|
| 119 | - if($o) { |
|
| 118 | + if ($url) { |
|
| 119 | + if ($o) { |
|
| 120 | 120 | $o .= '<br />'; |
| 121 | 121 | } |
| 122 | 122 | $attributes = ''; |
@@ -128,11 +128,11 @@ discard block |
||
| 128 | 128 | 'style' => $params['style'], |
| 129 | 129 | 'target' => $params['target'], |
| 130 | 130 | ); |
| 131 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 132 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
| 131 | + foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); |
|
| 132 | + $attributes .= ' '.$params['attrib']; // add extra |
|
| 133 | 133 | |
| 134 | 134 | // Output the link |
| 135 | - $o .= '<a' . rtrim($attributes) . '>' . ($params['text'] ? $modx->htmlspecialchars($params['text']) : $name) . '</a>'; |
|
| 135 | + $o .= '<a'.rtrim($attributes).'>'.($params['text'] ? $modx->htmlspecialchars($params['text']) : $name).'</a>'; |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | break; |
@@ -144,9 +144,9 @@ discard block |
||
| 144 | 144 | $o = ''; |
| 145 | 145 | // Loop through a list of tags |
| 146 | 146 | $countValue = count($value); |
| 147 | - for($i = 0; $i < $countValue; $i++) { |
|
| 147 | + for ($i = 0; $i < $countValue; $i++) { |
|
| 148 | 148 | $tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i]; |
| 149 | - if(!$tagvalue) { |
|
| 149 | + if (!$tagvalue) { |
|
| 150 | 150 | continue; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -157,11 +157,11 @@ discard block |
||
| 157 | 157 | 'class' => $params['class'], |
| 158 | 158 | 'style' => $params['style'], |
| 159 | 159 | ); |
| 160 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 161 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
| 160 | + foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); |
|
| 161 | + $attributes .= ' '.$params['attrib']; // add extra |
|
| 162 | 162 | |
| 163 | 163 | // Output the HTML Tag |
| 164 | - $o .= '<' . $tagname . rtrim($attributes) . '>' . $tagvalue . '</' . $tagname . '>'; |
|
| 164 | + $o .= '<'.$tagname.rtrim($attributes).'>'.$tagvalue.'</'.$tagname.'>'; |
|
| 165 | 165 | } |
| 166 | 166 | break; |
| 167 | 167 | |
@@ -170,12 +170,12 @@ discard block |
||
| 170 | 170 | $w = $params['w'] ? $params['w'] : '100%'; |
| 171 | 171 | $h = $params['h'] ? $params['h'] : '400px'; |
| 172 | 172 | $richtexteditor = $params['edt'] ? $params['edt'] : ""; |
| 173 | - $o = '<div class="MODX_RichTextWidget"><textarea id="' . $id . '" name="' . $id . '" style="width:' . $w . '; height:' . $h . ';">'; |
|
| 173 | + $o = '<div class="MODX_RichTextWidget"><textarea id="'.$id.'" name="'.$id.'" style="width:'.$w.'; height:'.$h.';">'; |
|
| 174 | 174 | $o .= $modx->htmlspecialchars($value); |
| 175 | 175 | $o .= '</textarea></div>'; |
| 176 | 176 | $replace_richtext = array($id); |
| 177 | 177 | // setup editors |
| 178 | - if(!empty($replace_richtext) && !empty($richtexteditor)) { |
|
| 178 | + if (!empty($replace_richtext) && !empty($richtexteditor)) { |
|
| 179 | 179 | // invoke OnRichTextEditorInit event |
| 180 | 180 | $evtOut = $modx->invokeEvent("OnRichTextEditorInit", array( |
| 181 | 181 | 'editor' => $richtexteditor, |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | 'width' => $w, |
| 185 | 185 | 'height' => $h |
| 186 | 186 | )); |
| 187 | - if(is_array($evtOut)) { |
|
| 187 | + if (is_array($evtOut)) { |
|
| 188 | 188 | $o .= implode("", $evtOut); |
| 189 | 189 | } |
| 190 | 190 | } |
@@ -197,8 +197,8 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | case "viewport": |
| 199 | 199 | $value = parseInput($value); |
| 200 | - $id = '_' . time(); |
|
| 201 | - if(!$params['vpid']) { |
|
| 200 | + $id = '_'.time(); |
|
| 201 | + if (!$params['vpid']) { |
|
| 202 | 202 | $params['vpid'] = $id; |
| 203 | 203 | } |
| 204 | 204 | $sTag = "<iframe"; |
@@ -206,42 +206,42 @@ discard block |
||
| 206 | 206 | $autoMode = "0"; |
| 207 | 207 | $w = $params['width']; |
| 208 | 208 | $h = $params['height']; |
| 209 | - if($params['stretch'] == 'Yes') { |
|
| 209 | + if ($params['stretch'] == 'Yes') { |
|
| 210 | 210 | $w = "100%"; |
| 211 | 211 | $h = "100%"; |
| 212 | 212 | } |
| 213 | - if($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
| 214 | - $autoMode = "3"; //both |
|
| 215 | - } else if($params['awidth'] == 'Yes') { |
|
| 213 | + if ($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
| 214 | + $autoMode = "3"; //both |
|
| 215 | + } else if ($params['awidth'] == 'Yes') { |
|
| 216 | 216 | $autoMode = "1"; //width only |
| 217 | - } else if($params['aheight'] == 'Yes') { |
|
| 218 | - $autoMode = "2"; //height only |
|
| 217 | + } else if ($params['aheight'] == 'Yes') { |
|
| 218 | + $autoMode = "2"; //height only |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/bin/viewport.js", array( |
|
| 221 | + $modx->regClientStartupScript(MODX_MANAGER_URL."media/script/bin/viewport.js", array( |
|
| 222 | 222 | 'name' => 'viewport', |
| 223 | 223 | 'version' => '0', |
| 224 | 224 | 'plaintext' => false |
| 225 | 225 | )); |
| 226 | - $o = $sTag . " id='" . $params['vpid'] . "' name='" . $params['vpid'] . "' "; |
|
| 227 | - if($params['class']) { |
|
| 228 | - $o .= " class='" . $params['class'] . "' "; |
|
| 226 | + $o = $sTag." id='".$params['vpid']."' name='".$params['vpid']."' "; |
|
| 227 | + if ($params['class']) { |
|
| 228 | + $o .= " class='".$params['class']."' "; |
|
| 229 | 229 | } |
| 230 | - if($params['style']) { |
|
| 231 | - $o .= " style='" . $params['style'] . "' "; |
|
| 230 | + if ($params['style']) { |
|
| 231 | + $o .= " style='".$params['style']."' "; |
|
| 232 | 232 | } |
| 233 | - if($params['attrib']) { |
|
| 234 | - $o .= $params['attrib'] . " "; |
|
| 233 | + if ($params['attrib']) { |
|
| 234 | + $o .= $params['attrib']." "; |
|
| 235 | 235 | } |
| 236 | - $o .= "scrolling='" . ($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto")) . "' "; |
|
| 237 | - $o .= "src='" . $value . "' frameborder='" . $params['borsize'] . "' "; |
|
| 238 | - $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'" . $params['vpid'] . "\\'," . $autoMode . ")',100);\" width='" . $w . "' height='" . $h . "' "; |
|
| 236 | + $o .= "scrolling='".($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto"))."' "; |
|
| 237 | + $o .= "src='".$value."' frameborder='".$params['borsize']."' "; |
|
| 238 | + $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'".$params['vpid']."\\',".$autoMode.")',100);\" width='".$w."' height='".$h."' "; |
|
| 239 | 239 | $o .= ">"; |
| 240 | 240 | $o .= $eTag; |
| 241 | 241 | break; |
| 242 | 242 | |
| 243 | 243 | case "datagrid": |
| 244 | - include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; |
|
| 244 | + include_once MODX_MANAGER_PATH."includes/controls/datagrid.class.php"; |
|
| 245 | 245 | $grd = new DataGrid('', $value); |
| 246 | 246 | |
| 247 | 247 | $grd->noRecordMsg = $params['egmsg']; |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | |
| 277 | 277 | case 'htmlentities': |
| 278 | 278 | $value = parseInput($value); |
| 279 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 279 | + if ($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 280 | 280 | // remove delimiter from checkbox and listbox-multiple TVs |
| 281 | 281 | $value = str_replace('||', '', $value); |
| 282 | 282 | } |
@@ -287,33 +287,33 @@ discard block |
||
| 287 | 287 | $widget_output = ''; |
| 288 | 288 | $o = ''; |
| 289 | 289 | /* If we are loading a file */ |
| 290 | - if(substr($params['output'], 0, 5) == "@FILE") { |
|
| 291 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 6)); |
|
| 292 | - if(!file_exists($file_name)) { |
|
| 293 | - $widget_output = $file_name . ' does not exist'; |
|
| 290 | + if (substr($params['output'], 0, 5) == "@FILE") { |
|
| 291 | + $file_name = MODX_BASE_PATH.trim(substr($params['output'], 6)); |
|
| 292 | + if (!file_exists($file_name)) { |
|
| 293 | + $widget_output = $file_name.' does not exist'; |
|
| 294 | 294 | } else { |
| 295 | 295 | $widget_output = file_get_contents($file_name); |
| 296 | 296 | } |
| 297 | - } elseif(substr($params['output'], 0, 8) == '@INCLUDE') { |
|
| 298 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 9)); |
|
| 299 | - if(!file_exists($file_name)) { |
|
| 300 | - $widget_output = $file_name . ' does not exist'; |
|
| 297 | + } elseif (substr($params['output'], 0, 8) == '@INCLUDE') { |
|
| 298 | + $file_name = MODX_BASE_PATH.trim(substr($params['output'], 9)); |
|
| 299 | + if (!file_exists($file_name)) { |
|
| 300 | + $widget_output = $file_name.' does not exist'; |
|
| 301 | 301 | } else { |
| 302 | 302 | /* The included file needs to set $widget_output. Can be string, array, object */ |
| 303 | 303 | include $file_name; |
| 304 | 304 | } |
| 305 | - } elseif(substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
| 305 | + } elseif (substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
| 306 | 306 | $chunk_name = trim(substr($params['output'], 7)); |
| 307 | 307 | $widget_output = $modx->getChunk($chunk_name); |
| 308 | - } elseif(substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
| 308 | + } elseif (substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
| 309 | 309 | $eval_str = trim(substr($params['output'], 6)); |
| 310 | 310 | $widget_output = eval($eval_str); |
| 311 | - } elseif($value !== '') { |
|
| 311 | + } elseif ($value !== '') { |
|
| 312 | 312 | $widget_output = $params['output']; |
| 313 | 313 | } else { |
| 314 | 314 | $widget_output = ''; |
| 315 | 315 | } |
| 316 | - if(is_string($widget_output)) { |
|
| 316 | + if (is_string($widget_output)) { |
|
| 317 | 317 | $_ = $modx->config['enable_filter']; |
| 318 | 318 | $modx->config['enable_filter'] = 1; |
| 319 | 319 | $widget_output = $modx->parseText($widget_output, array('value' => $value)); |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | |
| 327 | 327 | default: |
| 328 | 328 | $value = parseInput($value); |
| 329 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 329 | + if ($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 330 | 330 | // add separator |
| 331 | 331 | $value = explode('||', $value); |
| 332 | 332 | $value = implode($sep, $value); |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | * @param string $s |
| 342 | 342 | * @return string |
| 343 | 343 | */ |
| 344 | -function decodeParamValue($s) { |
|
| 344 | +function decodeParamValue($s){ |
|
| 345 | 345 | $s = str_replace("%3D", '=', $s); // = |
| 346 | 346 | return str_replace("%26", '&', $s); // & |
| 347 | 347 | } |
@@ -355,16 +355,16 @@ discard block |
||
| 355 | 355 | * @param bool $columns |
| 356 | 356 | * @return array|string |
| 357 | 357 | */ |
| 358 | -function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array |
|
| 358 | +function parseInput($src, $delim = "||", $type = "string", $columns = true){ // type can be: string, array |
|
| 359 | 359 | $modx = evolutionCMS(); |
| 360 | - if($modx->db->isResult($src)) { |
|
| 360 | + if ($modx->db->isResult($src)) { |
|
| 361 | 361 | // must be a recordset |
| 362 | 362 | $rows = array(); |
| 363 | - while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
| 363 | + while ($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
| 364 | 364 | return ($type == "array") ? $rows : implode($delim, $rows); |
| 365 | 365 | } else { |
| 366 | 366 | // must be a text |
| 367 | - if($type == "array") { |
|
| 367 | + if ($type == "array") { |
|
| 368 | 368 | return explode($delim, $src); |
| 369 | 369 | } else { |
| 370 | 370 | return $src; |
@@ -376,21 +376,21 @@ discard block |
||
| 376 | 376 | * @param string $value |
| 377 | 377 | * @return bool|false|int |
| 378 | 378 | */ |
| 379 | -function getUnixtimeFromDateString($value) { |
|
| 379 | +function getUnixtimeFromDateString($value){ |
|
| 380 | 380 | $timestamp = false; |
| 381 | 381 | // Check for MySQL or legacy style date |
| 382 | 382 | $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
| 383 | 383 | $date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
| 384 | 384 | $matches = array(); |
| 385 | - if(strpos($value, '-') !== false) { |
|
| 386 | - if(preg_match($date_match_1, $value, $matches)) { |
|
| 385 | + if (strpos($value, '-') !== false) { |
|
| 386 | + if (preg_match($date_match_1, $value, $matches)) { |
|
| 387 | 387 | $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]); |
| 388 | - } elseif(preg_match($date_match_2, $value, $matches)) { |
|
| 388 | + } elseif (preg_match($date_match_2, $value, $matches)) { |
|
| 389 | 389 | $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | // If those didn't work, use strtotime to figure out the date |
| 393 | - if($timestamp === false || $timestamp === -1) { |
|
| 393 | + if ($timestamp === false || $timestamp === -1) { |
|
| 394 | 394 | $timestamp = strtotime($value); |
| 395 | 395 | } |
| 396 | 396 | return $timestamp; |
@@ -15,7 +15,8 @@ discard block |
||
| 15 | 15 | * @param string $sep |
| 16 | 16 | * @return mixed|string |
| 17 | 17 | */ |
| 18 | -function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '') { |
|
| 18 | +function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '') |
|
| 19 | +{ |
|
| 19 | 20 | |
| 20 | 21 | $modx = evolutionCMS(); |
| 21 | 22 | $o = ''; |
@@ -59,7 +60,9 @@ discard block |
||
| 59 | 60 | if(isset($params['align']) && $params['align'] != 'none') { |
| 60 | 61 | $attr['align'] = $params['align']; |
| 61 | 62 | } |
| 62 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 63 | + foreach($attr as $k => $v) { |
|
| 64 | + $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 65 | + } |
|
| 63 | 66 | $attributes .= ' ' . $params['attrib']; |
| 64 | 67 | |
| 65 | 68 | // Output the image with attributes |
@@ -128,7 +131,9 @@ discard block |
||
| 128 | 131 | 'style' => $params['style'], |
| 129 | 132 | 'target' => $params['target'], |
| 130 | 133 | ); |
| 131 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 134 | + foreach($attr as $k => $v) { |
|
| 135 | + $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 136 | + } |
|
| 132 | 137 | $attributes .= ' ' . $params['attrib']; // add extra |
| 133 | 138 | |
| 134 | 139 | // Output the link |
@@ -157,7 +162,9 @@ discard block |
||
| 157 | 162 | 'class' => $params['class'], |
| 158 | 163 | 'style' => $params['style'], |
| 159 | 164 | ); |
| 160 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 165 | + foreach($attr as $k => $v) { |
|
| 166 | + $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 167 | + } |
|
| 161 | 168 | $attributes .= ' ' . $params['attrib']; // add extra |
| 162 | 169 | |
| 163 | 170 | // Output the HTML Tag |
@@ -341,7 +348,8 @@ discard block |
||
| 341 | 348 | * @param string $s |
| 342 | 349 | * @return string |
| 343 | 350 | */ |
| 344 | -function decodeParamValue($s) { |
|
| 351 | +function decodeParamValue($s) |
|
| 352 | +{ |
|
| 345 | 353 | $s = str_replace("%3D", '=', $s); // = |
| 346 | 354 | return str_replace("%26", '&', $s); // & |
| 347 | 355 | } |
@@ -355,12 +363,16 @@ discard block |
||
| 355 | 363 | * @param bool $columns |
| 356 | 364 | * @return array|string |
| 357 | 365 | */ |
| 358 | -function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array |
|
| 366 | +function parseInput($src, $delim = "||", $type = "string", $columns = true) |
|
| 367 | +{ |
|
| 368 | +// type can be: string, array |
|
| 359 | 369 | $modx = evolutionCMS(); |
| 360 | 370 | if($modx->db->isResult($src)) { |
| 361 | 371 | // must be a recordset |
| 362 | 372 | $rows = array(); |
| 363 | - while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
| 373 | + while($cols = $modx->db->getRow($src, 'num')) { |
|
| 374 | + $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
| 375 | + } |
|
| 364 | 376 | return ($type == "array") ? $rows : implode($delim, $rows); |
| 365 | 377 | } else { |
| 366 | 378 | // must be a text |
@@ -376,7 +388,8 @@ discard block |
||
| 376 | 388 | * @param string $value |
| 377 | 389 | * @return bool|false|int |
| 378 | 390 | */ |
| 379 | -function getUnixtimeFromDateString($value) { |
|
| 391 | +function getUnixtimeFromDateString($value) |
|
| 392 | +{ |
|
| 380 | 393 | $timestamp = false; |
| 381 | 394 | // Check for MySQL or legacy style date |
| 382 | 395 | $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class DATEPICKER {
|
| 4 | - function __construct() {
|
|
| 5 | - } |
|
| 4 | + function __construct() {
|
|
| 5 | + } |
|
| 6 | 6 | |
| 7 | - function getDP() {
|
|
| 8 | - $modx = evolutionCMS(); global $_lang; |
|
| 7 | + function getDP() {
|
|
| 8 | + $modx = evolutionCMS(); global $_lang; |
|
| 9 | 9 | |
| 10 | - $tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl'); |
|
| 11 | - return $modx->parseText($tpl, $_lang, '[%', '%]'); |
|
| 12 | - } |
|
| 10 | + $tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl'); |
|
| 11 | + return $modx->parseText($tpl, $_lang, '[%', '%]'); |
|
| 12 | + } |
|
| 13 | 13 | } |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class DATEPICKER {
|
|
| 4 | - function __construct() {
|
|
| 3 | +class DATEPICKER{
|
|
| 4 | + function __construct(){
|
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | - function getDP() {
|
|
| 7 | + function getDP(){
|
|
| 8 | 8 | $modx = evolutionCMS(); global $_lang; |
| 9 | 9 | |
| 10 | - $tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl'); |
|
| 10 | + $tpl = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |
|
| 11 | 11 | return $modx->parseText($tpl, $_lang, '[%', '%]'); |
| 12 | 12 | } |
| 13 | 13 | } |
@@ -1,10 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class DATEPICKER {
|
|
| 4 | - function __construct() {
|
|
| 3 | +class DATEPICKER |
|
| 4 | +{ |
|
| 5 | + function __construct() |
|
| 6 | + { |
|
| 5 | 7 | } |
| 6 | 8 | |
| 7 | - function getDP() {
|
|
| 9 | + function getDP() |
|
| 10 | + { |
|
| 8 | 11 | $modx = evolutionCMS(); global $_lang; |
| 9 | 12 | |
| 10 | 13 | $tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl'); |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | -class DATEPICKER { |
|
| 3 | - function __construct() { |
|
| 2 | +class DATEPICKER{ |
|
| 3 | + function __construct(){ |
|
| 4 | 4 | } |
| 5 | - function getDP() { |
|
| 5 | + function getDP(){ |
|
| 6 | 6 | $modx = evolutionCMS(); global$_lang; |
| 7 | 7 | |
| 8 | 8 | $tpl = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |
| 9 | - return $modx->parseText($tpl,$_lang,'[%','%]'); |
|
| 9 | + return $modx->parseText($tpl, $_lang, '[%', '%]'); |
|
| 10 | 10 | } |
| 11 | 11 | } |
@@ -1,8 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | -class DATEPICKER { |
|
| 3 | - function __construct() { |
|
| 2 | +class DATEPICKER |
|
| 3 | +{ |
|
| 4 | + function __construct() |
|
| 5 | + { |
|
| 4 | 6 | } |
| 5 | - function getDP() { |
|
| 7 | + function getDP() |
|
| 8 | + { |
|
| 6 | 9 | $modx = evolutionCMS(); global$_lang; |
| 7 | 10 | |
| 8 | 11 | $tpl = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |