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 = $this->_aViewData["oxid"] = $this->getEditObjectId();
00023         if ( $soxId != "-1" && isset( $soxId)) {
00024             // load object
00025             $oLinks = oxNew( "oxlinks", getViewName( 'oxlinks'));
00026             $oLinks->loadInLang( $this->_iEditLang, $soxId );
00027 
00028             $oOtherLang = $oLinks->getAvailableInLangs();
00029             if (!isset($oOtherLang[$this->_iEditLang])) {
00030                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00031                 $oLinks->loadInLang( key($oOtherLang), $soxId );
00032             }
00033             $this->_aViewData["edit"] =  $oLinks;
00034 
00035             // remove already created languages
00036             $this->_aViewData["posslang"] =  array_diff (oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
00037 
00038             foreach ( $oOtherLang as $id => $language) {
00039                 $oLang= new stdClass();
00040                 $oLang->sLangDesc = $language;
00041                 $oLang->selected = ($id == $this->_iEditLang);
00042                 $this->_aViewData["otherlang"][$id] =  clone $oLang;
00043             }
00044         }
00045 
00046         // generate editor
00047         $this->_aViewData["editor"] = $this->_generateTextEditor( "100%", 255, $oLinks, "oxlinks__oxurldesc", "links.tpl.css");
00048 
00049         return "adminlinks_main.tpl";
00050     }
00051 
00057     public function save()
00058     {
00059         $soxId = $this->getEditObjectId();
00060         $aParams = oxConfig::getParameter( "editval");
00061         // checkbox handling
00062         if ( !isset( $aParams['oxlinks__oxactive']))
00063             $aParams['oxlinks__oxactive'] = 0;
00064 
00065         // adds space to the end of URL description to keep new added links visible
00066         // if URL description left empty
00067         if (isset($aParams['oxlinks__oxurldesc']) && strlen($aParams['oxlinks__oxurldesc']) == 0)
00068             $aParams['oxlinks__oxurldesc'] .= " ";
00069 
00070         if ( !$aParams['oxlinks__oxinsert']) {
00071             // sets default (?) date format to output
00072             // else if possible - changes date format to system compatible
00073             $sDate = date(oxRegistry::getLang()->translateString( "simpleDateFormat"));
00074             if ($sDate == "simpleDateFormat")
00075                 $aParams['oxlinks__oxinsert'] = date( "Y-m-d");
00076             else
00077                 $aParams['oxlinks__oxinsert'] = $sDate;
00078         }
00079 
00080         $iEditLanguage = oxConfig::getParameter("editlanguage");
00081         $oLinks = oxNew( "oxlinks", getViewName( 'oxlinks'));
00082 
00083         if ( $soxId != "-1") {
00084             //$oLinks->load( $soxId );
00085             $oLinks->loadInLang( $iEditLanguage, $soxId );
00086 
00087         } else {
00088             $aParams['oxlinks__oxid'] = null;
00089         }
00090 
00091         //$aParams = $oLinks->ConvertNameArray2Idx( $aParams);
00092 
00093         $oLinks->setLanguage(0);
00094         $oLinks->assign( $aParams);
00095         $oLinks->setLanguage( $iEditLanguage );
00096         $oLinks->save();
00097 
00098         parent::save();
00099 
00100         // set oxid if inserted
00101         $this->setEditObjectId( $oLinks->getId() );
00102     }
00103 
00109     public function saveinnlang()
00110     {
00111         $soxId = $this->getEditObjectId();
00112         $aParams = oxConfig::getParameter( "editval");
00113         // checkbox handling
00114         if ( !isset( $aParams['oxlinks__oxactive']))
00115             $aParams['oxlinks__oxactive'] = 0;
00116 
00117             // shopid
00118             $sShopID = oxSession::getVar( "actshop");
00119             $aParams['oxlinks__oxshopid'] = $sShopID;
00120         $oLinks = oxNew( "oxlinks", getViewName( 'oxlinks'));
00121         $iEditLanguage = oxConfig::getParameter("editlanguage");
00122 
00123         if( $soxId != "-1")
00124             $oLinks->loadInLang( $iEditLanguage, $soxId );
00125         else
00126             $aParams['oxlinks__oxid'] = null;
00127         //$aParams = $oLinks->ConvertNameArray2Idx( $aParams);
00128 
00129 
00130 
00131         $oLinks->setLanguage(0);
00132         $oLinks->assign( $aParams);
00133 
00134         // apply new language
00135         $oLinks->setLanguage( oxConfig::getParameter( "new_lang" ) );
00136         $oLinks->save();
00137 
00138         // set oxid if inserted
00139         $this->setEditObjectId( $oLinks->getId() );
00140     }
00141 
00153     /*protected function _getTextEditor( $iWidth, $iHeight, $oObject, $sField, $sStylesheet = null )
00154     {
00155         if ( $oEditor = parent::_getTextEditor( $iWidth, $iHeight, $oObject, $sField, $sStylesheet ) ) {
00156             // setting empty value
00157             $oEditor->emptyValue = ( $oEditor->lineReturns == 'P' ) ? "<p>&nbsp;</p>" : "<div>&nbsp;</div>";
00158         }
00159         return $oEditor;
00160     }*/
00161 }