114         if ($this->_aCurrSorting === null) {
 
  117             if (!$this->_aCurrSorting && $this->_sDefSortField && ($oBaseObject = $this->
getItemListBaseObject())) {
 
  118                 $this->_aCurrSorting[$oBaseObject->getCoreTableName()] = array($this->_sDefSortField => 
"asc");
 
  132         if ($this->_aListFilter === null) {
 
  146         if (!$this->_iViewListSize) {
 
  149                 if (isset($aProfile[1])) {
 
  150                     $myConfig->setConfigParam(
'iAdminListSize', (
int) $aProfile[1]);
 
  154             $this->_iViewListSize = (int) 
$myConfig->getConfigParam(
'iAdminListSize');
 
  155             if (!$this->_iViewListSize) {
 
  156                 $this->_iViewListSize = 10;
 
  157                 $myConfig->setConfigParam(
'iAdminListSize', $this->_iViewListSize);
 
  181         if (!$this->_iViewListSize) {
 
  185             $this->_iViewListSize = $iViewListSize;
 
  201         $this->_aViewData[
'mylist'] = $this->
getItemList();
 
  216         $oDelete = 
oxNew($this->_sListClass);
 
  222         if ($blDelete && isset($_POST[
'oxid'])) {
 
  241         $sSql = $oStr->preg_replace(
'/select .* from/i', 
'select count(*) from ', $sSql);
 
  244         $sSql = $oStr->preg_replace(
'/order by .*$/i', 
'', $sSql);
 
  247         $this->_iListSize = 
oxDb::getDb()->getOne($sSql, 
false, 
false);
 
  262         $iJumpTo = $sPage ? ((int) $sPage) : ((int) ((
int) 
oxRegistry::getConfig()->getRequestParameter(
'lstrt')) / $iAdminListSize);
 
  263         $iJumpTo = ($sPage && $iJumpTo) ? ($iJumpTo - 1) : $iJumpTo;
 
  265         $iJumpTo = $iJumpTo * $iAdminListSize;
 
  268         } elseif ($iJumpTo >= $this->_iListSize) {
 
  269             $iJumpTo = floor($this->_iListSize / $iAdminListSize - 1) * $iAdminListSize;
 
  272         $this->_iCurrListPos = $this->_iOverPos = (int) $iJumpTo;
 
  287         if (is_array($aSortFields) && count($aSortFields)) {
 
  290             $sSql .= 
' order by ';
 
  294             $iLangId = $oListItem->isMultilang() ? $oListItem->getLanguage() : 
oxRegistry::getLang()->getBaseLanguage();
 
  297             $blSortDesc = $blSortDesc !== null ? (bool) $blSortDesc : $this->_blDesc;
 
  299             foreach ($aSortFields as $sTable => $aFieldData) {
 
  301                 $sTable = $sTable ? (getViewName($sTable, $iLangId) . 
'.') : 
'';
 
  302                 foreach ($aFieldData as $sColumn => $sSortDir) {
 
  304                     $sField = $sTable . $sColumn;
 
  310                     if ($blSortDesc || $sColumn == 
"oxactive" || strcasecmp($sSortDir, 
'desc') == 0) {
 
  331         return $oListObject !== null ? $oListObject->buildSelectString(null) : 
"";
 
  349         $sFieldValue = $oStr->preg_replace(
"/^%|%$/", 
"", trim($sFieldValue));
 
  351         return $oStr->preg_replace(
"/\s+/", 
" ", $sFieldValue);
 
  364         if ($blIsSearchValue) {
 
  366             $sQ = 
" like " . 
oxDb::getDb()->quote(
'%' . $sVal . 
'%') . 
" ";
 
  385         $blIsSearchValue = 
false;
 
  387         if ($oStr->preg_match(
'/^%/', $sFieldValue) && $oStr->preg_match(
'/%$/', $sFieldValue)) {
 
  388             $blIsSearchValue = 
true;
 
  392         return $blIsSearchValue;
 
  407         if (count($aWhere)) {
 
  409             while (list($sFieldName, $sFieldValue) = each($aWhere)) {
 
  410                 $sFieldValue = trim($sFieldValue);
 
  418                 if (strlen($sFieldValue)) {
 
  419                     $aVal = explode(
' ', $sFieldValue);
 
  422                     $sSqlBoolAction = 
' and (';
 
  424                     foreach ($aVal as $sVal) {
 
  427                         $sUml = $myUtilsString->prepareStrForSearch($sVal);
 
  429                             $sSqlBoolAction .= 
'(';
 
  433                         $sqlFull .= 
" {$sSqlBoolAction} {$sFieldName} ";
 
  436                         $sSqlBoolAction = 
' and ';
 
  438                         $sqlFull .= $this->
_buildFilter($sVal, $blIsSearchValue);
 
  441                             $sqlFull .= 
" or {$sFieldName} ";
 
  443                             $sqlFull .= $this->
_buildFilter($sUml, $blIsSearchValue);
 
  477         if ($this->_aWhere === null && ($oList = $this->
getItemList())) {
 
  479             $this->_aWhere = array();
 
  481             if (is_array($aFilter)) {
 
  484                 $iLangId = $oListItem->isMultilang() ? $oListItem->getLanguage() : 
oxRegistry::getLang()->getBaseLanguage();
 
  485                 $sLocalDateFormat = $this->
getConfig()->getConfigParam(
'sLocalDateFormat');
 
  487                 foreach ($aFilter as $sTable => $aFilterData) {
 
  488                     foreach ($aFilterData as $sName => $sValue) {
 
  489                         if ($sValue || 
'0' === ( 
string ) $sValue) {
 
  491                             $sField = 
"{$sTable}__{$sName}";
 
  494                             $sName = $sTable ? getViewName($sTable, $iLangId) . 
".{$sName}" : $sName;
 
  497                             if ($sLocalDateFormat && $sLocalDateFormat != 
'ISO' && isset($oListItem->$sField)) {
 
  498                                 $sFldType = $oListItem->{$sField}->fldtype;
 
  499                                 if (
"datetime" == $sFldType || 
"date" == $sFldType) {
 
  504                             $this->_aWhere[$sName] = 
"%{$sValue}%";
 
  522     protected function _convertToDBDate($sValue, $sFldType)
 
  525         $oConvObject->setValue($sValue);
 
  526         if ($sFldType == 
"datetime") {
 
  527             if (strlen($sValue) == 10 || strlen($sValue) == 22 || (strlen($sValue) == 19 && !stripos($sValue, 
"m"))) {
 
  530                 if (strlen($sValue) > 10) {
 
  531                     return $this->_convertTime($sValue);
 
  533                     return $this->_convertDate($sValue);
 
  536         } elseif ($sFldType == 
"date") {
 
  537             if (strlen($sValue) == 10) {
 
  540                 return $this->_convertDate($sValue);
 
  544         return $oConvObject->value;
 
  554     protected function _convertDate($sDate)
 
  557         $aDatePatterns = array(
"/^([0-9]{2})\.([0-9]{4})/" => 
"EUR2", 
 
  558                                "/^([0-9]{2})\.([0-9]{2})/" => 
"EUR1", 
 
  559                                "/^([0-9]{2})\/([0-9]{4})/" => 
"USA2", 
 
  560                                "/^([0-9]{2})\/([0-9]{2})/" => 
"USA1"  
  564         $aDFormats = array(
"EUR1" => array(2, 1),
 
  565                            "EUR2" => array(2, 1),
 
  566                            "USA1" => array(1, 2),
 
  567                            "USA2" => array(2, 1)
 
  571         $aDateMatches = array();
 
  573         foreach ($aDatePatterns as $sPattern => $sType) {
 
  574             if ($oStr->preg_match($sPattern, $sDate, $aDateMatches)) {
 
  575                 $sDate = $aDateMatches[$aDFormats[$sType][0]] . 
"-" . $aDateMatches[$aDFormats[$sType][1]];
 
  590     protected function _convertTime($sFullDate)
 
  592         $sDate = substr($sFullDate, 0, 10);
 
  594         $oConvObject->setValue($sDate);
 
  599         $sTime = substr($sFullDate, 11);
 
  600         if ($oStr->preg_match(
"/([0-9]{2}):([0-9]{2}) ([AP]{1}[M]{1})$/", $sTime, $aTimeMatches)) {
 
  601             if ($aTimeMatches[3] == 
"PM") {
 
  602                 $iIntVal = (int) $aTimeMatches[1];
 
  604                     $sTime = ($iIntVal + 12) . 
":" . $aTimeMatches[2];
 
  607                 $sTime = $aTimeMatches[1] . 
":" . $aTimeMatches[2];
 
  609         } elseif ($oStr->preg_match(
"/([0-9]{2}) ([AP]{1}[M]{1})$/", $sTime, $aTimeMatches)) {
 
  610             if ($aTimeMatches[2] == 
"PM") {
 
  611                 $iIntVal = (int) $aTimeMatches[1];
 
  613                     $sTime = ($iIntVal + 12);
 
  616                 $sTime = $aTimeMatches[1];
 
  619             $sTime = str_replace(
".", 
":", $sTime);
 
  622         return $oConvObject->value . 
" " . $sTime;
 
  628     protected function _setListNavigationParams()
 
  633         $blShowNavigation = 
false;
 
  634         $iAdminListSize = $this->_getViewListSize();
 
  635         if ($this->_iListSize > $iAdminListSize) {
 
  637             $pageNavigation = 
new stdClass();
 
  638             $pageNavigation->pages = round((($this->_iListSize - 1) / $iAdminListSize) + 0.5, 0);
 
  639             $pageNavigation->actpage = ($pageNavigation->actpage > $pageNavigation->pages) ? $pageNavigation->pages : round(($this->_iCurrListPos / $iAdminListSize) + 0.5, 0);
 
  640             $pageNavigation->lastlink = ($pageNavigation->pages - 1) * $iAdminListSize;
 
  641             $pageNavigation->nextlink = null;
 
  642             $pageNavigation->backlink = null;
 
  644             $iPos = $this->_iCurrListPos + $iAdminListSize;
 
  645             if ($iPos < $this->_iListSize) {
 
  646                 $pageNavigation->nextlink = $iPos = $this->_iCurrListPos + $iAdminListSize;
 
  649             if (($this->_iCurrListPos - $iAdminListSize) >= 0) {
 
  650                 $pageNavigation->backlink = $iPos = $this->_iCurrListPos - $iAdminListSize;
 
  654             $iStart = $pageNavigation->actpage - 5;
 
  655             $iStart = ($iStart <= 0) ? 1 : $iStart;
 
  658             $iEnd = $pageNavigation->actpage + 5;
 
  659             $iEnd = ($iEnd < $iStart + 10) ? $iStart + 10 : $iEnd;
 
  660             $iEnd = ($iEnd > $pageNavigation->pages) ? $pageNavigation->pages : $iEnd;
 
  663             $iStart = ($iEnd - 10 > 0) ? $iEnd - 10 : $iStart;
 
  664             $iStart = ($pageNavigation->pages <= 11) ? 1 : $iStart;
 
  667             for ($i = $iStart; $i <= $iEnd; $i++) {
 
  668                 $page = 
new stdclass();
 
  670                 if ($i == $pageNavigation->actpage) {
 
  673                 $pageNavigation->changePage[$i] = $page;
 
  676             $this->_aViewData[
'pagenavi'] = $pageNavigation;
 
  678             if (isset($this->_iOverPos)) {
 
  679                 $iPos = $this->_iOverPos;
 
  680                 $this->_iOverPos = null;
 
  689             $this->_aViewData[
'lstrt'] = $iPos;
 
  690             $this->_aViewData[
'listsize'] = $this->_iListSize;
 
  691             $blShowNavigation = 
true;
 
  695         $iShowListSize = $this->_iListSize - $this->_iCurrListPos;
 
  696         $iAdminListSize = $this->_getViewListSize();
 
  697         $iNotUsed = $iAdminListSize - min($iShowListSize, $iAdminListSize);
 
  698         $iSpace = $iNotUsed * 15;
 
  700         if (!$blShowNavigation) {
 
  704         $this->_aViewData[
'iListFillsize'] = $iSpace;
 
  712     protected function _setupNavigation($sNode)
 
  717             $myAdminNavigation = $this->getNavigation();
 
  719             $sOxId = $this->getEditObjectId();
 
  723                 $iActTab = $this->_iDefEdit;
 
  727                 $iActTab = $iActTab ? $iActTab : $this->_iDefEdit;
 
  731             $this->_aViewData[
'editnavi'] = $myAdminNavigation->getTabs($sNode, $iActTab);
 
  734             $this->_aViewData[
'actlocation'] = $myAdminNavigation->getActiveTab($sNode, $iActTab);
 
  737             $this->_aViewData[
'default_edit'] = $myAdminNavigation->getActiveTab($sNode, $this->_iDefEdit);
 
  740             $this->_aViewData[
'actedit'] = $iActTab;
 
  749     public function getItemList()
 
  751         if ($this->_oList === null && $this->_sListClass) {
 
  753             $this->_oList = 
oxNew($this->_sListType);
 
  754             $this->_oList->clear();
 
  755             $this->_oList->init($this->_sListClass);
 
  757             $aWhere = $this->buildWhere();
 
  759             $oListObject = $this->_oList->getBaseObject();
 
  762             $this->_aViewData[
'listTable'] = getViewName($oListObject->getCoreTableName());
 
  763             $this->getConfig()->setGlobalParameter(
'ListCoreTable', $oListObject->getCoreTableName());
 
  765             if ($oListObject->isMultilang()) {
 
  769                 if (isset($this->_blEmployMultilanguage)) {
 
  770                     $oListObject->setEnableMultilang($this->_blEmployMultilanguage);
 
  774             $sSql = $this->_buildSelectString($oListObject);
 
  775             $sSql = $this->_prepareWhereQuery($aWhere, $sSql);
 
  776             $sSql = $this->_prepareOrderByQuery($sSql);
 
  777             $sSql = $this->_changeselect($sSql);
 
  780             $this->_calcListItemsCount($sSql);
 
  786             $this->_oList->setSqlLimit($this->_iCurrListPos, $this->_getViewListSize());
 
  788             $this->_oList->selectString($sSql);
 
  791         return $this->_oList;
 
  797     public function clearItemList()
 
  799         $this->_oList = null;
 
  807     public function getItemListBaseObject()
 
  809         if (($oList = $this->getItemList())) {
 
  810             return $oList->getBaseObject();