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         $soxId = oxConfig::getParameter( "oxid");
00022         // check if we right now saved a new entry
00023         $sSavedID = oxConfig::getParameter( "saved_oxid");
00024         if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) {
00025             $soxId = $sSavedID;
00026             oxSession::deleteVar( "saved_oxid");
00027             $this->_aViewData["oxid"] =  $soxId;
00028             // for reloading upper frame
00029             $this->_aViewData["updatelist"] =  "1";
00030         }
00031 
00032         // copy this tree for our article choose
00033         $sChosenArtCat = oxConfig::getParameter( "artcat");
00034         if ( $soxId != "-1" && isset( $soxId)) {
00035             // generating category tree for select list
00036             $sChosenArtCat = $this->_getCategoryTree( "artcattree", $sChosenArtCat, $soxId);
00037 
00038             // load object
00039             $oAction = oxNew( "oxactions" );
00040             $oAction->loadInLang( $this->_iEditLang, $soxId);
00041 
00042             $oOtherLang = $oAction->getAvailableInLangs();
00043             if (!isset($oOtherLang[$this->_iEditLang])) {
00044                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00045                 $oAction->loadInLang( key($oOtherLang), $soxId );
00046             }
00047 
00048             $this->_aViewData["edit"] =  $oAction;
00049 
00050             // remove already created languages
00051             $aLang = array_diff ( oxLang::getInstance()->getLanguageNames(), $oOtherLang );
00052 
00053             if ( count( $aLang))
00054                 $this->_aViewData["posslang"] = $aLang;
00055 
00056             foreach ( $oOtherLang as $id => $language) {
00057                 $oLang= new oxStdClass();
00058                 $oLang->sLangDesc = $language;
00059                 $oLang->selected = ($id == $this->_iEditLang);
00060                 $this->_aViewData["otherlang"][$id] = clone $oLang;
00061             }
00062         }
00063         $aColumns = array();
00064         if ( oxConfig::getParameter("aoc") ) {
00065 
00066             include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00067             $this->_aViewData['oxajax'] = $aColumns;
00068 
00069             return "popups/actions_main.tpl";
00070         }
00071         
00072         
00073         if ( ( $oPromotion = $this->getViewDataElement( "edit" ) ) ) {
00074             if ( $oPromotion->oxactions__oxtype->value == 2 ) {
00075                 $this->_aViewData["editor"] = $this->_generateTextEditor( "100%", 300, $oPromotion, "oxactions__oxlongdesc", "details.tpl.css" );
00076 
00077                 if ( $iAoc = oxConfig::getParameter( "oxscpromotionsaoc" ) ) {
00078                     $sPopup = false;
00079                     switch( $iAoc ) {
00080                         /*case 1:
00081                             $sPopup = 'oxscpromotions_products';
00082                             break;*/
00083                         case 2:
00084                             $sPopup = 'actions_groups';
00085                             break;
00086                     }
00087 
00088                     if ( $sPopup ) {
00089                         $aColumns = array();
00090                         include_once "inc/{$sPopup}.inc.php";
00091                         $this->_aViewData['oxajax'] = $aColumns;
00092                         return "popups/{$sPopup}.tpl";
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         $soxId   = oxConfig::getParameter( "oxid");
00113         $aParams = oxConfig::getParameter( "editval");
00114 
00115         $oPromotion = oxNew( "oxactions" );
00116         if ( $soxId != "-1" ) {
00117             $oPromotion->load( $soxId );
00118         } else {
00119             $aParams['oxactions__oxid']   = null;
00120         }
00121 
00122         if ( !$aParams['oxactions__oxactive'] ) {
00123             $aParams['oxactions__oxactive'] = 0;
00124         }
00125 
00126         $oPromotion->setLanguage( 0 );
00127         $oPromotion->assign( $aParams );
00128         $oPromotion->setLanguage( $this->_iEditLang );
00129         $oPromotion = oxUtilsFile::getInstance()->processFiles( $oPromotion );
00130         $oPromotion->save();
00131 
00132         // set oxid if inserted
00133         if ( $soxId == "-1") {
00134             oxSession::setVar( "saved_oxid", $oPromotion->getId() );
00135         }
00136 
00137         $this->_aViewData["updatelist"] = "1";
00138     }
00139 
00145     public function saveinnlang()
00146     {
00147         $this->save();
00148     }
00149 }