adminlinks_main.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class Adminlinks_Main extends oxAdminDetails
00010 {
00016     public function render()
00017     {
00018         $myConfig  = $this->getConfig();
00019 
00020         parent::render();
00021 
00022         $soxId = oxConfig::getParameter( "oxid");
00023         // check if we right now saved a new entry
00024         $sSavedID = oxConfig::getParameter( "saved_oxid");
00025         if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) {
00026             $soxId = $sSavedID;
00027             oxSession::deleteVar( "saved_oxid");
00028             $this->_aViewData["oxid"] =  $soxId;
00029             // for reloading upper frame
00030             $this->_aViewData["updatelist"] =  "1";
00031         }
00032 
00033         if ( $soxId != "-1" && isset( $soxId)) {
00034             // load object
00035             $oLinks = oxNew( "oxlinks", getViewName( 'oxlinks'));
00036             $oLinks->loadInLang( $this->_iEditLang, $soxId );
00037 
00038             $oOtherLang = $oLinks->getAvailableInLangs();
00039             if (!isset($oOtherLang[$this->_iEditLang])) {
00040                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00041                 $oLinks->loadInLang( key($oOtherLang), $soxId );
00042             }
00043             $this->_aViewData["edit"] =  $oLinks;
00044 
00045             // remove already created languages
00046             $this->_aViewData["posslang"] =  array_diff (oxLang::getInstance()->getLanguageNames(), $oOtherLang);
00047 
00048             foreach ( $oOtherLang as $id => $language) {
00049                 $oLang= new oxStdClass();
00050                 $oLang->sLangDesc = $language;
00051                 $oLang->selected = ($id == $this->_iEditLang);
00052                 $this->_aViewData["otherlang"][$id] =  clone $oLang;
00053             }
00054         }
00055 
00056         // generate editor
00057         $this->_aViewData["editor"] = $this->_generateTextEditor( "100%", 255, $oLinks, "oxlinks__oxurldesc", "links.tpl.css");
00058 
00059         return "adminlinks_main.tpl";
00060     }
00061 
00067     public function save()
00068     {
00069         $soxId      = oxConfig::getParameter( "oxid");
00070         $aParams    = oxConfig::getParameter( "editval");
00071         // checkbox handling
00072         if ( !isset( $aParams['oxlinks__oxactive']))
00073             $aParams['oxlinks__oxactive'] = 0;
00074 
00075         // adds space to the end of URL description to keep new added links visible
00076         // if URL description left empty
00077         if (isset($aParams['oxlinks__oxurldesc']) && strlen($aParams['oxlinks__oxurldesc']) == 0)
00078             $aParams['oxlinks__oxurldesc'] .= " ";
00079 
00080         if ( !$aParams['oxlinks__oxinsert']) {
00081             // sets default (?) date format to output
00082             // else if possible - changes date format to system compatible
00083             $sDate = date(oxLang::getInstance()->translateString( "simpleDateFormat"));
00084             if ($sDate == "simpleDateFormat")
00085                 $aParams['oxlinks__oxinsert'] = date( "Y-m-d");
00086             else
00087                 $aParams['oxlinks__oxinsert'] = $sDate;
00088         }
00089 
00090         $iEditLanguage = oxConfig::getParameter("editlanguage");
00091         $oLinks = oxNew( "oxlinks", getViewName( 'oxlinks'));
00092 
00093         if ( $soxId != "-1") {
00094             //$oLinks->load( $soxId );
00095             $oLinks->loadInLang( $iEditLanguage, $soxId );
00096 
00097         } else {
00098             $aParams['oxlinks__oxid'] = null;
00099         }
00100 
00101         //$aParams = $oLinks->ConvertNameArray2Idx( $aParams);
00102 
00103         $oLinks->setLanguage(0);
00104         $oLinks->assign( $aParams);
00105         $oLinks->setLanguage( $iEditLanguage );
00106         $oLinks->save();
00107         $this->_aViewData["updatelist"] = "1";
00108 
00109 
00110         // set oxid if inserted
00111         if ( $soxId == "-1")
00112             oxSession::setVar( "saved_oxid", $oLinks->oxlinks__oxid->value);
00113 
00114         return $this->autosave();
00115     }
00116 
00122     public function saveinnlang()
00123     {
00124         $soxId      = oxConfig::getParameter( "oxid");
00125         $aParams    = oxConfig::getParameter( "editval");
00126         // checkbox handling
00127         if ( !isset( $aParams['oxlinks__oxactive']))
00128             $aParams['oxlinks__oxactive'] = 0;
00129 
00130             // shopid
00131             $sShopID = oxSession::getVar( "actshop");
00132             $aParams['oxlinks__oxshopid'] = $sShopID;
00133         $oLinks = oxNew( "oxlinks", getViewName( 'oxlinks'));
00134         $iEditLanguage = oxConfig::getParameter("editlanguage");
00135 
00136         if( $soxId != "-1")
00137             $oLinks->loadInLang( $iEditLanguage, $soxId );
00138         else
00139             $aParams['oxlinks__oxid'] = null;
00140         //$aParams = $oLinks->ConvertNameArray2Idx( $aParams);
00141 
00142 
00143 
00144         $oLinks->setLanguage(0);
00145         $oLinks->assign( $aParams);
00146 
00147         // apply new language
00148         $sNewLanguage = oxConfig::getParameter( "new_lang");
00149         $oLinks->setLanguage( $sNewLanguage);
00150         $oLinks->save();
00151         $this->_aViewData["updatelist"] = "1";
00152 
00153         // set oxid if inserted
00154         if ( $soxId == "-1")
00155             oxSession::setVar( "saved_oxid", $oLinks->oxlinks__oxid->value);
00156 
00157         return $this->autosave();
00158     }
00159 }

Generated on Fri Dec 19 14:20:27 2008 for OXID eShop CE by  doxygen 1.5.5