/** * Calls a specific Extension hook Callback method * * @param string $callbackName * @param mixed ... (any type of parameters) */ public function callExtensionHook() { $args = func_get_args(); $callbackName = array_shift($args); if (method_exists($this, $callbackName)) { try { return call_user_func_array(array($this, $callbackName), $args); } catch (Exception $e) { $msg = $e->getMessage(); if (strlen($msg) == 0) { $msg = $itext['TXT_EXCEPTION_HAS_OCCURED'] . "<br />"; $msg .= $itext['TXT_EXCEPTION_FILE'] . ": " . $e->getFile() . "<br />"; $msg .= $itext['TXT_EXCEPTION_LINE'] . ": " . $e->getLine(); } if ($this->frontendMode != 'true') { sKoala()->alert(addslashes($msg)); } else { sLog()->error($msg); } return false; } } }
function calcPageDir($dataCount, $defaultSortCol, $defaultSortOrder = 'ASC') { $pageDirPage = (int) sRequest()->parameters['pagedir_page']; $pageDirPerPage = sRequest()->parameters['pagedir_perpage']; $pageDirOrderBy = sRequest()->parameters['pagedir_orderby']; $pageDirOrderDir = (int) sRequest()->parameters['pagedir_orderdir']; $pageDirFrom = (int) sRequest()->parameters['pagedir_from']; if (!$pageDirFrom) { $pageDirFrom = 1; } if ($pageDirPerPage == 'ALL') { $pageDirPerPage = -1; } else { if (!$pageDirPerPage) { $pageDirPerPage = (int) sConfig()->getVar('CONFIG/PAGEDIR/DEFAULT_PER_PAGE'); } else { $pageDirPerPage = (int) $pageDirPerPage; } } $pageDirMaxPages = 1; if (!$pageDirPage) { $pageDirPage = 1; } if ($pageDirPerPage > 0) { $pageDirMaxPages = ceil($dataCount / $pageDirPerPage); } if ($pageDirMaxPages < 1) { $pageDirMaxPages = 1; } if ($pageDirPage > $pageDirMaxPages) { $pageDirPage = $pageDirMaxPages; $pageDirFrom = $pageDirPage * $pageDirPerPage - ($pageDirPerPage - 1); } if (!$pageDirOrderBy) { $pageDirOrderBy = $defaultSortCol; } if (!$pageDirOrderDir) { $pageDirOrderDir = $defaultSortOrder; } else { if ($pageDirOrderDir == 1) { $pageDirOrderDir = "ASC"; } else { $pageDirOrderDir = "DESC"; } } if ($pageDirPerPage > 0) { $pageDirLimit = $pageDirFrom - 1 . ',' . $pageDirPerPage; } sKoala()->queueScript('$K.yg_pageDirUpdate(\'' . sRequest()->parameters['win_no'] . '\', ' . $pageDirPage . ', ' . $pageDirPerPage . ', ' . $pageDirMaxPages . ', \'' . $pageDirOrderBy . '\', \'' . $pageDirOrderDir . '\', ' . $pageDirFrom . ', \'' . $pageDirLimit . '\');'); if ($pageDirPerPage == -1) { $itext = sItext(); $pageDirPerPage = $itext['TXT_PAGEDIR_SHOWALL_SHORT'] != '' ? $itext['TXT_PAGEDIR_SHOWALL_SHORT'] : '$TXT_PAGEDIR_SHOWALL_SHORT'; } sSmarty()->assign('pageDirPage', $pageDirPage); sSmarty()->assign('pageDirPerPage', $pageDirPerPage); sSmarty()->assign('pageDirMaxPages', $pageDirMaxPages); return array('pageDirOrderBy' => $pageDirOrderBy, 'pageDirOrderDir' => $pageDirOrderDir, 'pageDirLimit' => $pageDirLimit, 'pageDirMaxPages' => $pageDirMaxPages); }