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 ( oxRegistry::getLang()->getLanguageNames(), $oOtherLang );
00038 
00039             if ( count( $aLang))
00040                 $this->_aViewData["posslang"] = $aLang;
00041 
00042             foreach ( $oOtherLang as $id => $language) {
00043                 $oLang= new stdClass();
00044                 $oLang->sLangDesc = $language;
00045                 $oLang->selected = ($id == $this->_iEditLang);
00046                 $this->_aViewData["otherlang"][$id] = clone $oLang;
00047             }
00048         }
00049 
00050         if ( oxConfig::getParameter("aoc") ) {
00051             // generating category tree for select list
00052             $sChosenArtCat = oxConfig::getParameter( "artcat");
00053             $sChosenArtCat = $this->_getCategoryTree( "artcattree", $sChosenArtCat, $soxId);
00054 
00055             $oActionsMainAjax = oxNew( 'actions_main_ajax' );
00056             $this->_aViewData['oxajax'] = $oActionsMainAjax->getColumns();
00057 
00058             return "popups/actions_main.tpl";
00059         }
00060 
00061 
00062         if ( ( $oPromotion = $this->getViewDataElement( "edit" ) ) ) {
00063             if ( ($oPromotion->oxactions__oxtype->value == 2) || ($oPromotion->oxactions__oxtype->value == 3) ) {
00064                 if ( $iAoc = oxConfig::getParameter( "oxpromotionaoc" ) ) {
00065                     $sPopup = false;
00066                     switch( $iAoc ) {
00067                         case 'article':
00068                             // generating category tree for select list
00069                             $sChosenArtCat = oxConfig::getParameter( "artcat");
00070                             $sChosenArtCat = $this->_getCategoryTree( "artcattree", $sChosenArtCat, $soxId);
00071 
00072                             if ($oArticle = $oPromotion->getBannerArticle()) {
00073                                 $this->_aViewData['actionarticle_artnum'] = $oArticle->oxarticles__oxartnum->value;
00074                                 $this->_aViewData['actionarticle_title']  = $oArticle->oxarticles__oxtitle->value;
00075                             }
00076 
00077                             $sPopup = 'actions_article';
00078                             break;
00079                         case 'groups':
00080                             $sPopup = 'actions_groups';
00081                             break;
00082                     }
00083 
00084                     if ( $sPopup ) {
00085                         $aColumns = array();
00086                         $oActionsArticleAjax = oxNew( $sPopup.'_ajax' );
00087                         $this->_aViewData['oxajax'] = $oActionsArticleAjax->getColumns();
00088                         return "popups/{$sPopup}.tpl";
00089                     }
00090                 } else {
00091                     if ( $oPromotion->oxactions__oxtype->value == 2) {
00092                         $this->_aViewData["editor"] = $this->_generateTextEditor( "100%", 300, $oPromotion, "oxactions__oxlongdesc", "details.tpl.css" );
00093                     }
00094                 }
00095             }
00096         }
00097 
00098         return "actions_main.tpl";
00099     }
00100 
00101 
00107     public function save()
00108     {
00109         $myConfig  = $this->getConfig();
00110 
00111 
00112         parent::save();
00113 
00114         $soxId   = $this->getEditObjectId();
00115         $aParams = oxConfig::getParameter( "editval");
00116 
00117         $oPromotion = oxNew( "oxactions" );
00118         if ( $soxId != "-1" ) {
00119             $oPromotion->load( $soxId );
00120         } else {
00121             $aParams['oxactions__oxid']   = null;
00122         }
00123 
00124         if ( !$aParams['oxactions__oxactive'] ) {
00125             $aParams['oxactions__oxactive'] = 0;
00126         }
00127 
00128         $oPromotion->setLanguage( 0 );
00129         $oPromotion->assign( $aParams );
00130         $oPromotion->setLanguage( $this->_iEditLang );
00131         $oPromotion = oxRegistry::get("oxUtilsFile")->processFiles( $oPromotion );
00132         $oPromotion->save();
00133 
00134         // set oxid if inserted
00135         $this->setEditObjectId( $oPromotion->getId() );
00136     }
00137 
00143     public function saveinnlang()
00144     {
00145         $this->save();
00146     }
00147 }