/** * Cloner - DNPROSSI */ function NewsCloner() { global $xoopsDB, $xoopsConfig, $xoopsModule, $myts; include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; xoops_cp_header(); adminmenu(8); $clone_modulename = ''; $start = isset($_GET['start']) ? intval($_GET['start']) : 0; $result = $xoopsDB->query('SELECT * FROM ' . $xoopsDB->prefix('news_clonerdata')); $ix = 0; $iy = 0; while ( $clone = $xoopsDB->fetchArray($result) ) { //DNPROSSI - Control if clone dir exists if ( is_dir(XOOPS_ROOT_PATH . "/modules/" . $clone['clone_dir']) ) { $clone_arr[$ix] = $clone; $ix++; } else { $nonclone_arr[$iy] = $clone; $iy++; } } // If cloned dir does not exists because deleted remove from dtb if ( isset($nonclone_arr) ) { for ($iy = 0; $iy < count($nonclone_arr); $iy++) { $result = $xoopsDB->queryF("DELETE FROM " . $xoopsDB->prefix('news_clonerdata') . " WHERE clone_dir = '" . $nonclone_arr[$iy]['clone_dir'] . "' ;"); } } $totalclones = count($clone_arr); $class=''; echo '<h4>' . _AM_NW_CLONER . '</h4>'; nw_collapsableBar('NewsCloner', 'topNewsCloner'); echo "<img onclick=\"toggle('toptable'); toggleIcon('toptableicon');\" id='topNewsCloner' name='topNewsCloner' src='" . NW_MODULE_URL . "/images/close12.gif' alt='' /></a> " . _AM_NW_CLONER_CLONES . ' (' . $totalclones . ')'."</h4>"; echo "<div id='NewsCloner'>"; echo '<br />'; echo "<div style='text-align: center;'>"; echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'><tr class='bg3'><td align='center'>" . _AM_NW_CLONER_NAME . "</td><td align='center'>" . _AM_NW_CLONER_DIRFOL . "</td><td align='center'>" . _AM_NW_SUBPREFIX . "</td><td align='center'>" . _AM_NW_CLONER_VERSION . "</td><td align='center'>" . _AM_NW_ACTION . "</td><td align='center'>" . _AM_NW_CLONER_ACTION_INSTALL . "</td></tr>"; if(is_array($clone_arr) && $totalclones) { $cpt=1; $tmpcpt=$start; $ok=true; $output=''; while($ok) { if($tmpcpt < $totalclones) { //DNPROSSI - Upgrade if clone version is different from original news version //DNPROSSI - Install if cloned if ( $clone_arr[$tmpcpt]['clone_dir'] != $clone_arr[0]['clone_dir'] ) { if ( $clone_arr[$tmpcpt]['clone_version'] != $clone_arr[0]['clone_version'] ) { $linkupgrade = NW_MODULE_URL . '/admin/index.php?op=cloneupgrade&clone_id=' . $clone_arr[$tmpcpt]['clone_id']; $action = sprintf("<a href='%s'>%s</a>", $linkupgrade, _AM_NW_UPGRADE); if ( $clone_arr[$tmpcpt]['clone_installed'] == 1 ) { $linkupgrade = XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin&op=uninstall&module=' . $clone_arr[$tmpcpt]['clone_dir']; $installaction = sprintf("<a href='%s'>%s</a>", $linkupgrade, _AM_NW_CLONER_UNINSTALL); } else { $linkupgrade = XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin&op=install&module=' . $clone_arr[$tmpcpt]['clone_dir']; $installaction = sprintf("<a href='%s'>%s</a>", $linkupgrade, _AM_NW_CLONER_INSTALL); } } else { $action = _AM_NW_UPGRADE; if ( $clone_arr[$tmpcpt]['clone_installed'] == 1 ) { $linkupgrade = XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin&op=uninstall&module=' . $clone_arr[$tmpcpt]['clone_dir']; $installaction = sprintf("<a href='%s'>%s</a>", $linkupgrade, _AM_NW_CLONER_UNINSTALL); } else { $linkupgrade = XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin&op=install&module=' . $clone_arr[$tmpcpt]['clone_dir']; $installaction = sprintf("<a href='%s'>%s</a>", $linkupgrade, _AM_NW_CLONER_INSTALL); } } } else { $linkupgrade = XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin&op=update&module=' . $clone_arr[$tmpcpt]['clone_dir']; $action = sprintf("<a href='%s'>%s</a>", $linkupgrade, _AM_NW_CLONER_UPDATE); $installaction = ''; } $class = ($class == 'even') ? 'odd' : 'even'; $output = $output . "<tr class='" . $class . "'><td align='center'>" . $clone_arr[$tmpcpt]['clone_name'] . "</td><td align='center'>" . $clone_arr[$tmpcpt]['clone_dir'] . "</td><td align='center'>" . $clone_arr[$tmpcpt]['clone_subprefix'] . "</td><td align='center'>" . $clone_arr[$tmpcpt]['clone_version'] . "</td><td>" . $action . "</td><td>" . $installaction . "</td></tr>"; } else { $ok=false; } if($cpt>=nw_getmoduleoption('storycountadmin', NW_MODULE_DIR_NAME)) { $ok=false; } $tmpcpt++; $cpt++; } echo $output; } $pagenav = new XoopsPageNav( $totalclones, nw_getmoduleoption('storycountadmin', NW_MODULE_DIR_NAME), $start, 'start', 'op=clonemanager'); echo "</table><div align='right'>".$pagenav->renderNav().'</div><br />'; echo "</div></div><br />\n"; $clone_id = isset($_GET['clone_id']) ? intval($_GET['clone_id']) : 0; if($clone_id>0) { $xtmod = new nw_NewsTopic($clone_id); $clone_name=$xtmod->clone_name('E'); $clone_dir=$xtmod->clone_dir('E'); $clone_version=$xtmod->clone_version('E'); $op='modClone'; $btnlabel=_AM_NW_MODIFY; $parent=$xtmod->topic_pid(); $formlabel=_AM_NW_MODIFYTOPIC; $oldnewsimport=$xtmod->menu(); $topic_frontpage=$xtmod->topic_frontpage(); $topic_color=$xtmod->topic_color(); unset($xtmod); } else { $clone_name=''; $clone_frontpage=1; $clone_dir=''; $op='addTopic'; $btnlabel=_AM_NW_ADD; $parent=-1; $oldnewsimport=0; $clone_version=''; $formlabel=_AM_NW_ADD_TOPIC; } //Draw Form $sform = new XoopsThemeForm(_AM_NW_CLONER_ADD, "clonerform", NW_MODULE_URL . "/admin/index.php", "post"); $filedir_tray = new XoopsFormElementTray(_AM_NW_CLONER_NEWNAME, ""); $label = sprintf(_AM_NW_CLONER_NEWNAMEDESC, $xoopsModule->name()); $filedir_tray->addElement(new XoopsFormLabel($label), false); $filedir_tray->addElement(new XoopsFormText(_AM_NW_CLONER_NEWNAMELABEL, "clone_modulename", 50, 255, $clone_modulename), true); $sform->addElement($filedir_tray); $sform->addElement(new XoopsFormHidden("op", "clonerapply"), false); $button_tray = new XoopsFormElementTray("" ,""); $submit_btn = new XoopsFormButton("", "post", _SUBMIT, "submit"); $button_tray->addElement($submit_btn); $sform->addElement($button_tray); $sform->display(); //recalc original subprefix $sub = nw_remove_numbers(NW_SUBPREFIX); $result2 = $xoopsDB->query("SELECT * FROM " . $xoopsDB->prefix($sub.'_stories')); $count = $xoopsDB->getRowsNum($result2); $tmpmodule_handler =& xoops_gethandler('module'); //Draw Import News Form $sform = new XoopsThemeForm(_AM_NW_CLONER_IMPORTNEWS, "clonerimportform", NW_MODULE_URL . "/admin/index.php", "post"); if ( $tmpmodule_handler->getByDirname('news') && nw_TableExists($xoopsDB->prefix('stories')) && $count >= 0) { $sform->addElement(new XoopsFormLabel("", _AM_NW_CLONER_IMPORTNEWSDESC2), false); } $sform->addElement(new XoopsFormHidden('op', 'clonenewsimport'), false); if ( $tmpmodule_handler->getByDirname('news') && nw_TableExists($xoopsDB->prefix('stories')) && $count == 0) { $button_tray = new XoopsFormElementTray(_AM_NW_CLONER_IMPORTNEWSDESC1 , _AM_NW_CLONER_IMPORTNEWSDESC2); $submit_btn = new XoopsFormButton("", "post", _AM_NW_CLONER_IMPORTNEWSSUB, "submit"); $button_tray->addElement($submit_btn); $sform->addElement($button_tray); } $sform->display(); }