Go to the documentation of this file.00001 <?php
00002
00009 class Article_Pictures extends oxAdminDetails
00010 {
00017 public function render()
00018 {
00019 parent::render();
00020
00021 $this->_aViewData["edit"] = $oArticle = oxNew( "oxarticle");
00022
00023 $soxId = $this->getEditObjectId();
00024 if ( $soxId != "-1" && isset( $soxId ) ) {
00025
00026 $oArticle->load( $soxId);
00027
00028
00029
00030 if ( $oArticle->oxarticles__oxparentid->value) {
00031 $oParentArticle = oxNew( "oxarticle");
00032 $oParentArticle->load( $oArticle->oxarticles__oxparentid->value);
00033 $this->_aViewData["parentarticle"] = $oParentArticle;
00034 $this->_aViewData["oxparentid"] = $oArticle->oxarticles__oxparentid->value;
00035 }
00036 }
00037
00038 $this->_aViewData["iPicCount"] = $this->getConfig()->getConfigParam( 'iPicCount' );
00039
00040 return "article_pictures.tpl";
00041 }
00042
00048 public function save()
00049 {
00050 $myConfig = $this->getConfig();
00051
00052 if ( $myConfig->isDemoShop() ) {
00053
00054 $oEx = oxNew( "oxExceptionToDisplay" );
00055 $oEx->setMessage( 'ARTICLE_PICTURES_UPLOADISDISABLED' );
00056 oxRegistry::get("oxUtilsView")->addErrorToDisplay( $oEx, false );
00057
00058 return;
00059 }
00060
00061 parent::save();
00062
00063 $oArticle = oxNew( "oxarticle");
00064 if ( $oArticle->load( $this->getEditObjectId() ) ) {
00065 $oArticle->assign( oxConfig::getParameter( "editval") );
00066 oxRegistry::get("oxUtilsFile")->processFiles( $oArticle );
00067
00068
00069 if ( oxRegistry::get("oxUtilsFile")->getNewFilesCounter() == 0 ) {
00070 $oEx = oxNew( "oxExceptionToDisplay" );
00071 $oEx->setMessage( 'NO_PICTURES_CHANGES' );
00072 oxRegistry::get("oxUtilsView")->addErrorToDisplay( $oEx, false );
00073 }
00074
00075 $oArticle->save();
00076 }
00077 }
00078
00086 public function deletePicture()
00087 {
00088 $myConfig = $this->getConfig();
00089
00090 if ( $myConfig->isDemoShop() ) {
00091
00092 $oEx = oxNew( "oxExceptionToDisplay" );
00093 $oEx->setMessage( 'ARTICLE_PICTURES_UPLOADISDISABLED' );
00094 oxRegistry::get("oxUtilsView")->addErrorToDisplay( $oEx, false );
00095
00096 return;
00097 }
00098
00099 $sOxId = $this->getEditObjectId();
00100 $iIndex = oxConfig::getParameter( "masterPicIndex" );
00101
00102 $oArticle = oxNew( "oxarticle" );
00103 $oArticle->load( $sOxId );
00104
00105 if ( $iIndex == "ICO" ) {
00106
00107 $this->_deleteMainIcon( $oArticle );
00108 } elseif ( $iIndex == "TH" ) {
00109
00110 $this->_deleteThumbnail( $oArticle );
00111 } else {
00112 $iIndex = (int) $iIndex;
00113 if ( $iIndex > 0 ) {
00114
00115 $this->_resetMasterPicture( $oArticle, $iIndex, true );
00116 $oArticle->oxarticles__oxpicsgenerated = new oxField( 0 );
00117 }
00118 }
00119
00120 $oArticle->save();
00121 }
00122
00133 protected function _resetMasterPicture( $oArticle, $iIndex, $blDeleteMaster = false )
00134 {
00135 if ( $oArticle->{"oxarticles__oxpic".$iIndex}->value ) {
00136
00137 if ( !$oArticle->isDerived() ) {
00138 $oPicHandler = oxRegistry::get("oxPictureHandler");
00139 $oPicHandler->deleteArticleMasterPicture( $oArticle, $iIndex, $blDeleteMaster );
00140 }
00141
00142 if ( $blDeleteMaster ) {
00143
00144 $oArticle->{"oxarticles__oxpic".$iIndex} = new oxField();
00145 }
00146
00147
00148 if ( isset( $oArticle->{"oxarticles__oxzoom".$iIndex} ) ) {
00149 $oArticle->{"oxarticles__oxzoom".$iIndex} = new oxField();
00150 }
00151
00152 if ( $iIndex == 1 ) {
00153 $this->_cleanupCustomFields( $oArticle );
00154 }
00155 }
00156 }
00157
00165 protected function _deleteMainIcon( $oArticle )
00166 {
00167 if ( $oArticle->oxarticles__oxicon->value ) {
00168
00169 if ( !$oArticle->isDerived() ) {
00170 $oPicHandler = oxRegistry::get("oxPictureHandler");
00171 $oPicHandler->deleteMainIcon( $oArticle );
00172 }
00173
00174
00175 $oArticle->oxarticles__oxicon = new oxField();
00176 }
00177 }
00178
00186 protected function _deleteThumbnail( $oArticle )
00187 {
00188 if ( $oArticle->oxarticles__oxthumb->value ) {
00189
00190 if ( !$oArticle->isDerived() ) {
00191 $oPicHandler = oxRegistry::get("oxPictureHandler");
00192 $oPicHandler->deleteThumbnail( $oArticle );
00193 }
00194
00195
00196 $oArticle->oxarticles__oxthumb = new oxField();
00197 }
00198 }
00199
00208 protected function _cleanupCustomFields( $oArticle )
00209 {
00210 $myConfig = $this->getConfig();
00211
00212 $sIcon = $oArticle->oxarticles__oxicon->value;
00213 $sThumb = $oArticle->oxarticles__oxthumb->value;
00214
00215 if ( $sIcon == "nopic.jpg" ) {
00216 $oArticle->oxarticles__oxicon = new oxField();
00217 }
00218
00219 if ( $sThumb == "nopic.jpg" ) {
00220 $oArticle->oxarticles__oxthumb = new oxField();
00221 }
00222 }
00223 }