|
From: <be...@us...> - 2014-11-22 04:11:25
|
Revision: 12863
http://sourceforge.net/p/xoops/svn/12863
Author: beckmi
Date: 2014-11-22 04:11:17 +0000 (Sat, 22 Nov 2014)
Log Message:
-----------
replacing dirname(__FILE__), replacing WfdownloadsRequest with XoopsRequest
Modified Paths:
--------------
XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/about.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/admin_header.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/categories.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/clone.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/downloads.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/images.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/import.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/index.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/indexpage.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/menu.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/mimetypes.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/mirrors.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/permissions.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/ratings.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/reportsmodifications.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/reviews.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/blocks/top.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/blocks/top_by_cat.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/brokenfile.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/class/breadcrumb.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/class/category.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/class/dbupdater.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/class/download.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/class/img_uploader.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/class/ip_log.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/class/mimetype.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/class/mirror.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/class/modification.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/class/rating.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/class/report.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/class/review.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/class/session.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/class/wfdownloads.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/class/wfdownloads_lists.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/class/xoopstree.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/comment_delete.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/comment_edit.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/comment_new.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/comment_post.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/comment_reply.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/docs/changelog.txt
XoopsModules/wfdownloads/branches/mamba/wfdownloads/header.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/include/comment_functions.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/include/common.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/include/constants.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/include/directorychecker.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/include/filechecker.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/include/functions.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/include/notification.inc.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/include/search.inc.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/index.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/language/english/admin.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/language/english/help/tips_tricks.html
XoopsModules/wfdownloads/branches/mamba/wfdownloads/language/english/main.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/language/english/modinfo.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/mirror.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/newlist.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/notification_update.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/ratefile.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/review.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/rss.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/singlefile.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/sql/mysql.sql
XoopsModules/wfdownloads/branches/mamba/wfdownloads/submit.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/wfdownloads_download.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/wfdownloads_newlistindex.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/wfdownloads_singlefile.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/topten.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/viewcat.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/visit.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/xoops_version.php
Added Paths:
-----------
XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/swishe.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/assets/images/module_logo_blank.png
XoopsModules/wfdownloads/branches/mamba/wfdownloads/include/oninstall.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/include/onuninstall.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/include/onupdate.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/admin/wfdownloads_am_categorieslist.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/admin/wfdownloads_am_downloadslist.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/admin/wfdownloads_am_ip_logslist.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/admin/wfdownloads_am_mimetypeslist.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/admin/wfdownloads_am_mirrorslist.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/admin/wfdownloads_am_permissions.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/admin/wfdownloads_am_ratingslist.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/admin/wfdownloads_am_reportsmodificationslist.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/admin/wfdownloads_am_reviewslist.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/blocks/wfdownloads_mb_new.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/blocks/wfdownloads_mb_top.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/blocks/wfdownloads_mb_top_by_cat.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/wfdownloads_co_breadcrumb.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/wfdownloads_co_letterschoice.tpl
Removed Paths:
-------------
XoopsModules/wfdownloads/branches/mamba/wfdownloads/class/object.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/class/request.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/include/module.php
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/admin/wfdownloads_admin_categorieslist.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/admin/wfdownloads_admin_downloadslist.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/admin/wfdownloads_admin_ip_logslist.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/admin/wfdownloads_admin_mimetypeslist.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/admin/wfdownloads_admin_mirrorslist.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/admin/wfdownloads_admin_permissions.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/admin/wfdownloads_admin_ratingslist.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/admin/wfdownloads_admin_reportsmodificationslist.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/admin/wfdownloads_admin_reviewslist.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/blocks/wfdownloads_block_new.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/blocks/wfdownloads_block_top.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/blocks/wfdownloads_block_top_by_cat.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/wfdownloads_common_breadcrumb.tpl
XoopsModules/wfdownloads/branches/mamba/wfdownloads/templates/wfdownloads_common_letterschoice.tpl
Modified: XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/about.php
===================================================================
--- XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/about.php 2014-11-20 16:30:07 UTC (rev 12862)
+++ XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/about.php 2014-11-22 04:11:17 UTC (rev 12863)
@@ -18,7 +18,7 @@
* @author Xoops Development Team
* @version svn:$id$
*/
-include_once dirname(__FILE__) . '/admin_header.php';
+include_once __DIR__ . '/admin_header.php';
xoops_cp_header();
@@ -27,4 +27,4 @@
echo $aboutAdmin->addNavigation('about.php');
echo $aboutAdmin->renderAbout('6KJ7RW5DR3VTJ', false);
-include 'admin_footer.php';
+include_once __DIR__ . '/admin_footer.php';
Modified: XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/admin_header.php
===================================================================
--- XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/admin_header.php 2014-11-20 16:30:07 UTC (rev 12862)
+++ XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/admin_header.php 2014-11-22 04:11:17 UTC (rev 12863)
@@ -18,8 +18,8 @@
* @author Xoops Development Team
* @version svn:$id$
*/
-include_once dirname(dirname(dirname(dirname(__FILE__)))) . '/mainfile.php';
-include_once dirname(dirname(__FILE__)) . '/include/common.php';
+include_once dirname(dirname(dirname(__DIR__))) . '/mainfile.php';
+include_once dirname(__DIR__) . '/include/common.php';
// Include xoops admin header
include_once XOOPS_ROOT_PATH . '/include/cp_header.php';
@@ -35,6 +35,6 @@
xoops_loadLanguage('main', $wfdownloads->getModule()->dirname());
if (!isset($xoopsTpl) || !is_object($xoopsTpl)) {
- include_once(XOOPS_ROOT_PATH . '/class/template.php');
+ include_once XOOPS_ROOT_PATH . '/class/template.php';
$xoopsTpl = new XoopsTpl();
}
Modified: XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/categories.php
===================================================================
--- XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/categories.php 2014-11-20 16:30:07 UTC (rev 12862)
+++ XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/categories.php 2014-11-22 04:11:17 UTC (rev 12863)
@@ -19,47 +19,65 @@
* @version svn:$id$
*/
$currentFile = basename(__FILE__);
-include_once dirname(__FILE__) . '/admin_header.php';
+include_once __DIR__ . '/admin_header.php';
-$op = WfdownloadsRequest::getString('op', 'categories.list');
+// Check directories
+if (!is_dir($wfdownloads->getConfig('uploaddir'))) {
+ redirect_header('index.php', 4, _AM_WFDOWNLOADS_ERROR_UPLOADDIRNOTEXISTS);
+ exit();
+}
+if (!is_dir(XOOPS_ROOT_PATH . '/' . $wfdownloads->getConfig('mainimagedir'))) {
+ redirect_header('index.php', 4, _AM_WFDOWNLOADS_ERROR_MAINIMAGEDIRNOTEXISTS);
+ exit();
+}
+if (!is_dir(XOOPS_ROOT_PATH . '/' . $wfdownloads->getConfig('screenshots'))) {
+ redirect_header('index.php', 4, _AM_WFDOWNLOADS_ERROR_SCREENSHOTSDIRNOTEXISTS);
+ exit();
+}
+if (!is_dir(XOOPS_ROOT_PATH . '/' . $wfdownloads->getConfig('catimage'))) {
+ redirect_header('index.php', 4, _AM_WFDOWNLOADS_ERROR_CATIMAGEDIRNOTEXISTS);
+ exit();
+}
+
+$op = XoopsRequest::getString('op', 'categories.list');
switch ($op) {
- case "category.move":
- case "move":
- $ok = WfdownloadsRequest::getBool('ok', false, 'POST');
+ case 'category.move':
+ case 'move':
+ $ok = XoopsRequest::getBool('ok', false, 'POST');
if ($ok == false) {
- $cid = WfdownloadsRequest::getInt('cid', 0);
+ $cid = XoopsRequest::getInt('cid', 0);
wfdownloads_xoops_cp_header();
include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
- $sform = new XoopsThemeForm(_AM_WFDOWNLOADS_CCATEGORY_MOVE, "move", xoops_getenv('PHP_SELF'));
+ $sform = new XoopsThemeForm(_AM_WFDOWNLOADS_CCATEGORY_MOVE, 'move', xoops_getenv('PHP_SELF'));
- $categories = $wfdownloads->getHandler('category')->getObjects();
- $mytree = new XoopsObjectTree($categories, "cid", "pid");
- $sform->addElement(new XoopsFormLabel(_AM_WFDOWNLOADS_BMODIFY, $mytree->makeSelBox('target', 'title')));
+ $categoryObjs = $wfdownloads->getHandler('category')->getObjects();
+ $categoryObjsTree = new XoopsObjectTree($categoryObjs, 'cid', 'pid');
+ $sform->addElement(new XoopsFormLabel(_AM_WFDOWNLOADS_BMODIFY, $categoryObjsTree->makeSelBox('target', 'title')));
$create_tray = new XoopsFormElementTray('', '');
- $create_tray -> addElement(new XoopsFormHidden('source', $cid));
- $create_tray -> addElement(new XoopsFormHidden('ok', true));
- $create_tray -> addElement(new XoopsFormHidden('op', 'category.move'));
+ $create_tray->addElement(new XoopsFormHidden('source', $cid));
+ $create_tray->addElement(new XoopsFormHidden('ok', true));
+ $create_tray->addElement(new XoopsFormHidden('op', 'category.move'));
$butt_save = new XoopsFormButton('', '', _AM_WFDOWNLOADS_BMOVE, 'submit');
- $butt_save -> setExtra('onclick="this.form.elements.op.value=\'category.move\'"');
- $create_tray -> addElement($butt_save);
+ $butt_save->setExtra('onclick="this.form.elements.op.value=\'category.move\'"');
+ $create_tray->addElement($butt_save);
$butt_cancel = new XoopsFormButton('', '', _AM_WFDOWNLOADS_BCANCEL, 'submit');
- $butt_cancel -> setExtra('onclick="this.form.elements.op.value=\'cancel\'"');
+ $butt_cancel->setExtra('onclick="this.form.elements.op.value=\'cancel\'"');
$create_tray -> addElement($butt_cancel);
- $sform -> addElement($create_tray);
- $sform -> display();
+ $sform->addElement($create_tray);
+ $sform->display();
xoops_cp_footer();
} else {
- $source = WfdownloadsRequest::getInt('source', 0, 'POST');
- $target = WfdownloadsRequest::getInt('target', 0, 'POST');
+ $source = XoopsRequest::getInt('source', 0, 'POST');
+ $target = XoopsRequest::getInt('target', 0, 'POST');
if ($target == $source) {
redirect_header($currentFile . "?op=category.move&ok=0&cid={$source}", 5, _AM_WFDOWNLOADS_CCATEGORY_MODIFY_FAILED);
}
if (!$target) {
redirect_header($currentFile . "?op=category.move&ok=0&cid={$source}", 5, _AM_WFDOWNLOADS_CCATEGORY_MODIFY_FAILEDT);
}
- $result = $wfdownloads->getHandler('download')->updateAll("cid", $target, new Criteria("cid", $source), true);
+ $result = $wfdownloads->getHandler('download')->updateAll('cid', $target, new Criteria('cid', $source), true);
if (!$result) {
$error = _AM_WFDOWNLOADS_DBERROR;
trigger_error($error, E_USER_ERROR);
@@ -69,74 +87,73 @@
}
break;
- case "category.save" :
- case "addCat" :
- $cid = WfdownloadsRequest::getInt('cid', 0, 'POST');
- $pid = WfdownloadsRequest::getInt('pid', 0, 'POST');
- $weight = (isset($_POST["weight"]) && $_POST["weight"] > 0) ? (int) $_POST["weight"] : 0;
+ case 'category.save':
+ case 'addCat':
+ $cid = XoopsRequest::getInt('cid', 0, 'POST');
+ $pid = XoopsRequest::getInt('pid', 0, 'POST');
+ $weight = (isset($_POST['weight']) && $_POST['weight'] > 0) ? (int) $_POST["weight"] : 0;
$down_groups = isset($_POST['groups']) ? $_POST['groups'] : array();
$up_groups = isset($_POST['up_groups']) ? $_POST['up_groups'] : array();
- $spotlighthis = (isset($_POST["lid"])) ? (int) $_POST["lid"] : 0;
- $spotlighttop = (isset($_POST["spotlighttop"]) && ($_POST["spotlighttop"] == 1)) ? 1 : 0;
+ $spotlighthis = (isset($_POST['lid'])) ? (int) $_POST['lid'] : 0;
+ $spotlighttop = (isset($_POST['spotlighttop']) && ($_POST['spotlighttop'] == 1)) ? 1 : 0;
- include_once XOOPS_ROOT_PATH.'/class/uploader.php';
+ include_once XOOPS_ROOT_PATH . '/class/uploader.php';
$allowedMimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png');
- $maxFileSize = $wfdownloads->getConfig('maxfilesize');
- $maxImgWidth = $wfdownloads->getConfig('maximgwidth');
- $maxImgHeight = $wfdownloads->getConfig('maximgheight');
- $uploadDirectory = XOOPS_ROOT_PATH . '/' . $wfdownloads->getConfig('catimage');
+ $imgurl = 'blank.png';
+ $maxFileSize = $wfdownloads->getConfig('maxfilesize');
+ $maxImgWidth = $wfdownloads->getConfig('maximgwidth');
+ $maxImgHeight = $wfdownloads->getConfig('maximgheight');
+ $uploadDirectory = XOOPS_ROOT_PATH . '/' . $wfdownloads->getConfig('catimage');
$uploader = new XoopsMediaUploader($uploadDirectory, $allowedMimetypes, $maxFileSize, $maxImgWidth, $maxImgHeight);
if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
$uploader->setTargetFileName('wfdownloads_' . uniqid(time()) . '--' . strtolower($_FILES['uploadfile']['name']));
$uploader->fetchMedia($_POST['xoops_upload_file'][0]);
if (!$uploader->upload()) {
$errors = $uploader->getErrors();
- redirect_header("javascript:history.go(-1)",3, $errors);
+ redirect_header('javascript:history.go(-1)',3, $errors);
} else {
$imgurl = $uploader->getSavedFileName();
}
} else {
- $imgurl = (isset($_POST["imgurl"]) && $_POST["imgurl"] != "blank.png") ? $myts -> addslashes($_POST["imgurl"]) : "";
+ $imgurl = (isset($_POST['imgurl']) && $_POST['imgurl'] != 'blank.png') ? $myts -> addslashes($_POST['imgurl']) : '';
}
- // Formulize module support (2006/05/04) jpc
- if (wfdownloads_checkModule('formulize')) {
- $formulize_fid = (isset($_POST["formulize_fid"])) ? (int) $_POST["formulize_fid"] : 0;
- }
if (!$cid) {
- $category = $wfdownloads->getHandler('category')->create();
+ $categoryObj = $wfdownloads->getHandler('category')->create();
} else {
- $category = $wfdownloads->getHandler('category')->get($cid);
- $childcats = $wfdownloads->getHandler('category')->getChildCats($category);
+ $categoryObj = $wfdownloads->getHandler('category')->get($cid);
+ $childcats = $wfdownloads->getHandler('category')->getChildCats($categoryObj);
if ($pid == $cid || in_array($pid, array_keys($childcats))) {
- $category->setErrors(_AM_WFDOWNLOADS_CCATEGORY_CHILDASPARENT);
+ $categoryObj->setErrors(_AM_WFDOWNLOADS_CCATEGORY_CHILDASPARENT);
}
}
- $category->setVar('title', $_POST["title"]);
- $category->setVar('pid', $pid);
- $category->setVar('weight', $weight);
- $category->setVar('imgurl', $imgurl);
- $category->setVar('description', $_POST["description"]);
- $category->setVar('summary', $_POST["summary"]);
- $category->setVar('dohtml', isset($_POST['dohtml']));
- $category->setVar('dosmiley', isset($_POST['dosmiley']));
- $category->setVar('doxcode', isset($_POST['doxcode']));
- $category->setVar('doimage', isset($_POST['doimage']));
- $category->setVar('dobr', isset($_POST['dobr']));
- // Formulize module support (2006/05/04) jpc
+ $categoryObj->setVar('title', $_POST['title']);
+ $categoryObj->setVar('pid', $pid);
+ $categoryObj->setVar('weight', $weight);
+ $categoryObj->setVar('imgurl', $imgurl);
+ $categoryObj->setVar('description', $_POST['description']);
+ $categoryObj->setVar('summary', $_POST['summary']);
+ $categoryObj->setVar('dohtml', isset($_POST['dohtml']));
+ $categoryObj->setVar('dosmiley', isset($_POST['dosmiley']));
+ $categoryObj->setVar('doxcode', isset($_POST['doxcode']));
+ $categoryObj->setVar('doimage', isset($_POST['doimage']));
+ $categoryObj->setVar('dobr', isset($_POST['dobr']));
+// Formulize module support (2006/05/04) jpc - start
if (wfdownloads_checkModule('formulize')) {
- $category->setVar('formulize_fid', $formulize_fid);
+ $formulize_fid = (isset($_POST['formulize_fid'])) ? (int) $_POST['formulize_fid'] : 0;
+ $categoryObj->setVar('formulize_fid', $formulize_fid);
}
- $category->setVar('spotlighthis', $spotlighthis);
- $category->setVar('spotlighttop', $spotlighttop);
+// Formulize module support (2006/05/04) jpc - end
+ $categoryObj->setVar('spotlighthis', $spotlighthis);
+ $categoryObj->setVar('spotlighttop', $spotlighttop);
- if (!$wfdownloads->getHandler('category')->insert($category)) {
- echo $category->getHtmlErrors();
+ if (!$wfdownloads->getHandler('category')->insert($categoryObj)) {
+ echo $categoryObj->getHtmlErrors();
}
if (!$cid) {
if ($cid == 0) {
- $newid = (int) $category->getVar('cid');
+ $newid = (int) $categoryObj->getVar('cid');
}
wfdownloads_savePermissions($down_groups, $newid, 'WFDownCatPerm');
wfdownloads_savePermissions($up_groups, $newid, 'WFUpCatPerm');
@@ -144,8 +161,8 @@
$tags = array();
$tags['CATEGORY_NAME'] = $_POST['title'];
$tags['CATEGORY_URL'] = WFDOWNLOADS_URL . '/viewcat.php?cid=' . $newid;
- $notification_handler = & xoops_gethandler('notification');
- $notification_handler -> triggerEvent('global', 0, 'new_category', $tags);
+ $notification_handler = xoops_gethandler('notification');
+ $notification_handler->triggerEvent('global', 0, 'new_category', $tags);
$database_mess = _AM_WFDOWNLOADS_CCATEGORY_CREATED;
} else {
$database_mess = _AM_WFDOWNLOADS_CCATEGORY_MODIFIED;
@@ -155,27 +172,27 @@
redirect_header($currentFile, 1, $database_mess);
break;
- case "category.delete" :
- case "del" :
- $cid = WfdownloadsRequest::getInt('cid', 0);
- $ok = WfdownloadsRequest::getBool('ok', false, 'POST');
- $categories = $wfdownloads->getHandler('category')->getObjects();
- $mytree = new XoopsObjectTree($categories, "cid", "pid");
+ case 'category.delete':
+ case 'del':
+ $cid = XoopsRequest::getInt('cid', 0);
+ $ok = XoopsRequest::getBool('ok', false, 'POST');
+ $categoryObjs = $wfdownloads->getHandler('category')->getObjects();
+ $categoryObjsTree = new XoopsObjectTree($categoryObjs, 'cid', 'pid');
if ($ok == true) {
// get all subcategories under the specified category
- $arr = $mytree -> getAllChild($cid);
- foreach ($arr as $child) {
+ $childCategoryObjs = $categoryObjsTree->getAllChild($cid);
+ foreach ($childCategoryObjs as $childCategoryObj) {
// get all category ids
- $cids[] = $child->getVar('cid');
+ $cids[] = $childCategoryObj->getVar('cid');
}
$cids[] = $cid;
- $criteria = new Criteria("cid", "(" . implode(',', $cids) . ")", "IN");
+ $criteria = new Criteria('cid', '(' . implode(',', $cids) . ')', 'IN');
//get list of downloads in these subcategories
$downloads = $wfdownloads->getHandler('download')->getList($criteria);
- $download_criteria = new Criteria("lid", "(" . implode(',', array_keys($downloads)) . ")", "IN");
+ $download_criteria = new Criteria('lid', '(' . implode(',', array_keys($downloads)) . ')', 'IN');
// now for each download, delete the text data and vote data associated with the download
$wfdownloads->getHandler('rating')->deleteAll($download_criteria);
@@ -203,9 +220,9 @@
}
break;
- case "category.add" :
- case "category.edit" :
- case "modCat":
+ case 'category.add':
+ case 'category.edit':
+ case 'modCat':
wfdownloads_xoops_cp_header();
$indexAdmin = new ModuleAdmin();
echo $indexAdmin->addNavigation($currentFile);
@@ -215,19 +232,19 @@
echo $adminMenu->renderButton();
if (isset($_REQUEST['cid'])) {
- $category = $wfdownloads->getHandler('category')->get($_REQUEST['cid']);
+ $categoryObj = $wfdownloads->getHandler('category')->get($_REQUEST['cid']);
} else {
- $category = $wfdownloads->getHandler('category')->create();
+ $categoryObj = $wfdownloads->getHandler('category')->create();
}
- $form = $category->getForm();
+ $form = $categoryObj->getForm();
$form -> display();
- include 'admin_footer.php';
+ include_once __DIR__ . '/admin_footer.php';
break;
- case 'categories.list' :
- case 'main' :
- default :
+ case 'categories.list':
+ case 'main':
+ default:
wfdownloads_xoops_cp_header();
$indexAdmin = new ModuleAdmin();
echo $indexAdmin->addNavigation($currentFile);
@@ -241,14 +258,14 @@
$sorted_categories = wfdownloads_sortCategories();
$GLOBALS['xoopsTpl']->assign('sorted_categories', $sorted_categories);
$GLOBALS['xoopsTpl']->assign('token', $GLOBALS['xoopsSecurity']->getTokenHTML() );
- $GLOBALS['xoopsTpl']->display("db:{$wfdownloads->getModule()->dirname()}_admin_categorieslist.tpl");
+ $GLOBALS['xoopsTpl']->display("db:{$wfdownloads->getModule()->dirname()}_am_categorieslist.tpl");
} else {
redirect_header("{$currentFile}?op=category.add", 1, _AM_WFDOWNLOADS_CCATEGORY_NOEXISTS);
}
- include 'admin_footer.php';
+ include_once __DIR__ . '/admin_footer.php';
break;
- case 'categories.reorder' :
+ case 'categories.reorder':
if (!$GLOBALS['xoopsSecurity']->check()) {
redirect_header($currentFile, 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors() ));
}
@@ -257,12 +274,12 @@
$new_weights = $_POST['new_weights'];
$ids = array();
foreach ($new_weights as $cid => $new_weight) {
- $category = $wfdownloads->getHandler('category')->get($cid);
- $category->setVar('weight', $new_weight);
- if (!$wfdownloads->getHandler('category')->insert($category)) {
- redirect_header($currentFile, 3, $category->getErrors());
+ $categoryObj = $wfdownloads->getHandler('category')->get($cid);
+ $categoryObj->setVar('weight', $new_weight);
+ if (!$wfdownloads->getHandler('category')->insert($categoryObj)) {
+ redirect_header($currentFile, 3, $categoryObj->getErrors());
}
- unset($category);
+ unset($categoryObj);
}
redirect_header($currentFile, 1, _AM_WFDOWNLOADS_CATEGORIES_REORDERED);
exit();
Modified: XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/clone.php
===================================================================
--- XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/clone.php 2014-11-20 16:30:07 UTC (rev 12862)
+++ XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/clone.php 2014-11-22 04:11:17 UTC (rev 12863)
@@ -19,7 +19,7 @@
* @version svn:$id$
*/
$currentFile = basename(__FILE__);
-include_once dirname(__FILE__) . '/admin_header.php';
+include_once __DIR__ . '/admin_header.php';
if (@$_POST['op'] == 'submit') {
if (!$GLOBALS['xoopsSecurity']->check()) {
@@ -38,10 +38,14 @@
if ($cloneDirname && is_dir(XOOPS_ROOT_PATH . '/modules/' . $cloneDirname)) {
redirect_header($currentFile, 3, sprintf(_AM_WFDOWNLOADS_CLONE_EXISTS, $cloneDirname));
}
+ // Check dirname length for template file name length issues (template file name cannot be longer than 50 chars)
+ if (strlen($cloneDirname) > 18) {
+ redirect_header($currentFile, 3, sprintf(_AM_WFDOWNLOADS_CLONE_TOOLONG, $cloneDirname));
+ }
$patterns = array(
- strtolower(WFDOWNLOADS_DIRNAME) => strtolower($cloneDirname),
- strtoupper(WFDOWNLOADS_DIRNAME) => strtoupper($cloneDirname),
+ strtolower(WFDOWNLOADS_DIRNAME) => strtolower($cloneDirname),
+ strtoupper(WFDOWNLOADS_DIRNAME) => strtoupper($cloneDirname),
ucfirst(strtolower(WFDOWNLOADS_DIRNAME)) => ucfirst(strtolower($cloneDirname))
);
@@ -50,7 +54,7 @@
wfdownloads_cloneFileDir(WFDOWNLOADS_ROOT_PATH);
$logocreated = wfdownloads_createLogo(strtolower($cloneDirname));
- $message = "";
+ $message = '';
if (is_dir(XOOPS_ROOT_PATH . '/modules/' . strtolower($cloneDirname))) {
$message .= sprintf(
_AM_WFDOWNLOADS_CLONE_CONGRAT,
@@ -67,7 +71,7 @@
$indexAdmin = new ModuleAdmin();
echo $indexAdmin->addNavigation($currentFile);
echo $message;
- include 'admin_footer.php';
+ include_once __DIR__ . '/admin_footer.php';
exit();
} else {
@@ -75,17 +79,14 @@
$indexAdmin = new ModuleAdmin();
echo $indexAdmin->addNavigation($currentFile);
include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
- $form = new XoopsThemeForm(sprintf(
- _AM_WFDOWNLOADS_CLONE_TITLE,
- $wfdownloads->getModule()->getVar('name', 'E')
- ), 'clone', $currentFile, 'post', true);
- $cloneDirname_text = new XoopsFormText(_AM_WFDOWNLOADS_CLONE_NAME, 'clonedirname', 20, 20, '');
+ $form = new XoopsThemeForm(sprintf(_AM_WFDOWNLOADS_CLONE_TITLE, $wfdownloads->getModule()->getVar('name', 'E')), 'clone', $currentFile, 'post', true);
+ $cloneDirname_text = new XoopsFormText(_AM_WFDOWNLOADS_CLONE_NAME, 'clonedirname', 18, 18, '');
$cloneDirname_text->setDescription(_AM_WFDOWNLOADS_CLONE_NAME_DSC);
$form->addElement($cloneDirname_text, true);
$form->addElement(new XoopsFormHidden('op', 'submit'));
$form->addElement(new XoopsFormButton('', '', _SUBMIT, 'submit'));
$form->display();
- include 'admin_footer.php';
+ include_once __DIR__ . '/admin_footer.php';
exit();
}
@@ -134,16 +135,16 @@
{
$wfdownloads = WfdownloadsWfdownloads::getInstance();
// Check extension/functions
- if (!extension_loaded("gd")) {
+ if (!extension_loaded('gd')) {
return false;
} else {
$required_functions = array(
- "imagecreatetruecolor",
- "imagecolorallocate",
- "imagefilledrectangle",
- "imagejpeg",
- "imagedestroy",
- "imageftbbox"
+ 'imagecreatetruecolor',
+ 'imagecolorallocate',
+ 'imagefilledrectangle',
+ 'imagejpeg',
+ 'imagedestroy',
+ 'imageftbbox'
);
foreach ($required_functions as $func) {
if (!function_exists($func)) {
@@ -152,10 +153,10 @@
}
}
// Check original image/font
- if (!file_exists($imageBase = XOOPS_ROOT_PATH . "/modules/" . $dirname . "/assets/images/module_logo.png")) {
+ if (!file_exists($imageBase = XOOPS_ROOT_PATH . "/modules/{$dirname}/assets/images/module_logo_blank.png")) {
return false;
}
- if (!file_exists($font = XOOPS_ROOT_PATH . "/modules/" . $wfdownloads->getModule()->dirname() . "/assets/images/VeraBd.ttf")) {
+ if (!file_exists($font = XOOPS_ROOT_PATH . "/modules/{$wfdownloads->getModule()->dirname()}/assets/images/VeraBd.ttf")) {
return false;
}
// Create image
@@ -164,7 +165,7 @@
$greyColor = imagecolorallocate($imageModule, 237, 237, 237);
imagefilledrectangle($imageModule, 5, 35, 85, 46, $greyColor);
// Write text
- $textColor = imagecolorallocate($imageModule, 0, 0, 0);
+ $textColor = imagecolorallocate($imageModule, 0, 0, 0);
$space_to_border = (80 - strlen($dirname) * 6.5) / 2;
imagefttext($imageModule, 8.5, 0, $space_to_border, 45, $textColor, $font, ucfirst($dirname), array());
// Set transparency color
@@ -172,7 +173,7 @@
imagefill($imageModule, 0, 0, $whiteColor);
imagecolortransparent($imageModule, $whiteColor);
// Save new image
- imagepng($imageModule, XOOPS_ROOT_PATH . "/modules/" . $dirname . "/assets/images/module_logo.png");
+ imagepng($imageModule, XOOPS_ROOT_PATH . "/modules/{$dirname}/assets/images/module_logo.png");
imagedestroy($imageModule);
return true;
Modified: XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/downloads.php
===================================================================
--- XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/downloads.php 2014-11-20 16:30:07 UTC (rev 12862)
+++ XoopsModules/wfdownloads/branches/mamba/wfdownloads/admin/downloads.php 2014-11-22 04:11:17 UTC (rev 12863)
@@ -19,18 +19,31 @@
* @version svn:$id$
*/
$currentFile = basename(__FILE__);
-include_once dirname(__FILE__) . '/admin_header.php';
+include_once __DIR__ . '/admin_header.php';
+// Check directories
if (!is_dir($wfdownloads->getConfig('uploaddir'))) {
redirect_header('index.php', 4, _AM_WFDOWNLOADS_ERROR_UPLOADDIRNOTEXISTS);
exit();
}
+if (!is_dir(XOOPS_ROOT_PATH . '/' . $wfdownloads->getConfig('mainimagedir'))) {
+ redirect_header('index.php', 4, _AM_WFDOWNLOADS_ERROR_MAINIMAGEDIRNOTEXISTS);
+ exit();
+}
+if (!is_dir(XOOPS_ROOT_PATH . '/' . $wfdownloads->getConfig('screenshots'))) {
+ redirect_header('index.php', 4, _AM_WFDOWNLOADS_ERROR_SCREENSHOTSDIRNOTEXISTS);
+ exit();
+}
+if (!is_dir(XOOPS_ROOT_PATH . '/' . $wfdownloads->getConfig('catimage'))) {
+ redirect_header('index.php', 4, _AM_WFDOWNLOADS_ERROR_CATIMAGEDIRNOTEXISTS);
+ exit();
+}
-$op = WfdownloadsRequest::getString('op', 'downloads.list');
+$op = XoopsRequest::getString('op', 'downloads.list');
switch ($op) {
- case "download.edit" :
- case "download.add" :
- case "Download" :
+ case 'download.edit':
+ case 'download.add':
+ case 'Download':
wfdownloads_xoops_cp_header();
$indexAdmin = new ModuleAdmin();
echo $indexAdmin->addNavigation($currentFile);
@@ -39,74 +52,88 @@
$adminMenu->addItemButton(_MI_WFDOWNLOADS_MENU_DOWNLOADS, "{$currentFile}?op=downloads.list", 'list');
echo $adminMenu->renderButton();
- $lid = WfdownloadsRequest::getInt('lid', 0);
+ $lid = XoopsRequest::getInt('lid', 0);
- $category_count = $wfdownloads->getHandler('category')->getCount();
- if ($category_count) {
+ $categoriesCount = $wfdownloads->getHandler('category')->getCount();
+ if ($categoriesCount) {
// Allowed mimetypes list
echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_WFDOWNLOADS_FILE_ALLOWEDAMIME . "</legend>\n";
echo "<div style='padding: 8px;'>\n";
- $criteria = new Criteria("mime_admin", true);
- $mimetypes = $wfdownloads->getHandler('mimetype')->getList($criteria);
+ $criteria = new Criteria("mime_admin", true);
+ $mimetypes = $wfdownloads->getHandler('mimetype')->getList($criteria);
$allowMimetypes = implode(' | ', $mimetypes);
echo $allowMimetypes;
echo "</div>\n";
echo "</fieldset><br />\n";
if ($lid) {
- if (!$download = $wfdownloads->getHandler('download')->get($lid)) {
+ // edit download
+ if (!$downloadObj = $wfdownloads->getHandler('download')->get($lid)) {
redirect_header($currentFile, 4, _AM_WFDOWNLOADS_DOWN_ERROR_FILENOTFOUND);
exit();
}
- $cid = $download->getVar('cid');
- if (!$category = $wfdownloads->getHandler('category')->get($cid)) {
+ $cid = $downloadObj->getVar('cid');
+ if (!$categoryObj = $wfdownloads->getHandler('category')->get($cid)) {
redirect_header($currentFile, 4, _AM_WFDOWNLOADS_DOWN_ERROR_CATEGORYNOTFOUND);
exit();
}
- $title = preg_replace("/{category}/", $category->getVar('title'), _AM_WFDOWNLOADS_FFS_EDITDOWNLOADTITLE);
+ $title = preg_replace("/{category}/", $categoryObj->getVar('title'), _AM_WFDOWNLOADS_FILE_EDIT);
+ $title12 = preg_replace("/{category}/", $categoryObj->getVar('title'), _AM_WFDOWNLOADS_FFS_1STEP);
+ $title22 = preg_replace("/{category}/", $categoryObj->getVar('title'), _AM_WFDOWNLOADS_FFS_EDITDOWNLOADTITLE);
} else {
- $download = $wfdownloads->getHandler('download')->create();
- $cid = WfdownloadsRequest::getInt('cid', 0, 'POST');
- $category = $wfdownloads->getHandler('category')->get($cid);
- $download->setVar('cid', $cid);
- $title = preg_replace("/{category}/", $category->getVar('title'), _AM_WFDOWNLOADS_FFS_DOWNLOADTITLE);
+ // create download
+ $downloadObj = $wfdownloads->getHandler('download')->create();
+ $cid = XoopsRequest::getInt('cid', 0, 'POST');
+ $categoryObj = $wfdownloads->getHandler('category')->get($cid);
+ $downloadObj->setVar('cid', $cid);
+ $title = preg_replace("/{category}/", $categoryObj->getVar('title'), _AM_WFDOWNLOADS_FILE_CREATE);
+ $title12 = preg_replace("/{category}/", $categoryObj->getVar('title'), _AM_WFDOWNLOADS_FFS_1STEP);
+ $title22 = preg_replace("/{category}/", $categoryObj->getVar('title'), _AM_WFDOWNLOADS_FFS_DOWNLOADTITLE);
}
- // Added Formulize module support (2006/05/04) jpc - start
+// Formulize module support (2006/05/04) jpc - start
if (!wfdownloads_checkModule('formulize')) {
- $sform = $download->getAdminForm($title);
- } elseif ((isset($_POST['submit_category']) && !empty($_POST['submit_category'])) || $lid) {
- $fid = $category->getVar('formulize_fid');
+ // one step form: 1st step
+ $sform = $downloadObj->getAdminForm($title);
+ } elseif ((isset($_POST['submit_category']) && !empty($_POST['submit_category']))) {
+ // two steps form: 2nd step
+ $fid = $categoryObj->getVar('formulize_fid');
$customArray = array();
if ($fid) {
- include_once XOOPS_ROOT_PATH . "/modules/formulize/include/formdisplay.php";
- include_once XOOPS_ROOT_PATH . "/modules/formulize/include/functions.php";
- $customArray['fid'] = $fid;
- $customArray['formulize_mgr'] =& xoops_getmodulehandler('elements', 'formulize');
- $customArray['groups'] = $xoopsUser ? $xoopsUser->getGroups() : array(0 => XOOPS_GROUP_ANONYMOUS);
- $customArray['prevEntry'] = getEntryValues( // is a 'formulize' function
- $download->getVar('formulize_idreq'),
+ include_once XOOPS_ROOT_PATH . '/modules/formulize/include/formdisplay.php';
+ include_once XOOPS_ROOT_PATH . '/modules/formulize/include/functions.php';
+ $customArray['fid'] = $fid;
+ $customArray['formulize_mgr'] = xoops_getmodulehandler('elements', 'formulize');
+ $customArray['groups'] = $GLOBALS['xoopsUser'] ? $GLOBALS['xoopsUser']->getGroups() : array(0 => XOOPS_GROUP_ANONYMOUS);
+ $customArray['prevEntry'] = getEntryValues( // is a Formulize function
+ $downloadObj->getVar('formulize_idreq'),
$customArray['formulize_mgr'],
$customArray['groups'],
- $fid
+ $fid,
+ null,
+ null,
+ null,
+ null,
+ null
);
- $customArray['entry'] = $download->getVar('formulize_idreq');
- $customArray['go_back'] = "";
- $customArray['parentLinks'] = "";
+ $customArray['entry'] = $downloadObj->getVar('formulize_idreq');
+ $customArray['go_back'] = '';
+ $customArray['parentLinks'] = '';
if (wfdownloads_checkModule('formulize') < 300) {
- $owner = getEntryOwner($entry); // is a 'formulize' function
+ $owner = getEntryOwner($customArray['entry']); // is a Formulize function
} else {
- $owner = getEntryOwner($entry, $fid); // is a 'formulize' function
+ $owner = getEntryOwner($customArray['entry'], $fid); // is a Formulize function
}
- $ownerGroups = $member_handler->getGroupsByUser($owner, false);
+ $ownerGroups = $member_handler->getGroupsByUser($owner, false);
$customArray['owner_groups'] = $ownerGroups;
}
- $sform = $download->getAdminForm($title, $customArray);
+ $sform = $downloadObj->getAdminForm($title22, $customArray);
} else {
- $sform = $download->getCategoryForm();
+ // two steps form: 1st step
+ $sform = $downloadObj->getCategoryForm($title12);
}
+// Formulize module support (2006/05/04) jpc - end
$sform->display();
- // Added Formulize module support (2006/05/04) jpc - end
} else {
redirect_header('categories.php', 1, _AM_WFDOWNLOADS_CCATEGORY_NOEXISTS);
exit();
@@ -114,29 +141,29 @@
// Vote data list/manager
if ($lid) {
- $votes_count = $wfdownloads->getHandler('rating')->getCount();
+ $ratingCount = $wfdownloads->getHandler('rating')->getCount();
- $registeredCriteria = new CriteriaCompo(new Criteria('lid', $lid));
- $registeredCriteria->add(new Criteria('ratinguser', 0, '>'));
- $votesreg = $wfdownloads->getHandler('rating')->getCount($registeredCriteria);
- $registeredCriteria->setSort('ratingtimestamp');
- $registeredCriteria->setOrder('DESC');
- $regvotes = $wfdownloads->getHandler('rating')->getObjects($registeredCriteria);
+ $regUserCriteria = new CriteriaCompo(new Criteria('lid', $lid));
+ $regUserCriteria->add(new Criteria('ratinguser', 0, '>'));
+ $regUserRatingCount = $wfdownloads->getHandler('rating')->getCount($regUserCriteria);
+ $regUserCriteria->setSort('ratingtimestamp');
+ $regUserCriteria->setOrder('DESC');
+ $regUserRatingObjs = $wfdownloads->getHandler('rating')->getObjects($regUserCriteria);
- $anonymousCriteria = new CriteriaCompo(new Criteria('lid', $lid));
- $anonymousCriteria->add(new Criteria('ratinguser', 0, '='));
- $votesanon = $wfdownloads->getHandler('rating')->getCount($anonymousCriteria);
- $anonymousCriteria->setSort('ratingtimestamp');
- $anonymousCriteria->setOrder('DESC');
+ $anonUserCriteria = new CriteriaCompo(new Criteria('lid', $lid));
+ $anonUserCriteria->add(new Criteria('ratinguser', 0, '='));
+ $anonUserRatingCount = $wfdownloads->getHandler('rating')->getCount($anonUserCriteria);
+ $anonUserCriteria->setSort('ratingtimestamp');
+ $anonUserCriteria->setOrder('DESC');
echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_WFDOWNLOADS_VOTE_RATINGINFOMATION . "</legend>\n";
- echo "<div style='padding: 8px;'><b>" . _AM_WFDOWNLOADS_VOTE_TOTALVOTES . "</b>{$votes_count}<br /><br />\n";
+ echo "<div style='padding: 8px;'><b>" . _AM_WFDOWNLOADS_VOTE_TOTALVOTES . "</b>{$ratingCount}<br /><br />\n";
- printf(_AM_WFDOWNLOADS_VOTE_REGUSERVOTES, $votesreg);
+ printf(_AM_WFDOWNLOADS_VOTE_REGUSERVOTES, $regUserRatingCount);
echo "<br />";
- printf(_AM_WFDOWNLOADS_VOTE_ANONUSERVOTES, $votesanon);
+ printf(_AM_WFDOWNLOADS_VOTE_ANONUSERVOTES, $anonUserRatingCount);
echo "
</div>\n
@@ -152,36 +179,32 @@
</tr>\n
";
- if ($votesreg == 0) {
+ if ($regUserRatingCount == 0) {
echo "<tr><td colspan='7' class='even'><b>" . _AM_WFDOWNLOADS_VOTE_NOREGVOTES . "</b></td></tr>";
} else {
- foreach (array_keys($regvotes) as $i) {
- $uids[] = $regvotes[$i]->getVar('ratinguser');
+ foreach ($regUserRatingObjs as $regUserRatingObj) {
+ $uids[] = $regUserRatingObj->getVar('ratinguser');
}
- $criteria = new Criteria("ratinguser", "(" . implode(',', $uids) . ")", "IN");
- $criteria->setGroupby("ratinguser");
+ $criteria = new Criteria('ratinguser', '(' . implode(',', $uids) . ')', 'IN');
+ $criteria->setGroupby('ratinguser');
$userRatings = $wfdownloads->getHandler('rating')->getUserAverage($criteria);
- foreach (array_keys($regvotes) as $i) {
- $formatted_date = XoopsLocal::formatTimestamp($regvotes[$i]->getVar('ratingtimestamp'), 'l');
- $userAvgRating = isset($userRatings[$regvotes[$i]->getVar('ratinguser')]) ? $userRatings[$regvotes[$i]->getVar(
- 'ratinguser'
- )]["avg"] : 0;
- $userVotes = isset($userRatings[$regvotes[$i]->getVar('ratinguser')]) ? $userRatings[$regvotes[$i]->getVar(
- 'ratinguser'
- )]["count"] : 0;
- $ratingUserName = XoopsUser :: getUnameFromId($regvotes[$i]->getVar('ratinguser'));
+ foreach ($regUserRatingObjs as $regUserRatingObj) {
+ $formatted_date = XoopsLocal::formatTimestamp($regUserRatingObj->getVar('ratingtimestamp'), 'l');
+ $userAvgRating = isset($userRatings[$regUserRatingObj->getVar('ratinguser')]) ? $userRatings[$regUserRatingObj->getVar('ratinguser')]['avg'] : 0;
+ $userVotes = isset($userRatings[$regUserRatingObj->getVar('ratinguser')]) ? $userRatings[$regUserRatingObj->getVar('ratinguser')]['count'] : 0;
+ $ratingUserName = XoopsUser :: getUnameFromId($regUserRatingObj->getVar('ratinguser'));
echo "
<tr><td class='head'>$ratingUserName</td>\n
- <td class='even'>" . $regvotes[$i]->getVar('ratinghostname') . "</th>\n
- <td class='even'>" . $regvotes[$i]->getVar('rating') . "</th>\n
+ <td class='even'>" . $regUserRatingObj->getVar('ratinghostname') . "</th>\n
+ <td class='even'>" . $regUserRatingObj->getVar('rating') . "</th>\n
<td class='even'>$userAvgRating</th>\n
<td class='even'>$userVotes</th>\n
<td class='even'>$formatted_date</th>\n
<td class='even'>\n
- <a href='{$currentFile}?op=vote.delete&lid={$lid}&rid=" . $regvotes[$i]->getVar('ratingid') . "'>"
+ <a href='{$currentFile}?op=vote.delete&lid={$lid}&rid=" . $regUserRatingObj->getVar('ratingid') . "'>"
. $imagearray['deleteimg'] . "</a>\n
</th></tr>\n
";
@@ -201,29 +224,29 @@
<th>" . _AM_WFDOWNLOADS_MINDEX_ACTION . "</td>\n
</tr>\n
";
- if ($votesanon == 0) {
+ if ($anonUserRatingCount == 0) {
echo "<tr><td colspan='7' class='even'><b>" . _AM_WFDOWNLOADS_VOTE_NOUNREGVOTES . "</b></td></tr>";
} else {
- $criteria = new Criteria('ratinguser', 0);
- $userRatings = $wfdownloads->getHandler('rating')->getUserAverage($criteria);
- $anonymousVotes = $wfdownloads->getHandler('rating')->getObjects($anonymousCriteria);
+ $criteria = new Criteria('ratinguser', 0);
+ $userRatings = $wfdownloads->getHandler('rating')->getUserAverage($criteria);
+ $anonUserRatingObjs = $wfdownloads->getHandler('rating')->getObjects($anonUserCriteria);
- foreach (array_keys($anonymousVotes) as $i) {
- $formatted_date = XoopsLocal::formatTimestamp($anonymousVotes[$i]->getVar('ratingtimestamp'), 'l');
- $userAvgRating = isset($userRatings['avg']) ? $userRatings["avg"] : 0;
- $userVotes = isset($userRatings['count']) ? $userRatings["count"] : 0;
+ foreach (array_keys($anonUserRatingObjs) as $anonUserRatingObj) {
+ $formatted_date = XoopsLocal::formatTimestamp($anonUserRatingObj->getVar('ratingtimestamp'), 'l');
+ $userAvgRating = isset($userRatings['avg']) ? $userRatings['avg'] : 0;
+ $userVotes = isset($userRatings['count']) ? $userRatings['count'] : 0;
$ratingUserName = $GLOBALS['xoopsConfig']['anonymous'];
echo "
<tr><td class='head'>$ratingUserName</td>\n
- <td class='even'>" . $anonymousVotes[$i]->getVar('ratinghostname') . "</th>\n
- <td class='even'>" . $anonymousVotes[$i]->getVar('rating') . "</th>\n
+ <td class='even'>" . $anonUserRatingObj->getVar('ratinghostname') . "</th>\n
+ <td class='even'>" . $anonUserRatingObj->getVar('rating') . "</th>\n
<td class='even'>$userAvgRating</th>\n
<td class='even'>$userVotes</th>\n
<td class='even'>$formatted_date</th>\n
<td class='even'>\n
- <a href='{$currentFile}?op=vote.delete&lid={$lid}&rid=" . $anonymousVotes[$i]->getVar('ratingid') . "'>"
+ <a href='{$currentFile}?op=vote.delete&lid={$lid}&rid=" . $anonUserRatingObj->getVar('ratingid') . "'>"
. $imagearray['deleteimg'] . "</a>\n
</th></tr>\n
";
@@ -232,32 +255,32 @@
echo "</table>\n";
echo "</fieldset>\n";
}
- include 'admin_footer.php';
+ include_once __DIR__ . '/admin_footer.php';
break;
- case "download.save" :
- case "addDownload" :
- $lid = WfdownloadsRequest::getInt('lid', 0, 'POST');
- $cid = WfdownloadsRequest::getInt('cid', 0, 'POST');
- $status = WfdownloadsRequest::getInt('status', _WFDOWNLOADS_STATUS_UPDATED, 'POST');
+ case 'download.save':
+ case 'addDownload':
+ $lid = XoopsRequest::getInt('lid', 0, 'POST');
+ $cid = XoopsRequest::getInt('cid', 0, 'POST');
+ $status = XoopsRequest::getInt('status', _WFDOWNLOADS_STATUS_UPDATED, 'POST');
if ($lid > 0) {
$thisIsANewRecord = false; /* Added by Lankford on 2007/3/21 */
- $download = $wfdownloads->getHandler('download')->get($lid);
+ $downloadObj = $wfdownloads->getHandler('download')->get($lid);
} else {
$thisIsANewRecord = true; /* Added by Lankford on 2007/3/21 */
- $download = $wfdownloads->getHandler('download')->create();
+ $downloadObj = $wfdownloads->getHandler('download')->create();
}
// Define URL
if (empty($_FILES['userfile']['name'])) {
- if ($_POST['url'] && $_POST['url'] != "" && $_POST['url'] != "http://") {
- $url = ($_POST['url'] != "http://") ? $_POST['url'] : '';
+ if ($_POST['url'] && $_POST['url'] != '' && $_POST['url'] != 'http://') {
+ $url = ($_POST['url'] != 'http://') ? $_POST['url'] : '';
$filename = '';
$filetype = '';
// Get size from form
- $size = (empty($_POST['size']) || !is_numeric($_POST['size'])) ? 0 : (int) $_POST["size"];
+ $size = (empty($_POST['size']) || !is_numeric($_POST['size'])) ? 0 : (int) $_POST['size'];
} else {
- $url = ($_POST["url"] != "http://") ? $_POST['url'] : '';
+ $url = ($_POST['url'] != 'http://') ? $_POST['url'] : '';
$filename = $_POST['filename'];
$filetype = $_POST['filetype'];
$filePath = $wfdownloads->getConfig('uploaddir') . '/' . $filename;
@@ -265,32 +288,33 @@
$size = @filesize($filePath);
}
$title = trim($_POST['title']);
- $download->setVar('filename', $filename);
- $download->setVar('filetype', $filetype);
+ $downloadObj->setVar('filename', $filename);
+ $downloadObj->setVar('filetype', $filetype);
} else {
- $down = wfdownloads_uploading($_FILES, $wfdownloads->getConfig('uploaddir'), '', $currentFile, 0, false, true);
- $url = ($_POST['url'] != "http://") ? $_POST["url"] : '';
- $size = $down['size'];
+ $down = wfdownloads_uploading($_FILES, $wfdownloads->getConfig('uploaddir'), '', $currentFile, 0, false, true);
+ $url = ($_POST['url'] != 'http://') ? $_POST['url'] : '';
+ $size = $down['size'];
$title = $_FILES['userfile']['name'];
- $ext = rtrim(strrchr($title, '.'), '.');
+ $ext = rtrim(strrchr($title, '.'), '.');
$title = str_replace($ext, '', $title);
$title = (isset($_POST['title_checkbox']) && $_POST['title_checkbox'] == 1) ? $title : trim($_POST['title']);
$filename = $down['filename'];
$filetype = $_FILES['userfile']['type'];
- $download->setVar('filename', $filename);
- $download->setVar('filetype', $filetype);
+ $downloadObj->setVar('filename', $filename);
+ $downloadObj->setVar('filetype', $filetype);
}
// Get data from form
- $screenshot = ($_POST['screenshot'] != 'blank.png') ? $_POST['screenshot'] : '';
- $screenshot2 = ($_POST['screenshot2'] != 'blank.png') ? $_POST['screenshot2'] : '';
- $screenshot3 = ($_POST['screenshot3'] != 'blank.png') ? $_POST['screenshot3'] : '';
- $screenshot4 = ($_POST['screenshot4'] != 'blank.png') ? $_POST['screenshot4'] : '';
+ $screenshots = array();
+ $screenshots[] = ($_POST['screenshot'] != 'blank.png') ? $_POST['screenshot'] : '';
+ $screenshots[] = ($_POST['screenshot2'] != 'blank.png') ? $_POST['screenshot2'] : '';
+ $screenshots[] = ($_POST['screenshot3'] != 'blank.png') ? $_POST['screenshot3'] : '';
+ $screenshots[] = ($_POST['screenshot4'] != 'blank.png') ? $_POST['screenshot4'] : '';
- if (!empty($_POST['homepage']) || $_POST['homepage'] != "http://") {
- $download->setVar('homepage', trim($_POST['homepage']));
- $download->setVar('homepagetitle', trim($_POST['homepagetitle']));
+ if (!empty($_POST['homepage']) || $_POST['homepage'] != 'http://') {
+ $downloadObj->setVar('homepage', trim($_POST['homepage']));
+ $downloadObj->setVar('homepagetitle', trim($_POST['homepagetitle']));
}
$version = !empty($_POST['version']) ? trim($_POST['version']) : 0;
@@ -300,14 +324,14 @@
// a) Are they actually changing the value of version, or is it the same?
// b) Are they actually modifying the record, or is this a new one?
// If both conditions are true, then trigger all three notifications related to modified records.
- if (!$thisIsANewRecord && ($download->getVar('version') != $version)) {
+ if (!$thisIsANewRecord && ($downloadObj->getVar('version') != $version)) {
// Trigger the three events related to modified files (one for the file, category, and global event categories respectively)
- $tags = array();
- $tags['FILE_NAME'] = $title;
- $tags['FILE_URL'] = WFDOWNLOADS_URL . "/singlefile.php?cid={$cid}&lid={$lid}";
- $category = $wfdownloads->getHandler('category')->get($cid);
- $tags['FILE_VERSION'] = $version;
- $tags['CATEGORY_NAME'] = $category->getVar('title');
+ $tags = array();
+ $tags['FILE_NAME'] = $title;
+ $tags['FILE_URL'] = WFDOWNLOADS_URL . "/singlefile.php?cid={$cid}&lid={$lid}";
+ $categoryObj = $wfdownloads->getHandler('category')->get($cid);
+ $tags['FILE_VERSION'] = $version;
+ $tags['CATEGORY_NAME'] = $categoryObj->getVar('title');
$tags['CATEGORY_URL'] = WFDOWNLOADS_URL . "/viewcat.php?cid='{$cid}";
if ($wfdownloads->getConfig('autoapprove') == _WFDOWNLOADS_AUTOAPPROVE_DOWNLOAD
@@ -320,60 +344,61 @@
}
}
/* End add block */
- $download->setVar('version', $version);
- $download->setVar('url', $url);
- $download->setVar('cid', $cid);
- $download->setVar('title', $title);
- $download->setVar('status', $status);
- $download->setVar('size', $size);
- $download->setVar('screenshot', $screenshot);
- $download->setVar('screenshot2', $screenshot2);
- $download->setVar('screenshot3', $screenshot3);
- $download->setVar('screenshot4', $screenshot4);
- $download->setVar('platform', trim($_POST['platform']));
- $download->setVar('summary', trim($_POST['summary']));
- $download->setVar('description', trim($_POST['description']));
- $download->setVar('dohtml', isset($_POST['dohtml']));
- $download->setVar('dosmiley', isset($_POST['dosmiley']));
- $download->setVar('doxcode', isset($_POST['doxcode']));
- $download->setVar('doimage', isset($_POST['doimage']));
- $download->setVar('dobr', isset($_POST['dobr']));
- $download->setVar('submitter', trim($_POST['submitter']));
- $download->setVar('publisher', trim($_POST['publi...
[truncated message content] |