From: <txm...@us...> - 2012-06-22 13:55:54
|
Revision: 9687 http://xoops.svn.sourceforge.net/xoops/?rev=9687&view=rev Author: txmodxoops Date: 2012-06-22 13:55:42 +0000 (Fri, 22 Jun 2012) Log Message: ----------- Added Admin Class buttons No next revision Added Paths: ----------- XoopsModules/xforms/branches/timgno/ XoopsModules/xforms/branches/timgno/xforms/ XoopsModules/xforms/branches/timgno/xforms/admin/ XoopsModules/xforms/branches/timgno/xforms/admin/about.php XoopsModules/xforms/branches/timgno/xforms/admin/admin_footer.php XoopsModules/xforms/branches/timgno/xforms/admin/admin_header.php XoopsModules/xforms/branches/timgno/xforms/admin/default_elements.php XoopsModules/xforms/branches/timgno/xforms/admin/editelement.php XoopsModules/xforms/branches/timgno/xforms/admin/ele_check.php XoopsModules/xforms/branches/timgno/xforms/admin/ele_html.php XoopsModules/xforms/branches/timgno/xforms/admin/ele_radio.php XoopsModules/xforms/branches/timgno/xforms/admin/ele_select.php XoopsModules/xforms/branches/timgno/xforms/admin/ele_tarea.php XoopsModules/xforms/branches/timgno/xforms/admin/ele_text.php XoopsModules/xforms/branches/timgno/xforms/admin/ele_upload.php XoopsModules/xforms/branches/timgno/xforms/admin/ele_uploadimg.php XoopsModules/xforms/branches/timgno/xforms/admin/ele_yn.php XoopsModules/xforms/branches/timgno/xforms/admin/elements.php XoopsModules/xforms/branches/timgno/xforms/admin/file.php XoopsModules/xforms/branches/timgno/xforms/admin/index.php XoopsModules/xforms/branches/timgno/xforms/admin/main.php XoopsModules/xforms/branches/timgno/xforms/admin/menu.php XoopsModules/xforms/branches/timgno/xforms/admin/upgrade.php XoopsModules/xforms/branches/timgno/xforms/class/ XoopsModules/xforms/branches/timgno/xforms/class/elementrenderer.php XoopsModules/xforms/branches/timgno/xforms/class/elements.php XoopsModules/xforms/branches/timgno/xforms/class/forms.php XoopsModules/xforms/branches/timgno/xforms/class/index.html XoopsModules/xforms/branches/timgno/xforms/class/uploader.php XoopsModules/xforms/branches/timgno/xforms/docs/ XoopsModules/xforms/branches/timgno/xforms/docs/changelog.txt XoopsModules/xforms/branches/timgno/xforms/docs/credits.txt XoopsModules/xforms/branches/timgno/xforms/docs/index.html XoopsModules/xforms/branches/timgno/xforms/docs/install.txt XoopsModules/xforms/branches/timgno/xforms/docs/lang_diff.txt XoopsModules/xforms/branches/timgno/xforms/docs/licence.txt XoopsModules/xforms/branches/timgno/xforms/docs/readme.txt XoopsModules/xforms/branches/timgno/xforms/header.php XoopsModules/xforms/branches/timgno/xforms/images/ XoopsModules/xforms/branches/timgno/xforms/images/index.html XoopsModules/xforms/branches/timgno/xforms/images/xforms.png XoopsModules/xforms/branches/timgno/xforms/include/ XoopsModules/xforms/branches/timgno/xforms/include/common.php XoopsModules/xforms/branches/timgno/xforms/include/form_execute.php XoopsModules/xforms/branches/timgno/xforms/include/form_render.php XoopsModules/xforms/branches/timgno/xforms/include/functions.php XoopsModules/xforms/branches/timgno/xforms/include/index.html XoopsModules/xforms/branches/timgno/xforms/index.php XoopsModules/xforms/branches/timgno/xforms/language/ XoopsModules/xforms/branches/timgno/xforms/language/english/ XoopsModules/xforms/branches/timgno/xforms/language/english/admin.php XoopsModules/xforms/branches/timgno/xforms/language/english/help/ XoopsModules/xforms/branches/timgno/xforms/language/english/help/help.html XoopsModules/xforms/branches/timgno/xforms/language/english/help/index.html XoopsModules/xforms/branches/timgno/xforms/language/english/index.html XoopsModules/xforms/branches/timgno/xforms/language/english/mail_template/ XoopsModules/xforms/branches/timgno/xforms/language/english/mail_template/index.html XoopsModules/xforms/branches/timgno/xforms/language/english/mail_template/xforms.tpl XoopsModules/xforms/branches/timgno/xforms/language/english/main.php XoopsModules/xforms/branches/timgno/xforms/language/english/modinfo.php XoopsModules/xforms/branches/timgno/xforms/language/index.html XoopsModules/xforms/branches/timgno/xforms/sql/ XoopsModules/xforms/branches/timgno/xforms/sql/index.html XoopsModules/xforms/branches/timgno/xforms/sql/mysql.sql XoopsModules/xforms/branches/timgno/xforms/templates/ XoopsModules/xforms/branches/timgno/xforms/templates/index.html XoopsModules/xforms/branches/timgno/xforms/templates/xforms_error.html XoopsModules/xforms/branches/timgno/xforms/templates/xforms_form.html XoopsModules/xforms/branches/timgno/xforms/templates/xforms_index.html XoopsModules/xforms/branches/timgno/xforms/xoops_version.php Added: XoopsModules/xforms/branches/timgno/xforms/admin/about.php =================================================================== --- XoopsModules/xforms/branches/timgno/xforms/admin/about.php (rev 0) +++ XoopsModules/xforms/branches/timgno/xforms/admin/about.php 2012-06-22 13:55:42 UTC (rev 9687) @@ -0,0 +1,29 @@ +<?php +/** + * XoopsPartners module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * +* @copyright The XOOPS Project (http://www.xoops.org) + * @license {@link http://www.gnu.org/licenses/gpl-2.0.html GNU Public License} + * @package XoopsPartners + * @since 2.5.0 + * @author Mage, Mamba + * @version $Id $ + **/ + + include_once dirname(__FILE__) . '/admin_header.php'; + +xoops_cp_header(); + +$aboutAdmin = new ModuleAdmin(); + +echo $aboutAdmin->addNavigation('about.php'); +echo $aboutAdmin->renderAbout('6KJ7RW5DR3VTJ', false); + +include 'admin_footer.php'; \ No newline at end of file Added: XoopsModules/xforms/branches/timgno/xforms/admin/admin_footer.php =================================================================== --- XoopsModules/xforms/branches/timgno/xforms/admin/admin_footer.php (rev 0) +++ XoopsModules/xforms/branches/timgno/xforms/admin/admin_footer.php 2012-06-22 13:55:42 UTC (rev 9687) @@ -0,0 +1,28 @@ +<?php +/** + * xForms module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright:: The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license:: {@link http://www.gnu.org/licenses/gpl-2.0.html GNU Public License} + * @package:: xDirectory + * @subpackage:: admin + * @since: 2.5.0 + * @author:: XOOPS Development Team + * @version:: $Id $ +**/ + +echo "<div class='adminfooter'>\n" + ." <div style='text-align: center;'>\n" + ." <a href='http://www.xoops.org' target='_blank'><img src='{$pathIcon32}/xoopsmicrobutton.gif' alt='XOOPS' title='XOOPS'></a>\n" + ." </div>\n" + ." " . _AM_XFORMS_FOOTER . "\n" + ."</div>"; + +xoops_cp_footer(); \ No newline at end of file Added: XoopsModules/xforms/branches/timgno/xforms/admin/admin_header.php =================================================================== --- XoopsModules/xforms/branches/timgno/xforms/admin/admin_header.php (rev 0) +++ XoopsModules/xforms/branches/timgno/xforms/admin/admin_header.php 2012-06-22 13:55:42 UTC (rev 9687) @@ -0,0 +1,50 @@ +<?php +/** + * XoopsPartners module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright:: The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license:: {@link http://www.gnu.org/licenses/gpl-2.0.html GNU Public License} + * @package:: XoopsPartners + * @subpackage:: admin + * @since:: 2.5.0 + * @author:: XOOPS Team + * @version:: $Id $ +**/ +$path = dirname(dirname(dirname(dirname(__FILE__)))); +include_once $path . '/mainfile.php'; +require_once $path . '/include/cp_header.php'; + +include '../include/common.php'; +define('xforms_ADMIN_URL', xforms_URL.'admin/main.php'); +include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; + +global $xoopsModule; + +$thisModuleDir = $GLOBALS['xoopsModule']->getVar('dirname'); + +//if functions.php file exist +require_once dirname(dirname(__FILE__)) . '/include/functions.php'; + +// Load language files +xoops_loadLanguage('admin', $thisModuleDir); +xoops_loadLanguage('modinfo', $thisModuleDir); +xoops_loadLanguage('main', $thisModuleDir); + +$pathIcon16 = '../'.$xoopsModule->getInfo('icons16'); +$pathIcon32 = '../'.$xoopsModule->getInfo('icons32'); +$pathModuleAdmin = $xoopsModule->getInfo('dirmoduleadmin'); + +if ( file_exists($GLOBALS['xoops']->path($pathModuleAdmin.'/moduleadmin.php'))){ + include_once $GLOBALS['xoops']->path($pathModuleAdmin.'/moduleadmin.php'); +}else{ + redirect_header("../../../admin.php", 5, _AM_MODULEADMIN_MISSING, false); +} + +$adminMenu = new ModuleAdmin(); \ No newline at end of file Added: XoopsModules/xforms/branches/timgno/xforms/admin/default_elements.php =================================================================== --- XoopsModules/xforms/branches/timgno/xforms/admin/default_elements.php (rev 0) +++ XoopsModules/xforms/branches/timgno/xforms/admin/default_elements.php 2012-06-22 13:55:42 UTC (rev 9687) @@ -0,0 +1,41 @@ +<?php +############################################################################### +## See license.txt ## +############################################################################### +if( !defined('xforms_ROOT_PATH') ){ exit(); } + +$defaults = array(); +$defaults[0]['caption'] = 'Your name'; +$defaults[0]['req'] = true; +$defaults[0]['order'] = 1; +$defaults[0]['display'] = 1; +$defaults[0]['type'] = 'text'; +$defaults[0]['value'] = array( + 0 => $xoopsModuleConfig['t_width'], + 1 => $xoopsModuleConfig['t_max'], + 2 => '{UNAME}' + ); + +$defaults[1]['caption'] = 'Email address'; +$defaults[1]['req'] = true; +$defaults[1]['order'] = 2; +$defaults[1]['display'] = 1; +$defaults[1]['type'] = 'text'; +$defaults[1]['value'] = array( + 0 => $xoopsModuleConfig['t_width'], + 1 => $xoopsModuleConfig['t_max'], + 2 => '{EMAIL}' + ); + +$defaults[2]['caption'] = 'Your comments'; +$defaults[2]['req'] = true; +$defaults[2]['order'] = 3; +$defaults[2]['display'] = 1; +$defaults[2]['type'] = 'textarea'; +$defaults[2]['value'] = array( + 0 => '', + 1 => $xoopsModuleConfig['ta_rows'], + 2 => $xoopsModuleConfig['ta_cols'] + ); + +?> \ No newline at end of file Added: XoopsModules/xforms/branches/timgno/xforms/admin/editelement.php =================================================================== --- XoopsModules/xforms/branches/timgno/xforms/admin/editelement.php (rev 0) +++ XoopsModules/xforms/branches/timgno/xforms/admin/editelement.php 2012-06-22 13:55:42 UTC (rev 9687) @@ -0,0 +1,304 @@ +<?php +############################################################################### +## See license.txt ## +############################################################################### +include("admin_header.php"); +$xforms_ele_mgr = xoops_getmodulehandler('elements'); +include_once xforms_ROOT_PATH.'class/elementrenderer.php'; +define('_THIS_PAGE', xforms_URL.'admin/editelement.php'); +$myts = MyTextSanitizer::getInstance(); +if( $xforms_form_mgr->getCount() < 1 ){ + redirect_header(xforms_ADMIN_URL, 0, _AM_GO_CREATE_FORM); +} + +if( count($_POST) > 0 ){ + extract($_POST); +}else{ + extract($_GET); +} + +$op = isset($_GET['op']) ? trim($_GET['op']) : ''; +$op = isset($_POST['op']) ? trim($_POST['op']) : $op; +$clone = isset($_GET['clone']) ? intval($_GET['clone']) : 0; +$clone = isset($_POST['clone']) ? trim($_POST['clone']) : $clone; +$form_id = isset($_GET['form_id']) ? intval($_GET['form_id']) : 0; +$form_id = isset($_POST['form_id']) ? trim($_POST['form_id']) : $form_id; + +if( isset($_POST['submit']) && $_POST['submit'] == _AM_ELE_ADD_OPT_SUBMIT && intval($_POST['addopt']) > 0 ){ + $op = 'edit'; +} + +switch($op){ + case 'edit': + xoops_cp_header(); + if( !empty($ele_id) ){ + $element = $xforms_ele_mgr->get($ele_id); + $ele_type = $element->getVar('ele_type'); + $output_title = $clone ? _AM_ELE_CREATE : sprintf(_AM_ELE_EDIT, $element->getVar('ele_caption')); + }else{ + $element = $xforms_ele_mgr->create(); + $output_title = _AM_ELE_CREATE; + } + $output = new XoopsThemeForm($output_title, 'form_ele', _THIS_PAGE); + if( empty($addopt) ){ + $ele_caption = $clone ? sprintf(_AM_COPIED, $element->getVar('ele_caption', 'f')) : $element->getVar('ele_caption', 'f'); + $text_ele_caption = new XoopsFormText(_AM_ELE_CAPTION, 'ele_caption', 50, 255, $ele_caption); + $value = $element->getVar('ele_value', 'f'); + $req = $element->getVar('ele_req'); + $display = $element->getVar('ele_display'); + $order = $element->getVar('ele_order'); + }else{ + $ele_caption = $myts->makeTboxData4PreviewInForm($ele_caption); + $text_ele_caption = new XoopsFormText(_AM_ELE_CAPTION, 'ele_caption', 50, 255, $ele_caption); + $req = isset($_POST['ele_req']) ? 1 : 0; + $display = isset($_POST['ele_display']) ? 1 : 0; + $order = isset($_POST['ele_order']) ? intval($_POST['ele_order']) : 0; + } + $output->addElement($text_ele_caption); + + $check_ele_req = new XoopsFormCheckBox(_AM_ELE_REQ, 'ele_req', $req); + $check_ele_req->addOption(1, ' '); + $output->addElement($check_ele_req); + + $check_ele_display = new XoopsFormCheckBox(_AM_ELE_DISPLAY, 'ele_display', $display); + $check_ele_display->addOption(1, ' '); + $output->addElement($check_ele_display); + + $text_ele_order = new XoopsFormText(_AM_ELE_ORDER, 'ele_order', 3, 2, $order); + $output->addElement($text_ele_order); + + switch($ele_type){ + case 'text': + default: + include 'ele_text.php'; + break; + case 'textarea': + include 'ele_tarea.php'; + break; + case 'select': + include 'ele_select.php'; + break; + case 'checkbox': + include 'ele_check.php'; + break; + case 'radio': + include 'ele_radio.php'; + break; + case 'yn': + include 'ele_yn.php'; + break; + case 'html': + $check_ele_req->setExtra('disabled="disabled"'); + include 'ele_html.php'; + break; + case 'uploadimg': + include 'ele_uploadimg.php'; + break; + case 'upload': + include 'ele_upload.php'; + break; + } + + $hidden_op = new XoopsFormHidden('op', 'save'); + $hidden_type = new XoopsFormHidden('ele_type', $ele_type); + $output->addElement($hidden_op); + $output->addElement($hidden_type); + + if( $clone == true || empty($form_id) ){ + $select_apply_form = new XoopsFormSelect(_AM_ELE_APPLY_TO_FORM, 'form_id', $form_id); + $forms = $xforms_form_mgr->getObjects(null, 'form_id, form_title'); + foreach( $forms as $f ){ + $select_apply_form->addOption($f->getVar('form_id'), $f->getVar('form_title')); + } + $output->addElement($select_apply_form); + $hidden_clone = new XoopsFormHidden('clone', 1); + $output->addElement($hidden_clone); + }else{ + $hidden_form_id = new XoopsFormHidden('form_id', $form_id); + $output->addElement($hidden_form_id); + } + + if( !empty($ele_id) && !$clone ){ + $hidden_id = new XoopsFormHidden('ele_id', $ele_id); + $output->addElement($hidden_id); + } + $submit = new XoopsFormButton('', 'submit', _AM_SAVE, 'submit'); + $cancel = new XoopsFormButton('', 'cancel', _CANCEL, 'button'); + $cancel->setExtra('onclick="javascript:history.go(-1);"'); + $tray = new XoopsFormElementTray(''); + $tray->addElement($submit); + $tray->addElement($cancel); + $output->addElement($tray); + $output->display(); + break; + case 'delete': + if( empty($ele_id) ){ + redirect_header(xforms_ADMIN_URL, 0, _AM_NOTHING_SELECTED); + } + if( empty($_POST['ok']) ){ + //adminHtmlHeader(); + xoops_cp_header(); + xoops_confirm(array('op' => 'delete', 'ele_id' => $ele_id, 'form_id' => $form_id, 'ok' => 1), _THIS_PAGE, _AM_ELE_CONFIRM_DELETE); + }else{ + $element = $xforms_ele_mgr->get($ele_id); + $xforms_ele_mgr->delete($element); + redirect_header(xforms_URL.'admin/elements.php?form_id='.$form_id, 0, _AM_DBUPDATED); + } + break; + case 'save': + if( !empty($ele_id) ){ + $element = $xforms_ele_mgr->get($ele_id); + }else{ + $element = $xforms_ele_mgr->create(); + } + $element->setVar('form_id', $form_id); + $element->setVar('ele_caption', $ele_caption); + $req = !empty($ele_req) ? 1 : 0; + $element->setVar('ele_req', $req); + $order = empty($ele_order) ? 0 : intval($ele_order); + $element->setVar('ele_order', $order); + $display = !empty($ele_display) ? 1 : 0; + $element->setVar('ele_display', $display); + $element->setVar('ele_type', $ele_type); + $value = array(); + switch($ele_type){ + case 'text': + $value[] = !empty($ele_value[0]) ? intval($ele_value[0]) : $xoopsModuleConfig['t_width']; + $value[] = !empty($ele_value[1]) ? intval($ele_value[1]) : $xoopsModuleConfig['t_max']; + $value[] = $ele_value[2]; + break; + case 'textarea': + case 'html': + $value[] = $ele_value[0]; + if( intval($ele_value[1]) != 0 ){ + $value[] = intval($ele_value[1]); + }else{ + $value[] = $xoopsModuleConfig['ta_rows']; + } + if( intval($ele_value[2]) != 0 ){ + $value[] = intval($ele_value[2]); + }else{ + $value[] = $xoopsModuleConfig['ta_cols']; + } + break; + case 'select': + $value[0] = $ele_value[0]>1 ? intval($ele_value[0]) : 1; + $value[1] = !empty($ele_value[1]) ? 1 : 0; + $v2 = array(); + $multi_flag = 1; + while( $v = each($ele_value[2]) ){ + if( !empty($v['value']) ){ + if( $value[1] == 1 || $multi_flag ){ + if( $checked[$v['key']] == 1 ){ + $check = 1; + $multi_flag = 0; + }else{ + $check = 0; + } + }else{ + $check = 0; + } + $v2[$v['value']] = $check; + } + } + $value[2] = $v2; + break; + case 'checkbox': + while( $v = each($ele_value) ){ + if( !empty($v['value']) ){ + if( $checked[$v['key']] == 1 ){ + $check = 1; + }else{ + $check = 0; + } + $value[$v['value']] = $check; + } + } + break; + case 'radio': + while( $v = each($ele_value) ){ + if( !empty($v['value']) ){ + if( $checked == $v['key'] ){ + $value[$v['value']] = 1; + }else{ + $value[$v['value']] = 0; + } + } + } + break; + case 'yn': + if( $ele_value == '_NO' ){ + $value = array('_YES'=>0,'_NO'=>1); + }else{ + $value = array('_YES'=>1,'_NO'=>0); + } + break; + case 'uploadimg': + $value[] = intval($ele_value[0]); + $value[] = trim($ele_value[1]); + $value[] = trim($ele_value[2]); + $value[] = $ele_value[3] != 1 ? 0 : 1; + $value[] = intval($ele_value[4]); + $value[] = intval($ele_value[5]); + break; + case 'upload': + $value[] = intval($ele_value[0]); + $value[] = trim($ele_value[1]); + $value[] = trim($ele_value[2]); + $value[] = $ele_value[3] != 1 ? 0 : 1; + break; + } + $element->setVar('ele_value', $value); + if( !$xforms_ele_mgr->insert($element) ){ + //adminHtmlHeader(); + xoops_cp_header(); + echo $element->getHtmlErrors(); + }else{ + redirect_header(xforms_URL.'admin/elements.php?form_id='.$form_id, 0, _AM_DBUPDATED); + } + break; + default: + xoops_cp_header(); + echo $adminMenu->addNavigation('editelement.php'); + $adminMenu->addItemButton(_AM_ELE_TEXT, _THIS_PAGE.'?op=edit&ele_type=text', 'add'); + $adminMenu->addItemButton(_AM_ELE_TAREA, _THIS_PAGE.'?op=edit&ele_type=textarea', 'add'); + $adminMenu->addItemButton(_AM_ELE_SELECT, _THIS_PAGE.'?op=edit&ele_type=select', 'add'); + $adminMenu->addItemButton(_AM_ELE_CHECK, _THIS_PAGE.'?op=edit&ele_type=checkbox', 'add'); + $adminMenu->addItemButton(_AM_ELE_RADIO, _THIS_PAGE.'?op=edit&ele_type=radio', 'add'); + $adminMenu->addItemButton(_AM_ELE_YN, _THIS_PAGE.'?op=edit&ele_type=yn', 'add'); + $adminMenu->addItemButton(_AM_ELE_HTML, _THIS_PAGE.'?op=edit&ele_type=html', 'add'); + $adminMenu->addItemButton(_AM_ELE_UPLOADIMG, _THIS_PAGE.'?op=edit&ele_type=uploadimg', 'add'); + $adminMenu->addItemButton(_AM_ELE_UPLOADFILE, _THIS_PAGE.'?op=edit&ele_type=upload', 'add'); + echo $adminMenu->renderButton(); + + break; +} +include 'admin_footer.php'; +xoops_cp_footer(); + + +function addOption($id1, $id2, $text='', $type='check', $checked=null){ + $d = new XoopsFormText('', $id1, 40, 255, $text); + if( $type == 'check' ){ + $c = new XoopsFormCheckBox('', $id2, $checked); + $c->addOption(1, ' '); + }else{ + $c = new XoopsFormRadio('', 'checked', $checked); + $c->addOption($id2, ' '); + } + $t = new XoopsFormElementTray(''); + $t->addElement($c); + $t->addElement($d); + return $t; +} + +function addOptionsTray(){ + $t = new XoopsFormText('', 'addopt', 3, 2); + $l = new XoopsFormLabel('', sprintf(_AM_ELE_ADD_OPT, $t->render())); + $b = new XoopsFormButton('', 'submit', _AM_ELE_ADD_OPT_SUBMIT, 'submit'); + $r = new XoopsFormElementTray(''); + $r->addElement($l); + $r->addElement($b); + return $r; +} +?> \ No newline at end of file Added: XoopsModules/xforms/branches/timgno/xforms/admin/ele_check.php =================================================================== --- XoopsModules/xforms/branches/timgno/xforms/admin/ele_check.php (rev 0) +++ XoopsModules/xforms/branches/timgno/xforms/admin/ele_check.php 2012-06-22 13:55:42 UTC (rev 9687) @@ -0,0 +1,40 @@ +<?php +############################################################################### +## See license.txt ## +############################################################################### +if( !defined('xforms_ROOT_PATH') ){ exit(); } + +$options = array(); +$opt_count = 0; +if( empty($addopt) && !empty($ele_id) ){ + $keys = array_keys($value); + for( $i=0; $i<count($keys); $i++ ){ + $v = $myts->makeTboxData4PreviewInForm($keys[$i]); + $options[] = addOption('ele_value['.$opt_count.']', 'checked['.$opt_count.']', $v, 'check', $value[$keys[$i]]); + $opt_count++; + } +}else{ + if( isset($ele_value) && count($ele_value) > 0 ){ + while( $v = each($ele_value) ){ + $v['value'] = $myts->makeTboxData4PreviewInForm($v['value']); + if( !empty($v['value']) ){ + $options[] = addOption('ele_value['.$opt_count.']', 'checked['.$opt_count.']', $v['value'], 'check', $checked[$v['key']]); + $opt_count++; + } + } + } + $addopt = empty($addopt) ? 2 : $addopt; + for( $i=0; $i<$addopt; $i++ ){ + $options[] = addOption('ele_value['.$opt_count.']', 'checked['.$opt_count.']'); + $opt_count++; + } +} +$add_opt = addOptionsTray(); +$options[] = $add_opt; +$opt_tray = new XoopsFormElementTray(_AM_ELE_OPT, '<br />'); +$opt_tray->setDescription(_AM_ELE_OPT_DESC.'<br /><br />'._AM_ELE_OTHER); +for( $i=0; $i<count($options); $i++ ){ + $opt_tray->addElement($options[$i]); +} +$output->addElement($opt_tray); +?> \ No newline at end of file Added: XoopsModules/xforms/branches/timgno/xforms/admin/ele_html.php =================================================================== --- XoopsModules/xforms/branches/timgno/xforms/admin/ele_html.php (rev 0) +++ XoopsModules/xforms/branches/timgno/xforms/admin/ele_html.php 2012-06-22 13:55:42 UTC (rev 9687) @@ -0,0 +1,15 @@ +<?php +############################################################################### +## See license.txt ## +############################################################################### +if( !defined('xforms_ROOT_PATH') ){ exit(); } + +$rows = !empty($value[1]) ? $value[1] : $xoopsModuleConfig['ta_rows']; +$cols = !empty($value[2]) ? $value[2] : $xoopsModuleConfig['ta_cols']; +$rows = new XoopsFormText(_AM_ELE_ROWS, 'ele_value[1]', 3, 3, $rows); +$cols = new XoopsFormText(_AM_ELE_COLS, 'ele_value[2]', 3, 3, $cols); +$default = new XoopsFormDhtmlTextArea(_AM_ELE_DEFAULT, 'ele_value[0]', isset($value[0]) ? $myts->htmlspecialchars($myts->stripSlashesGPC($value[0])) : '', 10, 50); +$output->addElement($rows, 1); +$output->addElement($cols, 1); +$output->addElement($default); +?> \ No newline at end of file Added: XoopsModules/xforms/branches/timgno/xforms/admin/ele_radio.php =================================================================== --- XoopsModules/xforms/branches/timgno/xforms/admin/ele_radio.php (rev 0) +++ XoopsModules/xforms/branches/timgno/xforms/admin/ele_radio.php 2012-06-22 13:55:42 UTC (rev 9687) @@ -0,0 +1,41 @@ +<?php +############################################################################### +## See license.txt ## +############################################################################### +if( !defined('xforms_ROOT_PATH') ){ exit(); } + +$options = array(); +$opt_count = 0; +if( empty($addopt) && !empty($ele_id) ){ + $keys = array_keys($value); + for( $i=0; $i<count($keys); $i++ ){ + $r = $value[$keys[$i]] ? $opt_count : null; + $v = $myts->makeTboxData4PreviewInForm($keys[$i]); + $options[] = addOption('ele_value['.$opt_count.']', $opt_count, $v, 'radio', $r); + $opt_count++; + } +}else{ + if( isset($ele_value) && count($ele_value) > 0 ){ + while( $v = each($ele_value) ){ + $v['value'] = $myts->makeTboxData4PreviewInForm($v['value']); + if( !empty($v['value']) ){ + $r = ($checked == $opt_count) ? $opt_count : null; + $options[] = addOption('ele_value['.$opt_count.']', $opt_count, $v['value'], 'radio', $r); + $opt_count++; + } + } + } + $addopt = empty($addopt) ? 2 : $addopt; + for( $i=0; $i<$addopt; $i++ ){ + $options[] = addOption('ele_value['.$opt_count.']', $opt_count, '', 'radio'); + $opt_count++; + } +} +$options[] = addOptionsTray(); +$opt_tray = new XoopsFormElementTray(_AM_ELE_OPT, '<br />'); +$opt_tray->setDescription(_AM_ELE_OPT_DESC2.'<br /><br />'._AM_ELE_OTHER); +for( $i=0; $i<count($options); $i++ ){ + $opt_tray->addElement($options[$i]); +} +$output->addElement($opt_tray); +?> \ No newline at end of file Added: XoopsModules/xforms/branches/timgno/xforms/admin/ele_select.php =================================================================== --- XoopsModules/xforms/branches/timgno/xforms/admin/ele_select.php (rev 0) +++ XoopsModules/xforms/branches/timgno/xforms/admin/ele_select.php 2012-06-22 13:55:42 UTC (rev 9687) @@ -0,0 +1,52 @@ +<?php +############################################################################### +## See license.txt ## +############################################################################### +if( !defined('xforms_ROOT_PATH') ){ exit(); } + +if( empty($addopt) && !empty($ele_id) ){ + $ele_value = $element->getVar('ele_value'); +} +$ele_size = !empty($ele_value[0]) ? $ele_value[0] : 1; +$size = new XoopsFormText(_AM_ELE_SIZE, 'ele_value[0]', 3, 2, $ele_size); +$allow_multi = empty($ele_value[1]) ? 0 : 1; +$multiple = new XoopsFormRadioYN(_AM_ELE_MULTIPLE, 'ele_value[1]', $allow_multi); + +$options = array(); +$opt_count = 0; +if( empty($addopt) && !empty($ele_id) ){ + $keys = array_keys($ele_value[2]); + for( $i=0; $i<count($keys); $i++ ){ + $v = $myts->makeTboxData4PreviewInForm($keys[$i]); + $options[] = addOption('ele_value[2]['.$opt_count.']', 'checked['.$opt_count.']', $v, 'check', $ele_value[2][$keys[$i]]); + $opt_count++; + } +}else{ + if( !empty($ele_value[2]) ){ + while( $v = each($ele_value[2]) ){ + $v['value'] = $myts->makeTboxData4PreviewInForm($v['value']); + if( !empty($v['value']) ){ + $options[] = addOption('ele_value[2]['.$opt_count.']', 'checked['.$opt_count.']', $v['value'], 'check', $checked[$v['key']]); + $opt_count++; + } + } + } + $addopt = empty($addopt) ? 2 : $addopt; + for( $i=0; $i<$addopt; $i++ ){ + $options[] = addOption('ele_value[2]['.$opt_count.']', 'checked['.$opt_count.']'); + $opt_count++; + } +} + +$add_opt = addOptionsTray(); +$options[] = $add_opt; + +$opt_tray = new XoopsFormElementTray(_AM_ELE_OPT, '<br />'); +$opt_tray->setDescription(_AM_ELE_OPT_DESC._AM_ELE_OPT_DESC1); +for( $i=0; $i<count($options); $i++ ){ + $opt_tray->addElement($options[$i]); +} +$output->addElement($size, 1); +$output->addElement($multiple); +$output->addElement($opt_tray); +?> \ No newline at end of file Added: XoopsModules/xforms/branches/timgno/xforms/admin/ele_tarea.php =================================================================== --- XoopsModules/xforms/branches/timgno/xforms/admin/ele_tarea.php (rev 0) +++ XoopsModules/xforms/branches/timgno/xforms/admin/ele_tarea.php 2012-06-22 13:55:42 UTC (rev 9687) @@ -0,0 +1,16 @@ +<?php +############################################################################### +## See license.txt ## +############################################################################### +if( !defined('xforms_ROOT_PATH') ){ exit(); } + +$rows = !empty($value[1]) ? $value[1] : $xoopsModuleConfig['ta_rows']; +$cols = !empty($value[2]) ? $value[2] : $xoopsModuleConfig['ta_cols']; +$rows = new XoopsFormText(_AM_ELE_ROWS, 'ele_value[1]', 3, 3, $rows); +$cols = new XoopsFormText(_AM_ELE_COLS, 'ele_value[2]', 3, 3, $cols); +$default = new XoopsFormTextArea(_AM_ELE_DEFAULT, 'ele_value[0]', isset($value[0]) ? $myts->htmlspecialchars($myts->stripSlashesGPC($value[0])) : '', 5, 50); +$output->addElement($rows, 1); +$output->addElement($cols, 1); +$output->addElement($default); + +?> \ No newline at end of file Added: XoopsModules/xforms/branches/timgno/xforms/admin/ele_text.php =================================================================== --- XoopsModules/xforms/branches/timgno/xforms/admin/ele_text.php (rev 0) +++ XoopsModules/xforms/branches/timgno/xforms/admin/ele_text.php 2012-06-22 13:55:42 UTC (rev 9687) @@ -0,0 +1,17 @@ +<?php +############################################################################### +## See license.txt ## +############################################################################### +if( !defined('xforms_ROOT_PATH') ){ exit(); } + +$size = !empty($value[0]) ? intval($value[0]) : $xoopsModuleConfig['t_width']; +$max = !empty($value[1]) ? intval($value[1]) : $xoopsModuleConfig['t_max']; +$size = new XoopsFormText(_AM_ELE_SIZE, 'ele_value[0]', 3, 3, $size); +$max = new XoopsFormText(_AM_ELE_MAX_LENGTH, 'ele_value[1]', 3, 3, $max); +$default = new XoopsFormText(_AM_ELE_DEFAULT, 'ele_value[2]', 50, 255, $myts->htmlspecialchars($myts->stripSlashesGPC($value[2]))); +$default->setDescription(_AM_ELE_TEXT_DESC); +$output->addElement($size, 1); +$output->addElement($max, 1); +$output->addElement($default); + +?> \ No newline at end of file Added: XoopsModules/xforms/branches/timgno/xforms/admin/ele_upload.php =================================================================== --- XoopsModules/xforms/branches/timgno/xforms/admin/ele_upload.php (rev 0) +++ XoopsModules/xforms/branches/timgno/xforms/admin/ele_upload.php 2012-06-22 13:55:42 UTC (rev 9687) @@ -0,0 +1,27 @@ +<?php +############################################################################### +## See license.txt ## +############################################################################### +if( !defined('xforms_ROOT_PATH') ){ exit(); } + +$size = !empty($value[0]) ? intval($value[0]) : 0; +$saveas = $value[3] != 1 ? 0 : 1; + +$size = new XoopsFormText(_AM_ELE_UPLOAD_MAXSIZE, 'ele_value[0]', 10, 20, $size); +$size->setDescription(_AM_ELE_UPLOAD_MAXSIZE_DESC.'<br />'._AM_ELE_UPLOAD_DESC_SIZE_NOLIMIT); + +$ext = new XoopsFormText(_AM_ELE_UPLOAD_ALLOWED_EXT, 'ele_value[1]', 50, 255, isset($value[1]) ? $myts->htmlspecialchars($myts->stripSlashesGPC($value[1])) : ''); +$ext->setDescription(_AM_ELE_UPLOAD_ALLOWED_EXT_DESC.'<br /><br />'._AM_ELE_UPLOAD_DESC_NOLIMIT); + +$mime = new XoopsFormTextArea(_AM_ELE_UPLOAD_ALLOWED_MIME, 'ele_value[2]', isset($value[2]) ? $myts->htmlspecialchars($myts->stripSlashesGPC($value[2])) : '', 5, 50); +$mime->setDescription(_AM_ELE_UPLOAD_ALLOWED_MIME_DESC.'<br /><br />'._AM_ELE_UPLOAD_DESC_NOLIMIT); + +$saveas = new XoopsFormSelect(_AM_ELE_UPLOAD_SAVEAS, 'ele_value[3]', $saveas); +$saveas->addOptionArray(array(0=>_AM_ELE_UPLOAD_SAVEAS_MAIL, 1=>_AM_ELE_UPLOAD_SAVEAS_FILE)); + +$output->addElement($size, 1); +$output->addElement($ext); +$output->addElement($mime); +$output->addElement($saveas, 1); + +?> \ No newline at end of file Added: XoopsModules/xforms/branches/timgno/xforms/admin/ele_uploadimg.php =================================================================== --- XoopsModules/xforms/branches/timgno/xforms/admin/ele_uploadimg.php (rev 0) +++ XoopsModules/xforms/branches/timgno/xforms/admin/ele_uploadimg.php 2012-06-22 13:55:42 UTC (rev 9687) @@ -0,0 +1,39 @@ +<?php +############################################################################### +## See license.txt ## +############################################################################### +if( !defined('xforms_ROOT_PATH') ){ exit(); } + +$size = !empty($value[0]) ? intval($value[0]) : 0; +$ext = empty($ele_id) ? 'jpg|jpeg|gif|png|tif|tiff' : $value[1]; +$mime = empty($ele_id) ? 'image/jpeg|image/pjpeg|image/png|image/x-png|image/gif|image/tiff' : $value[2]; +$saveas = $value[3] != 1 ? 0 : 1; +$width = !empty($value[4]) ? intval($value[4]) : 0; +$height = !empty($value[5]) ? intval($value[5]) : 0; + +$size = new XoopsFormText(_AM_ELE_UPLOAD_MAXSIZE, 'ele_value[0]', 10, 20, $size); +$size->setDescription(_AM_ELE_UPLOAD_MAXSIZE_DESC.'<br />'._AM_ELE_UPLOAD_DESC_SIZE_NOLIMIT); + +$ext = new XoopsFormText(_AM_ELE_UPLOAD_ALLOWED_EXT, 'ele_value[1]', 50, 255, $myts->htmlspecialchars($myts->stripSlashesGPC($ext))); +$ext->setDescription(_AM_ELE_UPLOAD_ALLOWED_EXT_DESC.'<br /><br />'._AM_ELE_UPLOAD_DESC_NOLIMIT); + +$mime = new XoopsFormTextArea(_AM_ELE_UPLOAD_ALLOWED_MIME, 'ele_value[2]', $myts->htmlspecialchars($myts->stripSlashesGPC($mime)), 5, 50); +$mime->setDescription(_AM_ELE_UPLOAD_ALLOWED_MIME_DESC.'<br /><br />'._AM_ELE_UPLOAD_DESC_NOLIMIT); + +$saveas = new XoopsFormSelect(_AM_ELE_UPLOAD_SAVEAS, 'ele_value[3]', $saveas); +$saveas->addOptionArray(array(0=>_AM_ELE_UPLOAD_SAVEAS_MAIL, 1=>_AM_ELE_UPLOAD_SAVEAS_FILE)); + +$width = new XoopsFormText(_AM_ELE_UPLOADIMG_MAXWIDTH, 'ele_value[4]', 10, 20, $width); +$width->setDescription(_AM_ELE_UPLOAD_DESC_SIZE_NOLIMIT); + +$height = new XoopsFormText(_AM_ELE_UPLOADIMG_MAXHEIGHT, 'ele_value[5]',10, 20, $height); +$height->setDescription(_AM_ELE_UPLOAD_DESC_SIZE_NOLIMIT); + +$output->addElement($size, 1); +$output->addElement($ext); +$output->addElement($mime); +$output->addElement($saveas, 1); +$output->addElement($width, 1); +$output->addElement($height, 1); + +?> \ No newline at end of file Added: XoopsModules/xforms/branches/timgno/xforms/admin/ele_yn.php =================================================================== --- XoopsModules/xforms/branches/timgno/xforms/admin/ele_yn.php (rev 0) +++ XoopsModules/xforms/branches/timgno/xforms/admin/ele_yn.php 2012-06-22 13:55:42 UTC (rev 9687) @@ -0,0 +1,22 @@ +<?php +############################################################################### +## See license.txt ## +############################################################################### +if( !defined('xforms_ROOT_PATH') ){ exit(); } + +if( !empty($ele_id) ){ + if( $value['_YES'] == 1 ){ + $selected = '_YES'; + }else{ + $selected = '_NO'; + } +}else{ + $selected = '_YES'; +} +$options = new XoopsFormRadio(_AM_ELE_DEFAULT, 'ele_value', $selected); +$options->addOption('_YES', _YES); +$options->addOption('_NO', _NO); +$output->addElement($options); + + +?> \ No newline at end of file Added: XoopsModules/xforms/branches/timgno/xforms/admin/elements.php =================================================================== --- XoopsModules/xforms/branches/timgno/xforms/admin/elements.php (rev 0) +++ XoopsModules/xforms/branches/timgno/xforms/admin/elements.php 2012-06-22 13:55:42 UTC (rev 9687) @@ -0,0 +1,239 @@ +<?php +############################################################################### +## See license.txt ## +############################################################################### +include 'admin_header.php'; +$xforms_ele_mgr = xoops_getmodulehandler('elements'); +include_once xforms_ROOT_PATH.'class/elementrenderer.php'; +define('_THIS_PAGE', xforms_URL.'admin/elements.php'); +if( !isset($_POST['op']) || $_POST['op'] != 'save' ){ + $form_id = isset($_GET['form_id']) ? intval($_GET['form_id']) : 0; + if( empty($form_id) ){ + redirect_header(xforms_ADMIN_URL, 0, _AM_NOTHING_SELECTED); + } + $form = $xforms_form_mgr->get($form_id); + //adminHtmlHeader(); + xoops_cp_header(); + $jump = array(); + $jump[0] = new XoopsFormSelect('', 'ele_type'); + $jump[0]->addOptionArray(array('text' => _AM_ELE_TEXT, + 'textarea' => _AM_ELE_TAREA, + 'select' => _AM_ELE_SELECT, + 'checkbox' => _AM_ELE_CHECK, + 'radio' => _AM_ELE_RADIO, + 'yn' => _AM_ELE_YN, + 'html' => _AM_ELE_HTML, + 'uploadimg' => _AM_ELE_UPLOADIMG, + 'upload' => _AM_ELE_UPLOADFILE + )); + $jump[1] = new XoopsFormHidden('op', 'edit'); + $jump[2] = new XoopsFormHidden('form_id', $form_id); + $jump[3] = new XoopsFormButton('', 'submit', _GO, 'submit'); + echo '<div align="center"> + <form action="'.xforms_URL.'admin/editelement.php" method="post"> + <b>'._AM_ELE_CREATE.'</b>'; + foreach( $jump as $j ){ + echo "\n".$j->render(); + } + echo ' + </form> + </div> + <form action="'._THIS_PAGE.'" method="post"> + <table class="outer" cellspacing="1" width="100%"> + <tr><th colspan="6">'.sprintf(_AM_ELEMENTS_OF_FORM, $form->getVar('form_title')).'</th></tr> + <tr> + <td class="head" align="center" colspan="2">'._AM_ELE_CAPTION.' / '._AM_ELE_DEFAULT.'</td> + <td class="head" align="center">'._AM_ELE_REQ.'</td> + <td class="head" align="center">'._AM_ELE_ORDER.'</td> + <td class="head" align="center">'._AM_ELE_DISPLAY.'</td> + <td class="head" align="center">'._AM_ACTION.'</td> + </tr> + '; + $criteria = new Criteria('form_id', $form_id); + $criteria->setSort('ele_order'); + $criteria->setOrder('ASC'); + + if( $elements = $xforms_ele_mgr->getObjects($criteria) ){ + foreach( $elements as $i ){ + $id = $i->getVar('ele_id'); + $renderer = new xformsElementRenderer($i); + $ele_type = $i->getVar('ele_type'); + $req = $i->getVar('ele_req'); + $check_req = new XoopsFormCheckBox('', 'ele_req['.$id.']', $req); + $check_req->addOption(1, ' '); + $ele_value = $renderer->constructElement(true); + $order = $i->getVar('ele_order'); + $text_order = new XoopsFormText('', 'ele_order['.$id.']', 3, 2, $order); + $display = $i->getVar('ele_display'); + $check_display = new XoopsFormCheckBox('', 'ele_display['.$id.']', $display); + $check_display->addOption(1, ' '); + $hidden_id = new XoopsFormHidden('ele_id[]', $id); + echo '<tr>'; + echo '<td class="odd" colspan="2">'.$i->getVar('ele_caption')."</td>\n"; + echo '<td class="even" rowspan="2" align="center">'.$check_req->render()."</td>\n"; + echo '<td class="even" rowspan="2" align="center">'.$text_order->render()."</td>\n"; + echo '<td class="even" rowspan="2" align="center">'.$check_display->render().$hidden_id->render()."</td>\n"; + echo '<td class="even" align="center" nowrap="nowrap" rowspan="2"> + <a href="editelement.php?op=edit&ele_id='.$id.'&form_id='.$form_id.'"><img src='.$pathIcon16.'/edit.png title='._EDIT.'></a> + <a href="editelement.php?op=edit&ele_id='.$id.'&form_id='.$form_id.'&clone=1"><img src='.$pathIcon16.'/editcopy.png title='._CLONE.'></a> + <a href="editelement.php?op=delete&ele_id='.$id.'&form_id='.$form_id.'"><img src='.$pathIcon16.'/delete.png title='._DELETE.'></a></td>'; + echo '</tr>'; + echo '<tr><td class="even" colspan="2">'.$ele_value->render()."</td>\n</tr>"; + } + } + + $submit = new XoopsFormButton('', 'submit', _AM_SAVE, 'submit'); + $submit1 = new XoopsFormButton('', 'submit', _AM_SAVE_THEN_FORM, 'submit'); + $tray = new XoopsFormElementTray(''); + $tray->addElement($submit); + $tray->addElement($submit1); + echo ' + <tr> + <td class="foot" colspan="6" align="center">'.$tray->render().' + </tr> + </table> + '; + $hidden_op = new XoopsFormHidden('op', 'save'); + $hidden_form_id = new XoopsFormHidden('form_id', $form_id); + echo $hidden_op->render(); + echo $hidden_form_id->render(); + echo '</form>'; +}else{ + $form_id = isset($_POST['form_id']) ? intval($_POST['form_id']) : 0; + if( empty($form_id) ){ + redirect_header(xforms_ADMIN_URL, 0, _AM_NOTHING_SELECTED); + } + extract($_POST); + $error = ''; + foreach( $ele_id as $id ){ + $element = $xforms_ele_mgr->get($id); + $req = !empty($ele_req[$id]) ? 1 : 0; + $element->setVar('ele_req', $req); + $order = !empty($ele_order[$id]) ? intval($ele_order[$id]) : 0; + $element->setVar('ele_order', $order); + $display = !empty($ele_display[$id]) ? 1 : 0; + $element->setVar('ele_display', $display); + $type = $element->getVar('ele_type'); + $value = $element->getVar('ele_value'); + switch($type){ + case 'text': + $value[2] = $ele_value[$id]; + break; + case 'textarea': + case 'html': + $value[0] = $ele_value[$id]; + break; + case 'select': + $new_vars = array(); + $opt_count = 1; + if( isset($ele_value[$id]) ){ + if( is_array($ele_value[$id]) ){ + while( $j = each($value[2]) ){ + if( in_array($opt_count, $ele_value[$id]) ){ + $new_vars[$j['key']] = 1; + }else{ + $new_vars[$j['key']] = 0; + } + $opt_count++; + } + }else{ + if( count($value[2]) > 1 ){ + while( $j = each($value[2]) ){ + if( $opt_count == $ele_value[$id] ){ + $new_vars[$j['key']] = 1; + }else{ + $new_vars[$j['key']] = 0; + } + $opt_count++; + } + }else{ + while( $j = each($value[2]) ){ + if( !empty($ele_value[$id]) ){ + $new_vars = array($j['key']=>1); + }else{ + $new_vars = array($j['key']=>0); + } + } + } + } + $value[2] = $new_vars; + }else{ + foreach( $value[2] as $k => $v ){ + $value[2][$k] = 0; + } + } + break; + case 'checkbox': + $new_vars = array(); + $opt_count = 1; + if( isset($ele_value[$id]) && is_array($ele_value[$id]) ){ + while( $j = each($value) ){ + if( in_array($opt_count, $ele_value[$id]) ){ + $new_vars[$j['key']] = 1; + }else{ + $new_vars[$j['key']] = 0; + } + $opt_count++; + } + }else{ + if( count($value) > 1 ){ + while( $j = each($value) ){ + $new_vars[$j['key']] = 0; + } + }else{ + while( $j = each($value) ){ + if( !empty($ele_value[$id]) ){ + $new_vars = array($j['key']=>1); + }else{ + $new_vars = array($j['key']=>0); + } + } + } + } + $value = $new_vars; + break; + case 'radio': + case 'yn': + $new_vars = array(); + $i = 1; + while( $j = each($value) ){ + if( $ele_value[$id] == $i ){ + $new_vars[$j['key']] = 1; + }else{ + $new_vars[$j['key']] = 0; + } + $i++; + } + $value = $new_vars; + break; + case 'uploadimg': + $value[0] = intval($ele_value[$id][0]); + $value[4] = intval($ele_value[$id][4]); + $value[5] = intval($ele_value[$id][5]); + break; + case 'upload': + $value[0] = intval($ele_value[$id][0]); + break; + default: + break; + } + $element->setVar('ele_value', $value, true); + if( !$xforms_ele_mgr->insert($element) ){ + $error .= $element->getHtmlErrors(); + } + } + if( empty($error) ){ + if( $_POST['submit'] == _AM_SAVE_THEN_FORM ){ + redirect_header(xforms_ADMIN_URL.'?op=edit&form_id='.$form_id, 0, _AM_DBUPDATED); + }else{ + redirect_header(_THIS_PAGE.'?form_id='.$form_id, 0, _AM_DBUPDATED); + } + }else{ + //adminHtmlHeader(); + xoops_cp_header(); + echo $error; + } +} +include 'admin_footer.php'; +xoops_cp_footer(); +?> \ No newline at end of file Added: XoopsModules/xforms/branches/timgno/xforms/admin/file.php =================================================================== --- XoopsModules/xforms/branches/timgno/xforms/admin/file.php (rev 0) +++ XoopsModules/xforms/branches/timgno/xforms/admin/file.php 2012-06-22 13:55:42 UTC (rev 9687) @@ -0,0 +1,20 @@ +<?php +############################################################################### +## See license.txt ## +############################################################################### +include 'admin_header.php'; +$file = isset($_GET['f']) ? trim($_GET['f']) : ''; +$path = xforms_UPLOAD_PATH.$file; +if( !$file || !preg_match('/^[0-9]+_{1}[0-9a-z]+\.[0-9a-z]+$/', $file) || !file_exists($path) ){ + redirect_header(XOOPS_URL, 0, _AM_NOTHING_SELECTED); +} + +header("Content-Type: application/octet-stream"); +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header('Cache-Control: private, no-cache'); +header("Pragma: no-cache"); +header('Content-Disposition: attachment; filename="'.$file.'"'); +header("Content-Length: ".filesize($path)); + +readfile($path); +?> \ No newline at end of file Added: XoopsModules/xforms/branches/timgno/xforms/admin/index.php =================================================================== --- XoopsModules/xforms/branches/timgno/xforms/admin/index.php (rev 0) +++ XoopsModules/xforms/branches/timgno/xforms/admin/index.php 2012-06-22 13:55:42 UTC (rev 9687) @@ -0,0 +1,43 @@ +<?php +// $Id: index.php 8195 2011-11-07 02:45:44Z beckmi $ +// ------------------------------------------------------------------------ // +// XOOPS - PHP Content Management System // +// Copyright (c) 2000 XOOPS.org // +// <http://www.xoops.org/> // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Hacks provided by: Adam Frick // +// e-mail: afr...@ya... // +// Purpose: Create a yellow-page like business directory for xoops using // +// the mylinks module as the foundation. // +// ------------------------------------------------------------------------- // + +require_once '../../../include/cp_header.php'; +include_once 'admin_header.php'; + +xoops_cp_header(); + + $index_admin = new ModuleAdmin(); + echo $index_admin->addNavigation('index.php') ; + echo $index_admin->renderIndex(); + + +include "admin_footer.php"; \ No newline at end of file Added: XoopsModules/xforms/branches/timgno/xforms/admin/main.php =================================================================== --- XoopsModules/xforms/branches/timgno/xforms/admin/main.php (rev 0) +++ XoopsModules/xforms/branches/timgno/xforms/admin/main.php 2012-06-22 13:55:42 UTC (rev 9687) @@ -0,0 +1,290 @@ +<?php +############################################################################### +## See license.txt ## +############################################################################### +include 'admin_header.php'; +$myts = MyTextSanitizer::getInstance(); +$op = isset($_GET['op']) ? trim($_GET['op']) : 'list'; +$op = isset($_POST['op']) ? trim($_POST['op']) : $op; + +switch($op){ + case 'list': + default: + xoops_cp_header(); + echo $adminMenu->addNavigation('main.php'); + $adminMenu->addItemButton(_AM_FORM_NEW, 'main.php?op=edit', 'add'); + echo $adminMenu->renderButton(); + $criteria = new Criteria(1, 1); + $criteria->setSort('form_order'); + $criteria->setOrder('ASC'); + if( $forms = $xforms_form_mgr->getObjects($criteria, 'admin_list') ){ + echo '<form action="'.xforms_ADMIN_URL.'" method="post"> + <table class="outer" cellspacing="1" width="100%"> + <tr><th colspan="5">'._AM_FORM_LISTING.'</th></tr> + <tr> + <td class="head center">'._AM_ID.'</td> + <td class="head center">'._AM_FORM_ORDER.'<br />'._AM_FORM_ORDER_DESC.'</td> + <td class="head center">'._AM_FORM_TITLE.'</td> + <td class="head center">'._AM_FORM_SENDTO.'</td> + <td class="head center">'._AM_ACTION.'</td> + </tr>'; + foreach( $forms as $f ){ + $id = $f->getVar('form_id'); + $order = new XoopsFormText('', 'order['.$id.']', 3, 2, $f->getVar('form_order')); + $group_mgr = xoops_gethandler('group'); + $sendto = $f->getVar('form_send_to_group'); + if( false != $sendto && $group = $group_mgr->get($sendto) ){ + $sendto = $group->getVar('name'); + }else{ + $sendto = _AM_FORM_SENDTO_ADMIN; + } + $ids = new XoopsFormHidden('ids[]', $id); + echo ' + <tr> + <td class="odd center">'.$id.'</td> + <td class="even center">'.$order->render().'</td> + <td class="odd"><a target="_blank" href="'.xforms_URL.'?form_id='.$id.'">'.$f->getVar('form_title').'</a></td> + <td class="odd center">'.$sendto.'</td> + <td class="odd center"> + <a href="'.xforms_ADMIN_URL.'?op=edit&form_id='.$id.'"><img src='.$pathIcon16.'/edit.png title=' + ._AM_FORM_ACTION_EDITFORM.'alt='._AM_FORM_ACTION_EDITFORM.'></a> + <a href="elements.php?form_id='.$id.'"><img src='.$pathIcon16.'/1day.png title=' + ._AM_FORM_ACTION_EDITELEMENT.'alt='._AM_FORM_ACTION_EDITELEMENT.'></a> + <a href="'.xforms_ADMIN_URL.'?op=edit&clone=1&form_id='.$id.'"><img src='.$pathIcon16.'/editcopy.png title=' + ._AM_FORM_ACTION_CLONE.'alt='._AM_FORM_ACTION_CLONE.'></a> + <a href="'.xforms_ADMIN_URL.'?op=delete&form_id='.$id.'"><img src='.$pathIcon16.'/delete.png title=' + ._DELETE.'alt='._DELETE.'></a> + '.$ids->render().'</td> + </tr>'; + } + $submit = new XoopsFormButton('', 'submit', _AM_RESET_ORDER, 'submit'); + echo ' + <tr> + <td class="foot"> </td> + <td class="foot center">'.$submit->render().'</td> + <td class="foot" colspan="3"> </td> + </tr> + </table>'; + $hidden = new XoopsFormHidden('op', 'saveorder'); + echo $hidden->render()."\n</form>\n"; + } + break; + + case 'edit': + + $clone = isset($_GET['clone']) ? intval($_GET['clone']) : false; + $form_id = isset($_GET['form_id']) ? intval($_GET['form_id']) : 0; + xoops_cp_header(); + echo $adminMenu->addNavigation('main.php'); + $adminMenu->addItemButton(_AM_FORM_LIST, 'main.php?op=list', 'list'); + echo $adminMenu->renderButton(); + if( !empty($form_id) ){ + $form = $xforms_form_mgr->get($form_id); + }else{ + $form = $xforms_form_mgr->create(); + } + + $text_form_title = new XoopsFormText(_AM_FORM_TITLE, 'form_title', 50, 255, $form->getVar('form_title', 'e')); + + $group_ids = $moduleperm_handler->getGroupIds($xforms_form_mgr->perm_name, $form_id, $xoopsModule->getVar('mid')); + $select_form_group_perm = new XoopsFormSelectGroup(_AM_FORM_PERM, 'form_group_perm', true, $group_ids, 5, true); + + $select_form_send_method = new XoopsFormSelect(_AM_FORM_SEND_METHOD, 'form_send_method', $form->getVar('form_send_method')); + $select_form_send_method->addOption('e', _AM_FORM_SEND_METHOD_MAIL); + $select_form_send_method->addOption('p', _AM_FORM_SEND_METHOD_PM); + $select_form_send_method->setDescription(_AM_FORM_SEND_METHOD_DESC); + + $select_form_send_to_group = new XoopsFormSelectGroup(_AM_FORM_SENDTO, 'form_send_to_group', false, $form->getVar('form_send_to_group')); + $select_form_send_to_group->addOption('0', _AM_FORM_SENDTO_ADMIN); + + $select_form_delimiter = new XoopsFormSelect(_AM_FORM_DELIMETER, 'form_delimiter', $form->getVar('form_delimiter')); + $select_form_delimiter->addOption('s', _AM_FORM_DELIMETER_SPACE); + $select_form_delimiter->addOption('b', _AM_FORM_DELIMETER_BR); + + $text_form_order = new XoopsFormText(_AM_FORM_ORDER, 'form_order', 3, 2, $form->getVar('form_order')); + $text_form_order->setDescription(_AM_FORM_ORDER_DESC); + + $submit_text = $form->getVar('form_submit_text'); + $text_form_submit_text = new XoopsFormText(_AM_FORM_SUBMIT_TEXT, 'form_submit_text', 50, 50, empty($submit_text) ? _SUBMIT : $submit_text); + + $tarea_form_desc = new XoopsFormDhtmlTextArea(_AM_FORM_DESC, 'form_desc', $form->getVar('form_desc', 'e'), 5); + $tarea_form_desc->setDescription(_AM_FORM_DESC_DESC); + + $tarea_form_intro = new XoopsFormDhtmlTextArea(_AM_FORM_INTRO, 'form_intro', $form->getVar('form_intro', 'e'), 10); + $tarea_form_intro->setDescription(_AM_FORM_INTRO_DESC); + + $text_form_whereto = new XoopsFormText(_AM_FORM_WHERETO, 'form_whereto', 50, 255, $form->getVar('form_whereto')); + $text_form_whereto->setDescription(_AM_FORM_WHERETO_DESC); + + $hidden_op = new XoopsFormHidden('op', 'saveform'); + $submit = new XoopsFormButton('', 'submit', _AM_SAVE, 'submit'); + $submit1 = new XoopsFormButton('', 'submit', _AM_SAVE_THEN_ELEMENTS, 'submit'); + $tray = new XoopsFormElementTray(''); + $tray->addElement($submit); + $tray->addElement($submit1); + + if( empty($form_id) ){ + $caption = _AM_FORM_NEW; + }else{ + if( $clone ){ + $caption = sprintf(_AM_COPIED, $form->getVar('form_title')); + $clone_form_id = new XoopsFormHidden('clone_form_id', $form_id); + $text_form_title = new XoopsFormText(_AM_FORM_TITLE, 'form_title', 50, 255, sprintf(_AM_COPIED, $form->getVar('form_title', 'e'))); + }else{ + $caption = sprintf(_AM_FORM_EDIT, $form->getVar('form_title')); + $hidden_form_id = new XoopsFormHidden('form_id', $form_id); + } + } + $output = new XoopsThemeForm($caption, 'editform', xforms_ADMIN_URL); + $output->addElement($text_form_title, true); + $output->addElement($select_form_group_perm); + $output->addElement($select_form_send_method); + $output->addElement($select_form_send_to_group); + $output->addElement($select_form_delimiter); + $output->addElement($text_form_order); + $output->addElement($text_form_submit_text, true); + $output->addElement($tarea_form_desc); + $output->addElement($tarea_form_intro); + $output->addElement($text_form_whereto); + $output->addElement($hidden_op); + if( isset($hidden_form_id) && is_object($hidden_form_id) ){ + $output->addElement($hidden_form_id); + } + if( isset($clone_form_id) && is_object($clone_form_id) ){ + $output->addElement($clone_form_id); + } + $output->addElement($tray); + $output->display(); + break; + + case 'delete': + if( empty($_POST['ok']) ){ + //adminHtmlHeader(); + xoops_cp_header(); + xoops_confirm(array('op' => 'delete', 'form_id' => $_GET['form_id'], 'ok' => 1), xforms_ADMIN_URL, _AM_FORM_CONFIRM_DELETE); + }else{ + $form_id = intval($_POST['form_id']); + if( empty($form_id) ){ + redirect_header(xforms_ADMIN_URL, 0, _AM_NOTHING_SELECTED); + } + $form = $xforms_form_mgr->get($form_id); + $xforms_form_mgr->delete($form); + $xforms_ele_mgr = xoops_getmodulehandler('elements'); + $criteria = new Criteria('form_id', $form_id); + $xforms_ele_mgr->deleteAll($criteria); + $xforms_form_mgr->deleteFormPermissions($form_id); + redirect_header(xforms_ADMIN_URL, 0, _AM_DBUPDATED); + } + break; + + case 'saveorder': + if( !isset($_POST['ids']) || count($_POST['ids']) < 1 ){ + redirect_header(xforms_ADMIN_URL, 0, _AM_NOTHING_SELECTED); + } + extract($_POST); + foreach( $ids as $id ){ + $form = $xforms_form_mgr->get($id); + $form->setVar('form_order', $order[$id]); + $xforms_form_mgr->insert($form); + } + redirect_header(xforms_ADMIN_URL, 0, _AM_DBUPDATED); + break; + + case 'saveform': + if( !isset($_POST['submit']) ){ + redirect_header(xforms_ADMIN_URL, 0, _AM_NOTHING_SELECTED); + } + $error = ''; + extract($_POST); + if( !empty($form_id) ){ + $form = $xforms_form_mgr->get($form_id); + }else{ + $form = $xforms_form_mgr->create(); + } + $form->setVar('form_send_method', $form_send_method); + $form->setVar('form_send_to_group', $form_send_to_group); + $form->setVar('form_order', $form_order); + $form->setVar('form_delimiter', $form_delimiter); + $form->setVar('form_title', $form_title); + $form->setVar('form_submit_text', $form_submit_text); + $form->setVar('form_desc', $form_desc); + $form->setVar('form_intro', $form_intro); + $form->setVar('form_whereto', $form_whereto); + if( !$ret = $xforms_form_mgr->insert($form) ){ + $error = $form->getHtmlErrors(); + }else{ + $xforms_form_mgr->deleteFormPermissions($ret); + if( count($form_group_perm) > 0 ){ + $xforms_form_mgr->insertFormPermissions($ret, $form_group_perm); + } + if( !empty($clone_form_id) ){ + $xforms_ele_mgr = xoops_getmodulehandler('elements'); + $criteria = new Criteria('form_id', $clone_form_id); + $count = $xforms_ele_mgr->getCount($criteria); + if( $count > 0 ){ + $elements = $xforms_ele_mgr->getObjects($criteria); + foreach( $elements as $e ){ + $cloned = $e->xoopsClone(); + $cloned->setVar('form_id', $ret); + if( !$xforms_ele_mgr->insert($cloned) ){ + $error .= $cloned->getHtmlErrors(); + } + } + } + }elseif( empty($form_id) ){ + $xforms_ele_mgr = xoops_getmodulehandler('elements'); + $error = $xforms_ele_mgr->insertDefaults($ret); + } + } + if( !empty($error) ){ + //a... [truncated message content] |