Skip to content

Commit

Permalink
Update Doclister
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmi3yy committed Nov 17, 2017
1 parent 185adfe commit 0213e91
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
8 changes: 6 additions & 2 deletions assets/lib/Helpers/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,12 @@ public function loadArray($arr, $sep = ',')

if (is_scalar($arr)) {
$out = \jsonHelper::jsonDecode($arr, array('assoc' => true));
if (is_null($out) && $sep) {
$out = array_filter(explode($sep, $arr));
if (!is_array($out)) {
if ($sep) {
$out = array_filter(explode($sep, $arr));
} else {
$out = array();
}
}

return $out;
Expand Down
4 changes: 3 additions & 1 deletion assets/lib/Helpers/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public function __construct(\DocumentParser $modx, $cfg, $debug = false)
{
$this->modx = $modx;
$this->mail = new \MODxMailer();
$this->mail->init($modx);
if (method_exists('\MODxMailer', 'init')) {
$this->mail->init($modx);
}
$this->config = $cfg;
$this->debug = $debug;
$this->applyMailConfig();
Expand Down
12 changes: 6 additions & 6 deletions assets/lib/MODxAPI/modManagers.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,9 @@ protected function SessionHandler($directive, $cookieName, $remember = true)
}
break;
case 'destroy':
if (isset($_SESSION['webValidated'])) {
if (isset($_SESSION['mgrValidated'])) {
unset($_SESSION['usertype']);
unset($_SESSION['webShortname']);
unset($_SESSION['mgrShortname']);
unset($_SESSION['mgrFullname']);
unset($_SESSION['mgrEmail']);
unset($_SESSION['mgrValidated']);
Expand All @@ -525,12 +525,12 @@ protected function SessionHandler($directive, $cookieName, $remember = true)
unset($_SESSION['mgrDocgroups']);
unset($_SESSION['mgrPermissions']);

setcookie($cookieName, '', time() - 60, '/');
setcookie($cookieName, '', time() - 60, MODX_BASE_URL);
} else {
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time() - 60, '/');
setcookie(session_name(), '', time() - 60, MODX_BASE_URL);
}
setcookie($cookieName, '', time() - 60, '/');
setcookie($cookieName, '', time() - 60, MODX_BASE_URL);
session_destroy();
}
break;
Expand Down Expand Up @@ -561,7 +561,7 @@ public function setAutoLoginCookie($cookieName, $remember = true)
$remember = is_bool($remember) ? (60 * 60 * 24 * 365 * 5) : (int)$remember;
$cookieValue = $this->get('username');
$cookieExpires = time() + $remember;
setcookie($cookieName, $cookieValue, $cookieExpires, '/', '', $secure, true);
setcookie($cookieName, $cookieValue, $cookieExpires, MODX_BASE_URL, '', $secure, true);
}

return $this;
Expand Down
8 changes: 4 additions & 4 deletions assets/lib/MODxAPI/modUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,12 +495,12 @@ protected function SessionHandler($directive, $cookieName, $remember = true)
unset($_SESSION['webUserGroupNames']);
unset($_SESSION['webDocgroups']);

setcookie($cookieName, '', time() - 60, '/');
setcookie($cookieName, '', time() - 60, MODX_BASE_URL);
} else {
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time() - 60, '/');
setcookie(session_name(), '', time() - 60, MODX_BASE_URL);
}
setcookie($cookieName, '', time() - 60, '/');
setcookie($cookieName, '', time() - 60, MODX_BASE_URL);
session_destroy();
}
break;
Expand Down Expand Up @@ -532,7 +532,7 @@ public function setAutoLoginCookie($cookieName, $remember = true)
$cookieValue = array(md5($this->get('username')), $this->get('password'), $this->get('sessionid'), $remember);
$cookieValue = implode('|', $cookieValue);
$cookieExpires = time() + $remember;
setcookie($cookieName, $cookieValue, $cookieExpires, '/', '', $secure, true);
setcookie($cookieName, $cookieValue, $cookieExpires, MODX_BASE_URL, '', $secure, true);
}

return $this;
Expand Down
7 changes: 5 additions & 2 deletions assets/snippets/DocLister/lib/DLpaginate.class.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,10 @@ public function calculate()
/* Setup page vars for display. */
$prev = ($this->page <= 1) ? 0 : $this->page - 1; //previous page is page - 1
$next = (($this->page == $this->total_pages) ? 0 : ($this->page + 1)); //next page is page + 1
$lastpage = ceil($this->total_pages / $this->limit); //lastpage is = total pages / items per page, rounded up.
$lastpage = $this->total_pages;
if ($this->limit > 1 && $lastpage > $this->limit) {
$lastpage = $this->limit;
}
$lpm1 = $lastpage - 1; //last page minus 1

/*
Expand All @@ -360,7 +363,7 @@ public function calculate()
}
} elseif ($lastpage > 5 + ($this->adjacents * 2)) { //enough pages to hide some
//close to beginning; only hide later pages
if ($this->page < 1 + ($this->adjacents * 2)) {
if ($this->page <= 2 + ($this->adjacents * 2)) {
for ($counter = 1; $counter < 4 + ($this->adjacents * 2); $counter++) {
$tpl = ($counter == $this->page) ? $this->currentT : $this->numberT;
$this->pagination .= $this->renderItemTPL($tpl, $counter);
Expand Down

0 comments on commit 0213e91

Please sign in to comment.