00001 <?php
00002
00010 class Article_List extends oxAdminList
00011 {
00017 protected $_sListClass = 'oxarticle';
00018
00024 protected $_sListType = 'oxarticlelist';
00025
00032 public function init()
00033 {
00034
00035 $soxId = oxConfig::getParameter( "oxid");
00036 if ($soxId && $soxId != -1) {
00037 $oArticle = oxNew( "oxarticle");
00038 $oArticle->load( $soxId);
00039 $oArticle->getAdminVariants();
00040 }
00041
00042 parent::init();
00043 }
00044
00051 public function render()
00052 {
00053 $myConfig = $this->getConfig();
00054 $sPwrSearchFld = oxConfig::getParameter( "pwrsearchfld");
00055 if( !isset( $sPwrSearchFld))
00056 $sPwrSearchFld = "oxtitle";
00057
00058 foreach ( $this->_oList as $key => $oArticle) {
00059 $sFieldName = "oxarticles__".strtolower($sPwrSearchFld);
00060
00061
00062 if ( !$myConfig->getConfigParam( 'blSkipFormatConversion' ) ) {
00063 if ( $oArticle->$sFieldName->fldtype == "datetime")
00064 oxDb::getInstance()->convertDBDateTime( $oArticle->$sFieldName );
00065 elseif ( $oArticle->$sFieldName->fldtype == "timestamp")
00066 oxDb::getInstance()->convertDBTimestamp( $oArticle->$sFieldName );
00067 elseif ( $oArticle->$sFieldName->fldtype == "date")
00068 oxDb::getInstance()->convertDBDate( $oArticle->$sFieldName );
00069 }
00070
00071 $oArticle->pwrsearchval = $oArticle->$sFieldName->value;
00072 $this->_oList[$key] = $oArticle;
00073 }
00074
00075
00076 parent::render();
00077
00078
00079 $oArticle = oxNew("oxarticle");
00080 $this->_aViewData["pwrsearchfields"] = $oArticle->getSearchableFields();
00081 $this->_aViewData["pwrsearchfld"] = strtoupper($sPwrSearchFld);
00082
00083 if ( isset( $this->_aViewData["where"])) {
00084 $aWhere = &$this->_aViewData["where"];
00085 $sFieldName = "oxarticles__".strtoupper($sPwrSearchFld);
00086 if ( isset( $aWhere->$sFieldName))
00087 $this->_aViewData["pwrsearchinput"] = $aWhere->$sFieldName;
00088 }
00089
00090
00091 $oCatTree = oxNew( "oxCategoryList");
00092 $oCatTree->buildList($myConfig->getConfigParam( 'bl_perfLoadCatTree' ));
00093
00094 $sChosenCat = oxConfig::getParameter( "art_category");
00095 if ( isset( $aWhere ) && $aWhere ) {
00096 foreach ($oCatTree as $oCategory ) {
00097 if ( $oCategory->oxcategories__oxid->value == $sChosenCat ) {
00098 $oCategory->selected = 1;
00099 }
00100 }
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 }
00112 $this->_aViewData["cattree"] = $oCatTree;
00113
00114 return "article_list.tpl";
00115 }
00116
00124 protected function _changeselect( $sSql )
00125 {
00126
00127 $sChosenCat = oxConfig::getParameter( "art_category");
00128 if ( $sChosenCat ) {
00129 $sTable = getViewName("oxarticles");
00130 $sO2CView = getViewName("oxobject2category");
00131 $sInsert = "from $sTable left join $sO2CView on $sTable.oxid = $sO2CView.oxobjectid where $sO2CView.oxcatnid = '$sChosenCat' and ";
00132
00133 $sSql = preg_replace( "/from\s+$sTable\s+where/i", $sInsert, $sSql);
00134 }
00135
00136 return $sSql;
00137 }
00138
00144 public function buildWhere()
00145 {
00146
00147 $sViewName = getViewName( 'oxarticles' );
00148 $this->_aWhere = parent::buildWhere();
00149 if ( !is_array($this->_aWhere))
00150 $this->_aWhere = array();
00151
00152 $sFolder = oxConfig::getParameter( 'folder' );
00153 if ( $sFolder && $sFolder != '-1' ) {
00154 $this->_aWhere["$sViewName.oxfolder"] = $sFolder;
00155 }
00156 return $this->_aWhere;
00157 }
00158
00167 protected function _prepareWhereQuery( $aWhere, $sqlFull )
00168 {
00169 $sQ = parent::_prepareWhereQuery( $aWhere, $sqlFull );
00170 $sViewName = getViewName( 'oxarticles' );
00171
00172 $sQ .= " and $sViewName.oxparentid = ''";
00173 return $sQ;
00174 }
00175
00181 public function deleteEntry()
00182 {
00183 $oArticle = oxNew( "oxarticle");
00184 if ( $oArticle->load( oxConfig::getParameter( "oxid") ) ) {
00185 parent::deleteEntry();
00186 }
00187 }
00188
00189 }