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             // shopid
00091             $sShopID = oxSession::getVar( "actshop");
00092             $aParams['oxlinks__oxshopid'] = $sShopID;
00093 
00094         $iEditLanguage = oxConfig::getParameter("editlanguage");
00095         $oLinks = oxNew( "oxlinks", getViewName( 'oxlinks'));
00096 
00097         if ( $soxId != "-1") {
00098             //$oLinks->load( $soxId );
00099             $oLinks->loadInLang( $iEditLanguage, $soxId );
00100 
00101         } else {
00102             $aParams['oxlinks__oxid'] = null;
00103         }
00104 
00105         //$aParams = $oLinks->ConvertNameArray2Idx( $aParams);
00106 
00107         $oLinks->setLanguage(0);
00108         $oLinks->assign( $aParams);
00109         $oLinks->setLanguage( $iEditLanguage );
00110         $oLinks->save();
00111         $this->_aViewData["updatelist"] = "1";
00112 
00113 
00114         // set oxid if inserted
00115         if ( $soxId == "-1")
00116             oxSession::setVar( "saved_oxid", $oLinks->oxlinks__oxid->value);
00117 
00118         return $this->autosave();
00119     }
00120 
00126     public function saveinnlang()
00127     {
00128         $soxId      = oxConfig::getParameter( "oxid");
00129         $aParams    = oxConfig::getParameter( "editval");
00130         // checkbox handling
00131         if ( !isset( $aParams['oxlinks__oxactive']))
00132             $aParams['oxlinks__oxactive'] = 0;
00133 
00134             // shopid
00135             $sShopID = oxSession::getVar( "actshop");
00136             $aParams['oxlinks__oxshopid'] = $sShopID;
00137         $oLinks = oxNew( "oxlinks", getViewName( 'oxlinks'));
00138         $iEditLanguage = oxConfig::getParameter("editlanguage");
00139 
00140         if( $soxId != "-1")
00141             $oLinks->loadInLang( $iEditLanguage, $soxId );
00142         else
00143             $aParams['oxlinks__oxid'] = null;
00144         //$aParams = $oLinks->ConvertNameArray2Idx( $aParams);
00145 
00146 
00147 
00148         $oLinks->setLanguage(0);
00149         $oLinks->assign( $aParams);
00150 
00151         // apply new language
00152         $sNewLanguage = oxConfig::getParameter( "new_lang");
00153         $oLinks->setLanguage( $sNewLanguage);
00154         $oLinks->save();
00155         $this->_aViewData["updatelist"] = "1";
00156 
00157         // set oxid if inserted
00158         if ( $soxId == "-1")
00159             oxSession::setVar( "saved_oxid", $oLinks->oxlinks__oxid->value);
00160 
00161         return $this->autosave();
00162     }
00163 }

Generated on Thu Dec 4 12:04:55 2008 for OXID eShop CE by  doxygen 1.5.5