adminlinks_main.php
Go to the documentation of this file.00001 <?php
00002
00008 class Adminlinks_Main extends oxAdminDetails
00009 {
00016 public function render()
00017 {
00018 $myConfig = $this->getConfig();
00019
00020 parent::render();
00021
00022 $soxId = oxConfig::getParameter( "oxid");
00023
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
00030 $this->_aViewData["updatelist"] = "1";
00031 }
00032
00033 if ( $soxId != "-1" && isset( $soxId)) {
00034
00035 $oLinks = oxNew( "oxlinks", getViewName( 'oxlinks'));
00036 $oLinks->loadInLang( $this->_iEditLang, $soxId );
00037
00038 $oOtherLang = $oLinks->getAvailableInLangs();
00039 if (!isset($oOtherLang[$this->_iEditLang])) {
00040
00041 $oLinks->loadInLang( key($oOtherLang), $soxId );
00042 }
00043 $this->_aViewData["edit"] = $oLinks;
00044
00045
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
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
00072 if ( !isset( $aParams['oxlinks__oxactive']))
00073 $aParams['oxlinks__oxactive'] = 0;
00074
00075
00076
00077 if (isset($aParams['oxlinks__oxurldesc']) && strlen($aParams['oxlinks__oxurldesc']) == 0)
00078 $aParams['oxlinks__oxurldesc'] .= " ";
00079
00080 if ( !$aParams['oxlinks__oxinsert']) {
00081
00082
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
00095 $oLinks->loadInLang( $iEditLanguage, $soxId );
00096
00097 } else {
00098 $aParams['oxlinks__oxid'] = null;
00099 }
00100
00101
00102
00103 $oLinks->setLanguage(0);
00104 $oLinks->assign( $aParams);
00105 $oLinks->setLanguage( $iEditLanguage );
00106 $oLinks->save();
00107 $this->_aViewData["updatelist"] = "1";
00108
00109
00110
00111 if ( $soxId == "-1")
00112 oxSession::setVar( "saved_oxid", $oLinks->oxlinks__oxid->value);
00113 }
00114
00120 public function saveinnlang()
00121 {
00122 $soxId = oxConfig::getParameter( "oxid");
00123 $aParams = oxConfig::getParameter( "editval");
00124
00125 if ( !isset( $aParams['oxlinks__oxactive']))
00126 $aParams['oxlinks__oxactive'] = 0;
00127
00128
00129 $sShopID = oxSession::getVar( "actshop");
00130 $aParams['oxlinks__oxshopid'] = $sShopID;
00131 $oLinks = oxNew( "oxlinks", getViewName( 'oxlinks'));
00132 $iEditLanguage = oxConfig::getParameter("editlanguage");
00133
00134 if( $soxId != "-1")
00135 $oLinks->loadInLang( $iEditLanguage, $soxId );
00136 else
00137 $aParams['oxlinks__oxid'] = null;
00138
00139
00140
00141
00142 $oLinks->setLanguage(0);
00143 $oLinks->assign( $aParams);
00144
00145
00146 $sNewLanguage = oxConfig::getParameter( "new_lang");
00147 $oLinks->setLanguage( $sNewLanguage);
00148 $oLinks->save();
00149 $this->_aViewData["updatelist"] = "1";
00150
00151
00152 if ( $soxId == "-1")
00153 oxSession::setVar( "saved_oxid", $oLinks->oxlinks__oxid->value);
00154 }
00155
00167 protected function _getTextEditor( $iWidth, $iHeight, $oObject, $sField, $sStylesheet = null )
00168 {
00169 if ( $oEditor = parent::_getTextEditor( $iWidth, $iHeight, $oObject, $sField, $sStylesheet ) ) {
00170
00171 $oEditor->emptyValue = ( $oEditor->lineReturns == 'P' ) ? "<p> </p>" : "<div> </div>";
00172 }
00173 return $oEditor;
00174 }
00175 }