adminlinks_main.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class Adminlinks_Main extends oxAdminDetails
00009 {
00015     public function render()
00016     {
00017         $myConfig  = $this->getConfig();
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         if ( $soxId != "-1" && isset( $soxId)) {
00033             // load object
00034             $oLinks = oxNew( "oxlinks", getViewName( 'oxlinks'));
00035             $oLinks->loadInLang( $this->_iEditLang, $soxId );
00036 
00037             $oOtherLang = $oLinks->getAvailableInLangs();
00038             if (!isset($oOtherLang[$this->_iEditLang])) {
00039                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00040                 $oLinks->loadInLang( key($oOtherLang), $soxId );
00041             }
00042             $this->_aViewData["edit"] =  $oLinks;
00043 
00044             // remove already created languages
00045             $this->_aViewData["posslang"] =  array_diff (oxLang::getInstance()->getLanguageNames(), $oOtherLang);
00046 
00047             foreach ( $oOtherLang as $id => $language) {
00048                 $oLang= new oxStdClass();
00049                 $oLang->sLangDesc = $language;
00050                 $oLang->selected = ($id == $this->_iEditLang);
00051                 $this->_aViewData["otherlang"][$id] =  clone $oLang;
00052             }
00053         }
00054 
00055         // generate editor
00056         $this->_aViewData["editor"] = $this->_generateTextEditor( "100%", 255, $oLinks, "oxlinks__oxurldesc", "links.tpl.css");
00057 
00058         return "adminlinks_main.tpl";
00059     }
00060 
00066     public function save()
00067     {
00068         $soxId      = oxConfig::getParameter( "oxid");
00069         $aParams    = oxConfig::getParameter( "editval");
00070         // checkbox handling
00071         if ( !isset( $aParams['oxlinks__oxactive']))
00072             $aParams['oxlinks__oxactive'] = 0;
00073 
00074         // adds space to the end of URL description to keep new added links visible
00075         // if URL description left empty
00076         if (isset($aParams['oxlinks__oxurldesc']) && strlen($aParams['oxlinks__oxurldesc']) == 0)
00077             $aParams['oxlinks__oxurldesc'] .= " ";
00078 
00079         if ( !$aParams['oxlinks__oxinsert']) {
00080             // sets default (?) date format to output
00081             // else if possible - changes date format to system compatible
00082             $sDate = date(oxLang::getInstance()->translateString( "simpleDateFormat"));
00083             if ($sDate == "simpleDateFormat")
00084                 $aParams['oxlinks__oxinsert'] = date( "Y-m-d");
00085             else
00086                 $aParams['oxlinks__oxinsert'] = $sDate;
00087         }
00088 
00089         $iEditLanguage = oxConfig::getParameter("editlanguage");
00090         $oLinks = oxNew( "oxlinks", getViewName( 'oxlinks'));
00091 
00092         if ( $soxId != "-1") {
00093             //$oLinks->load( $soxId );
00094             $oLinks->loadInLang( $iEditLanguage, $soxId );
00095 
00096         } else {
00097             $aParams['oxlinks__oxid'] = null;
00098         }
00099 
00100         //$aParams = $oLinks->ConvertNameArray2Idx( $aParams);
00101 
00102         $oLinks->setLanguage(0);
00103         $oLinks->assign( $aParams);
00104         $oLinks->setLanguage( $iEditLanguage );
00105         $oLinks->save();
00106         $this->_aViewData["updatelist"] = "1";
00107 
00108 
00109         // set oxid if inserted
00110         if ( $soxId == "-1")
00111             oxSession::setVar( "saved_oxid", $oLinks->oxlinks__oxid->value);
00112     }
00113 
00119     public function saveinnlang()
00120     {
00121         $soxId      = oxConfig::getParameter( "oxid");
00122         $aParams    = oxConfig::getParameter( "editval");
00123         // checkbox handling
00124         if ( !isset( $aParams['oxlinks__oxactive']))
00125             $aParams['oxlinks__oxactive'] = 0;
00126 
00127             // shopid
00128             $sShopID = oxSession::getVar( "actshop");
00129             $aParams['oxlinks__oxshopid'] = $sShopID;
00130         $oLinks = oxNew( "oxlinks", getViewName( 'oxlinks'));
00131         $iEditLanguage = oxConfig::getParameter("editlanguage");
00132 
00133         if( $soxId != "-1")
00134             $oLinks->loadInLang( $iEditLanguage, $soxId );
00135         else
00136             $aParams['oxlinks__oxid'] = null;
00137         //$aParams = $oLinks->ConvertNameArray2Idx( $aParams);
00138 
00139 
00140 
00141         $oLinks->setLanguage(0);
00142         $oLinks->assign( $aParams);
00143 
00144         // apply new language
00145         $sNewLanguage = oxConfig::getParameter( "new_lang");
00146         $oLinks->setLanguage( $sNewLanguage);
00147         $oLinks->save();
00148         $this->_aViewData["updatelist"] = "1";
00149 
00150         // set oxid if inserted
00151         if ( $soxId == "-1")
00152             oxSession::setVar( "saved_oxid", $oLinks->oxlinks__oxid->value);
00153     }
00154 
00166     protected function _getTextEditor( $iWidth, $iHeight, $oObject, $sField, $sStylesheet = null )
00167     {
00168         if ( $oEditor = parent::_getTextEditor( $iWidth, $iHeight, $oObject, $sField, $sStylesheet ) ) {
00169             // setting empty value
00170             $oEditor->emptyValue = ( $oEditor->lineReturns == 'P' ) ? "<p>&nbsp;</p>" : "<div>&nbsp;</div>";
00171         }
00172         return $oEditor;
00173     }
00174 }

Generated on Wed May 13 13:25:50 2009 for OXID eShop CE by  doxygen 1.5.5