예제 #1
0
 public function setLogoDefault($d = array())
 {
     $code = isset($d['code']) ? $d['code'] : '';
     if (!empty($code)) {
         $plTemplate = $this->get('template');
         // Current plugin template
         if ($plTemplate && frameBup::_()->getModule($plTemplate)) {
             $newValue = frameBup::_()->getModule($plTemplate)->getDefOptions($code);
             if ($newValue !== NULL && file_exists(frameBup::_()->getModule($plTemplate)->getModDir() . $newValue)) {
                 // Remove prev. image
                 utilsBup::deleteFile(frameBup::_()->getModule('options')->getLogoImgFullDir());
                 // Copy new image from tpl module directory to uploads dirctory
                 copy(frameBup::_()->getModule($plTemplate)->getModDir() . $newValue, utilsBup::getUploadsDir() . DS . $this->getModule()->getLogoImgDir() . DS . $newValue);
                 if ($this->save(array('opt_values' => array($code => $newValue), 'code' => $code))) {
                     return $this->getModule()->getLogoImgFullPath();
                 }
             } else {
                 $this->pushError(__('There is no default for this option and current template', BUP_LANG_CODE));
             }
         } else {
             $this->pushError(__('There is no default for this option and current template', BUP_LANG_CODE));
         }
     } else {
         $this->pushError(__('Empty option code', BUP_LANG_CODE));
     }
     return false;
 }