Example #1
0
function _moduleContent(&$smarty, $module_name)
{
    //include module files
    require_once "modules/{$module_name}/configs/default.conf.php";
    require_once "modules/{$module_name}/libs/paloSantoDataFormList.class.php";
    load_language_module($module_name);
    //folder path for custom templates
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $templates_dir = isset($arrConfig['templates_dir']) ? $arrConfig['templates_dir'] : 'themes';
    $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConfig['theme'];
    // Definición del formulario de nueva formulario
    $smarty->assign("MODULE_NAME", $module_name);
    $script = "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"libs/js/jscalendar/calendar-win2k-2.css\" />\n    <script type=\"text/javascript\" src=\"libs/js/jscalendar/calendar.js\"></script>\n    <script type=\"text/javascript\" src=\"libs/js/jscalendar/lang/calendar-en.js\"></script>\n    <script type=\"text/javascript\" src=\"libs/js/jscalendar/calendar-setup.js\"></script>";
    $smarty->assign("HEADER", $script);
    //Definicion de campos
    $formCampos = array('form_nombre' => array("LABEL" => _tr("Form Name"), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => array("size" => "40"), "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), 'form_description' => array("LABEL" => _tr("Form Description"), "REQUIRED" => "no", "INPUT_TYPE" => "TEXTAREA", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "COLS" => "33", "ROWS" => "2"));
    $smarty->assign("type", _tr('Type'));
    $smarty->assign("select_type", "type");
    $smarty->assign("option_type", array("VALUE" => array("LABEL", "TEXT", "LIST", "DATE", "TEXTAREA"), "NAME" => array(_tr("Type Label"), _tr("Type Text"), _tr("Type List"), _tr("Type Date"), _tr("Type Text Area")), "SELECTED" => "Text"));
    $smarty->assign("item_list", _tr('List Item'));
    $oForm = new paloForm($smarty, $formCampos);
    $pDB = new paloDB($arrConfig['cadena_dsn']);
    if (!is_object($pDB->conn) || $pDB->errMsg != "") {
        $smarty->assign("mb_message", _tr("Error when connecting to database") . " " . $pDB->errMsg);
    }
    if (isset($_GET['id']) && isset($_GET['action']) && $_GET['action'] == "preview") {
        $contenidoModulo = preview_form($pDB, $smarty, $module_name, $local_templates_dir, $formCampos, $oForm);
    } else {
        $contenidoModulo = listadoForm($pDB, $smarty, $module_name, $local_templates_dir);
    }
    return $contenidoModulo;
}
Example #2
0
function _moduleContent(&$smarty, $module_name)
{
    //include module files
    include_once "modules/{$module_name}/configs/default.conf.php";
    global $arrConf;
    $arrConf['cadena_dsn'] = "mysql://*****:*****@localhost/hispana";
    // _pre($arrConf);
    // _pre($_SESSION);
    /*
        global $arrLang;
    
        #incluir el archivo de idioma de acuerdo al que este seleccionado
        #si el archivo de idioma no existe incluir el idioma por defecto
        $lang=get_language();
    
        $script_dir=dirname($_SERVER['SCRIPT_FILENAME']);
    
        // Include language file for EN, then for local, and merge the two.
        include_once("modules/$module_name/lang/en.lang");
        $lang_file="modules/$module_name/lang/$lang.lang";
        if (file_exists("$script_dir/$lang_file")) {
            $arrLangModuleEN = $arrLangModule;
            include_once($lang_file);
            $arrLangModule = array_merge($arrLangModuleEN, $arrLangModule);
        }
    */
    load_language_module($module_name);
    require_once "modules/{$module_name}/libs/paloSantoDataForm.class.php";
    //folder path for custom templates
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $templates_dir = isset($arrConfig['templates_dir']) ? $arrConfig['templates_dir'] : 'themes';
    $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme'];
    // Definición del formulario de nueva formulario
    $smarty->assign("MODULE_NAME", $module_name);
    $smarty->assign("REQUIRED_FIELD", _tr('Required field'));
    $smarty->assign("CANCEL", _tr('Cancel'));
    $smarty->assign("APPLY_CHANGES", _tr('Apply changes'));
    $smarty->assign("SAVE", _tr('Save'));
    $smarty->assign("EDIT", _tr('Edit'));
    $smarty->assign("DESCATIVATE", _tr('Desactivate'));
    $smarty->assign("DELETE", _tr('Delete'));
    $smarty->assign("CONFIRM_CONTINUE", _tr('Are you sure you wish to continue?'));
    $smarty->assign("new_field", _tr('New Field'));
    $smarty->assign("add_field", _tr('Add Field'));
    $smarty->assign("update_field", _tr('Update Field'));
    $smarty->assign("CONFIRM_DELETE", _tr('Are you sure you wish to delete form?'));
    //Definicion de campos
    $formCampos = array('form_nombre' => array("LABEL" => _tr('Form Name'), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => array("size" => "60"), "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), 'form_description' => array("LABEL" => _tr('Form Description'), "REQUIRED" => "no", "INPUT_TYPE" => "TEXTAREA", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "COLS" => "33", "ROWS" => "2"), 'field_nombre' => array("LABEL" => _tr('Field Name'), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXTAREA", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "COLS" => "50", "ROWS" => "2"), "order" => array("LABEL" => _tr('Order'), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => array("size" => "3"), "VALIDATION_TYPE" => "numeric", "VALIDATION_EXTRA_PARAM" => ""));
    $smarty->assign("type", _tr('Type'));
    $smarty->assign("select_type", "type");
    $arr_type = array("VALUE" => array("TEXT", "LIST", "DATE", "TEXTAREA", "LABEL"), "NAME" => array(_tr('Type Text'), _tr('Type List'), _tr('Type Date'), _tr('Type Text Area'), _tr('Type Label')), "SELECTED" => "TEXT");
    $smarty->assign("option_type", $arr_type);
    $smarty->assign("item_list", _tr('List Item'));
    $smarty->assign("agregar", _tr('Add Item'));
    $smarty->assign("quitar", _tr('Remove Item'));
    $oForm = new paloForm($smarty, $formCampos);
    // print_r($_SESSION['ayuda']);
    $xajax = new xajax();
    $xajax->registerFunction("agregar_campos_formulario");
    $xajax->registerFunction("cancelar_formulario_ingreso");
    $xajax->registerFunction("guardar_formulario");
    $xajax->registerFunction("eliminar_campos_formulario");
    $xajax->registerFunction("editar_campo_formulario");
    $xajax->registerFunction("update_campo_formulario");
    $xajax->registerFunction("cancel_campo_formulario");
    $xajax->registerFunction("desactivar_formulario");
    $xajax->processRequests();
    $smarty->assign("xajax_javascript", $xajax->printJavascript("libs/xajax/"));
    $pDB = new paloDB($arrConf['cadena_dsn']);
    if (!is_object($pDB->conn) || $pDB->errMsg != "") {
        $smarty->assign("mb_message", _tr('Error when connecting to database') . " " . $pDB->errMsg);
    }
    if (isset($_POST['submit_create_form'])) {
        $contenidoModulo = new_form($pDB, $smarty, $module_name, $local_templates_dir, $formCampos, $oForm);
    } else {
        if (isset($_POST['edit'])) {
            $contenidoModulo = edit_form($pDB, $smarty, $module_name, $local_templates_dir, $formCampos, $oForm);
        } else {
            if (isset($_POST['delete'])) {
                $contenidoModulo = delete_form($pDB, $smarty, $module_name, $local_templates_dir, $formCampos, $oForm);
            } else {
                if (isset($_GET['id']) && isset($_GET['action']) && $_GET['action'] == "view") {
                    $contenidoModulo = view_form($pDB, $smarty, $module_name, $local_templates_dir, $formCampos, $oForm);
                } else {
                    if (isset($_GET['id']) && isset($_GET['action']) && $_GET['action'] == "activar") {
                        $contenidoModulo = activar_form($pDB, $smarty, $module_name, $local_templates_dir, $formCampos, $oForm);
                    } else {
                        if (isset($_GET['id']) && isset($_GET['action']) && $_GET['action'] == "editarCampo") {
                            $contenidoModulo = editar_campo_status($pDB, $smarty, $module_name, $local_templates_dir, $formCampos, $oForm);
                        } else {
                            $contenidoModulo = listadoForm($pDB, $smarty, $module_name, $local_templates_dir);
                        }
                    }
                }
            }
        }
    }
    return $contenidoModulo;
}