@@ -56,23 +56,23 @@ |
||
| 56 | 56 | include_once $GLOBALS['xoops']->path('class'.DS.'xoopsmailer.php'); |
| 57 | 57 | |
| 58 | 58 | if ( file_exists($GLOBALS['xoops']->path('/Frameworks/moduleclasses/moduleadmin/moduleadmin.php'))){ |
| 59 | - include_once $GLOBALS['xoops']->path('/Frameworks/moduleclasses/moduleadmin/moduleadmin.php'); |
|
| 60 | - }else{ |
|
| 61 | - echo xoops_error("Error: You don't use the Frameworks \"admin module\". Please install this Frameworks"); |
|
| 62 | - } |
|
| 59 | + include_once $GLOBALS['xoops']->path('/Frameworks/moduleclasses/moduleadmin/moduleadmin.php'); |
|
| 60 | + }else{ |
|
| 61 | + echo xoops_error("Error: You don't use the Frameworks \"admin module\". Please install this Frameworks"); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | 64 | $GLOBALS['songlistImageIcon'] = XOOPS_URL .'/'. $GLOBALS['songlistModule']->getInfo('icons16'); |
| 65 | 65 | $GLOBALS['songlistImageAdmin'] = XOOPS_URL .'/'. $GLOBALS['songlistModule']->getInfo('icons32'); |
| 66 | 66 | |
| 67 | 67 | if ($GLOBALS['xoopsUser']) { |
| 68 | - $moduleperm_handler = xoops_gethandler('groupperm'); |
|
| 69 | - if (!$moduleperm_handler->checkRight('module_admin', $GLOBALS['songlistModule']->getVar( 'mid' ), $GLOBALS['xoopsUser']->getGroups())) { |
|
| 70 | - redirect_header(XOOPS_URL, 1, _NOPERM); |
|
| 71 | - exit(); |
|
| 72 | - } |
|
| 68 | + $moduleperm_handler = xoops_gethandler('groupperm'); |
|
| 69 | + if (!$moduleperm_handler->checkRight('module_admin', $GLOBALS['songlistModule']->getVar( 'mid' ), $GLOBALS['xoopsUser']->getGroups())) { |
|
| 70 | + redirect_header(XOOPS_URL, 1, _NOPERM); |
|
| 71 | + exit(); |
|
| 72 | + } |
|
| 73 | 73 | } else { |
| 74 | - redirect_header(XOOPS_URL . "/user.php", 1, _NOPERM); |
|
| 75 | - exit(); |
|
| 74 | + redirect_header(XOOPS_URL . "/user.php", 1, _NOPERM); |
|
| 75 | + exit(); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | xoops_loadLanguage('user'); |
@@ -111,25 +111,25 @@ |
||
| 111 | 111 | if ($uploader->fetchMedia('image')) { |
| 112 | 112 | if (!$uploader->upload()) { |
| 113 | 113 | |
| 114 | - songlist_adminMenu(1); |
|
| 115 | - echo $uploader->getErrors(); |
|
| 114 | + songlist_adminMenu(1); |
|
| 115 | + echo $uploader->getErrors(); |
|
| 116 | 116 | songlist_footer_adminMenu(); |
| 117 | 117 | xoops_cp_footer(); |
| 118 | 118 | exit(0); |
| 119 | - } else { |
|
| 119 | + } else { |
|
| 120 | 120 | |
| 121 | - if (strlen($albums->getVar('image'))) |
|
| 122 | - unlink($GLOBALS['xoops']->path($albums->getVar('path')).$albums->getVar('image')); |
|
| 121 | + if (strlen($albums->getVar('image'))) |
|
| 122 | + unlink($GLOBALS['xoops']->path($albums->getVar('path')).$albums->getVar('image')); |
|
| 123 | 123 | |
| 124 | - $albums->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']); |
|
| 125 | - $albums->setVar('image', $uploader->getSavedFileName()); |
|
| 126 | - @$albums_handler->insert($albums); |
|
| 124 | + $albums->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']); |
|
| 125 | + $albums->setVar('image', $uploader->getSavedFileName()); |
|
| 126 | + @$albums_handler->insert($albums); |
|
| 127 | 127 | |
| 128 | - } |
|
| 128 | + } |
|
| 129 | 129 | } else { |
| 130 | 130 | |
| 131 | 131 | songlist_adminMenu(1); |
| 132 | - echo $uploader->getErrors(); |
|
| 132 | + echo $uploader->getErrors(); |
|
| 133 | 133 | songlist_footer_adminMenu(); |
| 134 | 134 | xoops_cp_footer(); |
| 135 | 135 | exit(0); |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | case "actiona": |
| 23 | 23 | |
| 24 | 24 | if (isset($_SESSION['xmlfile'])) { |
| 25 | - redirect_header($_SERVER['PHP_SELF'].'?file='.$_SESSION['xmlfile'].'&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED); |
|
| 26 | - exit; |
|
| 25 | + redirect_header($_SERVER['PHP_SELF'].'?file='.$_SESSION['xmlfile'].'&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED); |
|
| 26 | + exit; |
|
| 27 | 27 | } |
| 28 | 28 | $indexAdmin = new ModuleAdmin(); |
| 29 | 29 | echo $indexAdmin->addNavigation(basename(__FILE__)); |
@@ -53,18 +53,18 @@ discard block |
||
| 53 | 53 | if ($uploader->fetchMedia('xmlfile')) { |
| 54 | 54 | if (!$uploader->upload()) { |
| 55 | 55 | |
| 56 | - echo $uploader->getErrors(); |
|
| 56 | + echo $uploader->getErrors(); |
|
| 57 | 57 | songlist_footer_adminMenu(); |
| 58 | 58 | xoops_cp_footer(); |
| 59 | 59 | exit(0); |
| 60 | - } else { |
|
| 61 | - $_SESSION['xmlfile'] = $uploader->getSavedFileName(); |
|
| 62 | - redirect_header($_SERVER['PHP_SELF'].'?file='.$uploader->getSavedFileName().'&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED); |
|
| 63 | - exit; |
|
| 64 | - } |
|
| 60 | + } else { |
|
| 61 | + $_SESSION['xmlfile'] = $uploader->getSavedFileName(); |
|
| 62 | + redirect_header($_SERVER['PHP_SELF'].'?file='.$uploader->getSavedFileName().'&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED); |
|
| 63 | + exit; |
|
| 64 | + } |
|
| 65 | 65 | } else { |
| 66 | 66 | |
| 67 | - echo $uploader->getErrors(); |
|
| 67 | + echo $uploader->getErrors(); |
|
| 68 | 68 | songlist_footer_adminMenu(); |
| 69 | 69 | xoops_cp_footer(); |
| 70 | 70 | exit(0); |
@@ -111,26 +111,26 @@ |
||
| 111 | 111 | if ($uploader->fetchMedia('image')) { |
| 112 | 112 | if (!$uploader->upload()) { |
| 113 | 113 | |
| 114 | - songlist_adminMenu(1); |
|
| 115 | - echo $uploader->getErrors(); |
|
| 114 | + songlist_adminMenu(1); |
|
| 115 | + echo $uploader->getErrors(); |
|
| 116 | 116 | songlist_footer_adminMenu(); |
| 117 | 117 | xoops_cp_footer(); |
| 118 | 118 | exit(0); |
| 119 | - } else { |
|
| 119 | + } else { |
|
| 120 | 120 | |
| 121 | - if (strlen($category->getVar('image'))) |
|
| 122 | - unlink($GLOBALS['xoops']->path($category->getVar('path')).$category->getVar('image')); |
|
| 121 | + if (strlen($category->getVar('image'))) |
|
| 122 | + unlink($GLOBALS['xoops']->path($category->getVar('path')).$category->getVar('image')); |
|
| 123 | 123 | |
| 124 | - $category->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']); |
|
| 125 | - $category->setVar('image', $uploader->getSavedFileName()); |
|
| 126 | - @$category_handler->insert($category); |
|
| 124 | + $category->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']); |
|
| 125 | + $category->setVar('image', $uploader->getSavedFileName()); |
|
| 126 | + @$category_handler->insert($category); |
|
| 127 | 127 | |
| 128 | - } |
|
| 128 | + } |
|
| 129 | 129 | } else { |
| 130 | 130 | |
| 131 | 131 | $indexAdmin = new ModuleAdmin(); |
| 132 | 132 | echo $indexAdmin->addNavigation(basename(__FILE__)); |
| 133 | - echo $uploader->getErrors(); |
|
| 133 | + echo $uploader->getErrors(); |
|
| 134 | 134 | songlist_footer_adminMenu(); |
| 135 | 135 | xoops_cp_footer(); |
| 136 | 136 | exit(0); |
@@ -111,25 +111,25 @@ |
||
| 111 | 111 | if ($uploader->fetchMedia('image')) { |
| 112 | 112 | if (!$uploader->upload()) { |
| 113 | 113 | |
| 114 | - songlist_adminMenu(1); |
|
| 115 | - echo $uploader->getErrors(); |
|
| 114 | + songlist_adminMenu(1); |
|
| 115 | + echo $uploader->getErrors(); |
|
| 116 | 116 | songlist_footer_adminMenu(); |
| 117 | 117 | xoops_cp_footer(); |
| 118 | 118 | exit(0); |
| 119 | - } else { |
|
| 119 | + } else { |
|
| 120 | 120 | |
| 121 | - if (strlen($votes->getVar('image'))) |
|
| 122 | - unlink($GLOBALS['xoops']->path($votes->getVar('path')).$votes->getVar('image')); |
|
| 121 | + if (strlen($votes->getVar('image'))) |
|
| 122 | + unlink($GLOBALS['xoops']->path($votes->getVar('path')).$votes->getVar('image')); |
|
| 123 | 123 | |
| 124 | - $votes->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']); |
|
| 125 | - $votes->setVar('image', $uploader->getSavedFileName()); |
|
| 126 | - @$votes_handler->insert($votes); |
|
| 124 | + $votes->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']); |
|
| 125 | + $votes->setVar('image', $uploader->getSavedFileName()); |
|
| 126 | + @$votes_handler->insert($votes); |
|
| 127 | 127 | |
| 128 | - } |
|
| 128 | + } |
|
| 129 | 129 | } else { |
| 130 | 130 | |
| 131 | 131 | songlist_adminMenu(1); |
| 132 | - echo $uploader->getErrors(); |
|
| 132 | + echo $uploader->getErrors(); |
|
| 133 | 133 | songlist_footer_adminMenu(); |
| 134 | 134 | xoops_cp_footer(); |
| 135 | 135 | exit(0); |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | case "actiona": |
| 24 | 24 | |
| 25 | 25 | if (isset($_SESSION['xmlfile'])) { |
| 26 | - redirect_header($_SERVER['PHP_SELF'].'?file='.$_SESSION['xmlfile'].'&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED); |
|
| 27 | - exit; |
|
| 26 | + redirect_header($_SERVER['PHP_SELF'].'?file='.$_SESSION['xmlfile'].'&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED); |
|
| 27 | + exit; |
|
| 28 | 28 | } |
| 29 | 29 | $indexAdmin = new ModuleAdmin(); |
| 30 | 30 | echo $indexAdmin->addNavigation(basename(__FILE__)); |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | if ($_POST['file']!='') { |
| 39 | 39 | $file = substr(md5(microtime(true)), mt_rand(0,20), 13).'.xml'; |
| 40 | 40 | copy($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']).$_POST['file'], $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']).$file); |
| 41 | - $_SESSION['xmlfile'] = $file; |
|
| 42 | - redirect_header($_SERVER['PHP_SELF'].'?file='.$file.'&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_COPIED); |
|
| 43 | - exit; |
|
| 41 | + $_SESSION['xmlfile'] = $file; |
|
| 42 | + redirect_header($_SERVER['PHP_SELF'].'?file='.$file.'&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_COPIED); |
|
| 43 | + exit; |
|
| 44 | 44 | } elseif (isset($_FILES['xmlfile'])&&strlen($_FILES['xmlfile']['name'])) { |
| 45 | 45 | |
| 46 | 46 | if (!is_dir($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']))) { |
@@ -59,25 +59,25 @@ discard block |
||
| 59 | 59 | if (!$uploader->upload()) { |
| 60 | 60 | $indexAdmin = new ModuleAdmin(); |
| 61 | 61 | echo $indexAdmin->addNavigation(basename(__FILE__)); |
| 62 | - echo $uploader->getErrors(); |
|
| 62 | + echo $uploader->getErrors(); |
|
| 63 | 63 | xoops_cp_footer(); |
| 64 | 64 | exit(0); |
| 65 | - } else { |
|
| 66 | - $_SESSION['xmlfile'] = $uploader->getSavedFileName(); |
|
| 67 | - redirect_header($_SERVER['PHP_SELF'].'?file='.$uploader->getSavedFileName().'&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED); |
|
| 68 | - exit; |
|
| 69 | - } |
|
| 65 | + } else { |
|
| 66 | + $_SESSION['xmlfile'] = $uploader->getSavedFileName(); |
|
| 67 | + redirect_header($_SERVER['PHP_SELF'].'?file='.$uploader->getSavedFileName().'&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED); |
|
| 68 | + exit; |
|
| 69 | + } |
|
| 70 | 70 | } else { |
| 71 | 71 | $indexAdmin = new ModuleAdmin(); |
| 72 | 72 | echo $indexAdmin->addNavigation(basename(__FILE__)); |
| 73 | - echo $uploader->getErrors(); |
|
| 73 | + echo $uploader->getErrors(); |
|
| 74 | 74 | xoops_cp_footer(); |
| 75 | 75 | exit(0); |
| 76 | 76 | } |
| 77 | 77 | } else { |
| 78 | 78 | $indexAdmin = new ModuleAdmin(); |
| 79 | 79 | echo $indexAdmin->addNavigation(basename(__FILE__)); |
| 80 | - echo _AM_SONGLIST_IMPORT_NOFILE; |
|
| 80 | + echo _AM_SONGLIST_IMPORT_NOFILE; |
|
| 81 | 81 | xoops_cp_footer(); |
| 82 | 82 | exit(0); |
| 83 | 83 | } |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | $op = (!empty($_GET['op']) ? $_GET['op'] : (!empty($_POST['op']) ? $_POST['op'] : "default")); |
| 38 | 38 | |
| 39 | 39 | switch ($op) { |
| 40 | - case "default": |
|
| 41 | - default: |
|
| 40 | + case "default": |
|
| 41 | + default: |
|
| 42 | 42 | |
| 43 | 43 | $indexAdmin = new ModuleAdmin(); |
| 44 | 44 | echo $indexAdmin->addNavigation(basename(__FILE__)); |
@@ -54,19 +54,19 @@ discard block |
||
| 54 | 54 | $requests_handler = xoops_getmodulehandler('requests', 'songlist'); |
| 55 | 55 | $votes_handler = xoops_getmodulehandler('votes', 'songlist'); |
| 56 | 56 | |
| 57 | - $indexAdmin->addInfoBox(_AM_SONGLIST_COUNT); |
|
| 58 | - $indexAdmin->addInfoBoxLine(_AM_SONGLIST_COUNT, "<label>"._AM_SONGLIST_NUMBER_OF_CATEGORY."</label>", $category_handler->getCount(NULL, true), 'green'); |
|
| 59 | - $indexAdmin->addInfoBoxLine(_AM_SONGLIST_COUNT, "<label>"._AM_SONGLIST_NUMBER_OF_ARTISTS."</label>", $artists_handler->getCount(NULL, true), 'green'); |
|
| 60 | - $indexAdmin->addInfoBoxLine(_AM_SONGLIST_COUNT, "<label>"._AM_SONGLIST_NUMBER_OF_ALBUMS."</label>", $albums_handler->getCount(NULL, true), 'green'); |
|
| 61 | - $indexAdmin->addInfoBoxLine(_AM_SONGLIST_COUNT, "<label>"._AM_SONGLIST_NUMBER_OF_GENRE."</label>", $genre_handler->getCount(NULL, true), 'green'); |
|
| 57 | + $indexAdmin->addInfoBox(_AM_SONGLIST_COUNT); |
|
| 58 | + $indexAdmin->addInfoBoxLine(_AM_SONGLIST_COUNT, "<label>"._AM_SONGLIST_NUMBER_OF_CATEGORY."</label>", $category_handler->getCount(NULL, true), 'green'); |
|
| 59 | + $indexAdmin->addInfoBoxLine(_AM_SONGLIST_COUNT, "<label>"._AM_SONGLIST_NUMBER_OF_ARTISTS."</label>", $artists_handler->getCount(NULL, true), 'green'); |
|
| 60 | + $indexAdmin->addInfoBoxLine(_AM_SONGLIST_COUNT, "<label>"._AM_SONGLIST_NUMBER_OF_ALBUMS."</label>", $albums_handler->getCount(NULL, true), 'green'); |
|
| 61 | + $indexAdmin->addInfoBoxLine(_AM_SONGLIST_COUNT, "<label>"._AM_SONGLIST_NUMBER_OF_GENRE."</label>", $genre_handler->getCount(NULL, true), 'green'); |
|
| 62 | 62 | $indexAdmin->addInfoBoxLine(_AM_SONGLIST_COUNT, "<label>"._AM_SONGLIST_NUMBER_OF_VOICE."</label>", $voice_handler->getCount(NULL, true), 'green'); |
| 63 | - $indexAdmin->addInfoBoxLine(_AM_SONGLIST_COUNT, "<label>"._AM_SONGLIST_NUMBER_OF_SONGS."</label>", $songs_handler->getCount(NULL, true), 'green'); |
|
| 64 | - $indexAdmin->addInfoBoxLine(_AM_SONGLIST_COUNT, "<label>"._AM_SONGLIST_NUMBER_OF_REQUESTS."</label>", $requests_handler->getCount(NULL, true), 'green'); |
|
| 65 | - $indexAdmin->addInfoBoxLine(_AM_SONGLIST_COUNT, "<label>"._AM_SONGLIST_NUMBER_OF_VOTES."</label>", $votes_handler->getCount(NULL, true), 'green'); |
|
| 66 | - echo $indexAdmin->renderIndex(); |
|
| 63 | + $indexAdmin->addInfoBoxLine(_AM_SONGLIST_COUNT, "<label>"._AM_SONGLIST_NUMBER_OF_SONGS."</label>", $songs_handler->getCount(NULL, true), 'green'); |
|
| 64 | + $indexAdmin->addInfoBoxLine(_AM_SONGLIST_COUNT, "<label>"._AM_SONGLIST_NUMBER_OF_REQUESTS."</label>", $requests_handler->getCount(NULL, true), 'green'); |
|
| 65 | + $indexAdmin->addInfoBoxLine(_AM_SONGLIST_COUNT, "<label>"._AM_SONGLIST_NUMBER_OF_VOTES."</label>", $votes_handler->getCount(NULL, true), 'green'); |
|
| 66 | + echo $indexAdmin->renderIndex(); |
|
| 67 | 67 | |
| 68 | - xoops_cp_footer(); |
|
| 69 | - break; |
|
| 68 | + xoops_cp_footer(); |
|
| 69 | + break; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | ?> |
| 73 | 73 | \ No newline at end of file |
@@ -45,71 +45,71 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | class forum_XoopsGroupPermForm extends XoopsGroupPermForm |
| 47 | 47 | { |
| 48 | - function forum_XoopsGroupPermForm($title, $modid, $permname, $permdesc, $url = "") |
|
| 49 | - { |
|
| 50 | - $this->XoopsGroupPermForm($title, $modid, $permname, $permdesc, $url); |
|
| 51 | - } |
|
| 48 | + function forum_XoopsGroupPermForm($title, $modid, $permname, $permdesc, $url = "") |
|
| 49 | + { |
|
| 50 | + $this->XoopsGroupPermForm($title, $modid, $permname, $permdesc, $url); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - function render() |
|
| 54 | - { |
|
| 55 | - // load all child ids for javascript codes |
|
| 56 | - foreach (array_keys($this->_itemTree)as $item_id) { |
|
| 57 | - $this->_itemTree[$item_id]['allchild'] = array(); |
|
| 58 | - $this->_loadAllChildItemIds($item_id, $this->_itemTree[$item_id]['allchild']); |
|
| 59 | - } |
|
| 60 | - $gperm_handler = xoops_gethandler('groupperm'); |
|
| 61 | - $member_handler = xoops_gethandler('member'); |
|
| 62 | - $glist = $member_handler->getGroupList(); |
|
| 63 | - foreach (array_keys($glist) as $i) { |
|
| 64 | - // get selected item id(s) for each group |
|
| 65 | - $selected = $gperm_handler->getItemIds($this->_permName, $i, $this->_modid); |
|
| 66 | - $ele = new forum_XoopsGroupFormCheckBox($glist[$i], 'perms[' . $this->_permName . ']', $i, $selected); |
|
| 67 | - $ele->setOptionTree($this->_itemTree); |
|
| 68 | - $this->addElement($ele); |
|
| 69 | - unset($ele); |
|
| 70 | - } |
|
| 71 | - $tray = new XoopsFormElementTray(''); |
|
| 72 | - $tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
| 73 | - $tray->addElement(new XoopsFormButton('', 'reset', _CANCEL, 'reset')); |
|
| 74 | - $this->addElement($tray); |
|
| 75 | - $ret = '<h4>' . $this->getTitle() . '</h4>' . $this->_permDesc . '<br />'; |
|
| 76 | - $ret .= "<form name='" . $this->getName() . "' id='" . $this->getName() . "' action='" . $this->getAction() . "' method='" . $this->getMethod() . "'" . $this->getExtra() . ">\n<table width='100%' class='outer' cellspacing='1' valign='top'>\n"; |
|
| 77 | - $elements = $this->getElements(); |
|
| 78 | - $hidden = ''; |
|
| 79 | - foreach (array_keys($elements) as $i) { |
|
| 80 | - if (!is_object($elements[$i])) { |
|
| 81 | - $ret .= $elements[$i]; |
|
| 82 | - } elseif (!$elements[$i]->isHidden()) { |
|
| 83 | - $ret .= "<tr valign='top' align='left'><td class='head'>" . $elements[$i]->getCaption(); |
|
| 84 | - if ($elements[$i]->getDescription() != '') { |
|
| 85 | - $ret .= '<br /><br /><span style="font-weight: normal;">' . $elements[$i]->getDescription() . '</span>'; |
|
| 86 | - } |
|
| 87 | - $ret .= "</td>\n<td class='even'>\n" . $elements[$i]->render() . "\n</td></tr>\n"; |
|
| 88 | - } else { |
|
| 89 | - $hidden .= $elements[$i]->render(); |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - $ret .= "</table>$hidden</form>"; |
|
| 93 | - $ret .= $this->renderValidationJS( true ); |
|
| 94 | - return $ret; |
|
| 95 | - } |
|
| 53 | + function render() |
|
| 54 | + { |
|
| 55 | + // load all child ids for javascript codes |
|
| 56 | + foreach (array_keys($this->_itemTree)as $item_id) { |
|
| 57 | + $this->_itemTree[$item_id]['allchild'] = array(); |
|
| 58 | + $this->_loadAllChildItemIds($item_id, $this->_itemTree[$item_id]['allchild']); |
|
| 59 | + } |
|
| 60 | + $gperm_handler = xoops_gethandler('groupperm'); |
|
| 61 | + $member_handler = xoops_gethandler('member'); |
|
| 62 | + $glist = $member_handler->getGroupList(); |
|
| 63 | + foreach (array_keys($glist) as $i) { |
|
| 64 | + // get selected item id(s) for each group |
|
| 65 | + $selected = $gperm_handler->getItemIds($this->_permName, $i, $this->_modid); |
|
| 66 | + $ele = new forum_XoopsGroupFormCheckBox($glist[$i], 'perms[' . $this->_permName . ']', $i, $selected); |
|
| 67 | + $ele->setOptionTree($this->_itemTree); |
|
| 68 | + $this->addElement($ele); |
|
| 69 | + unset($ele); |
|
| 70 | + } |
|
| 71 | + $tray = new XoopsFormElementTray(''); |
|
| 72 | + $tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
| 73 | + $tray->addElement(new XoopsFormButton('', 'reset', _CANCEL, 'reset')); |
|
| 74 | + $this->addElement($tray); |
|
| 75 | + $ret = '<h4>' . $this->getTitle() . '</h4>' . $this->_permDesc . '<br />'; |
|
| 76 | + $ret .= "<form name='" . $this->getName() . "' id='" . $this->getName() . "' action='" . $this->getAction() . "' method='" . $this->getMethod() . "'" . $this->getExtra() . ">\n<table width='100%' class='outer' cellspacing='1' valign='top'>\n"; |
|
| 77 | + $elements = $this->getElements(); |
|
| 78 | + $hidden = ''; |
|
| 79 | + foreach (array_keys($elements) as $i) { |
|
| 80 | + if (!is_object($elements[$i])) { |
|
| 81 | + $ret .= $elements[$i]; |
|
| 82 | + } elseif (!$elements[$i]->isHidden()) { |
|
| 83 | + $ret .= "<tr valign='top' align='left'><td class='head'>" . $elements[$i]->getCaption(); |
|
| 84 | + if ($elements[$i]->getDescription() != '') { |
|
| 85 | + $ret .= '<br /><br /><span style="font-weight: normal;">' . $elements[$i]->getDescription() . '</span>'; |
|
| 86 | + } |
|
| 87 | + $ret .= "</td>\n<td class='even'>\n" . $elements[$i]->render() . "\n</td></tr>\n"; |
|
| 88 | + } else { |
|
| 89 | + $hidden .= $elements[$i]->render(); |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + $ret .= "</table>$hidden</form>"; |
|
| 93 | + $ret .= $this->renderValidationJS( true ); |
|
| 94 | + return $ret; |
|
| 95 | + } |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | class forum_XoopsGroupFormCheckBox extends XoopsGroupFormCheckBox |
| 99 | 99 | { |
| 100 | - function forum_XoopsGroupFormCheckBox($caption, $name, $groupId, $values = null) |
|
| 101 | - { |
|
| 102 | - $this->XoopsGroupFormCheckBox($caption, $name, $groupId, $values); |
|
| 103 | - } |
|
| 100 | + function forum_XoopsGroupFormCheckBox($caption, $name, $groupId, $values = null) |
|
| 101 | + { |
|
| 102 | + $this->XoopsGroupFormCheckBox($caption, $name, $groupId, $values); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Renders checkbox options for this group |
|
| 107 | - * |
|
| 108 | - * @return string |
|
| 109 | - * @access public |
|
| 110 | - */ |
|
| 111 | - function render() |
|
| 112 | - { |
|
| 105 | + /** |
|
| 106 | + * Renders checkbox options for this group |
|
| 107 | + * |
|
| 108 | + * @return string |
|
| 109 | + * @access public |
|
| 110 | + */ |
|
| 111 | + function render() |
|
| 112 | + { |
|
| 113 | 113 | $ret = '<table class="outer"><tr><td class="odd"><table><tr>'; |
| 114 | 114 | $cols = 1; |
| 115 | 115 | foreach ($this->_optionTree[0]['children'] as $topitem) { |
@@ -134,38 +134,38 @@ discard block |
||
| 134 | 134 | $ret .= _ALL." <input id=\"".$checkallbtn_id."\" type=\"checkbox\" value=\"\" onclick=\"var optionids = new Array(".$option_ids_str."); xoopsCheckAllElements(optionids, '".$checkallbtn_id."');\" />"; |
| 135 | 135 | $ret .= '</td></tr></table>'; |
| 136 | 136 | return $ret; |
| 137 | - } |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - function _renderOptionTree(&$tree, $option, $prefix, $parentIds = array()) |
|
| 140 | - { |
|
| 141 | - if($option['id'] > 0): |
|
| 142 | - $tree .= $prefix . "<input type=\"checkbox\" name=\"" . $this->getName() . "[groups][" . $this->_groupId . "][" . $option['id'] . "]\" id=\"" . $this->getName() . "[groups][" . $this->_groupId . "][" . $option['id'] . "]\" onclick=\""; |
|
| 143 | - foreach ($parentIds as $pid) { |
|
| 144 | - if($pid <= 0) continue; |
|
| 145 | - $parent_ele = $this->getName() . '[groups][' . $this->_groupId . '][' . $pid . ']'; |
|
| 146 | - $tree .= "var ele = xoopsGetElementById('" . $parent_ele . "'); if(ele.checked != true) {ele.checked = this.checked;}"; |
|
| 147 | - } |
|
| 148 | - foreach ($option['allchild'] as $cid) { |
|
| 149 | - $child_ele = $this->getName() . '[groups][' . $this->_groupId . '][' . $cid . ']'; |
|
| 150 | - $tree .= "var ele = xoopsGetElementById('" . $child_ele . "'); if(this.checked != true) {ele.checked = false;}"; |
|
| 151 | - } |
|
| 152 | - $tree .= '" value="1"'; |
|
| 153 | - if (in_array($option['id'], $this->_value)) { |
|
| 154 | - $tree .= ' checked="checked"'; |
|
| 155 | - } |
|
| 156 | - $tree .= " />" . $option['name'] . "<input type=\"hidden\" name=\"" . $this->getName() . "[parents][" . $option['id'] . "]\" value=\"" . implode(':', $parentIds). "\" /><input type=\"hidden\" name=\"" . $this->getName() . "[itemname][" . $option['id'] . "]\" value=\"" . htmlspecialchars($option['name']). "\" /><br />\n"; |
|
| 157 | - else: |
|
| 158 | - $tree .= $prefix . $option['name'] . "<input type=\"hidden\" id=\"" . $this->getName() . "[groups][" . $this->_groupId . "][" . $option['id'] . "]\" /><br />\n"; |
|
| 159 | - endif; |
|
| 160 | - if (isset($option['children'])) { |
|
| 161 | - foreach ($option['children'] as $child) { |
|
| 162 | - if($option['id'] > 0){ |
|
| 163 | - array_push($parentIds, $option['id']); |
|
| 164 | - } |
|
| 165 | - $this->_renderOptionTree($tree, $this->_optionTree[$child], $prefix . ' -', $parentIds); |
|
| 166 | - } |
|
| 167 | - } |
|
| 168 | - } |
|
| 139 | + function _renderOptionTree(&$tree, $option, $prefix, $parentIds = array()) |
|
| 140 | + { |
|
| 141 | + if($option['id'] > 0): |
|
| 142 | + $tree .= $prefix . "<input type=\"checkbox\" name=\"" . $this->getName() . "[groups][" . $this->_groupId . "][" . $option['id'] . "]\" id=\"" . $this->getName() . "[groups][" . $this->_groupId . "][" . $option['id'] . "]\" onclick=\""; |
|
| 143 | + foreach ($parentIds as $pid) { |
|
| 144 | + if($pid <= 0) continue; |
|
| 145 | + $parent_ele = $this->getName() . '[groups][' . $this->_groupId . '][' . $pid . ']'; |
|
| 146 | + $tree .= "var ele = xoopsGetElementById('" . $parent_ele . "'); if(ele.checked != true) {ele.checked = this.checked;}"; |
|
| 147 | + } |
|
| 148 | + foreach ($option['allchild'] as $cid) { |
|
| 149 | + $child_ele = $this->getName() . '[groups][' . $this->_groupId . '][' . $cid . ']'; |
|
| 150 | + $tree .= "var ele = xoopsGetElementById('" . $child_ele . "'); if(this.checked != true) {ele.checked = false;}"; |
|
| 151 | + } |
|
| 152 | + $tree .= '" value="1"'; |
|
| 153 | + if (in_array($option['id'], $this->_value)) { |
|
| 154 | + $tree .= ' checked="checked"'; |
|
| 155 | + } |
|
| 156 | + $tree .= " />" . $option['name'] . "<input type=\"hidden\" name=\"" . $this->getName() . "[parents][" . $option['id'] . "]\" value=\"" . implode(':', $parentIds). "\" /><input type=\"hidden\" name=\"" . $this->getName() . "[itemname][" . $option['id'] . "]\" value=\"" . htmlspecialchars($option['name']). "\" /><br />\n"; |
|
| 157 | + else: |
|
| 158 | + $tree .= $prefix . $option['name'] . "<input type=\"hidden\" id=\"" . $this->getName() . "[groups][" . $this->_groupId . "][" . $option['id'] . "]\" /><br />\n"; |
|
| 159 | + endif; |
|
| 160 | + if (isset($option['children'])) { |
|
| 161 | + foreach ($option['children'] as $child) { |
|
| 162 | + if($option['id'] > 0){ |
|
| 163 | + array_push($parentIds, $option['id']); |
|
| 164 | + } |
|
| 165 | + $this->_renderOptionTree($tree, $this->_optionTree[$child], $prefix . ' -', $parentIds); |
|
| 166 | + } |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | xoops_cp_header(); |
@@ -190,14 +190,14 @@ discard block |
||
| 190 | 190 | $opform->addElement($op_select); |
| 191 | 191 | $opform->display(); |
| 192 | 192 | |
| 193 | - $member_handler = xoops_gethandler('member'); |
|
| 194 | - $glist = $member_handler->getGroupList(); |
|
| 195 | - $elements = array(); |
|
| 196 | - $songlistperm_handler = xoops_getmodulehandler('permission', 'songlist'); |
|
| 197 | - $perm_template = $songlistperm_handler->getTemplate($groupid = 0); |
|
| 198 | - foreach (array_keys($glist) as $i) { |
|
| 199 | - $selected = !empty($perm_template[$i]) ? array_keys($perm_template[$i]) : array(); |
|
| 200 | - $ret_ele = '<tr align="left" valign="top"><td class="head">'.$glist[$i].'</td>'; |
|
| 193 | + $member_handler = xoops_gethandler('member'); |
|
| 194 | + $glist = $member_handler->getGroupList(); |
|
| 195 | + $elements = array(); |
|
| 196 | + $songlistperm_handler = xoops_getmodulehandler('permission', 'songlist'); |
|
| 197 | + $perm_template = $songlistperm_handler->getTemplate($groupid = 0); |
|
| 198 | + foreach (array_keys($glist) as $i) { |
|
| 199 | + $selected = !empty($perm_template[$i]) ? array_keys($perm_template[$i]) : array(); |
|
| 200 | + $ret_ele = '<tr align="left" valign="top"><td class="head">'.$glist[$i].'</td>'; |
|
| 201 | 201 | $ret_ele .= '<td class="even">'; |
| 202 | 202 | $ret_ele .= '<table class="outer"><tr><td class="odd"><table><tr>'; |
| 203 | 203 | $ii = 0; |
@@ -216,37 +216,37 @@ discard block |
||
| 216 | 216 | $ret_ele .= _ALL.' <input id="checkall['.$i.']" type="checkbox" value="" onclick="var optionids = new Array('.implode(", ", $option_ids).'); xoopsCheckAllElements(optionids, \'checkall['.$i.']\')" />'; |
| 217 | 217 | $ret_ele .= '</td></tr></table>'; |
| 218 | 218 | $ret_ele .= '</td></tr>'; |
| 219 | - $elements[] = $ret_ele; |
|
| 220 | - } |
|
| 221 | - $tray = new XoopsFormElementTray(''); |
|
| 222 | - $tray->addElement(new XoopsFormHidden('action', 'template_save')); |
|
| 223 | - $tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
| 224 | - $tray->addElement(new XoopsFormButton('', 'reset', _CANCEL, 'reset')); |
|
| 225 | - $ret = '<h4>' . _AM_SONGLIST_PERM_TEMPLATE . '</h4>' . _AM_SONGLIST_PERM_TEMPLATE_DESC . '<br /><br /><br />'; |
|
| 226 | - $ret .= "<form name='template' id='template' method='post'>\n<table width='100%' class='outer' cellspacing='1'>\n"; |
|
| 227 | - $ret .= implode("\n",$elements); |
|
| 219 | + $elements[] = $ret_ele; |
|
| 220 | + } |
|
| 221 | + $tray = new XoopsFormElementTray(''); |
|
| 222 | + $tray->addElement(new XoopsFormHidden('action', 'template_save')); |
|
| 223 | + $tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
| 224 | + $tray->addElement(new XoopsFormButton('', 'reset', _CANCEL, 'reset')); |
|
| 225 | + $ret = '<h4>' . _AM_SONGLIST_PERM_TEMPLATE . '</h4>' . _AM_SONGLIST_PERM_TEMPLATE_DESC . '<br /><br /><br />'; |
|
| 226 | + $ret .= "<form name='template' id='template' method='post'>\n<table width='100%' class='outer' cellspacing='1'>\n"; |
|
| 227 | + $ret .= implode("\n",$elements); |
|
| 228 | 228 | $ret .= '<tr align="left" valign="top"><td class="head"></td><td class="even">'; |
| 229 | - $ret .= $tray->render(); |
|
| 229 | + $ret .= $tray->render(); |
|
| 230 | 230 | $ret .= '</td></tr>'; |
| 231 | - $ret .= '</table></form>'; |
|
| 232 | - echo $ret; |
|
| 233 | - break; |
|
| 231 | + $ret .= '</table></form>'; |
|
| 232 | + echo $ret; |
|
| 233 | + break; |
|
| 234 | 234 | |
| 235 | 235 | case "template_save": |
| 236 | - $songlistperm_handler = xoops_getmodulehandler('permission', 'songlist'); |
|
| 237 | - $res = $songlistperm_handler->setTemplate($_POST['perms'], $groupid = 0); |
|
| 238 | - if($res){ |
|
| 239 | - redirect_header("permissions.php?action=template", 2, _AM_SONGLIST_PERM_TEMPLATE_CREATED); |
|
| 240 | - }else{ |
|
| 241 | - redirect_header("permissions.php?action=template", 2, _AM_SONGLIST_PERM_TEMPLATE_ERROR); |
|
| 242 | - } |
|
| 236 | + $songlistperm_handler = xoops_getmodulehandler('permission', 'songlist'); |
|
| 237 | + $res = $songlistperm_handler->setTemplate($_POST['perms'], $groupid = 0); |
|
| 238 | + if($res){ |
|
| 239 | + redirect_header("permissions.php?action=template", 2, _AM_SONGLIST_PERM_TEMPLATE_CREATED); |
|
| 240 | + }else{ |
|
| 241 | + redirect_header("permissions.php?action=template", 2, _AM_SONGLIST_PERM_TEMPLATE_ERROR); |
|
| 242 | + } |
|
| 243 | 243 | break; |
| 244 | 244 | |
| 245 | 245 | case "apply": |
| 246 | - $songlistperm_handler = xoops_getmodulehandler('permission', 'songlist'); |
|
| 247 | - $perm_template = $songlistperm_handler->getTemplate(); |
|
| 246 | + $songlistperm_handler = xoops_getmodulehandler('permission', 'songlist'); |
|
| 247 | + $perm_template = $songlistperm_handler->getTemplate(); |
|
| 248 | 248 | if($perm_template===null){ |
| 249 | - redirect_header("permissions.php?action=template", 2, _AM_SONGLIST_PERM_TEMPLATE); |
|
| 249 | + redirect_header("permissions.php?action=template", 2, _AM_SONGLIST_PERM_TEMPLATE); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | $opform = new XoopsSimpleForm(_AM_SONGLIST_PERM_ACTION, 'actionform', 'permissions.php', "get"); |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | $fm_options[-1*$c] = "[".$categories[$c]->getVar('cat_title')."]"; |
| 267 | 267 | foreach(array_keys($songlists[$c]) as $f){ |
| 268 | 268 | $fm_options[$f] = $songlists[$c][$f]["title"]; |
| 269 | - if(!isset($songlists[$c][$f]["sub"])) continue; |
|
| 269 | + if(!isset($songlists[$c][$f]["sub"])) continue; |
|
| 270 | 270 | foreach(array_keys($songlists[$c][$f]["sub"]) as $s){ |
| 271 | 271 | $fm_options[$s] = "-- ".$songlists[$c][$f]["sub"][$s]["title"]; |
| 272 | 272 | } |
@@ -277,22 +277,22 @@ discard block |
||
| 277 | 277 | $fm_select = new XoopsFormSelect(_AM_SONGLIST_PERM_FORUMS, 'forums', null, 10, true); |
| 278 | 278 | $fm_select->addOptionArray($fm_options); |
| 279 | 279 | $fmform->addElement($fm_select); |
| 280 | - $tray = new XoopsFormElementTray(''); |
|
| 281 | - $tray->addElement(new XoopsFormHidden('action', 'apply_save')); |
|
| 282 | - $tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
| 283 | - $tray->addElement(new XoopsFormButton('', 'reset', _CANCEL, 'reset')); |
|
| 280 | + $tray = new XoopsFormElementTray(''); |
|
| 281 | + $tray->addElement(new XoopsFormHidden('action', 'apply_save')); |
|
| 282 | + $tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
| 283 | + $tray->addElement(new XoopsFormButton('', 'reset', _CANCEL, 'reset')); |
|
| 284 | 284 | $fmform->addElement($tray); |
| 285 | 285 | $fmform->display(); |
| 286 | 286 | break; |
| 287 | 287 | |
| 288 | 288 | case "apply_save": |
| 289 | 289 | if(empty($_POST["forums"])) break; |
| 290 | - $songlistperm_handler = xoops_getmodulehandler('permission', 'songlist'); |
|
| 290 | + $songlistperm_handler = xoops_getmodulehandler('permission', 'songlist'); |
|
| 291 | 291 | foreach($_POST["forums"] as $songlist){ |
| 292 | 292 | if($songlist < 1) continue; |
| 293 | 293 | $songlistperm_handler->applyTemplate($songlist, $module_id); |
| 294 | 294 | } |
| 295 | - redirect_header("permissions.php", 2, _AM_SONGLIST_PERM_TEMPLATE_APPLIED); |
|
| 295 | + redirect_header("permissions.php", 2, _AM_SONGLIST_PERM_TEMPLATE_APPLIED); |
|
| 296 | 296 | break; |
| 297 | 297 | |
| 298 | 298 | default: |
@@ -353,10 +353,10 @@ discard block |
||
| 353 | 353 | $key_c = -1 * $c; |
| 354 | 354 | $form->addItem($key_c, "<strong>[".$categories[$c]->getVar('cat_title')."]</strong>"); |
| 355 | 355 | foreach(array_keys($songlists[$c]) as $f){ |
| 356 | - $form->addItem($f, $songlists[$c][$f]["title"], $key_c); |
|
| 357 | - if(!isset($songlists[$c][$f]["sub"])) continue; |
|
| 356 | + $form->addItem($f, $songlists[$c][$f]["title"], $key_c); |
|
| 357 | + if(!isset($songlists[$c][$f]["sub"])) continue; |
|
| 358 | 358 | foreach(array_keys($songlists[$c][$f]["sub"]) as $s){ |
| 359 | - $form->addItem($s, "→".$songlists[$c][$f]["sub"][$s]["title"], $f); |
|
| 359 | + $form->addItem($s, "→".$songlists[$c][$f]["sub"][$s]["title"], $f); |
|
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | 362 | } |
@@ -54,59 +54,59 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | class SonglistFormSelectAlbum extends XoopsFormElement |
| 56 | 56 | { |
| 57 | - /** |
|
| 58 | - * Options |
|
| 59 | - * |
|
| 60 | - * @var array |
|
| 61 | - * @access private |
|
| 62 | - */ |
|
| 63 | - var $_options = array(); |
|
| 57 | + /** |
|
| 58 | + * Options |
|
| 59 | + * |
|
| 60 | + * @var array |
|
| 61 | + * @access private |
|
| 62 | + */ |
|
| 63 | + var $_options = array(); |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Allow multiple selections? |
|
| 67 | - * |
|
| 68 | - * @var bool |
|
| 69 | - * @access private |
|
| 70 | - */ |
|
| 71 | - var $_multiple = false; |
|
| 65 | + /** |
|
| 66 | + * Allow multiple selections? |
|
| 67 | + * |
|
| 68 | + * @var bool |
|
| 69 | + * @access private |
|
| 70 | + */ |
|
| 71 | + var $_multiple = false; |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Number of rows. "1" makes a dropdown list. |
|
| 75 | - * |
|
| 76 | - * @var int |
|
| 77 | - * @access private |
|
| 78 | - */ |
|
| 79 | - var $_size; |
|
| 73 | + /** |
|
| 74 | + * Number of rows. "1" makes a dropdown list. |
|
| 75 | + * |
|
| 76 | + * @var int |
|
| 77 | + * @access private |
|
| 78 | + */ |
|
| 79 | + var $_size; |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * Pre-selcted values |
|
| 83 | - * |
|
| 84 | - * @var array |
|
| 85 | - * @access private |
|
| 86 | - */ |
|
| 87 | - var $_value = array(); |
|
| 81 | + /** |
|
| 82 | + * Pre-selcted values |
|
| 83 | + * |
|
| 84 | + * @var array |
|
| 85 | + * @access private |
|
| 86 | + */ |
|
| 87 | + var $_value = array(); |
|
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * Constructor |
|
| 91 | - * |
|
| 92 | - * @param string $caption Caption |
|
| 93 | - * @param string $name "name" attribute |
|
| 94 | - * @param mixed $value Pre-selected value (or array of them). |
|
| 95 | - * @param int $size Number or rows. "1" makes a drop-down-list |
|
| 96 | - * @param bool $multiple Allow multiple selections? |
|
| 97 | - */ |
|
| 98 | - function SonglistFormSelectAlbum($caption, $name, $value = null, $size = 1, $multiple = false, $ownid=0) |
|
| 99 | - { |
|
| 100 | - global $_form_object_options; |
|
| 101 | - xoops_loadLanguage('modinfo', 'songlist'); |
|
| 89 | + /** |
|
| 90 | + * Constructor |
|
| 91 | + * |
|
| 92 | + * @param string $caption Caption |
|
| 93 | + * @param string $name "name" attribute |
|
| 94 | + * @param mixed $value Pre-selected value (or array of them). |
|
| 95 | + * @param int $size Number or rows. "1" makes a drop-down-list |
|
| 96 | + * @param bool $multiple Allow multiple selections? |
|
| 97 | + */ |
|
| 98 | + function SonglistFormSelectAlbum($caption, $name, $value = null, $size = 1, $multiple = false, $ownid=0) |
|
| 99 | + { |
|
| 100 | + global $_form_object_options; |
|
| 101 | + xoops_loadLanguage('modinfo', 'songlist'); |
|
| 102 | 102 | |
| 103 | - $this->setCaption($caption); |
|
| 104 | - $this->setName($name); |
|
| 105 | - $this->_multiple = $multiple; |
|
| 106 | - $this->_size = intval($size); |
|
| 107 | - if (isset($value)) { |
|
| 108 | - $this->setValue($value); |
|
| 109 | - } |
|
| 103 | + $this->setCaption($caption); |
|
| 104 | + $this->setName($name); |
|
| 105 | + $this->_multiple = $multiple; |
|
| 106 | + $this->_size = intval($size); |
|
| 107 | + if (isset($value)) { |
|
| 108 | + $this->setValue($value); |
|
| 109 | + } |
|
| 110 | 110 | $this->addOption('0', _MI_SONGLIST_NONE); |
| 111 | 111 | if (!isset($_form_object_options['albums'])) { |
| 112 | 112 | $albums_handler =& xoops_getmodulehandler('albums', 'songlist'); |
@@ -121,159 +121,159 @@ discard block |
||
| 121 | 121 | foreach($_form_object_options['albums'] as $id => $value) |
| 122 | 122 | $this->addOption($id, $value); |
| 123 | 123 | } |
| 124 | - } |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * Are multiple selections allowed? |
|
| 128 | - * |
|
| 129 | - * @return bool |
|
| 130 | - */ |
|
| 131 | - function isMultiple() |
|
| 132 | - { |
|
| 133 | - return $this->_multiple; |
|
| 134 | - } |
|
| 126 | + /** |
|
| 127 | + * Are multiple selections allowed? |
|
| 128 | + * |
|
| 129 | + * @return bool |
|
| 130 | + */ |
|
| 131 | + function isMultiple() |
|
| 132 | + { |
|
| 133 | + return $this->_multiple; |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - /** |
|
| 137 | - * Get the size |
|
| 138 | - * |
|
| 139 | - * @return int |
|
| 140 | - */ |
|
| 141 | - function getSize() |
|
| 142 | - { |
|
| 143 | - return $this->_size; |
|
| 144 | - } |
|
| 136 | + /** |
|
| 137 | + * Get the size |
|
| 138 | + * |
|
| 139 | + * @return int |
|
| 140 | + */ |
|
| 141 | + function getSize() |
|
| 142 | + { |
|
| 143 | + return $this->_size; |
|
| 144 | + } |
|
| 145 | 145 | |
| 146 | - /** |
|
| 147 | - * Get an array of pre-selected values |
|
| 148 | - * |
|
| 149 | - * @param bool $encode To sanitizer the text? |
|
| 150 | - * @return array |
|
| 151 | - */ |
|
| 152 | - function getValue($encode = false) |
|
| 153 | - { |
|
| 154 | - if (! $encode) { |
|
| 155 | - return $this->_value; |
|
| 156 | - } |
|
| 157 | - $value = array(); |
|
| 158 | - foreach($this->_value as $val) { |
|
| 159 | - $value[] = $val ? htmlspecialchars($val, ENT_QUOTES) : $val; |
|
| 160 | - } |
|
| 161 | - return $value; |
|
| 162 | - } |
|
| 146 | + /** |
|
| 147 | + * Get an array of pre-selected values |
|
| 148 | + * |
|
| 149 | + * @param bool $encode To sanitizer the text? |
|
| 150 | + * @return array |
|
| 151 | + */ |
|
| 152 | + function getValue($encode = false) |
|
| 153 | + { |
|
| 154 | + if (! $encode) { |
|
| 155 | + return $this->_value; |
|
| 156 | + } |
|
| 157 | + $value = array(); |
|
| 158 | + foreach($this->_value as $val) { |
|
| 159 | + $value[] = $val ? htmlspecialchars($val, ENT_QUOTES) : $val; |
|
| 160 | + } |
|
| 161 | + return $value; |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - /** |
|
| 165 | - * Set pre-selected values |
|
| 166 | - * |
|
| 167 | - * @param $value mixed |
|
| 168 | - */ |
|
| 169 | - function setValue($value) |
|
| 170 | - { |
|
| 171 | - if (is_array($value)) { |
|
| 172 | - foreach($value as $v) { |
|
| 173 | - $this->_value[] = $v; |
|
| 174 | - } |
|
| 175 | - } elseif (isset($value)) { |
|
| 176 | - $this->_value[] = $value; |
|
| 177 | - } |
|
| 178 | - } |
|
| 164 | + /** |
|
| 165 | + * Set pre-selected values |
|
| 166 | + * |
|
| 167 | + * @param $value mixed |
|
| 168 | + */ |
|
| 169 | + function setValue($value) |
|
| 170 | + { |
|
| 171 | + if (is_array($value)) { |
|
| 172 | + foreach($value as $v) { |
|
| 173 | + $this->_value[] = $v; |
|
| 174 | + } |
|
| 175 | + } elseif (isset($value)) { |
|
| 176 | + $this->_value[] = $value; |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - /** |
|
| 181 | - * Add an option |
|
| 182 | - * |
|
| 183 | - * @param string $value "value" attribute |
|
| 184 | - * @param string $name "name" attribute |
|
| 185 | - */ |
|
| 186 | - function addOption($value, $name = '') |
|
| 187 | - { |
|
| 188 | - if ($name != '') { |
|
| 189 | - $this->_options[$value] = $name; |
|
| 190 | - } else { |
|
| 191 | - $this->_options[$value] = $value; |
|
| 192 | - } |
|
| 193 | - } |
|
| 180 | + /** |
|
| 181 | + * Add an option |
|
| 182 | + * |
|
| 183 | + * @param string $value "value" attribute |
|
| 184 | + * @param string $name "name" attribute |
|
| 185 | + */ |
|
| 186 | + function addOption($value, $name = '') |
|
| 187 | + { |
|
| 188 | + if ($name != '') { |
|
| 189 | + $this->_options[$value] = $name; |
|
| 190 | + } else { |
|
| 191 | + $this->_options[$value] = $value; |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | - /** |
|
| 196 | - * Add multiple options |
|
| 197 | - * |
|
| 198 | - * @param array $options Associative array of value->name pairs |
|
| 199 | - */ |
|
| 200 | - function addOptionArray($options) |
|
| 201 | - { |
|
| 202 | - if (is_array($options)) { |
|
| 203 | - foreach($options as $k => $v) { |
|
| 204 | - $this->addOption($k, $v); |
|
| 205 | - } |
|
| 206 | - } |
|
| 207 | - } |
|
| 195 | + /** |
|
| 196 | + * Add multiple options |
|
| 197 | + * |
|
| 198 | + * @param array $options Associative array of value->name pairs |
|
| 199 | + */ |
|
| 200 | + function addOptionArray($options) |
|
| 201 | + { |
|
| 202 | + if (is_array($options)) { |
|
| 203 | + foreach($options as $k => $v) { |
|
| 204 | + $this->addOption($k, $v); |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - /** |
|
| 210 | - * Get an array with all the options |
|
| 211 | - * |
|
| 212 | - * Note: both name and value should be sanitized. However for backward compatibility, only value is sanitized for now. |
|
| 213 | - * |
|
| 214 | - * @param int $encode To sanitizer the text? potential values: 0 - skip; 1 - only for value; 2 - for both value and name |
|
| 215 | - * @return array Associative array of value->name pairs |
|
| 216 | - */ |
|
| 217 | - function getOptions($encode = false) |
|
| 218 | - { |
|
| 219 | - if (! $encode) { |
|
| 220 | - return $this->_options; |
|
| 221 | - } |
|
| 222 | - $value = array(); |
|
| 223 | - foreach($this->_options as $val => $name) { |
|
| 224 | - $value[$encode ? htmlspecialchars($val, ENT_QUOTES) : $val] = ($encode > 1) ? htmlspecialchars($name, ENT_QUOTES) : $name; |
|
| 225 | - } |
|
| 226 | - return $value; |
|
| 227 | - } |
|
| 209 | + /** |
|
| 210 | + * Get an array with all the options |
|
| 211 | + * |
|
| 212 | + * Note: both name and value should be sanitized. However for backward compatibility, only value is sanitized for now. |
|
| 213 | + * |
|
| 214 | + * @param int $encode To sanitizer the text? potential values: 0 - skip; 1 - only for value; 2 - for both value and name |
|
| 215 | + * @return array Associative array of value->name pairs |
|
| 216 | + */ |
|
| 217 | + function getOptions($encode = false) |
|
| 218 | + { |
|
| 219 | + if (! $encode) { |
|
| 220 | + return $this->_options; |
|
| 221 | + } |
|
| 222 | + $value = array(); |
|
| 223 | + foreach($this->_options as $val => $name) { |
|
| 224 | + $value[$encode ? htmlspecialchars($val, ENT_QUOTES) : $val] = ($encode > 1) ? htmlspecialchars($name, ENT_QUOTES) : $name; |
|
| 225 | + } |
|
| 226 | + return $value; |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - /** |
|
| 230 | - * Prepare HTML for output |
|
| 231 | - * |
|
| 232 | - * @return string HTML |
|
| 233 | - */ |
|
| 234 | - function render() |
|
| 235 | - { |
|
| 236 | - $ele_name = $this->getName(); |
|
| 229 | + /** |
|
| 230 | + * Prepare HTML for output |
|
| 231 | + * |
|
| 232 | + * @return string HTML |
|
| 233 | + */ |
|
| 234 | + function render() |
|
| 235 | + { |
|
| 236 | + $ele_name = $this->getName(); |
|
| 237 | 237 | $ele_title = $this->getTitle(); |
| 238 | - $ele_value = $this->getValue(); |
|
| 239 | - $ele_options = $this->getOptions(); |
|
| 240 | - $ret = '<select size="'.$this->getSize().'"'.$this->getExtra(); |
|
| 241 | - if ($this->isMultiple() != false) { |
|
| 242 | - $ret .= ' name="'.$ele_name.'[]" id="'.$ele_name.'" title="'. $ele_title. '" multiple="multiple">' ; |
|
| 243 | - } else { |
|
| 244 | - $ret .= ' name="'.$ele_name.'" id="'.$ele_name.'" title="'. $ele_title. '">' ; |
|
| 245 | - } |
|
| 246 | - foreach($ele_options as $value => $name) { |
|
| 247 | - $ret .= '<option value="'.htmlspecialchars($value, ENT_QUOTES).'"'; |
|
| 248 | - if (count($ele_value) > 0 && in_array($value, $ele_value)) { |
|
| 249 | - $ret .= ' selected="selected"'; |
|
| 250 | - } |
|
| 251 | - $ret .= '>'.$name.'</option>' ; |
|
| 252 | - } |
|
| 253 | - $ret .= '</select>'; |
|
| 254 | - return $ret; |
|
| 255 | - } |
|
| 238 | + $ele_value = $this->getValue(); |
|
| 239 | + $ele_options = $this->getOptions(); |
|
| 240 | + $ret = '<select size="'.$this->getSize().'"'.$this->getExtra(); |
|
| 241 | + if ($this->isMultiple() != false) { |
|
| 242 | + $ret .= ' name="'.$ele_name.'[]" id="'.$ele_name.'" title="'. $ele_title. '" multiple="multiple">' ; |
|
| 243 | + } else { |
|
| 244 | + $ret .= ' name="'.$ele_name.'" id="'.$ele_name.'" title="'. $ele_title. '">' ; |
|
| 245 | + } |
|
| 246 | + foreach($ele_options as $value => $name) { |
|
| 247 | + $ret .= '<option value="'.htmlspecialchars($value, ENT_QUOTES).'"'; |
|
| 248 | + if (count($ele_value) > 0 && in_array($value, $ele_value)) { |
|
| 249 | + $ret .= ' selected="selected"'; |
|
| 250 | + } |
|
| 251 | + $ret .= '>'.$name.'</option>' ; |
|
| 252 | + } |
|
| 253 | + $ret .= '</select>'; |
|
| 254 | + return $ret; |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | - /** |
|
| 258 | - * Render custom javascript validation code |
|
| 259 | - * |
|
| 260 | - * @seealso XoopsForm::renderValidationJS |
|
| 261 | - */ |
|
| 262 | - function renderValidationJS() |
|
| 263 | - { |
|
| 264 | - // render custom validation code if any |
|
| 265 | - if (! empty($this->customValidationCode)) { |
|
| 266 | - return implode("\n", $this->customValidationCode); |
|
| 267 | - // generate validation code if required |
|
| 268 | - } elseif ($this->isRequired()) { |
|
| 269 | - $eltname = $this->getName(); |
|
| 270 | - $eltcaption = $this->getCaption(); |
|
| 271 | - $eltmsg = empty($eltcaption) ? sprintf(_FORM_ENTER, $eltname) : sprintf(_FORM_ENTER, $eltcaption); |
|
| 272 | - $eltmsg = str_replace('"', '\"', stripslashes($eltmsg)); |
|
| 273 | - return "\nvar hasSelected = false; var selectBox = myform.{$eltname};"."for (i = 0; i < selectBox.options.length; i++ ) { if (selectBox.options[i].selected == true) { hasSelected = true; break; } }"."if (!hasSelected) { window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }"; |
|
| 274 | - } |
|
| 275 | - return ''; |
|
| 276 | - } |
|
| 257 | + /** |
|
| 258 | + * Render custom javascript validation code |
|
| 259 | + * |
|
| 260 | + * @seealso XoopsForm::renderValidationJS |
|
| 261 | + */ |
|
| 262 | + function renderValidationJS() |
|
| 263 | + { |
|
| 264 | + // render custom validation code if any |
|
| 265 | + if (! empty($this->customValidationCode)) { |
|
| 266 | + return implode("\n", $this->customValidationCode); |
|
| 267 | + // generate validation code if required |
|
| 268 | + } elseif ($this->isRequired()) { |
|
| 269 | + $eltname = $this->getName(); |
|
| 270 | + $eltcaption = $this->getCaption(); |
|
| 271 | + $eltmsg = empty($eltcaption) ? sprintf(_FORM_ENTER, $eltname) : sprintf(_FORM_ENTER, $eltcaption); |
|
| 272 | + $eltmsg = str_replace('"', '\"', stripslashes($eltmsg)); |
|
| 273 | + return "\nvar hasSelected = false; var selectBox = myform.{$eltname};"."for (i = 0; i < selectBox.options.length; i++ ) { if (selectBox.options[i].selected == true) { hasSelected = true; break; } }"."if (!hasSelected) { window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }"; |
|
| 274 | + } |
|
| 275 | + return ''; |
|
| 276 | + } |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | ?> |
| 280 | 280 | \ No newline at end of file |