function form_edit($bid, $mode = 'edit')
 {
     $bid = intval($bid);
     //HACK by domifara
     $block = new XoopsBlock($bid);
     if (!$block->getVar('bid')) {
         // new defaults
         $bid = 0;
         $mode = 'new';
         $block->setVar('mid', 0);
         $block->setVar('block_type', 'C');
     }
     switch ($mode) {
         case 'clone':
             $form_title = _MD_A_MYBLOCKSADMIN_CLONEFORM;
             $button_value = _MD_A_MYBLOCKSADMIN_BTN_CLONE;
             $next_op = 'clone_ok';
             // breadcrumbs
             $breadcrumbsObj =& AltsysBreadcrumbs::getInstance();
             $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_CLONEFORM);
             break;
         case 'new':
             $form_title = _MD_A_MYBLOCKSADMIN_NEWFORM;
             $button_value = _MD_A_MYBLOCKSADMIN_BTN_NEW;
             $next_op = 'new_ok';
             // breadcrumbs
             $breadcrumbsObj =& AltsysBreadcrumbs::getInstance();
             $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_NEWFORM);
             break;
         case 'edit':
         default:
             $form_title = _MD_A_MYBLOCKSADMIN_EDITFORM;
             $button_value = _MD_A_MYBLOCKSADMIN_BTN_EDIT;
             $next_op = 'edit_ok';
             // breadcrumbs
             $breadcrumbsObj =& AltsysBreadcrumbs::getInstance();
             $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_EDITFORM);
             break;
     }
     $is_custom = in_array($block->getVar('block_type'), array('C', 'E')) ? true : false;
     $block_template = $block->getVar('template', 'n');
     $block_template_tplset = '';
     if (!$is_custom && $block_template) {
         // find template of the block
         $tplfile_handler =& xoops_gethandler('tplfile');
         $found_templates = $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], 'block', null, null, $block_template);
         $block_template_tplset = count($found_templates) > 0 ? $GLOBALS['xoopsConfig']['template_set'] : 'default';
     }
     //HACK by domifara
     /*
     	if ( !($block->getVar('c_type')) ){
     		$block->setVar('c_type','S');
     	}
     */
     $block_data = $this->preview_request + array('bid' => $bid, 'name' => $block->getVar('name', 'n'), 'title' => $block->getVar('title', 'n'), 'weight' => intval($block->getVar('weight')), 'bcachetime' => intval($block->getVar('bcachetime')), 'side' => intval($block->getVar('side')), 'visible' => intval($block->getVar('visible')), 'template' => $block_template, 'template_tplset' => $block_template_tplset, 'options' => $block->getVar('options'), 'content' => $block->getVar('content', 'n'), 'is_custom' => $is_custom, 'type' => $block->getVar('block_type'), 'ctype' => $block->getVar('c_type'));
     $block4assign = array('name_raw' => $block_data['name'], 'title_raw' => $block_data['title'], 'content_raw' => $block_data['content'], 'cell_position' => $this->renderCell4BlockPosition($block_data), 'cell_module_link' => $this->renderCell4BlockModuleLink($block_data), 'cell_group_perm' => $this->renderCell4BlockReadGroupPerm($block_data), 'cell_options' => $this->renderCell4BlockOptions($block_data), 'content_preview' => $this->previewContent($block_data)) + $block_data;
     // display
     require_once XOOPS_TRUST_PATH . '/libs/altsys/class/D3Tpl.class.php';
     $tpl = new D3Tpl();
     //dhtml
     include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
     if ($block_data['ctype'] == 'H' || empty($block_data['ctype'])) {
         $editor_configs = array();
         $editor_configs["name"] = "content_block";
         $editor_configs["value"] = $block_data['content'];
         $editor_configs["rows"] = 20;
         $editor_configs["cols"] = 100;
         $editor_configs["width"] = "100%";
         $editor_configs["height"] = "400px";
         $editor_configs["editor"] = xoops_getModuleOption('blocks_editor', 'system');
         $form = new XoopsFormEditor('', "textarea_content", $editor_configs);
         $rendered = $form->render();
         $tpl->assign('altsys_x25_dhtmltextarea', $rendered);
     } else {
         $form = new XoopsFormDhtmlTextArea('', 'textarea_content', $block_data['content'], 80, 20);
         $rendered = $form->render();
         $rendered = '<div id="textarea_content_bbcode_buttons_pre" style="display:block;">' . str_replace(array('<textarea', '</textarea><br />'), array('</div><textarea', '</textarea><div id="textarea_content_bbcode_buttons_post" style="display:block;">'), $rendered) . '</div>';
         $tpl->assign('altsys_x25_dhtmltextarea', $rendered);
     }
     $tpl->assign(array('target_dirname' => $this->target_dirname, 'target_mname' => $this->target_mname, 'language' => $this->lang, 'cachetime_options' => $this->cachetime_options, 'ctype_options' => $this->ctype_options, 'block' => $block4assign, 'op' => $next_op, 'form_title' => $form_title, 'submit_button' => $button_value, 'common_fck_installed' => file_exists(XOOPS_ROOT_PATH . '/common/fckeditor/fckeditor.js'), 'gticket_hidden' => $GLOBALS['xoopsGTicket']->getTicketHtml(__LINE__, 1800, 'myblocksadmin')));
     //HACK by domifara
     $tpl->display('db:altsys_main_myblocksadmin_edit_4x25.html');
     return;
 }
