| 1 | <?php |
|---|
| 2 | // $Id: myblockform.php,v 1.8 2003/03/10 13:32:05 okazu Exp $ |
|---|
| 3 | // ------------------------------------------------------------------------ // |
|---|
| 4 | // XOOPS - PHP Content Management System // |
|---|
| 5 | // Copyright (c) 2000 XOOPS.org // |
|---|
| 6 | // <http://www.xoops.org/> // |
|---|
| 7 | // ------------------------------------------------------------------------ // |
|---|
| 8 | // This program is free software; you can redistribute it and/or modify // |
|---|
| 9 | // it under the terms of the GNU General Public License as published by // |
|---|
| 10 | // the Free Software Foundation; either version 2 of the License, or // |
|---|
| 11 | // (at your option) any later version. // |
|---|
| 12 | // // |
|---|
| 13 | // You may not change or alter any portion of this comment or credits // |
|---|
| 14 | // of supporting developers from this source code or any supporting // |
|---|
| 15 | // source code which is considered copyrighted (c) material of the // |
|---|
| 16 | // original comment or credit authors. // |
|---|
| 17 | // // |
|---|
| 18 | // This program is distributed in the hope that it will be useful, // |
|---|
| 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|---|
| 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|---|
| 21 | // GNU General Public License for more details. // |
|---|
| 22 | // // |
|---|
| 23 | // You should have received a copy of the GNU General Public License // |
|---|
| 24 | // along with this program; if not, write to the Free Software // |
|---|
| 25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
|---|
| 26 | // ------------------------------------------------------------------------ // |
|---|
| 27 | |
|---|
| 28 | if( ! defined( 'XOOPS_ROOT_PATH' ) ) exit ; |
|---|
| 29 | |
|---|
| 30 | $usespaw = empty( $_GET['usespaw'] ) ? 0 : 1 ; |
|---|
| 31 | |
|---|
| 32 | require_once XOOPS_ROOT_PATH."/class/xoopsformloader.php"; |
|---|
| 33 | //$form = new XoopsThemeForm($block['form_title'], 'blockform', XOOPS_URL."/modules/blocksadmin/admin/admin.php" ) ; |
|---|
| 34 | $form = new XoopsThemeForm($block['form_title'], 'blockform', "admin.php?dirname=".preg_replace('[^a-zA-Z0-9_.-]','',@$_GET['dirname'])) ; |
|---|
| 35 | if (isset($block['name'])) { |
|---|
| 36 | $form->addElement(new XoopsFormLabel(_AM_NAME, $block['name'])); |
|---|
| 37 | } |
|---|
| 38 | $side_select = new XoopsFormSelect(_AM_BLKTYPE, "bside", $block['side']); |
|---|
| 39 | $side_select->addOptionArray(array(0 => _AM_SBLEFT, 1 => _AM_SBRIGHT, 3 => _AM_CBLEFT, 4 => _AM_CBRIGHT, 5 => _AM_CBCENTER, )); |
|---|
| 40 | $form->addElement($side_select); |
|---|
| 41 | $form->addElement(new XoopsFormText(_AM_WEIGHT, "bweight", 2, 5, $block['weight'])); |
|---|
| 42 | $form->addElement(new XoopsFormRadioYN(_AM_VISIBLE, 'bvisible', $block['visible'])); |
|---|
| 43 | $mod_select = new XoopsFormSelect(_AM_VISIBLEIN, "bmodule", $block['modules'], 5, true); |
|---|
| 44 | $module_handler =& xoops_gethandler('module'); |
|---|
| 45 | $criteria = new CriteriaCompo(new Criteria('hasmain', 1)); |
|---|
| 46 | $criteria->add(new Criteria('isactive', 1)); |
|---|
| 47 | $module_list =& $module_handler->getList($criteria); |
|---|
| 48 | $module_list[-1] = _AM_TOPPAGE; |
|---|
| 49 | $module_list[0] = _AM_ALLPAGES; |
|---|
| 50 | ksort($module_list); |
|---|
| 51 | $mod_select->addOptionArray($module_list); |
|---|
| 52 | $form->addElement($mod_select); |
|---|
| 53 | $form->addElement(new XoopsFormText(_AM_TITLE, 'btitle', 50, 255, $block['title']), false); |
|---|
| 54 | |
|---|
| 55 | if ( $block['is_custom'] ) { |
|---|
| 56 | |
|---|
| 57 | // Custom Block's textarea |
|---|
| 58 | $notice_for_tags = '<span style="font-size:x-small;font-weight:bold;">'._AM_USEFULTAGS.'</span><br /><span style="font-size:x-small;font-weight:normal;">'.sprintf(_AM_BLOCKTAG1, '{X_SITEURL}', XOOPS_URL.'/').'</span>' ; |
|---|
| 59 | $current_op = @$_GET['op'] == 'clone' ? 'clone' : 'edit' ; |
|---|
| 60 | $uri_to_myself = XOOPS_URL . "/modules/blocksadmin/admin/admin.php?fct=blocksadmin&op=$current_op&bid={$block['bid']}" ; |
|---|
| 61 | // $can_use_spaw = check_browser_can_use_spaw() ; |
|---|
| 62 | $can_use_spaw = true ; |
|---|
| 63 | if( $usespaw && $can_use_spaw ) { |
|---|
| 64 | // SPAW Config |
|---|
| 65 | include XOOPS_ROOT_PATH.'/common/spaw/spaw_control.class.php' ; |
|---|
| 66 | ob_start() ; |
|---|
| 67 | $sw = new SPAW_Wysiwyg( 'bcontent' , $block['content'] ) ; |
|---|
| 68 | $sw->show() ; |
|---|
| 69 | $textarea = new XoopsFormLabel( _AM_CONTENT , ob_get_contents() ) ; |
|---|
| 70 | $textarea->setDescription( $notice_for_tags . "<br /><br /><a href='$uri_to_myself&usespaw=0'>NORMAL</a>" ) ; |
|---|
| 71 | ob_end_clean() ; |
|---|
| 72 | } else { |
|---|
| 73 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 74 | $textarea = new XoopsFormDhtmlTextArea(_AM_CONTENT, 'bcontent', $myts->htmlSpecialChars( $block['content'] ) , 15, 70); |
|---|
| 75 | if( $can_use_spaw ) { |
|---|
| 76 | $textarea->setDescription( $notice_for_tags . "<br /><br /><a href='$uri_to_myself&usespaw=1'>SPAW</a>" ) ; |
|---|
| 77 | } else { |
|---|
| 78 | $textarea->setDescription( $notice_for_tags ) ; |
|---|
| 79 | } |
|---|
| 80 | } |
|---|
| 81 | $form->addElement($textarea, true); |
|---|
| 82 | |
|---|
| 83 | $ctype_select = new XoopsFormSelect(_AM_CTYPE, 'bctype', $block['ctype']); |
|---|
| 84 | $ctype_select->addOptionArray(array('H' => _AM_HTML, 'P' => _AM_PHP, 'S' => _AM_AFWSMILE, 'T' => _AM_AFNOSMILE)); |
|---|
| 85 | $form->addElement($ctype_select); |
|---|
| 86 | } else { |
|---|
| 87 | if ($block['template'] != '' && ! defined('XOOPS_ORETEKI') ) { |
|---|
| 88 | $tplfile_handler =& xoops_gethandler('tplfile'); |
|---|
| 89 | $btemplate =& $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']); |
|---|
| 90 | if (count($btemplate) > 0) { |
|---|
| 91 | $form->addElement(new XoopsFormLabel(_AM_CONTENT, '<a href="mytplsform.php?tpl_file='.$btemplate[0]->getVar('tpl_file').'&tpl_tplset='.htmlspecialchars($GLOBALS['xoopsConfig']['template_set'],ENT_QUOTES).'">'._AM_EDITTPL.'</a>')); |
|---|
| 92 | } else { |
|---|
| 93 | $btemplate2 =& $tplfile_handler->find('default', 'block', $block['bid']); |
|---|
| 94 | if (count($btemplate2) > 0) { |
|---|
| 95 | $form->addElement(new XoopsFormLabel(_AM_CONTENT, '<a href="mytplsform.php?tpl_file='.$btemplate2[0]->getVar('tpl_file').'&tpl_tplset=default">'._AM_EDITTPL.'</a>')); |
|---|
| 96 | } |
|---|
| 97 | } |
|---|
| 98 | } |
|---|
| 99 | if ($block['edit_form'] != false) { |
|---|
| 100 | $form->addElement(new XoopsFormLabel(_AM_OPTIONS, $block['edit_form'])); |
|---|
| 101 | } |
|---|
| 102 | } |
|---|
| 103 | $cache_select = new XoopsFormSelect(_AM_BCACHETIME, 'bcachetime', $block['cachetime']); |
|---|
| 104 | $cache_select->addOptionArray(array('0' => _NOCACHE, '30' => sprintf(_SECONDS, 30), '60' => _MINUTE, '300' => sprintf(_MINUTES, 5), '1800' => sprintf(_MINUTES, 30), '3600' => _HOUR, '18000' => sprintf(_HOURS, 5), '86400' => _DAY, '259200' => sprintf(_DAYS, 3), '604800' => _WEEK, '2592000' => _MONTH)); |
|---|
| 105 | $form->addElement($cache_select); |
|---|
| 106 | if (isset($block['bid'])) { |
|---|
| 107 | $form->addElement(new XoopsFormHidden('bid', $block['bid'])); |
|---|
| 108 | } |
|---|
| 109 | // $form->addElement(new XoopsFormHidden('options', $block['options'])); |
|---|
| 110 | $form->addElement(new XoopsFormHidden('op', $block['op'])); |
|---|
| 111 | $form->addElement(new XoopsFormHidden('fct', 'blocksadmin')); |
|---|
| 112 | $button_tray = new XoopsFormElementTray('', ' '); |
|---|
| 113 | if ($block['is_custom']) { |
|---|
| 114 | $button_tray->addElement(new XoopsFormButton('', 'previewblock', _PREVIEW, "submit")); |
|---|
| 115 | } |
|---|
| 116 | $button_tray->addElement(new XoopsFormButton('', 'submitblock', $block['submit_button'], "submit")); |
|---|
| 117 | $form->addElement($button_tray); |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | // checks browser compatibility with the control |
|---|
| 121 | function check_browser_can_use_spaw() { |
|---|
| 122 | $browser = $_SERVER['HTTP_USER_AGENT'] ; |
|---|
| 123 | // check if msie |
|---|
| 124 | if( eregi( "MSIE[^;]*" , $browser , $msie ) ) { |
|---|
| 125 | // get version |
|---|
| 126 | if( eregi( "[0-9]+\.[0-9]+" , $msie[0] , $version ) ) { |
|---|
| 127 | // check version |
|---|
| 128 | if( (float)$version[0] >= 5.5 ) { |
|---|
| 129 | // finally check if it's not opera impersonating ie |
|---|
| 130 | if( ! eregi( "opera" , $browser ) ) { |
|---|
| 131 | return true ; |
|---|
| 132 | } |
|---|
| 133 | } |
|---|
| 134 | } |
|---|
| 135 | } |
|---|
| 136 | return false ; |
|---|
| 137 | } |
|---|
| 138 | |
|---|
| 139 | ?> |
|---|