@@ -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 | global $modx, $_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 { |
@@ -1,9 +1,9 @@ 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 | -$lockElementId = (int)$lockElementId; |
|
| 6 | +$lockElementId = (int) $lockElementId; |
|
| 7 | 7 | |
| 8 | 8 | if ($lockElementId > 0) { |
| 9 | 9 | ?> |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | var stay = document.getElementById('stay'); |
| 19 | 19 | // Trigger unlock |
| 20 | 20 | if ((stay && stay.value !== '2') || !form_save) { |
| 21 | - var url = '<?php echo MODX_MANAGER_URL; ?>?a=67&type=<?php echo $lockElementType;?>&id=<?php echo $lockElementId;?>&o=' + Math.random(); |
|
| 21 | + var url = '<?php echo MODX_MANAGER_URL; ?>?a=67&type=<?php echo $lockElementType; ?>&id=<?php echo $lockElementId; ?>&o=' + Math.random(); |
|
| 22 | 22 | if (navigator.sendBeacon) { |
| 23 | 23 | navigator.sendBeacon(url) |
| 24 | 24 | } else { |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public $errormessage; |
| 17 | 17 | |
| 18 | - public function __construct() { |
|
| 18 | + public function __construct(){ |
|
| 19 | 19 | |
| 20 | 20 | $_lang = $this->include_lang('errormsg'); |
| 21 | 21 | |
@@ -50,33 +50,33 @@ discard block |
||
| 50 | 50 | ); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - function include_lang($context='common') { |
|
| 53 | + function include_lang($context = 'common'){ |
|
| 54 | 54 | global $modx; |
| 55 | 55 | $_lang = array(); |
| 56 | 56 | |
| 57 | - $context = trim($context,'/'); |
|
| 58 | - if(strpos($context,'..')!==false) return; |
|
| 57 | + $context = trim($context, '/'); |
|
| 58 | + if (strpos($context, '..') !== false) return; |
|
| 59 | 59 | |
| 60 | - if($context === 'common') |
|
| 61 | - $lang_path = MODX_MANAGER_PATH . 'includes/lang/'; |
|
| 60 | + if ($context === 'common') |
|
| 61 | + $lang_path = MODX_MANAGER_PATH.'includes/lang/'; |
|
| 62 | 62 | else |
| 63 | - $lang_path = MODX_MANAGER_PATH . "includes/lang/{$context}/"; |
|
| 64 | - include_once($lang_path . 'english.inc.php'); |
|
| 63 | + $lang_path = MODX_MANAGER_PATH."includes/lang/{$context}/"; |
|
| 64 | + include_once($lang_path.'english.inc.php'); |
|
| 65 | 65 | $manager_language = $modx->config['manager_language']; |
| 66 | - if(is_file("{$lang_path}{$manager_language}.inc.php")) |
|
| 66 | + if (is_file("{$lang_path}{$manager_language}.inc.php")) |
|
| 67 | 67 | include_once("{$lang_path}{$manager_language}.inc.php"); |
| 68 | 68 | return $_lang; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - function setError($errorcode, $custommessage=""){ |
|
| 72 | - $this->errorcode=$errorcode; |
|
| 73 | - $this->errormessage=$this->errors[$errorcode]; |
|
| 74 | - if($custommessage!="") { |
|
| 75 | - $this->errormessage=$custommessage; |
|
| 71 | + function setError($errorcode, $custommessage = ""){ |
|
| 72 | + $this->errorcode = $errorcode; |
|
| 73 | + $this->errormessage = $this->errors[$errorcode]; |
|
| 74 | + if ($custommessage != "") { |
|
| 75 | + $this->errormessage = $custommessage; |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - function getError() { |
|
| 79 | + function getError(){ |
|
| 80 | 80 | return $this->errorcode; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -12,24 +12,24 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | -class logHandler { |
|
| 15 | +class logHandler{ |
|
| 16 | 16 | // Single variable for a log entry |
| 17 | 17 | var $entry = array(); |
| 18 | 18 | |
| 19 | - function initAndWriteLog($msg="", $internalKey="", $username="", $action="", $itemid="", $itemname="") { |
|
| 19 | + function initAndWriteLog($msg = "", $internalKey = "", $username = "", $action = "", $itemid = "", $itemname = ""){ |
|
| 20 | 20 | global $modx; |
| 21 | 21 | $this->entry['msg'] = $msg; // writes testmessage to the object |
| 22 | - $this->entry['action'] = empty($action)? $modx->manager->action : $action; // writes the action to the object |
|
| 22 | + $this->entry['action'] = empty($action) ? $modx->manager->action : $action; // writes the action to the object |
|
| 23 | 23 | |
| 24 | 24 | // User Credentials |
| 25 | 25 | $this->entry['internalKey'] = $internalKey == "" ? $modx->getLoginUserID() : $internalKey; |
| 26 | 26 | $this->entry['username'] = $username == "" ? $modx->getLoginUserName() : $username; |
| 27 | 27 | |
| 28 | - $this->entry['itemId'] = (empty($itemid) && isset($_REQUEST['id'])) ? (int)$_REQUEST['id'] : $itemid; // writes the id to the object |
|
| 29 | - if($this->entry['itemId'] == 0) $this->entry['itemId'] = "-"; // to stop items having id 0 |
|
| 28 | + $this->entry['itemId'] = (empty($itemid) && isset($_REQUEST['id'])) ? (int) $_REQUEST['id'] : $itemid; // writes the id to the object |
|
| 29 | + if ($this->entry['itemId'] == 0) $this->entry['itemId'] = "-"; // to stop items having id 0 |
|
| 30 | 30 | |
| 31 | - $this->entry['itemName'] = ($itemname == "" && isset($_SESSION['itemname']))? $_SESSION['itemname'] : $itemname; // writes the id to the object |
|
| 32 | - if($this->entry['itemName'] == "") $this->entry['itemName'] = "-"; // to stop item name being empty |
|
| 31 | + $this->entry['itemName'] = ($itemname == "" && isset($_SESSION['itemname'])) ? $_SESSION['itemname'] : $itemname; // writes the id to the object |
|
| 32 | + if ($this->entry['itemName'] == "") $this->entry['itemName'] = "-"; // to stop item name being empty |
|
| 33 | 33 | |
| 34 | 34 | $this->writeToLog(); |
| 35 | 35 | return; |
@@ -38,20 +38,20 @@ discard block |
||
| 38 | 38 | // function to write to the log |
| 39 | 39 | // collects all required info, and |
| 40 | 40 | // writes it to the logging table |
| 41 | - function writeToLog() { |
|
| 41 | + function writeToLog(){ |
|
| 42 | 42 | global $modx; |
| 43 | 43 | $tbl_manager_log = $modx->getFullTableName('manager_log'); |
| 44 | 44 | |
| 45 | - if($this->entry['internalKey'] == "") { |
|
| 45 | + if ($this->entry['internalKey'] == "") { |
|
| 46 | 46 | $modx->webAlertAndQuit("Logging error: internalKey not set."); |
| 47 | 47 | } |
| 48 | - if(empty($this->entry['action'])) { |
|
| 48 | + if (empty($this->entry['action'])) { |
|
| 49 | 49 | $modx->webAlertAndQuit("Logging error: action not set."); |
| 50 | 50 | } |
| 51 | - if($this->entry['msg'] == "") { |
|
| 51 | + if ($this->entry['msg'] == "") { |
|
| 52 | 52 | include_once "actionlist.inc.php"; |
| 53 | 53 | $this->entry['msg'] = getAction($this->entry['action'], $this->entry['itemId']); |
| 54 | - if($this->entry['msg'] == "") { |
|
| 54 | + if ($this->entry['msg'] == "") { |
|
| 55 | 55 | $modx->webAlertAndQuit("Logging error: couldn't find message to write to log."); |
| 56 | 56 | } |
| 57 | 57 | } |
@@ -63,14 +63,14 @@ discard block |
||
| 63 | 63 | $fields['itemid'] = $this->entry['itemId']; |
| 64 | 64 | $fields['itemname'] = $modx->db->escape($this->entry['itemName']); |
| 65 | 65 | $fields['message'] = $modx->db->escape($this->entry['msg']); |
| 66 | - $insert_id = $modx->db->insert($fields,$tbl_manager_log); |
|
| 67 | - if(!$insert_id) { |
|
| 66 | + $insert_id = $modx->db->insert($fields, $tbl_manager_log); |
|
| 67 | + if (!$insert_id) { |
|
| 68 | 68 | $modx->messageQuit("Logging error: couldn't save log to table! Error code: ".$modx->db->getLastError()); |
| 69 | 69 | } else { |
| 70 | - $limit = (isset($modx->config['manager_log_limit'])) ? (int)$modx->config['manager_log_limit'] : 3000; |
|
| 71 | - $trim = (isset($modx->config['manager_log_trim'])) ? (int)$modx->config['manager_log_trim'] : 100; |
|
| 72 | - if(($insert_id % $trim) === 0) { |
|
| 73 | - $modx->rotate_log('manager_log',$limit,$trim); |
|
| 70 | + $limit = (isset($modx->config['manager_log_limit'])) ? (int) $modx->config['manager_log_limit'] : 3000; |
|
| 71 | + $trim = (isset($modx->config['manager_log_trim'])) ? (int) $modx->config['manager_log_trim'] : 100; |
|
| 72 | + if (($insert_id % $trim) === 0) { |
|
| 73 | + $modx->rotate_log('manager_log', $limit, $trim); |
|
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -67,14 +67,14 @@ discard block |
||
| 67 | 67 | $countChild++; |
| 68 | 68 | $id = $value[0]; |
| 69 | 69 | $ph['id'] = $id; |
| 70 | - $ph['li_class'] = $this->get_li_class($id) . $value[10]; |
|
| 70 | + $ph['li_class'] = $this->get_li_class($id).$value[10]; |
|
| 71 | 71 | $ph['href'] = $value[3]; |
| 72 | 72 | $ph['alt'] = $value[4]; |
| 73 | 73 | $ph['target'] = $value[7]; |
| 74 | 74 | $ph['onclick'] = $value[5]; |
| 75 | 75 | $ph['a_class'] = $this->get_a_class($id); |
| 76 | 76 | $ph['LinkAttr'] = $this->getLinkAttr($id); |
| 77 | - $ph['itemName'] = $value[2] . $this->getItemName($id); |
|
| 77 | + $ph['itemName'] = $value[2].$this->getItemName($id); |
|
| 78 | 78 | |
| 79 | 79 | $ph['DrawSub'] = ''; |
| 80 | 80 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | public function get_li_class($id) |
| 114 | 114 | { |
| 115 | 115 | if (isset($this->menu[$id])) { |
| 116 | - return $this->defaults['parentClass'] . ' '; |
|
| 116 | + return $this->defaults['parentClass'].' '; |
|
| 117 | 117 | } else { |
| 118 | 118 | return ''; |
| 119 | 119 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | public function get_a_class($id) |
| 123 | 123 | { |
| 124 | 124 | if (isset($this->menu[$id])) { |
| 125 | - return ' class="' . $this->defaults['parentLinkClass'] . '"'; |
|
| 125 | + return ' class="'.$this->defaults['parentLinkClass'].'"'; |
|
| 126 | 126 | } else { |
| 127 | 127 | return ''; |
| 128 | 128 | } |
@@ -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', |
@@ -14,13 +14,13 @@ discard block |
||
| 14 | 14 | 'DIRECTORY' |
| 15 | 15 | ); |
| 16 | 16 | |
| 17 | -function ProcessTVCommand($value, $name = '', $docid = '', $src='docform', $tvsArray = array()) { |
|
| 17 | +function ProcessTVCommand($value, $name = '', $docid = '', $src = 'docform', $tvsArray = array()){ |
|
| 18 | 18 | global $modx; |
| 19 | - $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
|
| 19 | + $docid = (int) $docid > 0 ? (int) $docid : $modx->documentIdentifier; |
|
| 20 | 20 | $nvalue = trim($value); |
| 21 | 21 | if (substr($nvalue, 0, 1) != '@') |
| 22 | 22 | return $value; |
| 23 | - elseif(isset($modx->config['enable_bindings']) && $modx->config['enable_bindings']!=1 && $src==='docform') { |
|
| 23 | + elseif (isset($modx->config['enable_bindings']) && $modx->config['enable_bindings'] != 1 && $src === 'docform') { |
|
| 24 | 24 | return '@Bindings is disabled.'; |
| 25 | 25 | } |
| 26 | 26 | else { |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | break; |
| 47 | 47 | |
| 48 | 48 | case "SELECT" : // selects a record from the cms database |
| 49 | - $rt = array (); |
|
| 50 | - $replacementVars = array ( |
|
| 49 | + $rt = array(); |
|
| 50 | + $replacementVars = array( |
|
| 51 | 51 | 'DBASE' => $modx->db->config['dbase'], |
| 52 | 52 | 'PREFIX' => $modx->db->config['table_prefix'] |
| 53 | 53 | ); |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 88 | break; |
| 89 | 89 | |
| 90 | 90 | case 'DIRECTORY' : |
| 91 | - $files = array (); |
|
| 92 | - $path = $modx->config['base_path'] . $param; |
|
| 91 | + $files = array(); |
|
| 92 | + $path = $modx->config['base_path'].$param; |
|
| 93 | 93 | if (substr($path, -1, 1) != '/') { |
| 94 | 94 | $path .= '/'; |
| 95 | 95 | } |
@@ -117,10 +117,10 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | -function ProcessFile($file) { |
|
| 120 | +function ProcessFile($file){ |
|
| 121 | 121 | // get the file |
| 122 | 122 | $buffer = @file_get_contents($file); |
| 123 | - if ($buffer===false) $buffer = " Could not retrieve document '$file'."; |
|
| 123 | + if ($buffer === false) $buffer = " Could not retrieve document '$file'."; |
|
| 124 | 124 | return $buffer; |
| 125 | 125 | } |
| 126 | 126 | |
@@ -129,12 +129,12 @@ discard block |
||
| 129 | 129 | { |
| 130 | 130 | global $BINDINGS; |
| 131 | 131 | $binding_array = array(); |
| 132 | - foreach($BINDINGS as $cmd) |
|
| 132 | + foreach ($BINDINGS as $cmd) |
|
| 133 | 133 | { |
| 134 | - if(strpos($binding_string,'@'.$cmd)===0) |
|
| 134 | + if (strpos($binding_string, '@'.$cmd) === 0) |
|
| 135 | 135 | { |
| 136 | - $code = substr($binding_string,strlen($cmd)+1); |
|
| 137 | - $binding_array = array($cmd,trim($code)); |
|
| 136 | + $code = substr($binding_string, strlen($cmd) + 1); |
|
| 137 | + $binding_array = array($cmd, trim($code)); |
|
| 138 | 138 | break; |
| 139 | 139 | } |
| 140 | 140 | } |
@@ -149,12 +149,12 @@ discard block |
||
| 149 | 149 | if (strpos($param, '[*') !== false) { |
| 150 | 150 | $matches = $modx->getTagsFromContent($param, '[*', '*]'); |
| 151 | 151 | foreach ($matches[0] as $i=>$match) { |
| 152 | - if(isset($tvsArray[ $matches[1][$i] ])) { |
|
| 153 | - if(is_array($tvsArray[ $matches[1][$i] ])) { |
|
| 152 | + if (isset($tvsArray[$matches[1][$i]])) { |
|
| 153 | + if (is_array($tvsArray[$matches[1][$i]])) { |
|
| 154 | 154 | $value = $tvsArray[$matches[1][$i]]['value']; |
| 155 | 155 | $value = $value === '' ? $tvsArray[$matches[1][$i]]['default_text'] : $value; |
| 156 | 156 | } else { |
| 157 | - $value = $tvsArray[ $matches[1][$i] ]; |
|
| 157 | + $value = $tvsArray[$matches[1][$i]]; |
|
| 158 | 158 | } |
| 159 | 159 | $param = str_replace($match, $value, $param); |
| 160 | 160 | } |
@@ -29,34 +29,34 @@ discard block |
||
| 29 | 29 | // include MagPieRSS |
| 30 | 30 | require_once(MODX_MANAGER_PATH.'media/rss/rss_fetch.inc'); |
| 31 | 31 | // Convert relative path into absolute url |
| 32 | -function rel2abs( $rel, $base ) { |
|
| 32 | +function rel2abs($rel, $base){ |
|
| 33 | 33 | // parse base URL and convert to local variables: $scheme, $host, $path |
| 34 | - $tmp = parse_url( $base ); |
|
| 35 | - extract( $tmp ); |
|
| 36 | - if ( strpos( $rel,"//" ) === 0 ) { |
|
| 37 | - return $scheme . ':' . $rel; |
|
| 34 | + $tmp = parse_url($base); |
|
| 35 | + extract($tmp); |
|
| 36 | + if (strpos($rel, "//") === 0) { |
|
| 37 | + return $scheme.':'.$rel; |
|
| 38 | 38 | } |
| 39 | 39 | // return if already absolute URL |
| 40 | - if ( parse_url( $rel, PHP_URL_SCHEME ) != '' ) { |
|
| 40 | + if (parse_url($rel, PHP_URL_SCHEME) != '') { |
|
| 41 | 41 | return $rel; |
| 42 | 42 | } |
| 43 | 43 | // queries and anchors |
| 44 | - if ( $rel[0] == '#' || $rel[0] == '?' ) { |
|
| 45 | - return $base . $rel; |
|
| 44 | + if ($rel[0] == '#' || $rel[0] == '?') { |
|
| 45 | + return $base.$rel; |
|
| 46 | 46 | } |
| 47 | 47 | // remove non-directory element from path |
| 48 | - $path = preg_replace( '#/[^/]*$#', '', $path ); |
|
| 48 | + $path = preg_replace('#/[^/]*$#', '', $path); |
|
| 49 | 49 | // destroy path if relative url points to root |
| 50 | - if ( $rel[0] == '/' ) { |
|
| 50 | + if ($rel[0] == '/') { |
|
| 51 | 51 | $path = ''; |
| 52 | 52 | } |
| 53 | 53 | // dirty absolute URL |
| 54 | - $abs = $host . $path . "/" . $rel; |
|
| 54 | + $abs = $host.$path."/".$rel; |
|
| 55 | 55 | // replace '//' or '/./' or '/foo/../' with '/' |
| 56 | - $abs = preg_replace( "/(\/\.?\/)/", "/", $abs ); |
|
| 57 | - $abs = preg_replace( "/\/(?!\.\.)[^\/]+\/\.\.\//", "/", $abs ); |
|
| 56 | + $abs = preg_replace("/(\/\.?\/)/", "/", $abs); |
|
| 57 | + $abs = preg_replace("/\/(?!\.\.)[^\/]+\/\.\.\//", "/", $abs); |
|
| 58 | 58 | // absolute URL is ready! |
| 59 | - return $scheme . '://' . $abs; |
|
| 59 | + return $scheme.'://'.$abs; |
|
| 60 | 60 | } |
| 61 | 61 | $feedData = array(); |
| 62 | 62 | |
@@ -64,15 +64,15 @@ discard block |
||
| 64 | 64 | foreach ($urls as $section=>$url) { |
| 65 | 65 | $output = ''; |
| 66 | 66 | $rss = @fetch_rss($url); |
| 67 | - if( !$rss ){ |
|
| 68 | - $feedData[$section] = 'Failed to retrieve ' . $url; |
|
| 67 | + if (!$rss) { |
|
| 68 | + $feedData[$section] = 'Failed to retrieve '.$url; |
|
| 69 | 69 | continue; |
| 70 | 70 | } |
| 71 | 71 | $output .= '<ul>'; |
| 72 | 72 | |
| 73 | 73 | $items = array_slice($rss->items, 0, $itemsNumber); |
| 74 | 74 | foreach ($items as $item) { |
| 75 | - $href = rel2abs($item['link'],'https://github.com'); |
|
| 75 | + $href = rel2abs($item['link'], 'https://github.com'); |
|
| 76 | 76 | $title = $item['title']; |
| 77 | 77 | $pubdate = $item['pubdate']; |
| 78 | 78 | $pubdate = $modx->toDateFormat(strtotime($pubdate)); |
@@ -5,38 +5,38 @@ discard block |
||
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | // Added by Raymond 20-Jan-2005 |
| 8 | -function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '') { |
|
| 8 | +function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = ''){ |
|
| 9 | 9 | |
| 10 | 10 | global $modx; |
| 11 | 11 | $o = ''; |
| 12 | 12 | |
| 13 | 13 | // process any TV commands in value |
| 14 | - $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
|
| 14 | + $docid = (int) $docid > 0 ? (int) $docid : $modx->documentIdentifier; |
|
| 15 | 15 | $value = ProcessTVCommand($value, $name, $docid); |
| 16 | 16 | |
| 17 | 17 | $params = array(); |
| 18 | - if($paramstring) { |
|
| 18 | + if ($paramstring) { |
|
| 19 | 19 | $cp = explode("&", $paramstring); |
| 20 | - foreach($cp as $p => $v) { |
|
| 20 | + foreach ($cp as $p => $v) { |
|
| 21 | 21 | $v = trim($v); // trim |
| 22 | 22 | $ar = explode("=", $v); |
| 23 | - if(is_array($ar) && count($ar) == 2) { |
|
| 23 | + if (is_array($ar) && count($ar) == 2) { |
|
| 24 | 24 | $params[$ar[0]] = decodeParamValue($ar[1]); |
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | $id = "tv$name"; |
| 30 | - switch($format) { |
|
| 30 | + switch ($format) { |
|
| 31 | 31 | case 'image': |
| 32 | 32 | $images = parseInput($value, '||', 'array'); |
| 33 | - foreach($images as $image) { |
|
| 34 | - if(!is_array($image)) { |
|
| 33 | + foreach ($images as $image) { |
|
| 34 | + if (!is_array($image)) { |
|
| 35 | 35 | $image = explode('==', $image); |
| 36 | 36 | } |
| 37 | 37 | $src = $image[0]; |
| 38 | 38 | |
| 39 | - if($src) { |
|
| 39 | + if ($src) { |
|
| 40 | 40 | // We have a valid source |
| 41 | 41 | $attributes = ''; |
| 42 | 42 | $attr = array( |
@@ -46,14 +46,14 @@ discard block |
||
| 46 | 46 | 'alt' => $modx->htmlspecialchars($params['alttext']), |
| 47 | 47 | 'style' => $params['style'] |
| 48 | 48 | ); |
| 49 | - if(isset($params['align']) && $params['align'] != 'none') { |
|
| 49 | + if (isset($params['align']) && $params['align'] != 'none') { |
|
| 50 | 50 | $attr['align'] = $params['align']; |
| 51 | 51 | } |
| 52 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 53 | - $attributes .= ' ' . $params['attrib']; |
|
| 52 | + foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); |
|
| 53 | + $attributes .= ' '.$params['attrib']; |
|
| 54 | 54 | |
| 55 | 55 | // Output the image with attributes |
| 56 | - $o .= '<img' . rtrim($attributes) . ' />'; |
|
| 56 | + $o .= '<img'.rtrim($attributes).' />'; |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | break; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | case "delim": // display as delimitted list |
| 62 | 62 | $value = parseInput($value, "||"); |
| 63 | 63 | $p = $params['format'] ? $params['format'] : " "; |
| 64 | - if($p == "\\n") { |
|
| 64 | + if ($p == "\\n") { |
|
| 65 | 65 | $p = "\n"; |
| 66 | 66 | } |
| 67 | 67 | $o = str_replace("||", $p, $value); |
@@ -70,13 +70,13 @@ discard block |
||
| 70 | 70 | case "string": |
| 71 | 71 | $value = parseInput($value); |
| 72 | 72 | $format = strtolower($params['format']); |
| 73 | - if($format == 'upper case') { |
|
| 73 | + if ($format == 'upper case') { |
|
| 74 | 74 | $o = strtoupper($value); |
| 75 | - } else if($format == 'lower case') { |
|
| 75 | + } else if ($format == 'lower case') { |
|
| 76 | 76 | $o = strtolower($value); |
| 77 | - } else if($format == 'sentence case') { |
|
| 77 | + } else if ($format == 'sentence case') { |
|
| 78 | 78 | $o = ucfirst($value); |
| 79 | - } else if($format == 'capitalize') { |
|
| 79 | + } else if ($format == 'capitalize') { |
|
| 80 | 80 | $o = ucwords($value); |
| 81 | 81 | } else { |
| 82 | 82 | $o = $value; |
@@ -84,8 +84,8 @@ discard block |
||
| 84 | 84 | break; |
| 85 | 85 | |
| 86 | 86 | case "date": |
| 87 | - if($value != '' || $params['default'] == 'Yes') { |
|
| 88 | - if(empty($value)) { |
|
| 87 | + if ($value != '' || $params['default'] == 'Yes') { |
|
| 88 | + if (empty($value)) { |
|
| 89 | 89 | $value = 'now'; |
| 90 | 90 | } |
| 91 | 91 | $timestamp = getUnixtimeFromDateString($value); |
@@ -100,13 +100,13 @@ discard block |
||
| 100 | 100 | $value = parseInput($value, "||", "array"); |
| 101 | 101 | $o = ''; |
| 102 | 102 | $countValue = count($value); |
| 103 | - for($i = 0; $i < $countValue; $i++) { |
|
| 103 | + for ($i = 0; $i < $countValue; $i++) { |
|
| 104 | 104 | list($name, $url) = is_array($value[$i]) ? $value[$i] : explode("==", $value[$i]); |
| 105 | - if(!$url) { |
|
| 105 | + if (!$url) { |
|
| 106 | 106 | $url = $name; |
| 107 | 107 | } |
| 108 | - if($url) { |
|
| 109 | - if($o) { |
|
| 108 | + if ($url) { |
|
| 109 | + if ($o) { |
|
| 110 | 110 | $o .= '<br />'; |
| 111 | 111 | } |
| 112 | 112 | $attributes = ''; |
@@ -118,11 +118,11 @@ discard block |
||
| 118 | 118 | 'style' => $params['style'], |
| 119 | 119 | 'target' => $params['target'], |
| 120 | 120 | ); |
| 121 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 122 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
| 121 | + foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); |
|
| 122 | + $attributes .= ' '.$params['attrib']; // add extra |
|
| 123 | 123 | |
| 124 | 124 | // Output the link |
| 125 | - $o .= '<a' . rtrim($attributes) . '>' . ($params['text'] ? $modx->htmlspecialchars($params['text']) : $name) . '</a>'; |
|
| 125 | + $o .= '<a'.rtrim($attributes).'>'.($params['text'] ? $modx->htmlspecialchars($params['text']) : $name).'</a>'; |
|
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | break; |
@@ -134,9 +134,9 @@ discard block |
||
| 134 | 134 | $o = ''; |
| 135 | 135 | // Loop through a list of tags |
| 136 | 136 | $countValue = count($value); |
| 137 | - for($i = 0; $i < $countValue; $i++) { |
|
| 137 | + for ($i = 0; $i < $countValue; $i++) { |
|
| 138 | 138 | $tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i]; |
| 139 | - if(!$tagvalue) { |
|
| 139 | + if (!$tagvalue) { |
|
| 140 | 140 | continue; |
| 141 | 141 | } |
| 142 | 142 | |
@@ -147,11 +147,11 @@ discard block |
||
| 147 | 147 | 'class' => $params['class'], |
| 148 | 148 | 'style' => $params['style'], |
| 149 | 149 | ); |
| 150 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 151 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
| 150 | + foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); |
|
| 151 | + $attributes .= ' '.$params['attrib']; // add extra |
|
| 152 | 152 | |
| 153 | 153 | // Output the HTML Tag |
| 154 | - $o .= '<' . $tagname . rtrim($attributes) . '>' . $tagvalue . '</' . $tagname . '>'; |
|
| 154 | + $o .= '<'.$tagname.rtrim($attributes).'>'.$tagvalue.'</'.$tagname.'>'; |
|
| 155 | 155 | } |
| 156 | 156 | break; |
| 157 | 157 | |
@@ -160,12 +160,12 @@ discard block |
||
| 160 | 160 | $w = $params['w'] ? $params['w'] : '100%'; |
| 161 | 161 | $h = $params['h'] ? $params['h'] : '400px'; |
| 162 | 162 | $richtexteditor = $params['edt'] ? $params['edt'] : ""; |
| 163 | - $o = '<div class="MODX_RichTextWidget"><textarea id="' . $id . '" name="' . $id . '" style="width:' . $w . '; height:' . $h . ';">'; |
|
| 163 | + $o = '<div class="MODX_RichTextWidget"><textarea id="'.$id.'" name="'.$id.'" style="width:'.$w.'; height:'.$h.';">'; |
|
| 164 | 164 | $o .= $modx->htmlspecialchars($value); |
| 165 | 165 | $o .= '</textarea></div>'; |
| 166 | 166 | $replace_richtext = array($id); |
| 167 | 167 | // setup editors |
| 168 | - if(!empty($replace_richtext) && !empty($richtexteditor)) { |
|
| 168 | + if (!empty($replace_richtext) && !empty($richtexteditor)) { |
|
| 169 | 169 | // invoke OnRichTextEditorInit event |
| 170 | 170 | $evtOut = $modx->invokeEvent("OnRichTextEditorInit", array( |
| 171 | 171 | 'editor' => $richtexteditor, |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | 'width' => $w, |
| 175 | 175 | 'height' => $h |
| 176 | 176 | )); |
| 177 | - if(is_array($evtOut)) { |
|
| 177 | + if (is_array($evtOut)) { |
|
| 178 | 178 | $o .= implode("", $evtOut); |
| 179 | 179 | } |
| 180 | 180 | } |
@@ -187,8 +187,8 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | case "viewport": |
| 189 | 189 | $value = parseInput($value); |
| 190 | - $id = '_' . time(); |
|
| 191 | - if(!$params['vpid']) { |
|
| 190 | + $id = '_'.time(); |
|
| 191 | + if (!$params['vpid']) { |
|
| 192 | 192 | $params['vpid'] = $id; |
| 193 | 193 | } |
| 194 | 194 | $sTag = "<iframe"; |
@@ -196,42 +196,42 @@ discard block |
||
| 196 | 196 | $autoMode = "0"; |
| 197 | 197 | $w = $params['width']; |
| 198 | 198 | $h = $params['height']; |
| 199 | - if($params['stretch'] == 'Yes') { |
|
| 199 | + if ($params['stretch'] == 'Yes') { |
|
| 200 | 200 | $w = "100%"; |
| 201 | 201 | $h = "100%"; |
| 202 | 202 | } |
| 203 | - if($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
| 204 | - $autoMode = "3"; //both |
|
| 205 | - } else if($params['awidth'] == 'Yes') { |
|
| 203 | + if ($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
| 204 | + $autoMode = "3"; //both |
|
| 205 | + } else if ($params['awidth'] == 'Yes') { |
|
| 206 | 206 | $autoMode = "1"; //width only |
| 207 | - } else if($params['aheight'] == 'Yes') { |
|
| 208 | - $autoMode = "2"; //height only |
|
| 207 | + } else if ($params['aheight'] == 'Yes') { |
|
| 208 | + $autoMode = "2"; //height only |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/bin/viewport.js", array( |
|
| 211 | + $modx->regClientStartupScript(MODX_MANAGER_URL."media/script/bin/viewport.js", array( |
|
| 212 | 212 | 'name' => 'viewport', |
| 213 | 213 | 'version' => '0', |
| 214 | 214 | 'plaintext' => false |
| 215 | 215 | )); |
| 216 | - $o = $sTag . " id='" . $params['vpid'] . "' name='" . $params['vpid'] . "' "; |
|
| 217 | - if($params['class']) { |
|
| 218 | - $o .= " class='" . $params['class'] . "' "; |
|
| 216 | + $o = $sTag." id='".$params['vpid']."' name='".$params['vpid']."' "; |
|
| 217 | + if ($params['class']) { |
|
| 218 | + $o .= " class='".$params['class']."' "; |
|
| 219 | 219 | } |
| 220 | - if($params['style']) { |
|
| 221 | - $o .= " style='" . $params['style'] . "' "; |
|
| 220 | + if ($params['style']) { |
|
| 221 | + $o .= " style='".$params['style']."' "; |
|
| 222 | 222 | } |
| 223 | - if($params['attrib']) { |
|
| 224 | - $o .= $params['attrib'] . " "; |
|
| 223 | + if ($params['attrib']) { |
|
| 224 | + $o .= $params['attrib']." "; |
|
| 225 | 225 | } |
| 226 | - $o .= "scrolling='" . ($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto")) . "' "; |
|
| 227 | - $o .= "src='" . $value . "' frameborder='" . $params['borsize'] . "' "; |
|
| 228 | - $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'" . $params['vpid'] . "\\'," . $autoMode . ")',100);\" width='" . $w . "' height='" . $h . "' "; |
|
| 226 | + $o .= "scrolling='".($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto"))."' "; |
|
| 227 | + $o .= "src='".$value."' frameborder='".$params['borsize']."' "; |
|
| 228 | + $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'".$params['vpid']."\\',".$autoMode.")',100);\" width='".$w."' height='".$h."' "; |
|
| 229 | 229 | $o .= ">"; |
| 230 | 230 | $o .= $eTag; |
| 231 | 231 | break; |
| 232 | 232 | |
| 233 | 233 | case "datagrid": |
| 234 | - include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; |
|
| 234 | + include_once MODX_MANAGER_PATH."includes/controls/datagrid.class.php"; |
|
| 235 | 235 | $grd = new DataGrid('', $value); |
| 236 | 236 | |
| 237 | 237 | $grd->noRecordMsg = $params['egmsg']; |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | |
| 267 | 267 | case 'htmlentities': |
| 268 | 268 | $value = parseInput($value); |
| 269 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 269 | + if ($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 270 | 270 | // remove delimiter from checkbox and listbox-multiple TVs |
| 271 | 271 | $value = str_replace('||', '', $value); |
| 272 | 272 | } |
@@ -277,33 +277,33 @@ discard block |
||
| 277 | 277 | $widget_output = ''; |
| 278 | 278 | $o = ''; |
| 279 | 279 | /* If we are loading a file */ |
| 280 | - if(substr($params['output'], 0, 5) == "@FILE") { |
|
| 281 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 6)); |
|
| 282 | - if(!file_exists($file_name)) { |
|
| 283 | - $widget_output = $file_name . ' does not exist'; |
|
| 280 | + if (substr($params['output'], 0, 5) == "@FILE") { |
|
| 281 | + $file_name = MODX_BASE_PATH.trim(substr($params['output'], 6)); |
|
| 282 | + if (!file_exists($file_name)) { |
|
| 283 | + $widget_output = $file_name.' does not exist'; |
|
| 284 | 284 | } else { |
| 285 | 285 | $widget_output = file_get_contents($file_name); |
| 286 | 286 | } |
| 287 | - } elseif(substr($params['output'], 0, 8) == '@INCLUDE') { |
|
| 288 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 9)); |
|
| 289 | - if(!file_exists($file_name)) { |
|
| 290 | - $widget_output = $file_name . ' does not exist'; |
|
| 287 | + } elseif (substr($params['output'], 0, 8) == '@INCLUDE') { |
|
| 288 | + $file_name = MODX_BASE_PATH.trim(substr($params['output'], 9)); |
|
| 289 | + if (!file_exists($file_name)) { |
|
| 290 | + $widget_output = $file_name.' does not exist'; |
|
| 291 | 291 | } else { |
| 292 | 292 | /* The included file needs to set $widget_output. Can be string, array, object */ |
| 293 | 293 | include $file_name; |
| 294 | 294 | } |
| 295 | - } elseif(substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
| 295 | + } elseif (substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
| 296 | 296 | $chunk_name = trim(substr($params['output'], 7)); |
| 297 | 297 | $widget_output = $modx->getChunk($chunk_name); |
| 298 | - } elseif(substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
| 298 | + } elseif (substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
| 299 | 299 | $eval_str = trim(substr($params['output'], 6)); |
| 300 | 300 | $widget_output = eval($eval_str); |
| 301 | - } elseif($value !== '') { |
|
| 301 | + } elseif ($value !== '') { |
|
| 302 | 302 | $widget_output = $params['output']; |
| 303 | 303 | } else { |
| 304 | 304 | $widget_output = ''; |
| 305 | 305 | } |
| 306 | - if(is_string($widget_output)) { |
|
| 306 | + if (is_string($widget_output)) { |
|
| 307 | 307 | $_ = $modx->config['enable_filter']; |
| 308 | 308 | $modx->config['enable_filter'] = 1; |
| 309 | 309 | $widget_output = $modx->parseText($widget_output, array('value' => $value)); |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | default: |
| 318 | 318 | $value = parseInput($value); |
| 319 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 319 | + if ($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 320 | 320 | // add separator |
| 321 | 321 | $value = explode('||', $value); |
| 322 | 322 | $value = implode($sep, $value); |
@@ -327,23 +327,23 @@ discard block |
||
| 327 | 327 | return $o; |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | -function decodeParamValue($s) { |
|
| 330 | +function decodeParamValue($s){ |
|
| 331 | 331 | $s = str_replace("%3D", '=', $s); // = |
| 332 | 332 | $s = str_replace("%26", '&', $s); // & |
| 333 | 333 | return $s; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | // returns an array if a delimiter is present. returns array is a recordset is present |
| 337 | -function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array |
|
| 337 | +function parseInput($src, $delim = "||", $type = "string", $columns = true){ // type can be: string, array |
|
| 338 | 338 | global $modx; |
| 339 | - if($modx->db->isResult($src)) { |
|
| 339 | + if ($modx->db->isResult($src)) { |
|
| 340 | 340 | // must be a recordset |
| 341 | 341 | $rows = array(); |
| 342 | - while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
| 342 | + while ($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
| 343 | 343 | return ($type == "array") ? $rows : implode($delim, $rows); |
| 344 | 344 | } else { |
| 345 | 345 | // must be a text |
| 346 | - if($type == "array") { |
|
| 346 | + if ($type == "array") { |
|
| 347 | 347 | return explode($delim, $src); |
| 348 | 348 | } else { |
| 349 | 349 | return $src; |
@@ -351,21 +351,21 @@ discard block |
||
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | -function getUnixtimeFromDateString($value) { |
|
| 354 | +function getUnixtimeFromDateString($value){ |
|
| 355 | 355 | $timestamp = false; |
| 356 | 356 | // Check for MySQL or legacy style date |
| 357 | 357 | $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
| 358 | 358 | $date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
| 359 | 359 | $matches = array(); |
| 360 | - if(strpos($value, '-') !== false) { |
|
| 361 | - if(preg_match($date_match_1, $value, $matches)) { |
|
| 360 | + if (strpos($value, '-') !== false) { |
|
| 361 | + if (preg_match($date_match_1, $value, $matches)) { |
|
| 362 | 362 | $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]); |
| 363 | - } elseif(preg_match($date_match_2, $value, $matches)) { |
|
| 363 | + } elseif (preg_match($date_match_2, $value, $matches)) { |
|
| 364 | 364 | $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
| 365 | 365 | } |
| 366 | 366 | } |
| 367 | 367 | // If those didn't work, use strtotime to figure out the date |
| 368 | - if($timestamp === false || $timestamp === -1) { |
|
| 368 | + if ($timestamp === false || $timestamp === -1) { |
|
| 369 | 369 | $timestamp = strtotime($value); |
| 370 | 370 | } |
| 371 | 371 | return $timestamp; |
@@ -1,21 +1,21 @@ |
||
| 1 | 1 | <?php |
| 2 | -class DATEPICKER { |
|
| 3 | - public function getDP() { |
|
| 2 | +class DATEPICKER{ |
|
| 3 | + public function getDP(){ |
|
| 4 | 4 | global $modx; |
| 5 | 5 | |
| 6 | 6 | $load_script = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |
| 7 | - if(!isset($modx->config['lang_code'])) $modx->config['lang_code'] = $this->getLangCode(); |
|
| 7 | + if (!isset($modx->config['lang_code'])) $modx->config['lang_code'] = $this->getLangCode(); |
|
| 8 | 8 | $modx->config['datetime_format_lc'] = isset($modx->config['datetime_format']) ? strtolower($modx->config['datetime_format']) : 'dd-mm-yyyy'; |
| 9 | 9 | return $modx->mergeSettingsContent($load_script); |
| 10 | 10 | } |
| 11 | - public function getLangCode() { |
|
| 11 | + public function getLangCode(){ |
|
| 12 | 12 | global $modx, $modx_lang_attribute; |
| 13 | 13 | |
| 14 | - if(!$modx_lang_attribute) return 'en'; |
|
| 14 | + if (!$modx_lang_attribute) return 'en'; |
|
| 15 | 15 | |
| 16 | 16 | $lc = $modx_lang_attribute; |
| 17 | - if($lc === 'uk') return 'ru'; |
|
| 18 | - $dp_path = str_replace('\\','/',dirname(__FILE__)); |
|
| 17 | + if ($lc === 'uk') return 'ru'; |
|
| 18 | + $dp_path = str_replace('\\', '/', dirname(__FILE__)); |
|
| 19 | 19 | |
| 20 | 20 | return (is_file("{$dp_path}/i18n/datepicker.{$lc}.js")) ? $modx_lang_attribute : 'en'; |
| 21 | 21 | } |