当前位置: 首页>>代码示例>>PHP>>正文


PHP FileField::setDescription方法代码示例

本文整理汇总了PHP中FileField::setDescription方法的典型用法代码示例。如果您正苦于以下问题:PHP FileField::setDescription方法的具体用法?PHP FileField::setDescription怎么用?PHP FileField::setDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileField的用法示例。


在下文中一共展示了FileField::setDescription方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: page

 public function page()
 {
     if (!OW::getRequest()->isAjax()) {
         OW::getNavigation()->activateMenuItem(OW_Navigation::ADMIN_SETTINGS, 'admin', 'sidebar_menu_item_main_settings');
     }
     $language = OW::getLanguage();
     $menu = $this->getMenu();
     $this->addComponent('menu', $menu);
     if (!OW::getRequest()->isAjax()) {
         OW::getDocument()->setHeading(OW::getLanguage()->text('admin', 'heading_page_settings'));
         OW::getDocument()->setHeadingIconClass('ow_ic_file');
     }
     $form = new Form('page_settings');
     $form->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA);
     $this->addForm($form);
     $headCode = new Textarea('head_code');
     $headCode->setLabel($language->text('admin', 'page_settings_form_headcode_label'));
     $headCode->setDescription($language->text('admin', 'page_settings_form_headcode_desc'));
     $form->addElement($headCode);
     $bottomCode = new Textarea('bottom_code');
     $bottomCode->setLabel($language->text('admin', 'page_settings_form_bottomcode_label'));
     $bottomCode->setDescription($language->text('admin', 'page_settings_form_bottomcode_desc'));
     $form->addElement($bottomCode);
     $favicon = new FileField('favicon');
     $favicon->setLabel($language->text('admin', 'page_settings_form_favicon_label'));
     $favicon->setDescription($language->text('admin', 'page_settings_form_favicon_desc'));
     $form->addElement($favicon);
     $enableFavicon = new CheckboxField('enable_favicon');
     $form->addElement($enableFavicon);
     $submit = new Submit('save');
     $submit->setValue($language->text('admin', 'save_btn_label'));
     $form->addElement($submit);
     $faviconPath = OW::getPluginManager()->getPlugin('base')->getUserFilesDir() . 'favicon.ico';
     $faviconUrl = OW::getPluginManager()->getPlugin('base')->getUserFilesUrl() . 'favicon.ico';
     $this->assign('faviconSrc', $faviconUrl);
     if (OW::getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             OW::getConfig()->saveConfig('base', 'html_head_code', $data['head_code']);
             OW::getConfig()->saveConfig('base', 'html_prebody_code', $data['bottom_code']);
             if (!empty($_FILES['favicon']['name'])) {
                 if ((int) $_FILES['favicon']['error'] === 0 && is_uploaded_file($_FILES['favicon']['tmp_name']) && UTIL_File::getExtension($_FILES['favicon']['name']) === 'ico') {
                     if (file_exists($faviconPath)) {
                         @unlink($faviconPath);
                     }
                     @move_uploaded_file($_FILES['favicon']['tmp_name'], $faviconPath);
                     if (file_exists($_FILES['favicon']['tmp_name'])) {
                         @unlink($_FILES['favicon']['tmp_name']);
                     }
                 } else {
                     OW::getFeedback()->error($language->text('admin', 'page_settings_favicon_submit_error_message'));
                 }
             }
             OW::getConfig()->saveConfig('base', 'favicon', !empty($data['enable_favicon']));
             OW::getFeedback()->info($language->text('admin', 'settings_submit_success_message'));
         } else {
             OW::getFeedback()->error($language->text('admin', 'settings_submit_error_message'));
         }
         $this->redirect();
     }
     $headCode->setValue(OW::getConfig()->getValue('base', 'html_head_code'));
     $bottomCode->setValue(OW::getConfig()->getValue('base', 'html_prebody_code'));
     $enableFavicon->setValue((int) OW::getConfig()->getValue('base', 'favicon'));
     $this->assign('faviconEnabled', OW::getConfig()->getValue('base', 'favicon'));
     $script = "\$('#{$enableFavicon->getId()}').change(function(){ if(this.checked){ \$('#favicon_enabled').show();\$('#favicon_desabled').hide(); \$('{$favicon->getId()}').attr('disabled', true);}else{ \$('#favicon_enabled').hide();\$('#favicon_desabled').show(); \$('{$favicon->getId()}').attr('disabled', false);} });";
     OW::getDocument()->addOnloadScript($script);
 }
开发者ID:hardikamutech,项目名称:loov,代码行数:67,代码来源:settings.php


注:本文中的FileField::setDescription方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。