From: <zy...@us...> - 2015-02-21 20:56:28
|
Revision: 13006 http://sourceforge.net/p/xoops/svn/13006 Author: zyspec Date: 2015-02-21 20:56:25 +0000 (Sat, 21 Feb 2015) Log Message: ----------- * require XOOPS 2.5.7+ & PHP 5.3.7+ * renamed all template extensions from .html to .tpl * added XOOPS & PHP version checks on install/update * moved install/uninstall/upgrade functions to ./include/action.module.php * moved images and css directories to ./assets * added loading stylesheet in block * added XoopspartnersConstants class for constant definitions * added block config to be able to trim title length * added _MI_XPARTNERS_INCADMIN define, missing in previous BETA * refactored /admin/main.php from seperate functions to switch statement * general code cleanup for PSRx Modified Paths: -------------- XoopsModules/xoopspartners/branches/zyspec/xoopspartners/admin/about.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/admin/admin_footer.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/admin/admin_header.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/admin/index.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/admin/main.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/admin/menu.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/blocks/partners.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/class/partners.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/docs/changelog.txt XoopsModules/xoopspartners/branches/zyspec/xoopspartners/docs/install.txt XoopsModules/xoopspartners/branches/zyspec/xoopspartners/docs/readme.txt XoopsModules/xoopspartners/branches/zyspec/xoopspartners/footer.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/header.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/index.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/join.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/language/english/admin.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/language/english/blocks.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/language/english/main.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/language/english/modinfo.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/language/french/admin.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/language/french/blocks.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/language/french/modinfo.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/language/spanish/admin.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/language/spanish/blocks.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/language/spanish/modinfo.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/test/readme.txt XoopsModules/xoopspartners/branches/zyspec/xoopspartners/vpartner.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/xoops_version.php Added Paths: ----------- XoopsModules/xoopspartners/branches/zyspec/xoopspartners/assets/ XoopsModules/xoopspartners/branches/zyspec/xoopspartners/assets/css/ XoopsModules/xoopspartners/branches/zyspec/xoopspartners/assets/css/style.css XoopsModules/xoopspartners/branches/zyspec/xoopspartners/assets/images/ XoopsModules/xoopspartners/branches/zyspec/xoopspartners/assets/index.html XoopsModules/xoopspartners/branches/zyspec/xoopspartners/class/constants.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/include/ XoopsModules/xoopspartners/branches/zyspec/xoopspartners/include/action.module.php XoopsModules/xoopspartners/branches/zyspec/xoopspartners/include/index.html XoopsModules/xoopspartners/branches/zyspec/xoopspartners/templates/blocks/xoopspartners_block_site.tpl XoopsModules/xoopspartners/branches/zyspec/xoopspartners/templates/xoopspartners_index.tpl XoopsModules/xoopspartners/branches/zyspec/xoopspartners/templates/xoopspartners_join.tpl Removed Paths: ------------- XoopsModules/xoopspartners/branches/zyspec/xoopspartners/css/ XoopsModules/xoopspartners/branches/zyspec/xoopspartners/images/ XoopsModules/xoopspartners/branches/zyspec/xoopspartners/templates/blocks/xoopspartners_block_site.html XoopsModules/xoopspartners/branches/zyspec/xoopspartners/templates/xoopspartners_index.html XoopsModules/xoopspartners/branches/zyspec/xoopspartners/templates/xoopspartners_join.html Modified: XoopsModules/xoopspartners/branches/zyspec/xoopspartners/admin/about.php =================================================================== --- XoopsModules/xoopspartners/branches/zyspec/xoopspartners/admin/about.php 2015-02-20 09:09:25 UTC (rev 13005) +++ XoopsModules/xoopspartners/branches/zyspec/xoopspartners/admin/about.php 2015-02-21 20:56:25 UTC (rev 13006) @@ -1,5 +1,5 @@ <?php -/** +/* * XoopsPartners module * * You may not change or alter any portion of this comment or credits @@ -8,17 +8,19 @@ * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ +/** + * XoopsPartners - a partner affiliation links modulerequire __DIR__ . '/admin_header.php'; * - * @copyright:: The XOOPS Project (http://www.xoops.org) - * @license:: GNU GPL (http://www.gnu.org/licenses/gpl-2.0.html/) - * @package:: XoopsPartners + * @copyright:: {@link http://sourceforge.net/projects/xoops/ The XOOPS Project}$indexAdmin = new ModuleAdmin(); + * @license:: {@link http://www.fsf.org/copyleft/gpl.html GNU public license}$pathImageIcon = XOOPS_URL .'/'. $moduleInfo->getInfo('icons16'); + * @package:: xoopspartners + * @author:: Mage, Mamba * @since:: 1.11 - * @author:: Mage, Mamba - * @version:: $Id $ - * + * @version:: $Id: $ */ -require 'admin_header.php'; +require __DIR__ . '/admin_header.php'; include '../../../class/xoopsformloader.php'; $aboutAdmin = new ModuleAdmin(); @@ -26,4 +28,4 @@ echo $aboutAdmin->addNavigation('about.php'); echo $aboutAdmin->renderabout('6KJ7RW5DR3VTJ', false); -include 'admin_footer.php'; \ No newline at end of file +include __DIR__ . '/admin_footer.php'; Modified: XoopsModules/xoopspartners/branches/zyspec/xoopspartners/admin/admin_footer.php =================================================================== --- XoopsModules/xoopspartners/branches/zyspec/xoopspartners/admin/admin_footer.php 2015-02-20 09:09:25 UTC (rev 13005) +++ XoopsModules/xoopspartners/branches/zyspec/xoopspartners/admin/admin_footer.php 2015-02-21 20:56:25 UTC (rev 13006) @@ -1,5 +1,5 @@ <?php -/** +/* * XoopsPartner module * * You may not change or alter any portion of this comment or credits @@ -8,13 +8,14 @@ * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * @copyright:: The XOOPS Project http://sourceforge.net/projects/xoops/ - * @license:: http://www.fsf.org/copyleft/gpl.html GNU public license - * @package:: XoopsPartners + */ +/** + * @copyright:: {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} + * @license:: {@link http://www.fsf.org/copyleft/gpl.html GNU public license} + * @package:: xoopspartners * @since:: 1.11 * @author:: XOOPS Development Team - * @version: $Id $ + * @version: $Id: $ **/ if (!isset($moduleInfo) || !is_a($moduleInfo, 'XoopsModule')) { @@ -25,10 +26,10 @@ } echo "<div class='adminfooter'>\n" - ." <div style='text-align: center;'>\n" - ." <a href='" . $moduleInfo->getInfo('author_website_url') . "' target='_blank'><img src='" . XOOPS_URL . "/" . $moduleInfo->getInfo("dirmoduleadmin") . "/icons/32/xoopsmicrobutton.gif' alt='" . $xoopsModule->getInfo('author_website_name') . "' title='" . $moduleInfo->getInfo('author_website_name') . "' /></a>\n" + ." <div class='txtcenter'>\n" + ." <a href='" . $moduleInfo->getInfo('author_website_url') . "' target='_blank'><img src='" . $GLOBALS['xoops']->url("www/{$pathIcon32}/xoopsmicrobutton.gif") . "' alt='" . $xoopsModule->getInfo('author_website_name') . "' title='" . $moduleInfo->getInfo('author_website_name') . "' /></a>\n" ." </div>\n" ." " . _AM_XPARTNERS_ADMIN_FOOTER . "\n" - ."</div>"; + ."</div>\n"; -xoops_cp_footer(); \ No newline at end of file +xoops_cp_footer(); Modified: XoopsModules/xoopspartners/branches/zyspec/xoopspartners/admin/admin_header.php =================================================================== --- XoopsModules/xoopspartners/branches/zyspec/xoopspartners/admin/admin_header.php 2015-02-20 09:09:25 UTC (rev 13005) +++ XoopsModules/xoopspartners/branches/zyspec/xoopspartners/admin/admin_header.php 2015-02-21 20:56:25 UTC (rev 13006) @@ -1,5 +1,5 @@ <?php -/** +/* * XoopsPartners module * * You may not change or alter any portion of this comment or credits @@ -8,24 +8,29 @@ * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * @copyright:: The XOOPS Project http://sourceforge.net/projects/xoops/ - * @license:: http://www.fsf.org/copyleft/gpl.html GNU public license - * @package:: XoopsPartners + */ +/** + * @copyright:: {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} + * @license:: {@link http://www.fsf.org/copyleft/gpl.html GNU public license} + * @package:: xoopspartners * @subpackage:: admin * @since:: 1.11 * @author:: XOOPS Team - * @version:: $Id $ + * @version:: $Id: $ **/ -require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/mainfile.php'; -include_once XOOPS_ROOT_PATH . '/include/cp_functions.php'; -require XOOPS_ROOT_PATH . '/include/cp_header.php'; +require_once dirname(dirname(dirname(__DIR__))) . '/mainfile.php'; +include_once $GLOBALS['xoops']->path('/include/cp_functions.php'); +require $GLOBALS['xoops']->path('/include/cp_header.php'); + +$moduleDirname = basename(dirname(__DIR__)); +xoops_load('constants', $moduleDirname); + //Load languages -$thisModDir = $xoopsModule->getVar('dirname', 'n'); -xoops_loadLanguage('admin', $thisModDir); -xoops_loadLanguage('modinfo', $thisModDir); -xoops_loadLanguage('main', $thisModDir); +$moduleDirname = $GLOBALS['xoopsModule']->getVar('dirname', 'n'); +xoops_loadLanguage('admin', $moduleDirname); +xoops_loadLanguage('modinfo', $moduleDirname); +xoops_loadLanguage('main', $moduleDirname); if ( file_exists($GLOBALS['xoops']->path('/Frameworks/moduleclasses/moduleadmin/moduleadmin.php'))){ include_once $GLOBALS['xoops']->path('/Frameworks/moduleclasses/moduleadmin/moduleadmin.php'); @@ -35,15 +40,19 @@ //return false; } -$moduleInfo =& $module_handler->get($xoopsModule->getVar('mid')); -$pathImageIcon = XOOPS_URL .'/'. $moduleInfo->getInfo('icons16'); -$pathImageAdmin = XOOPS_URL .'/'. $moduleInfo->getInfo('icons32'); +$moduleHandler =& xoops_gethandler('module'); +$moduleInfo =& $moduleHandler->get($GLOBALS['xoopsModule']->getVar('mid')); +$pathIcon16 = $GLOBALS['xoopsModule']->getInfo('icons16'); +$pathIcon32 = $GLOBALS['xoopsModule']->getInfo('icons32'); +$pathModuleAdmin = $GLOBALS['xoopsModule']->getInfo('dirmoduleadmin'); +//$pathImageIcon = XOOPS_URL .'/'. $moduleInfo->getInfo('icons16'); +//$pathImageAdmin = XOOPS_URL .'/'. $moduleInfo->getInfo('icons32'); $myts =& MyTextSanitizer::getInstance(); -if (!isset($xoopsTpl) || !is_object($xoopsTpl)) { - include_once XOOPS_ROOT_PATH . "/class/template.php"; - $xoopsTpl = new XoopsTpl(); +if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) { + include_once $GLOBALS['xoops']->path("/class/template.php"); + $GLOBALS['xoopsTpl'] = new XoopsTpl(); } -xoops_cp_header(); \ No newline at end of file +xoops_cp_header(); Modified: XoopsModules/xoopspartners/branches/zyspec/xoopspartners/admin/index.php =================================================================== --- XoopsModules/xoopspartners/branches/zyspec/xoopspartners/admin/index.php 2015-02-20 09:09:25 UTC (rev 13005) +++ XoopsModules/xoopspartners/branches/zyspec/xoopspartners/admin/index.php 2015-02-21 20:56:25 UTC (rev 13006) @@ -1,45 +1,46 @@ <?php -// -// ------------------------------------------------------------------------ // -// XOOPS - PHP Content Management System // -// Copyright (c) 2000 XOOPS.org // -// <http://www.xoops.org/> // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Raul Recio (AKA UNFOR) // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // + +/*------------------------------------------------------------------------ + XOOPS - PHP Content Management System + Copyright (c) 2000 XOOPS.org + <http://www.xoops.org/> + ------------------------------------------------------------------------ + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting + source code which is considered copyrighted (c) material of the + original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + ------------------------------------------------------------------------ + Author: Raul Recio (AKA UNFOR) + Project: The XOOPS Project + ------------------------------------------------------------------------- + */ /** - * Xoops Headline Administration + * XoopsParnters Administration * - * @copyright:: The XOOPS Project http://sourceforge.net/projects/xoops/ - * @license:: http://www.fsf.org/copyleft/gpl.html GNU public license - * @package:: xoopsheadline - * @since:: 1.11 + * @copyright:: {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} + * @license:: {@link http://www.fsf.org/copyleft/gpl.html GNU public license} + * @package:: xoopspartners + * @since:: 1.11 * @author:: Raul Recio (aka UNFOR) * @version: $Id: $ */ -require 'admin_header.php'; -$indexAdmin = new ModuleAdmin(); +require __DIR__ . '/admin_header.php'; +$adminClass = new ModuleAdmin(); //----------------------- $xpPartnerHandler =& xoops_getmodulehandler('partners', $xoopsModule->getVar('dirname', 'n')); @@ -48,14 +49,14 @@ $totalNonActivePartners = $xpPartnerHandler->getCount(new Criteria('status', 0, '=')); $totalActivePartners = $totalPartners - $totalNonActivePartners; -$indexAdmin->addInfoBox(_MD_XPARTNERS_DASHBOARD); +$adminClass->addInfoBox(_MD_XPARTNERS_DASHBOARD); -$indexAdmin->addInfoBoxLine(_MD_XPARTNERS_DASHBOARD, "<infolabel>" ._MD_XPARTNERS_TOTALACTIVE. "</infolabel>", $totalActivePartners, 'Green'); -$indexAdmin->addInfoBoxLine(_MD_XPARTNERS_DASHBOARD, "<infolabel>" ._MD_XPARTNERS_TOTALNONACTIVE. "</infolabel>", $totalNonActivePartners, 'Red'); -$indexAdmin->addInfoBoxLine(_MD_XPARTNERS_DASHBOARD, "<infolabel>" ._MD_XPARTNERS_TOTALPARTNERS. "</infolabel><infotext>", $totalPartners."</infotext>"); +$adminClass->addInfoBoxLine(_MD_XPARTNERS_DASHBOARD, "<infolabel>" ._MD_XPARTNERS_TOTALACTIVE. "</infolabel>", $totalActivePartners, 'Green'); +$adminClass->addInfoBoxLine(_MD_XPARTNERS_DASHBOARD, "<infolabel>" ._MD_XPARTNERS_TOTALNONACTIVE. "</infolabel>", $totalNonActivePartners, 'Red'); +$adminClass->addInfoBoxLine(_MD_XPARTNERS_DASHBOARD, "<infolabel>" ._MD_XPARTNERS_TOTALPARTNERS. "</infolabel><infotext>", $totalPartners."</infotext>"); //---------------------------- -echo $indexAdmin->addNavigation('index.php'); -echo $indexAdmin->renderIndex(); +echo $adminClass->addNavigation('index.php'); +echo $adminClass->renderIndex(); -include 'admin_footer.php'; \ No newline at end of file +include __DIR__ . '/admin_footer.php'; Modified: XoopsModules/xoopspartners/branches/zyspec/xoopspartners/admin/main.php =================================================================== --- XoopsModules/xoopspartners/branches/zyspec/xoopspartners/admin/main.php 2015-02-20 09:09:25 UTC (rev 13005) +++ XoopsModules/xoopspartners/branches/zyspec/xoopspartners/admin/main.php 2015-02-21 20:56:25 UTC (rev 13006) @@ -1,426 +1,363 @@ <?php -// $Id: main.php,v 1.9.4.2 2005/03/29 15:58:18 mithyt2 Exp $ -// ------------------------------------------------------------------------ // -// XOOPS - PHP Content Management System // -// Copyright (c) 2000 XOOPS.org // -// <http://www.xoops.org/> // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Raul Recio (AKA UNFOR) // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // +/* + ------------------------------------------------------------------------ + XOOPS - PHP Content Management System + Copyright (c) 2000 XOOPS.org + <http://www.xoops.org/> + ------------------------------------------------------------------------ + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -require 'admin_header.php'; + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting + source code which is considered copyrighted (c) material of the + original comment or credit authors. -$indexAdmin = new ModuleAdmin(); -$pathImageIcon = XOOPS_URL .'/'. $moduleInfo->getInfo('icons16'); + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -$del = 0; + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + ------------------------------------------------------------------------ + Author: Raul Recio (AKA UNFOR) + Project: The XOOPS Project + ------------------------------------------------------------------------- +*/ +/** + * XoopsPartners - a partner affiliation links module + * + * @copyright:: {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} + * @license:: {@link http://www.fsf.org/copyleft/gpl.html GNU public license} + * @package:: xoopspartners + * @author:: Raul Recio (aka unfor) + * @version:: $Id: $ + */ +require __DIR__ . '/admin_header.php'; +$adminClass = new ModuleAdmin(); +$pathImageIcon = $GLOBALS['xoops']->url('www/'. $moduleInfo->getInfo('icons16')); -function partnersAdmin() -{ - global $xoopsModule, $indexAdmin, $pathImageIcon; - $xoopsDB =& XoopsDatabaseFactory::getDatabaseConnection(); -// $xoopsDB =& Database::getInstance(); - $myts =& MyTextSanitizer::getInstance(); - $xpPartnerHandler =& xoops_getmodulehandler('partners', $xoopsModule->getVar('dirname')); +$myts =& MyTextSanitizer::getInstance(); - echo $indexAdmin->addNavigation('main.php?op=default'); - echo" <form action='main.php' method='post' name='reorderform'>\n" - . " <table style='width: 100%; border-width: 0px; margin: 1px; padding: 0px;' class='outer'>\n" - . " <tr>\n" . " <th style='width: 20%; text-align: center;'>" . _AM_XPARTNERS_TITLE . "</th>\n" - . " <th style='width: 3%; text-align: center;'>" . _AM_XPARTNERS_IMAGE . "</th>\n" . " <th>" - . _AM_XPARTNERS_DESCRIPTION . "</th>\n" . " <th style='width: 3%; text-align: center;'>" - . _AM_XPARTNERS_ACTIVE . "</th>\n" . " <th style='width: 3%; text-align: center;'>" - . _AM_XPARTNERS_WEIGHT . "</th>\n" . " <th style='width: 3%; text-align: center;'>" . _AM_XPARTNERS_HITS - . "</th>\n" . " <th style='width: 3%; text-align: center;'>" . _AM_XPARTNERS_ACTIONS . "</th>\n" - . " </tr>\n"; +xoops_load('XoopsRequest'); +$op = XoopsRequest::getCmd('op', ''); +$id = XoopsRequest::getInt('id', 0); - $criteria = new CriteriaCompo(); - $criteria->setSort('status DESC, weight ASC, title'); - $criteria->setOrder('DESC'); - $partnerObjs = $xpPartnerHandler->getAll($criteria); - $class = 'even'; - foreach ($partnerObjs as $partnerObj) { - $url = formatURL($myts->htmlSpecialChars($partnerObj->getVar('url'))); - $image = formatURL($myts->htmlSpecialChars($partnerObj->getVar('image'))); - $title = $myts->htmlSpecialChars($partnerObj->getVar('title')); - $description = $myts->htmlSpecialChars($partnerObj->getVar('description')); - $imageInfo = @getimagesize($partnerObj->getVar('image')); - /* - $result = $xoopsDB->query("SELECT id, hits, url, weight, image, title, description, status FROM ".$xoopsDB->prefix("partners")." ORDER BY status DESC, weight ASC, title DESC"); - $class = 'even'; - while (list($id, $hits, $url, $weight, $image, $title, $description, $status) = $xoopsDB->fetchrow($result)) { - $url = formatURL($myts->htmlSpecialChars($url)); - $image = formatURL($myts->htmlSpecialChars($image)); - $title = $myts->htmlSpecialChars($title); - $description = $myts->htmlSpecialChars($description); - */ - if ($imageInfo = getimagesize($image)) { - $imageWidth = $imageInfo[0]; - $imageHeight = $imageInfo[1]; - $errorMsg = ($imageWidth >= 150 || $imageHeight >= 110) ? "<br />" . _AM_XPARTNERS_IMAGE_ERROR : ''; - } else { - $imageWidth = 150; - $imageHeight = 110; - } - $check1 = $check2 = ""; - if (1 == $partnerObj->getVar('status')) { - $check1 = " selected='selected'"; - } else { - $check2 = " selected='selected'"; - } - echo" <tr>\n" - . " <td class='{$class}' style='width: 20%; text-align: center; vertical-align: middle;'><a href='{$url}' rel='external'>{$title}</a></td>\n" - . " <td class='{$class}' style='width: 3%; text-align: center;'>"; - if (!empty($image)) { - echo "<img src='{$image}' alt='{$title}' style='width: " . intval(.65 * $imageWidth) . "px; height: " . intval(.65 * $imageHeight) . "px;' />{$errorMsg}"; - } else { - echo " "; - } +$del = isset($_POST['del']) ? XoopsRequest::getInt('del', XoopspartnersConstants::CONFIRM_NOT_OK, 'POST') : null; +$hits = isset($_POST['hits']) ? XoopsRequest::getint('hits', 0, 'POST') : null; +$url = isset($_POST['url']) ? XoopsRequest::getString('url', '', 'POST') : null; +$image = isset($_POST['image']) ? XoopsRequest::getText('image', '', 'POST') : null; +$title = isset($_POST['title']) ? XoopsRequest::getString('title', '', 'POST') : null; +$description = isset($_POST['description']) ? XoopsRequest::getText('description', '', 'POST') : null; +$status = isset($_POST['status']) ? XoopsRequest::getInt('status', array(), 'POST') : null; - echo" </td>\n" . " <td class='{$class}'>{$description}</td>\n" - . " <td class='{$class}' style='width: 3%px; text-align: center;'>\n" - . " <select style='size: 1px;' name='status[" . $partnerObj->getVar('id') - . "]'> <option value='1'{$check1}>" . _YES . "</option><option value='0'{$check2}>" . _NO - . "</option></select>\n" . " <td class='{$class}' style='width: 3%; text-align: center;'>\n" - . " <input type='text' name='weight[" . $partnerObj->getVar('id') . "]' value='" - . $partnerObj->getVar( - 'weight' - ) . "' style='size: 3px; text-align: center;' maxlength='3' />\n" . " </td>\n" - . " <td class='{$class}' style='width: 3%; text-align: center;'>" . $partnerObj->getVar('hits') . "</td>\n" - . " <td class='{$class}' style='width: 3%; text-align: center;'>\n" +switch ($op) { - . " <a href='main.php?op=editPartner&id=" . $partnerObj->getVar('id') - . "'><img src='{$pathImageIcon}/edit.png' alt='" . _EDIT . "' title='" . _EDIT . "' /></a>\n" + case 'partnersAdmin': + default: + $xpPartnerHandler =& xoops_getmodulehandler('partners', $GLOBALS['xoopsModule']->getVar('dirname')); - . " <a href='main.php?op=delPartner&id=" . $partnerObj->getVar('id') - . "'><img src='{$pathImageIcon}/delete.png' alt='" . _DELETE . "' title='" . _DELETE . "' /></a>\n" - . " </td>\n" . " </tr>\n"; - $class = ($class == 'odd') ? 'even' : 'odd'; - } - unset($partnerObjs); - echo" <tr>\n" . " <td class='foot' colspan='7' style='text-align: right;'>\n" - . " <input type='hidden' name='op' value='reorderPartners' />\n" - . " <input type='button' name='button' onclick=\"location='main.php?op=partnersAdminAdd'\" value='" - . _AM_XPARTNERS_ADD . "' />\n" - . " <input type='button' name='button' onclick=\"location='main.php?op=reorderAutoPartners'\" value='" - . _AM_XPARTNERS_AUTOMATIC_SORT . "' />\n" . " <input type='submit' name='submit' value='" - . _AM_XPARTNERS_REORDER . "' />\n" . " </td>\n" . " </tr>\n" . " </table>\n" . " </form>\n"; - include 'admin_footer.php'; -} + echo $adminClass->addNavigation('main.php'); + $adminClass->addItemButton(_AM_XPARTNERS_ADD, 'main.php' . '?op=partnersAdminAdd', $icon = 'add'); + echo $adminClass->renderButton(); -function reorderPartners($weight=array(), $status=0) -{ - global $xoopsModule, $xoopsDB; + echo " <form action='main.php' method='post' name='reorderform'>\n" + . " <table style='margin: 1px; padding: 0px;' class='outer width100 bnone'>\n" + . " <thead>\n" + . " <tr>\n" + . " <th class='txtcenter width20'>" . _AM_XPARTNERS_TITLE . "</th>\n" + . " <th style='width: 3%; text-align: center;'>" . _AM_XPARTNERS_IMAGE . "</th>\n" + . " <th>" . _AM_XPARTNERS_DESCRIPTION . "</th>\n" + . " <th class='width3 txtcenter'>" . _AM_XPARTNERS_ACTIVE . "</th>\n" + . " <th class='width3 txtcenter'>" . _AM_XPARTNERS_WEIGHT . "</th>\n" + . " <th class='width3 txtcenter'>" . _AM_XPARTNERS_HITS . "</th>\n" + . " <th class='width3 txtcenter'>" . _AM_XPARTNERS_ACTIONS . "</th>\n" + . " </tr>\n" + . " </thead>\n" + . " <tbody\n"; - $partnerHandler =& xoops_getmodulehandler('partners', $xoopsModule->getVar('dirname')); - $partnerCount = $partnerHandler->getCount(); - if ($partnerCount) { - /* - $result = $xoopsDB->query("SELECT id FROM ".$xoopsDB->prefix("partners")); - if ($xoopsDB->getRowsNum($result)) { - */ - foreach ($weight as $id => $order) { - if (intval($id) > 0) { - $order = (intval($order) > 0) ? intval($order) : 0; - $stat = isset($status[$id]) ? intval($status[$id]) : 0; - $thisObj = $partnerHandler->get($id); - if (is_object($thisObj) && count($thisObj)) { - $thisObj->setVars(array('weight' => $order, 'status' => $stat)); - $partnerHandler->insert($thisObj); - unset($thisObj); - } + $criteria = new CriteriaCompo(); + $criteria->setSort('status DESC, weight ASC, title'); + $criteria->setOrder('DESC'); + $partnerObjs = $xpPartnerHandler->getAll($criteria); + $class = 'even'; + $maxWidth = $GLOBALS['xoopsModuleConfig']['maxwidth']; + $maxHeight = $GLOBALS['xoopsModuleConfig']['maxheight']; + foreach ($partnerObjs as $partnerObj) { + $url = formatURL($partnerObj->getVar('url')); + $image = formatURL($partnerObj->getVar('image')); + $title = $partnerObj->getVar('title'); + $description = $partnerObj->getVar('description'); + //@TODO - find a way to check size of remote image if allow_url_fopen=0 + if ($imageInfo = @getimagesize($image)) { //note this will "fail" if server set with allow_url_fopen=0 + $imageWidth = $imageInfo[0]; + $imageHeight = $imageInfo[1]; + $errorMsg = ($imageWidth > $maxWidth || $imageHeight > $maxHeight) ? "<br />" . _AM_XPARTNERS_IMAGE_ERROR : ''; + } else { + $imageWidth = $maxWidth; + $imageHeight = $maxHeight; + $errorMsg = ''; } + if (1 == $partnerObj->getVar('status')) { + $check1 = " selected='selected'"; + $check2 = ""; + } else { + $check1 = ""; + $check2 = " selected='selected'"; + } + echo " <tr>\n" + . " <td class='{$class} width20 txtcenter alignmiddle'><a href='{$url}' rel='external'>{$title}</a></td>\n" + . " <td class='{$class} width3 txtcenter'>"; + if (!empty($image)) { + echo "<img src='{$image}' alt='{$title}' style='width: " . intval(.65 * $imageWidth) . "px; height: " . intval(.65 * $imageHeight) . "px;' />{$errorMsg}"; + } else { + echo " "; + } + + echo " </td>\n" + . " <td class='{$class} alignmiddle'>{$description}</td>\n" + . " <td class='{$class} width3 txtcenter alignmiddle'>\n" + . " <select name='status[" . $partnerObj->getVar('id') . "]'>\n" + . " <option value='0'{$check2}>" . _NO . "</option>\n" + . " <option value='1'{$check1}>" . _YES . "</option>\n" + . " </select>\n" + . " <td class='{$class} width3 txtcenter alignmiddle'>\n" + . " <input type='number' class='txtcenter' name='weight[" . $partnerObj->getVar('id') . "]' value='" . $partnerObj->getVar('weight') . "' min='0' size='3' />\n" + . " </td>\n" + . " <td class='{$class} width3 txtcenter alignmiddle'>" . $partnerObj->getVar('hits') . "</td>\n" + . " <td class='{$class} width3 txtcenter alignmiddle'>\n" + . " <a href='main.php?op=editPartner&id=" . $partnerObj->getVar('id') . "'><img src='{$pathImageIcon}/edit.png' alt='" . _EDIT . "' title='" . _EDIT . "' /></a>\n" + . " <a href='main.php?op=delPartner&id=" . $partnerObj->getVar('id') . "'><img src='{$pathImageIcon}/delete.png' alt='" . _DELETE . "' title='" . _DELETE . "' /></a>\n" + . " </td>\n" + . " </tr>\n"; + $class = ($class == 'odd') ? 'even' : 'odd'; } - redirect_header("main.php?op=default", 1, _AM_XPARTNERS_UPDATED); - } else { - redirect_header("main.php?op=partnersAdminAdd", 2, _AM_XPARTNERS_EMPTYDATABASE, false); - } -} + if (empty($partnerObjs)) { + echo "<tr><td class='{$class} txtcenter bold line140' colspan='7'>" . _AM_XPARTNERS_NOPARTNERS . "</td></tr>\n"; + $adminButtons = ''; + } else { + $adminButtons = " <input type='button' name='button' onclick=\"location='main.php?op=reorderAutoPartners'\" value='" . _AM_XPARTNERS_AUTOMATIC_SORT . "' />\n" + . " <input type='submit' name='submit' value='" . _AM_XPARTNERS_UPDATE . "' />"; -function reorderAutoPartners() -{ - global $xoopsModule; - //$xoopsDB =& Database::getInstance(); - $partnerHandler =& xoops_getmodulehandler('partners', $xoopsModule->getVar('dirname')); - $partnerObjs = $partnerHandler->getAll(null, array('weight')); - $partnerCount = count($partnerObjs); - $weight = 0; - if ($partnerCount > 1) { - foreach ($partnerObjs as $thisObj) { - $weight++; - $thisObj->setVar('weight', $weight); - $partnerHandler->insert($thisObj); - unset($thisObj); } - redirect_header("main.php?op=default", 1, _AM_XPARTNERS_UPDATED); - } else { - redirect_header("main.php?op=partnersAdminAdd", 2, _AM_XPARTNERS_EMPTYDATABASE, false); - } -} + echo" <tr>\n" + . " <td class='foot txtright' colspan='7'>\n" + . " <input type='hidden' name='op' value='reorderPartners' />\n" +// . " <input type='button' name='button' onclick=\"location='main.php?op=partnersAdminAdd'\" value='" . _AM_XPARTNERS_ADD . "' />\n" + . "{$adminButtons}\n" + . " </td>\n" + . " </tr>\n" + . " </tbody>\n" + . " </table>\n" + . " </form>\n"; -function partnersAdminAdd() -{ - global $xoopsModule, $indexAdmin, $pathImageIcon, $myts; - $xoopsDB =& XoopsDatabaseFactory::getDatabaseConnection(); -// $xoopsDB =& Database::getInstance(); + unset($partnerObjs); + include __DIR__ . '/admin_footer.php'; + break; - echo $indexAdmin->addNavigation('main.php?op=partnersAdminAdd'); - //echo "<h4>"._AM_XPARTNERS_ADD."</h4>"; - include XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; - $form = new XoopsThemeForm(_AM_XPARTNERS_ADDPARTNER, "addform", "main.php", "post", true); - $formweight = new XoopsFormText(_AM_XPARTNERS_WEIGHT, "weight", 3, 10, 0); - $formimage = new XoopsFormText(_AM_XPARTNERS_IMAGE, "image", 100, 150, 'http://'); - $formurl = new XoopsFormText(_AM_XPARTNERS_URL, "url", 100, 150, 'http://'); - $formtitle = new XoopsFormText(_AM_XPARTNERS_TITLE, "title", 100, 150); - $formdesc = new XoopsFormTextArea(_AM_XPARTNERS_DESCRIPTION, "description", "", 10, "60"); - $statontxt - = " <img src=". $pathImageIcon .'/on.png'.' '. "alt='" . _AM_XPARTNERS_ACTIVE . "' /> " . _AM_XPARTNERS_ACTIVE - . " "; - $statofftxt - = " <img src=". $pathImageIcon .'/off.png' .' '."alt='" . _AM_XPARTNERS_INACTIVE . "' /> " - . _AM_XPARTNERS_INACTIVE . " "; - $formstat = new XoopsFormRadioYN(_AM_XPARTNERS_STATUS, 'status', 1, $statontxt, $statofftxt); - $opHidden = new XoopsFormHidden("op", "addPartner"); - $submitButton = new XoopsFormButton("", "submit", _AM_XPARTNERS_ADDPARTNER, "submit"); - $form->addElement($formtitle, true); - $form->addElement($formimage); - $form->addElement($formurl, true); - $form->addElement($formweight); - $form->addElement($formdesc, true); - $form->addElement($formstat); - $form->addElement($opHidden); - $form->addElement($submitButton); - $form->display(); - include 'admin_footer.php'; -} + case 'reorderPartners': + $weight = isset($_POST['weight']) ? XoopsRequest::getArray('weight', array(), 'POST') : null; + $status = isset($_POST['status']) ? XoopsRequest::getArray('status', array(), 'POST') : null; -function addPartner($weight=0, $url, $image, $title, $description, $status=0) -{ - global $xoopsModule, $xoopsDB, $myts; - - $partnerHandler =& xoops_getmodulehandler('partners', $xoopsModule->getVar('dirname')); - $newPartner = $partnerHandler->create(); - - $status = (intval($status) > 0) ? intval($status) : 0; - $weight = (intval($weight) > 0) ? intval($weight) : 0; - $title = isset($title) ? trim($title) : ''; - $url = isset($url) ? trim($url) : ''; - $image = isset($image) ? trim($image) : ''; - $image = $myts->addSlashes(formatURL($image)); - $description = isset($description) ? trim($description) : ''; - if ('' == $title || '' == $url || '' == $description) { - redirect_header('main.php?op=default', 2, _AM_XPARTNERS_BESURE); - } - /* - if (!empty($image)) { - $image_info = @getimagesize($image); - var_dump($image_info); - exit; - if (!$image_info[2]) { - redirect_header("main.php?op=default", 2, _AM_XPARTNERS_NOEXIST . '<br />(' . $image . ')'); + $xpPartnerHandler =& xoops_getmodulehandler('partners', $GLOBALS['xoopsModule']->getVar('dirname')); + $partnerCount = $xpPartnerHandler->getCount(); + if ($partnerCount) { + foreach ($weight as $id => $order) { + if (intval($id) > XoopspartnersConstants::DEFAULT_PID) { + $order = ((!empty($order)) && (intval($order) > XoopspartnersConstants::DEFAULT_WEIGHT)) ? intval($order) : XoopspartnersConstants::DEFAULT_WEIGHT; + $stat = (!empty($status[$id]) && ($status[$id] > XoopspartnersConstants::STATUS_INACTIVE)) ? intval($status[$id]) : XoopspartnersConstants::STATUS_INACTIVE; + $thisObj = $xpPartnerHandler->get($id); + if (!empty($thisObj) && ($thisObj instanceof XoopspartnersPartners)) { + $thisObj->setVars(array('weight' => $order, 'status' => $stat)); + $xpPartnerHandler->insert($thisObj); + unset($thisObj); + } + } } + redirect_header("main.php", XoopspartnersConstants::REDIRECT_DELAY_SHORT, _AM_XPARTNERS_UPDATED); + } else { + redirect_header("main.php?op=partnersAdminAdd", XoopspartnersConstants::REDIRECT_DELAY_MEDIUM, _AM_XPARTNERS_EMPTYDATABASE, false); } + break; - if (!empty($image)) { - $image_info = exif_imagetype($image); - if (false === $image_info) { - redirect_header("main.php?op=default", 1, _AM_XPARTNERS_NOEXIST); + case 'reorderAutoPartners': + $xpPartnerHandler =& xoops_getmodulehandler('partners', $GLOBALS['xoopsModule']->getVar('dirname')); + $partnerObjs = $xpPartnerHandler->getAll(null, array('weight')); + $partnerCount = count($partnerObjs); + $weight = XoopspartnersConstants::DEFAULT_WEIGHT; + if ($partnerCount > 1) { + foreach ($partnerObjs as $thisObj) { + ++$weight; + $thisObj->setVar('weight', $weight); + $xpPartnerHandler->insert($thisObj); + unset($thisObj); } + redirect_header('main.php', XoopspartnersConstants::REDIRECT_DELAY_SHORT, _AM_XPARTNERS_UPDATED); + } else { + redirect_header('main.php?op=partnersAdminAdd', XoopspartnersConstants::REDIRECT_DELAY_MEDIUM, _AM_XPARTNERS_EMPTYDATABASE, false); } - */ - $newPartner->setVar('url', $myts->addSlashes(formatURL($url))); - $newPartner->setVar('image', $image); - $newPartner->setVar('title', $myts->addSlashes($title)); - $newPartner->setVar('description', $myts->addSlashes($description)); - $newPartner->setVar('status', $status); - $newPartner->setVar('weight', $weight); + break; - if ($GLOBALS['xoopsSecurity']->check() && $partnerHandler->insert($newPartner)) { - /* - $sql = "INSERT INTO ".$xoopsDB->prefix("partners")." VALUES (NULL, ".intval($weight).", 0, '$url', '$image', '$title', '$description', $status)"; - if ($GLOBALS['xoopsSecurity']->check() && $xoopsDB->query($sql)) { - */ - redirect_header("main.php?op=default", 1, _AM_XPARTNERS_UPDATED); - } else { - redirect_header("main.php?op=default", 1, _AM_XPARTNERS_NOTUPDATED . "<br />" . implode('<br />', $GLOBALS['xoopsSecurity']->getErrors()) + case 'partnersAdminAdd': + echo $adminClass->addNavigation('main.php?op=partnersAdminAdd'); + //echo "<h4>"._AM_XPARTNERS_ADD."</h4>"; + + include $GLOBALS['xoops']->path('/class/xoopsformloader.php'); + $form = new XoopsThemeForm(_AM_XPARTNERS_ADDPARTNER, "addform", "main.php", "post", true); + $formWeight = new XoopsFormText(_AM_XPARTNERS_WEIGHT, "weight", 3, 10, XoopspartnersConstants::DEFAULT_WEIGHT); + $formImage = new XoopsFormText(_AM_XPARTNERS_IMAGE, "image", 100, 150, 'http://'); + $formUrl = new XoopsFormText(_AM_XPARTNERS_URL, "url", 100, 150, 'http://'); + $formTitle = new XoopsFormText(_AM_XPARTNERS_TITLE, "title", 100, 150); + $formDesc = new XoopsFormTextArea(_AM_XPARTNERS_DESCRIPTION, "description", "", 10, "60"); + $statOnTxt + = " <img src='{$pathImageIcon}/on.png' alt='" . _AM_XPARTNERS_ACTIVE . "' /> " . _AM_XPARTNERS_ACTIVE + . " "; + $statOffTxt + = " <img src='{$pathImageIcon}/off.png' alt='" . _AM_XPARTNERS_INACTIVE . "' /> " + . _AM_XPARTNERS_INACTIVE . " "; + $formStat = new XoopsFormRadioYN(_AM_XPARTNERS_STATUS, 'status', XoopspartnersConstants::STATUS_ACTIVE, $statOnTxt, $statOffTxt); + $opHidden = new XoopsFormHidden("op", "addPartner"); + $submitButton = new XoopsFormButton("", "submit", _AM_XPARTNERS_ADDPARTNER, "submit"); + $form->addElement($formTitle, true); + $form->addElement($formImage); + $form->addElement($formUrl, true); + $form->addElement($formWeight); + $form->addElement($formDesc, true); + $form->addElement($formStat); + $form->addElement($opHidden); + $form->addElement($submitButton); + $form->display(); + include __DIR__ . '/admin_footer.php'; + break; + + case 'addPartner': + $xpPartnerHandler =& xoops_getmodulehandler('partners', $GLOBALS['xoopsModule']->getVar('dirname')); + $newPartner = $xpPartnerHandler->create(); + $status = ((!empty($status)) && (intval($status) > 0)) ? intval($status) : XoopspartnersConstants::STATUS_INACTIVE; + $weight = XoopsRequest::getInt('weight', XoopspartnersConstants::DEFAULT_WEIGHT, 'POST'); + $title = isset($title) ? trim($title) : ''; + $url = isset($url) ? trim($url) : ''; + $image = isset($image) ? trim($image) : ''; + $image = $myts->addSlashes(formatURL($image)); + $description = isset($description) ? trim($description) : ''; + if (empty($title) || empty($url) || empty($description)) { + redirect_header('main.php', XoopspartnersConstants::REDIRECT_DELAY_MEDIUM, _AM_XPARTNERS_BESURE); + } + $newPartner->setVars(array('url' => $myts->addSlashes(formatURL($url)), + 'image' => $image, + 'title' => $myts->addSlashes($title), + 'description' => $myts->addSlashes($description), + 'status' => $status, + 'weight' => $weight) ); - } -} -function editPartner($id=0) -{ - global $xoopsModule, $indexAdmin, $pathImageIcon, $xoopsDB, $myts; + if ($GLOBALS['xoopsSecurity']->check() && $xpPartnerHandler->insert($newPartner)) { + redirect_header('main.php', XoopspartnersConstants::REDIRECT_DELAY_SHORT, _AM_XPARTNERS_UPDATED); + } else { + redirect_header('main.php', XoopspartnersConstants::REDIRECT_DELAY_MEDIUM, _AM_XPARTNERS_NOTUPDATED . "<br />" . implode('<br />', $GLOBALS['xoopsSecurity']->getErrors()) + ); + } + break; - echo $indexAdmin->addNavigation('main.php?op=default'); - $id = (intval($id) > 0) ? intval($id) : 0; + case 'editPartner': + echo $adminClass->addNavigation('main.php'); + $id = (intval($id) > XoopspartnersConstants::DEFAULT_PID) ? intval($id) : XoopspartnersConstants::DEFAULT_PID; - //echo "<h4>"._EDIT."</h4>"; - $partnerHandler =& xoops_getmodulehandler('partners', $xoopsModule->getVar('dirname')); - $partnerObj = $partnerHandler->get($id); - if (is_object($partnerObj) && count($partnerObj)) { - /* - $result = $xoopsDB->query("SELECT weight, hits, url, image, title, description, status FROM ".$xoopsDB->prefix("partners")." WHERE id={$id}"); - list($weight, $hits, $url, $image, $title, $description, $status) = $xoopsDB->fetchrow($result); - */ - $partnerVars = $partnerObj->getValues(); - $url = $myts->htmlSpecialChars($partnerVars['url']); - $image = $myts->htmlSpecialChars($partnerVars['image']); - $title = $myts->htmlSpecialChars($partnerVars['title']); - $description = $myts->htmlSpecialChars($partnerVars['description']); + $xpPartnerHandler =& xoops_getmodulehandler('partners', $GLOBALS['xoopsModule']->getVar('dirname')); + $partnerObj = $xpPartnerHandler->get($id); + if (!empty($partnerObj) && ($partnerObj instanceof XoopspartnersPartners)) { + $partnerVars = $partnerObj->getValues(); + //url, image, title, and description are all txtboxes so they have gone through htmlspecialchars via XoopsObject getVar - include XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; - $form = new XoopsThemeForm(_AM_XPARTNERS_EDITPARTNER, "editform", "main.php", "post", true); - $formweight = new XoopsFormText(_AM_XPARTNERS_WEIGHT, "weight", 3, 10, $partnerVars['weight']); - $formhits = new XoopsFormText(_AM_XPARTNERS_HITS, "hits", 3, 10, $partnerVars['hits']); - $formimage = new XoopsFormText(_AM_XPARTNERS_IMAGE, "image", 50, 150, $image); - $formurl = new XoopsFormText(_AM_XPARTNERS_URL, "url", 50, 150, $url); - $formtitle = new XoopsFormText(_AM_XPARTNERS_TITLE, "title", 50, 150, $title); - $formdesc = new XoopsFormTextArea(_AM_XPARTNERS_DESCRIPTION, "description", $description, 10, "100%"); - $statontxt = " <img src='{$pathImageIcon}/on.png' alt='" - . _AM_XPARTNERS_ACTIVE . "' /> " - . _AM_XPARTNERS_ACTIVE . " "; - $statofftxt = " <img src='{$pathImageIcon}/off.png' alt='" - . _AM_XPARTNERS_INACTIVE . "' /> " - . _AM_XPARTNERS_INACTIVE . " "; + include $GLOBALS['xoops']->path("/class/xoopsformloader.php"); + $form = new XoopsThemeForm(_AM_XPARTNERS_EDITPARTNER, 'editform', 'main.php', "post", true); + $formWeight = new XoopsFormText(_AM_XPARTNERS_WEIGHT, 'weight', 3, 10, $partnerVars['weight']); + $formHits = new XoopsFormText(_AM_XPARTNERS_HITS, 'hits', 3, 10, $partnerVars['hits']); + $formImage = new XoopsFormText(_AM_XPARTNERS_IMAGE, 'image', 50, 150, $partnerVars['image']); + $formUrl = new XoopsFormText(_AM_XPARTNERS_URL, 'url', 50, 150, $partnerVars['url']); + $formTitle = new XoopsFormText(_AM_XPARTNERS_TITLE, 'title', 50, 150, $partnerVars['title']); + $formDesc = new XoopsFormTextArea(_AM_XPARTNERS_DESCRIPTION, 'description', $partnerVars['description'], 10, '100%'); - $formstat = new XoopsFormRadioYN(_AM_XPARTNERS_STATUS, 'status', $partnerVars['status'], $statontxt, $statofftxt); - $submitButton = new XoopsFormButton("", "submit", _SUBMIT, "submit"); - $form->addElement($formtitle, true); - $form->addElement($formimage); - $form->addElement($formurl, true); - $form->addElement($formweight); - $form->addElement($formdesc, true); - $form->addElement($formhits); - $form->addElement($formstat); - $form->addElement(new XoopsFormHidden("id", $id)); - $form->addElement(new XoopsFormHidden("op", "updatePartner")); - $form->addElement($submitButton); - $form->display(); - include 'admin_footer.php'; - } else { - redirect_header("main.php?op=default", 2, _AM_XPARTNERS_INVALIDID); - } -} + $statOnTxt = " <img src='{$pathImageIcon}/on.png' alt='" . _AM_XPARTNERS_ACTIVE . "' /> " . _AM_XPARTNERS_ACTIVE . " "; + $statOffTxt = " <img src='{$pathImageIcon}/off.png' alt='" . _AM_XPARTNERS_INACTIVE . "' /> " . _AM_XPARTNERS_INACTIVE . " "; + $formStat = new XoopsFormRadioYN(_AM_XPARTNERS_STATUS, 'status', $partnerVars['status'], $statOnTxt, $statOffTxt); -function updatePartner($id, $weight, $hits, $url, $image, $title, $description, $status) -{ - global $xoopsModule, $xoopsDB, $myts; + $submitButton = new XoopsFormButton("", "submit", _SUBMIT, "submit"); + $form->addElement($formTitle, true); + $form->addElement($formImage); + $form->addElement($formUrl, true); + $form->addElement($formWeight); + $form->addElement($formDesc, true); + $form->addElement($formHits); + $form->addElement($formStat); + $form->addElement(new XoopsFormHidden("id", $id)); + $form->addElement(new XoopsFormHidden("op", "updatePartner")); + $form->addElement($submitButton); + $form->display(); + include __DIR__ . '/admin_footer.php'; + } else { + redirect_header("main.php", XoopspartnersConstants::REDIRECT_DELAY_MEDIUM, _AM_XPARTNERS_INVALIDID); + } + break; - $title = isset($title) ? trim($title) : ''; - $image = isset($image) ? trim($image) : ''; - $image = $myts->addSlashes(formatURL($image)); - $url = isset($url) ? trim($url) : ''; - $description = isset($description) ? trim($description) : ''; - $id = (isset($id) && intval($id) > 0) ? intval($id) : 0; - $status = isset($status) ? intval($status) : 0; - $weight = isset($weight) ? intval($weight) : 0; - $hits = (isset($hits) && intval($hits) > 0) ? intval($hits) : 0; - if ($title == '' || $url == '' || empty($id) || $description == '') { - redirect_header("main.php?op=edit_partner&id={$id}", 1, _AM_XPARTNERS_BESURE); - } - /* - if (!empty($image)) { - $image_info = exif_imagetype($image);; - if (false === $image_info) { - redirect_header("main.php?op=edit_partner&id={$id}", 1, _AM_XPARTNERS_NOEXIST); + case 'updatePartner': + $title = isset($title) ? trim($title) : ''; + $image = isset($image) ? trim($image) : ''; + $image = $myts->addSlashes(formatURL($image)); + $url = isset($url) ? trim($url) : ''; + $description = isset($description) ? trim($description) : ''; + $id = ($id > XoopspartnersConstants::DEFAULT_PID) ? $id : XoopspartnersConstants::DEFAULT_PID; + $status = ((!empty($status)) && ($status > XoopspartnersConstants::STATUS_INACTIVE)) ? intval($status) : XoopspartnersConstants::STATUS_INACTIVE; + $weight = XoopsRequest::getInt('weight', XoopspartnersConstants::DEFAULT_WEIGHT, 'POST'); + $weight = (($weight > XoopspartnersConstants::DEFAULT_WEIGHT)) ? $weight : XoopspartnersConstants::DEFAULT_WEIGHT; + $hits = ((!empty($hits)) && (intval($hits) > 0)) ? intval($hits) : 0; + if ($title == '' || $url == '' || empty($id) || $description == '') { + redirect_header("main.php?op=edit_partner&id={$id}", XoopspartnersConstants::REDIRECT_DELAY_SHORT, _AM_XPARTNERS_BESURE); + } + /* + if (!empty($image)) { + $image_info = exif_imagetype($image);; + if (false === $image_info) { + redirect_header("main.php?op=edit_partner&id={$id}", 1, _AM_XPARTNERS_NOEXIST); + } } + */ + $xpPartnerHandler =& xoops_getmodulehandler('partners', $GLOBALS['xoopsModule']->getVar('dirname')); + $partnerObj = $xpPartnerHandler->get($id); + if ($GLOBALS['xoopsSecurity']->check() && ($partnerObj instanceof XoopspartnersPartners)) { + $partnerObj->setVar('url', $myts->addSlashes(formatURL($url))); + $partnerObj->setVar('title', $myts->addSlashes($title)); + $partnerObj->setVar('description', $myts->addSlashes($description)); + $partnerObj->setVar('hits', $hits); + $partnerObj->setVar('weight', $weight); + $partnerObj->setVar('status', $status); + $partnerObj->setVar('image', $image); + $success = $xpPartnerHandler->insert($partnerObj); + if ($success) { + redirect_header("main.php", XoopspartnersConstants::REDIRECT_DELAY_SHORT, _AM_XPARTNERS_UPDATED); + } } - */ - $partnerHandler =& xoops_getmodulehandler('partners', $xoopsModule->getVar('dirname')); - $partnerObj = $partnerHandler->get($id); - if ($GLOBALS['xoopsSecurity']->check() && is_object($partnerObj) && count($partnerObj)) { - $partnerObj->setVar('url', $myts->addSlashes(formatURL($url))); - $partnerObj->setVar('title', $myts->addSlashes($title)); - $partnerObj->setVar('description', $myts->addSlashes($description)); - $partnerObj->setVar('hits', $hits); - $partnerObj->setVar('weight', $weight); - $partnerObj->setVar('status', $status); - $partnerObj->setVar('image', $image); - $success = $partnerHandler->insert($partnerObj); - if ($success) { - redirect_header("main.php?op=default", 1, _AM_XPARTNERS_UPDATED); - } - } - redirect_header("main.php?op=default", 1, _AM_XPARTNERS_NOTUPDATED . "<br />" . implode('<br />', $GLOBALS['xoopsSecurity']->getErrors())); -} + redirect_header("main.php", XoopspartnersConstants::REDIRECT_DELAY_MEDIUM, _AM_XPARTNERS_NOTUPDATED . "<br />" . implode('<br />', $GLOBALS['xoopsSecurity']->getErrors())); + break; -function delPartner($id, $del = 0) -{ - global $xoopsModule, $indexAdmin, $xoopsDB; - $id = (isset($id) && intval($id)) ? intval($id) : 0; - if ((1 == $del) && ($id > 0)) { - $partnerHandler =& xoops_getmodulehandler('partners', $xoopsModule->getVar('dirname')); - $partnerObj = $partnerHandler->get($id); - if (is_object($partnerObj) && count($partnerObj)) { - if ($partnerHandler->delete($partnerObj)) { - redirect_header("main.php?op=default", 1, _AM_XPARTNERS_UPDATED); + case 'delPartner': + if ((XoopspartnersConstants::CONFIRM_OK == $del) && ($id > XoopspartnersConstants::DEFAULT_PID)) { + $xpPartnerHandler =& xoops_getmodulehandler('partners', $GLOBALS['xoopsModule']->getVar('dirname')); + $partnerObj = $xpPartnerHandler->get($id); + if ($partnerObj instanceof XoopspartnersPartners) { + if ($xpPartnerHandler->delete($partnerObj)) { + redirect_header('main.php', XoopspartnersConstants::REDIRECT_DELAY_SHORT, _AM_XPARTNERS_UPDATED); + } } + redirect_header('main.php', XoopspartnersConstants::REDIRECT_DELAY_MEDIUM, _AM_XPARTNERS_NOTUPDATED); + } else { + echo $adminClass->addNavigation('main.php'); + xoops_confirm(array('op' => 'delPartner', 'id' => intval($id), 'del' => XoopspartnersConstants::CONFIRM_OK), 'main.php', _AM_XPARTNERS_SUREDELETE); + include __DIR__ . '/admin_footer.php'; } - redirect_header("main.php?op=default", 1, _AM_XPARTNERS_NOTUPDATED); - } else { - echo $indexAdmin->addNavigation('main.php?op=default'); - xoops_confirm(array('op' => 'delPartner', 'id' => intval($id), 'del' => 1), 'main.php', _AM_XPARTNERS_SUREDELETE); - include 'admin_footer.php'; - } + break; } - -$op = ''; - -$fields = array('op', 'id', 'weight', 'hits', 'url', 'image', 'tit... [truncated message content] |