actions_main.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class Actions_Main extends oxAdminDetails
00010 {
00017     public function render()
00018     {
00019         parent::render();
00020 
00021         // check if we right now saved a new entry
00022         $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00023         if ( $soxId != "-1" && isset( $soxId)) {
00024             // load object
00025             $oAction = oxNew( "oxactions" );
00026             $oAction->loadInLang( $this->_iEditLang, $soxId);
00027 
00028             $oOtherLang = $oAction->getAvailableInLangs();
00029             if (!isset($oOtherLang[$this->_iEditLang])) {
00030                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00031                 $oAction->loadInLang( key($oOtherLang), $soxId );
00032             }
00033 
00034             $this->_aViewData["edit"] =  $oAction;
00035 
00036             // remove already created languages
00037             $aLang = array_diff ( oxLang::getInstance()->getLanguageNames(), $oOtherLang );
00038 
00039             if ( count( $aLang))
00040                 $this->_aViewData["posslang"] = $aLang;
00041 
00042             foreach ( $oOtherLang as $id => $language) {
00043                 $oLang= new oxStdClass();
00044                 $oLang->sLangDesc = $language;
00045                 $oLang->selected = ($id == $this->_iEditLang);
00046                 $this->_aViewData["otherlang"][$id] = clone $oLang;
00047             }
00048         }
00049         $aColumns = array();
00050 
00051         if ( oxConfig::getParameter("aoc") ) {
00052             // generating category tree for select list
00053             $sChosenArtCat = oxConfig::getParameter( "artcat");
00054             $sChosenArtCat = $this->_getCategoryTree( "artcattree", $sChosenArtCat, $soxId);
00055 
00056             include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00057             $this->_aViewData['oxajax'] = $aColumns;
00058 
00059             return "popups/actions_main.tpl";
00060         }
00061 
00062 
00063         if ( ( $oPromotion = $this->getViewDataElement( "edit" ) ) ) {
00064             if ( ($oPromotion->oxactions__oxtype->value == 2) || ($oPromotion->oxactions__oxtype->value == 3) ) {
00065                 if ( $iAoc = oxConfig::getParameter( "oxpromotionaoc" ) ) {
00066                     $sPopup = false;
00067                     switch( $iAoc ) {
00068                         case 'article':
00069                             // generating category tree for select list
00070                             $sChosenArtCat = oxConfig::getParameter( "artcat");
00071                             $sChosenArtCat = $this->_getCategoryTree( "artcattree", $sChosenArtCat, $soxId);
00072 
00073                             if ($oArticle = $oPromotion->getBannerArticle()) {
00074                                 $this->_aViewData['actionarticle_artnum'] = $oArticle->oxarticles__oxartnum->value;
00075                                 $this->_aViewData['actionarticle_title']  = $oArticle->oxarticles__oxtitle->value;
00076                             }
00077 
00078                             $sPopup = 'actions_article';
00079                             break;
00080                         case 'groups':
00081                             $sPopup = 'actions_groups';
00082                             break;
00083                     }
00084 
00085                     if ( $sPopup ) {
00086                         $aColumns = array();
00087                         include_once "inc/{$sPopup}.inc.php";
00088                         $this->_aViewData['oxajax'] = $aColumns;
00089                         return "popups/{$sPopup}.tpl";
00090                     }
00091                 } else {
00092                     if ( $oPromotion->oxactions__oxtype->value == 2) {
00093                         $this->_aViewData["editor"] = $this->_generateTextEditor( "100%", 300, $oPromotion, "oxactions__oxlongdesc", "details.tpl.css" );
00094                     }
00095                 }
00096             }
00097         }
00098 
00099         return "actions_main.tpl";
00100     }
00101 
00102 
00108     public function save()
00109     {
00110         $myConfig  = $this->getConfig();
00111 
00112 
00113         parent::save();
00114 
00115         $soxId   = $this->getEditObjectId();
00116         $aParams = oxConfig::getParameter( "editval");
00117 
00118         $oPromotion = oxNew( "oxactions" );
00119         if ( $soxId != "-1" ) {
00120             $oPromotion->load( $soxId );
00121 
00122                 oxUtilsPic::getInstance()->overwritePic( $oPromotion, 'oxactions', 'oxpic', 'PROMO', oxUtilsFile::PROMO_PICTURE_DIR, $aParams, $myConfig->getPictureDir(false));
00123 
00124         } else {
00125             $aParams['oxactions__oxid']   = null;
00126         }
00127 
00128         if ( !$aParams['oxactions__oxactive'] ) {
00129             $aParams['oxactions__oxactive'] = 0;
00130         }
00131 
00132         $oPromotion->setLanguage( 0 );
00133         $oPromotion->assign( $aParams );
00134         $oPromotion->setLanguage( $this->_iEditLang );
00135         $oPromotion = oxUtilsFile::getInstance()->processFiles( $oPromotion );
00136         $oPromotion->save();
00137 
00138         // set oxid if inserted
00139         $this->setEditObjectId( $oPromotion->getId() );
00140     }
00141 
00147     public function saveinnlang()
00148     {
00149         $this->save();
00150     }
00151 }