示例#2
0
/**
 * Obtenemos el editor correcto
 */
function rmmf_select_editor($name, $type = 'dhtml', $value = '', $width = '100%', $height = '400px', $addon = '')
{
    $editor = false;
    $caption = '';
    $x22 = false;
    $xv = str_replace('XOOPS ', '', XOOPS_VERSION);
    if (substr($xv, 2, 1) == '2') {
        $x22 = true;
    }
    $editor_configs = array();
    $editor_configs["name"] = $name;
    $editor_configs["value"] = $value;
    $editor_configs["rows"] = 15;
    $editor_configs["cols"] = 50;
    $editor_configs["width"] = $width;
    $editor_configs["height"] = $height;
    include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
    switch (strtolower($type)) {
        case "spaw":
            if (!$x22) {
                if (is_readable(XOOPS_ROOT_PATH . "/class/spaw/formspaw.php")) {
                    include_once XOOPS_ROOT_PATH . "/class/spaw/formspaw.php";
                    $editor = new XoopsFormSpaw($caption, $name, $value);
                }
            } else {
                $editor = new XoopsFormEditor($caption, "spaw", $editor_configs);
            }
            break;
        case "fck":
            if (!$x22) {
                if (is_readable(XOOPS_ROOT_PATH . "/class/fckeditor/formfckeditor.php")) {
                    include_once XOOPS_ROOT_PATH . "/class/fckeditor/formfckeditor.php";
                    $editor = new XoopsFormFckeditor($caption, $name, $value);
                }
            } else {
                $editor = new XoopsFormEditor($caption, "fckeditor", $editor_configs);
            }
            break;
        case "htmlarea":
            if (!$x22) {
                if (is_readable(XOOPS_ROOT_PATH . "/class/htmlarea/formhtmlarea.php")) {
                    include_once XOOPS_ROOT_PATH . "/class/htmlarea/formhtmlarea.php";
                    $editor = new XoopsFormHtmlarea($caption, $name, $value);
                }
            } else {
                $editor = new XoopsFormEditor($caption, "htmlarea", $editor_configs);
            }
            break;
        case "dhtml":
            if (!$x22) {
                $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 50, $supplemental);
            } else {
                $editor = new XoopsFormEditor($caption, "dhtmltextarea", $editor_configs);
            }
            break;
        case "textarea":
            $editor = new XoopsFormTextArea($caption, $name, $value);
            break;
        case "koivi":
            if (!$x22) {
                if (is_readable(XOOPS_ROOT_PATH . "/class/wysiwyg/formwysiwygtextarea.php")) {
                    include_once XOOPS_ROOT_PATH . "/class/wysiwyg/formwysiwygtextarea.php";
                    $editor = new XoopsFormWysiwygTextArea($caption, $name, $value, '100%', '400px', '');
                }
            } else {
                $editor = new XoopsFormEditor($caption, "koivi", $editor_configs);
            }
            break;
    }
    return $editor->render();
}