@@ -27,35 +27,35 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | function references_notify_iteminfo($category, $item_id) |
| 29 | 29 | { |
| 30 | - global $xoopsModule, $xoopsModuleConfig, $xoopsConfig; |
|
| 31 | - $item_id = (int)$item_id; |
|
| 30 | + global $xoopsModule, $xoopsModuleConfig, $xoopsConfig; |
|
| 31 | + $item_id = (int)$item_id; |
|
| 32 | 32 | |
| 33 | - if (empty($xoopsModule) || $xoopsModule->getVar('dirname') !== 'references') { |
|
| 34 | - $module_handler = xoops_getHandler('module'); |
|
| 35 | - $module = $module_handler->getByDirname('references'); |
|
| 36 | - $config_handler = xoops_getHandler('config'); |
|
| 37 | - $config = $config_handler->getConfigsByCat(0, $module->getVar('mid')); |
|
| 38 | - } else { |
|
| 39 | - $module =& $xoopsModule; |
|
| 40 | - $config =& $xoopsModuleConfig; |
|
| 41 | - } |
|
| 33 | + if (empty($xoopsModule) || $xoopsModule->getVar('dirname') !== 'references') { |
|
| 34 | + $module_handler = xoops_getHandler('module'); |
|
| 35 | + $module = $module_handler->getByDirname('references'); |
|
| 36 | + $config_handler = xoops_getHandler('config'); |
|
| 37 | + $config = $config_handler->getConfigsByCat(0, $module->getVar('mid')); |
|
| 38 | + } else { |
|
| 39 | + $module =& $xoopsModule; |
|
| 40 | + $config =& $xoopsModuleConfig; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - if ($category === 'global') { |
|
| 44 | - $item['name'] = ''; |
|
| 45 | - $item['url'] = ''; |
|
| 43 | + if ($category === 'global') { |
|
| 44 | + $item['name'] = ''; |
|
| 45 | + $item['url'] = ''; |
|
| 46 | 46 | |
| 47 | - return $item; |
|
| 48 | - } |
|
| 47 | + return $item; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - if ($category === 'new_article') { |
|
| 51 | - include REFERENCES_PATH . ' include/common.php'; |
|
| 52 | - $article = null; |
|
| 53 | - $article = $h_references_articles->get($item_id); |
|
| 54 | - if (is_object($article)) { |
|
| 55 | - $item['name'] = $article->getVar('article_title'); |
|
| 56 | - $item['url'] = REFERENCES_URL; |
|
| 57 | - } |
|
| 50 | + if ($category === 'new_article') { |
|
| 51 | + include REFERENCES_PATH . ' include/common.php'; |
|
| 52 | + $article = null; |
|
| 53 | + $article = $h_references_articles->get($item_id); |
|
| 54 | + if (is_object($article)) { |
|
| 55 | + $item['name'] = $article->getVar('article_title'); |
|
| 56 | + $item['url'] = REFERENCES_URL; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - return $item; |
|
| 60 | - } |
|
| 59 | + return $item; |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -22,30 +22,30 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | function references_tag_iteminfo(&$items) |
| 24 | 24 | { |
| 25 | - $items_id = array(); |
|
| 26 | - foreach (array_keys($items) as $cat_id) { |
|
| 27 | - foreach (array_keys($items[$cat_id]) as $item_id) { |
|
| 28 | - $items_id[] = (int)$item_id; |
|
| 29 | - } |
|
| 30 | - } |
|
| 31 | - include XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
|
| 32 | - $items_obj = $h_references_articles->getItemsFromIds($items_id); |
|
| 25 | + $items_id = array(); |
|
| 26 | + foreach (array_keys($items) as $cat_id) { |
|
| 27 | + foreach (array_keys($items[$cat_id]) as $item_id) { |
|
| 28 | + $items_id[] = (int)$item_id; |
|
| 29 | + } |
|
| 30 | + } |
|
| 31 | + include XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
|
| 32 | + $items_obj = $h_references_articles->getItemsFromIds($items_id); |
|
| 33 | 33 | |
| 34 | - foreach (array_keys($items) as $cat_id) { |
|
| 35 | - foreach (array_keys($items[$cat_id]) as $item_id) { |
|
| 36 | - $item_obj =& $items_obj[$item_id]; |
|
| 37 | - /** @noinspection SenselessCommaInArrayDefinitionInspection */ |
|
| 38 | - $items[$cat_id][$item_id] = array( |
|
| 39 | - 'title' => $item_obj->getVar('article_title'), |
|
| 40 | - 'uid' => $item_obj->getVar('article_author'), |
|
| 41 | - 'link' => 'index.php', |
|
| 42 | - 'time' => $item_obj->getVar('article_timestamp'), |
|
| 43 | - 'tags' => '', |
|
| 44 | - 'content' => '', |
|
| 45 | - ); |
|
| 46 | - } |
|
| 47 | - } |
|
| 48 | - unset($items_obj); |
|
| 34 | + foreach (array_keys($items) as $cat_id) { |
|
| 35 | + foreach (array_keys($items[$cat_id]) as $item_id) { |
|
| 36 | + $item_obj =& $items_obj[$item_id]; |
|
| 37 | + /** @noinspection SenselessCommaInArrayDefinitionInspection */ |
|
| 38 | + $items[$cat_id][$item_id] = array( |
|
| 39 | + 'title' => $item_obj->getVar('article_title'), |
|
| 40 | + 'uid' => $item_obj->getVar('article_author'), |
|
| 41 | + 'link' => 'index.php', |
|
| 42 | + 'time' => $item_obj->getVar('article_timestamp'), |
|
| 43 | + 'tags' => '', |
|
| 44 | + 'content' => '', |
|
| 45 | + ); |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | + unset($items_obj); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** Remove orphan tag-item links * |
@@ -53,22 +53,22 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | function references_tag_synchronization($mid) |
| 55 | 55 | { |
| 56 | - global $xoopsDB; |
|
| 57 | - $item_handler_keyName = 'article_id'; |
|
| 58 | - $item_handler_table = $xoopsDB->prefix('references_articles'); |
|
| 59 | - $link_handler = xoops_getModuleHandler('link', 'tag'); |
|
| 60 | - $where = "($item_handler_table.article_online = 1)"; |
|
| 61 | - $where1 = "($item_handler_table.article_online = 0)"; |
|
| 56 | + global $xoopsDB; |
|
| 57 | + $item_handler_keyName = 'article_id'; |
|
| 58 | + $item_handler_table = $xoopsDB->prefix('references_articles'); |
|
| 59 | + $link_handler = xoops_getModuleHandler('link', 'tag'); |
|
| 60 | + $where = "($item_handler_table.article_online = 1)"; |
|
| 61 | + $where1 = "($item_handler_table.article_online = 0)"; |
|
| 62 | 62 | |
| 63 | - /* clear tag-item links */ |
|
| 64 | - if ($link_handler->mysql_major_version() >= 4): |
|
| 65 | - $sql = " DELETE FROM {$link_handler->table}" . ' WHERE ' . " tag_modid = {$mid}" . ' AND ' . ' ( tag_itemid NOT IN ' . " ( SELECT DISTINCT {$item_handler_keyName} " . " FROM {$item_handler_table} " . " WHERE $where" . ' ) ' |
|
| 66 | - . ' )'; |
|
| 67 | - else: |
|
| 68 | - $sql = " DELETE {$link_handler->table} FROM {$link_handler->table}" . " LEFT JOIN {$item_handler_table} AS aa ON {$link_handler->table}.tag_itemid = aa.{$item_handler_keyName} " . ' WHERE ' . " tag_modid = {$mid}" . ' AND ' . " ( aa.{$item_handler_keyName} IS NULL" |
|
| 69 | - . " OR $where1" . ' )'; |
|
| 70 | - endif; |
|
| 71 | - if (!$link_handler->db->queryF($sql)) { |
|
| 72 | - trigger_error($link_handler->db->error()); |
|
| 73 | - } |
|
| 63 | + /* clear tag-item links */ |
|
| 64 | + if ($link_handler->mysql_major_version() >= 4): |
|
| 65 | + $sql = " DELETE FROM {$link_handler->table}" . ' WHERE ' . " tag_modid = {$mid}" . ' AND ' . ' ( tag_itemid NOT IN ' . " ( SELECT DISTINCT {$item_handler_keyName} " . " FROM {$item_handler_table} " . " WHERE $where" . ' ) ' |
|
| 66 | + . ' )'; |
|
| 67 | + else: |
|
| 68 | + $sql = " DELETE {$link_handler->table} FROM {$link_handler->table}" . " LEFT JOIN {$item_handler_table} AS aa ON {$link_handler->table}.tag_itemid = aa.{$item_handler_keyName} " . ' WHERE ' . " tag_modid = {$mid}" . ' AND ' . " ( aa.{$item_handler_keyName} IS NULL" |
|
| 69 | + . " OR $where1" . ' )'; |
|
| 70 | + endif; |
|
| 71 | + if (!$link_handler->db->queryF($sql)) { |
|
| 72 | + trigger_error($link_handler->db->error()); |
|
| 73 | + } |
|
| 74 | 74 | } |
@@ -30,15 +30,15 @@ discard block |
||
| 30 | 30 | require_once REFERENCES_PATH . 'admin/dbupdate.php'; |
| 31 | 31 | |
| 32 | 32 | if (!isset($op)) { |
| 33 | - $op = 'default'; |
|
| 33 | + $op = 'default'; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | if (isset($_POST['op'])) { |
| 37 | - $op = $_POST['op']; |
|
| 37 | + $op = $_POST['op']; |
|
| 38 | 38 | } else { |
| 39 | - if (isset($_GET['op'])) { |
|
| 40 | - $op = $_GET['op']; |
|
| 41 | - } |
|
| 39 | + if (isset($_GET['op'])) { |
|
| 40 | + $op = $_GET['op']; |
|
| 41 | + } |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // V???rification de l'existence et de l'???tat d'???criture des diff???rents r???pertoire de stockage et de cache |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | function show_footer() |
| 67 | 67 | { |
| 68 | - echo "<br><br><div align='center'><a href='http://www.instant-zero.com' target='_blank' title='Instant Zero'><img src='../assets/images/instantzero.gif' alt='Instant Zero' /></a></div>"; |
|
| 68 | + echo "<br><br><div align='center'><a href='http://www.instant-zero.com' target='_blank' title='Instant Zero'><img src='../assets/images/instantzero.gif' alt='Instant Zero' /></a></div>"; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | references_utils::loadLanguageFile('modinfo.php'); |
@@ -76,634 +76,634 @@ discard block |
||
| 76 | 76 | // ****************************************************************************************************************************************** |
| 77 | 77 | switch ($op) { |
| 78 | 78 | |
| 79 | - // **************************************************************************************************************** |
|
| 80 | - case 'default': // Gestion des articles |
|
| 81 | - case 'articles': |
|
| 82 | - // **************************************************************************************************************** |
|
| 83 | - xoops_cp_header(); |
|
| 84 | - // references_adminMenu(0); |
|
| 85 | - $objet = 'articles'; |
|
| 86 | - $items = array(); |
|
| 87 | - if (isset($_GET['move'])) { |
|
| 88 | - $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
|
| 89 | - $ordre = isset($_GET['ordre']) ? (int)$_GET['ordre'] : 0; |
|
| 90 | - if ($_GET['move'] === 'up' && $id > 0) { |
|
| 91 | - $handlers->h_references_articles->moveUp($id, $ordre); |
|
| 92 | - } |
|
| 93 | - if ($_GET['move'] === 'down' && $id > 0) { |
|
| 94 | - $handlers->h_references_articles->moveDown($id, $ordre); |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - $form = "<form method='post' action='$baseurl' name='frmadd$objet' id='frmadd$objet'><input type='hidden' name='op' id='op' value='add$objet' /><input type='submit' name='btngo' id='btngo' value='" . _AM_REFERENCES_ADD_ITEM . "' /></form>"; |
|
| 98 | - echo $form; |
|
| 99 | - $categoriesList = $h_references_categories->getListArray(); |
|
| 100 | - $upText = _AM_REFERENCES_UP; |
|
| 101 | - $downText = _AM_REFERENCES_DOWN; |
|
| 102 | - $upImg = "<a href='$baseurl?op=articles&move=up&id=%d&ordre=%d' title=\"$upText\"><img src='" . REFERENCES_IMAGES_URL . "up.png' alt=\"$upText\" /></a>"; |
|
| 103 | - $downImg = "<a href='$baseurl?op=articles&move=down&id=%d&ordre=%d' title=\"$downText\"><img src='" . REFERENCES_IMAGES_URL . "down.png' alt=\"$downText\" /></a>"; |
|
| 104 | - |
|
| 105 | - $referencesFilter = new references_listFilter($h_references_articles, 'op', 'articles', 'start', $limit, $baseurl, $defaultSortField, $defaultSortOrder, true, REFERENCES_JS_URL); |
|
| 106 | - $referencesFilter->initFilter('article_id', array('dataType' => references_listFilter::FILTER_DATA_NUMERIC, 'fieldType' => references_listFilter::FILTER_FIELD_TEXT, 'size' => 5, 'maxLength' => 10)); |
|
| 107 | - $referencesFilter->initFilter('article_title', array('dataType' => references_listFilter::FILTER_DATA_TEXT, 'fieldType' => references_listFilter::FILTER_FIELD_TEXT, 'size' => 35, 'maxLength' => 255, 'autoComplete' => true)); |
|
| 108 | - $referencesFilter->initFilter('article_weight', array('dataType' => references_listFilter::FILTER_DATA_NUMERIC, 'fieldType' => references_listFilter::FILTER_FIELD_TEXT, 'size' => 5, 'maxLength' => 10)); |
|
| 109 | - |
|
| 110 | - $referencesFilter->initFilter('article_category_id', array('dataType' => references_listFilter::FILTER_DATA_NUMERIC, 'fieldType' => references_listFilter::FILTER_FIELD_SELECT, 'values' => $categoriesList, 'withNull' => true, 'style' => 'width: 170px; max-width: 170px;')); |
|
| 111 | - $referencesFilter->initFilter('article_online', array('dataType' => references_listFilter::FILTER_DATA_NUMERIC, 'fieldType' => references_listFilter::FILTER_FIELD_SELECT, 'values' => array(2 => _YES, 1 => _NO), 'withNull' => true, 'minusOne' => true)); |
|
| 112 | - $sortFields = array('article_id' => _AM_REFERENCES_ID, 'article_title' => _AM_REFERENCES_TITLE, 'article_weight' => _AM_REFERENCES_WEIGHT, 'article_category_id' => _AM_REFERENCES_CATEGORY, 'article_online' => _AM_REFERENCES_ONLINE); |
|
| 113 | - $referencesFilter->setSortFields($sortFields); |
|
| 114 | - |
|
| 115 | - $referencesFilter->filter(); |
|
| 116 | - $itemsCount = $referencesFilter->getCount(); |
|
| 117 | - references_utils::htitle(_MI_REFERENCES_ADMENU0 . ' (' . $itemsCount . ')', 4); |
|
| 118 | - |
|
| 119 | - if ($itemsCount > $limit) { |
|
| 120 | - $pagenav = $referencesFilter->getPager(); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - $items = $referencesFilter->getObjects(); |
|
| 124 | - $visibleCountItems = count($items); |
|
| 125 | - $counter = 0; |
|
| 126 | - $categories = $h_references_categories->getListArray(); |
|
| 127 | - echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'>"; |
|
| 128 | - echo "<tr>\n"; |
|
| 129 | - echo "<form method='post' action='$baseurl'>\n"; |
|
| 130 | - echo "<td colspan='4' align='right'>" . $referencesFilter->getSortPlaceHolderHtmlCode(); |
|
| 131 | - echo $referencesFilter->getClearFilterbutton(); |
|
| 132 | - echo "</td>\n"; |
|
| 133 | - echo "<td colspan='2' align='right'>"; |
|
| 134 | - if (isset($pagenav) && is_object($pagenav)) { |
|
| 135 | - echo $pagenav->renderNav(); |
|
| 136 | - } |
|
| 137 | - echo "</td>\n</tr>\n"; |
|
| 138 | - |
|
| 139 | - echo "<th align='center'>" . _AM_REFERENCES_ID . "</th><th align='center'>" . _AM_REFERENCES_TITLE . "</th><th align='center'>" . _AM_REFERENCES_WEIGHT . "</th><th align='center'>" . _AM_REFERENCES_CATEGORY . "</th><th align='center'>" . _AM_REFERENCES_ONLINE . "</th><th align='center'>" |
|
| 140 | - . _AM_REFERENCES_MANUAL_DATE . "</th><th align='center'>" . _AM_REFERENCES_ACTION . '</th></tr>'; |
|
| 141 | - // Filtres **************************************** |
|
| 142 | - echo "<tr>\n"; |
|
| 143 | - echo "<th align='center'>" . $referencesFilter->getFilterField('article_id') . "</th>\n"; |
|
| 144 | - echo "<th align='center'>" . $referencesFilter->getFilterField('article_title') . "</th>\n"; |
|
| 145 | - echo "<th align='center'>" . $referencesFilter->getFilterField('article_weight') . "</th>\n"; |
|
| 146 | - echo "<th align='center'>" . $referencesFilter->getFilterField('article_category_id') . "</th>\n"; |
|
| 147 | - echo "<th align='center'>" . $referencesFilter->getFilterField('article_online') . "</th>\n"; |
|
| 148 | - echo "<th align='center'> </th>\n"; |
|
| 149 | - echo "<th align='center'>" . $referencesFilter->getGoButton() . "</th></form></tr>\n"; |
|
| 150 | - // ************************************************ |
|
| 151 | - $class = ''; |
|
| 152 | - foreach ($items as $item) { |
|
| 153 | - ++$counter; |
|
| 154 | - $class = ($class === 'even') ? 'odd' : 'even'; |
|
| 155 | - $id = $item->getVar('article_id'); |
|
| 156 | - $action_edit = "<a href='$baseurl?op=edit" . $objet . '&id=' . $id . "' title='" . _EDIT . "'>" . $icones['edit'] . '</a>'; |
|
| 157 | - $action_delete = "<a href='$baseurl?op=delete" . $objet . '&id=' . $id . "' title='" . _DELETE . "'" . $conf_msg . '>' . $icones['delete'] . '</a>'; |
|
| 158 | - $category = isset($categories[$item->getVar('article_category_id')]) ? $categories[$item->getVar('article_category_id')] : ''; |
|
| 159 | - $up = $down = ''; |
|
| 160 | - echo "<tr class='" . $class . "'>\n"; |
|
| 161 | - $ordre = $item->getVar('article_weight'); |
|
| 162 | - if ($counter == 1 && $visibleCountItems > 1) { // Premier ???l???ment |
|
| 163 | - $down = sprintf($downImg, $id, $ordre); |
|
| 164 | - } |
|
| 165 | - if ($counter == $visibleCountItems && $visibleCountItems > 1) { // Dernier ???l???ment |
|
| 166 | - $up = sprintf($upImg, $id, $ordre); |
|
| 167 | - } |
|
| 168 | - if ($counter > 1 & $counter < $visibleCountItems && $visibleCountItems > 1) { // Element dans le milieu |
|
| 169 | - $up = sprintf($upImg, $id, $ordre); |
|
| 170 | - $down = sprintf($downImg, $id, $ordre); |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - echo "<td align='center'>" . $id . '</td>'; |
|
| 174 | - echo "<td align='left'><a target='_blank' href='" . $item->getUrl() . "'>" . $item->getVar('article_title') . '</a></td>'; |
|
| 175 | - echo "<td align='center'>" . $item->getVar('article_weight') . " $up $down</td>"; |
|
| 176 | - echo "<td align='center'>" . $category . '</td>'; |
|
| 177 | - if ($item->isArticleOnline()) { |
|
| 178 | - $statusLink = "<a href='$baseurl?op=offline&id=$id' title='" . _AM_REFERENCES_GO_OFFLINE . "'><img src='" . REFERENCES_IMAGES_URL . "status_online.png' alt='" . _AM_REFERENCES_GO_OFFLINE . "' /></a>"; |
|
| 179 | - } else { |
|
| 180 | - $statusLink = "<a href='$baseurl?op=online&id=$id' title='" . _AM_REFERENCES_GO_ONLINE . "'><img src='" . REFERENCES_IMAGES_URL . "status_offline.png' alt='" . _AM_REFERENCES_GO_ONLINE . "' /></a>"; |
|
| 181 | - } |
|
| 182 | - echo "<td align='center'>" . $statusLink . '</td>'; |
|
| 183 | - echo "<td align='center'>" . $item->getVar('article_date') . '</td>'; |
|
| 184 | - echo "<td align='center'>" . $action_edit . ' ' . $action_delete . "</td>\n"; |
|
| 185 | - echo "<tr>\n"; |
|
| 186 | - } |
|
| 187 | - $class = ($class === 'even') ? 'odd' : 'even'; |
|
| 188 | - echo "<tr class='" . $class . "'>\n"; |
|
| 189 | - echo "<td colspan='7' align='center'>" . $form . "</td>\n"; |
|
| 190 | - echo "</tr>\n"; |
|
| 191 | - echo "</table>\n"; |
|
| 192 | - echo $referencesFilter->getJavascriptInitCode(); |
|
| 193 | - if (isset($pagenav) && is_object($pagenav)) { |
|
| 194 | - echo "<div align='center'>" . $pagenav->renderNav() . '</div>'; |
|
| 195 | - } |
|
| 196 | - echo "<br><br>\n"; |
|
| 197 | - include_once __DIR__ . '/admin_footer.php'; //show_footer(); |
|
| 198 | - break; |
|
| 199 | - |
|
| 200 | - // **************************************************************************************************************** |
|
| 201 | - case 'addarticles': // Ajout d'un article |
|
| 202 | - case 'editarticles': // Edition d'un article |
|
| 203 | - // **************************************************************************************************************** |
|
| 204 | - xoops_cp_header(); |
|
| 205 | - // references_adminMenu(0); |
|
| 206 | - $object = 'articles'; |
|
| 207 | - if ($op == 'edit' . $object) { |
|
| 208 | - $title = _AM_REFERENCES_EDIT_ARTICLE; |
|
| 209 | - $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
|
| 210 | - if (empty($id)) { |
|
| 211 | - references_utils::redirect(_AM_REFERENCES_ERROR_1, $baseurl, 5); |
|
| 212 | - } |
|
| 213 | - // Item exits ? |
|
| 214 | - $item = null; |
|
| 215 | - $item = $h_references_articles->get($id); |
|
| 216 | - if (!is_object($item)) { |
|
| 217 | - references_utils::redirect(_AM_REFERENCES_NOT_FOUND, $baseurl, 5); |
|
| 218 | - } |
|
| 219 | - $edit = true; |
|
| 220 | - $label_submit = _AM_REFERENCES_MODIFY; |
|
| 221 | - } else { |
|
| 222 | - $title = _AM_REFERENCES_ADD_ARTICLE; |
|
| 223 | - $item = $h_references_articles->create(true); |
|
| 224 | - $item->setVar('article_online', true); |
|
| 225 | - if (REFERENCES_AUTO_FILL_MANUAL_DATE) { |
|
| 226 | - $item->setVar('article_date', formatTimestamp(time(), 's')); |
|
| 227 | - } |
|
| 228 | - $label_submit = _AM_REFERENCES_ADD; |
|
| 229 | - $edit = false; |
|
| 230 | - } |
|
| 231 | - $sform = new XoopsThemeForm($title, 'frmadd' . $object, $baseurl); |
|
| 232 | - $sform->setExtra('enctype="multipart/form-data"'); |
|
| 233 | - $sform->addElement(new XoopsFormHidden('op', 'saveedit' . $object)); |
|
| 234 | - $sform->addElement(new XoopsFormHidden('article_id', $item->getVar('article_id'))); |
|
| 235 | - $categories = $h_references_categories->getListArray(); |
|
| 236 | - $categoriesList = new XoopsFormSelect(_AM_REFERENCES_CATEGORY, 'article_category_id', $item->getVar('article_category_id', 'e')); |
|
| 237 | - $categoriesList->addOptionArray($categories); |
|
| 238 | - $sform->addElement($categoriesList, true); |
|
| 239 | - |
|
| 240 | - $sform->addElement(new XoopsFormText(_AM_REFERENCES_TITLE, 'article_title', 50, 255, $item->getVar('article_title', 'e')), true); |
|
| 241 | - $sform->addElement(new XoopsFormRadioYN(_AM_REFERENCES_ONLINE, 'article_online', $item->getVar('article_online', 'e')), true); |
|
| 242 | - $sform->addElement(new XoopsFormText(_AM_REFERENCES_MANUAL_DATE, 'article_date', 30, 30, $item->getVar('article_date', 'e')), false); |
|
| 243 | - $sform->addElement(new XoopsFormTextDateSelect(_AM_REFERENCES_DATE, 'article_timestamp', 15, $item->getVar('article_timestamp', 'e'))); |
|
| 244 | - $sform->addElement(new XoopsFormText(_AM_REFERENCES_WEIGHT, 'article_weight', 5, 5, $item->getVar('article_weight', 'e')), false); |
|
| 245 | - $sform->addElement(new XoopsFormText(_AM_REFERENCES_URL, 'article_externalurl', 50, 255, $item->getVar('article_externalurl', 'e')), false); |
|
| 246 | - |
|
| 247 | - $editor = references_utils::getWysiwygForm(_AM_REFERENCES_TEXT, 'article_text', $item->getVar('article_text', 'e'), 15, 60, 'article_text_hidden'); |
|
| 248 | - if ($editor) { |
|
| 249 | - $sform->addElement($editor, false); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - $editor1 = references_utils::getWysiwygForm(_AM_REFERENCES_TEXT_MORE, 'article_readmore', $item->getVar('article_readmore', 'e'), 15, 60, 'article_readmore_hidden'); |
|
| 253 | - if ($editor1) { |
|
| 254 | - $sform->addElement($editor1, false); |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - if (references_utils::getModuleOption('use_tags') && references_utils::tagModuleExists()) { |
|
| 258 | - require_once XOOPS_ROOT_PATH . '/modules/tag/include/formtag.php'; |
|
| 259 | - $sform->addElement(new XoopsFormTag('item_tag', 60, 255, $item->getVar('article_id'), 0)); |
|
| 260 | - } |
|
| 261 | - // Images |
|
| 262 | - for ($i = 1; $i <= 10; ++$i) { |
|
| 263 | - if ($op == 'edit' . $object && $item->pictureExists($i)) { |
|
| 264 | - $pictureTray = new XoopsFormElementTray(_AM_REFERENCES_CURRENT_PICTURE . ' ' . $i, '<br>'); |
|
| 265 | - $pictureTray->addElement(new XoopsFormLabel('', "<img src='" . $item->getPictureUrl($i) . "' alt='' border='0' />")); |
|
| 266 | - $deleteCheckbox = new XoopsFormCheckBox('', 'delpicture' . $i); |
|
| 267 | - $deleteCheckbox->addOption(1, _DELETE); |
|
| 268 | - $pictureTray->addElement($deleteCheckbox); |
|
| 269 | - $sform->addElement($pictureTray); |
|
| 270 | - unset($pictureTray, $deleteCheckbox); |
|
| 271 | - } |
|
| 272 | - $sform->addElement(new XoopsFormFile(_AM_REFERENCES_IMAGE . ' ' . $i, 'attachedfile' . $i, references_utils::getModuleOption('maxuploadsize')), false); |
|
| 273 | - $fieldName = 'article_picture' . $i . '_text'; |
|
| 274 | - $sform->addElement(new XoopsFormText(_AM_REFERENCES_PICTURE_TEXT . ' ' . $i, $fieldName, 50, 255, $item->getVar($fieldName)), false); |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - // Fichier attach??? |
|
| 278 | - if ($op == 'edit' . $object && $item->attachmentExists()) { |
|
| 279 | - $attachedTray = new XoopsFormElementTray(_AM_REFERENCES_ATTACHED_FILE, '<br>'); |
|
| 280 | - $attachedTray->addElement(new XoopsFormLabel('', "<a href='" . $item->getAttachmentUrl() . "' target='_blank'>" . $item->getVar('article_attached_file') . '</a>')); |
|
| 281 | - $deleteCheckbox = new XoopsFormCheckBox('', 'delattach'); |
|
| 282 | - $deleteCheckbox->addOption(1, _DELETE); |
|
| 283 | - $attachedTray->addElement($deleteCheckbox); |
|
| 284 | - $sform->addElement($attachedTray); |
|
| 285 | - unset($attachedTray, $deleteCheckbox); |
|
| 286 | - } |
|
| 287 | - $sform->addElement(new XoopsFormFile(_AM_REFERENCES_ATTACHED_FILE, 'article_attached_file', references_utils::getModuleOption('maxuploadsize')), false); |
|
| 288 | - |
|
| 289 | - $button_tray = new XoopsFormElementTray('', ''); |
|
| 290 | - $submit_btn = new XoopsFormButton('', 'post', $label_submit, 'submit'); |
|
| 291 | - $button_tray->addElement($submit_btn); |
|
| 292 | - $sform->addElement($button_tray); |
|
| 293 | - $sform = references_utils::formMarkRequiredFields($sform); |
|
| 294 | - $sform->display(); |
|
| 295 | - include_once __DIR__ . '/admin_footer.php'; //show_footer(); |
|
| 296 | - break; |
|
| 297 | - |
|
| 298 | - // **************************************************************************************************************** |
|
| 299 | - case 'saveeditarticles': // Sauvegarde d'un article |
|
| 300 | - // **************************************************************************************************************** |
|
| 301 | - xoops_cp_header(); |
|
| 302 | - $id = isset($_POST['article_id']) ? (int)$_POST['article_id'] : 0; |
|
| 303 | - $opRedirect = 'articles'; |
|
| 304 | - if (!empty($id)) { |
|
| 305 | - $edit = true; |
|
| 306 | - $item = $h_references_articles->get($id); |
|
| 307 | - if (!is_object($item)) { |
|
| 308 | - references_utils::redirect(_AM_REFERENCES_NOT_FOUND, $baseurl, 5); |
|
| 309 | - } |
|
| 310 | - $item->unsetNew(); |
|
| 311 | - } else { |
|
| 312 | - $edit = false; |
|
| 313 | - $item = $h_references_articles->create(true); |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - $item->setVars($_POST); |
|
| 317 | - |
|
| 318 | - // Images |
|
| 319 | - for ($i = 1; $i <= 10; ++$i) { |
|
| 320 | - if (isset($_POST['delpicture' . $i]) && (int)$_POST['delpicture' . $i] == 1) { |
|
| 321 | - $item->deletePicture($i); |
|
| 322 | - $item->setVar('article_picture' . $i, ''); |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - // Upload de l'image et cr???ation de la vignette |
|
| 326 | - $destname = ''; |
|
| 327 | - $return = references_utils::uploadFile($i - 1, references_utils::getModuleOption('images_path')); |
|
| 328 | - if ($return === true) { |
|
| 329 | - if (references_utils::getModuleOption('images_width') > 0 && references_utils::getModuleOption('images_height') > 0) { |
|
| 330 | - references_utils::createThumb(references_utils::getModuleOption('images_path') . '/' . basename($destname), references_utils::getModuleOption('images_path') . '/' . basename($destname), references_utils::getModuleOption('images_width'), |
|
| 331 | - references_utils::getModuleOption('images_height'), true); |
|
| 332 | - } |
|
| 333 | - $newDestName = references_utils::getModuleOption('images_path') . DIRECTORY_SEPARATOR . REFERENCES_THUMBS_PREFIX . basename($destname); |
|
| 334 | - $retval = references_utils::resizePicture(references_utils::getModuleOption('images_path') . '/' . basename($destname), $newDestName, $thumbs_width, $thumbs_height, true); |
|
| 335 | - if ($retval == 1 || $retval == 3) { |
|
| 336 | - $item->setVar('article_picture' . $i, $destname); |
|
| 337 | - } |
|
| 338 | - } else { |
|
| 339 | - if ($return !== false) { |
|
| 340 | - echo $return; |
|
| 341 | - } |
|
| 342 | - } |
|
| 343 | - } |
|
| 344 | - |
|
| 345 | - $timestamp = mktime(0, 0, 0, (int)substr($_POST['article_timestamp'], 5, 2), (int)substr($_POST['article_timestamp'], 8, 2), (int)substr($_POST['article_timestamp'], 0, 4)); |
|
| 346 | - $item->setVar('article_timestamp', $timestamp); |
|
| 347 | - |
|
| 348 | - if (!$edit) { |
|
| 349 | - $item->setVar('article_author', references_utils::getCurrentUserID()); |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - // Suppression ???ventuelle du fichier attach??? |
|
| 353 | - if (isset($_POST['delattach']) && (int)$_POST['delattach'] == 1) { |
|
| 354 | - $item->deleteAttachment(); |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - $destname = ''; |
|
| 358 | - // Upload de la pi???ce jointe |
|
| 359 | - $return = references_utils::uploadFile(10, references_utils::getModuleOption('attached_path')); |
|
| 360 | - if ($return === true) { |
|
| 361 | - $item->setVar('article_attached_file', $destname); |
|
| 362 | - } else { |
|
| 363 | - if ($return !== false) { |
|
| 364 | - echo $return; |
|
| 365 | - } |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - $res = $h_references_articles->insert($item); |
|
| 369 | - if ($res) { |
|
| 370 | - if (references_utils::getModuleOption('use_tags') && references_utils::tagModuleExists()) { |
|
| 371 | - $tag_handler = xoops_getModuleHandler('tag', 'tag'); |
|
| 372 | - $tag_handler->updateByItem($_POST['item_tag'], $item->getVar('article_id'), $xoopsModule->getVar('dirname'), 0); |
|
| 373 | - } |
|
| 374 | - if (!$edit) { |
|
| 375 | - $h_references_articles->notifyNewArticle($item); |
|
| 376 | - } |
|
| 377 | - references_utils::updateCache(); |
|
| 378 | - references_utils::redirect(_AM_REFERENCES_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2); |
|
| 379 | - } else { |
|
| 380 | - references_utils::redirect(_AM_REFERENCES_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5); |
|
| 381 | - } |
|
| 382 | - break; |
|
| 383 | - |
|
| 384 | - // **************************************************************************************************************** |
|
| 385 | - case 'offline': // Mise hors ligne d'un article |
|
| 386 | - case 'online': // Mise en ligne d'un article |
|
| 387 | - // **************************************************************************************************************** |
|
| 388 | - xoops_cp_header(); |
|
| 389 | - $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
|
| 390 | - if (empty($id)) { |
|
| 391 | - references_utils::redirect(_AM_REFERENCES_ERROR_1, $baseurl, 5); |
|
| 392 | - } |
|
| 393 | - $opRedirect = 'articles'; |
|
| 394 | - $item = null; |
|
| 395 | - $item = $h_references_articles->get($id); |
|
| 396 | - if (is_object($item)) { |
|
| 397 | - if ($op === 'offline') { |
|
| 398 | - $res = $h_references_articles->offlineArticle($item); |
|
| 399 | - } else { |
|
| 400 | - $res = $h_references_articles->onlineArticle($item); |
|
| 401 | - } |
|
| 402 | - if ($res) { |
|
| 403 | - references_utils::updateCache(); |
|
| 404 | - references_utils::redirect(_AM_REFERENCES_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2); |
|
| 405 | - } |
|
| 406 | - } |
|
| 407 | - references_utils::redirect(_AM_REFERENCES_NOT_FOUND, $baseurl . '?op=' . $opRedirect, 5); |
|
| 408 | - break; |
|
| 409 | - |
|
| 410 | - // **************************************************************************************************************** |
|
| 411 | - case 'deletearticles': // Suppression d'un article |
|
| 412 | - // **************************************************************************************************************** |
|
| 413 | - xoops_cp_header(); |
|
| 414 | - $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
|
| 415 | - if (empty($id)) { |
|
| 416 | - references_utils::redirect(_AM_REFERENCES_ERROR_1, $baseurl, 5); |
|
| 417 | - } |
|
| 418 | - $opRedirect = 'articles'; |
|
| 419 | - $item = null; |
|
| 420 | - $item = $h_references_articles->get($id); |
|
| 421 | - if (is_object($item)) { |
|
| 422 | - $res = $h_references_articles->deleteArticle($item, true); |
|
| 423 | - if ($res) { |
|
| 424 | - references_utils::updateCache(); |
|
| 425 | - references_utils::redirect(_AM_REFERENCES_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2); |
|
| 426 | - } |
|
| 427 | - } |
|
| 428 | - references_utils::redirect(_AM_REFERENCES_NOT_FOUND, $baseurl . '?op=' . $opRedirect, 5); |
|
| 429 | - break; |
|
| 430 | - |
|
| 431 | - // **************************************************************************************************************** |
|
| 432 | - case 'instant-zero'; // Publicit??? |
|
| 433 | - // **************************************************************************************************************** |
|
| 434 | - xoops_cp_header(); |
|
| 435 | - // references_adminMenu(4); |
|
| 436 | - echo "<iframe src='http://www.instant-zero.com/modules/liaise/?form_id=2' width='100%' height='600' frameborder='0'></iframe>"; |
|
| 437 | - include_once __DIR__ . '/admin_footer.php'; //show_footer(); |
|
| 438 | - break; |
|
| 439 | - |
|
| 440 | - // **************************************************************************************************************** |
|
| 441 | - case 'perms'; // Permissions |
|
| 442 | - // **************************************************************************************************************** |
|
| 443 | - xoops_cp_header(); |
|
| 444 | - // references_adminMenu(3); |
|
| 445 | - require_once XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php'; |
|
| 446 | - $categories = $handlers->h_references_categories->getCategories(); |
|
| 447 | - $permissionsForm = new XoopsGroupPermForm(_AM_REFERENCES_VIEWFORM, $xoopsModule->getVar('mid'), REFERENCES_PERM_READ, _AM_REFERENCES_VIEWFORM_DESC, 'admin/index.php?op=perms', 'true'); |
|
| 448 | - foreach ($categories as $category) { |
|
| 449 | - $permissionsForm->addItem($category->category_id, $category->category_title, 0); |
|
| 450 | - } |
|
| 451 | - echo $permissionsForm->render(); |
|
| 452 | - echo "<br><br><br><br>\n"; |
|
| 453 | - unset($permissionsForm); |
|
| 454 | - include_once __DIR__ . '/admin_footer.php'; //show_footer(); |
|
| 455 | - break; |
|
| 456 | - |
|
| 457 | - // **************************************************************************************************************** |
|
| 458 | - case 'texts': // Gestion des textes |
|
| 459 | - // **************************************************************************************************************** |
|
| 460 | - xoops_cp_header(); |
|
| 461 | - // references_adminMenu(2); |
|
| 462 | - require_once REFERENCES_PATH . 'class/registryfile.php'; |
|
| 463 | - $registry = new references_registryfile(); |
|
| 464 | - |
|
| 465 | - $sform = new XoopsThemeForm(_MI_REFERENCES_ADMENU1, 'frmatxt', $baseurl); |
|
| 466 | - $sform->addElement(new XoopsFormHidden('op', 'savetexts')); |
|
| 467 | - // Texte ??? afficher sur la page d'index du module |
|
| 468 | - $editor1 = references_utils::getWysiwygForm(_AM_REFERENCES_TEXT1, 'text1', $registry->getfile(REFERENCES_TEXTFILE1), 5, 60, 'hometext1_hidden'); |
|
| 469 | - if ($editor1) { |
|
| 470 | - $sform->addElement($editor1, false); |
|
| 471 | - } |
|
| 472 | - $button_tray = new XoopsFormElementTray('', ''); |
|
| 473 | - $submit_btn = new XoopsFormButton('', 'post', _AM_REFERENCES_MODIFY, 'submit'); |
|
| 474 | - $button_tray->addElement($submit_btn); |
|
| 475 | - $sform->addElement($button_tray); |
|
| 476 | - $sform = references_utils::formMarkRequiredFields($sform); |
|
| 477 | - $sform->display(); |
|
| 478 | - include_once __DIR__ . '/admin_footer.php'; //show_footer(); |
|
| 479 | - break; |
|
| 480 | - |
|
| 481 | - // **************************************************************************************************************** |
|
| 482 | - case 'savetexts': // Sauvegarde des textes |
|
| 483 | - // **************************************************************************************************************** |
|
| 484 | - xoops_cp_header(); |
|
| 485 | - require_once REFERENCES_PATH . 'class/registryfile.php'; |
|
| 486 | - $registry = new references_registryfile(); |
|
| 487 | - $myts = MyTextSanitizer::getInstance(); |
|
| 488 | - $registry->savefile($myts->stripSlashesGPC($_POST['text1']), REFERENCES_TEXTFILE1); |
|
| 489 | - references_utils::updateCache(); |
|
| 490 | - references_utils::redirect(_AM_REFERENCES_SAVE_OK, $baseurl . '?op=texts', 2); |
|
| 491 | - break; |
|
| 492 | - |
|
| 493 | - // **************************************************************************************************************** |
|
| 494 | - case 'maintain': // Maintenance des tables |
|
| 495 | - // **************************************************************************************************************** |
|
| 496 | - xoops_cp_header(); |
|
| 497 | - // references_adminMenu(); |
|
| 498 | - references_utils::maintainTablesCache(); |
|
| 499 | - references_utils::redirect(_AM_REFERENCES_SAVE_OK, $baseurl, 2); |
|
| 500 | - break; |
|
| 501 | - |
|
| 502 | - // **************************************************************************************************************** |
|
| 503 | - case 'categories': // Gestion des cat???gories |
|
| 504 | - // **************************************************************************************************************** |
|
| 505 | - xoops_cp_header(); |
|
| 506 | - // references_adminMenu(1); |
|
| 507 | - $start = isset($_GET['start']) ? (int)$_GET['start'] : 0; |
|
| 508 | - $objet = 'categories'; |
|
| 509 | - $items = array(); |
|
| 510 | - $form = "<form method='post' action='$baseurl' name='frmadd$objet' id='frmadd$objet'><input type='hidden' name='op' id='op' value='add$objet' /><input type='submit' name='btngo' id='btngo' value='" . _AM_REFERENCES_ADD_ITEM . "' /></form>"; |
|
| 511 | - echo $form; |
|
| 512 | - references_utils::htitle(_MI_REFERENCES_ADMENU2, 4); |
|
| 513 | - |
|
| 514 | - $itemsCount = $h_references_categories->getCount(); |
|
| 515 | - if ($itemsCount > $limit) { |
|
| 516 | - $pagenav = new XoopsPageNav($itemsCount, $limit, $start, 'start'); |
|
| 517 | - } |
|
| 518 | - |
|
| 519 | - $items = $h_references_categories->getCategories($start, $limit); |
|
| 520 | - if (isset($pagenav) && is_object($pagenav)) { |
|
| 521 | - echo "<div align='right'>" . $pagenav->renderNav() . '</div>'; |
|
| 522 | - } |
|
| 523 | - echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'>"; |
|
| 524 | - |
|
| 525 | - echo "<tr><th align='center'>" . _AM_REFERENCES_ID . "</th><th align='center'>" . _AM_REFERENCES_TITLE . "</th><th align='center'>" . _AM_REFERENCES_CATEGORY_WEIGHT . "</th><th align='center'>" . _AM_REFERENCES_ACTION . '</th></tr>'; |
|
| 526 | - |
|
| 527 | - $class = ''; |
|
| 528 | - foreach ($items as $item) { |
|
| 529 | - $class = ($class === 'even') ? 'odd' : 'even'; |
|
| 530 | - $id = $item->getVar('category_id'); |
|
| 531 | - $action_edit = "<a href='$baseurl?op=edit" . $objet . '&id=' . $id . "' title='" . _EDIT . "'>" . $icones['edit'] . '</a>'; |
|
| 532 | - $action_delete = "<a href='$baseurl?op=delete" . $objet . '&id=' . $id . "' title='" . _DELETE . "'" . $conf_msg . '>' . $icones['delete'] . '</a>'; |
|
| 533 | - |
|
| 534 | - echo "<tr class='" . $class . "'>\n"; |
|
| 535 | - echo "<td align='center'>" . $id . '</td>'; |
|
| 536 | - echo "<td align='left'><a target='_blank' href='" . $item->getUrl() . "'>" . $item->getVar('category_title') . '</a></td>'; |
|
| 537 | - echo "<td align='right'>" . $item->getVar('category_weight') . '</td>'; |
|
| 538 | - echo "<td align='center'>" . $action_edit . ' ' . $action_delete . "</td>\n"; |
|
| 539 | - echo "<tr>\n"; |
|
| 540 | - } |
|
| 541 | - $class = ($class === 'even') ? 'odd' : 'even'; |
|
| 542 | - echo "<tr class='" . $class . "'>\n"; |
|
| 543 | - echo "<td colspan='4' align='center'>" . $form . "</td>\n"; |
|
| 544 | - echo "</tr>\n"; |
|
| 545 | - echo "</table>\n"; |
|
| 546 | - if (isset($pagenav) && is_object($pagenav)) { |
|
| 547 | - echo "<div align='center'>" . $pagenav->renderNav() . '</div>'; |
|
| 548 | - } |
|
| 549 | - echo "<br><br>\n"; |
|
| 550 | - include_once __DIR__ . '/admin_footer.php'; //show_footer(); |
|
| 551 | - break; |
|
| 552 | - |
|
| 553 | - // **************************************************************************************************************** |
|
| 554 | - case 'addcategories': // Ajout d'une cat???gorie |
|
| 555 | - case 'editcategories': // Edition d'une categories |
|
| 556 | - // **************************************************************************************************************** |
|
| 557 | - xoops_cp_header(); |
|
| 558 | - // references_adminMenu(1); |
|
| 559 | - $object = 'categories'; |
|
| 560 | - if ($op == 'edit' . $object) { |
|
| 561 | - $title = _AM_REFERENCES_EDIT_CATEGORY; |
|
| 562 | - $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
|
| 563 | - if (empty($id)) { |
|
| 564 | - references_utils::redirect(_AM_REFERENCES_ERROR_1, $baseurl, 5); |
|
| 565 | - } |
|
| 566 | - // Item exits ? |
|
| 567 | - $item = null; |
|
| 568 | - $item = $h_references_categories->get($id); |
|
| 569 | - if (!is_object($item)) { |
|
| 570 | - references_utils::redirect(_AM_REFERENCES_NOT_FOUND, $baseurl, 5); |
|
| 571 | - } |
|
| 572 | - $edit = true; |
|
| 573 | - $label_submit = _AM_REFERENCES_MODIFY; |
|
| 574 | - } else { |
|
| 575 | - $title = _AM_REFERENCES_ADD_CATEGORY; |
|
| 576 | - $item = $h_references_categories->create(true); |
|
| 577 | - $label_submit = _AM_REFERENCES_ADD; |
|
| 578 | - $edit = false; |
|
| 579 | - } |
|
| 580 | - $sform = new XoopsThemeForm($title, 'frmadd' . $object, $baseurl); |
|
| 581 | - $sform->addElement(new XoopsFormHidden('op', 'saveedit' . $object)); |
|
| 582 | - $sform->addElement(new XoopsFormHidden('category_id', $item->getVar('category_id'))); |
|
| 583 | - $sform->addElement(new XoopsFormText(_AM_REFERENCES_TITLE, 'category_title', 50, 255, $item->getVar('category_title', 'e')), true); |
|
| 584 | - $sform->addElement(new XoopsFormText(_AM_REFERENCES_CATEGORY_WEIGHT, 'category_weight', 10, 10, $item->getVar('category_weight', 'e')), true); |
|
| 585 | - $editor = references_utils::getWysiwygForm(_AM_REFERENCES_DESCRIPTION, 'category_description', $item->getVar('category_description', 'e'), 15, 60, 'category_description_hidden'); |
|
| 586 | - if ($editor) { |
|
| 587 | - $sform->addElement($editor, false); |
|
| 588 | - } |
|
| 589 | - |
|
| 590 | - // Permissions |
|
| 591 | - $membersHandler = xoops_getHandler('member'); |
|
| 592 | - $allGroupsList = $membersHandler->getGroupList(); |
|
| 593 | - $permHandler = xoops_getHandler('groupperm'); |
|
| 594 | - $allGroupsIds = array_keys($allGroupsList); |
|
| 595 | - |
|
| 596 | - $groupsIds = array(); |
|
| 597 | - if ($edit) { |
|
| 598 | - $groupsIds = $permHandler->getGroupIds(REFERENCES_PERM_READ, $item->getVar('category_id'), $xoopsModule->getVar('mid')); |
|
| 599 | - $groupsIds = array_values($groupsIds); |
|
| 600 | - $groupsThatCanViewCheckbox = new XoopsFormCheckBox(_AM_REFERENCES_VIEWFORM, 'groups_references_can_view[]', $groupsIds); |
|
| 601 | - } else { |
|
| 602 | - $groupsThatCanViewCheckbox = new XoopsFormCheckBox(_AM_REFERENCES_VIEWFORM, 'groups_references_can_view[]', $allGroupsIds); |
|
| 603 | - } |
|
| 604 | - $groupsThatCanViewCheckbox->addOptionArray($allGroupsList); |
|
| 605 | - $sform->addElement($groupsThatCanViewCheckbox); |
|
| 606 | - // ***** |
|
| 607 | - |
|
| 608 | - $button_tray = new XoopsFormElementTray('', ''); |
|
| 609 | - $submit_btn = new XoopsFormButton('', 'post', $label_submit, 'submit'); |
|
| 610 | - $button_tray->addElement($submit_btn); |
|
| 611 | - $sform->addElement($button_tray); |
|
| 612 | - $sform = references_utils::formMarkRequiredFields($sform); |
|
| 613 | - $sform->display(); |
|
| 614 | - include_once __DIR__ . '/admin_footer.php'; //show_footer(); |
|
| 615 | - break; |
|
| 616 | - |
|
| 617 | - // **************************************************************************************************************** |
|
| 618 | - case 'saveeditcategories': // Sauvegarde d'une cat???gorie |
|
| 619 | - // **************************************************************************************************************** |
|
| 620 | - xoops_cp_header(); |
|
| 621 | - $id = isset($_POST['category_id']) ? (int)$_POST['category_id'] : 0; |
|
| 622 | - $opRedirect = 'categories'; |
|
| 623 | - if (!empty($id)) { |
|
| 624 | - $edit = true; |
|
| 625 | - $item = $h_references_categories->get($id); |
|
| 626 | - if (!is_object($item)) { |
|
| 627 | - references_utils::redirect(_AM_REFERENCES_NOT_FOUND, $baseurl, 5); |
|
| 628 | - } |
|
| 629 | - $item->unsetNew(); |
|
| 630 | - } else { |
|
| 631 | - $edit = false; |
|
| 632 | - $item = $h_references_categories->create(true); |
|
| 633 | - } |
|
| 634 | - |
|
| 635 | - $item->setVars($_POST); |
|
| 636 | - |
|
| 637 | - $res = $h_references_categories->insert($item); |
|
| 638 | - if ($res) { |
|
| 639 | - // Permissions |
|
| 640 | - // Suppression des permissions actuelles |
|
| 641 | - $gperm_handler = xoops_getHandler('groupperm'); |
|
| 642 | - $criteria = new CriteriaCompo(); |
|
| 643 | - $criteria->add(new Criteria('gperm_itemid', $item->category_id, '=')); |
|
| 644 | - $criteria->add(new Criteria('gperm_modid', $xoopsModule->getVar('mid'), '=')); |
|
| 645 | - $criteria->add(new Criteria('gperm_name', REFERENCES_PERM_READ, '=')); |
|
| 646 | - $gperm_handler->deleteAll($criteria); |
|
| 647 | - // Sauvegarde des nouvelles permissions, si elles existente |
|
| 648 | - if (isset($_POST['groups_references_can_view'])) { |
|
| 649 | - foreach ($_POST['groups_references_can_view'] as $groupId) { |
|
| 650 | - $gperm_handler->addRight(REFERENCES_PERM_READ, $item->category_id, $groupId, $xoopsModule->getVar('mid')); |
|
| 651 | - } |
|
| 652 | - } |
|
| 653 | - // **** |
|
| 654 | - if (!$edit) { |
|
| 655 | - $h_references_categories->notifyNewCategory($item); |
|
| 656 | - } |
|
| 657 | - references_utils::updateCache(); |
|
| 658 | - references_utils::redirect(_AM_REFERENCES_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2); |
|
| 659 | - } else { |
|
| 660 | - references_utils::redirect(_AM_REFERENCES_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5); |
|
| 661 | - } |
|
| 662 | - break; |
|
| 663 | - |
|
| 664 | - // **************************************************************************************************************** |
|
| 665 | - case 'deletecategories': // Suppression d'une cat???gorie |
|
| 666 | - // **************************************************************************************************************** |
|
| 667 | - xoops_cp_header(); |
|
| 668 | - $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
|
| 669 | - if (empty($id)) { |
|
| 670 | - references_utils::redirect(_AM_REFERENCES_ERROR_1, $baseurl, 5); |
|
| 671 | - } |
|
| 672 | - $opRedirect = 'categories'; |
|
| 673 | - $item = null; |
|
| 674 | - $item = $h_references_categories->get($id); |
|
| 675 | - if (is_object($item)) { |
|
| 676 | - $res = $h_references_categories->delete($item, true); |
|
| 677 | - if ($res) { |
|
| 678 | - references_utils::updateCache(); |
|
| 679 | - references_utils::redirect(_AM_REFERENCES_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2); |
|
| 680 | - } |
|
| 681 | - } |
|
| 682 | - references_utils::redirect(_AM_REFERENCES_NOT_FOUND, $baseurl . '?op=' . $opRedirect, 5); |
|
| 683 | - break; |
|
| 684 | - |
|
| 685 | - // **************************************************************************************************************** |
|
| 686 | - case 'autocomplete': // Ajax, autocompl???tion |
|
| 687 | - // **************************************************************************************************************** |
|
| 688 | - if (!isset($xoopsUser) || !is_object($xoopsUser)) { |
|
| 689 | - exit; |
|
| 690 | - } |
|
| 691 | - if (!references_utils::isAdmin()) { |
|
| 692 | - exit; |
|
| 693 | - } |
|
| 694 | - error_reporting(0); |
|
| 695 | - @$xoopsLogger->activated = false; |
|
| 696 | - $handler = isset($_REQUEST['handler']) ? $_REQUEST['handler'] : ''; |
|
| 697 | - if ($handler != '') { |
|
| 698 | - switch ($handler) { |
|
| 699 | - case 'references_articles': |
|
| 700 | - $referencesFilter = new references_listFilter($h_references_articles, 'op', 'articles', 'start', $limit, $baseurl, 'article_title', 'ASC', true, REFERENCES_JS_URL); |
|
| 701 | - $referencesFilter->initFilter('article_title', array('dataType' => references_listFilter::FILTER_DATA_TEXT, 'fieldType' => references_listFilter::FILTER_FIELD_TEXT, 'size' => 35, 'maxLength' => 255, 'autoComplete' => true)); |
|
| 702 | - echo utf8_encode($referencesFilter->autoComplete($_REQUEST['q'], $_REQUEST['limit'], $_REQUEST['field'])); |
|
| 703 | - break; |
|
| 704 | - } |
|
| 705 | - } |
|
| 706 | - exit; |
|
| 707 | - break; |
|
| 79 | + // **************************************************************************************************************** |
|
| 80 | + case 'default': // Gestion des articles |
|
| 81 | + case 'articles': |
|
| 82 | + // **************************************************************************************************************** |
|
| 83 | + xoops_cp_header(); |
|
| 84 | + // references_adminMenu(0); |
|
| 85 | + $objet = 'articles'; |
|
| 86 | + $items = array(); |
|
| 87 | + if (isset($_GET['move'])) { |
|
| 88 | + $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
|
| 89 | + $ordre = isset($_GET['ordre']) ? (int)$_GET['ordre'] : 0; |
|
| 90 | + if ($_GET['move'] === 'up' && $id > 0) { |
|
| 91 | + $handlers->h_references_articles->moveUp($id, $ordre); |
|
| 92 | + } |
|
| 93 | + if ($_GET['move'] === 'down' && $id > 0) { |
|
| 94 | + $handlers->h_references_articles->moveDown($id, $ordre); |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + $form = "<form method='post' action='$baseurl' name='frmadd$objet' id='frmadd$objet'><input type='hidden' name='op' id='op' value='add$objet' /><input type='submit' name='btngo' id='btngo' value='" . _AM_REFERENCES_ADD_ITEM . "' /></form>"; |
|
| 98 | + echo $form; |
|
| 99 | + $categoriesList = $h_references_categories->getListArray(); |
|
| 100 | + $upText = _AM_REFERENCES_UP; |
|
| 101 | + $downText = _AM_REFERENCES_DOWN; |
|
| 102 | + $upImg = "<a href='$baseurl?op=articles&move=up&id=%d&ordre=%d' title=\"$upText\"><img src='" . REFERENCES_IMAGES_URL . "up.png' alt=\"$upText\" /></a>"; |
|
| 103 | + $downImg = "<a href='$baseurl?op=articles&move=down&id=%d&ordre=%d' title=\"$downText\"><img src='" . REFERENCES_IMAGES_URL . "down.png' alt=\"$downText\" /></a>"; |
|
| 104 | + |
|
| 105 | + $referencesFilter = new references_listFilter($h_references_articles, 'op', 'articles', 'start', $limit, $baseurl, $defaultSortField, $defaultSortOrder, true, REFERENCES_JS_URL); |
|
| 106 | + $referencesFilter->initFilter('article_id', array('dataType' => references_listFilter::FILTER_DATA_NUMERIC, 'fieldType' => references_listFilter::FILTER_FIELD_TEXT, 'size' => 5, 'maxLength' => 10)); |
|
| 107 | + $referencesFilter->initFilter('article_title', array('dataType' => references_listFilter::FILTER_DATA_TEXT, 'fieldType' => references_listFilter::FILTER_FIELD_TEXT, 'size' => 35, 'maxLength' => 255, 'autoComplete' => true)); |
|
| 108 | + $referencesFilter->initFilter('article_weight', array('dataType' => references_listFilter::FILTER_DATA_NUMERIC, 'fieldType' => references_listFilter::FILTER_FIELD_TEXT, 'size' => 5, 'maxLength' => 10)); |
|
| 109 | + |
|
| 110 | + $referencesFilter->initFilter('article_category_id', array('dataType' => references_listFilter::FILTER_DATA_NUMERIC, 'fieldType' => references_listFilter::FILTER_FIELD_SELECT, 'values' => $categoriesList, 'withNull' => true, 'style' => 'width: 170px; max-width: 170px;')); |
|
| 111 | + $referencesFilter->initFilter('article_online', array('dataType' => references_listFilter::FILTER_DATA_NUMERIC, 'fieldType' => references_listFilter::FILTER_FIELD_SELECT, 'values' => array(2 => _YES, 1 => _NO), 'withNull' => true, 'minusOne' => true)); |
|
| 112 | + $sortFields = array('article_id' => _AM_REFERENCES_ID, 'article_title' => _AM_REFERENCES_TITLE, 'article_weight' => _AM_REFERENCES_WEIGHT, 'article_category_id' => _AM_REFERENCES_CATEGORY, 'article_online' => _AM_REFERENCES_ONLINE); |
|
| 113 | + $referencesFilter->setSortFields($sortFields); |
|
| 114 | + |
|
| 115 | + $referencesFilter->filter(); |
|
| 116 | + $itemsCount = $referencesFilter->getCount(); |
|
| 117 | + references_utils::htitle(_MI_REFERENCES_ADMENU0 . ' (' . $itemsCount . ')', 4); |
|
| 118 | + |
|
| 119 | + if ($itemsCount > $limit) { |
|
| 120 | + $pagenav = $referencesFilter->getPager(); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + $items = $referencesFilter->getObjects(); |
|
| 124 | + $visibleCountItems = count($items); |
|
| 125 | + $counter = 0; |
|
| 126 | + $categories = $h_references_categories->getListArray(); |
|
| 127 | + echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'>"; |
|
| 128 | + echo "<tr>\n"; |
|
| 129 | + echo "<form method='post' action='$baseurl'>\n"; |
|
| 130 | + echo "<td colspan='4' align='right'>" . $referencesFilter->getSortPlaceHolderHtmlCode(); |
|
| 131 | + echo $referencesFilter->getClearFilterbutton(); |
|
| 132 | + echo "</td>\n"; |
|
| 133 | + echo "<td colspan='2' align='right'>"; |
|
| 134 | + if (isset($pagenav) && is_object($pagenav)) { |
|
| 135 | + echo $pagenav->renderNav(); |
|
| 136 | + } |
|
| 137 | + echo "</td>\n</tr>\n"; |
|
| 138 | + |
|
| 139 | + echo "<th align='center'>" . _AM_REFERENCES_ID . "</th><th align='center'>" . _AM_REFERENCES_TITLE . "</th><th align='center'>" . _AM_REFERENCES_WEIGHT . "</th><th align='center'>" . _AM_REFERENCES_CATEGORY . "</th><th align='center'>" . _AM_REFERENCES_ONLINE . "</th><th align='center'>" |
|
| 140 | + . _AM_REFERENCES_MANUAL_DATE . "</th><th align='center'>" . _AM_REFERENCES_ACTION . '</th></tr>'; |
|
| 141 | + // Filtres **************************************** |
|
| 142 | + echo "<tr>\n"; |
|
| 143 | + echo "<th align='center'>" . $referencesFilter->getFilterField('article_id') . "</th>\n"; |
|
| 144 | + echo "<th align='center'>" . $referencesFilter->getFilterField('article_title') . "</th>\n"; |
|
| 145 | + echo "<th align='center'>" . $referencesFilter->getFilterField('article_weight') . "</th>\n"; |
|
| 146 | + echo "<th align='center'>" . $referencesFilter->getFilterField('article_category_id') . "</th>\n"; |
|
| 147 | + echo "<th align='center'>" . $referencesFilter->getFilterField('article_online') . "</th>\n"; |
|
| 148 | + echo "<th align='center'> </th>\n"; |
|
| 149 | + echo "<th align='center'>" . $referencesFilter->getGoButton() . "</th></form></tr>\n"; |
|
| 150 | + // ************************************************ |
|
| 151 | + $class = ''; |
|
| 152 | + foreach ($items as $item) { |
|
| 153 | + ++$counter; |
|
| 154 | + $class = ($class === 'even') ? 'odd' : 'even'; |
|
| 155 | + $id = $item->getVar('article_id'); |
|
| 156 | + $action_edit = "<a href='$baseurl?op=edit" . $objet . '&id=' . $id . "' title='" . _EDIT . "'>" . $icones['edit'] . '</a>'; |
|
| 157 | + $action_delete = "<a href='$baseurl?op=delete" . $objet . '&id=' . $id . "' title='" . _DELETE . "'" . $conf_msg . '>' . $icones['delete'] . '</a>'; |
|
| 158 | + $category = isset($categories[$item->getVar('article_category_id')]) ? $categories[$item->getVar('article_category_id')] : ''; |
|
| 159 | + $up = $down = ''; |
|
| 160 | + echo "<tr class='" . $class . "'>\n"; |
|
| 161 | + $ordre = $item->getVar('article_weight'); |
|
| 162 | + if ($counter == 1 && $visibleCountItems > 1) { // Premier ???l???ment |
|
| 163 | + $down = sprintf($downImg, $id, $ordre); |
|
| 164 | + } |
|
| 165 | + if ($counter == $visibleCountItems && $visibleCountItems > 1) { // Dernier ???l???ment |
|
| 166 | + $up = sprintf($upImg, $id, $ordre); |
|
| 167 | + } |
|
| 168 | + if ($counter > 1 & $counter < $visibleCountItems && $visibleCountItems > 1) { // Element dans le milieu |
|
| 169 | + $up = sprintf($upImg, $id, $ordre); |
|
| 170 | + $down = sprintf($downImg, $id, $ordre); |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + echo "<td align='center'>" . $id . '</td>'; |
|
| 174 | + echo "<td align='left'><a target='_blank' href='" . $item->getUrl() . "'>" . $item->getVar('article_title') . '</a></td>'; |
|
| 175 | + echo "<td align='center'>" . $item->getVar('article_weight') . " $up $down</td>"; |
|
| 176 | + echo "<td align='center'>" . $category . '</td>'; |
|
| 177 | + if ($item->isArticleOnline()) { |
|
| 178 | + $statusLink = "<a href='$baseurl?op=offline&id=$id' title='" . _AM_REFERENCES_GO_OFFLINE . "'><img src='" . REFERENCES_IMAGES_URL . "status_online.png' alt='" . _AM_REFERENCES_GO_OFFLINE . "' /></a>"; |
|
| 179 | + } else { |
|
| 180 | + $statusLink = "<a href='$baseurl?op=online&id=$id' title='" . _AM_REFERENCES_GO_ONLINE . "'><img src='" . REFERENCES_IMAGES_URL . "status_offline.png' alt='" . _AM_REFERENCES_GO_ONLINE . "' /></a>"; |
|
| 181 | + } |
|
| 182 | + echo "<td align='center'>" . $statusLink . '</td>'; |
|
| 183 | + echo "<td align='center'>" . $item->getVar('article_date') . '</td>'; |
|
| 184 | + echo "<td align='center'>" . $action_edit . ' ' . $action_delete . "</td>\n"; |
|
| 185 | + echo "<tr>\n"; |
|
| 186 | + } |
|
| 187 | + $class = ($class === 'even') ? 'odd' : 'even'; |
|
| 188 | + echo "<tr class='" . $class . "'>\n"; |
|
| 189 | + echo "<td colspan='7' align='center'>" . $form . "</td>\n"; |
|
| 190 | + echo "</tr>\n"; |
|
| 191 | + echo "</table>\n"; |
|
| 192 | + echo $referencesFilter->getJavascriptInitCode(); |
|
| 193 | + if (isset($pagenav) && is_object($pagenav)) { |
|
| 194 | + echo "<div align='center'>" . $pagenav->renderNav() . '</div>'; |
|
| 195 | + } |
|
| 196 | + echo "<br><br>\n"; |
|
| 197 | + include_once __DIR__ . '/admin_footer.php'; //show_footer(); |
|
| 198 | + break; |
|
| 199 | + |
|
| 200 | + // **************************************************************************************************************** |
|
| 201 | + case 'addarticles': // Ajout d'un article |
|
| 202 | + case 'editarticles': // Edition d'un article |
|
| 203 | + // **************************************************************************************************************** |
|
| 204 | + xoops_cp_header(); |
|
| 205 | + // references_adminMenu(0); |
|
| 206 | + $object = 'articles'; |
|
| 207 | + if ($op == 'edit' . $object) { |
|
| 208 | + $title = _AM_REFERENCES_EDIT_ARTICLE; |
|
| 209 | + $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
|
| 210 | + if (empty($id)) { |
|
| 211 | + references_utils::redirect(_AM_REFERENCES_ERROR_1, $baseurl, 5); |
|
| 212 | + } |
|
| 213 | + // Item exits ? |
|
| 214 | + $item = null; |
|
| 215 | + $item = $h_references_articles->get($id); |
|
| 216 | + if (!is_object($item)) { |
|
| 217 | + references_utils::redirect(_AM_REFERENCES_NOT_FOUND, $baseurl, 5); |
|
| 218 | + } |
|
| 219 | + $edit = true; |
|
| 220 | + $label_submit = _AM_REFERENCES_MODIFY; |
|
| 221 | + } else { |
|
| 222 | + $title = _AM_REFERENCES_ADD_ARTICLE; |
|
| 223 | + $item = $h_references_articles->create(true); |
|
| 224 | + $item->setVar('article_online', true); |
|
| 225 | + if (REFERENCES_AUTO_FILL_MANUAL_DATE) { |
|
| 226 | + $item->setVar('article_date', formatTimestamp(time(), 's')); |
|
| 227 | + } |
|
| 228 | + $label_submit = _AM_REFERENCES_ADD; |
|
| 229 | + $edit = false; |
|
| 230 | + } |
|
| 231 | + $sform = new XoopsThemeForm($title, 'frmadd' . $object, $baseurl); |
|
| 232 | + $sform->setExtra('enctype="multipart/form-data"'); |
|
| 233 | + $sform->addElement(new XoopsFormHidden('op', 'saveedit' . $object)); |
|
| 234 | + $sform->addElement(new XoopsFormHidden('article_id', $item->getVar('article_id'))); |
|
| 235 | + $categories = $h_references_categories->getListArray(); |
|
| 236 | + $categoriesList = new XoopsFormSelect(_AM_REFERENCES_CATEGORY, 'article_category_id', $item->getVar('article_category_id', 'e')); |
|
| 237 | + $categoriesList->addOptionArray($categories); |
|
| 238 | + $sform->addElement($categoriesList, true); |
|
| 239 | + |
|
| 240 | + $sform->addElement(new XoopsFormText(_AM_REFERENCES_TITLE, 'article_title', 50, 255, $item->getVar('article_title', 'e')), true); |
|
| 241 | + $sform->addElement(new XoopsFormRadioYN(_AM_REFERENCES_ONLINE, 'article_online', $item->getVar('article_online', 'e')), true); |
|
| 242 | + $sform->addElement(new XoopsFormText(_AM_REFERENCES_MANUAL_DATE, 'article_date', 30, 30, $item->getVar('article_date', 'e')), false); |
|
| 243 | + $sform->addElement(new XoopsFormTextDateSelect(_AM_REFERENCES_DATE, 'article_timestamp', 15, $item->getVar('article_timestamp', 'e'))); |
|
| 244 | + $sform->addElement(new XoopsFormText(_AM_REFERENCES_WEIGHT, 'article_weight', 5, 5, $item->getVar('article_weight', 'e')), false); |
|
| 245 | + $sform->addElement(new XoopsFormText(_AM_REFERENCES_URL, 'article_externalurl', 50, 255, $item->getVar('article_externalurl', 'e')), false); |
|
| 246 | + |
|
| 247 | + $editor = references_utils::getWysiwygForm(_AM_REFERENCES_TEXT, 'article_text', $item->getVar('article_text', 'e'), 15, 60, 'article_text_hidden'); |
|
| 248 | + if ($editor) { |
|
| 249 | + $sform->addElement($editor, false); |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + $editor1 = references_utils::getWysiwygForm(_AM_REFERENCES_TEXT_MORE, 'article_readmore', $item->getVar('article_readmore', 'e'), 15, 60, 'article_readmore_hidden'); |
|
| 253 | + if ($editor1) { |
|
| 254 | + $sform->addElement($editor1, false); |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + if (references_utils::getModuleOption('use_tags') && references_utils::tagModuleExists()) { |
|
| 258 | + require_once XOOPS_ROOT_PATH . '/modules/tag/include/formtag.php'; |
|
| 259 | + $sform->addElement(new XoopsFormTag('item_tag', 60, 255, $item->getVar('article_id'), 0)); |
|
| 260 | + } |
|
| 261 | + // Images |
|
| 262 | + for ($i = 1; $i <= 10; ++$i) { |
|
| 263 | + if ($op == 'edit' . $object && $item->pictureExists($i)) { |
|
| 264 | + $pictureTray = new XoopsFormElementTray(_AM_REFERENCES_CURRENT_PICTURE . ' ' . $i, '<br>'); |
|
| 265 | + $pictureTray->addElement(new XoopsFormLabel('', "<img src='" . $item->getPictureUrl($i) . "' alt='' border='0' />")); |
|
| 266 | + $deleteCheckbox = new XoopsFormCheckBox('', 'delpicture' . $i); |
|
| 267 | + $deleteCheckbox->addOption(1, _DELETE); |
|
| 268 | + $pictureTray->addElement($deleteCheckbox); |
|
| 269 | + $sform->addElement($pictureTray); |
|
| 270 | + unset($pictureTray, $deleteCheckbox); |
|
| 271 | + } |
|
| 272 | + $sform->addElement(new XoopsFormFile(_AM_REFERENCES_IMAGE . ' ' . $i, 'attachedfile' . $i, references_utils::getModuleOption('maxuploadsize')), false); |
|
| 273 | + $fieldName = 'article_picture' . $i . '_text'; |
|
| 274 | + $sform->addElement(new XoopsFormText(_AM_REFERENCES_PICTURE_TEXT . ' ' . $i, $fieldName, 50, 255, $item->getVar($fieldName)), false); |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + // Fichier attach??? |
|
| 278 | + if ($op == 'edit' . $object && $item->attachmentExists()) { |
|
| 279 | + $attachedTray = new XoopsFormElementTray(_AM_REFERENCES_ATTACHED_FILE, '<br>'); |
|
| 280 | + $attachedTray->addElement(new XoopsFormLabel('', "<a href='" . $item->getAttachmentUrl() . "' target='_blank'>" . $item->getVar('article_attached_file') . '</a>')); |
|
| 281 | + $deleteCheckbox = new XoopsFormCheckBox('', 'delattach'); |
|
| 282 | + $deleteCheckbox->addOption(1, _DELETE); |
|
| 283 | + $attachedTray->addElement($deleteCheckbox); |
|
| 284 | + $sform->addElement($attachedTray); |
|
| 285 | + unset($attachedTray, $deleteCheckbox); |
|
| 286 | + } |
|
| 287 | + $sform->addElement(new XoopsFormFile(_AM_REFERENCES_ATTACHED_FILE, 'article_attached_file', references_utils::getModuleOption('maxuploadsize')), false); |
|
| 288 | + |
|
| 289 | + $button_tray = new XoopsFormElementTray('', ''); |
|
| 290 | + $submit_btn = new XoopsFormButton('', 'post', $label_submit, 'submit'); |
|
| 291 | + $button_tray->addElement($submit_btn); |
|
| 292 | + $sform->addElement($button_tray); |
|
| 293 | + $sform = references_utils::formMarkRequiredFields($sform); |
|
| 294 | + $sform->display(); |
|
| 295 | + include_once __DIR__ . '/admin_footer.php'; //show_footer(); |
|
| 296 | + break; |
|
| 297 | + |
|
| 298 | + // **************************************************************************************************************** |
|
| 299 | + case 'saveeditarticles': // Sauvegarde d'un article |
|
| 300 | + // **************************************************************************************************************** |
|
| 301 | + xoops_cp_header(); |
|
| 302 | + $id = isset($_POST['article_id']) ? (int)$_POST['article_id'] : 0; |
|
| 303 | + $opRedirect = 'articles'; |
|
| 304 | + if (!empty($id)) { |
|
| 305 | + $edit = true; |
|
| 306 | + $item = $h_references_articles->get($id); |
|
| 307 | + if (!is_object($item)) { |
|
| 308 | + references_utils::redirect(_AM_REFERENCES_NOT_FOUND, $baseurl, 5); |
|
| 309 | + } |
|
| 310 | + $item->unsetNew(); |
|
| 311 | + } else { |
|
| 312 | + $edit = false; |
|
| 313 | + $item = $h_references_articles->create(true); |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + $item->setVars($_POST); |
|
| 317 | + |
|
| 318 | + // Images |
|
| 319 | + for ($i = 1; $i <= 10; ++$i) { |
|
| 320 | + if (isset($_POST['delpicture' . $i]) && (int)$_POST['delpicture' . $i] == 1) { |
|
| 321 | + $item->deletePicture($i); |
|
| 322 | + $item->setVar('article_picture' . $i, ''); |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + // Upload de l'image et cr???ation de la vignette |
|
| 326 | + $destname = ''; |
|
| 327 | + $return = references_utils::uploadFile($i - 1, references_utils::getModuleOption('images_path')); |
|
| 328 | + if ($return === true) { |
|
| 329 | + if (references_utils::getModuleOption('images_width') > 0 && references_utils::getModuleOption('images_height') > 0) { |
|
| 330 | + references_utils::createThumb(references_utils::getModuleOption('images_path') . '/' . basename($destname), references_utils::getModuleOption('images_path') . '/' . basename($destname), references_utils::getModuleOption('images_width'), |
|
| 331 | + references_utils::getModuleOption('images_height'), true); |
|
| 332 | + } |
|
| 333 | + $newDestName = references_utils::getModuleOption('images_path') . DIRECTORY_SEPARATOR . REFERENCES_THUMBS_PREFIX . basename($destname); |
|
| 334 | + $retval = references_utils::resizePicture(references_utils::getModuleOption('images_path') . '/' . basename($destname), $newDestName, $thumbs_width, $thumbs_height, true); |
|
| 335 | + if ($retval == 1 || $retval == 3) { |
|
| 336 | + $item->setVar('article_picture' . $i, $destname); |
|
| 337 | + } |
|
| 338 | + } else { |
|
| 339 | + if ($return !== false) { |
|
| 340 | + echo $return; |
|
| 341 | + } |
|
| 342 | + } |
|
| 343 | + } |
|
| 344 | + |
|
| 345 | + $timestamp = mktime(0, 0, 0, (int)substr($_POST['article_timestamp'], 5, 2), (int)substr($_POST['article_timestamp'], 8, 2), (int)substr($_POST['article_timestamp'], 0, 4)); |
|
| 346 | + $item->setVar('article_timestamp', $timestamp); |
|
| 347 | + |
|
| 348 | + if (!$edit) { |
|
| 349 | + $item->setVar('article_author', references_utils::getCurrentUserID()); |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + // Suppression ???ventuelle du fichier attach??? |
|
| 353 | + if (isset($_POST['delattach']) && (int)$_POST['delattach'] == 1) { |
|
| 354 | + $item->deleteAttachment(); |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + $destname = ''; |
|
| 358 | + // Upload de la pi???ce jointe |
|
| 359 | + $return = references_utils::uploadFile(10, references_utils::getModuleOption('attached_path')); |
|
| 360 | + if ($return === true) { |
|
| 361 | + $item->setVar('article_attached_file', $destname); |
|
| 362 | + } else { |
|
| 363 | + if ($return !== false) { |
|
| 364 | + echo $return; |
|
| 365 | + } |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + $res = $h_references_articles->insert($item); |
|
| 369 | + if ($res) { |
|
| 370 | + if (references_utils::getModuleOption('use_tags') && references_utils::tagModuleExists()) { |
|
| 371 | + $tag_handler = xoops_getModuleHandler('tag', 'tag'); |
|
| 372 | + $tag_handler->updateByItem($_POST['item_tag'], $item->getVar('article_id'), $xoopsModule->getVar('dirname'), 0); |
|
| 373 | + } |
|
| 374 | + if (!$edit) { |
|
| 375 | + $h_references_articles->notifyNewArticle($item); |
|
| 376 | + } |
|
| 377 | + references_utils::updateCache(); |
|
| 378 | + references_utils::redirect(_AM_REFERENCES_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2); |
|
| 379 | + } else { |
|
| 380 | + references_utils::redirect(_AM_REFERENCES_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5); |
|
| 381 | + } |
|
| 382 | + break; |
|
| 383 | + |
|
| 384 | + // **************************************************************************************************************** |
|
| 385 | + case 'offline': // Mise hors ligne d'un article |
|
| 386 | + case 'online': // Mise en ligne d'un article |
|
| 387 | + // **************************************************************************************************************** |
|
| 388 | + xoops_cp_header(); |
|
| 389 | + $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
|
| 390 | + if (empty($id)) { |
|
| 391 | + references_utils::redirect(_AM_REFERENCES_ERROR_1, $baseurl, 5); |
|
| 392 | + } |
|
| 393 | + $opRedirect = 'articles'; |
|
| 394 | + $item = null; |
|
| 395 | + $item = $h_references_articles->get($id); |
|
| 396 | + if (is_object($item)) { |
|
| 397 | + if ($op === 'offline') { |
|
| 398 | + $res = $h_references_articles->offlineArticle($item); |
|
| 399 | + } else { |
|
| 400 | + $res = $h_references_articles->onlineArticle($item); |
|
| 401 | + } |
|
| 402 | + if ($res) { |
|
| 403 | + references_utils::updateCache(); |
|
| 404 | + references_utils::redirect(_AM_REFERENCES_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2); |
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | + references_utils::redirect(_AM_REFERENCES_NOT_FOUND, $baseurl . '?op=' . $opRedirect, 5); |
|
| 408 | + break; |
|
| 409 | + |
|
| 410 | + // **************************************************************************************************************** |
|
| 411 | + case 'deletearticles': // Suppression d'un article |
|
| 412 | + // **************************************************************************************************************** |
|
| 413 | + xoops_cp_header(); |
|
| 414 | + $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
|
| 415 | + if (empty($id)) { |
|
| 416 | + references_utils::redirect(_AM_REFERENCES_ERROR_1, $baseurl, 5); |
|
| 417 | + } |
|
| 418 | + $opRedirect = 'articles'; |
|
| 419 | + $item = null; |
|
| 420 | + $item = $h_references_articles->get($id); |
|
| 421 | + if (is_object($item)) { |
|
| 422 | + $res = $h_references_articles->deleteArticle($item, true); |
|
| 423 | + if ($res) { |
|
| 424 | + references_utils::updateCache(); |
|
| 425 | + references_utils::redirect(_AM_REFERENCES_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2); |
|
| 426 | + } |
|
| 427 | + } |
|
| 428 | + references_utils::redirect(_AM_REFERENCES_NOT_FOUND, $baseurl . '?op=' . $opRedirect, 5); |
|
| 429 | + break; |
|
| 430 | + |
|
| 431 | + // **************************************************************************************************************** |
|
| 432 | + case 'instant-zero'; // Publicit??? |
|
| 433 | + // **************************************************************************************************************** |
|
| 434 | + xoops_cp_header(); |
|
| 435 | + // references_adminMenu(4); |
|
| 436 | + echo "<iframe src='http://www.instant-zero.com/modules/liaise/?form_id=2' width='100%' height='600' frameborder='0'></iframe>"; |
|
| 437 | + include_once __DIR__ . '/admin_footer.php'; //show_footer(); |
|
| 438 | + break; |
|
| 439 | + |
|
| 440 | + // **************************************************************************************************************** |
|
| 441 | + case 'perms'; // Permissions |
|
| 442 | + // **************************************************************************************************************** |
|
| 443 | + xoops_cp_header(); |
|
| 444 | + // references_adminMenu(3); |
|
| 445 | + require_once XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php'; |
|
| 446 | + $categories = $handlers->h_references_categories->getCategories(); |
|
| 447 | + $permissionsForm = new XoopsGroupPermForm(_AM_REFERENCES_VIEWFORM, $xoopsModule->getVar('mid'), REFERENCES_PERM_READ, _AM_REFERENCES_VIEWFORM_DESC, 'admin/index.php?op=perms', 'true'); |
|
| 448 | + foreach ($categories as $category) { |
|
| 449 | + $permissionsForm->addItem($category->category_id, $category->category_title, 0); |
|
| 450 | + } |
|
| 451 | + echo $permissionsForm->render(); |
|
| 452 | + echo "<br><br><br><br>\n"; |
|
| 453 | + unset($permissionsForm); |
|
| 454 | + include_once __DIR__ . '/admin_footer.php'; //show_footer(); |
|
| 455 | + break; |
|
| 456 | + |
|
| 457 | + // **************************************************************************************************************** |
|
| 458 | + case 'texts': // Gestion des textes |
|
| 459 | + // **************************************************************************************************************** |
|
| 460 | + xoops_cp_header(); |
|
| 461 | + // references_adminMenu(2); |
|
| 462 | + require_once REFERENCES_PATH . 'class/registryfile.php'; |
|
| 463 | + $registry = new references_registryfile(); |
|
| 464 | + |
|
| 465 | + $sform = new XoopsThemeForm(_MI_REFERENCES_ADMENU1, 'frmatxt', $baseurl); |
|
| 466 | + $sform->addElement(new XoopsFormHidden('op', 'savetexts')); |
|
| 467 | + // Texte ??? afficher sur la page d'index du module |
|
| 468 | + $editor1 = references_utils::getWysiwygForm(_AM_REFERENCES_TEXT1, 'text1', $registry->getfile(REFERENCES_TEXTFILE1), 5, 60, 'hometext1_hidden'); |
|
| 469 | + if ($editor1) { |
|
| 470 | + $sform->addElement($editor1, false); |
|
| 471 | + } |
|
| 472 | + $button_tray = new XoopsFormElementTray('', ''); |
|
| 473 | + $submit_btn = new XoopsFormButton('', 'post', _AM_REFERENCES_MODIFY, 'submit'); |
|
| 474 | + $button_tray->addElement($submit_btn); |
|
| 475 | + $sform->addElement($button_tray); |
|
| 476 | + $sform = references_utils::formMarkRequiredFields($sform); |
|
| 477 | + $sform->display(); |
|
| 478 | + include_once __DIR__ . '/admin_footer.php'; //show_footer(); |
|
| 479 | + break; |
|
| 480 | + |
|
| 481 | + // **************************************************************************************************************** |
|
| 482 | + case 'savetexts': // Sauvegarde des textes |
|
| 483 | + // **************************************************************************************************************** |
|
| 484 | + xoops_cp_header(); |
|
| 485 | + require_once REFERENCES_PATH . 'class/registryfile.php'; |
|
| 486 | + $registry = new references_registryfile(); |
|
| 487 | + $myts = MyTextSanitizer::getInstance(); |
|
| 488 | + $registry->savefile($myts->stripSlashesGPC($_POST['text1']), REFERENCES_TEXTFILE1); |
|
| 489 | + references_utils::updateCache(); |
|
| 490 | + references_utils::redirect(_AM_REFERENCES_SAVE_OK, $baseurl . '?op=texts', 2); |
|
| 491 | + break; |
|
| 492 | + |
|
| 493 | + // **************************************************************************************************************** |
|
| 494 | + case 'maintain': // Maintenance des tables |
|
| 495 | + // **************************************************************************************************************** |
|
| 496 | + xoops_cp_header(); |
|
| 497 | + // references_adminMenu(); |
|
| 498 | + references_utils::maintainTablesCache(); |
|
| 499 | + references_utils::redirect(_AM_REFERENCES_SAVE_OK, $baseurl, 2); |
|
| 500 | + break; |
|
| 501 | + |
|
| 502 | + // **************************************************************************************************************** |
|
| 503 | + case 'categories': // Gestion des cat???gories |
|
| 504 | + // **************************************************************************************************************** |
|
| 505 | + xoops_cp_header(); |
|
| 506 | + // references_adminMenu(1); |
|
| 507 | + $start = isset($_GET['start']) ? (int)$_GET['start'] : 0; |
|
| 508 | + $objet = 'categories'; |
|
| 509 | + $items = array(); |
|
| 510 | + $form = "<form method='post' action='$baseurl' name='frmadd$objet' id='frmadd$objet'><input type='hidden' name='op' id='op' value='add$objet' /><input type='submit' name='btngo' id='btngo' value='" . _AM_REFERENCES_ADD_ITEM . "' /></form>"; |
|
| 511 | + echo $form; |
|
| 512 | + references_utils::htitle(_MI_REFERENCES_ADMENU2, 4); |
|
| 513 | + |
|
| 514 | + $itemsCount = $h_references_categories->getCount(); |
|
| 515 | + if ($itemsCount > $limit) { |
|
| 516 | + $pagenav = new XoopsPageNav($itemsCount, $limit, $start, 'start'); |
|
| 517 | + } |
|
| 518 | + |
|
| 519 | + $items = $h_references_categories->getCategories($start, $limit); |
|
| 520 | + if (isset($pagenav) && is_object($pagenav)) { |
|
| 521 | + echo "<div align='right'>" . $pagenav->renderNav() . '</div>'; |
|
| 522 | + } |
|
| 523 | + echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'>"; |
|
| 524 | + |
|
| 525 | + echo "<tr><th align='center'>" . _AM_REFERENCES_ID . "</th><th align='center'>" . _AM_REFERENCES_TITLE . "</th><th align='center'>" . _AM_REFERENCES_CATEGORY_WEIGHT . "</th><th align='center'>" . _AM_REFERENCES_ACTION . '</th></tr>'; |
|
| 526 | + |
|
| 527 | + $class = ''; |
|
| 528 | + foreach ($items as $item) { |
|
| 529 | + $class = ($class === 'even') ? 'odd' : 'even'; |
|
| 530 | + $id = $item->getVar('category_id'); |
|
| 531 | + $action_edit = "<a href='$baseurl?op=edit" . $objet . '&id=' . $id . "' title='" . _EDIT . "'>" . $icones['edit'] . '</a>'; |
|
| 532 | + $action_delete = "<a href='$baseurl?op=delete" . $objet . '&id=' . $id . "' title='" . _DELETE . "'" . $conf_msg . '>' . $icones['delete'] . '</a>'; |
|
| 533 | + |
|
| 534 | + echo "<tr class='" . $class . "'>\n"; |
|
| 535 | + echo "<td align='center'>" . $id . '</td>'; |
|
| 536 | + echo "<td align='left'><a target='_blank' href='" . $item->getUrl() . "'>" . $item->getVar('category_title') . '</a></td>'; |
|
| 537 | + echo "<td align='right'>" . $item->getVar('category_weight') . '</td>'; |
|
| 538 | + echo "<td align='center'>" . $action_edit . ' ' . $action_delete . "</td>\n"; |
|
| 539 | + echo "<tr>\n"; |
|
| 540 | + } |
|
| 541 | + $class = ($class === 'even') ? 'odd' : 'even'; |
|
| 542 | + echo "<tr class='" . $class . "'>\n"; |
|
| 543 | + echo "<td colspan='4' align='center'>" . $form . "</td>\n"; |
|
| 544 | + echo "</tr>\n"; |
|
| 545 | + echo "</table>\n"; |
|
| 546 | + if (isset($pagenav) && is_object($pagenav)) { |
|
| 547 | + echo "<div align='center'>" . $pagenav->renderNav() . '</div>'; |
|
| 548 | + } |
|
| 549 | + echo "<br><br>\n"; |
|
| 550 | + include_once __DIR__ . '/admin_footer.php'; //show_footer(); |
|
| 551 | + break; |
|
| 552 | + |
|
| 553 | + // **************************************************************************************************************** |
|
| 554 | + case 'addcategories': // Ajout d'une cat???gorie |
|
| 555 | + case 'editcategories': // Edition d'une categories |
|
| 556 | + // **************************************************************************************************************** |
|
| 557 | + xoops_cp_header(); |
|
| 558 | + // references_adminMenu(1); |
|
| 559 | + $object = 'categories'; |
|
| 560 | + if ($op == 'edit' . $object) { |
|
| 561 | + $title = _AM_REFERENCES_EDIT_CATEGORY; |
|
| 562 | + $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
|
| 563 | + if (empty($id)) { |
|
| 564 | + references_utils::redirect(_AM_REFERENCES_ERROR_1, $baseurl, 5); |
|
| 565 | + } |
|
| 566 | + // Item exits ? |
|
| 567 | + $item = null; |
|
| 568 | + $item = $h_references_categories->get($id); |
|
| 569 | + if (!is_object($item)) { |
|
| 570 | + references_utils::redirect(_AM_REFERENCES_NOT_FOUND, $baseurl, 5); |
|
| 571 | + } |
|
| 572 | + $edit = true; |
|
| 573 | + $label_submit = _AM_REFERENCES_MODIFY; |
|
| 574 | + } else { |
|
| 575 | + $title = _AM_REFERENCES_ADD_CATEGORY; |
|
| 576 | + $item = $h_references_categories->create(true); |
|
| 577 | + $label_submit = _AM_REFERENCES_ADD; |
|
| 578 | + $edit = false; |
|
| 579 | + } |
|
| 580 | + $sform = new XoopsThemeForm($title, 'frmadd' . $object, $baseurl); |
|
| 581 | + $sform->addElement(new XoopsFormHidden('op', 'saveedit' . $object)); |
|
| 582 | + $sform->addElement(new XoopsFormHidden('category_id', $item->getVar('category_id'))); |
|
| 583 | + $sform->addElement(new XoopsFormText(_AM_REFERENCES_TITLE, 'category_title', 50, 255, $item->getVar('category_title', 'e')), true); |
|
| 584 | + $sform->addElement(new XoopsFormText(_AM_REFERENCES_CATEGORY_WEIGHT, 'category_weight', 10, 10, $item->getVar('category_weight', 'e')), true); |
|
| 585 | + $editor = references_utils::getWysiwygForm(_AM_REFERENCES_DESCRIPTION, 'category_description', $item->getVar('category_description', 'e'), 15, 60, 'category_description_hidden'); |
|
| 586 | + if ($editor) { |
|
| 587 | + $sform->addElement($editor, false); |
|
| 588 | + } |
|
| 589 | + |
|
| 590 | + // Permissions |
|
| 591 | + $membersHandler = xoops_getHandler('member'); |
|
| 592 | + $allGroupsList = $membersHandler->getGroupList(); |
|
| 593 | + $permHandler = xoops_getHandler('groupperm'); |
|
| 594 | + $allGroupsIds = array_keys($allGroupsList); |
|
| 595 | + |
|
| 596 | + $groupsIds = array(); |
|
| 597 | + if ($edit) { |
|
| 598 | + $groupsIds = $permHandler->getGroupIds(REFERENCES_PERM_READ, $item->getVar('category_id'), $xoopsModule->getVar('mid')); |
|
| 599 | + $groupsIds = array_values($groupsIds); |
|
| 600 | + $groupsThatCanViewCheckbox = new XoopsFormCheckBox(_AM_REFERENCES_VIEWFORM, 'groups_references_can_view[]', $groupsIds); |
|
| 601 | + } else { |
|
| 602 | + $groupsThatCanViewCheckbox = new XoopsFormCheckBox(_AM_REFERENCES_VIEWFORM, 'groups_references_can_view[]', $allGroupsIds); |
|
| 603 | + } |
|
| 604 | + $groupsThatCanViewCheckbox->addOptionArray($allGroupsList); |
|
| 605 | + $sform->addElement($groupsThatCanViewCheckbox); |
|
| 606 | + // ***** |
|
| 607 | + |
|
| 608 | + $button_tray = new XoopsFormElementTray('', ''); |
|
| 609 | + $submit_btn = new XoopsFormButton('', 'post', $label_submit, 'submit'); |
|
| 610 | + $button_tray->addElement($submit_btn); |
|
| 611 | + $sform->addElement($button_tray); |
|
| 612 | + $sform = references_utils::formMarkRequiredFields($sform); |
|
| 613 | + $sform->display(); |
|
| 614 | + include_once __DIR__ . '/admin_footer.php'; //show_footer(); |
|
| 615 | + break; |
|
| 616 | + |
|
| 617 | + // **************************************************************************************************************** |
|
| 618 | + case 'saveeditcategories': // Sauvegarde d'une cat???gorie |
|
| 619 | + // **************************************************************************************************************** |
|
| 620 | + xoops_cp_header(); |
|
| 621 | + $id = isset($_POST['category_id']) ? (int)$_POST['category_id'] : 0; |
|
| 622 | + $opRedirect = 'categories'; |
|
| 623 | + if (!empty($id)) { |
|
| 624 | + $edit = true; |
|
| 625 | + $item = $h_references_categories->get($id); |
|
| 626 | + if (!is_object($item)) { |
|
| 627 | + references_utils::redirect(_AM_REFERENCES_NOT_FOUND, $baseurl, 5); |
|
| 628 | + } |
|
| 629 | + $item->unsetNew(); |
|
| 630 | + } else { |
|
| 631 | + $edit = false; |
|
| 632 | + $item = $h_references_categories->create(true); |
|
| 633 | + } |
|
| 634 | + |
|
| 635 | + $item->setVars($_POST); |
|
| 636 | + |
|
| 637 | + $res = $h_references_categories->insert($item); |
|
| 638 | + if ($res) { |
|
| 639 | + // Permissions |
|
| 640 | + // Suppression des permissions actuelles |
|
| 641 | + $gperm_handler = xoops_getHandler('groupperm'); |
|
| 642 | + $criteria = new CriteriaCompo(); |
|
| 643 | + $criteria->add(new Criteria('gperm_itemid', $item->category_id, '=')); |
|
| 644 | + $criteria->add(new Criteria('gperm_modid', $xoopsModule->getVar('mid'), '=')); |
|
| 645 | + $criteria->add(new Criteria('gperm_name', REFERENCES_PERM_READ, '=')); |
|
| 646 | + $gperm_handler->deleteAll($criteria); |
|
| 647 | + // Sauvegarde des nouvelles permissions, si elles existente |
|
| 648 | + if (isset($_POST['groups_references_can_view'])) { |
|
| 649 | + foreach ($_POST['groups_references_can_view'] as $groupId) { |
|
| 650 | + $gperm_handler->addRight(REFERENCES_PERM_READ, $item->category_id, $groupId, $xoopsModule->getVar('mid')); |
|
| 651 | + } |
|
| 652 | + } |
|
| 653 | + // **** |
|
| 654 | + if (!$edit) { |
|
| 655 | + $h_references_categories->notifyNewCategory($item); |
|
| 656 | + } |
|
| 657 | + references_utils::updateCache(); |
|
| 658 | + references_utils::redirect(_AM_REFERENCES_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2); |
|
| 659 | + } else { |
|
| 660 | + references_utils::redirect(_AM_REFERENCES_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5); |
|
| 661 | + } |
|
| 662 | + break; |
|
| 663 | + |
|
| 664 | + // **************************************************************************************************************** |
|
| 665 | + case 'deletecategories': // Suppression d'une cat???gorie |
|
| 666 | + // **************************************************************************************************************** |
|
| 667 | + xoops_cp_header(); |
|
| 668 | + $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
|
| 669 | + if (empty($id)) { |
|
| 670 | + references_utils::redirect(_AM_REFERENCES_ERROR_1, $baseurl, 5); |
|
| 671 | + } |
|
| 672 | + $opRedirect = 'categories'; |
|
| 673 | + $item = null; |
|
| 674 | + $item = $h_references_categories->get($id); |
|
| 675 | + if (is_object($item)) { |
|
| 676 | + $res = $h_references_categories->delete($item, true); |
|
| 677 | + if ($res) { |
|
| 678 | + references_utils::updateCache(); |
|
| 679 | + references_utils::redirect(_AM_REFERENCES_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2); |
|
| 680 | + } |
|
| 681 | + } |
|
| 682 | + references_utils::redirect(_AM_REFERENCES_NOT_FOUND, $baseurl . '?op=' . $opRedirect, 5); |
|
| 683 | + break; |
|
| 684 | + |
|
| 685 | + // **************************************************************************************************************** |
|
| 686 | + case 'autocomplete': // Ajax, autocompl???tion |
|
| 687 | + // **************************************************************************************************************** |
|
| 688 | + if (!isset($xoopsUser) || !is_object($xoopsUser)) { |
|
| 689 | + exit; |
|
| 690 | + } |
|
| 691 | + if (!references_utils::isAdmin()) { |
|
| 692 | + exit; |
|
| 693 | + } |
|
| 694 | + error_reporting(0); |
|
| 695 | + @$xoopsLogger->activated = false; |
|
| 696 | + $handler = isset($_REQUEST['handler']) ? $_REQUEST['handler'] : ''; |
|
| 697 | + if ($handler != '') { |
|
| 698 | + switch ($handler) { |
|
| 699 | + case 'references_articles': |
|
| 700 | + $referencesFilter = new references_listFilter($h_references_articles, 'op', 'articles', 'start', $limit, $baseurl, 'article_title', 'ASC', true, REFERENCES_JS_URL); |
|
| 701 | + $referencesFilter->initFilter('article_title', array('dataType' => references_listFilter::FILTER_DATA_TEXT, 'fieldType' => references_listFilter::FILTER_FIELD_TEXT, 'size' => 35, 'maxLength' => 255, 'autoComplete' => true)); |
|
| 702 | + echo utf8_encode($referencesFilter->autoComplete($_REQUEST['q'], $_REQUEST['limit'], $_REQUEST['field'])); |
|
| 703 | + break; |
|
| 704 | + } |
|
| 705 | + } |
|
| 706 | + exit; |
|
| 707 | + break; |
|
| 708 | 708 | } |
| 709 | 709 | xoops_cp_footer(); |
@@ -34,38 +34,38 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | $xoopsModuleAdminPath = XOOPS_ROOT_PATH . '/' . $module->getInfo('dirmoduleadmin'); |
| 36 | 36 | if (!file_exists($fileinc = $xoopsModuleAdminPath . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/' . 'main.php')) { |
| 37 | - $fileinc = $xoopsModuleAdminPath . '/language/english/main.php'; |
|
| 37 | + $fileinc = $xoopsModuleAdminPath . '/language/english/main.php'; |
|
| 38 | 38 | } |
| 39 | 39 | include_once $fileinc; |
| 40 | 40 | |
| 41 | 41 | $adminmenu[] = array( |
| 42 | - 'title' => _AM_MODULEADMIN_HOME, |
|
| 43 | - 'link' => 'admin/index.php', |
|
| 44 | - 'icon' => $pathIcon32 . '/home.png' |
|
| 42 | + 'title' => _AM_MODULEADMIN_HOME, |
|
| 43 | + 'link' => 'admin/index.php', |
|
| 44 | + 'icon' => $pathIcon32 . '/home.png' |
|
| 45 | 45 | ); |
| 46 | 46 | |
| 47 | 47 | $adminmenu[] = array( |
| 48 | - 'title' => _MI_REFERENCES_ADMENU0, |
|
| 49 | - 'link' => 'admin/main.php', |
|
| 50 | - 'icon' => $pathIcon32 . '/index.png' |
|
| 48 | + 'title' => _MI_REFERENCES_ADMENU0, |
|
| 49 | + 'link' => 'admin/main.php', |
|
| 50 | + 'icon' => $pathIcon32 . '/index.png' |
|
| 51 | 51 | ); |
| 52 | 52 | |
| 53 | 53 | $adminmenu[] = array( |
| 54 | - 'title' => _MI_REFERENCES_ADMENU2, |
|
| 55 | - 'link' => 'admin/main.php?op=categories', |
|
| 56 | - 'icon' => $pathIcon32 . '/category.png' |
|
| 54 | + 'title' => _MI_REFERENCES_ADMENU2, |
|
| 55 | + 'link' => 'admin/main.php?op=categories', |
|
| 56 | + 'icon' => $pathIcon32 . '/category.png' |
|
| 57 | 57 | ); |
| 58 | 58 | |
| 59 | 59 | $adminmenu[] = array( |
| 60 | - 'title' => _MI_REFERENCES_ADMENU1, |
|
| 61 | - 'link' => 'admin/main.php?op=texts', |
|
| 62 | - 'icon' => $pathIcon32 . '/manage.png' |
|
| 60 | + 'title' => _MI_REFERENCES_ADMENU1, |
|
| 61 | + 'link' => 'admin/main.php?op=texts', |
|
| 62 | + 'icon' => $pathIcon32 . '/manage.png' |
|
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | 65 | $adminmenu[] = array( |
| 66 | - 'title' => _MI_REFERENCES_ADMENU3, |
|
| 67 | - 'link' => 'admin/main.php?op=perms', |
|
| 68 | - 'icon' => $pathIcon32 . '/permissions.png' |
|
| 66 | + 'title' => _MI_REFERENCES_ADMENU3, |
|
| 67 | + 'link' => 'admin/main.php?op=perms', |
|
| 68 | + 'icon' => $pathIcon32 . '/permissions.png' |
|
| 69 | 69 | ); |
| 70 | 70 | |
| 71 | 71 | //$adminmenu[] = array( |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | //); |
| 76 | 76 | |
| 77 | 77 | $adminmenu[] = array( |
| 78 | - 'title' => _AM_MODULEADMIN_ABOUT, |
|
| 79 | - 'link' => 'admin/about.php', |
|
| 80 | - 'icon' => $pathIcon32 . '/about.png' |
|
| 78 | + 'title' => _AM_MODULEADMIN_ABOUT, |
|
| 79 | + 'link' => 'admin/about.php', |
|
| 80 | + 'icon' => $pathIcon32 . '/about.png' |
|
| 81 | 81 | ); |
| 82 | 82 | |
@@ -23,22 +23,22 @@ |
||
| 23 | 23 | // Nouveau champ article_attached_file_description dans references_articles |
| 24 | 24 | $tableName = $xoopsDB->prefix('references_articles'); |
| 25 | 25 | if (!references_utils::fieldExists('article_weight', $tableName)) { |
| 26 | - references_utils::addField('`article_weight` MEDIUMINT( 8 ) UNSIGNED NOT NULL AFTER `article_timestamp`', $tableName); |
|
| 27 | - $xoopsDB->queryF('ALTER TABLE ' . $tableName . ' ADD INDEX ( `article_weight` )'); |
|
| 28 | - $wasUpdated = true; |
|
| 26 | + references_utils::addField('`article_weight` MEDIUMINT( 8 ) UNSIGNED NOT NULL AFTER `article_timestamp`', $tableName); |
|
| 27 | + $xoopsDB->queryF('ALTER TABLE ' . $tableName . ' ADD INDEX ( `article_weight` )'); |
|
| 28 | + $wasUpdated = true; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | if (!references_utils::fieldExists('article_readmore', $tableName)) { |
| 32 | - references_utils::addField('article_readmore TEXT NOT NULL', $tableName); |
|
| 33 | - $wasUpdated = true; |
|
| 32 | + references_utils::addField('article_readmore TEXT NOT NULL', $tableName); |
|
| 33 | + $wasUpdated = true; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $tableName = $xoopsDB->prefix('references_categories'); |
| 37 | 37 | if (!references_utils::fieldExists('category_description', $tableName)) { |
| 38 | - references_utils::addField('category_description TEXT NOT NULL', $tableName); |
|
| 39 | - $wasUpdated = true; |
|
| 38 | + references_utils::addField('category_description TEXT NOT NULL', $tableName); |
|
| 39 | + $wasUpdated = true; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | if ($wasUpdated) { |
| 43 | - $op = 'maintain'; |
|
| 43 | + $op = 'maintain'; |
|
| 44 | 44 | } |
@@ -31,24 +31,24 @@ discard block |
||
| 31 | 31 | $baseurl = REFERENCES_URL . basename(__FILE__); |
| 32 | 32 | $artice_id = isset($_GET['article_id']) ? (int)$_GET['article_id'] : 0; |
| 33 | 33 | if ($artice_id == 0) { |
| 34 | - references_utils::redirect(_MD_REFERENCES_ERROR4, 'index.php', 4); |
|
| 34 | + references_utils::redirect(_MD_REFERENCES_ERROR4, 'index.php', 4); |
|
| 35 | 35 | } |
| 36 | 36 | $article = null; |
| 37 | 37 | $article = $h_references_articles->get($artice_id); |
| 38 | 38 | if (!is_object($article)) { |
| 39 | - references_utils::redirect(_MD_REFERENCES_ERROR4, 'index.php', 4); |
|
| 39 | + references_utils::redirect(_MD_REFERENCES_ERROR4, 'index.php', 4); |
|
| 40 | 40 | } |
| 41 | 41 | // Vérification des permissions |
| 42 | 42 | $handlers = references_handler::getInstance(); |
| 43 | 43 | if (!$handlers->h_references_articles->userCanSeeReference($article)) { |
| 44 | - references_utils::redirect(_NOPERM, 'index.php', 4); |
|
| 44 | + references_utils::redirect(_NOPERM, 'index.php', 4); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | // Chargement de la catégorie |
| 48 | 48 | $category = null; |
| 49 | 49 | $category = $h_references_categories->get($article->getVar('article_category_id')); |
| 50 | 50 | if (!is_object($category)) { |
| 51 | - references_utils::redirect(_MD_REFERENCES_ERROR2, 'index.php', 4); |
|
| 51 | + references_utils::redirect(_MD_REFERENCES_ERROR2, 'index.php', 4); |
|
| 52 | 52 | } |
| 53 | 53 | $xoopsTpl->assign('category', $category->toArray()); |
| 54 | 54 | $xoopsTpl->assign('article', $article->toArray()); |
@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | // Breadcrumb |
| 59 | 59 | $breadcrumb = array( |
| 60 | - $category->getUrl() => $category->getVar('category_title'), |
|
| 61 | - $baseurl => $article->getVar('article_title') |
|
| 60 | + $category->getUrl() => $category->getVar('category_title'), |
|
| 61 | + $baseurl => $article->getVar('article_title') |
|
| 62 | 62 | ); |
| 63 | 63 | $xoopsTpl->assign('breadcrumb', references_utils::breadcrumb($breadcrumb)); |
| 64 | 64 | |
@@ -68,9 +68,9 @@ discard block |
||
| 68 | 68 | $xoTheme->addScript(REFERENCES_JS_URL . 'js/mootools.js'); |
| 69 | 69 | $xoTheme->addScript(REFERENCES_JS_URL . 'js/mootools-1.2-more.js'); |
| 70 | 70 | if (isset($xoopsConfig) && file_exists(REFERENCES_PATH . 'language/' . $xoopsConfig['language'] . '/slimbox.js')) { |
| 71 | - $xoTheme->addScript(REFERENCES_URL . 'language/' . $xoopsConfig['language'] . '/slimbox.js'); |
|
| 71 | + $xoTheme->addScript(REFERENCES_URL . 'language/' . $xoopsConfig['language'] . '/slimbox.js'); |
|
| 72 | 72 | } else { |
| 73 | - $xoTheme->addScript(REFERENCES_JS_URL . 'js/slimbox.js'); |
|
| 73 | + $xoTheme->addScript(REFERENCES_JS_URL . 'js/slimbox.js'); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $categoriesSelect = $h_references_categories->getCategoriesSelect('categoriesSelect', $category->getVar('category_id')); |
@@ -41,9 +41,9 @@ discard block |
||
| 41 | 41 | $xoTheme->addScript(REFERENCES_JS_URL . 'js/mootools-1.2-more.js'); |
| 42 | 42 | |
| 43 | 43 | if (isset($xoopsConfig) && file_exists(REFERENCES_PATH . 'language/' . $xoopsConfig['language'] . '/slimbox.js')) { |
| 44 | - $xoTheme->addScript(REFERENCES_URL . 'language/' . $xoopsConfig['language'] . '/slimbox.js'); |
|
| 44 | + $xoTheme->addScript(REFERENCES_URL . 'language/' . $xoopsConfig['language'] . '/slimbox.js'); |
|
| 45 | 45 | } else { |
| 46 | - $xoTheme->addScript(REFERENCES_JS_URL . 'js/slimbox.js'); |
|
| 46 | + $xoTheme->addScript(REFERENCES_JS_URL . 'js/slimbox.js'); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $categories = $h_references_categories->getCategories(); |
@@ -63,42 +63,42 @@ discard block |
||
| 63 | 63 | $refFounded = false; |
| 64 | 64 | $mostRecentReferenceDate = 0; |
| 65 | 65 | if ($limit > 0) { |
| 66 | - $uniqueCategories = $h_references_articles->getDistinctCategoriesIds(); |
|
| 67 | - foreach ($uniqueCategories as $categoryId) { |
|
| 68 | - $items = array(); |
|
| 69 | - $items = $h_references_articles->getRecentArticles($start, $limit, references_utils::getModuleOption('sort_field'), references_utils::getModuleOption('sort_order'), true, $categoryId); |
|
| 70 | - $categoryTitle = isset($categories[$categoryId]) ? $categories[$categoryId]->getVar('category_title') : ''; |
|
| 71 | - $categoryWeight = isset($categories[$categoryId]) ? $categories[$categoryId]->getVar('category_weight') : 0; |
|
| 72 | - if (count($items) > 0) { |
|
| 73 | - foreach ($items as $item) { |
|
| 74 | - $articleData = array(); |
|
| 75 | - $articleData = $item->toArray(); |
|
| 76 | - if ($item->getVar('article_id') == $article_id) { |
|
| 77 | - $xoopsTpl->assign('defaultArticle', $index); |
|
| 78 | - $refFounded = true; |
|
| 79 | - } |
|
| 80 | - ++$index; |
|
| 81 | - $articleData['article_category_id'] = $categoryId; |
|
| 82 | - $articleData['article_category_title'] = $categoryTitle; |
|
| 83 | - $articleData['article_category_weight'] = $categoryWeight; |
|
| 84 | - $categoriesForTemplate[$categoryWeight . '-' . $categoryId]['articles'][] = $articleData; |
|
| 85 | - $categoriesForTemplate[$categoryWeight . '-' . $categoryId]['categoryTitle'] = $categoryTitle; |
|
| 86 | - $categoriesForTemplate[$categoryWeight . '-' . $categoryId]['categoryId'] = $categoryId; |
|
| 87 | - if ($item->getVar('article_timestamp') > $mostRecentReferenceDate) { |
|
| 88 | - $mostRecentReferenceDate = $item->getVar('article_timestamp'); |
|
| 89 | - $lastTitle = strip_tags($item->getVar('article_title', 'n')) . ', ' . $item->getVar('article_date'); |
|
| 90 | - $lastKeywords = strip_tags($item->getVar('article_text', 'n')); |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - if (!$refFounded) { |
|
| 96 | - $xoopsTpl->assign('defaultArticle', 0); |
|
| 97 | - } |
|
| 98 | - if (count($categoriesForTemplate) > 0) { |
|
| 99 | - ksort($categoriesForTemplate); |
|
| 100 | - } |
|
| 101 | - $xoopsTpl->assign('categories', $categoriesForTemplate); |
|
| 66 | + $uniqueCategories = $h_references_articles->getDistinctCategoriesIds(); |
|
| 67 | + foreach ($uniqueCategories as $categoryId) { |
|
| 68 | + $items = array(); |
|
| 69 | + $items = $h_references_articles->getRecentArticles($start, $limit, references_utils::getModuleOption('sort_field'), references_utils::getModuleOption('sort_order'), true, $categoryId); |
|
| 70 | + $categoryTitle = isset($categories[$categoryId]) ? $categories[$categoryId]->getVar('category_title') : ''; |
|
| 71 | + $categoryWeight = isset($categories[$categoryId]) ? $categories[$categoryId]->getVar('category_weight') : 0; |
|
| 72 | + if (count($items) > 0) { |
|
| 73 | + foreach ($items as $item) { |
|
| 74 | + $articleData = array(); |
|
| 75 | + $articleData = $item->toArray(); |
|
| 76 | + if ($item->getVar('article_id') == $article_id) { |
|
| 77 | + $xoopsTpl->assign('defaultArticle', $index); |
|
| 78 | + $refFounded = true; |
|
| 79 | + } |
|
| 80 | + ++$index; |
|
| 81 | + $articleData['article_category_id'] = $categoryId; |
|
| 82 | + $articleData['article_category_title'] = $categoryTitle; |
|
| 83 | + $articleData['article_category_weight'] = $categoryWeight; |
|
| 84 | + $categoriesForTemplate[$categoryWeight . '-' . $categoryId]['articles'][] = $articleData; |
|
| 85 | + $categoriesForTemplate[$categoryWeight . '-' . $categoryId]['categoryTitle'] = $categoryTitle; |
|
| 86 | + $categoriesForTemplate[$categoryWeight . '-' . $categoryId]['categoryId'] = $categoryId; |
|
| 87 | + if ($item->getVar('article_timestamp') > $mostRecentReferenceDate) { |
|
| 88 | + $mostRecentReferenceDate = $item->getVar('article_timestamp'); |
|
| 89 | + $lastTitle = strip_tags($item->getVar('article_title', 'n')) . ', ' . $item->getVar('article_date'); |
|
| 90 | + $lastKeywords = strip_tags($item->getVar('article_text', 'n')); |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + if (!$refFounded) { |
|
| 96 | + $xoopsTpl->assign('defaultArticle', 0); |
|
| 97 | + } |
|
| 98 | + if (count($categoriesForTemplate) > 0) { |
|
| 99 | + ksort($categoriesForTemplate); |
|
| 100 | + } |
|
| 101 | + $xoopsTpl->assign('categories', $categoriesForTemplate); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | $xoopsTpl->assign('isAdmin', references_utils::isAdmin()); |
@@ -26,26 +26,26 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | function b_references_last_news_show($options) |
| 28 | 28 | { |
| 29 | - global $xoopsConfig; |
|
| 30 | - require XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
|
| 31 | - $block = array(); |
|
| 32 | - $start = 0; |
|
| 33 | - $limit = (int)$options[0]; |
|
| 34 | - if ($limit > 0) { |
|
| 35 | - $items = array(); |
|
| 36 | - $categories = array(); |
|
| 37 | - if (is_array($options) && count($options) > 1) { |
|
| 38 | - $categories = array_slice($options, 1); |
|
| 39 | - } |
|
| 40 | - $items = $h_references_articles->getRecentArticles($start, $limit, 'article_timestamp', 'DESC', true, $categories); |
|
| 41 | - if (count($items) > 0) { |
|
| 42 | - foreach ($items as $item) { |
|
| 43 | - $block['block_last_news'][] = $item->toArray(); |
|
| 44 | - } |
|
| 45 | - } |
|
| 46 | - } |
|
| 29 | + global $xoopsConfig; |
|
| 30 | + require XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
|
| 31 | + $block = array(); |
|
| 32 | + $start = 0; |
|
| 33 | + $limit = (int)$options[0]; |
|
| 34 | + if ($limit > 0) { |
|
| 35 | + $items = array(); |
|
| 36 | + $categories = array(); |
|
| 37 | + if (is_array($options) && count($options) > 1) { |
|
| 38 | + $categories = array_slice($options, 1); |
|
| 39 | + } |
|
| 40 | + $items = $h_references_articles->getRecentArticles($start, $limit, 'article_timestamp', 'DESC', true, $categories); |
|
| 41 | + if (count($items) > 0) { |
|
| 42 | + foreach ($items as $item) { |
|
| 43 | + $block['block_last_news'][] = $item->toArray(); |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - return $block; |
|
| 48 | + return $block; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -56,26 +56,26 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | function b_references_last_news_edit($options) |
| 58 | 58 | { |
| 59 | - global $xoopsConfig; |
|
| 60 | - include XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
|
| 61 | - $handlers = references_handler::getInstance(); |
|
| 62 | - $categories = $handlers->h_references_categories->getListArray(); |
|
| 63 | - $form = ''; |
|
| 64 | - $form .= "<table border='0'>"; |
|
| 65 | - $form .= '<tr><td>' . _MB_REFERENCES_ITEMS_COUNT . "</td><td><input type='text' name='options[]' id='options' value='" . $options[0] . "' /></td></tr>\n"; |
|
| 66 | - $form .= '<tr><td>' . _MB_REFERENCES_CATEGORIES . "</td><td><select name='options[]' multiple='multiple'>"; |
|
| 67 | - $size = count($options); |
|
| 68 | - foreach ($categories as $Idcategory => $categoryName) { |
|
| 69 | - $sel = ''; |
|
| 70 | - for ($i = 1; $i < $size; ++$i) { |
|
| 71 | - if ($options[$i] == $Idcategory) { |
|
| 72 | - $sel = " selected='selected'"; |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - $form .= "<option value='$Idcategory' $sel>$categoryName</option>"; |
|
| 76 | - } |
|
| 77 | - $form .= "</select></td></tr>\n"; |
|
| 78 | - $form .= '</table>'; |
|
| 59 | + global $xoopsConfig; |
|
| 60 | + include XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
|
| 61 | + $handlers = references_handler::getInstance(); |
|
| 62 | + $categories = $handlers->h_references_categories->getListArray(); |
|
| 63 | + $form = ''; |
|
| 64 | + $form .= "<table border='0'>"; |
|
| 65 | + $form .= '<tr><td>' . _MB_REFERENCES_ITEMS_COUNT . "</td><td><input type='text' name='options[]' id='options' value='" . $options[0] . "' /></td></tr>\n"; |
|
| 66 | + $form .= '<tr><td>' . _MB_REFERENCES_CATEGORIES . "</td><td><select name='options[]' multiple='multiple'>"; |
|
| 67 | + $size = count($options); |
|
| 68 | + foreach ($categories as $Idcategory => $categoryName) { |
|
| 69 | + $sel = ''; |
|
| 70 | + for ($i = 1; $i < $size; ++$i) { |
|
| 71 | + if ($options[$i] == $Idcategory) { |
|
| 72 | + $sel = " selected='selected'"; |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + $form .= "<option value='$Idcategory' $sel>$categoryName</option>"; |
|
| 76 | + } |
|
| 77 | + $form .= "</select></td></tr>\n"; |
|
| 78 | + $form .= '</table>'; |
|
| 79 | 79 | |
| 80 | - return $form; |
|
| 80 | + return $form; |
|
| 81 | 81 | } |
@@ -22,44 +22,44 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | function references_tag_block_cloud_show($options) |
| 24 | 24 | { |
| 25 | - require XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
|
| 26 | - if (!references_utils::tagModuleExists()) { |
|
| 27 | - return false; |
|
| 28 | - } |
|
| 29 | - require_once XOOPS_ROOT_PATH . '/modules/tag/blocks/block.php'; |
|
| 25 | + require XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
|
| 26 | + if (!references_utils::tagModuleExists()) { |
|
| 27 | + return false; |
|
| 28 | + } |
|
| 29 | + require_once XOOPS_ROOT_PATH . '/modules/tag/blocks/block.php'; |
|
| 30 | 30 | |
| 31 | - return tag_block_cloud_show($options, 'references'); |
|
| 31 | + return tag_block_cloud_show($options, 'references'); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | function references_tag_block_cloud_edit($options) |
| 35 | 35 | { |
| 36 | - require XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
|
| 37 | - if (!references_utils::tagModuleExists()) { |
|
| 38 | - return false; |
|
| 39 | - } |
|
| 40 | - require_once XOOPS_ROOT_PATH . '/modules/tag/blocks/block.php'; |
|
| 36 | + require XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
|
| 37 | + if (!references_utils::tagModuleExists()) { |
|
| 38 | + return false; |
|
| 39 | + } |
|
| 40 | + require_once XOOPS_ROOT_PATH . '/modules/tag/blocks/block.php'; |
|
| 41 | 41 | |
| 42 | - return tag_block_cloud_edit($options); |
|
| 42 | + return tag_block_cloud_edit($options); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | function references_tag_block_top_show($options) |
| 46 | 46 | { |
| 47 | - require XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
|
| 48 | - if (!references_utils::tagModuleExists()) { |
|
| 49 | - return false; |
|
| 50 | - } |
|
| 51 | - require_once XOOPS_ROOT_PATH . '/modules/tag/blocks/block.php'; |
|
| 47 | + require XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
|
| 48 | + if (!references_utils::tagModuleExists()) { |
|
| 49 | + return false; |
|
| 50 | + } |
|
| 51 | + require_once XOOPS_ROOT_PATH . '/modules/tag/blocks/block.php'; |
|
| 52 | 52 | |
| 53 | - return tag_block_top_show($options, 'references'); |
|
| 53 | + return tag_block_top_show($options, 'references'); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | function references_tag_block_top_edit($options) |
| 57 | 57 | { |
| 58 | - require XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
|
| 59 | - if (!references_utils::tagModuleExists()) { |
|
| 60 | - return false; |
|
| 61 | - } |
|
| 62 | - require_once XOOPS_ROOT_PATH . '/modules/tag/blocks/block.php'; |
|
| 58 | + require XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
|
| 59 | + if (!references_utils::tagModuleExists()) { |
|
| 60 | + return false; |
|
| 61 | + } |
|
| 62 | + require_once XOOPS_ROOT_PATH . '/modules/tag/blocks/block.php'; |
|
| 63 | 63 | |
| 64 | - return tag_block_top_edit($options); |
|
| 64 | + return tag_block_top_edit($options); |
|
| 65 | 65 | } |