From: <luc...@us...> - 2014-09-16 20:31:57
|
Revision: 12782 http://sourceforge.net/p/xoops/svn/12782 Author: luciorota Date: 2014-09-16 20:31:50 +0000 (Tue, 16 Sep 2014) Log Message: ----------- standardize code use absolute path/url where possible Modified Paths: -------------- XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/about.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/admin_header.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/categories.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/clone.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/downloads.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/images.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/import.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/index.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/indexpage.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/mimetypes.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/mirrors.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/permissions.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/ratings.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/reportsmodifications.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/reviews.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/swishe.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/blocks/top.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/blocks/top_by_cat.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/brokenfile.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/class/breadcrumb.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/class/category.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/class/download.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/class/mimetype.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/class/mirror.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/class/rating.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/class/review.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/class/wfdownloads_lists.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/class/xoopstree.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/comment_delete.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/comment_edit.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/comment_new.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/comment_post.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/comment_reply.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/docs/changelog.txt XoopsModules/wfdownloads/branches/luciorota/wfdownloads/include/comment_functions.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/include/common.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/include/constants.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/include/directorychecker.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/include/filechecker.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/include/functions.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/include/notification.inc.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/include/oninstall.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/include/onuninstall.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/include/onupdate.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/include/search.inc.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/index.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/mirror.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/newlist.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/notification_update.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/ratefile.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/review.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/rss.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/singlefile.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/submit.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/templates/wfdownloads_newlistindex.tpl XoopsModules/wfdownloads/branches/luciorota/wfdownloads/topten.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/viewcat.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/visit.php XoopsModules/wfdownloads/branches/luciorota/wfdownloads/xoops_version.php Modified: XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/about.php =================================================================== --- XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/about.php 2014-09-15 03:39:05 UTC (rev 12781) +++ XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/about.php 2014-09-16 20:31:50 UTC (rev 12782) @@ -27,4 +27,4 @@ echo $aboutAdmin->addNavigation('about.php'); echo $aboutAdmin->renderAbout('6KJ7RW5DR3VTJ', false); -include 'admin_footer.php'; +include_once dirname(__FILE__) . '/admin_footer.php'; Modified: XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/admin_header.php =================================================================== --- XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/admin_header.php 2014-09-15 03:39:05 UTC (rev 12781) +++ XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/admin_header.php 2014-09-16 20:31:50 UTC (rev 12782) @@ -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/luciorota/wfdownloads/admin/categories.php =================================================================== --- XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/categories.php 2014-09-15 03:39:05 UTC (rev 12781) +++ XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/categories.php 2014-09-16 20:31:50 UTC (rev 12782) @@ -91,13 +91,13 @@ 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; + $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'); @@ -109,12 +109,12 @@ $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']) : ''; } if (!$cid) { @@ -127,12 +127,12 @@ } } - $categoryObj->setVar('title', $_POST["title"]); + $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('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'])); @@ -140,7 +140,7 @@ $categoryObj->setVar('dobr', isset($_POST['dobr'])); // Formulize module support (2006/05/04) jpc - start if (wfdownloads_checkModule('formulize')) { - $formulize_fid = (isset($_POST["formulize_fid"])) ? (int) $_POST["formulize_fid"] : 0; + $formulize_fid = (isset($_POST['formulize_fid'])) ? (int) $_POST['formulize_fid'] : 0; $categoryObj->setVar('formulize_fid', $formulize_fid); } // Formulize module support (2006/05/04) jpc - end @@ -238,7 +238,7 @@ $form = $categoryObj->getForm(); $form -> display(); - include 'admin_footer.php'; + include_once dirname(__FILE__) . '/admin_footer.php'; break; case 'categories.list' : @@ -261,7 +261,7 @@ } else { redirect_header("{$currentFile}?op=category.add", 1, _AM_WFDOWNLOADS_CCATEGORY_NOEXISTS); } - include 'admin_footer.php'; + include_once dirname(__FILE__) . '/admin_footer.php'; break; case 'categories.reorder' : Modified: XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/clone.php =================================================================== --- XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/clone.php 2014-09-15 03:39:05 UTC (rev 12781) +++ XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/clone.php 2014-09-16 20:31:50 UTC (rev 12782) @@ -44,8 +44,8 @@ } $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)) ); @@ -54,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, @@ -71,7 +71,7 @@ $indexAdmin = new ModuleAdmin(); echo $indexAdmin->addNavigation($currentFile); echo $message; - include 'admin_footer.php'; + include_once dirname(__FILE__) . '/admin_footer.php'; exit(); } else { @@ -79,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); + $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 dirname(__FILE__) . '/admin_footer.php'; exit(); } @@ -138,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)) { @@ -156,10 +153,10 @@ } } // Check original image/font - if (!file_exists($imageBase = XOOPS_ROOT_PATH . "/modules/" . $dirname . "/assets/images/module_logo_blank.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 @@ -168,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 @@ -176,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/luciorota/wfdownloads/admin/downloads.php =================================================================== --- XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/downloads.php 2014-09-15 03:39:05 UTC (rev 12781) +++ XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/downloads.php 2014-09-16 20:31:50 UTC (rev 12782) @@ -41,9 +41,9 @@ $op = WfdownloadsRequest::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); @@ -59,8 +59,8 @@ // 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"; @@ -83,7 +83,7 @@ } else { // create download $downloadObj = $wfdownloads->getHandler('download')->create(); - $cid = WfdownloadsRequest::getInt('cid', 0, 'POST'); + $cid = WfdownloadsRequest::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); @@ -97,15 +97,15 @@ $sform = $downloadObj->getAdminForm($title); } elseif ((isset($_POST['submit_category']) && !empty($_POST['submit_category']))) { // two steps form: 2nd step - $fid = $categoryObj->getVar('formulize_fid'); + $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; + 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 + $customArray['groups'] = $xoopsUser ? $xoopsUser->getGroups() : array(0 => XOOPS_GROUP_ANONYMOUS); + $customArray['prevEntry'] = getEntryValues( // is a Formulize function $downloadObj->getVar('formulize_idreq'), $customArray['formulize_mgr'], $customArray['groups'], @@ -117,14 +117,14 @@ null ); $customArray['entry'] = $downloadObj->getVar('formulize_idreq'); - $customArray['go_back'] = ""; - $customArray['parentLinks'] = ""; + $customArray['go_back'] = ''; + $customArray['parentLinks'] = ''; if (wfdownloads_checkModule('formulize') < 300) { $owner = getEntryOwner($customArray['entry']); // is a Formulize function } else { $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 = $downloadObj->getAdminForm($title22, $customArray); @@ -141,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 @@ -179,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 "; @@ -228,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 "; @@ -259,32 +255,32 @@ echo "</table>\n"; echo "</fieldset>\n"; } - include 'admin_footer.php'; + include_once dirname(__FILE__) . '/admin_footer.php'; break; - case "download.save" : - case "addDownload" : - $lid = WfdownloadsRequest::getInt('lid', 0, 'POST'); - $cid = WfdownloadsRequest::getInt('cid', 0, 'POST'); + 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'); if ($lid > 0) { $thisIsANewRecord = false; /* Added by Lankford on 2007/3/21 */ - $downloadObj = $wfdownloads->getHandler('download')->get($lid); + $downloadObj = $wfdownloads->getHandler('download')->get($lid); } else { $thisIsANewRecord = true; /* Added by Lankford on 2007/3/21 */ - $downloadObj = $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"]; } else { - $url = ($_POST["url"] != "http://") ? $_POST['url'] : ''; + $url = ($_POST["url"] != "http://") ? $_POST['url'] : ''; $filename = $_POST['filename']; $filetype = $_POST['filetype']; $filePath = $wfdownloads->getConfig('uploaddir') . '/' . $filename; @@ -295,12 +291,12 @@ $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']); @@ -329,11 +325,11 @@ // If both conditions are true, then trigger all three notifications related to modified records. 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}"; - $categoryObj = $wfdownloads->getHandler('category')->get($cid); - $tags['FILE_VERSION'] = $version; + $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}"; @@ -379,12 +375,12 @@ $versiontypes = (isset($_POST['versiontypes'])) ? $_POST['versiontypes'] : ''; $downloadObj->setVar('versiontypes', $versiontypes); - $dhistory = (isset($_POST['dhistory'])) ? $_POST['dhistory'] : ''; + $dhistory = (isset($_POST['dhistory'])) ? $_POST['dhistory'] : ''; $dhistoryhistory = (isset($_POST['dhistoryaddedd'])) ? $_POST['dhistoryaddedd'] : ''; if ($lid > 0 && !empty($dhistoryhistory)) { $dhistory = $dhistory . "\n\n"; - $time = time(); + $time = time(); $dhistory .= _AM_WFDOWNLOADS_FILE_HISTORYVERS . $version . _AM_WFDOWNLOADS_FILE_HISTORDATE . XoopsLocal::formatTimestamp($time, 'l') . "\n\n"; $dhistory .= $dhistoryhistory; } @@ -400,7 +396,7 @@ $offline = ($_POST['offline'] == true) ? true : false; $downloadObj->setVar('offline', $offline); - $approved = (isset($_POST['approved']) && $_POST['approved'] == true) ? true : false; + $approved = (isset($_POST['approved']) && $_POST['approved'] == true) ? true : false; $notifypub = (isset($_POST['notifypub']) && $_POST['notifypub'] == true); $expiredate = 0; @@ -408,7 +404,7 @@ $publishdate = time(); } else { $publishdate = $_POST['was_published']; - $expiredate = $_POST['was_expired']; + $expiredate = $_POST['was_expired']; } if ($approved == 1 && empty($publishdate)) { $publishdate = time(); @@ -440,8 +436,8 @@ if (wfdownloads_checkModule('formulize')) { $fid = $categoryObj->getVar('formulize_fid'); if ($fid) { - include_once XOOPS_ROOT_PATH . "/modules/formulize/include/formread.php"; - include_once XOOPS_ROOT_PATH . "/modules/formulize/include/functions.php"; + include_once XOOPS_ROOT_PATH . '/modules/formulize/include/formread.php'; + include_once XOOPS_ROOT_PATH . '/modules/formulize/include/functions.php'; $formulize_mgr =& xoops_getmodulehandler('elements', 'formulize'); if ($lid) { $entries[$fid][0] = $downloadObj->getVar('formulize_idreq'); @@ -452,19 +448,19 @@ $owner = getEntryOwner($entries[$fid][0], $fid); // is a Formulize function } } else { - print "no idreq"; - $entries[$fid][0] = ""; - $owner = ""; + print 'no idreq'; + $entries[$fid][0] = ''; + $owner = ''; } $cid = $downloadObj->getVar('cid'); } else { - $entries[$fid][0] = ""; - $owner = ""; + $entries[$fid][0] = ''; + $owner = ''; } - $ownerGroups =& $member_handler->getGroupsByUser($owner, false); - $uid = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0; - $groups = $xoopsUser ? $xoopsUser->getGroups() : array(0 => XOOPS_GROUP_ANONYMOUS); - $entries = handleSubmission( + $ownerGroups = $member_handler->getGroupsByUser($owner, false); + $uid = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0; + $groups = $xoopsUser ? $xoopsUser->getGroups() : array(0 => XOOPS_GROUP_ANONYMOUS); + $entries = handleSubmission( $formulize_mgr, $entries, $uid, @@ -472,7 +468,7 @@ $fid, $ownerGroups, $groups, - "new" + 'new' ); // "new" causes xoops token check to be skipped, since Wfdownloads should be doing that if (!$owner) { $id_req = $entries[$fid][0]; @@ -485,21 +481,21 @@ $newid = (int) $downloadObj->getVar('lid'); // Send notifications if (!$lid) { - $tags = array(); - $tags['FILE_NAME'] = $title; - $tags['FILE_URL'] = WFDOWNLOADS_URL . "/singlefile.php?cid={$cid}&lid={$newid}"; + $tags = array(); + $tags['FILE_NAME'] = $title; + $tags['FILE_URL'] = WFDOWNLOADS_URL . "/singlefile.php?cid={$cid}&lid={$newid}"; $tags['CATEGORY_NAME'] = $categoryObj->getVar('title'); - $tags['CATEGORY_URL'] = WFDOWNLOADS_URL . "/viewcat.php?cid={$cid}"; + $tags['CATEGORY_URL'] = WFDOWNLOADS_URL . "/viewcat.php?cid={$cid}"; $notification_handler->triggerEvent('global', 0, 'new_file', $tags); $notification_handler->triggerEvent('category', $cid, 'new_file', $tags); } if ($lid && $approved && $notifypub) { - $tags = array(); - $tags['FILE_NAME'] = $title; - $tags['FILE_URL'] = WFDOWNLOADS_URL . "/singlefile.php?cid={$cid}&lid={$lid}"; - $categoryObj = $wfdownloads->getHandler('category')->get($cid); + $tags = array(); + $tags['FILE_NAME'] = $title; + $tags['FILE_URL'] = WFDOWNLOADS_URL . "/singlefile.php?cid={$cid}&lid={$lid}"; + $categoryObj = $wfdownloads->getHandler('category')->get($cid); $tags['CATEGORY_NAME'] = $categoryObj->getVar('title'); - $tags['CATEGORY_URL'] = WFDOWNLOADS_URL . '/viewcat.php?cid=' . $cid; + $tags['CATEGORY_URL'] = WFDOWNLOADS_URL . '/viewcat.php?cid=' . $cid; $notification_handler->triggerEvent('global', 0, 'new_file', $tags); $notification_handler->triggerEvent('category', $cid, 'new_file', $tags); $notification_handler->triggerEvent('file', $lid, 'approve', $tags); @@ -510,9 +506,9 @@ redirect_header($currentFile, 1, $message); break; - case "download.delete" : + case 'download.delete': $lid = WfdownloadsRequest::getInt('lid', 0); - $ok = WfdownloadsRequest::getBool('ok', false, 'POST'); + $ok = WfdownloadsRequest::getBool('ok', false, 'POST'); if (!$downloadObj = $wfdownloads->getHandler('download')->get($lid)) { redirect_header($currentFile, 4, _AM_WFDOWNLOADS_ERROR_DOWNLOADNOTFOUND); exit(); @@ -544,17 +540,17 @@ } break; - case "vote.delete" : - case "delVote" : - $rating = $wfdownloads->getHandler('rating')->get($_GET['rid']); - if ($wfdownloads->getHandler('rating')->delete($rating, true)) { - wfdownloads_updateRating(intval($rating->getVar('lid'))); + case 'vote.delete': + case 'delVote': + $ratingObj = $wfdownloads->getHandler('rating')->get($_GET['rid']); + if ($wfdownloads->getHandler('rating')->delete($ratingObj, true)) { + wfdownloads_updateRating((int) $ratingObj->getVar('lid')); } redirect_header($currentFile, 1, _AM_WFDOWNLOADS_VOTE_VOTEDELETED); break; // Formulize module support (2006/05/04) jpc - start - case "patch_formulize" : + case 'patch_formulize': if (wfdownloads_checkModule('formulize')) { if (!isset($_POST['patch_formulize'])) { print "<form action=\"{$currentFile}?op=patch_formulize\" method=post>"; @@ -576,8 +572,8 @@ break; // Formulize module support (2006/05/04) jpc - end - case "newdownload.approve" : - case "approve" : + case 'newdownload.approve': + case 'approve': $lid = WfdownloadsRequest::getInt('lid', 0); if (!$downloadObj = $wfdownloads->getHandler('download')->get($lid)) { redirect_header($currentFile, 4, _AM_WFDOWNLOADS_ERROR_DOWNLOADNOTFOUND); @@ -591,14 +587,14 @@ exit(); } // Trigger notify - $title = $downloadObj->getVar('title'); - $cid = $downloadObj->getVar('cid'); - $categoryObj = $wfdownloads->getHandler('category')->get($cid); - $tags = array(); - $tags['FILE_NAME'] = $title; - $tags['FILE_URL'] = WFDOWNLOADS_URL . "/singlefile.php?cid={$cid}&lid={$lid}"; + $title = $downloadObj->getVar('title'); + $cid = $downloadObj->getVar('cid'); + $categoryObj = $wfdownloads->getHandler('category')->get($cid); + $tags = array(); + $tags['FILE_NAME'] = $title; + $tags['FILE_URL'] = WFDOWNLOADS_URL . "/singlefile.php?cid={$cid}&lid={$lid}"; $tags['CATEGORY_NAME'] = $categoryObj->getVar('title'); - $tags['CATEGORY_URL'] = WFDOWNLOADS_URL . "/viewcat.php?cid={$cid}"; + $tags['CATEGORY_URL'] = WFDOWNLOADS_URL . "/viewcat.php?cid={$cid}"; $notification_handler->triggerEvent('global', 0, 'new_file', $tags); $notification_handler->triggerEvent('category', $cid, 'new_file', $tags); if ($downloadObj->getVar('notifypub')) { @@ -607,17 +603,18 @@ redirect_header($currentFile, 1, _AM_WFDOWNLOADS_SUB_NEWFILECREATED); break; - case "downloads.list" : - case "downloads.filter" : + case 'downloads.list': + case 'downloads.filter': default : - $filter_title_condition = WfdownloadsRequest::getString('filter_title_condition', '='); - $filter_title = WfdownloadsRequest::getString('filter_title', ''); + // get filter conditions + $filter_title_condition = WfdownloadsRequest::getString('filter_title_condition', '='); + $filter_title = WfdownloadsRequest::getString('filter_title', ''); $filter_category_title_condition = WfdownloadsRequest::getString('filter_category_title_condition', '='); - $filter_category_title = WfdownloadsRequest::getString('filter_category_title', ''); - $filter_submitter = WfdownloadsRequest::getArray('filter_submitter', null); - $filter_date = WfdownloadsRequest::getArray('filter_date', null); - $filter_date_condition = WfdownloadsRequest::getString('filter_date_condition', '<'); - + $filter_category_title = WfdownloadsRequest::getString('filter_category_title', ''); + $filter_submitter = WfdownloadsRequest::getArray('filter_submitter', null); + $filter_date = WfdownloadsRequest::getArray('filter_date', null); + $filter_date_condition = WfdownloadsRequest::getString('filter_date_condition', '<'); + // check filter conditions if ($op == 'downloads.filter') { if ($filter_title == '' && $filter_category_title == '' && is_null($filter_submitter)) { $op = 'downloads.list'; @@ -626,16 +623,16 @@ include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; - $categories = $wfdownloads->getHandler('category')->getObjects(); + $categoryObjs = $wfdownloads->getHandler('category')->getObjects(); - $start_published = WfdownloadsRequest::getInt('start_published', 0); - $start_new = WfdownloadsRequest::getInt('start_new', 0); + $start_published = WfdownloadsRequest::getInt('start_published', 0); + $start_new = WfdownloadsRequest::getInt('start_new', 0); $start_autopublished = WfdownloadsRequest::getInt('start_autopublished', 0); - $start_expired = WfdownloadsRequest::getInt('start_expired', 0); - $start_offline = WfdownloadsRequest::getInt('start_offline', 0); + $start_expired = WfdownloadsRequest::getInt('start_expired', 0); + $start_offline = WfdownloadsRequest::getInt('start_offline', 0); $totalCategoriesCount = wfdownloads_categoriesCount(); - $categories = $wfdownloads->getHandler('category')->getObjects(null, true, false); + $categoryObjs = $wfdownloads->getHandler('category')->getObjects(null, true, false); $totalDownloadsCount = $wfdownloads->getHandler('download')->getCount(); @@ -683,13 +680,13 @@ $criteria->setOrder('DESC'); $criteria->setStart($start_published); $criteria->setLimit($wfdownloads->getConfig('admin_perpage')); - $publishedDownloads = $wfdownloads->getHandler('download')->getActiveDownloads($criteria); - $publishedDownloadsCount = $wfdownloads->getHandler('download')->getActiveCount(); - $GLOBALS['xoopsTpl']->assign('published_downloads_count', $publishedDownloadsCount); + $publishedDownloadObjs = $wfdownloads->getHandler('download')->getActiveDownloads($criteria); + $publishedDownloadCount = $wfdownloads->getHandler('download')->getActiveCount(); + $GLOBALS['xoopsTpl']->assign('published_downloads_count', $publishedDownloadCount); - if ($publishedDownloadsCount > 0) { - foreach ($publishedDownloads as $publishedDownload) { - $publishedDownload_array = $publishedDownload->toArray(); + if ($publishedDownloadCount > 0) { + foreach ($publishedDownloadObjs as $publishedDownloadObj) { + $publishedDownload_array = $publishedDownloadObj->toArray(); $publishedDownload_array['title_html'] = $myts->htmlSpecialChars(trim($publishedDownload_array['title'])); $publishedDownload_array['category_title'] = $categories[$publishedDownload_array['cid']]['title']; $publishedDownload_array['submitter_uname'] = XoopsUserUtility::getUnameFromId($publishedDownload_array['submitter']); @@ -723,12 +720,12 @@ $criteria->add(new Criteria('published', 0)); $criteria->setStart($start_new); $criteria->setLimit($wfdownloads->getConfig('admin_perpage')); - $newDownloads = $wfdownloads->getHandler('download')->getObjects($criteria); - $newDownloadsCount = $wfdownloads->getHandler('download')->getCount($criteria); - $GLOBALS['xoopsTpl']->assign('new_downloads_count', $newDownloadsCount); - if ($newDownloadsCount > 0) { - foreach ($newDownloads as $newDownload) { - $newDownload_array = $newDownload->toArray(); + $newDownloadObjs = $wfdownloads->getHandler('download')->getObjects($criteria); + $newDownloadCount = $wfdownloads->getHandler('download')->getCount($criteria); + $GLOBALS['xoopsTpl']->assign('new_downloads_count', $newDownloadCount); + if ($newDownloadCount > 0) { + foreach ($newDownloadObjs as $newDownloadObj) { + $newDownload_array = $newDownloadObj->toArray(); $newDownload_array['rating'] = number_format($newDownload_array['rating'], 2); $newDownload_array['title_html'] = $myts->htmlSpecialChars($newDownload_array['title']); $newDownload_array['category_title'] = $categories[$newDownload_array['cid']]['title']; @@ -743,7 +740,7 @@ $GLOBALS['xoopsTpl']->append('new_downloads', $newDownload_array); } } - $pagenav = new XoopsPageNav($newDownloadsCount, $wfdownloads->getConfig('admin_perpage'), $start_new, 'start_new'); + $pagenav = new XoopsPageNav($newDownloadCount, $wfdownloads->getConfig('admin_perpage'), $start_new, 'start_new'); $GLOBALS['xoopsTpl']->assign('new_downloads_pagenav', $pagenav->renderNav()); // Autopublished Downloads @@ -753,12 +750,12 @@ $criteria->setOrder("ASC"); $criteria->setStart($start_autopublished); $criteria->setLimit($wfdownloads->getConfig('admin_perpage')); - $autopublishedDownloads = $wfdownloads->getHandler('download')->getObjects($criteria); - $autopublishedDownloadsCount = $wfdownloads->getHandler('download')->getCount($criteria); - $GLOBALS['xoopsTpl']->assign('autopublished_downloads_count', $autopublishedDownloadsCount); - if ($autopublishedDownloadsCount > 0) { - foreach ($autopublishedDownloads as $autopublishedDownload) { - $autopublishedDownload_array = $autopublishedDownload->toArray(); + $autopublishedDownloadObjs = $wfdownloads->getHandler('download')->getObjects($criteria); + $autopublishedDownloadCount = $wfdownloads->getHandler('download')->getCount($criteria); + $GLOBALS['xoopsTpl']->assign('autopublished_downloads_count', $autopublishedDownloadCount); + if ($autopublishedDownloadCount > 0) { + foreach ($autopublishedDownloadObjs as $autopublishedDownloadObj) { + $autopublishedDownload_array = $autopublishedDownloadObj->toArray(); $autopublishedDownload_array['title_html'] = $myts->htmlSpecialChars(trim($autopublishedDownload_array['title'])); $autopublishedDownload_array['category_title'] = $categories[$autopublishedDownload_array['cid']]['title']; $autopublishedDownload_array['submitter_uname'] = XoopsUserUtility::getUnameFromId($autopublishedDownload_array['submitter']); @@ -766,7 +763,7 @@ $GLOBALS['xoopsTpl']->append('autopublished_downloads', $autopublishedDownload_array); } } - $pagenav = new XoopsPageNav($autopublishedDownloadsCount, $wfdownloads->getConfig( + $pagenav = new XoopsPageNav($autopublishedDownloadCount, $wfdownloads->getConfig( 'admin_perpage' ), $start_autopublished, 'start_autopublished'); $GLOBALS['xoopsTpl']->assign('autopublished_downloads_pagenav', $pagenav->renderNav()); @@ -779,12 +776,12 @@ $criteria->setOrder('ASC'); $criteria->setStart($start_expired); $criteria->setLimit($wfdownloads->getConfig('admin_perpage')); - $expired_downloads = $wfdownloads->getHandler('download')->getObjects($criteria); - $expiredDownloadsCount = $wfdownloads->getHandler('download')->getCount($criteria); - $GLOBALS['xoopsTpl']->assign('expired_downloads_count', $expiredDownloadsCount); - if ($expiredDownloadsCount > 0) { - foreach ($expired_downloads as $expired_download) { - $expired_download_array = $expired_download->toArray(); + $expiredDownloadObjs = $wfdownloads->getHandler('download')->getObjects($criteria); + $expiredDownloadCount = $wfdownloads->getHandler('download')->getCount($criteria); + $GLOBALS['xoopsTpl']->assign('expired_downloads_count', $expiredDownloadCount); + if ($expiredDownloadCount > 0) { + foreach ($expiredDownloadObjs as $expiredDownloadObj) { + $expired_download_array = $expiredDownloadObj->toArray(); $expired_download_array['title_html'] = $myts->htmlSpecialChars(trim($expired_download_array['title'])); $expired_download_array['category_title'] = $categories[$expired_download_array['cid']]['title']; $expired_download_array['submitter_uname'] = XoopsUserUtility::getUnameFromId($expired_download_array['submitter']); @@ -792,7 +789,7 @@ $GLOBALS['xoopsTpl']->append('expired_downloads', $expired_download_array); } } - $pagenav = new XoopsPageNav($expiredDownloadsCount, $wfdownloads->getConfig('admin_perpage'), $start_expired, 'start_expired'); + $pagenav = new XoopsPageNav($expiredDownloadCount, $wfdownloads->getConfig('admin_perpage'), $start_expired, 'start_expired'); $GLOBALS['xoopsTpl']->assign('expired_downloads_pagenav', $pagenav->renderNav()); // Offline downloads @@ -801,13 +798,12 @@ $criteria->setOrder('ASC'); $criteria->setStart($start_offline); $criteria->setLimit($wfdownloads->getConfig('admin_perpage')); - $offlineDownloadsCount = $wfdownloads->getHandler('download')->getCount($criteria); - $offlineDownloads = $wfdownloads->getHandler('download')->getObjects($criteria); - $offlineDownloadsCount = $wfdownloads->getHandler('download')->getCount($criteria); - $GLOBALS['xoopsTpl']->assign('offline_downloads_count', $offlineDownloadsCount); - if ($offlineDownloadsCount > 0) { - foreach ($offlineDownloads as $offlineDownload) { - $offlineDownload_array = $offlineDownload->toArray(); + $offlineDownloadObjs = $wfdownloads->getHandler('download')->getObjects($criteria); + $offlineDownloadCount = $wfdownloads->getHandler('download')->getCount($criteria); + $GLOBALS['xoopsTpl']->assign('offline_downloads_count', $offlineDownloadCount); + if ($offlineDownloadCount > 0) { + foreach ($offlineDownloadObjs as $offlineDownloadObj) { + $offlineDownload_array = $offlineDownloadObj->toArray(); $offlineDownload_array['title_html'] = $myts->htmlSpecialChars(trim($offlineDownload_array['title'])); $offlineDownload_array['category_title'] = $categories[$offlineDownload_array['cid']]['title']; $offlineDownload_array['submitter_uname'] = XoopsUserUtility::getUnameFromId($offlineDownload_array['submitter']); @@ -815,7 +811,7 @@ $GLOBALS['xoopsTpl']->append('offline_downloads', $offlineDownload_array); } } - $pagenav = new XoopsPageNav($offlineDownloadsCount, $wfdownloads->getConfig('admin_perpage'), $start_offline, 'start_offline'); + $pagenav = new XoopsPageNav($offlineDownloadCount, $wfdownloads->getConfig('admin_perpage'), $start_offline, 'start_offline'); $GLOBALS['xoopsTpl']->assign('offline_downloads_pagenav', $pagenav->renderNav()); } else { // NOP @@ -843,10 +839,10 @@ $GLOBALS['xoopsTpl']->display("db:{$wfdownloads->getModule()->dirname()}_am_downloadslist.tpl"); - include 'admin_footer.php'; + include_once dirname(__FILE__) . '/admin_footer.php'; break; - case "batchfile.add" : + case 'batchfile.add': $batchid = WfdownloadsRequest::getInt('batchid', 0); $extensionToMime = include $GLOBALS['xoops']->path('include/mimetypes.inc.php'); @@ -873,7 +869,6 @@ $downloadObj->setVar('filename', $savedFileName); $downloadObj->setVar('size', filesize($wfdownloads->getConfig('uploaddir') . '/' . $savedFileName)); $downloadObj->setVar('filetype', $extensionToMime[pathinfo($batchFile, PATHINFO_EXTENSION)]); - $downloadObj->setVar('version', 0); $downloadObj->setVar('status', _WFDOWNLOADS_STATUS_APPROVED); // IN PROGRESS $downloadObj->setVar('published', time()); @@ -892,7 +887,7 @@ redirect_header("{$currentFile}?op=download.edit&lid={$newid}", 3, _AM_WFDOWNLOADS_BATCHFILE_MOVEDEDITNOW); break; - case "batchfile.delete" : + case 'batchfile.delete': $batchid = WfdownloadsRequest::getInt('batchid', 0); $ok = WfdownloadsRequest::getBool('ok', false, 'POST'); @@ -922,7 +917,7 @@ } break; - case "ip_logs.list" : + case 'ip_logs.list': $lid = WfdownloadsRequest::getInt('lid', 0); if (!$lid) { header('Location index.php'); @@ -943,15 +938,15 @@ } $criteria->setSort('date'); $criteria->setOrder('DESC'); - $ip_logObjs = $wfdownloads->getHandler('ip_log')->getObjects($criteria); - $ip_logs_count = $wfdownloads->getHandler('ip_log')->getCount($criteria); - $GLOBALS['xoopsTpl']->assign('ip_logs_count', $ip_logs_count); + $ip_logObjs = $wfdownloads->getHandler('ip_log')->getObjects($criteria); + $ip_logCount = $wfdownloads->getHandler('ip_log')->getCount($criteria); + $GLOBALS['xoopsTpl']->assign('ip_logs_count', $ip_logCount); unset($criteria); // Get download info if ($lid != 0) { - $downloadObj = $wfdownloads->getHandler('download')->get($lid); - $download_array = $downloadObj->toArray(); + $downloadObj = $wfdownloads->getHandler('download')->get($lid); + $download_array = $downloadObj->toArray(); $download_array['log_title'] = sprintf(_AM_WFDOWNLOADS_LOG_FOR_LID, $download_array['title']); $GLOBALS['xoopsTpl']->assign('download', $download_array); } @@ -972,8 +967,8 @@ // NOP } else { foreach ($ip_logObjs as $ip_logObj) { - $ip_log_array = $ip_logObj->toArray(); - $ip_log_array['uname'] = XoopsUserUtility::getUnameFromId( + $ip_log_array = $ip_logObj->toArray(); + $ip_log_array['uname'] = XoopsUserUtility::getUnameFromId( $ip_log_array['uid'] ); //($ip_log_array['uid'] != 0) ? $userList[$ip_log_array['uid']] : _AM_WFDOWNLOADS_ANONYMOUS; @@ -984,6 +979,6 @@ $GLOBALS['xoopsTpl']->display("db:{$wfdownloads->getModule()->dirname()}_am_ip_logslist.tpl"); - include 'admin_footer.php'; + include_once dirname(__FILE__) . '/admin_footer.php'; break; } Modified: XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/images.php =================================================================== --- XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/images.php 2014-09-15 03:39:05 UTC (rev 12781) +++ XoopsModules/wfdownloads/branches/luciorota/wfdownloads/admin/images.php 2014-09-16 20:31:50 UTC (rev 12782) @@ -36,8 +36,8 @@ $op = WfdownloadsRequest::getString('op', 'images.list'); switch ($op) { - case "image.upload" : - if ($_FILES['uploadfile']['name'] != "") { + case 'image.upload': + if ($_FILES['uploadfile']['name'] != '') { if (file_exists(XOOPS_ROOT_PATH . '/' . $_POST['uploadpath'] . '/' . $_FILES['uploadfile']['name'])) { redirect_header($currentFile, 2, _AM_WFDOWNLOADS_DOWN_IMAGEEXIST); } @@ -60,7 +60,7 @@ } break; - case "image.delete" : + case 'image.delete': $ok = WfdownloadsRequest::getBool('ok', false, 'POST'); if ($ok == true) { @@ -86,11 +86,11 @@ _AM_WFDOWNLOADS_DOWN_DELETEFILE . "<br /><br />" . $_POST['downfile'], _AM_WFDOWNLOADS_BDELETE ); - include 'admin_footer.php'; + include_once dirname(__FILE__) . '/admin_footer.php'; } break; - case "images.list" : + case 'images.list': default: include_once WFDOWNLOADS_ROOT_PATH . '/class/wfdownloads_lists.php'; @@ -140,24 +140,16 @@ $iform->addElement(new XoopsFormLabel(_AM_WFDOWNLOADS_DOWN_FUPLOADPATH, XOOPS_R... [truncated message content] |