Esempio n. 1
0
}
$smarty->assign("T_APPEARANCE_LOGO_FORM", $appearanceLogoForm->toArray());
$appearanceFaviconForm = new Html_QuickForm("appearance_favicon_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=appearance&tab=favicon", "", null, true);
$appearanceFaviconForm->registerRule('checkParameter', 'callback', 'eF_checkParameter');
$appearanceFaviconForm->addElement('file', 'favicon', _FILENAME);
$appearanceFaviconForm->addElement("static", "", _EACHFILESIZEMUSTBESMALLERTHAN . ' <b>' . FileSystemTree::getUploadMaxSize() . '</b> ' . _KB);
$appearanceFaviconForm->addElement("advcheckbox", "default_favicon", _USEDEFAULTFAVICON, null, 'class = "inputCheckBox"  id = "set_default_favicon" onclick = "$(\'favicon_settings\').select(\'input\').each(function(s) {if (s.type != \'submit\' && s.id != \'set_default_favicon\') s.disabled ? s.disabled = \'\' : s.disabled = \'disabled\' })"', array(0, 1));
$appearanceFaviconForm->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
if (isset($currentUser->coreAccess['configuration']) && $currentUser->coreAccess['configuration'] != 'change') {
    $appearanceFaviconForm->freeze();
} else {
    $appearanceFaviconForm->addElement("submit", "submit", _SAVE, 'class = "flatButton"');
    if ($appearanceFaviconForm->isSubmitted() && $appearanceFaviconForm->validate()) {
        try {
            //If the form is submitted and validated
            if ($appearanceFaviconForm->exportValue('default_favicon')) {
                EfrontConfiguration::setValue('favicon', '');
            } else {
                $faviconDirectory = new EfrontDirectory(G_LOGOPATH);
                $filesystem = new FileSystemTree(G_LOGOPATH);
                try {
                    $faviconFile = $filesystem->uploadFile('favicon', $logoDirectory);
                    if (strpos($faviconFile['mime_type'], 'image') === false) {
                        throw new EfrontFileException(_NOTANIMAGEFILE, EfrontFileException::NOT_APPROPRIATE_TYPE);
                    }
                    EfrontConfiguration::setValue('favicon', $faviconFile['id']);
                    clearTemplatesCache();
                } catch (Exception $e) {
                    if ($e->getCode() != UPLOAD_ERR_NO_FILE) {
                        throw $e;
                    }