00001 <?php
00002
00009 class Article_List extends oxAdminList
00010 {
00016 protected $_sListClass = 'oxarticle';
00017
00023 protected $_sListType = 'oxarticlelist';
00024
00031 public function render()
00032 {
00033 $myConfig = $this->getConfig();
00034 $sPwrSearchFld = oxConfig::getParameter( "pwrsearchfld" );
00035 if ( !isset( $sPwrSearchFld ) ) {
00036 $sPwrSearchFld = "oxtitle";
00037 }
00038
00039 $oArticle = null;
00040 foreach ( $this->_oList as $key => $oArticle ) {
00041 $sFieldName = "oxarticles__".strtolower( $sPwrSearchFld );
00042
00043
00044 if ( !$myConfig->getConfigParam( 'blSkipFormatConversion' ) ) {
00045 if ( $oArticle->$sFieldName->fldtype == "datetime")
00046 oxDb::getInstance()->convertDBDateTime( $oArticle->$sFieldName );
00047 elseif ( $oArticle->$sFieldName->fldtype == "timestamp")
00048 oxDb::getInstance()->convertDBTimestamp( $oArticle->$sFieldName );
00049 elseif ( $oArticle->$sFieldName->fldtype == "date")
00050 oxDb::getInstance()->convertDBDate( $oArticle->$sFieldName );
00051 }
00052
00053 $oArticle->pwrsearchval = $oArticle->$sFieldName->value;
00054 $this->_oList[$key] = $oArticle;
00055 }
00056
00057
00058 parent::render();
00059
00060
00061 if ( !$oArticle ) {
00062 $oArticle = $this->_oList->getBaseObject();
00063 }
00064 $this->_aViewData["pwrsearchfields"] = $oArticle->getSearchableFields();
00065 $this->_aViewData["pwrsearchfld"] = strtoupper( $sPwrSearchFld );
00066
00067 $aWhere = array();
00068 if ( isset( $this->_aViewData["where"] ) ) {
00069 $aWhere = &$this->_aViewData["where"];
00070 $sFieldName = "oxarticles__".strtoupper( $sPwrSearchFld );
00071 if ( isset( $aWhere->$sFieldName ) )
00072 $this->_aViewData["pwrsearchinput"] = $aWhere->$sFieldName;
00073 }
00074
00075
00076 $oCatTree = oxNew( "oxCategoryList");
00077 $oCatTree->buildList( $myConfig->getConfigParam( 'bl_perfLoadCatTree' ) );
00078
00079 if ( ( $sChosenCat= oxConfig::getParameter( "art_category") ) ) {
00080 foreach ($oCatTree as $oCategory ) {
00081 if ( $oCategory->oxcategories__oxid->value == $sChosenCat ) {
00082 $oCategory->selected = 1;
00083 break;
00084 }
00085 }
00086 }
00087
00088 $this->_aViewData["cattree"] = $oCatTree;
00089 return "article_list.tpl";
00090 }
00091
00099 protected function _changeselect( $sSql )
00100 {
00101
00102 if ( ( $sChosenCat = oxConfig::getParameter( "art_category" ) ) ) {
00103 $sTable = getViewName( "oxarticles" );
00104 $sO2CView = getViewName( "oxobject2category" );
00105 $sInsert = "from $sTable left join $sO2CView on $sTable.oxid = $sO2CView.oxobjectid where $sO2CView.oxcatnid = '$sChosenCat' and ";
00106 $sSql = preg_replace( "/from\s+$sTable\s+where/i", $sInsert, $sSql);
00107 }
00108
00109 return $sSql;
00110 }
00111
00117 public function buildWhere()
00118 {
00119
00120 $this->_aWhere = parent::buildWhere();
00121 if ( !is_array( $this->_aWhere ) ) {
00122 $this->_aWhere = array();
00123 }
00124
00125
00126 $sFolder = oxConfig::getParameter( 'folder' );
00127 if ( $sFolder && $sFolder != '-1' ) {
00128 $sViewName = getViewName( 'oxarticles' );
00129 $this->_aWhere["$sViewName.oxfolder"] = $sFolder;
00130 }
00131
00132 return $this->_aWhere;
00133 }
00134
00143 protected function _prepareWhereQuery( $aWhere, $sQ )
00144 {
00145 $sQ = parent::_prepareWhereQuery( $aWhere, $sQ );
00146
00147 return $sQ . " and ".getViewName( 'oxarticles' ).".oxparentid = '' ";
00148 }
00149
00155 public function deleteEntry()
00156 {
00157 $sOxId = oxConfig::getParameter( "oxid" );
00158 $oArticle = oxNew( "oxarticle");
00159 if ( $sOxId && $oArticle->load( $sOxId ) ) {
00160 parent::deleteEntry();
00161 }
00162 }
00163
00164 }