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 (oxLang::getInstance()->getLanguageNames(), $oOtherLang);
00037 
00038             foreach ( $oOtherLang as $id => $language) {
00039                 $oLang= new oxStdClass();
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(oxLang::getInstance()->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 
00099         // set oxid if inserted
00100         $this->setEditObjectId( $oLinks->getId() );
00101     }
00102 
00108     public function saveinnlang()
00109     {
00110         $soxId = $this->getEditObjectId();
00111         $aParams = oxConfig::getParameter( "editval");
00112         // checkbox handling
00113         if ( !isset( $aParams['oxlinks__oxactive']))
00114             $aParams['oxlinks__oxactive'] = 0;
00115 
00116             // shopid
00117             $sShopID = oxSession::getVar( "actshop");
00118             $aParams['oxlinks__oxshopid'] = $sShopID;
00119         $oLinks = oxNew( "oxlinks", getViewName( 'oxlinks'));
00120         $iEditLanguage = oxConfig::getParameter("editlanguage");
00121 
00122         if( $soxId != "-1")
00123             $oLinks->loadInLang( $iEditLanguage, $soxId );
00124         else
00125             $aParams['oxlinks__oxid'] = null;
00126         //$aParams = $oLinks->ConvertNameArray2Idx( $aParams);
00127 
00128 
00129 
00130         $oLinks->setLanguage(0);
00131         $oLinks->assign( $aParams);
00132 
00133         // apply new language
00134         $oLinks->setLanguage( oxConfig::getParameter( "new_lang" ) );
00135         $oLinks->save();
00136 
00137         // set oxid if inserted
00138         $this->setEditObjectId( $oLinks->getId() );
00139     }
00140 
00152     protected function _getTextEditor( $iWidth, $iHeight, $oObject, $sField, $sStylesheet = null )
00153     {
00154         if ( $oEditor = parent::_getTextEditor( $iWidth, $iHeight, $oObject, $sField, $sStylesheet ) ) {
00155             // setting empty value
00156             $oEditor->emptyValue = ( $oEditor->lineReturns == 'P' ) ? "<p>&nbsp;</p>" : "<div>&nbsp;</div>";
00157         }
00158         return $oEditor;
00159     }
00160 }