113 if ( $this->_aCurrSorting === null ) {
116 if ( !$this->_aCurrSorting && $this->_sDefSortField && ( $oBaseObject = $this->
getItemListBaseObject() ) ) {
117 $this->_aCurrSorting[$oBaseObject->getCoreTableName()] = array( $this->_sDefSortField =>
"asc" );
131 if ( $this->_aListFilter === null ) {
145 if ( !$this->_iViewListSize ) {
148 if ( isset( $aProfile[1] ) ) {
149 $myConfig->setConfigParam(
'iAdminListSize', (
int) $aProfile[1] );
153 $this->_iViewListSize = (int)
$myConfig->getConfigParam(
'iAdminListSize' );
154 if ( !$this->_iViewListSize ) {
155 $this->_iViewListSize = 10;
156 $myConfig->setConfigParam(
'iAdminListSize', $this->_iViewListSize );
180 if ( !$this->_iViewListSize ) {
184 $this->_iViewListSize = $iViewListSize;
200 $this->_aViewData[
'mylist'] = $this->
getItemList();
215 $oDelete =
oxNew( $this->_sListClass );
221 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 );
264 $iJumpTo = $sPage?( (int) $sPage):( (int) ( (
int)
oxConfig::getParameter(
'lstrt' ) ) / $iAdminListSize );
265 $iJumpTo = ( $sPage && $iJumpTo )?( $iJumpTo - 1 ):$iJumpTo;
267 $iJumpTo = $iJumpTo * $iAdminListSize;
268 if ( $iJumpTo < 1 ) {
270 } elseif ( $iJumpTo >= $this->_iListSize ) {
271 $iJumpTo = floor( $this->_iListSize / $iAdminListSize - 1 ) * $iAdminListSize;
274 $this->_iCurrListPos = $this->_iOverPos = (int) $iJumpTo;
289 if ( is_array( $aSortFields ) && count( $aSortFields ) ) {
292 $sSql .=
' order by ';
296 $iLangId = $oListItem->isMultilang() ? $oListItem->getLanguage() :
oxRegistry::getLang()->getBaseLanguage();
299 $blSortDesc = $blSortDesc !== null ? (bool) $blSortDesc : $this->_blDesc;
301 foreach ( $aSortFields as $sTable => $aFieldData ) {
303 $sTable = $sTable ? ( getViewName( $sTable, $iLangId ) .
'.' ) :
'';
304 foreach ( $aFieldData as $sColumn => $sSortDir ) {
306 $sField = $sTable . $sColumn;
309 $sSql .= ( ( ( $blSep ) ?
', ' :
'' ) ) .
oxDb::getInstance()->escapeString( $sField );
312 if ( $blSortDesc || $sColumn ==
"oxactive" || strcasecmp( $sSortDir,
'desc' ) == 0 ) {
333 return $oListObject !== null ? $oListObject->buildSelectString( null ) :
"";
351 $sFieldValue = $oStr->preg_replace(
"/^%|%$/",
"", trim( $sFieldValue ) );
352 return $oStr->preg_replace(
"/\s+/",
" ", $sFieldValue );
365 if ( $blIsSearchValue ) {
367 $sQ =
" like ".oxDb::getDb()->quote(
'%'.$sVal.
'%' ).
" ";
370 $sQ =
" = ".oxDb::getDb()->quote( $sVal ).
" ";
386 $blIsSearchValue =
false;
388 if ( $oStr->preg_match(
'/^%/', $sFieldValue ) && $oStr->preg_match(
'/%$/', $sFieldValue ) ) {
389 $blIsSearchValue =
true;
393 return $blIsSearchValue;
408 if ( count($aWhere) ) {
410 while ( list($sFieldName, $sFieldValue) = each( $aWhere ) ) {
411 $sFieldValue = trim( $sFieldValue );
419 if ( strlen($sFieldValue) ) {
420 $aVal = explode(
' ', $sFieldValue );
423 $sSqlBoolAction =
' and (';
425 foreach ( $aVal as $sVal) {
428 $sUml = $myUtilsString->prepareStrForSearch( $sVal );
430 $sSqlBoolAction .=
'(';
434 $sqlFull .=
" {$sSqlBoolAction} {$sFieldName} ";
437 $sSqlBoolAction =
' and ';
439 $sqlFull .= $this->
_buildFilter( $sVal, $blIsSearchValue );
442 $sqlFull .=
" or {$sFieldName} ";
444 $sqlFull .= $this->
_buildFilter( $sUml, $blIsSearchValue );
478 if ( $this->_aWhere === null && ( $oList = $this->
getItemList() ) ) {
480 $this->_aWhere = array();
482 if ( is_array( $aFilter ) ) {
485 $iLangId = $oListItem->isMultilang() ? $oListItem->getLanguage() :
oxRegistry::getLang()->getBaseLanguage();
486 $sLocalDateFormat = $this->
getConfig()->getConfigParam(
'sLocalDateFormat' );
488 foreach ( $aFilter as $sTable => $aFilterData ) {
489 foreach ( $aFilterData as $sName => $sValue ) {
490 if ( $sValue ||
'0' === (
string ) $sValue ) {
492 $sField =
"{$sTable}__{$sName}";
495 $sName = $sTable ? getViewName( $sTable, $iLangId ) .
".{$sName}" : $sName;
498 if ( $sLocalDateFormat && $sLocalDateFormat !=
'ISO' && isset( $oListItem->$sField ) ) {
499 $sFldType = $oListItem->{$sField}->fldtype;
500 if (
"datetime" == $sFldType ||
"date" == $sFldType ) {
505 $this->_aWhere[$sName] =
"%{$sValue}%";
523 protected function _convertToDBDate( $sValue, $sFldType )
526 $oConvObject->setValue($sValue);
527 if ( $sFldType ==
"datetime" ) {
528 if ( strlen($sValue) == 10 || strlen($sValue) == 22 || ( strlen($sValue) == 19 && !stripos( $sValue,
"m" ) ) ) {
529 oxRegistry::get(
"oxUtilsDate")->convertDBDateTime( $oConvObject,
true );
531 if ( strlen($sValue) > 10 ) {
532 return $this->_convertTime( $sValue );
534 return $this->_convertDate( $sValue );
537 } elseif ( $sFldType ==
"date" ) {
538 if ( strlen($sValue) == 10 ) {
541 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];
603 if ( $iIntVal < 13) {
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];
612 if ( $iIntVal < 13) {
613 $sTime = ($iIntVal + 12);
616 $sTime = $aTimeMatches[1];
619 $sTime = str_replace(
".",
":", $sTime);
622 return $oConvObject->value .
" " . $sTime;
630 protected function _setListNavigationParams()
635 $blShowNavigation =
false;
636 $iAdminListSize = $this->_getViewListSize();
637 if ( $this->_iListSize > $iAdminListSize ) {
639 $pageNavigation =
new stdClass();
640 $pageNavigation->pages = round( ( ( $this->_iListSize - 1 ) / $iAdminListSize ) + 0.5, 0 );
641 $pageNavigation->actpage = ($pageNavigation->actpage > $pageNavigation->pages)? $pageNavigation->pages : round( ( $this->_iCurrListPos / $iAdminListSize ) + 0.5, 0 );
642 $pageNavigation->lastlink = ( $pageNavigation->pages - 1 ) * $iAdminListSize;
643 $pageNavigation->nextlink = null;
644 $pageNavigation->backlink = null;
646 $iPos = $this->_iCurrListPos + $iAdminListSize;
647 if ( $iPos < $this->_iListSize ) {
648 $pageNavigation->nextlink = $iPos = $this->_iCurrListPos + $iAdminListSize;
651 if ( ( $this->_iCurrListPos - $iAdminListSize ) >= 0 ) {
652 $pageNavigation->backlink = $iPos = $this->_iCurrListPos - $iAdminListSize;
656 $iStart = $pageNavigation->actpage - 5;
657 $iStart = ( $iStart <= 0 ) ? 1 : $iStart;
660 $iEnd = $pageNavigation->actpage + 5;
661 $iEnd = ( $iEnd < $iStart + 10) ? $iStart + 10 : $iEnd;
662 $iEnd = ( $iEnd > $pageNavigation->pages ) ? $pageNavigation->pages : $iEnd;
665 $iStart = ( $iEnd - 10 > 0 ) ? $iEnd - 10 : $iStart;
666 $iStart = ( $pageNavigation->pages <= 11) ? 1 : $iStart;
669 for ( $i = $iStart; $i <= $iEnd; $i++ ) {
670 $page =
new stdclass();
672 if ( $i == $pageNavigation->actpage ) {
675 $pageNavigation->changePage[$i] = $page;
678 $this->_aViewData[
'pagenavi'] = $pageNavigation;
680 if ( isset( $this->_iOverPos)) {
681 $iPos = $this->_iOverPos;
682 $this->_iOverPos = null;
691 $this->_aViewData[
'lstrt'] = $iPos;
692 $this->_aViewData[
'listsize'] = $this->_iListSize;
693 $blShowNavigation =
true;
697 $iShowListSize = $this->_iListSize - $this->_iCurrListPos;
698 $iAdminListSize = $this->_getViewListSize();
699 $iNotUsed = $iAdminListSize - min( $iShowListSize, $iAdminListSize );
700 $iSpace = $iNotUsed * 15;
702 if ( !$blShowNavigation ) {
706 $this->_aViewData[
'iListFillsize'] = $iSpace;
716 protected function _setupNavigation( $sNode )
721 $myAdminNavigation = $this->getNavigation();
723 $sOxId = $this->getEditObjectId();
727 $iActTab = $this->_iDefEdit;
731 $iActTab = $iActTab ? $iActTab : $this->_iDefEdit;
735 $this->_aViewData[
'editnavi'] = $myAdminNavigation->getTabs( $sNode, $iActTab );
738 $this->_aViewData[
'actlocation'] = $myAdminNavigation->getActiveTab( $sNode, $iActTab );
741 $this->_aViewData[
'default_edit'] = $myAdminNavigation->getActiveTab( $sNode, $this->_iDefEdit );
744 $this->_aViewData[
'actedit'] = $iActTab;
753 public function getItemList()
755 if ( $this->_oList === null && $this->_sListClass ) {
757 $this->_oList =
oxNew( $this->_sListType );
758 $this->_oList->clear();
759 $this->_oList->init( $this->_sListClass );
761 $aWhere = $this->buildWhere();
763 $oListObject = $this->_oList->getBaseObject();
766 $this->_aViewData[
'listTable'] = getViewName( $oListObject->getCoreTableName() );
767 $this->getConfig()->setGlobalParameter(
'ListCoreTable', $oListObject->getCoreTableName() );
769 if ( $oListObject->isMultilang() ) {
773 if ( isset( $this->_blEmployMultilanguage ) ) {
774 $oListObject->setEnableMultilang( $this->_blEmployMultilanguage );
778 $sSql = $this->_buildSelectString( $oListObject );
779 $sSql = $this->_prepareWhereQuery( $aWhere, $sSql );
780 $sSql = $this->_prepareOrderByQuery( $sSql );
781 $sSql = $this->_changeselect( $sSql );
784 $this->_calcListItemsCount( $sSql );
790 $this->_oList->setSqlLimit( $this->_iCurrListPos, $this->_getViewListSize() );
792 $this->_oList->selectString( $sSql );
795 return $this->_oList;
803 public function clearItemList()
805 $this->_oList = null;
813 public function getItemListBaseObject()
815 if ( ( $oList = $this->getItemList() ) ) {
816 return $oList->getBaseObject();