adminlinks_main.php

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