From 811db151b54c8ace7adb426e79f7496b91f1df11 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sat, 12 Jan 2019 04:09:28 -0500 Subject: [PATCH 01/62] fineuploader files --- class/CategoryHandler.php | 2 +- class/Common/FineimpuploadHandler.php | 320 +++++++++++++++++++++ class/Common/Images.php | 227 +++++++++++++++ class/Common/ImagesHandler.php | 154 ++++++++++ language/english/common.php | 13 + templates/tdmdownloads_trigger_uploads.tpl | 65 +++++ templates/tdmdownloads_upload.tpl | 88 ++++++ upload.php | 126 ++++++++ xoops_version.php | 3 + 9 files changed, 997 insertions(+), 1 deletion(-) create mode 100644 class/Common/FineimpuploadHandler.php create mode 100644 class/Common/Images.php create mode 100644 class/Common/ImagesHandler.php create mode 100644 templates/tdmdownloads_trigger_uploads.tpl create mode 100644 templates/tdmdownloads_upload.tpl create mode 100644 upload.php diff --git a/class/CategoryHandler.php b/class/CategoryHandler.php index bc6607f..c773183 100644 --- a/class/CategoryHandler.php +++ b/class/CategoryHandler.php @@ -26,7 +26,7 @@ class CategoryHandler extends \XoopsPersistableObjectHandler { /** * CategoryHandler constructor. - * @param \XoopsDatabase $db + * @param \XoopsDatabase|null $db */ public function __construct(\XoopsDatabase $db = null) { diff --git a/class/Common/FineimpuploadHandler.php b/class/Common/FineimpuploadHandler.php new file mode 100644 index 0000000..1667419 --- /dev/null +++ b/class/Common/FineimpuploadHandler.php @@ -0,0 +1,320 @@ +allowedMimeTypes = ['image/gif', 'image/jpeg', 'image/png']; + $this->allowedExtensions = ['gif', 'jpeg', 'jpg', 'png']; + } + + protected function storeUploadedFile($target, $mimeType, $uid) + { + include_once XOOPS_ROOT_PATH .'/modules/'. $moduleDirName .'/header.php'; + include_once XOOPS_ROOT_PATH .'/modules/'. $moduleDirName .'/include/resizer.php'; + $this->pathUpload = WGGALLERY_UPLOAD_IMAGE_PATH; + + $this->permUseralbum = 1; //TODO: handle an option, whether images should be online immediately or not + + $pathParts = pathinfo($this->getName()); + + $this->imageName = uniqid('img', true) . '.' . strtolower($pathParts['extension']); + $this->imageNicename = str_replace(['_', '-'], ' ', $pathParts['filename']); + $this->imageNameLarge = uniqid('imgl', true) . '.' . strtolower($pathParts['extension']); + $this->imagePath = $this->pathUpload . '/large/' . $this->imageNameLarge; + + if (false === move_uploaded_file($_FILES[$this->inputName]['tmp_name'], $this->imagePath)) { + return false; + } + + $this->imageNameOrig = $_FILES[$this->inputName]['name']; + $this->imageMimetype = $_FILES[$this->inputName]['type']; + $this->imageSize = $_FILES[$this->inputName]['size']; + + $ret = $this->handleImageDB(); + if (false === $ret) { + return [ + 'error' => sprintf(_FAILSAVEIMG, $this->imageNicename) + ]; + } + + // load watermark settings + $albumObj = $albumsHandler->get($this->claims->cat); + $wmId = $albumObj->getVar('alb_wmid'); + $wmTargetM = false; + $wmTargetL = false; + if ( 0 < $wmId) { + $watermarksObj = $watermarksHandler->get($wmId); + $wmTarget = $watermarksObj->getVar('wm_target'); + if ( WGGALLERY_WATERMARK_TARGET_A === $wmTarget || WGGALLERY_WATERMARK_TARGET_M === $wmTarget) {$wmTargetM = true;} + if ( WGGALLERY_WATERMARK_TARGET_A === $wmTarget || WGGALLERY_WATERMARK_TARGET_L === $wmTarget) {$wmTargetL = true;} + } + + // create medium image + // $ret = $this->resizeImage($this->pathUpload . '/medium/' . $this->imageName, $helper->getConfig('maxwidth_medium'), $helper->getConfig('maxheight_medium')); + $ret = resizeImage($this->imagePath, $this->pathUpload . '/medium/' . $this->imageName, $helper->getConfig('maxwidth_medium'), $helper->getConfig('maxheight_medium'), $this->imageMimetype); + if (false === $ret) { + return ['error' => sprintf(CO_TDMDOWNLOADS_FAILSAVEIMG_MEDIUM, $this->imageNicename)]; + } + if ('copy' === $ret) { + copy($this->pathUpload . '/large/' . $this->imageNameLarge, $this->pathUpload . '/medium/' . $this->imageName); + } + + // create thumb + // $ret = $this->resizeImage($this->pathUpload . '/thumbs/' . $this->imageName, $helper->getConfig('maxwidth_thumbs'), $helper->getConfig('maxheight_thumbs')); + $ret = resizeImage($this->imagePath, $this->pathUpload . '/thumbs/' . $this->imageName, $helper->getConfig('maxwidth_thumbs'), $helper->getConfig('maxheight_thumbs'), $this->imageMimetype); + if (false === $ret) { + return ['error' => sprintf(CO_TDMDOWNLOADS_FAILSAVEIMG_THUMBS, $this->imageNicename)]; + } + if ('copy' === $ret) { + copy($this->pathUpload . '/large/' . $this->imageNameLarge, $this->pathUpload . '/thumbs/' . $this->imageName); + } + + // add watermark to large image + if ( true === $wmTargetL) { + $imgWm = $this->pathUpload . '/large/' . $this->imageNameLarge; + $resWm = $watermarksHandler->watermarkImage( $wmId, $imgWm, $imgWm ); + if ( true !== $resWm) { + return ['error' => sprintf(_MA_TDMDOWNLOADS_FAILSAVEWM_LARGE, $this->imageNicename, $resWm)]; + } + } + // add watermark to medium image + if ( true === $wmTargetM) { + $imgWm = $this->pathUpload . '/medium/' . $this->imageName; + $resWm = $watermarksHandler->watermarkImage( $wmId, $imgWm, $imgWm ); + if ( true !== $resWm) { + return ['error' => sprintf(_MA_TDMDOWNLOADS_FAILSAVEWM_MEDIUM, $this->imageNicename, $resWm)]; + } + } + + return ['success' => true, 'uuid' => $uuid]; + } + + + private function handleImageDB () { + + include_once XOOPS_ROOT_PATH .'/modules/'. $moduleDirName .'/header.php'; + global $xoopsUser; + + $this->getImageDim(); + + $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); + $imagesHandler = $helper->getHandler('Images'); + $imagesObj = $imagesHandler->create(); + // Set Vars + $imagesObj->setVar('img_title', $this->imageNicename); + $imagesObj->setVar('img_desc', ''); + $imagesObj->setVar('img_name', $this->imageName); + $imagesObj->setVar('img_namelarge', $this->imageNameLarge); + $imagesObj->setVar('img_nameorig', $this->imageNameOrig); + $imagesObj->setVar('img_mimetype', $this->imageMimetype); + $imagesObj->setVar('img_size', $this->imageSize); + $imagesObj->setVar('img_resx', $this->imageWidth); + $imagesObj->setVar('img_resy', $this->imageHeight); + $imagesObj->setVar('img_albid', $this->claims->cat); + $imagesObj->setVar('img_state', $this->permUseralbum); + $imagesObj->setVar('img_date', time()); + $imagesObj->setVar('img_submitter', $xoopsUser->id()); + $imagesObj->setVar('img_ip', '-'); + // Insert Data + if ($imagesHandler->insert($imagesObj)) { + $this->imageId = $imagesHandler->getInsertId; + return true; + } + return false; + } + + private function getImageDim () { + + switch ($this->imageMimetype) { + case'image/png': + $img = imagecreatefrompng($this->imagePath); + break; + case'image/jpeg': + $img = imagecreatefromjpeg($this->imagePath); + break; + case'image/gif': + $img = imagecreatefromgif($this->imagePath); + break; + default: + $this->imageWidth = 0; + $this->imageHeight = 0; + return 'Unsupported format'; + } + $this->imageWidth = imagesx($img); + $this->imageHeight = imagesy($img); + + imagedestroy($img); + + return true; + } + + /** + * resize image if size exceed given width/height + * @param string $endfile + * @param int $max_width + * @param int $max_height + * @return string|boolean + */ +/* private function resizeImage_sav($endfile, $max_width, $max_height){ + // check file extension + switch ($this->imageMimetype) { + case'image/png': + $img = imagecreatefrompng($this->imagePath); + + break; + case'image/jpeg': + $img = imagecreatefromjpeg($this->imagePath); + break; + case'image/gif': + $img = imagecreatefromgif($this->imagePath); + break; + default: + return 'Unsupported format'; + } + + $width = imagesx($img); + $height = imagesy($img); + + if ($width > $max_width || $height > $max_height) { + // recalc image size based on max_width/max_height + if ($width > $height) { + if ($width < $max_width) { + $new_width = $width; + } else { + $new_width = $max_width; + $divisor = $width / $new_width; + $new_height = floor($height / $divisor); + } + } else if($height < $max_height){ + $new_height = $height; + } else { + $new_height = $max_height; + $divisor = $height / $new_height; + $new_width = floor($width / $divisor); + } + + // Create a new temporary image. + $tmpimg = imagecreatetruecolor($new_width, $new_height); + imagealphablending($tmpimg, false); + imagesavealpha($tmpimg, true); + + // Copy and resize old image into new image. + imagecopyresampled($tmpimg, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); + + //compressing the file + switch ($this->imageMimetype) { + case'image/png': + imagepng($tmpimg, $endfile, 0); + break; + case'image/jpeg': + imagejpeg($tmpimg, $endfile, 100); + break; + case'image/gif': + imagegif($tmpimg, $endfile); + break; + } + + // release the memory + imagedestroy($tmpimg); + } else { + return 'copy'; + } + imagedestroy($img); + return true; + } */ +} diff --git a/class/Common/Images.php b/class/Common/Images.php new file mode 100644 index 0000000..b66d004 --- /dev/null +++ b/class/Common/Images.php @@ -0,0 +1,227 @@ + - Website: + * @version $Id: 1.0 images.php 1 Mon 2018-03-19 10:04:51Z XOOPS Project (www.xoops.org) $ + */ + +use XoopsModules\Tdmdownloads; + +defined('XOOPS_ROOT_PATH') || die('Restricted access'); + +/** + * Class Object Images + */ +class Images extends \XoopsObject +{ + /** + * Constructor + * + * @param null + */ + public function __construct() + { + $this->initVar('img_id', XOBJ_DTYPE_INT); + $this->initVar('img_title', XOBJ_DTYPE_TXTBOX); + $this->initVar('img_desc', XOBJ_DTYPE_TXTAREA); + $this->initVar('img_name', XOBJ_DTYPE_TXTBOX); + $this->initVar('img_namelarge', XOBJ_DTYPE_TXTBOX); + $this->initVar('img_nameorig', XOBJ_DTYPE_TXTBOX); + $this->initVar('img_mimetype', XOBJ_DTYPE_TXTBOX); + $this->initVar('img_size', XOBJ_DTYPE_INT); + $this->initVar('img_resx', XOBJ_DTYPE_INT); + $this->initVar('img_resy', XOBJ_DTYPE_INT); + $this->initVar('img_downloads', XOBJ_DTYPE_INT); + $this->initVar('img_ratinglikes', XOBJ_DTYPE_INT); + $this->initVar('img_votes', XOBJ_DTYPE_INT); + $this->initVar('img_weight', XOBJ_DTYPE_INT); + $this->initVar('img_albid', XOBJ_DTYPE_INT); + $this->initVar('img_state', XOBJ_DTYPE_INT); + $this->initVar('img_date', XOBJ_DTYPE_INT); + $this->initVar('img_submitter', XOBJ_DTYPE_INT); + $this->initVar('img_ip', XOBJ_DTYPE_TXTAREA); + $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); + } + + /** + * @static function &getInstance + * + * @param null + */ + public static function getInstance() + { + static $instance = false; + if (!$instance) { + $instance = new self(); + } + } + + /** + * The new inserted $Id + * @return inserted id + */ + public function getNewInsertedIdImages() + { + $newInsertedId = $GLOBALS['xoopsDB']->getInsertId(); + return $newInsertedId; + } + + /** + * @public function getForm + * @param bool $action + * @return XoopsThemeForm + */ + public function getFormImages($action = false) + { + $helper = Tdmdownloads\Helper::getInstance(); + if (false === $action) { + $action = $_SERVER['REQUEST_URI']; + } + // Title + $title = $this->isNew() ? sprintf(_CO_WGGALLERY_IMAGE_ADD) : sprintf(_CO_WGGALLERY_IMAGE_EDIT); + // Get Theme Form + xoops_load('XoopsFormLoader'); + $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); + $form->setExtra('enctype="multipart/form-data"'); + // Form Text ImgTitle + $form->addElement(new \XoopsFormText( _CO_WGGALLERY_IMAGE_TITLE, 'img_title', 50, 255, $this->getVar('img_title') )); + // Form editor ImgDesc + $editorConfigs = []; + $editorConfigs['name'] = 'img_desc'; + $editorConfigs['value'] = $this->getVar('img_desc', 'e'); + $editorConfigs['rows'] = 5; + $editorConfigs['cols'] = 40; + $editorConfigs['width'] = '100%'; + $editorConfigs['height'] = '400px'; + $editorConfigs['editor'] = $helper->getConfig('editor'); + $form->addElement(new \XoopsFormEditor(_CO_WGGALLERY_IMAGE_DESC, 'img_desc', $editorConfigs)); + // Form Text ImgName + $form->addElement(new \XoopsFormText(_CO_WGGALLERY_IMAGE_NAME, 'img_name', 50, 255, $this->getVar('img_name')), true); + // Form Text ImgNameLarge + $form->addElement(new \XoopsFormText( _CO_WGGALLERY_IMAGE_NAMELARGE, 'img_namelarge', 50, 255, $this->getVar('img_namelarge') ), true); + // Form Text ImgOrigname + $form->addElement(new \XoopsFormText( _CO_WGGALLERY_IMAGE_NAMEORIG, 'img_nameorig', 50, 255, $this->getVar('img_nameorig') ), true); + // Form Text ImgMimetype + $imgMimetype = $this->isNew() ? '0' : $this->getVar('img_mimetype'); + $form->addElement(new \XoopsFormText(_CO_WGGALLERY_IMAGE_MIMETYPE, 'img_mimetype', 20, 150, $imgMimetype)); + // Form Text ImgSize + $imgSize = $this->isNew() ? '0' : $this->getVar('img_size'); + $form->addElement(new \XoopsFormText(_CO_WGGALLERY_IMAGE_SIZE, 'img_size', 20, 150, $imgSize)); + // Form Text ImgResx + $imgResx = $this->isNew() ? '0' : $this->getVar('img_resx'); + $form->addElement(new \XoopsFormText(_CO_WGGALLERY_IMAGE_RESX, 'img_resx', 20, 150, $imgResx)); + // Form Text ImgResy + $imgResy = $this->isNew() ? '0' : $this->getVar('img_resy'); + $form->addElement(new \XoopsFormText(_CO_WGGALLERY_IMAGE_RESY, 'img_resy', 20, 150, $imgResy)); + // Form Text ImgDownloads + $imgDownloads = $this->isNew() ? '0' : $this->getVar('img_downloads'); + $form->addElement(new \XoopsFormText(_CO_WGGALLERY_IMAGE_DOWNLOADS, 'img_downloads', 20, 150, $imgDownloads)); + // Form Text ImgRatinglikes + $imgRatinglikes = $this->isNew() ? '0' : $this->getVar('img_ratinglikes'); + $form->addElement(new \XoopsFormText(_CO_WGGALLERY_IMAGE_RATINGLIKES, 'img_ratinglikes', 20, 150, $imgRatinglikes)); + // Form Text ImgVotes + $imgVotes = $this->isNew() ? '0' : $this->getVar('img_votes'); + $form->addElement(new \XoopsFormText(_CO_WGGALLERY_IMAGE_VOTES, 'img_votes', 20, 150, $imgVotes)); + // Form Text ImgWeight + $imgWeight = $this->isNew() ? '0' : $this->getVar('img_weight'); + $form->addElement(new \XoopsFormText(_CO_WGGALLERY_IMAGE_WEIGHT, 'img_weight', 20, 150, $imgWeight)); + // Form Table albums + $albumsHandler = $helper->getHandler('Albums'); + $imgAlbidSelect = new \XoopsFormSelect(_CO_WGGALLERY_IMAGE_ALBID, 'img_albid', $this->getVar('img_albid')); + $imgAlbidSelect->addOptionArray($albumsHandler->getList()); + $form->addElement($imgAlbidSelect, true); + // Images handler + $imagesHandler = $helper->getHandler('Images'); + // Form Select Images + $imgStateSelect = new \XoopsFormSelect(_CO_WGGALLERY_IMAGE_STATE, 'img_state', $this->getVar('img_state')); + $imgStateSelect->addOption('Empty'); + $imgStateSelect->addOptionArray($imagesHandler->getList()); + $form->addElement($imgStateSelect, true); + // Form Text Date Select ImgDate + $imgDate = $this->isNew() ? 0 : $this->getVar('img_date'); + $form->addElement(new \XoopsFormTextDateSelect(_CO_WGGALLERY_DATE, 'img_date', '', $imgDate)); + // Form Select User ImgSubmitter + $form->addElement(new \XoopsFormSelectUser(_CO_WGGALLERY_SUBMITTER, 'img_submitter', false, $this->getVar('img_submitter'))); + // Form Text ImgIp + $form->addElement(new \XoopsFormText(_CO_WGGALLERY_IMAGE_IP, 'img_ip', 50, 255, $this->getVar('img_ip'))); + // To Save + $form->addElement(new \XoopsFormHidden('op', 'save')); + $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); + return $form; + } + + /** + * Get Values + * @param null $keys + * @param null $format + * @param null $maxDepth + * @return array + */ + public function getValuesImages($keys = null, $format = null, $maxDepth = null) + { + $helper = Tdmdownloads\Helper::getInstance(); + $ret = $this->getValues($keys, $format, $maxDepth); + $ret['id'] = $this->getVar('img_id'); + $ret['title'] = $this->getVar('img_title'); + $ret['desc'] = $this->getVar('img_desc', 'n'); + $ret['name'] = $this->getVar('img_name'); + $ret['namelarge'] = $this->getVar('img_namelarge'); + $ret['nameorig'] = $this->getVar('img_nameorig'); + $ret['mimetype'] = $this->getVar('img_mimetype'); + $ret['size'] = $this->getVar('img_size'); + $ret['resx'] = $this->getVar('img_resx'); + $ret['resy'] = $this->getVar('img_resy'); + $ret['downloads'] = $this->getVar('img_downloads'); + $ret['ratinglikes'] = $this->getVar('img_ratinglikes'); + $ret['votes'] = $this->getVar('img_votes'); + $ret['weight'] = $this->getVar('img_weight'); + $ret['albid'] = $this->getVar('img_albid'); + //$albums = $helper->getHandler('Albums'); + //$albumsObj = $albums->get($this->getVar('img_albid')); + //if (isset($albumsObj) && is_object($albumsObj)) { + //$ret['alb_name'] = $albumsObj->getVar('alb_name'); + //} + $ret['state'] = $this->getVar('img_state'); + $ret['state_text'] = $helper->getStateText($this->getVar('img_state')); + $ret['date'] = formatTimestamp($this->getVar('img_date'), 's'); + $ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('img_submitter')); + $ret['ip'] = $this->getVar('img_ip'); + $ret['large'] = WGGALLERY_UPLOAD_IMAGE_URL . '/large/' . $this->getVar('img_namelarge'); + $ret['medium'] = WGGALLERY_UPLOAD_IMAGE_URL . '/medium/' . $this->getVar('img_name'); + $ret['thumb'] = WGGALLERY_UPLOAD_IMAGE_URL . '/thumbs/' . $this->getVar('img_name'); + return $ret; + } + + /** + * Returns an array representation of the object + * + * @return array + */ + public function toArrayImages() + { + $ret = []; + $vars = $this->getVars(); + foreach (array_keys($vars) as $var) { + $ret[$var] = $this->getVar('"{$var}"'); + } + return $ret; + } +} diff --git a/class/Common/ImagesHandler.php b/class/Common/ImagesHandler.php new file mode 100644 index 0000000..8497b69 --- /dev/null +++ b/class/Common/ImagesHandler.php @@ -0,0 +1,154 @@ + - Website: + * @version $Id: 1.0 images.php 1 Mon 2018-03-19 10:04:51Z XOOPS Project (www.xoops.org) $ + */ + +use XoopsModules\Tdmdownloads; + +defined('XOOPS_ROOT_PATH') || die('Restricted access'); + + +/** + * Class Object Handler Images + */ +class ImagesHandler extends \XoopsPersistableObjectHandler +{ + /** + * Constructor + * + * @param null|\XoopsDatabase $db + */ + public function __construct(\XoopsDatabase $db = null) + { + parent::__construct($db, 'wggallery_images', Images::class, 'img_id', 'img_name'); + } + + /** + * @param bool $isNew + * + * @return object + */ + public function create($isNew = true) + { + return parent::create($isNew); + } + + /** + * retrieve a field + * + * @param int $i field id + * @param null fields + * @return mixed reference to the {@link Get} object + */ + public function get($i = null, $fields = null) + { + return parent::get($i, $fields); + } + + /** + * get inserted id + * + * @param null + * @return integer reference to the {@link Get} object + */ + public function getInsertId() + { + return $this->db->getInsertId(); + } + + /** + * Get Count Images in the database + * @param int $albId + * @param int $start + * @param int $limit + * @param string $sort + * @param string $order + * @return int + */ + public function getCountImages($albId = 0, $start = 0, $limit = 0, $sort = 'img_id ASC, img_name', $order = 'ASC') + { + $crCountImages = new \CriteriaCompo(); + $crCountImages = $this->getImagesCriteria($crCountImages, $albId, $start, $limit, $sort, $order); + return parent::getCount($crCountImages); + } + + /** + * Get All Images in the database + * @param int $start + * @param int $limit + * @param string $sort + * @param string $order + * @return array + */ + public function getAllImages($start = 0, $limit = 0, $sort = 'img_id ASC, img_name', $order = 'ASC') + { + $crAllImages = new \CriteriaCompo(); + $crAllImages = $this->getImagesCriteria($crAllImages, 0, $start, $limit, $sort, $order); + return parent::getAll($crAllImages); + } + + /** + * Get Criteria Images + * @param $crImages + * @param $albId + * @param int $start + * @param int $limit + * @param string $sort + * @param string $order + * @return int + */ + private function getImagesCriteria($crImages, $albId, $start, $limit, $sort, $order) + { + if (0 < $albId) { + $crImages->add(new \Criteria('img_albid', $albId)); + } + $crImages->setStart($start); + $crImages->setLimit($limit); + $crImages->setSort($sort); + $crImages->setOrder($order); + return $crImages; + } + + /** + * delete all copies of a specific image + * @param $imageName + * @return bool + */ + public function unlinkImages($imageName) + { + unlink(WGGALLERY_UPLOAD_IMAGE_PATH . '/large/' . $imageName); + if (file_exists(WGGALLERY_UPLOAD_IMAGE_PATH . '/large/' . $imageName)) { + return false; + } + unlink(WGGALLERY_UPLOAD_IMAGE_PATH . '/medium/' . $imageName); + if (file_exists(WGGALLERY_UPLOAD_IMAGE_PATH . '/medium/' . $imageName)) { + return false; + } + unlink(WGGALLERY_UPLOAD_IMAGE_PATH . '/thumbs/' . $imageName); + if (file_exists(WGGALLERY_UPLOAD_IMAGE_PATH . '/thumbs/' . $imageName)) { + return false; + } + + return true; + } +} diff --git a/language/english/common.php b/language/english/common.php index 7031ae9..9347e15 100644 --- a/language/english/common.php +++ b/language/english/common.php @@ -122,3 +122,16 @@ define('CO_' . $moduleDirNameUpper . '_FOLDER_YES', 'Folder "%s" exist'); define('CO_' . $moduleDirNameUpper . '_FOLDER_NO', 'Folder "%s" does not exist. Create the specified folder with CHMOD 777.'); + +//Uploader +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGES_UPLOAD', 'Upload Images'); + +// ---------------- Errors ---------------- +define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEIMG_THUMBS', 'Error when creating thumb image: %s'); +define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEIMG_MEDIUM', 'Error when creating medium image: %s'); +define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEWM_MEDIUM', 'Error when adding watermark to medium image: %s (reason: %g)'); +define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEWM_LARGE', 'Error when adding watermark to large image: %s (reason: %g)'); + +// Album buttons +define('CO_' . $moduleDirNameUpper . '_' . 'ALBUM_ADD', 'Add Album'); +define('CO_' . $moduleDirNameUpper . '_' . 'ALBUM_EDIT', 'Edit Album'); diff --git a/templates/tdmdownloads_trigger_uploads.tpl b/templates/tdmdownloads_trigger_uploads.tpl new file mode 100644 index 0000000..3605a27 --- /dev/null +++ b/templates/tdmdownloads_trigger_uploads.tpl @@ -0,0 +1,65 @@ + + \ No newline at end of file diff --git a/templates/tdmdownloads_upload.tpl b/templates/tdmdownloads_upload.tpl new file mode 100644 index 0000000..8e9c345 --- /dev/null +++ b/templates/tdmdownloads_upload.tpl @@ -0,0 +1,88 @@ +<{include file='db:tdmdownloads_header.tpl'}> + +<{if $form}> + <{$form}> +<{/if}> + +<{if $multiupload}> +
 
+ <{includeq file="db:tdmdownloads_trigger_uploads.tpl"}> +

<{$img_albname}>

+
+
<{$smarty.const._IMGMAXSIZE}> <{$img_maxsize}>
+
<{$smarty.const._IMGMAXWIDTH}> <{$img_maxwidth}>
+
<{$smarty.const._IMGMAXHEIGHT}> <{$img_maxheight}>
+ + +<{/if}> +
 
+ + + +<{include file='db:tdmdownloads_footer.tpl'}> diff --git a/upload.php b/upload.php new file mode 100644 index 0000000..b7cc1cf --- /dev/null +++ b/upload.php @@ -0,0 +1,126 @@ + - Website: + */ + +use Xmf\Request; +use XoopsModules\Tdmdownloads; + +include_once __DIR__ . '/header.php'; +// It recovered the value of argument op in URL$ +$op = Request::getString('op', 'form'); +$albId = Request::getInt('alb_id', 0); +// Template +$GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_upload.tpl'; +include_once XOOPS_ROOT_PATH . '/header.php'; + +$GLOBALS['xoopsTpl']->assign('wggallery_icon_url_16', WGGALLERY_ICONS_URL . '/16'); + +// Form Create +if (isset($albId)) { + $albumsObj = $albumsHandler->get($albId); +} else { + $albumsObj = $albumsHandler->create(); +} + +if ($permissionsHandler->permGlobalSubmit()) { + $form = $albumsObj->getFormUploadToAlbum(); + $GLOBALS['xoopsTpl']->assign('form', $form->render()); + + if (0 < $albId) { + $GLOBALS['xoopsTpl']->assign('albId', $albId); + + $albumObj = $albumsHandler->get($albId); + // get config for file type/extenstion + $fileextions = $helper->getConfig('fileext'); + $mimetypes = []; + foreach ($fileextions as $fe) { + switch ($fe) { + case 'jpg': + case 'jpeg': + case 'jpe': + $mimetypes['image/jpeg'] = 'image/jpeg'; + break; + case 'gif': + $mimetypes['image/gif'] = 'image/gif'; + break; + case 'png': + $mimetypes['image/png'] = 'image/png'; + break; + case 'bmp': + $mimetypes['image/bmp'] = 'image/bmp'; + break; + case 'tiff': + case 'tif': + $mimetypes['image/tiff'] = 'image/tiff'; + break; + case 'else': + default: + + break; + } + } + + $allowedfileext = implode("', '", $fileextions); + if ('' !== $allowedfileext) { + $allowedfileext = "'" . $allowedfileext . "'"; + } + $allowedmimetypes = implode("', '", $mimetypes); + if ('' !== $allowedmimetypes) { + $allowedmimetypes = "'" . $allowedmimetypes . "'"; + } + // Define Stylesheet + $xoTheme->addStylesheet(XOOPS_URL . '/media/fine-uploader/fine-uploader-new.css'); + $xoTheme->addStylesheet(XOOPS_URL . '/media/fine-uploader/ManuallyTriggerUploads.css'); + $xoTheme->addStylesheet(XOOPS_URL . '/media/font-awesome/css/font-awesome.min.css'); + $xoTheme->addStylesheet(XOOPS_URL . '/modules/system/css/admin.css'); + // Define scripts + $xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js'); + $xoTheme->addScript('modules/system/js/admin.js'); + $xoTheme->addScript('media/fine-uploader/fine-uploader.js'); + // Define Breadcrumb and tips + $xoopsTpl->assign('multiupload', true); + // echo $helper->getConfig('mimetypes'); + $xoopsTpl->assign('img_maxsize', $helper->getConfig('maxsize')); + $xoopsTpl->assign('img_maxwidth', $helper->getConfig('maxwidth')); + $xoopsTpl->assign('img_maxheight', $helper->getConfig('maxheight')); + $xoopsTpl->assign('img_albname', $albumObj->getVar('alb_name')); + $xoopsTpl->assign('allowedfileext', $albumObj->getVar('allowedfileext')); + $xoopsTpl->assign('allowedmimetypes', $albumObj->getVar('allowedmimetypes')); + $payload = [ + 'aud' => 'ajaxfineupload.php', + 'cat' => $albId, + 'uid' => $xoopsUser instanceof \XoopsUser ? $xoopsUser->id() : 0, + 'handler' => '\XoopsModules\\'. $moduleDirName .'\FineimpuploadHandler', + 'moddir' => $moduleDirName, + ]; + $jwt = \Xmf\Jwt\TokenFactory::build('fineuploader', $payload, 60 * 30); // token good for 30 minutes + $xoopsTpl->assign('jwt', $jwt); + setcookie('jwt', $jwt); + $fineup_debug = 'false'; + if (($xoopsUser instanceof \XoopsUser ? $xoopsUser->isAdmin() : false) + && isset($_REQUEST['FINEUPLOADER_DEBUG'])) { + $fineup_debug = 'true'; + } + $xoopsTpl->assign('fineup_debug', $fineup_debug); + } +} + +// Breadcrumbs +$xoBreadcrumbs[] = ['title' => constant('CO_' . $moduleDirNameUpper . '_IMAGES_UPLOAD')]; +include __DIR__ . '/footer.php'; diff --git a/xoops_version.php b/xoops_version.php index 13cbed4..5ccc3a2 100644 --- a/xoops_version.php +++ b/xoops_version.php @@ -178,6 +178,9 @@ ['file' => $moduleDirName . '_viewcat.tpl', 'description' => ''], ['file' => $moduleDirName . '_liste.tpl', 'description' => ''], ['file' => $moduleDirName . '_rss.tpl', 'description' => ''], + //uploads + ['file' => $moduleDirName . '_trigger_uploads.tpl', 'description' => ''], + ['file' => $moduleDirName . '_upload.tpl', 'description' => ''], ]; // ------------------- Help files ------------------- // From 182eea54c411c5eeac2e3c344e5645b9c027f98c Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sat, 12 Jan 2019 11:12:46 -0500 Subject: [PATCH 02/62] updates --- admin/category.php | 8 +-- admin/downloads.php | 3 + class/Common/FineimpuploadHandler.php | 6 +- class/Common/Images.php | 79 +++++++++++---------- class/Common/ImagesHandler.php | 33 +++------ class/Downloads.php | 14 ++-- class/Form/UploadForm.php | 99 +++++++++++++++++++++++++++ class/Form/index.html | 1 + include/common.php | 2 +- language/english/admin.php | 2 + upload.php | 31 +++++---- 11 files changed, 187 insertions(+), 91 deletions(-) create mode 100644 class/Form/UploadForm.php create mode 100644 class/Form/index.html diff --git a/admin/category.php b/admin/category.php index 92b2dca..c322bb3 100644 --- a/admin/category.php +++ b/admin/category.php @@ -327,10 +327,10 @@ $obj->setVar('cat_title', \Xmf\Request::getString('cat_title', '', 'POST')); //$_POST['cat_title']); $obj->setVar('cat_description_main', \Xmf\Request::getString('cat_description_main', '', 'POST')); //$_POST['cat_description_main']); $obj->setVar('cat_weight', \Xmf\Request::getInt('cat_weight', 0, 'POST')); //$_POST["cat_weight"]); - if (0 === \Xmf\Request::getInt('cat_weight', 0, 'REQUEST')) { - $erreur = true; - $errorMessage = _AM_TDMDOWNLOADS_ERREUR_WEIGHT . '
'; - } +// if (0 === \Xmf\Request::getInt('cat_weight', 0, 'REQUEST')) { +// $erreur = true; +// $errorMessage = _AM_TDMDOWNLOADS_ERREUR_WEIGHT . '
'; +// } if (\Xmf\Request::hasVar('cat_cid', 'REQUEST')) { if ($cat_cid === \Xmf\Request::getInt('cat_pid', 0, 'POST')) { $erreur = true; diff --git a/admin/downloads.php b/admin/downloads.php index 54ba70c..88d39b4 100644 --- a/admin/downloads.php +++ b/admin/downloads.php @@ -43,6 +43,9 @@ $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); if (1 == $statusMenu) { $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_NEW, 'downloads.php?op=new_downloads', 'add'); + + $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_NEW_MULTIUPLOAD, '../upload.php?op=list&alb_id=' . $albId, 'add'); + if (0 == $downloads_waiting) { $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_WAIT, 'downloads.php?op=list&statut_display=0', 'add'); } else { diff --git a/class/Common/FineimpuploadHandler.php b/class/Common/FineimpuploadHandler.php index 1667419..f6d2ead 100644 --- a/class/Common/FineimpuploadHandler.php +++ b/class/Common/FineimpuploadHandler.php @@ -106,7 +106,7 @@ protected function storeUploadedFile($target, $mimeType, $uid) { include_once XOOPS_ROOT_PATH .'/modules/'. $moduleDirName .'/header.php'; include_once XOOPS_ROOT_PATH .'/modules/'. $moduleDirName .'/include/resizer.php'; - $this->pathUpload = WGGALLERY_UPLOAD_IMAGE_PATH; + $this->pathUpload = constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH'); $this->permUseralbum = 1; //TODO: handle an option, whether images should be online immediately or not @@ -140,8 +140,8 @@ protected function storeUploadedFile($target, $mimeType, $uid) if ( 0 < $wmId) { $watermarksObj = $watermarksHandler->get($wmId); $wmTarget = $watermarksObj->getVar('wm_target'); - if ( WGGALLERY_WATERMARK_TARGET_A === $wmTarget || WGGALLERY_WATERMARK_TARGET_M === $wmTarget) {$wmTargetM = true;} - if ( WGGALLERY_WATERMARK_TARGET_A === $wmTarget || WGGALLERY_WATERMARK_TARGET_L === $wmTarget) {$wmTargetL = true;} + if ( constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_A') === $wmTarget || constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_M') === $wmTarget) {$wmTargetM = true;} + if ( constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_A') === $wmTarget || constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_L') === $wmTarget) {$wmTargetL = true;} } // create medium image diff --git a/class/Common/Images.php b/class/Common/Images.php index b66d004..25fb7e9 100644 --- a/class/Common/Images.php +++ b/class/Common/Images.php @@ -13,14 +13,10 @@ */ /** - * wgGallery module for xoops - * - * @copyright module for xoops - * @license GPL 2.0 or later - * @since 1.0 - * @min_xoops 2.5.9 + * @copyright 2019 XOOPS Project (https://xoops.org) + * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @link https://xoops.org * @author Wedega - Email: - Website: - * @version $Id: 1.0 images.php 1 Mon 2018-03-19 10:04:51Z XOOPS Project (www.xoops.org) $ */ use XoopsModules\Tdmdownloads; @@ -44,7 +40,7 @@ public function __construct() $this->initVar('img_desc', XOBJ_DTYPE_TXTAREA); $this->initVar('img_name', XOBJ_DTYPE_TXTBOX); $this->initVar('img_namelarge', XOBJ_DTYPE_TXTBOX); - $this->initVar('img_nameorig', XOBJ_DTYPE_TXTBOX); + $this->initVar('img_nameorig', XOBJ_DTYPE_TXTBOX); $this->initVar('img_mimetype', XOBJ_DTYPE_TXTBOX); $this->initVar('img_size', XOBJ_DTYPE_INT); $this->initVar('img_resx', XOBJ_DTYPE_INT); @@ -58,7 +54,7 @@ public function __construct() $this->initVar('img_date', XOBJ_DTYPE_INT); $this->initVar('img_submitter', XOBJ_DTYPE_INT); $this->initVar('img_ip', XOBJ_DTYPE_TXTAREA); - $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); + $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); } /** @@ -75,8 +71,7 @@ public static function getInstance() } /** - * The new inserted $Id - * @return inserted id + * @return int $newInsertedId */ public function getNewInsertedIdImages() { @@ -87,22 +82,24 @@ public function getNewInsertedIdImages() /** * @public function getForm * @param bool $action - * @return XoopsThemeForm + * @return \XoopsThemeForm */ public function getFormImages($action = false) { + $moduleDirName = basename(dirname(dirname(__DIR__))); + $moduleDirNameUpper = mb_strtoupper($moduleDirName); $helper = Tdmdownloads\Helper::getInstance(); if (false === $action) { $action = $_SERVER['REQUEST_URI']; } // Title - $title = $this->isNew() ? sprintf(_CO_WGGALLERY_IMAGE_ADD) : sprintf(_CO_WGGALLERY_IMAGE_EDIT); + $title = $this->isNew() ? sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_ADD')) : sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_EDIT')); // Get Theme Form xoops_load('XoopsFormLoader'); - $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); + $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); $form->setExtra('enctype="multipart/form-data"'); // Form Text ImgTitle - $form->addElement(new \XoopsFormText( _CO_WGGALLERY_IMAGE_TITLE, 'img_title', 50, 255, $this->getVar('img_title') )); + $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_TITLE'), 'img_title', 50, 255, $this->getVar('img_title'))); // Form editor ImgDesc $editorConfigs = []; $editorConfigs['name'] = 'img_desc'; @@ -112,56 +109,56 @@ public function getFormImages($action = false) $editorConfigs['width'] = '100%'; $editorConfigs['height'] = '400px'; $editorConfigs['editor'] = $helper->getConfig('editor'); - $form->addElement(new \XoopsFormEditor(_CO_WGGALLERY_IMAGE_DESC, 'img_desc', $editorConfigs)); + $form->addElement(new \XoopsFormEditor(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_DESC'), 'img_desc', $editorConfigs)); // Form Text ImgName - $form->addElement(new \XoopsFormText(_CO_WGGALLERY_IMAGE_NAME, 'img_name', 50, 255, $this->getVar('img_name')), true); + $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_NAME'), 'img_name', 50, 255, $this->getVar('img_name')), true); // Form Text ImgNameLarge - $form->addElement(new \XoopsFormText( _CO_WGGALLERY_IMAGE_NAMELARGE, 'img_namelarge', 50, 255, $this->getVar('img_namelarge') ), true); + $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_NAMELARGE'), 'img_namelarge', 50, 255, $this->getVar('img_namelarge')), true); // Form Text ImgOrigname - $form->addElement(new \XoopsFormText( _CO_WGGALLERY_IMAGE_NAMEORIG, 'img_nameorig', 50, 255, $this->getVar('img_nameorig') ), true); + $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_NAMEORIG'), 'img_nameorig', 50, 255, $this->getVar('img_nameorig')), true); // Form Text ImgMimetype $imgMimetype = $this->isNew() ? '0' : $this->getVar('img_mimetype'); - $form->addElement(new \XoopsFormText(_CO_WGGALLERY_IMAGE_MIMETYPE, 'img_mimetype', 20, 150, $imgMimetype)); + $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_MIMETYPE'), 'img_mimetype', 20, 150, $imgMimetype)); // Form Text ImgSize $imgSize = $this->isNew() ? '0' : $this->getVar('img_size'); - $form->addElement(new \XoopsFormText(_CO_WGGALLERY_IMAGE_SIZE, 'img_size', 20, 150, $imgSize)); + $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_SIZE'), 'img_size', 20, 150, $imgSize)); // Form Text ImgResx $imgResx = $this->isNew() ? '0' : $this->getVar('img_resx'); - $form->addElement(new \XoopsFormText(_CO_WGGALLERY_IMAGE_RESX, 'img_resx', 20, 150, $imgResx)); + $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_RESX'), 'img_resx', 20, 150, $imgResx)); // Form Text ImgResy $imgResy = $this->isNew() ? '0' : $this->getVar('img_resy'); - $form->addElement(new \XoopsFormText(_CO_WGGALLERY_IMAGE_RESY, 'img_resy', 20, 150, $imgResy)); + $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_RESY'), 'img_resy', 20, 150, $imgResy)); // Form Text ImgDownloads $imgDownloads = $this->isNew() ? '0' : $this->getVar('img_downloads'); - $form->addElement(new \XoopsFormText(_CO_WGGALLERY_IMAGE_DOWNLOADS, 'img_downloads', 20, 150, $imgDownloads)); + $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_DOWNLOADS'), 'img_downloads', 20, 150, $imgDownloads)); // Form Text ImgRatinglikes $imgRatinglikes = $this->isNew() ? '0' : $this->getVar('img_ratinglikes'); - $form->addElement(new \XoopsFormText(_CO_WGGALLERY_IMAGE_RATINGLIKES, 'img_ratinglikes', 20, 150, $imgRatinglikes)); + $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_RATINGLIKES'), 'img_ratinglikes', 20, 150, $imgRatinglikes)); // Form Text ImgVotes $imgVotes = $this->isNew() ? '0' : $this->getVar('img_votes'); - $form->addElement(new \XoopsFormText(_CO_WGGALLERY_IMAGE_VOTES, 'img_votes', 20, 150, $imgVotes)); + $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_VOTES'), 'img_votes', 20, 150, $imgVotes)); // Form Text ImgWeight $imgWeight = $this->isNew() ? '0' : $this->getVar('img_weight'); - $form->addElement(new \XoopsFormText(_CO_WGGALLERY_IMAGE_WEIGHT, 'img_weight', 20, 150, $imgWeight)); + $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WEIGHT'), 'img_weight', 20, 150, $imgWeight)); // Form Table albums $albumsHandler = $helper->getHandler('Albums'); - $imgAlbidSelect = new \XoopsFormSelect(_CO_WGGALLERY_IMAGE_ALBID, 'img_albid', $this->getVar('img_albid')); + $imgAlbidSelect = new \XoopsFormSelect(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_ALBID'), 'img_albid', $this->getVar('img_albid')); $imgAlbidSelect->addOptionArray($albumsHandler->getList()); $form->addElement($imgAlbidSelect, true); // Images handler $imagesHandler = $helper->getHandler('Images'); // Form Select Images - $imgStateSelect = new \XoopsFormSelect(_CO_WGGALLERY_IMAGE_STATE, 'img_state', $this->getVar('img_state')); + $imgStateSelect = new \XoopsFormSelect(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_STATE'), 'img_state', $this->getVar('img_state')); $imgStateSelect->addOption('Empty'); $imgStateSelect->addOptionArray($imagesHandler->getList()); $form->addElement($imgStateSelect, true); // Form Text Date Select ImgDate $imgDate = $this->isNew() ? 0 : $this->getVar('img_date'); - $form->addElement(new \XoopsFormTextDateSelect(_CO_WGGALLERY_DATE, 'img_date', '', $imgDate)); + $form->addElement(new \XoopsFormTextDateSelect(constant('CO_' . $moduleDirNameUpper . '_' . 'DATE'), 'img_date', '', $imgDate)); // Form Select User ImgSubmitter - $form->addElement(new \XoopsFormSelectUser(_CO_WGGALLERY_SUBMITTER, 'img_submitter', false, $this->getVar('img_submitter'))); + $form->addElement(new \XoopsFormSelectUser(constant('CO_' . $moduleDirNameUpper . '_' . 'SUBMITTER'), 'img_submitter', false, $this->getVar('img_submitter'))); // Form Text ImgIp - $form->addElement(new \XoopsFormText(_CO_WGGALLERY_IMAGE_IP, 'img_ip', 50, 255, $this->getVar('img_ip'))); + $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_IP'), 'img_ip', 50, 255, $this->getVar('img_ip'))); // To Save $form->addElement(new \XoopsFormHidden('op', 'save')); $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); @@ -177,14 +174,16 @@ public function getFormImages($action = false) */ public function getValuesImages($keys = null, $format = null, $maxDepth = null) { - $helper = Tdmdownloads\Helper::getInstance(); + $moduleDirName = basename(dirname(dirname(__DIR__))); + $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $helper = Tdmdownloads\Helper::getInstance(); $ret = $this->getValues($keys, $format, $maxDepth); $ret['id'] = $this->getVar('img_id'); $ret['title'] = $this->getVar('img_title'); - $ret['desc'] = $this->getVar('img_desc', 'n'); + $ret['desc'] = $this->getVar('img_desc', 'n'); $ret['name'] = $this->getVar('img_name'); - $ret['namelarge'] = $this->getVar('img_namelarge'); - $ret['nameorig'] = $this->getVar('img_nameorig'); + $ret['namelarge'] = $this->getVar('img_namelarge'); + $ret['nameorig'] = $this->getVar('img_nameorig'); $ret['mimetype'] = $this->getVar('img_mimetype'); $ret['size'] = $this->getVar('img_size'); $ret['resx'] = $this->getVar('img_resx'); @@ -197,16 +196,16 @@ public function getValuesImages($keys = null, $format = null, $maxDepth = null) //$albums = $helper->getHandler('Albums'); //$albumsObj = $albums->get($this->getVar('img_albid')); //if (isset($albumsObj) && is_object($albumsObj)) { - //$ret['alb_name'] = $albumsObj->getVar('alb_name'); + //$ret['alb_name'] = $albumsObj->getVar('alb_name'); //} $ret['state'] = $this->getVar('img_state'); $ret['state_text'] = $helper->getStateText($this->getVar('img_state')); $ret['date'] = formatTimestamp($this->getVar('img_date'), 's'); $ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('img_submitter')); $ret['ip'] = $this->getVar('img_ip'); - $ret['large'] = WGGALLERY_UPLOAD_IMAGE_URL . '/large/' . $this->getVar('img_namelarge'); - $ret['medium'] = WGGALLERY_UPLOAD_IMAGE_URL . '/medium/' . $this->getVar('img_name'); - $ret['thumb'] = WGGALLERY_UPLOAD_IMAGE_URL . '/thumbs/' . $this->getVar('img_name'); + $ret['large'] = constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_URL') . '/large/' . $this->getVar('img_namelarge'); + $ret['medium'] = constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_URL') . '/medium/' . $this->getVar('img_name'); + $ret['thumb'] = constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_URL') . '/thumbs/' . $this->getVar('img_name'); return $ret; } diff --git a/class/Common/ImagesHandler.php b/class/Common/ImagesHandler.php index 8497b69..45eb158 100644 --- a/class/Common/ImagesHandler.php +++ b/class/Common/ImagesHandler.php @@ -13,21 +13,16 @@ */ /** - * wgGallery module for xoops - * - * @copyright module for xoops - * @license GPL 2.0 or later - * @since 1.0 - * @min_xoops 2.5.9 + * @copyright 2019 XOOPS Project (https://xoops.org) + * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @link https://xoops.org * @author Wedega - Email: - Website: - * @version $Id: 1.0 images.php 1 Mon 2018-03-19 10:04:51Z XOOPS Project (www.xoops.org) $ */ use XoopsModules\Tdmdownloads; defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class Object Handler Images */ @@ -43,16 +38,6 @@ public function __construct(\XoopsDatabase $db = null) parent::__construct($db, 'wggallery_images', Images::class, 'img_id', 'img_name'); } - /** - * @param bool $isNew - * - * @return object - */ - public function create($isNew = true) - { - return parent::create($isNew); - } - /** * retrieve a field * @@ -136,16 +121,16 @@ private function getImagesCriteria($crImages, $albId, $start, $limit, $sort, $or */ public function unlinkImages($imageName) { - unlink(WGGALLERY_UPLOAD_IMAGE_PATH . '/large/' . $imageName); - if (file_exists(WGGALLERY_UPLOAD_IMAGE_PATH . '/large/' . $imageName)) { + unlink(constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/large/' . $imageName); + if (file_exists(constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/large/' . $imageName)) { return false; } - unlink(WGGALLERY_UPLOAD_IMAGE_PATH . '/medium/' . $imageName); - if (file_exists(WGGALLERY_UPLOAD_IMAGE_PATH . '/medium/' . $imageName)) { + unlink(constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/medium/' . $imageName); + if (file_exists(constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/medium/' . $imageName)) { return false; } - unlink(WGGALLERY_UPLOAD_IMAGE_PATH . '/thumbs/' . $imageName); - if (file_exists(WGGALLERY_UPLOAD_IMAGE_PATH . '/thumbs/' . $imageName)) { + unlink(constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/thumbs/' . $imageName); + if (file_exists(constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/thumbs/' . $imageName)) { return false; } diff --git a/class/Downloads.php b/class/Downloads.php index b15926a..2196df3 100644 --- a/class/Downloads.php +++ b/class/Downloads.php @@ -254,17 +254,19 @@ public function getForm($donnee = [], $erreur = false, $action = false) $editorConfigs['editor'] = $helper->getConfig('editor'); $form->addElement(new \XoopsFormEditor(_AM_TDMDOWNLOADS_FORMTEXTDOWNLOADS, 'description', $editorConfigs), true); //tag - $dir_tag_ok = false; - if (is_dir(dirname(__DIR__) . '/tag') || is_dir(dirname(dirname(__DIR__)) . '/tag')) { - $dir_tag_ok = true; - } - if ((1 == $helper->getConfig('usetag')) && $dir_tag_ok) { +// $dir_tag_ok = false; +// if (is_dir(dirname(__DIR__) . '/tag') || is_dir(dirname(dirname(__DIR__)) . '/tag')) { +// $dir_tag_ok = true; +// } + if ((1 == $helper->getConfig('usetag')) && class_exists('\XoopsModules\Tag\FormTag')) { $tagId = $this->isNew() ? 0 : $this->getVar('lid'); if (true === $erreur) { $tagId = $donnee['TAG']; } // require_once XOOPS_ROOT_PATH.'/modules/tag/class/formtag.php'; - $form->addElement(new \XoopsModules\Tag\FormTag('tag', 60, 255, $tagId, 0)); +// if (class_exists('\XoopsModules\Tag\FormTag')) { + $form->addElement(new \XoopsModules\Tag\FormTag('tag', 60, 255, $tagId, 0)); +// } } //image diff --git a/class/Form/UploadForm.php b/class/Form/UploadForm.php new file mode 100644 index 0000000..9268eda --- /dev/null +++ b/class/Form/UploadForm.php @@ -0,0 +1,99 @@ + + * @copyright {@link https://xoops.org/ XOOPS Project} + * @license GPL 2.0 or later + * @link https://xoops.org/ + * @since 1.0.0 + */ + +use Xmf\Request; +use XoopsModules\Tdmdownloads; + +require_once dirname(dirname(__DIR__)) . '/include/common.php'; + +$moduleDirName = basename(dirname(dirname(__DIR__))); +//$helper = Tdmdownloads\Helper::getInstance(); +$permHelper = new \Xmf\Module\Helper\Permission(); + +xoops_load('XoopsFormLoader'); + +/** + * Class FieldForm + */ +class FieldForm extends \XoopsThemeForm +{ + public $targetObject; + + /** + * Constructor + * + * @param $target + */ + public function __construct($target) + { + // global $helper; + $this->helper = $target->helper; + $this->targetObject = $target; + + $title = $this->targetObject->isNew() ? sprintf(AM_TDMDOWNLOADS_FIELD_ADD) : sprintf(AM_TDMDOWNLOADS_FIELD_EDIT); + parent::__construct($title, 'form', xoops_getenv('PHP_SELF'), 'post', true); + $this->setExtra('enctype="multipart/form-data"'); + + //include ID field, it's needed so the module knows if it is a new form or an edited form + + $hidden = new \XoopsFormHidden('fid', $this->targetObject->getVar('fid')); + $this->addElement($hidden); + unset($hidden); + + // Fid + $this->addElement(new \XoopsFormLabel(AM_TDMDOWNLOADS_FIELD_FID, $this->targetObject->getVar('fid'), 'fid')); + // Title + $this->addElement(new \XoopsFormText(AM_TDMDOWNLOADS_FIELD_TITLE, 'title', 50, 255, $this->targetObject->getVar('title')), false); + // Img + $img = $this->targetObject->getVar('img') ?: 'blank.png'; + + $uploadDir = '/uploads/tdmdownloads/images/'; + $imgtray = new \XoopsFormElementTray(AM_TDMDOWNLOADS_FIELD_IMG, '
'); + $imgpath = sprintf(AM_TDMDOWNLOADS_FORMIMAGE_PATH, $uploadDir); + $imageselect = new \XoopsFormSelect($imgpath, 'img', $img); + $imageArray = \XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . $uploadDir); + foreach ($imageArray as $image) { + $imageselect->addOption((string)$image, $image); + } + $imageselect->setExtra("onchange='showImgSelected(\"image_img\", \"img\", \"" . $uploadDir . '", "", "' . XOOPS_URL . "\")'"); + $imgtray->addElement($imageselect); + $imgtray->addElement(new \XoopsFormLabel('', "
")); + $fileseltray = new \XoopsFormElementTray('', '
'); + $fileseltray->addElement(new \XoopsFormFile(AM_TDMDOWNLOADS_FORMUPLOAD, 'img', xoops_getModuleOption('maxsize'))); + $fileseltray->addElement(new \XoopsFormLabel('')); + $imgtray->addElement($fileseltray); + $this->addElement($imgtray); + // Weight + $this->addElement(new \XoopsFormText(AM_TDMDOWNLOADS_FIELD_WEIGHT, 'weight', 50, 255, $this->targetObject->getVar('weight')), false); + // Status + $this->addElement(new \XoopsFormText(AM_TDMDOWNLOADS_FIELD_STATUS, 'status', 50, 255, $this->targetObject->getVar('status')), false); + // Search + $this->addElement(new \XoopsFormText(AM_TDMDOWNLOADS_FIELD_SEARCH, 'search', 50, 255, $this->targetObject->getVar('search')), false); + // Status_def + $this->addElement(new \XoopsFormText(AM_TDMDOWNLOADS_FIELD_STATUS_DEF, 'status_def', 50, 255, $this->targetObject->getVar('status_def')), false); + + $this->addElement(new \XoopsFormHidden('op', 'save')); + $this->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); + } +} diff --git a/class/Form/index.html b/class/Form/index.html new file mode 100644 index 0000000..2c5cdd3 --- /dev/null +++ b/class/Form/index.html @@ -0,0 +1 @@ + diff --git a/include/common.php b/include/common.php index f1a5408..2509acb 100644 --- a/include/common.php +++ b/include/common.php @@ -97,5 +97,5 @@ $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16); - $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32); + $GLOBALS['xoopsTpl']->assign('pathModIcon32', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon32); } diff --git a/language/english/admin.php b/language/english/admin.php index 00ad74a..de78c11 100644 --- a/language/english/admin.php +++ b/language/english/admin.php @@ -184,3 +184,5 @@ define('_AM_TDMDOWNLOADS_ERROR_BAD_REMOVE', 'Could not delete %s'); define('_AM_TDMDOWNLOADS_ERROR_NO_PLUGIN', 'Could not load plugin'); define('_AM_TDMDOWNLOADS_NUMBYTES', '%s bytes'); +//multi-upload +define('_AM_TDMDOWNLOADS_DOWNLOADS_NEW_MULTIUPLOAD', 'New Multi-upload'); diff --git a/upload.php b/upload.php index b7cc1cf..e7d81d7 100644 --- a/upload.php +++ b/upload.php @@ -10,13 +10,12 @@ */ /** - * @copyright module for xoops - * @license GPL 2.0 or later - * @package wggallery - * @since 1.0 - * @min_xoops 2.5.9 - * @author Wedega - Email: - Website: - */ + * @copyright XOOPS Project https://xoops.org/ + * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @link https://xoops.org/ + * @min_xoops 2.5.9 + * @author Wedega - Email: - Website: + */ use Xmf\Request; use XoopsModules\Tdmdownloads; @@ -29,23 +28,29 @@ $GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_upload.tpl'; include_once XOOPS_ROOT_PATH . '/header.php'; -$GLOBALS['xoopsTpl']->assign('wggallery_icon_url_16', WGGALLERY_ICONS_URL . '/16'); +$GLOBALS['xoopsTpl']->assign('wggallery_icon_url_16', constant($moduleDirNameUpper . '_' . 'ICONS_URL') . '/16'); + +$categoryHandler = new \XoopsModules\Tdmdownloads\CategoryHandler(); // Form Create if (isset($albId)) { - $albumsObj = $albumsHandler->get($albId); + $categoryObj = $categoryHandler->get($albId); } else { - $albumsObj = $albumsHandler->create(); + $categoryObj = $categoryHandler->create(); } if ($permissionsHandler->permGlobalSubmit()) { - $form = $albumsObj->getFormUploadToAlbum(); +// $form = $categoryObj->getFormUploadToAlbum(); + + $form = new XoopsModules\Tdmdownloads\Form\FieldForm(); +// $form->display(); + $GLOBALS['xoopsTpl']->assign('form', $form->render()); if (0 < $albId) { $GLOBALS['xoopsTpl']->assign('albId', $albId); - $albumObj = $albumsHandler->get($albId); + $albumObj = $categoryHandler->get($albId); // get config for file type/extenstion $fileextions = $helper->getConfig('fileext'); $mimetypes = []; @@ -106,7 +111,7 @@ 'aud' => 'ajaxfineupload.php', 'cat' => $albId, 'uid' => $xoopsUser instanceof \XoopsUser ? $xoopsUser->id() : 0, - 'handler' => '\XoopsModules\\'. $moduleDirName .'\FineimpuploadHandler', + 'handler' => '\XoopsModules\\' . $moduleDirName . '\FineimpuploadHandler', 'moddir' => $moduleDirName, ]; $jwt = \Xmf\Jwt\TokenFactory::build('fineuploader', $payload, 60 * 30); // token good for 30 minutes From 271a0c647a4c9bd7c6559b9defbe6008b7a9bc0f Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sat, 12 Jan 2019 16:45:53 -0500 Subject: [PATCH 03/62] updates --- admin/category.php | 4 ---- class/Category.php | 6 ++++++ class/Common/FineimpuploadHandler.php | 11 +++++++++-- class/Form/UploadForm.php | 2 +- include/common.php | 1 + upload.php | 21 ++++++++++++--------- 6 files changed, 29 insertions(+), 16 deletions(-) diff --git a/admin/category.php b/admin/category.php index c322bb3..de9272e 100644 --- a/admin/category.php +++ b/admin/category.php @@ -327,10 +327,6 @@ $obj->setVar('cat_title', \Xmf\Request::getString('cat_title', '', 'POST')); //$_POST['cat_title']); $obj->setVar('cat_description_main', \Xmf\Request::getString('cat_description_main', '', 'POST')); //$_POST['cat_description_main']); $obj->setVar('cat_weight', \Xmf\Request::getInt('cat_weight', 0, 'POST')); //$_POST["cat_weight"]); -// if (0 === \Xmf\Request::getInt('cat_weight', 0, 'REQUEST')) { -// $erreur = true; -// $errorMessage = _AM_TDMDOWNLOADS_ERREUR_WEIGHT . '
'; -// } if (\Xmf\Request::hasVar('cat_cid', 'REQUEST')) { if ($cat_cid === \Xmf\Request::getInt('cat_pid', 0, 'POST')) { $erreur = true; diff --git a/class/Category.php b/class/Category.php index e66d163..34e1219 100644 --- a/class/Category.php +++ b/class/Category.php @@ -16,6 +16,9 @@ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + +use XoopsModules\Tdmdownloads; + defined('XOOPS_ROOT_PATH') || die('Restricted access'); /** @@ -32,6 +35,9 @@ class Category extends \XoopsObject public function __construct() { parent::__construct(); + /** @var Tdmdownloads\Helper $helper */ + $this->helper = Tdmdownloads\Helper::getInstance(); + $this->permHelper = new \Xmf\Module\Helper\Permission(); $this->initVar('cat_cid', XOBJ_DTYPE_INT, null, false, 5); $this->initVar('cat_pid', XOBJ_DTYPE_INT, null, false, 5); $this->initVar('cat_title', XOBJ_DTYPE_TXTBOX, null, false); diff --git a/class/Common/FineimpuploadHandler.php b/class/Common/FineimpuploadHandler.php index f6d2ead..076d1d5 100644 --- a/class/Common/FineimpuploadHandler.php +++ b/class/Common/FineimpuploadHandler.php @@ -98,8 +98,8 @@ class FineimpuploadHandler extends \SystemFineUploadHandler public function __construct(\stdClass $claims) { parent::__construct($claims); - $this->allowedMimeTypes = ['image/gif', 'image/jpeg', 'image/png']; - $this->allowedExtensions = ['gif', 'jpeg', 'jpg', 'png']; + $this->allowedMimeTypes = array('image/gif', 'image/jpeg', 'image/png', 'application/zip'); + $this->allowedExtensions = array('gif', 'jpeg', 'jpg', 'png', 'zip'); } protected function storeUploadedFile($target, $mimeType, $uid) @@ -230,6 +230,13 @@ private function getImageDim () { case'image/gif': $img = imagecreatefromgif($this->imagePath); break; + + case'application/zip': + $this->imageWidth = 0; + $this->imageHeight = 0; + // $img = imagecreatefromgif($this->imagePath); + break; + default: $this->imageWidth = 0; $this->imageHeight = 0; diff --git a/class/Form/UploadForm.php b/class/Form/UploadForm.php index 9268eda..353fc42 100644 --- a/class/Form/UploadForm.php +++ b/class/Form/UploadForm.php @@ -36,7 +36,7 @@ /** * Class FieldForm */ -class FieldForm extends \XoopsThemeForm +class UploadForm extends \XoopsThemeForm { public $targetObject; diff --git a/include/common.php b/include/common.php index 2509acb..bc19b07 100644 --- a/include/common.php +++ b/include/common.php @@ -56,6 +56,7 @@ define($moduleDirNameUpper . '_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/'); define($moduleDirNameUpper . '_URL', XOOPS_URL . '/modules/' . $moduleDirName . '/'); define($moduleDirNameUpper . '_IMAGE_URL', constant($moduleDirNameUpper . '_URL') . '/assets/images/'); + define($moduleDirNameUpper . '_ICONS_URL', constant($moduleDirNameUpper . '_URL') . '/assets/icons/'); define($moduleDirNameUpper . '_IMAGE_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/assets/images'); define($moduleDirNameUpper . '_ADMIN_URL', constant($moduleDirNameUpper . '_URL') . '/admin/'); define($moduleDirNameUpper . '_ADMIN_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/admin/'); diff --git a/upload.php b/upload.php index e7d81d7..d95d950 100644 --- a/upload.php +++ b/upload.php @@ -39,18 +39,17 @@ $categoryObj = $categoryHandler->create(); } -if ($permissionsHandler->permGlobalSubmit()) { -// $form = $categoryObj->getFormUploadToAlbum(); +//if ($permissionsHandler->permGlobalSubmit()) { + // $form = $categoryObj->getFormUploadToAlbum(); - $form = new XoopsModules\Tdmdownloads\Form\FieldForm(); -// $form->display(); + $form = new \XoopsModules\Tdmdownloads\Form\UploadForm($categoryObj); $GLOBALS['xoopsTpl']->assign('form', $form->render()); if (0 < $albId) { $GLOBALS['xoopsTpl']->assign('albId', $albId); - $albumObj = $categoryHandler->get($albId); + $categoryObj = $categoryHandler->get($albId); // get config for file type/extenstion $fileextions = $helper->getConfig('fileext'); $mimetypes = []; @@ -74,6 +73,10 @@ case 'tif': $mimetypes['image/tiff'] = 'image/tiff'; break; + + case 'zip': + $mimetypes['application/zip'] = 'application/zip'; + case 'else': default: @@ -104,9 +107,9 @@ $xoopsTpl->assign('img_maxsize', $helper->getConfig('maxsize')); $xoopsTpl->assign('img_maxwidth', $helper->getConfig('maxwidth')); $xoopsTpl->assign('img_maxheight', $helper->getConfig('maxheight')); - $xoopsTpl->assign('img_albname', $albumObj->getVar('alb_name')); - $xoopsTpl->assign('allowedfileext', $albumObj->getVar('allowedfileext')); - $xoopsTpl->assign('allowedmimetypes', $albumObj->getVar('allowedmimetypes')); + $xoopsTpl->assign('img_albname', $categoryObj->getVar('alb_name')); + $xoopsTpl->assign('allowedfileext', $categoryObj->getVar('allowedfileext')); + $xoopsTpl->assign('allowedmimetypes', $categoryObj->getVar('allowedmimetypes')); $payload = [ 'aud' => 'ajaxfineupload.php', 'cat' => $albId, @@ -124,7 +127,7 @@ } $xoopsTpl->assign('fineup_debug', $fineup_debug); } -} +//} // Breadcrumbs $xoBreadcrumbs[] = ['title' => constant('CO_' . $moduleDirNameUpper . '_IMAGES_UPLOAD')]; From 1f9dff6317deeebba6c414c17be09ce2ccd170a9 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sat, 12 Jan 2019 18:59:08 -0500 Subject: [PATCH 04/62] updates --- class/Form/UploadForm.php | 3 ++- upload.php | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/class/Form/UploadForm.php b/class/Form/UploadForm.php index 353fc42..3a6944f 100644 --- a/class/Form/UploadForm.php +++ b/class/Form/UploadForm.php @@ -60,7 +60,7 @@ public function __construct($target) $hidden = new \XoopsFormHidden('fid', $this->targetObject->getVar('fid')); $this->addElement($hidden); unset($hidden); - +/* // Fid $this->addElement(new \XoopsFormLabel(AM_TDMDOWNLOADS_FIELD_FID, $this->targetObject->getVar('fid'), 'fid')); // Title @@ -95,5 +95,6 @@ public function __construct($target) $this->addElement(new \XoopsFormHidden('op', 'save')); $this->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); +*/ } } diff --git a/upload.php b/upload.php index d95d950..8d8f8d2 100644 --- a/upload.php +++ b/upload.php @@ -28,7 +28,7 @@ $GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_upload.tpl'; include_once XOOPS_ROOT_PATH . '/header.php'; -$GLOBALS['xoopsTpl']->assign('wggallery_icon_url_16', constant($moduleDirNameUpper . '_' . 'ICONS_URL') . '/16'); +$GLOBALS['xoopsTpl']->assign('tdmdownloads_icon_url_16', constant($moduleDirNameUpper . '_' . 'ICONS_URL') . '/16'); //TODO $categoryHandler = new \XoopsModules\Tdmdownloads\CategoryHandler(); @@ -51,7 +51,7 @@ $categoryObj = $categoryHandler->get($albId); // get config for file type/extenstion - $fileextions = $helper->getConfig('fileext'); + $fileextions = $helper->getConfig('mimetype'); $mimetypes = []; foreach ($fileextions as $fe) { switch ($fe) { @@ -131,4 +131,4 @@ // Breadcrumbs $xoBreadcrumbs[] = ['title' => constant('CO_' . $moduleDirNameUpper . '_IMAGES_UPLOAD')]; -include __DIR__ . '/footer.php'; +//include __DIR__ . '/footer.php'; From 3db44fe41a4e628f6de24bd5b7871d323b988c39 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 13 Jan 2019 06:49:42 -0500 Subject: [PATCH 05/62] updates --- class/Common/FineimpuploadHandler.php | 2 ++ class/Common/ImagesHandler.php | 2 +- class/Form/UploadForm.php | 30 +++++++++++++++------------ header.php | 1 + language/english/admin.php | 2 ++ language/english/common.php | 15 ++++++++++++++ language/english/main.php | 3 +++ templates/tdmdownloads_footer.tpl | 23 ++++++++++++++++++++ templates/tdmdownloads_header.tpl | 8 +++++++ templates/tdmdownloads_upload.tpl | 2 +- upload.php | 8 +++++-- xoops_version.php | 2 ++ 12 files changed, 81 insertions(+), 17 deletions(-) create mode 100644 templates/tdmdownloads_footer.tpl create mode 100644 templates/tdmdownloads_header.tpl diff --git a/class/Common/FineimpuploadHandler.php b/class/Common/FineimpuploadHandler.php index 076d1d5..617169f 100644 --- a/class/Common/FineimpuploadHandler.php +++ b/class/Common/FineimpuploadHandler.php @@ -104,6 +104,8 @@ public function __construct(\stdClass $claims) protected function storeUploadedFile($target, $mimeType, $uid) { + $moduleDirName = basename(dirname(dirname(__DIR__))); + $moduleDirNameUpper = mb_strtoupper($moduleDirName); include_once XOOPS_ROOT_PATH .'/modules/'. $moduleDirName .'/header.php'; include_once XOOPS_ROOT_PATH .'/modules/'. $moduleDirName .'/include/resizer.php'; $this->pathUpload = constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH'); diff --git a/class/Common/ImagesHandler.php b/class/Common/ImagesHandler.php index 45eb158..9ff1a63 100644 --- a/class/Common/ImagesHandler.php +++ b/class/Common/ImagesHandler.php @@ -35,7 +35,7 @@ class ImagesHandler extends \XoopsPersistableObjectHandler */ public function __construct(\XoopsDatabase $db = null) { - parent::__construct($db, 'wggallery_images', Images::class, 'img_id', 'img_name'); + parent::__construct($db, 'tdmdownloads_images', Images::class, 'img_id', 'img_name'); } /** diff --git a/class/Form/UploadForm.php b/class/Form/UploadForm.php index 3a6944f..e0f93cf 100644 --- a/class/Form/UploadForm.php +++ b/class/Form/UploadForm.php @@ -27,7 +27,7 @@ require_once dirname(dirname(__DIR__)) . '/include/common.php'; -$moduleDirName = basename(dirname(dirname(__DIR__))); +//$moduleDirName = basename(dirname(dirname(__DIR__))); //$helper = Tdmdownloads\Helper::getInstance(); $permHelper = new \Xmf\Module\Helper\Permission(); @@ -47,11 +47,13 @@ class UploadForm extends \XoopsThemeForm */ public function __construct($target) { + $moduleDirName = basename(dirname(dirname(__DIR__))); + $moduleDirNameUpper = mb_strtoupper($moduleDirName); // global $helper; $this->helper = $target->helper; $this->targetObject = $target; - $title = $this->targetObject->isNew() ? sprintf(AM_TDMDOWNLOADS_FIELD_ADD) : sprintf(AM_TDMDOWNLOADS_FIELD_EDIT); + $title = $this->targetObject->isNew() ? sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_ADD')) : sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_EDIT')); parent::__construct($title, 'form', xoops_getenv('PHP_SELF'), 'post', true); $this->setExtra('enctype="multipart/form-data"'); @@ -60,41 +62,43 @@ public function __construct($target) $hidden = new \XoopsFormHidden('fid', $this->targetObject->getVar('fid')); $this->addElement($hidden); unset($hidden); -/* + // Fid - $this->addElement(new \XoopsFormLabel(AM_TDMDOWNLOADS_FIELD_FID, $this->targetObject->getVar('fid'), 'fid')); + $this->addElement(new \XoopsFormLabel(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_FID'), $this->targetObject->getVar('fid'), 'fid')); // Title - $this->addElement(new \XoopsFormText(AM_TDMDOWNLOADS_FIELD_TITLE, 'title', 50, 255, $this->targetObject->getVar('title')), false); + $this->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_TITLE'), 'title', 50, 255, $this->targetObject->getVar('title')), false); // Img $img = $this->targetObject->getVar('img') ?: 'blank.png'; $uploadDir = '/uploads/tdmdownloads/images/'; - $imgtray = new \XoopsFormElementTray(AM_TDMDOWNLOADS_FIELD_IMG, '
'); - $imgpath = sprintf(AM_TDMDOWNLOADS_FORMIMAGE_PATH, $uploadDir); + $imgtray = new \XoopsFormElementTray(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_IMG'), '
'); + $imgpath = sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'FORMIMAGE_PATH'), $uploadDir); $imageselect = new \XoopsFormSelect($imgpath, 'img', $img); $imageArray = \XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . $uploadDir); foreach ($imageArray as $image) { $imageselect->addOption((string)$image, $image); } + + $imageselect->setExtra("onchange='showImgSelected(\"image_img\", \"img\", \"" . $uploadDir . '", "", "' . XOOPS_URL . "\")'"); $imgtray->addElement($imageselect); $imgtray->addElement(new \XoopsFormLabel('', "
")); $fileseltray = new \XoopsFormElementTray('', '
'); - $fileseltray->addElement(new \XoopsFormFile(AM_TDMDOWNLOADS_FORMUPLOAD, 'img', xoops_getModuleOption('maxsize'))); + $fileseltray->addElement(new \XoopsFormFile(constant('CO_' . $moduleDirNameUpper . '_' . 'FORMUPLOAD'), 'img', xoops_getModuleOption('maxsize'))); $fileseltray->addElement(new \XoopsFormLabel('')); $imgtray->addElement($fileseltray); $this->addElement($imgtray); // Weight - $this->addElement(new \XoopsFormText(AM_TDMDOWNLOADS_FIELD_WEIGHT, 'weight', 50, 255, $this->targetObject->getVar('weight')), false); + $this->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_WEIGHT'), 'weight', 50, 255, $this->targetObject->getVar('weight')), false); // Status - $this->addElement(new \XoopsFormText(AM_TDMDOWNLOADS_FIELD_STATUS, 'status', 50, 255, $this->targetObject->getVar('status')), false); + $this->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_STATUS'), 'status', 50, 255, $this->targetObject->getVar('status')), false); // Search - $this->addElement(new \XoopsFormText(AM_TDMDOWNLOADS_FIELD_SEARCH, 'search', 50, 255, $this->targetObject->getVar('search')), false); + $this->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_SEARCH'), 'search', 50, 255, $this->targetObject->getVar('search')), false); // Status_def - $this->addElement(new \XoopsFormText(AM_TDMDOWNLOADS_FIELD_STATUS_DEF, 'status_def', 50, 255, $this->targetObject->getVar('status_def')), false); + $this->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_STATUS_DEF'), 'status_def', 50, 255, $this->targetObject->getVar('status_def')), false); $this->addElement(new \XoopsFormHidden('op', 'save')); $this->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); -*/ + } } diff --git a/header.php b/header.php index a46f412..44f704d 100644 --- a/header.php +++ b/header.php @@ -17,6 +17,7 @@ require dirname(dirname(__DIR__)) . '/mainfile.php'; $moduleDirName = basename(__DIR__); +$moduleDirNameUpper = mb_strtoupper($moduleDirName); //require_once XOOPS_ROOT_PATH.'/class/pagenav.php'; //require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; diff --git a/language/english/admin.php b/language/english/admin.php index de78c11..77097d7 100644 --- a/language/english/admin.php +++ b/language/english/admin.php @@ -186,3 +186,5 @@ define('_AM_TDMDOWNLOADS_NUMBYTES', '%s bytes'); //multi-upload define('_AM_TDMDOWNLOADS_DOWNLOADS_NEW_MULTIUPLOAD', 'New Multi-upload'); + + diff --git a/language/english/common.php b/language/english/common.php index 9347e15..4108f78 100644 --- a/language/english/common.php +++ b/language/english/common.php @@ -135,3 +135,18 @@ // Album buttons define('CO_' . $moduleDirNameUpper . '_' . 'ALBUM_ADD', 'Add Album'); define('CO_' . $moduleDirNameUpper . '_' . 'ALBUM_EDIT', 'Edit Album'); + +//Uploader +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_ADD', 'Edit Field'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_EDIT', 'Add Field'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_TITLE', 'Title'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_FID', 'ID'); +define('CO_' . $moduleDirNameUpper . '_' . 'FORMIMAGE_PATH', 'Image Path'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_IMG', 'Image Field'); + + + + + + + diff --git a/language/english/main.php b/language/english/main.php index 35adbe4..75955ad 100644 --- a/language/english/main.php +++ b/language/english/main.php @@ -138,3 +138,6 @@ define('_MD_TDMDOWNLOADS_BOOKMARK_TO_BALATARIN', 'Bookmark to Balatarin'); define('_MD_TDMDOWNLOADS_BOOKMARK_TO_GOOGLEPLUS', 'Bookmark to Google Plus'); define('_MD_TDMDOWNLOADS_BOOKMARK_TO_GOOGLEBOOKMARKS', 'Bookmark to Google Bookmarks'); + +//module admin +define('_MD_TDMDOWNLOADS_ADMIN', 'Module Admin'); diff --git a/templates/tdmdownloads_footer.tpl b/templates/tdmdownloads_footer.tpl new file mode 100644 index 0000000..3af2021 --- /dev/null +++ b/templates/tdmdownloads_footer.tpl @@ -0,0 +1,23 @@ +<{if $error}> +
<{$error}>
+<{/if}> +
+<{if $xoops_isadmin}> +
+<{/if}> +
+ <{if $comment_mode == "flat"}> + <{include file="db:system_comments_flat.tpl"}> + <{elseif $comment_mode == "thread"}> + <{include file="db:system_comments_thread.tpl"}> + <{elseif $comment_mode == "nest"}> + <{include file="db:system_comments_nest.tpl"}> + <{/if}> +
+ +
+<{include file='db:system_notification_select.tpl'}> +
+<{if $copyright}> +
<{$copyright}>
+<{/if}> diff --git a/templates/tdmdownloads_header.tpl b/templates/tdmdownloads_header.tpl new file mode 100644 index 0000000..2c70a68 --- /dev/null +++ b/templates/tdmdownloads_header.tpl @@ -0,0 +1,8 @@ +<{if $show_breadcrumbs}> + <{include file='db:tdmdownloads_breadcrumbs.tpl'}> +<{/if}> + +<{if $ads != ''}> +
+<{$ads}>
+<{/if}> diff --git a/templates/tdmdownloads_upload.tpl b/templates/tdmdownloads_upload.tpl index 8e9c345..d44e2ec 100644 --- a/templates/tdmdownloads_upload.tpl +++ b/templates/tdmdownloads_upload.tpl @@ -6,7 +6,7 @@ <{if $multiupload}>
 
- <{includeq file="db:tdmdownloads_trigger_uploads.tpl"}> + <{include file="db:tdmdownloads_trigger_uploads.tpl"}>

<{$img_albname}>

<{$smarty.const._IMGMAXSIZE}> <{$img_maxsize}>
diff --git a/upload.php b/upload.php index 8d8f8d2..1d6a1b3 100644 --- a/upload.php +++ b/upload.php @@ -20,6 +20,9 @@ use Xmf\Request; use XoopsModules\Tdmdownloads; +$moduleDirName = basename(__DIR__); +$moduleDirNameUpper = mb_strtoupper($moduleDirName); + include_once __DIR__ . '/header.php'; // It recovered the value of argument op in URL$ $op = Request::getString('op', 'form'); @@ -43,7 +46,6 @@ // $form = $categoryObj->getFormUploadToAlbum(); $form = new \XoopsModules\Tdmdownloads\Form\UploadForm($categoryObj); - $GLOBALS['xoopsTpl']->assign('form', $form->render()); if (0 < $albId) { @@ -131,4 +133,6 @@ // Breadcrumbs $xoBreadcrumbs[] = ['title' => constant('CO_' . $moduleDirNameUpper . '_IMAGES_UPLOAD')]; -//include __DIR__ . '/footer.php'; +include_once XOOPS_ROOT_PATH .'/footer.php'; + //include __DIR__ . '/footer.php'; + diff --git a/xoops_version.php b/xoops_version.php index a616d4f..c8386e2 100644 --- a/xoops_version.php +++ b/xoops_version.php @@ -181,6 +181,8 @@ //uploads ['file' => $moduleDirName . '_trigger_uploads.tpl', 'description' => ''], ['file' => $moduleDirName . '_upload.tpl', 'description' => ''], + ['file' => $moduleDirName . '_header.tpl', 'description' => ''], + ['file' => $moduleDirName . '_footer.tpl', 'description' => ''], ]; // ------------------- Help files ------------------- // From 1b25d8ef51e32a597b7bcca263367d98d5b50570 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 13 Jan 2019 19:22:59 -0500 Subject: [PATCH 06/62] updates --- admin/category.php | 6 ++---- class/Form/UploadForm.php | 16 ++++++++-------- language/english/common.php | 8 ++++---- templates/tdmdownloads_breadcrumbs.tpl | 12 ++++++++++++ templates/tdmdownloads_upload.tpl | 3 ++- upload.php | 7 ++++++- xoops_version.php | 1 + 7 files changed, 35 insertions(+), 18 deletions(-) create mode 100644 templates/tdmdownloads_breadcrumbs.tpl diff --git a/admin/category.php b/admin/category.php index 9774891..bc499af 100644 --- a/admin/category.php +++ b/admin/category.php @@ -327,11 +327,9 @@ $obj->setVar('cat_pid', \Xmf\Request::getInt('cat_pid', 0, 'POST')); //$_POST['cat_pid']); $obj->setVar('cat_title', \Xmf\Request::getString('cat_title', '', 'POST')); //$_POST['cat_title']); $obj->setVar('cat_description_main', \Xmf\Request::getString('cat_description_main', '', 'POST')); //$_POST['cat_description_main']); -<<<<<<< HEAD - $obj->setVar('cat_weight', \Xmf\Request::getInt('cat_weight', 0, 'POST')); //$_POST["cat_weight"]); -======= $obj->setVar('cat_weight', \Xmf\Request::getInt('cat_weight', 0, 'POST')); ->>>>>>> 601ce31163ec597d3628a3f6a3fcdcd6e045365e + + if (\Xmf\Request::hasVar('cat_cid', 'REQUEST')) { if ($cat_cid === \Xmf\Request::getInt('cat_pid', 0, 'POST')) { $erreur = true; diff --git a/class/Form/UploadForm.php b/class/Form/UploadForm.php index e0f93cf..86ebf58 100644 --- a/class/Form/UploadForm.php +++ b/class/Form/UploadForm.php @@ -88,14 +88,14 @@ public function __construct($target) $fileseltray->addElement(new \XoopsFormLabel('')); $imgtray->addElement($fileseltray); $this->addElement($imgtray); - // Weight - $this->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_WEIGHT'), 'weight', 50, 255, $this->targetObject->getVar('weight')), false); - // Status - $this->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_STATUS'), 'status', 50, 255, $this->targetObject->getVar('status')), false); - // Search - $this->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_SEARCH'), 'search', 50, 255, $this->targetObject->getVar('search')), false); - // Status_def - $this->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_STATUS_DEF'), 'status_def', 50, 255, $this->targetObject->getVar('status_def')), false); +// // Weight +// $this->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_WEIGHT'), 'weight', 50, 255, $this->targetObject->getVar('weight')), false); +// // Status +// $this->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_STATUS'), 'status', 50, 255, $this->targetObject->getVar('status')), false); +// // Search +// $this->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_SEARCH'), 'search', 50, 255, $this->targetObject->getVar('search')), false); +// // Status_def +// $this->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_STATUS_DEF'), 'status_def', 50, 255, $this->targetObject->getVar('status_def')), false); $this->addElement(new \XoopsFormHidden('op', 'save')); $this->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); diff --git a/language/english/common.php b/language/english/common.php index 3d36c2a..6b54e01 100644 --- a/language/english/common.php +++ b/language/english/common.php @@ -145,10 +145,10 @@ define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_IMG', 'Image Field'); define('CO_' . $moduleDirNameUpper . '_' . 'FORMUPLOAD', 'Upload'); -define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_WEIGHT', 'Title'); -define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_STATUS', 'Title'); -define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_SEARCH', 'Title'); -define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_STATUS_DEF', 'Title'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_WEIGHT', 'Weight'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_STATUS', 'Status'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_SEARCH', 'Search'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_STATUS_DEF', 'Status Defi'); diff --git a/templates/tdmdownloads_breadcrumbs.tpl b/templates/tdmdownloads_breadcrumbs.tpl new file mode 100644 index 0000000..5ffdee2 --- /dev/null +++ b/templates/tdmdownloads_breadcrumbs.tpl @@ -0,0 +1,12 @@ + diff --git a/templates/tdmdownloads_upload.tpl b/templates/tdmdownloads_upload.tpl index d44e2ec..50ced5f 100644 --- a/templates/tdmdownloads_upload.tpl +++ b/templates/tdmdownloads_upload.tpl @@ -5,7 +5,8 @@ <{/if}> <{if $multiupload}> -
 
+ + <{*
 
*}> <{include file="db:tdmdownloads_trigger_uploads.tpl"}>

<{$img_albname}>

diff --git a/upload.php b/upload.php index 1d6a1b3..c9df059 100644 --- a/upload.php +++ b/upload.php @@ -31,7 +31,7 @@ $GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_upload.tpl'; include_once XOOPS_ROOT_PATH . '/header.php'; -$GLOBALS['xoopsTpl']->assign('tdmdownloads_icon_url_16', constant($moduleDirNameUpper . '_' . 'ICONS_URL') . '/16'); //TODO +$GLOBALS['xoopsTpl']->assign('tdmdownloads_icon_url_16', constant($moduleDirNameUpper . '_' . 'ICONS_URL') . '16'); //TODO $categoryHandler = new \XoopsModules\Tdmdownloads\CategoryHandler(); @@ -42,6 +42,9 @@ $categoryObj = $categoryHandler->create(); } +$albId = 1; //for testing, comment out later +$xoopsTpl->assign('multiupload', true); + //if ($permissionsHandler->permGlobalSubmit()) { // $form = $categoryObj->getFormUploadToAlbum(); @@ -128,6 +131,8 @@ $fineup_debug = 'true'; } $xoopsTpl->assign('fineup_debug', $fineup_debug); + + $xoopsTpl->assign('multiupload', true); } //} diff --git a/xoops_version.php b/xoops_version.php index fe6d59b..e854aa1 100644 --- a/xoops_version.php +++ b/xoops_version.php @@ -183,6 +183,7 @@ ['file' => $moduleDirName . '_upload.tpl', 'description' => ''], ['file' => $moduleDirName . '_header.tpl', 'description' => ''], ['file' => $moduleDirName . '_footer.tpl', 'description' => ''], + ['file' => $moduleDirName . '_breadcrumbs.tpl', 'description' => ''], ]; // ------------------- Help files ------------------- // From f4bad400e708ccd2b8298a7811089dc7ef108ff8 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Tue, 15 Jan 2019 03:37:47 -0500 Subject: [PATCH 07/62] start on fineuploader --- admin/category.php | 4 +- admin/downloads.php | 2 +- admin/field.php | 4 +- assets/css/blocks.css | 2 +- assets/css/styles.css | 6 +- blocks/tdmdownloads_search.php | 1 + blocks/tdmdownloads_top.php | 11 +- class/Common/FineimpuploadHandler.php | 166 ++++----- class/Common/ImageResizer.php | 314 ++++++++++++++++++ class/Form/UploadForm.php | 77 ++--- class/Utility.php | 5 +- config/imageconfig.php | 46 +++ config/index.html | 1 + docs/changelog.txt | 8 +- header.php | 2 + language/english/blocksadmin.php | 1 - language/english/common.php | 36 +- language/english/help/help.html | 4 +- language/french/admin.php | 1 - language/french/common.php | 46 +++ language/french/help/help.html | 4 +- language/french/modinfo.php | 2 +- language/german/blocksadmin.php | 1 - language/german/changelog.txt | 4 +- language/german/common.php | 51 ++- language/german/help/help.html | 4 +- modfile.php | 2 +- submit.php | 2 +- templates/blocks/tdmdownloads_block_new.tpl | 2 +- .../blocks/tdmdownloads_block_random.tpl | 2 +- .../blocks/tdmdownloads_block_rating.tpl | 2 +- .../tdmdownloads_block_styledefault.tpl | 6 +- templates/blocks/tdmdownloads_block_top.tpl | 2 +- templates/tdmdownloads_breadcrumbs.tpl | 8 +- templates/tdmdownloads_download.tpl | 6 +- templates/tdmdownloads_footer.tpl | 2 +- templates/tdmdownloads_header.tpl | 2 +- templates/tdmdownloads_liste.tpl | 16 +- templates/tdmdownloads_trigger_uploads.tpl | 9 +- templates/tdmdownloads_upload.tpl | 50 ++- templates/tdmdownloads_viewcat.tpl | 64 ++-- upload.php | 55 +-- xoops_version.php | 8 +- 43 files changed, 754 insertions(+), 287 deletions(-) create mode 100644 class/Common/ImageResizer.php create mode 100644 config/imageconfig.php create mode 100644 config/index.html diff --git a/admin/category.php b/admin/category.php index 1059a64..74ab3ea 100644 --- a/admin/category.php +++ b/admin/category.php @@ -304,7 +304,7 @@ redirect_header('category.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); } xoops_cp_header(); - $cat_cid = \Xmf\Request::getInt('cat_cid', 0, 'POST'); + $cat_cid = \Xmf\Request::getInt('cat_cid', 0, 'POST'); if (0 !== $cat_cid) { $obj = $categoryHandler->get($cat_cid); } else { @@ -338,7 +338,7 @@ $obj->setVar('cat_pid', \Xmf\Request::getInt('cat_pid', 0, 'POST')); //$_POST['cat_pid']); $obj->setVar('cat_title', \Xmf\Request::getString('cat_title', '', 'POST')); //$_POST['cat_title']); $obj->setVar('cat_description_main', \Xmf\Request::getString('cat_description_main', '', 'POST')); //$_POST['cat_description_main']); - $obj->setVar('cat_weight', \Xmf\Request::getInt('cat_weight', 0, 'POST')); + $obj->setVar('cat_weight', \Xmf\Request::getInt('cat_weight', 0, 'POST')); if (\Xmf\Request::hasVar('cat_cid', 'REQUEST')) { diff --git a/admin/downloads.php b/admin/downloads.php index e2f45e0..d9d252a 100644 --- a/admin/downloads.php +++ b/admin/downloads.php @@ -627,7 +627,7 @@ $obj->setVar('size', \Xmf\Request::getInt('size', 0, 'POST') . ' ' . \Xmf\Request::getString('type_size', '', 'POST')); // Pour le fichier if (isset($_POST['xoops_upload_file'][0])) { - $uploader = new \XoopsMediaUploader($uploaddir_downloads, $helper->getConfig('mimetype'), $helper->getConfig('maxuploadsize'), null, null); + $uploader = new \XoopsMediaUploader($uploaddir_downloads, $helper->getConfig('mimetypes'), $helper->getConfig('maxuploadsize'), null, null); if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { if ($helper->getConfig('newnamedownload')) { $uploader->setPrefix($helper->getConfig('prefixdownloads')); diff --git a/admin/field.php b/admin/field.php index b57de78..011522d 100644 --- a/admin/field.php +++ b/admin/field.php @@ -206,13 +206,13 @@ $obj->setVar('status_def', \Xmf\Request::getInt('status_def', 0, 'POST')); if (true === $erreur) { - xoops_cp_header(); + xoops_cp_header(); $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); } else { if ($fieldHandler->insert($obj)) { redirect_header('field.php', 1, _AM_TDMDOWNLOADS_REDIRECT_SAVE); } - xoops_cp_header(); + xoops_cp_header(); $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); } $form = $obj->getForm(); diff --git a/assets/css/blocks.css b/assets/css/blocks.css index 80202c5..3092ee1 100644 --- a/assets/css/blocks.css +++ b/assets/css/blocks.css @@ -1,4 +1,4 @@ .endline { clear: both; width: 100%; -} +} diff --git a/assets/css/styles.css b/assets/css/styles.css index 7268a23..9544b9e 100644 --- a/assets/css/styles.css +++ b/assets/css/styles.css @@ -184,12 +184,12 @@ } .tdmdownloads-tag { - margin: 1px; + margin: 1px; padding: 1px; } .tdmdownloads-socialnetwork { - width: 100%; + width: 100%; height: 25px; margin-bottom: 40px; } @@ -200,7 +200,7 @@ } .tdmdownloads-bookmarkme { - width: 100%; + width: 100%; height: 50px; } diff --git a/blocks/tdmdownloads_search.php b/blocks/tdmdownloads_search.php index b359203..d19bf4c 100644 --- a/blocks/tdmdownloads_search.php +++ b/blocks/tdmdownloads_search.php @@ -65,6 +65,7 @@ function b_tdmdownloads_search_show() $criteria->setSort('weight ASC, title'); $criteria->setOrder('ASC'); $downloads_field = $fieldHandler->getAll($criteria); + $fieldNameBase = ''; foreach (array_keys($downloads_field) as $i) { /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ $title_sup = ''; diff --git a/blocks/tdmdownloads_top.php b/blocks/tdmdownloads_top.php index 85f0ce2..a5407d7 100644 --- a/blocks/tdmdownloads_top.php +++ b/blocks/tdmdownloads_top.php @@ -62,7 +62,8 @@ function b_tdmdownloads_top_show($options) $xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $moduleDirName . '/assets/css/blocks.css', null); /** @var \XoopsModules\Tdmdownloads\Utility $utility */ $utility = new \XoopsModules\Tdmdownloads\Utility(); - $helper->loadLanguage('main'); + /** @var \XoopsModules\Tdmdownloads\Helper $helper */ + $helper->loadLanguage('main'); $categories = $utility->getItemIds('tdmdownloads_view', $moduleDirName); $criteria = new \CriteriaCompo(); @@ -127,7 +128,7 @@ function b_tdmdownloads_top_show($options) $block[$i]['blockstyle'] = $blockstyle; } $GLOBALS['xoopsTpl']->assign('tdmblockstyle', $blockstyle); - + $grouppermHandler = xoops_getHandler('groupperm'); $groups = XOOPS_GROUP_ANONYMOUS; if (is_object($GLOBALS['xoopsUser'])) { @@ -137,7 +138,7 @@ function b_tdmdownloads_top_show($options) $perm_modif = $grouppermHandler->checkRight('tdmdownloads_ac', 8, $groups, $mymodule->getVar('mid')) ? true : false; $GLOBALS['xoopsTpl']->assign('perm_submit', $perm_submit); $GLOBALS['xoopsTpl']->assign('perm_modif', $perm_modif); - + return $block; } @@ -191,13 +192,13 @@ function b_tdmdownloads_top_edit($options) $floatSelect->addOption('right', _MB_TDMDOWNLOADS_FLOAT_RIGHT); $form .= _MB_TDMDOWNLOADS_FLOAT . $floatSelect->render() . '
'; $form .= _MB_TDMDOWNLOADS_WHITE . ':
\n"; - $form .= _MB_TDMDOWNLOADS_CHARSDSC . ':
\n"; + $form .= _MB_TDMDOWNLOADS_CHARSDSC . ':
\n"; $styleSelect = new \XoopsFormSelect('', 'options[9]', $options[9]); $styleSelect->addOption('default', 'default'); $styleSelect->addOption('simple1', 'simple1'); $styleSelect->addOption('simple4', 'simple4'); $form .= _MB_TDMDOWNLOADS_BLOCKSTYLE . ': ' . $styleSelect->render() . '
'; - + array_shift($options); array_shift($options); array_shift($options); diff --git a/class/Common/FineimpuploadHandler.php b/class/Common/FineimpuploadHandler.php index 617169f..de0508d 100644 --- a/class/Common/FineimpuploadHandler.php +++ b/class/Common/FineimpuploadHandler.php @@ -40,6 +40,11 @@ use XoopsModules\Tdmdownloads; //class FineImpUploadHandler extends \SystemFineUploadHandler + +/** + * Class FineimpuploadHandler + * @package XoopsModules\Tdmdownloads\Common + */ class FineimpuploadHandler extends \SystemFineUploadHandler { /** @@ -93,47 +98,61 @@ class FineimpuploadHandler extends \SystemFineUploadHandler /** * XoopsFineImUploadHandler constructor. - * @param stdClass $claims claims passed in JWT header + * @param \stdClass $claims claims passed in JWT header */ public function __construct(\stdClass $claims) { parent::__construct($claims); - $this->allowedMimeTypes = array('image/gif', 'image/jpeg', 'image/png', 'application/zip'); - $this->allowedExtensions = array('gif', 'jpeg', 'jpg', 'png', 'zip'); + $this->allowedMimeTypes = ['image/gif', 'image/jpeg', 'image/png', 'application/zip']; + $this->allowedExtensions = ['gif', 'jpeg', 'jpg', 'png', 'zip']; } + /** + * @param $target + * @param $mimeType + * @param $uid + * @return array|bool + */ protected function storeUploadedFile($target, $mimeType, $uid) { $moduleDirName = basename(dirname(dirname(__DIR__))); $moduleDirNameUpper = mb_strtoupper($moduleDirName); include_once XOOPS_ROOT_PATH .'/modules/'. $moduleDirName .'/header.php'; - include_once XOOPS_ROOT_PATH .'/modules/'. $moduleDirName .'/include/resizer.php'; $this->pathUpload = constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH'); + $utility = new \XoopsModules\Tdmdownloads\Utility(); + /** @var \XoopsModules\Tdmdownloads\Helper $helper */ + $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); + +// if ( WGGALLERY_PERM_SUBMITAPPR === $permissionsHandler->permGlobalSubmit()) { +// $this->permUseralbum = WGGALLERY_STATE_APPROVAL_VAL; +// } else { +// $this->permUseralbum = WGGALLERY_STATE_ONLINE_VAL; +// } - $this->permUseralbum = 1; //TODO: handle an option, whether images should be online immediately or not + $this->permUseralbum = 1; //TODO: handle an option, whether images should be online immediately or not $pathParts = pathinfo($this->getName()); $this->imageName = uniqid('img', true) . '.' . strtolower($pathParts['extension']); $this->imageNicename = str_replace(['_', '-'], ' ', $pathParts['filename']); $this->imageNameLarge = uniqid('imgl', true) . '.' . strtolower($pathParts['extension']); - $this->imagePath = $this->pathUpload . '/large/' . $this->imageNameLarge; + $this->imagePath = $this->pathUpload . '/large/' . $this->imageNameLarge; if (false === move_uploaded_file($_FILES[$this->inputName]['tmp_name'], $this->imagePath)) { return false; } - $this->imageNameOrig = $_FILES[$this->inputName]['name']; + $this->imageNameOrig = $_FILES[$this->inputName]['name']; $this->imageMimetype = $_FILES[$this->inputName]['type']; $this->imageSize = $_FILES[$this->inputName]['size']; - $ret = $this->handleImageDB(); + $ret = $this->handleImageDB(); if (false === $ret) { return [ 'error' => sprintf(_FAILSAVEIMG, $this->imageNicename) ]; } - + // load watermark settings $albumObj = $albumsHandler->get($this->claims->cat); $wmId = $albumObj->getVar('alb_wmid'); @@ -145,33 +164,33 @@ protected function storeUploadedFile($target, $mimeType, $uid) if ( constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_A') === $wmTarget || constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_M') === $wmTarget) {$wmTargetM = true;} if ( constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_A') === $wmTarget || constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_L') === $wmTarget) {$wmTargetL = true;} } - + // create medium image // $ret = $this->resizeImage($this->pathUpload . '/medium/' . $this->imageName, $helper->getConfig('maxwidth_medium'), $helper->getConfig('maxheight_medium')); - $ret = resizeImage($this->imagePath, $this->pathUpload . '/medium/' . $this->imageName, $helper->getConfig('maxwidth_medium'), $helper->getConfig('maxheight_medium'), $this->imageMimetype); + $ret = $utility->resizeImage($this->imagePath, $this->pathUpload . '/medium/' . $this->imageName, $helper->getConfig('maxwidth_medium'), $helper->getConfig('maxheight_medium'), $this->imageMimetype); if (false === $ret) { - return ['error' => sprintf(CO_TDMDOWNLOADS_FAILSAVEIMG_MEDIUM, $this->imageNicename)]; + return ['error' => sprintf(constant($moduleDirNameUpper . '_' . 'FAILSAVEIMG_MEDIUM'), $this->imageNicename)]; } if ('copy' === $ret) { - copy($this->pathUpload . '/large/' . $this->imageNameLarge, $this->pathUpload . '/medium/' . $this->imageName); + copy($this->pathUpload . '/large/' . $this->imageNameLarge, $this->pathUpload . '/medium/' . $this->imageName); } - + // create thumb - // $ret = $this->resizeImage($this->pathUpload . '/thumbs/' . $this->imageName, $helper->getConfig('maxwidth_thumbs'), $helper->getConfig('maxheight_thumbs')); - $ret = resizeImage($this->imagePath, $this->pathUpload . '/thumbs/' . $this->imageName, $helper->getConfig('maxwidth_thumbs'), $helper->getConfig('maxheight_thumbs'), $this->imageMimetype); + // $ret = $this->resizeImage($this->pathUpload . '/thumbs/' . $this->imageName, $helper->getConfig('maxwidth_thumbs'), $helper->getConfig('maxheight_thumbs')); + $ret = $utility->resizeImage($this->imagePath, $this->pathUpload . '/thumbs/' . $this->imageName, $helper->getConfig('maxwidth_thumbs'), $helper->getConfig('maxheight_thumbs'), $this->imageMimetype); if (false === $ret) { - return ['error' => sprintf(CO_TDMDOWNLOADS_FAILSAVEIMG_THUMBS, $this->imageNicename)]; + return ['error' => sprintf(constant($moduleDirNameUpper . '_' . 'FAILSAVEIMG_THUMBS'), $this->imageNicename)]; } if ('copy' === $ret) { - copy($this->pathUpload . '/large/' . $this->imageNameLarge, $this->pathUpload . '/thumbs/' . $this->imageName); - } - + copy($this->pathUpload . '/large/' . $this->imageNameLarge, $this->pathUpload . '/thumbs/' . $this->imageName); + } + // add watermark to large image if ( true === $wmTargetL) { $imgWm = $this->pathUpload . '/large/' . $this->imageNameLarge; $resWm = $watermarksHandler->watermarkImage( $wmId, $imgWm, $imgWm ); if ( true !== $resWm) { - return ['error' => sprintf(_MA_TDMDOWNLOADS_FAILSAVEWM_LARGE, $this->imageNicename, $resWm)]; + return ['error' => sprintf(constant($moduleDirNameUpper . '_' . 'FAILSAVEWM_LARGE'), $this->imageNicename, $resWm)]; } } // add watermark to medium image @@ -179,30 +198,33 @@ protected function storeUploadedFile($target, $mimeType, $uid) $imgWm = $this->pathUpload . '/medium/' . $this->imageName; $resWm = $watermarksHandler->watermarkImage( $wmId, $imgWm, $imgWm ); if ( true !== $resWm) { - return ['error' => sprintf(_MA_TDMDOWNLOADS_FAILSAVEWM_MEDIUM, $this->imageNicename, $resWm)]; + return ['error' => sprintf(constant($moduleDirNameUpper . '_' . 'FAILSAVEWM_MEDIUM'), $this->imageNicename, $resWm)]; } } - + return ['success' => true, 'uuid' => $uuid]; } - - - private function handleImageDB () { - include_once XOOPS_ROOT_PATH .'/modules/'. $moduleDirName .'/header.php'; + /** + * @return bool + */ + private function handleImageDB () { + $moduleDirName = basename(dirname(dirname(__DIR__))); + include_once XOOPS_ROOT_PATH .'/modules/'. $moduleDirName .'/header.php'; global $xoopsUser; $this->getImageDim(); - $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); - $imagesHandler = $helper->getHandler('Images'); + $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); +// $imagesHandler = $helper->getHandler('Images'); + $imagesHandler = new \XoopsModules\Tdmdownloads\Common\ImagesHandler(); $imagesObj = $imagesHandler->create(); // Set Vars $imagesObj->setVar('img_title', $this->imageNicename); $imagesObj->setVar('img_desc', ''); $imagesObj->setVar('img_name', $this->imageName); $imagesObj->setVar('img_namelarge', $this->imageNameLarge); - $imagesObj->setVar('img_nameorig', $this->imageNameOrig); + $imagesObj->setVar('img_nameorig', $this->imageNameOrig); $imagesObj->setVar('img_mimetype', $this->imageMimetype); $imagesObj->setVar('img_size', $this->imageSize); $imagesObj->setVar('img_resx', $this->imageWidth); @@ -211,16 +233,19 @@ private function handleImageDB () { $imagesObj->setVar('img_state', $this->permUseralbum); $imagesObj->setVar('img_date', time()); $imagesObj->setVar('img_submitter', $xoopsUser->id()); - $imagesObj->setVar('img_ip', '-'); + $imagesObj->setVar('img_ip', $_SERVER['REMOTE_ADDR']); // Insert Data if ($imagesHandler->insert($imagesObj)) { - $this->imageId = $imagesHandler->getInsertId; + $this->imageId = $imagesHandler->getInsertId(); return true; } return false; } - private function getImageDim () { + /** + * @return bool|string + */ + private function getImageDim () { switch ($this->imageMimetype) { case'image/png': @@ -251,79 +276,4 @@ private function getImageDim () { return true; } - - /** - * resize image if size exceed given width/height - * @param string $endfile - * @param int $max_width - * @param int $max_height - * @return string|boolean - */ -/* private function resizeImage_sav($endfile, $max_width, $max_height){ - // check file extension - switch ($this->imageMimetype) { - case'image/png': - $img = imagecreatefrompng($this->imagePath); - - break; - case'image/jpeg': - $img = imagecreatefromjpeg($this->imagePath); - break; - case'image/gif': - $img = imagecreatefromgif($this->imagePath); - break; - default: - return 'Unsupported format'; - } - - $width = imagesx($img); - $height = imagesy($img); - - if ($width > $max_width || $height > $max_height) { - // recalc image size based on max_width/max_height - if ($width > $height) { - if ($width < $max_width) { - $new_width = $width; - } else { - $new_width = $max_width; - $divisor = $width / $new_width; - $new_height = floor($height / $divisor); - } - } else if($height < $max_height){ - $new_height = $height; - } else { - $new_height = $max_height; - $divisor = $height / $new_height; - $new_width = floor($width / $divisor); - } - - // Create a new temporary image. - $tmpimg = imagecreatetruecolor($new_width, $new_height); - imagealphablending($tmpimg, false); - imagesavealpha($tmpimg, true); - - // Copy and resize old image into new image. - imagecopyresampled($tmpimg, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); - - //compressing the file - switch ($this->imageMimetype) { - case'image/png': - imagepng($tmpimg, $endfile, 0); - break; - case'image/jpeg': - imagejpeg($tmpimg, $endfile, 100); - break; - case'image/gif': - imagegif($tmpimg, $endfile); - break; - } - - // release the memory - imagedestroy($tmpimg); - } else { - return 'copy'; - } - imagedestroy($img); - return true; - } */ } diff --git a/class/Common/ImageResizer.php b/class/Common/ImageResizer.php new file mode 100644 index 0000000..0e65313 --- /dev/null +++ b/class/Common/ImageResizer.php @@ -0,0 +1,314 @@ + - Website: + */ + +trait ImageResizer +{ + + /** + * resize image if size exceed given width/height + * @param $sourcefile + * @param string $endfile + * @param int $max_width + * @param int $max_height + * @param $imageMimetype + * @return string|boolean + */ + + public function resizeImage($sourcefile, $endfile, $max_width, $max_height, $imageMimetype) + { + // check file extension + switch ($imageMimetype) { + case'image/png': + $img = imagecreatefrompng($sourcefile); + break; + case'image/jpeg': + $img = imagecreatefromjpeg($sourcefile); + break; + case'image/gif': + $img = imagecreatefromgif($sourcefile); + break; + default: + return 'Unsupported format'; + } + + $width = imagesx($img); + $height = imagesy($img); + + if ($width > $max_width || $height > $max_height) { + // recalc image size based on max_width/max_height + if ($width > $height) { + if ($width < $max_width) { + $new_width = $width; + } else { + $new_width = $max_width; + $divisor = $width / $new_width; + $new_height = floor($height / $divisor); + } + } else if ($height < $max_height) { + $new_height = $height; + } else { + $new_height = $max_height; + $divisor = $height / $new_height; + $new_width = floor($width / $divisor); + } + + // Create a new temporary image. + $tmpimg = imagecreatetruecolor($new_width, $new_height); + imagealphablending($tmpimg, false); + imagesavealpha($tmpimg, true); + + // Copy and resize old image into new image. + imagecopyresampled($tmpimg, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); + + unlink($endfile); + //compressing the file + switch ($imageMimetype) { + case'image/png': + imagepng($tmpimg, $endfile, 0); + break; + case'image/jpeg': + imagejpeg($tmpimg, $endfile, 100); + break; + case'image/gif': + imagegif($tmpimg, $endfile); + break; + } + + // release the memory + imagedestroy($tmpimg); + } else { + return 'copy'; + } + imagedestroy($img); + return true; + } + + /** + * @param $src_url + * @param $src_mimetype + * @param $dest_url + * @param $dest_w + * @param $dest_h + * @param int $quality + * @return bool + */ + public function resizeAndCrop($src_url, $src_mimetype, $dest_url, $dest_w, $dest_h, $quality = 90) + { + // check file extension + switch ($src_mimetype) { + case 'image/png': + $original = imagecreatefrompng($src_url); + break; + case 'image/jpeg': + $original = imagecreatefromjpeg($src_url); + break; + case 'image/gif': + $original = imagecreatefromgif($src_url); + break; + default: + return 'Unsupported format'; + } + + if (!$original) { + return false; + } + + // GET ORIGINAL IMAGE DIMENSIONS + list($original_w, $original_h) = getimagesize($src_url); + + // RESIZE IMAGE AND PRESERVE PROPORTIONS + $dest_w_resize = $dest_w; + $dest_h_resize = $dest_h; + if ($original_w > $original_h) { + $dest_h_ratio = $dest_h / $original_h; + $dest_w_resize = (int)round($original_w * $dest_h_ratio); + } else { + $dest_w_ratio = $dest_w / $original_w; + $dest_h_resize = (int)round($original_h * $dest_w_ratio); + } + if ($dest_w_resize < $dest_w) { + $dest_h_ratio = $dest_w / $dest_w_resize; + $dest_h_resize = (int)round($dest_h * $dest_h_ratio); + $dest_w_resize = $dest_w; + } + + // CREATE THE PROPORTIONAL IMAGE RESOURCE + $thumb = imagecreatetruecolor($dest_w_resize, $dest_h_resize); + if (!imagecopyresampled($thumb, $original, 0, 0, 0, 0, $dest_w_resize, $dest_h_resize, $original_w, $original_h)) { + return false; + } + + // CREATE THE CENTERED CROPPED IMAGE TO THE SPECIFIED DIMENSIONS + $final = imagecreatetruecolor($dest_w, $dest_h); + + $dest_w_offset = 0; + $dest_h_offset = 0; + if ($dest_w < $dest_w_resize) { + $dest_w_offset = (int)round(($dest_w_resize - $dest_w) / 2); + } else { + $dest_h_offset = (int)round(($dest_h_resize - $dest_h) / 2); + } + + if (!imagecopy($final, $thumb, 0, 0, $dest_w_offset, $dest_h_offset, $dest_w_resize, $dest_h_resize)) { + return false; + } + + // STORE THE FINAL IMAGE - WILL OVERWRITE $dest_url + if (!imagejpeg($final, $dest_url, $quality)) { + return false; + } + return true; + } + + /** + * @param $src_url + * @param $dest_url + * @param $pos + * @param $of + */ + public function mergeImage($src_url, $dest_url, $pos, $of) + { + $dest = imagecreatefromjpeg($dest_url); + $src = imagecreatefromjpeg($src_url); + // ImageCopy ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h ) +// $src = imagecreatefromjpeg($src_url); + if (4 == $of) { + switch ($pos) { + case 1: + imagecopy($dest, $src, 0, 0, 0, 0, 199, 149); //top left + break; + case 2: + imagecopy($dest, $src, 201, 0, 0, 0, 199, 149); //top right + break; + case 3: + imagecopy($dest, $src, 0, 151, 0, 0, 199, 149); //bottom left + break; + case 4: + imagecopy($dest, $src, 201, 151, 0, 0, 199, 149); //bottom right + break; + } + } + if (6 == $of) { + switch ($pos) { + case 1: + imagecopy($dest, $src, 0, 0, 0, 0, 133, 149); //top left + break; + case 2: + imagecopy($dest, $src, 134, 0, 0, 0, 133, 149); //top center + break; + case 3: + imagecopy($dest, $src, 268, 0, 0, 0, 133, 149); //top right + break; + case 4: + imagecopy($dest, $src, 0, 151, 0, 0, 133, 149); //bottom left + break; + case 5: + imagecopy($dest, $src, 134, 151, 0, 0, 133, 149); //bottom center + break; + case 6: + imagecopy($dest, $src, 268, 151, 0, 0, 133, 149); //bottom right + break; + } + } + imagejpeg($dest, $dest_url); + + imagedestroy($src); + imagedestroy($dest); + } + + /** + * resize image if size exceed given width/height + * @param string $endfile + * @param int $max_width + * @param int $max_height + * @return string|boolean + */ + /* private function resizeImageSave($endfile, $max_width, $max_height){ + // check file extension + switch ($this->imageMimetype) { + case'image/png': + $img = imagecreatefrompng($this->imagePath); + + break; + case'image/jpeg': + $img = imagecreatefromjpeg($this->imagePath); + break; + case'image/gif': + $img = imagecreatefromgif($this->imagePath); + break; + default: + return 'Unsupported format'; + } + + $width = imagesx($img); + $height = imagesy($img); + + if ($width > $max_width || $height > $max_height) { + // recalc image size based on max_width/max_height + if ($width > $height) { + if ($width < $max_width) { + $new_width = $width; + } else { + $new_width = $max_width; + $divisor = $width / $new_width; + $new_height = floor($height / $divisor); + } + } else if($height < $max_height){ + $new_height = $height; + } else { + $new_height = $max_height; + $divisor = $height / $new_height; + $new_width = floor($width / $divisor); + } + + // Create a new temporary image. + $tmpimg = imagecreatetruecolor($new_width, $new_height); + imagealphablending($tmpimg, false); + imagesavealpha($tmpimg, true); + + // Copy and resize old image into new image. + imagecopyresampled($tmpimg, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); + + //compressing the file + switch ($this->imageMimetype) { + case'image/png': + imagepng($tmpimg, $endfile, 0); + break; + case'image/jpeg': + imagejpeg($tmpimg, $endfile, 100); + break; + case'image/gif': + imagegif($tmpimg, $endfile); + break; + } + + // release the memory + imagedestroy($tmpimg); + } else { + return 'copy'; + } + imagedestroy($img); + return true; + } */ +} diff --git a/class/Form/UploadForm.php b/class/Form/UploadForm.php index 86ebf58..6083753 100644 --- a/class/Form/UploadForm.php +++ b/class/Form/UploadForm.php @@ -39,66 +39,67 @@ class UploadForm extends \XoopsThemeForm { public $targetObject; + public $helper; /** * Constructor * - * @param $target + * @param \XoopsModules\Tdmdownloads\Category $target */ public function __construct($target) { $moduleDirName = basename(dirname(dirname(__DIR__))); $moduleDirNameUpper = mb_strtoupper($moduleDirName); - // global $helper; + /** @var \XoopsModules\Tdmdownloads\Helper $this->helper */ $this->helper = $target->helper; $this->targetObject = $target; $title = $this->targetObject->isNew() ? sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_ADD')) : sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_EDIT')); - parent::__construct($title, 'form', xoops_getenv('PHP_SELF'), 'post', true); + parent::__construct('', 'form', xoops_getenv('PHP_SELF'), 'post', true); $this->setExtra('enctype="multipart/form-data"'); //include ID field, it's needed so the module knows if it is a new form or an edited form - $hidden = new \XoopsFormHidden('fid', $this->targetObject->getVar('fid')); + $hidden = new \XoopsFormHidden('fid', $this->targetObject->getVar('cat_cid')); $this->addElement($hidden); unset($hidden); - // Fid - $this->addElement(new \XoopsFormLabel(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_FID'), $this->targetObject->getVar('fid'), 'fid')); - // Title - $this->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_TITLE'), 'title', 50, 255, $this->targetObject->getVar('title')), false); - // Img - $img = $this->targetObject->getVar('img') ?: 'blank.png'; - - $uploadDir = '/uploads/tdmdownloads/images/'; - $imgtray = new \XoopsFormElementTray(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_IMG'), '
'); - $imgpath = sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'FORMIMAGE_PATH'), $uploadDir); - $imageselect = new \XoopsFormSelect($imgpath, 'img', $img); - $imageArray = \XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . $uploadDir); - foreach ($imageArray as $image) { - $imageselect->addOption((string)$image, $image); - } + $categoryHandler = new \XoopsModules\Tdmdownloads\CategoryHandler(); + $start = Request::getInt('start', 0); + $catPaginationLimit = $this->helper->getConfig('userpager') ?: 10; + + $criteria = new \CriteriaCompo(); + $criteria->setOrder('DESC'); + $criteria->setLimit($catPaginationLimit); + $criteria->setStart($start); + + $catCount = $categoryHandler->getCount($criteria); + $catArray = $categoryHandler->getAll($criteria); + + // Form Select Category + $categoryIdSelect = new \XoopsFormSelect( constant('CO_' . $moduleDirNameUpper . '_' . 'SELECT'), 'cat_title', $this->targetObject->getVar('cat_cid')); + $categoryIdSelect->setExtra('onchange="submit()"'); +// $categoryIdSelect->addOption(0, ' '); + + foreach(array_keys($catArray) as $i) { + $catName = $catArray[$i]->getVar('cat_title'); + $catPid = $catArray[$i]->getVar('cat_pid'); + if ( 0 < $catPid ) { + $categoryObj = $categoryHandler->get($catPid); + if (is_object( $categoryObj)) { + $catName .= ' (' . $categoryObj->getVar('cat_title') . ')'; + } else { + $catName .= ' (' . constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR_CATPID') . ')'; + } + } + $categoryIdSelect->addOption($catArray[$i]->getVar('cat_cid'), $catName); + } - $imageselect->setExtra("onchange='showImgSelected(\"image_img\", \"img\", \"" . $uploadDir . '", "", "' . XOOPS_URL . "\")'"); - $imgtray->addElement($imageselect); - $imgtray->addElement(new \XoopsFormLabel('', "
")); - $fileseltray = new \XoopsFormElementTray('', '
'); - $fileseltray->addElement(new \XoopsFormFile(constant('CO_' . $moduleDirNameUpper . '_' . 'FORMUPLOAD'), 'img', xoops_getModuleOption('maxsize'))); - $fileseltray->addElement(new \XoopsFormLabel('')); - $imgtray->addElement($fileseltray); - $this->addElement($imgtray); -// // Weight -// $this->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_WEIGHT'), 'weight', 50, 255, $this->targetObject->getVar('weight')), false); -// // Status -// $this->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_STATUS'), 'status', 50, 255, $this->targetObject->getVar('status')), false); -// // Search -// $this->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_SEARCH'), 'search', 50, 255, $this->targetObject->getVar('search')), false); -// // Status_def -// $this->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_STATUS_DEF'), 'status_def', 50, 255, $this->targetObject->getVar('status_def')), false); - - $this->addElement(new \XoopsFormHidden('op', 'save')); - $this->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); + $this->addElement($categoryIdSelect); + unset($categoryCriteria); + $this->addElement(new \XoopsFormHidden('start', 0)); + $this->addElement(new \XoopsFormHidden('limit', 0)); } } diff --git a/class/Utility.php b/class/Utility.php index c9be6b8..e2bef9e 100644 --- a/class/Utility.php +++ b/class/Utility.php @@ -26,6 +26,8 @@ class Utility use Common\FilesManagement; // Files Management Trait + use Common\ImageResizer; // ImageResizer Trait + /** * truncateHtml can truncate a string up to a number of characters while preserving whole words and HTML tags * www.gsdesign.ro/blog/cut-html-string-without-breaking-the-tags @@ -343,9 +345,10 @@ public static function cleanVars(&$global, $key, $default = '', $type = 'int') */ public function getPathTree($mytree, $key, $category_array, $title, $prefix = '') { + /** @var \XoopsObjectTree $mytree */ $categoryParent = $mytree->getAllParent($key); $categoryParent = array_reverse($categoryParent); - $path = ''; + $path = ''; foreach (array_keys($categoryParent) as $j) { /** @var \XoopsModules\Tdmdownloads\Category[] $categoryParent */ $path .= $categoryParent[$j]->getVar($title) . $prefix; diff --git a/config/imageconfig.php b/config/imageconfig.php new file mode 100644 index 0000000..3c26af5 --- /dev/null +++ b/config/imageconfig.php @@ -0,0 +1,46 @@ +loadLanguage('common'); + +// extra module configs +$modversion['config'][] = [ + 'name' => 'imageConfigs', + 'title' => 'CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG', + 'description' => 'CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG_DSC', + 'formtype' => 'line_break', + 'valuetype' => 'textbox', + 'default' => 'head' +]; + +$modversion['config'][] = [ + 'name' => 'imageWidth', + 'title' => 'CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH', + 'description' => 'CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH_DSC', + 'formtype' => 'textbox', + 'valuetype' => 'int', + 'default' => 1200 +]; // =1024/16 + +$modversion['config'][] = [ + 'name' => 'imageHeight', + 'title' => 'CO_' . $moduleDirNameUpper . '_' . 'IMAGE_HEIGHT', + 'description' => 'CO_' . $moduleDirNameUpper . '_' . 'IMAGE_HEIGHT_DSC', + 'formtype' => 'textbox', + 'valuetype' => 'int', + 'default' => 800 +]; // =768/16 + +$modversion['config'][] = [ + 'name' => 'imageUploadPath', + 'title' => 'CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH', + 'description' => 'CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH_DSC', + 'formtype' => 'textbox', + 'valuetype' => 'text', + 'default' => 'uploads/' . $modversion['dirname'] . '/images' +]; + diff --git a/config/index.html b/config/index.html new file mode 100644 index 0000000..990cbd6 --- /dev/null +++ b/config/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/changelog.txt b/docs/changelog.txt index a2701fa..0bdedf7 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -20,6 +20,10 @@ - implemented perm_autoapprove also for modifying on user side (goffy/mage) - added description to preference maxuploadsize (goffy/mage) - rebuild file list in search.php (goffy/mage) +- added external config for images in /config/imageconfig.php (mamba) +- added fineuploader based on Goffy's wggallery (mamba) +- added ImageResizer trait based on Goffy's wggallery (mamba) +
2.0 Alpha 1 [2019-01-05]

@@ -134,7 +138,7 @@ List of improvements: Informations - - See the file "lang_diff.txt" for changes in language. + - See the file "lang_diff.txt" for changes in language. Installation: @@ -182,7 +186,7 @@ List of improvements: Informations: - Adding the suffix "cat_" in all fields of the table "tdmdownloads_cat. - - See the file "lang_diff.txt" for changes in language. + - See the file "lang_diff.txt" for changes in language.
1.10 [11.11.2009]
diff --git a/header.php b/header.php index 44f704d..05b53ff 100644 --- a/header.php +++ b/header.php @@ -27,6 +27,8 @@ /** @var \XoopsModules\Tdmdownloads\Helper $helper */ $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); +$permHelper = new \Xmf\Module\Helper\Permission(); + $modulePath = XOOPS_ROOT_PATH . '/modules/' . $moduleDirName; require __DIR__ . '/include/common.php'; $myts = \MyTextSanitizer::getInstance(); diff --git a/language/english/blocksadmin.php b/language/english/blocksadmin.php index bf10dec..9fc853b 100644 --- a/language/english/blocksadmin.php +++ b/language/english/blocksadmin.php @@ -26,7 +26,6 @@ define('_AM_VISIBLE', 'Visible'); define('_AM_VISIBLEIN', 'Visible In'); define('_AM_ACTION', 'Action'); -define('_AM_TITLE', 'Title'); define('_AM_BCACHETIME', 'Cache time'); define('_AM_ACTIVERIGHTS', 'Module administration rights'); define('_AM_ACCESSRIGHTS', 'Module access rights'); diff --git a/language/english/common.php b/language/english/common.php index 6b54e01..34d2e69 100644 --- a/language/english/common.php +++ b/language/english/common.php @@ -119,12 +119,11 @@ //Menu define('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_MIGRATE', 'Migrate'); - -define('CO_' . $moduleDirNameUpper . '_FOLDER_YES', 'Folder "%s" exist'); -define('CO_' . $moduleDirNameUpper . '_FOLDER_NO', 'Folder "%s" does not exist. Create the specified folder with CHMOD 777.'); +define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_YES', 'Folder "%s" exist'); +define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_NO', 'Folder "%s" does not exist. Create the specified folder with CHMOD 777.'); //Uploader -define('CO_' . $moduleDirNameUpper . '_' . 'IMAGES_UPLOAD', 'Upload Images'); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGES_UPLOAD', 'Upload Files'); // ---------------- Errors ---------------- define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEIMG_THUMBS', 'Error when creating thumb image: %s'); @@ -133,16 +132,16 @@ define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEWM_LARGE', 'Error when adding watermark to large image: %s (reason: %g)'); // Album buttons -define('CO_' . $moduleDirNameUpper . '_' . 'ALBUM_ADD', 'Add Album'); -define('CO_' . $moduleDirNameUpper . '_' . 'ALBUM_EDIT', 'Edit Album'); +define('CO_' . $moduleDirNameUpper . '_' . 'ALBUM_ADD', 'Add Category'); +define('CO_' . $moduleDirNameUpper . '_' . 'ALBUM_EDIT', 'Edit Category'); //Uploader -define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_ADD', 'Edit Field'); -define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_EDIT', 'Add Field'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_ADD', 'Add Field'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_EDIT', 'Edit Field'); define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_TITLE', 'Title'); define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_FID', 'ID'); -define('CO_' . $moduleDirNameUpper . '_' . 'FORMIMAGE_PATH', 'Image Path'); -define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_IMG', 'Image Field'); +define('CO_' . $moduleDirNameUpper . '_' . 'FORMIMAGE_PATH', 'File Path'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_IMG', 'File Field'); define('CO_' . $moduleDirNameUpper . '_' . 'FORMUPLOAD', 'Upload'); define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_WEIGHT', 'Weight'); @@ -150,10 +149,27 @@ define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_SEARCH', 'Search'); define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_STATUS_DEF', 'Status Defi'); +// fine uploader +define('CO_' . $moduleDirNameUpper . '_' . 'FU_SUBMIT', 'Submitting file: '); +define('CO_' . $moduleDirNameUpper . '_' . 'FU_SUBMITTED', 'File successfully checked, please upload'); +define('CO_' . $moduleDirNameUpper . '_' . 'FU_UPLOAD', 'Upload file: '); +define('CO_' . $moduleDirNameUpper . '_' . 'FU_FAILED', 'Errors occurred during uploading the file'); +define('CO_' . $moduleDirNameUpper . '_' . 'FU_SUCCEEDED', 'Successfully uploaded all files'); +define('CO_' . $moduleDirNameUpper . '_' . 'SELECT', 'Select Category'); +define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_CATPID', 'Error: parent category not found'); +//image config +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH', 'Image Display Width'); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH_DSC', 'Display width for image'); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_HEIGHT', 'Image Display Height'); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_HEIGHT_DSC', 'Display height for image'); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG', '--- EXTERNAL Image configuration --- '); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG_DSC', ''); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH', 'Image Upload path'); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH_DSC', 'Path for uploading images'); diff --git a/language/english/help/help.html b/language/english/help/help.html index 2235a47..7a56dd7 100644 --- a/language/english/help/help.html +++ b/language/english/help/help.html @@ -14,7 +14,7 @@

Description

It uses XOOPS permission and group management, thus allowing a great flexibility in use.

Install/uninstall

- No special measures necessary, follow the standard installation process + No special measures necessary, follow the standard installation process extract the /tdmdownloads folder into the ../modules directory. Install the module through Admin -> System Module -> Modules.

Detailed instructions on installing modules are available in the @@ -33,7 +33,7 @@

Operating instructions



Detailed instructions on configuring the access rights for user groups are available in the XOOPS Operations Manual -

+

Tutorial

Not available at the moment. diff --git a/language/french/admin.php b/language/french/admin.php index 5e7d9e0..3b4b31b 100644 --- a/language/french/admin.php +++ b/language/french/admin.php @@ -185,4 +185,3 @@ define('_AM_TDMDOWNLOADS_ERROR_BAD_REMOVE', 'Impossible de supprimer %s'); define('_AM_TDMDOWNLOADS_ERROR_NO_PLUGIN', 'Impossible de charger le plug-in'); define('_AM_TDMDOWNLOADS_NUMBYTES', '%s octets'); -define('_AM_TDMDOWNLOADS_NUMBYTES', '%s octets'); diff --git a/language/french/common.php b/language/french/common.php index 6c8ea6f..0085500 100644 --- a/language/french/common.php +++ b/language/french/common.php @@ -119,3 +119,49 @@ //Menu define('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_MIGRATE', 'Migrate'); +define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_YES', 'Folder "%s" exist'); +define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_NO', 'Folder "%s" does not exist. Create the specified folder with CHMOD 777.'); + +//Uploader +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGES_UPLOAD', 'Upload Files'); + +// ---------------- Errors ---------------- +define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEIMG_THUMBS', 'Error when creating thumb image: %s'); +define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEIMG_MEDIUM', 'Error when creating medium image: %s'); +define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEWM_MEDIUM', 'Error when adding watermark to medium image: %s (reason: %g)'); +define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEWM_LARGE', 'Error when adding watermark to large image: %s (reason: %g)'); + +// Album buttons +define('CO_' . $moduleDirNameUpper . '_' . 'ALBUM_ADD', 'Add Category'); +define('CO_' . $moduleDirNameUpper . '_' . 'ALBUM_EDIT', 'Edit Category'); + +//Uploader +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_ADD', 'Edit Field'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_EDIT', 'Add Field'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_TITLE', 'Title'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_FID', 'ID'); +define('CO_' . $moduleDirNameUpper . '_' . 'FORMIMAGE_PATH', 'File Path'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_IMG', 'File Field'); + +define('CO_' . $moduleDirNameUpper . '_' . 'FORMUPLOAD', 'Upload'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_WEIGHT', 'Weight'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_STATUS', 'Status'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_SEARCH', 'Search'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_STATUS_DEF', 'Status Defi'); + +// fine uploader +define('CO_' . $moduleDirNameUpper . '_' . 'FU_SUBMIT', 'Submitting file: '); +define('CO_' . $moduleDirNameUpper . '_' . 'FU_SUBMITTED', 'File successfully checked, please upload'); +define('CO_' . $moduleDirNameUpper . '_' . 'FU_UPLOAD', 'Upload file: '); +define('CO_' . $moduleDirNameUpper . '_' . 'FU_FAILED', 'Errors occurred during uploading the file'); +define('CO_' . $moduleDirNameUpper . '_' . 'FU_SUCCEEDED', 'Successfully uploaded all files'); + +//image config +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH', 'Image Display Width'); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH_DSC', 'Display width for image'); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_HEIGHT', 'Image Display Height'); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_HEIGHT_DSC', 'Display height for image'); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG', '--- EXTERNAL Image configuration --- '); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG_DSC', ''); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH', 'Image Upload path'); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH_DSC', 'Path for uploading images'); diff --git a/language/french/help/help.html b/language/french/help/help.html index c91835b..4c87319 100644 --- a/language/french/help/help.html +++ b/language/french/help/help.html @@ -14,7 +14,7 @@

Description

Il utilise la permission de XOOPS et la gestion des groupes, permettant ainsi une grande flexibilité dans l'utilisation.

Installation / Désinstallation

- Aucune mesure spéciale n'est nécessaire, suivez la procédure standard d'installation. + Aucune mesure spéciale n'est nécessaire, suivez la procédure standard d'installation. Envoyez le dossier /tdmdownloads dans le répertoire .../modules. Installez le module par l'administration : Admin-> système -> Modules.

Des instructions détaillées sur l'installation de modules sont disponibles dans le @@ -33,7 +33,7 @@

Mode d'emploi



Des instructions détaillées sur la configuration des droits d'accès pour les groupes d'utilisateurs sont disponibles dans le Manuel des opérations de XOOPS -

+

Tutoriel

Non disponible pour le moment. diff --git a/language/french/modinfo.php b/language/french/modinfo.php index 7b81392..11876c5 100644 --- a/language/french/modinfo.php +++ b/language/french/modinfo.php @@ -126,7 +126,7 @@ define('_MI_TDMDOWNLOADS_TIMECACHERSS', 'Temps du cache RSS'); define('_MI_TDMDOWNLOADS_TIMECACHERSSDSC', 'Temps de cache pour les pages RSS en minutes'); define('_MI_TDMDOWNLOADS_LOGORSS', 'Logo du site pour les pages RSS'); -define('_MI_TDMDOWNLOADS_PREFERENCE_BREAK_COMNOTI', 'Commentaires et avis'); +//define('_MI_TDMDOWNLOADS_PREFERENCE_BREAK_COMNOTI', 'Commentaires et avis'); // Notifications define('_MI_TDMDOWNLOADS_GLOBAL_NOTIFY', 'Global'); define('_MI_TDMDOWNLOADS_GLOBAL_NOTIFYDSC', 'Options de notification globales pour les téléchargements .'); diff --git a/language/german/blocksadmin.php b/language/german/blocksadmin.php index 7d5018b..fd5a5e5 100644 --- a/language/german/blocksadmin.php +++ b/language/german/blocksadmin.php @@ -26,7 +26,6 @@ define('_AM_VISIBLE', 'Sichtbar'); define('_AM_VISIBLEIN', 'Sichtbar in'); define('_AM_ACTION', 'Aktion'); -define('_AM_TITLE', 'Titel'); define('_AM_BCACHETIME', 'Cache time'); define('_AM_ACTIVERIGHTS', 'Berechtigungen Modulverwaltung'); define('_AM_ACCESSRIGHTS', 'Berechtigungen Modulzugriffe'); diff --git a/language/german/changelog.txt b/language/german/changelog.txt index 320c486..5e0bc5f 100644 --- a/language/german/changelog.txt +++ b/language/german/changelog.txt @@ -42,7 +42,7 @@ List of improvements: Informations - - See the file "lang_diff.txt" for changes in language. + - See the file "lang_diff.txt" for changes in language. Installation: @@ -91,7 +91,7 @@ List of improvements: Informations: - Adding the suffix "cat_" in all fields of the table "tdmdownloads_cat. - - See the file "lang_diff.txt" for changes in language. + - See the file "lang_diff.txt" for changes in language. ------------------------------------------------- Version: 1.10 diff --git a/language/german/common.php b/language/german/common.php index f514cbc..93ccab7 100644 --- a/language/german/common.php +++ b/language/german/common.php @@ -102,6 +102,51 @@ define('CO_' . $moduleDirNameUpper . '_GENERATE', 'Generate'); define('CO_' . $moduleDirNameUpper . '_FILENAME', 'File Name'); //Menu -define('CO_' . $moduleDirNameUpper . '_ADMENU_MIGRATE', 'Migrate'); -define('CO_' . $moduleDirNameUpper . '_FOLDER_YES', 'Folder "%s" exist'); -define('CO_' . $moduleDirNameUpper . '_FOLDER_NO', 'Folder "%s" does not exist. Create the specified folder with CHMOD 777.'); +define('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_MIGRATE', 'Migrate'); +define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_YES', 'Folder "%s" exist'); +define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_NO', 'Folder "%s" does not exist. Create the specified folder with CHMOD 777.'); + + +//Uploader +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGES_UPLOAD', 'Upload Files'); + +// ---------------- Errors ---------------- +define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEIMG_THUMBS', 'Error when creating thumb image: %s'); +define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEIMG_MEDIUM', 'Error when creating medium image: %s'); +define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEWM_MEDIUM', 'Error when adding watermark to medium image: %s (reason: %g)'); +define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEWM_LARGE', 'Error when adding watermark to large image: %s (reason: %g)'); + +// Album buttons +define('CO_' . $moduleDirNameUpper . '_' . 'ALBUM_ADD', 'Add Category'); +define('CO_' . $moduleDirNameUpper . '_' . 'ALBUM_EDIT', 'Edit Category'); + +//Uploader +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_ADD', 'Edit Field'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_EDIT', 'Add Field'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_TITLE', 'Title'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_FID', 'ID'); +define('CO_' . $moduleDirNameUpper . '_' . 'FORMIMAGE_PATH', 'File Path'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_IMG', 'File Field'); + +define('CO_' . $moduleDirNameUpper . '_' . 'FORMUPLOAD', 'Upload'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_WEIGHT', 'Weight'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_STATUS', 'Status'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_SEARCH', 'Search'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_STATUS_DEF', 'Status Defi'); + +// fine uploader +define('CO_' . $moduleDirNameUpper . '_' . 'FU_SUBMIT', 'Submitting file: '); +define('CO_' . $moduleDirNameUpper . '_' . 'FU_SUBMITTED', 'File successfully checked, please upload'); +define('CO_' . $moduleDirNameUpper . '_' . 'FU_UPLOAD', 'Upload file: '); +define('CO_' . $moduleDirNameUpper . '_' . 'FU_FAILED', 'Errors occurred during uploading the file'); +define('CO_' . $moduleDirNameUpper . '_' . 'FU_SUCCEEDED', 'Successfully uploaded all files'); + +//image config +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH', 'Image Display Width'); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH_DSC', 'Display width for image'); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_HEIGHT', 'Image Display Height'); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_HEIGHT_DSC', 'Display height for image'); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG', '--- EXTERNAL Image configuration --- '); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG_DSC', ''); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH', 'Image Upload path'); +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH_DSC', 'Path for uploading images'); diff --git a/language/german/help/help.html b/language/german/help/help.html index 97cb205..97e4d78 100644 --- a/language/german/help/help.html +++ b/language/german/help/help.html @@ -14,7 +14,7 @@

Description

It uses XOOPS permission and group management, thus allowing a great flexibility in use.

Install/uninstall

- No special measures necessary, follow the standard installation process + No special measures necessary, follow the standard installation process extract the /TDMDownloas folder into the ../modules directory. Install the module through Admin -> System Module -> Modules.

Detailed instructions on installing modules are available in the @@ -33,7 +33,7 @@

Operating instructions



Detailed instructions on configuring the access rights for user groups are available in the XOOPS Operations Manual -

+

Tutorial

Not available at the moment. diff --git a/modfile.php b/modfile.php index d2e4966..8be9254 100644 --- a/modfile.php +++ b/modfile.php @@ -163,7 +163,7 @@ $obj->setVar('size', \Xmf\Request::getInt('size', 0, 'POST') . ' ' . \Xmf\Request::getString('type_size', '', 'POST')); // Pour le fichier if (isset($_POST['xoops_upload_file'][0])) { - $uploader = new \XoopsMediaUploader($uploaddir_downloads, $helper->getConfig('mimetype'), $helper->getConfig('maxuploadsize'), null, null); + $uploader = new \XoopsMediaUploader($uploaddir_downloads, $helper->getConfig('mimetypes'), $helper->getConfig('maxuploadsize'), null, null); if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { if ($helper->getConfig('newnamedownload')) { $uploader->setPrefix($helper->getConfig('prefixdownloads')); diff --git a/submit.php b/submit.php index fd3a49e..0a8cf88 100644 --- a/submit.php +++ b/submit.php @@ -164,7 +164,7 @@ $obj->setVar('size', \Xmf\Request::getString('size', '', 'POST') . ' ' . \Xmf\Request::getString('type_size', '', 'POST')); // Pour le fichier if (isset($_POST['xoops_upload_file'][0])) { - $uploader = new \XoopsMediaUploader($uploaddir_downloads, $helper->getConfig('mimetype'), $helper->getConfig('maxuploadsize'), null, null); + $uploader = new \XoopsMediaUploader($uploaddir_downloads, $helper->getConfig('mimetypes'), $helper->getConfig('maxuploadsize'), null, null); if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { if ($helper->getConfig('newnamedownload')) { $uploader->setPrefix($helper->getConfig('prefixdownloads')); diff --git a/templates/blocks/tdmdownloads_block_new.tpl b/templates/blocks/tdmdownloads_block_new.tpl index b23c662..46bbaea 100644 --- a/templates/blocks/tdmdownloads_block_new.tpl +++ b/templates/blocks/tdmdownloads_block_new.tpl @@ -19,5 +19,5 @@ <{include file='db:tdmdownloads_block_styledefault.tpl' downloads=$downloads}> <{/foreach}> <{/if}> - + diff --git a/templates/blocks/tdmdownloads_block_random.tpl b/templates/blocks/tdmdownloads_block_random.tpl index 619d702..d29d0aa 100644 --- a/templates/blocks/tdmdownloads_block_random.tpl +++ b/templates/blocks/tdmdownloads_block_random.tpl @@ -8,5 +8,5 @@ <{include file='db:tdmdownloads_block_styledefault.tpl' downloads=$downloads}> <{/foreach}> <{/if}> - + diff --git a/templates/blocks/tdmdownloads_block_rating.tpl b/templates/blocks/tdmdownloads_block_rating.tpl index 619d702..d29d0aa 100644 --- a/templates/blocks/tdmdownloads_block_rating.tpl +++ b/templates/blocks/tdmdownloads_block_rating.tpl @@ -8,5 +8,5 @@ <{include file='db:tdmdownloads_block_styledefault.tpl' downloads=$downloads}> <{/foreach}> <{/if}> - + diff --git a/templates/blocks/tdmdownloads_block_styledefault.tpl b/templates/blocks/tdmdownloads_block_styledefault.tpl index 18acd22..d4eb17e 100644 --- a/templates/blocks/tdmdownloads_block_styledefault.tpl +++ b/templates/blocks/tdmdownloads_block_styledefault.tpl @@ -1,8 +1,8 @@

<{if $downloads.inforation}>
diff --git a/templates/blocks/tdmdownloads_block_top.tpl b/templates/blocks/tdmdownloads_block_top.tpl index 619d702..d29d0aa 100644 --- a/templates/blocks/tdmdownloads_block_top.tpl +++ b/templates/blocks/tdmdownloads_block_top.tpl @@ -8,5 +8,5 @@ <{include file='db:tdmdownloads_block_styledefault.tpl' downloads=$downloads}> <{/foreach}> <{/if}> - +
diff --git a/templates/tdmdownloads_breadcrumbs.tpl b/templates/tdmdownloads_breadcrumbs.tpl index 5ffdee2..1722e18 100644 --- a/templates/tdmdownloads_breadcrumbs.tpl +++ b/templates/tdmdownloads_breadcrumbs.tpl @@ -1,12 +1,12 @@ diff --git a/templates/tdmdownloads_download.tpl b/templates/tdmdownloads_download.tpl index e5085e6..4e9c4cd 100644 --- a/templates/tdmdownloads_download.tpl +++ b/templates/tdmdownloads_download.tpl @@ -1,8 +1,8 @@
diff --git a/templates/tdmdownloads_footer.tpl b/templates/tdmdownloads_footer.tpl index 3af2021..b1c1ac9 100644 --- a/templates/tdmdownloads_footer.tpl +++ b/templates/tdmdownloads_footer.tpl @@ -1,5 +1,5 @@ <{if $error}> -
<{$error}>
+
<{$error}>
<{/if}>
<{if $xoops_isadmin}> diff --git a/templates/tdmdownloads_header.tpl b/templates/tdmdownloads_header.tpl index 2c70a68..96d937c 100644 --- a/templates/tdmdownloads_header.tpl +++ b/templates/tdmdownloads_header.tpl @@ -3,6 +3,6 @@ <{/if}> <{if $ads != ''}> -
+
<{$ads}>
<{/if}> diff --git a/templates/tdmdownloads_liste.tpl b/templates/tdmdownloads_liste.tpl index 4ba89fa..4d09807 100644 --- a/templates/tdmdownloads_liste.tpl +++ b/templates/tdmdownloads_liste.tpl @@ -23,14 +23,14 @@ <{foreach item=download from=$search_list}> - <{$download.title}> - + <{$download.title}> + - <{$download.cat}> - + <{$download.cat}> + - <{$download.cat}> - + <{$download.cat}> + <{foreach item=fielddata from=$download.fielddata}> <{$fielddata}> <{/foreach}> @@ -38,7 +38,7 @@ <{$download.rating}> <{$download.hits}> - + <{$smarty.const._MD_TDMDOWNLOADS_SEARCH_DOWNLOAD}><{$download.title}> @@ -49,7 +49,7 @@ <{$smarty.const._EDIT}><{$download.title}> <{/if}> - + <{/foreach}> diff --git a/templates/tdmdownloads_trigger_uploads.tpl b/templates/tdmdownloads_trigger_uploads.tpl index 3605a27..be4ebe2 100644 --- a/templates/tdmdownloads_trigger_uploads.tpl +++ b/templates/tdmdownloads_trigger_uploads.tpl @@ -2,8 +2,13 @@ ====================================================================== --> \ No newline at end of file + diff --git a/templates/tdmdownloads_upload.tpl b/templates/tdmdownloads_upload.tpl index 50ced5f..c435139 100644 --- a/templates/tdmdownloads_upload.tpl +++ b/templates/tdmdownloads_upload.tpl @@ -1,21 +1,21 @@ <{include file='db:tdmdownloads_header.tpl'}> <{if $form}> - <{$form}> + <{$form}> <{/if}> <{if $multiupload}> - - <{*
 
*}> +
 
<{include file="db:tdmdownloads_trigger_uploads.tpl"}> -

<{$img_albname}>

+

<{$categoryname}>

-
<{$smarty.const._IMGMAXSIZE}> <{$img_maxsize}>
+
<{$smarty.const._IMGMAXSIZE}> <{$file_maxsize}>
<{$smarty.const._IMGMAXWIDTH}> <{$img_maxwidth}>
<{$smarty.const._IMGMAXHEIGHT}> <{$img_maxheight}>
\ No newline at end of file diff --git a/class/Utility.php b/class/Utility.php index 7398f83..65e1ff5 100644 --- a/class/Utility.php +++ b/class/Utility.php @@ -343,7 +343,7 @@ public static function cleanVars(&$global, $key, $default = '', $type = 'int') * @param string $prefix * @return string */ - public function getPathTree($mytree, $key, $category_array, $title, $prefix = '') + public static function getPathTree($mytree, $key, $category_array, $title, $prefix = '') { /** @var \XoopsObjectTree $mytree */ $categoryParent = $mytree->getAllParent($key); @@ -375,7 +375,7 @@ public function getPathTree($mytree, $key, $category_array, $title, $prefix = '' * @param bool $lasturl * @return string */ - public function getPathTreeUrl($mytree, $key, $category_array, $title, $prefix = '', $link = false, $order = 'ASC', $lasturl = false) + public static function getPathTreeUrl($mytree, $key, $category_array, $title, $prefix = '', $link = false, $order = 'ASC', $lasturl = false) { global $xoopsModule; $categoryParent = $mytree->getAllParent($key); @@ -424,4 +424,25 @@ public function getPathTreeUrl($mytree, $key, $category_array, $title, $prefix = return $path; } + + /** + * @param $val + * @return float|int + */ + public static function returnBytes($val) + { + switch (mb_substr($val, -1)) { + case 'K': + case 'k': + return (int)$val * 1024; + case 'M': + case 'm': + return (int)$val * 1048576; + case 'G': + case 'g': + return (int)$val * 1073741824; + default: + return $val; + } + } } diff --git a/docs/Update.txt b/docs/Update.txt new file mode 100644 index 0000000..13112fa --- /dev/null +++ b/docs/Update.txt @@ -0,0 +1,11 @@ +Important information for updating a version below 2.0 !!! + +Step: + +1. Connect to your site and go to module administration. +2. Delete the folder "modules/TDMDownloads" +3. Copy the "tdmdownloads" folder (version greater than 2) to folder "modules/" +4. Update the "tdmdownloads" module +5. Go into the preferences of the module "tdmdownloads", choose "Max uploaded files size" and validate them. + +tdmdownloads is now up to date. \ No newline at end of file diff --git a/extra/uploads/index.html b/extra/uploads/index.html new file mode 100644 index 0000000..74b6f45 --- /dev/null +++ b/extra/uploads/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/extra/uploads/tdmdownloads/images/field/size.png b/extra/uploads/tdmdownloads/images/field/size.png index 7f74aa5555ede5e445e776a0c13fc8832195919a..b7a47293e7c9713b1370695939cf8a2bf46285fa 100644 GIT binary patch delta 233 zcmX>kcARN~BnJxv1H;x|=C3ACT!M8Gi-<001BJ|6u?C010qNS#tmY3lRVS3lRZ-WM7d0018iOLqkwd zXm50Hb7*gHAW1_*AaHVTW@&6?004N}ol|F2Q|T5x_ulkEONfA!OK(yY2q02Ii+~i7 zCMqEb5K4$4q1hEt!4XA81RKbphy#v}fQ%JUEDVYY*azexqJNHqqlk*i`{8?|Yu3E? z=FR@K*FNX0^PRKL2fzpnmPj*EHGmAMLLL#|gU7_i;p8qrfeIvW01ybXWFd3?BLM*T zemp!YBESc}00DT@3kU$fO`E_l9Ebl8>Oz@Z0f2-7z;ux~O9+4z06=< z09Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p00esgV8|mQcmRZ%02D^@ zS3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D}NL=VFF>AKrX_0nHe&HG!NkO z%m4tOkrff(gY*4(&JM25&Nhy=4qq+mzXtyzVq)X|<DpKGaQJ>aJVl|9x!Kv};eCNs@5@0DoRYBra6Svp>fO002awfhw>;8}z{# zEWidF!3EsG3;bXU&9EIRU@z1_9W=mEXoiz;4lcq~ zxDGvV5BgyUp1~-*fe8db$Osc*A=-!mVv1NJjtCc-h4>-CNCXm#Bp}I%6j35eku^v$ zQh$n6AXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>Xu_CMttHv6zR;&ZN ziS=X8v3CR#fknUxHUxJlp|(=5QHQ7#Gb=$GgN^mhymh82Uyh-WAnn-~WeXBl@Gub51x8Pkgy$5b#kG3%J;nGcz7Rah#v zDtr}@$_kZAl_r%NDlb&2s-~*ms(%Yr^Hs}KkEvc$eXd4TGgITK3DlOWRjQp(>r)$3 zXQ?}=hpK0&Z&W{|ep&sA23f;Q!%st`QJ}G3IcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya?2D1z#2HOnI z7(B%_ac?{wFUQ;QQA1tBKz~D}VU=N*;e?U7(LAHoMvX=fjA_PP<0Rv4#%;! zuC{HqePL%}7iYJ{uEXw=y_0>qeU1G+2MveW4yzqn9e#7PauhmNI^LSjobEq;#q^fx zFK1ZK5YN~%R|78Dq z|Iq-afF%KE1Brn_fm;Im_iKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$3*&ni zm@mj(aCxE5!hiIIrxvL$5-d8FKum~EIF#@~5Gtq^j3x3DcO{MrdBPpSXCg1rHqnUK zLtH8zPVz`9O?r~-k-Rl|B*inOEaka`C#jIUObtxkn>wBrnsy*W_HW0Wrec-#cqqYFCLW#$!oKatOZ#u3V*gjrsz~!DAy_nvS(#iX1~pe z$~l&+o-57m%(KedkT;y~pa1O=!V=+2Q(!ODWcwE=7E3snl`g?;PX*X>OX6feMEuLErma3QLmkw?X+1j)X z-&VBk_4Y;EFPF_I+q;9dL%E~BJh;4Nr^(LEJ3myURP#>OB6F(@)2{oV%K?xm;_x?s~noduI3P8=g1L-SoYA@fQEq)t)&$-M#aAZ}-Lb_1_lV zesU-M&da;mcPH+xyidGe^g!)F*+boj)qg)*{@mE_+<$7occAmp+(-8Yg@e!jk@b%c zLj{kSkIRM)hU=a(|cFn9-q^@|Tmp zZG5Hu>cHz6uiM7L#vZ=Ocr!6x^j7=r!FSwu9q*&x4^QNLAb%+TX!)`AQ_!dTlMNY@ zlm7$*nDhK&GcDVZAwP0mNklPx#07*qoM6N<$g6MNn8vpqxsqjqBnJxv1H;x|=C3AC2KEw9Usv|WjKa(o zdasVlDljlG%6PgshG?8GJ#|pKxlrc#$K^WF4k9eLj-^?C;*1*Pka%m@wf^ z&BX&-e%I^ocMOj=5I^&k=U+X$&BMu@|97m(@zOop@cfU`!#njNTCAU6Y~hsnx_|S* zUx)u?cbd07u}}EE#%txYAmi(zIhWdb7i|81)9B}sV@rBYChy!E&5$g(;pAtghzN@w z78Ze-tO1eFCTTJ3Tfs2JwSh89a_vtpsPHmgS&g3C;U!>I8yu{hq#MyXV*XKyaEqoPE`yS5!d@A?v*Qeay zMHN2J;Z)iK3|7?=*NBpo#FA92Oz@Z0f2-7z;ux~O9+4z06=< z09Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p00esgV8|mQcmRZ%02D^@ zS3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D}NL=VFF>AKrX_0nHe&HG!NkO z%m4tOkrff(gY*4(&JM25&Nhy=4qq+mzXtyzVq)X|<DpKGaQJ>aJVl|9x!Kv};eCNs@5@0DoRYBra6Svp>fO002awfhw>;8}z{# zEWidF!3EsG3;bXU&9EIRU@z1_9W=mEXoiz;4lcq~ zxDGvV5BgyUp1~-*fe8db$Osc*A=-!mVv1NJjtCc-h4>-CNCXm#Bp}I%6j35eku^v$ zQh$n6AXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>Xu_CMttHv6zR;&ZN ziS=X8v3CR#fknUxHUxJlp|(=5QHQ7#Gb=$GgN^mhymh82Uyh-WAnn-~WeXBl@Gub51x8Pkgy$5b#kG3%J;nGcz7Rah#v zDtr}@$_kZAl_r%NDlb&2s-~*ms(%Yr^Hs}KkEvc$eXd4TGgITK3DlOWRjQp(>r)$3 zXQ?}=hpK0&Z&W{|ep&sA23f;Q!%st`QJ}G3IcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya?2D1z#2HOnI z7(B%_ac?{wFUQ;QQA1tBKz~D}VU=N*;e?U7(LAHoMvX=fjA_PP<0Rv4#%;! zuC{HqePL%}7iYJ{uEXw=y_0>qeU1G+2MveW4yzqn9e#7PauhmNI^LSjobEq;#q^fx zFK1ZK5YN~%R|78Dq z|Iq-afF%KE1Brn_fm;Im_iKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$3*&ni zm@mj(aCxE5!hiIIrxvL$5-d8FKum~EIF#@~5Gtq^j3x3DcO{MrdBPpSXCg1rHqnUK zLtH8zPVz`9O?r~-k-Rl|B*inOEaka`C#jIUObtxkn>wBrnsy*W_HW0Wrec-#cqqYFCLW#$!oKatOZ#u3V*gjrsz~!DAy_nvS(#iX1~pe z$~l&+o-57m%(KedkT;y~pa1O=!V=+2Q(!ODWcwE=7E3snl`g?;PX*X>OX6feMEuLErma3QLmkw?X+1j)X z-&VBk_4Y;EFPF_I+q;9dL%E~BJh;4Nr^(LEJ3myURP#>OB6F(@)2{oV%K?xm;_x?s~noduI3P8=g1L-SoYA@fQEq)t)&$-M#aAZ}-Lb_1_lV zesU-M&da;mcPH+xyidGe^g!)F*+boj)qg)*{@mE_+<$7occAmp+(-8Yg@e!jk@b%c zLj{kSkIRM)hU=a(|cFn9-q^@|Tmp zZG5Hu>cHz6uiM7L#vZ=Ocr!6x^j7=r!FSwu9q*&x4^QNLAb%+TX!)`AQ_!dTlMNY@ zlm7$*nDhK&GcDVZAwGWr;7LS5RCwBqQ?cvXP!PVnCMGc^m861DCo3Xdx>P5JHe|3+ z!NILcgB{wTe}ilPg5uuQtq>5Tql0^?L8)7y@(_#FyoYJLPX5U6hiQB8;N89NKJL4_ z2Z#ulbJyDK_M1+p^Zsr;nL{AOipAn%MNwWzlJu-xE z=QRM_yNbLbflMZoFT>$5_I>|IDg8w$W#jSq^M6Tj9Oq@T*|aUoBA(~{m``S6zPq|<7(ULhhzQG~123OAb#A|i6mk#ml59HVX9ozxy!mh}Jt zKomvreIG`n5zJ;Y5JeGWSq4G~XqsjvbHt>hX_|hyQ%Yg6Sio|*1kdweFc?6kQh|Iv zuctOKNf3r1oK7c*;}}fS1WA$r06 _ALBM_CAPTION_TOTAL, + 'mod_url' => $mod_url, + 'mod_copyright' => $mod_copyright, + 'lang_latest_list' => _ALBM_LATESTLIST, + 'lang_descriptionc' => _ALBM_DESCRIPTIONC, + 'lang_lastupdatec' => _ALBM_LASTUPDATEC, + 'lang_submitter' => _ALBM_SUBMITTER, + 'lang_hitsc' => _ALBM_HITSC, + 'lang_commentsc' => _ALBM_COMMENTSC, + 'lang_new' => _ALBM_NEW, + 'lang_updated' => _ALBM_UPDATED, + 'lang_popular' => _ALBM_POPULAR, + 'lang_ratethisphoto' => _ALBM_RATETHISPHOTO, + 'lang_editthisphoto' => _ALBM_EDITTHISPHOTO, + 'lang_deletethisphoto' => _ALBM_DELETE_THIS_PHOTO, + 'lang_guestname' => _ALBM_CAPTION_GUESTNAME, + 'lang_category' => _ALBM_CAPTION_CATEGORY, + 'lang_nomatch' => _ALBM_NOMATCH, + 'lang_directcatsel' => _ALBM_DIRECTCATSEL, + 'photos_url' => $photos_url, + 'thumbs_url' => $thumbs_url, + 'thumbsize' => $myalbum_thumbsize, + 'colsoftableview' => $myalbum_colsoftableview, + 'canrateview' => $GLOBALS['global_perms'] && GPERM_RATEVIEW, + 'canratevote' => $GLOBALS['global_perms'] && GPERM_RATEVOTE +]; diff --git a/include/xoops_version.inc.php b/include/xoops_version.inc.php new file mode 100644 index 0000000..f4f87eb --- /dev/null +++ b/include/xoops_version.inc.php @@ -0,0 +1,36 @@ +Ue`cOHYI^YN$1aU!5evIT7Bx<*^VV>fZ{^a|y8oiM zllW1-V!QO~$@y;2yS$}}&5WfII;1Wo%PweNVdkB5R&e6U4#!QiRHBojQ@V2+&O}Vy z$*UPLaZ$aim5W!{k}bPZw*Fk37o!!nWRv3e7oQdL)jvzmIHoswqWJWi^DUK5_-Q=x zo-tv$#(gi9=06+nJ?eY)PPsusm_TVH59 zubU>yfT0l#A)qAq!Uv5Z#(^8YLL?zZ9fqg~A2xJhqKO8RnK?fYME&=6H~p~i!6t40 z&(r7kd*1teDj8eecz+{;Aj{)jd>X!Kc(1Cz3qD^sH8SoBwve@Z^}Jn{On|Vm-UraQ zDiuH)Nb=y02@pn*WwMgV+Sx=mlhakN^${e26F!{udB_ms_b~*4Rxb>CGvz#! z=EbTnC`GWMZ5s@Zm&;{u+3(fO0#4F2?Q-~h9%$jQ1~pr9Jet*3W8i_6GZn*DbPaVG zr9OSYj$km-g%ngHkys?wtZJcP$#6$9aMDZQs_N!dv9|0q_&1Ctt*y+U0q``i^Z_#m z`;l*}fnn`#@5nWT(J(!x0-GZB^LlPT1)3e_BN+VRl@*x@@Ih9jI5Hab2L*zJ>5Bo5 zB!VI(hFFdW)i{>Ib_RHYqS-(|@QWlV5G)rYxDZP~4K31iXAK+IEL+lYpypSBeydpj zZLv($1d^?r8C~zMO+c!s+qzZM4K&(Ip_>&=*2|XLoP}I@U@A`nSu}MOtyGs$mhjG! zl;6jNf_^a|RI(NXQlQyRTJ!}uo@B8qR{lQ~!(lMEI~xBPm6{69pL<*!d?+lg4$$Df zm~b)nT{-kDg52SW^K8bM`t=Cec#gPlnG~pC0Dj@UzdHfZMfn3+V~j%9sAZ}T~F_6xC~Z}%%s|X_Po*K-0Ya0 zxf1DUc%7emczox4eRS&8(G?e2rmOD8jxWMrO>oVER5#Ju)-?I!_fUKOz$@0+fyDH6 z-$Z@k;ADO-**d2+eH3d=?e6||KHK}i@hzioumAG1PiAAAHvKeRD230X_Y5CvTJz`R z$&W8wEu7e%JUkP}$kqF{T1vTC6*q{Q)>I@=PR}`A8>#5 fU7KEWYA>=3In%t8Q5#nucYjB5A<2(&+lK!Eg3h)H diff --git a/language/english/new.png b/language/english/new.png index efc456eaa64fdb8a3f1639648e278b28f5c74653..6de6b8b6bcf86583cae038abdfe967ca1c0c223c 100644 GIT binary patch delta 660 zcmZ3*vzv8-WIYQ51B2pTKMNqmlJ4m1$iT3%pZiZDE0C{{>=ES4z)+>ez|hdb!0-zw z)bN6Vq11qZ;Z*_ygVhWM2JwP9y8>;15==?n?k)`f+xyS#2lCiUJbhi+A2SLwTj;$y zE~~)6z&Ov-#WBR=_}yvt`p$tO2kM`1y&>hP>rwxN*G#E~p;Nrsu_Z9+px!T5j~a$a zvvg`0Lt1VoxVN4RnAPFIlj}L*`ZrnU|9i4lPr1YQPV!#m_os8>&&@A?FSzuoc0|yp z$2k{|T7P1XSB+NfpZ1k6u7ic&OFAg%({Z0!-EUs*s&jv#S)`hClEwR>pi)*d<5u)9%Ro+(Sq z?N7}KOj#%QX^vg-iIPk9ynl|Y+t0&tXx{JBH{CbhvO1z=5w_`lg{yzo*7W<|_)cCa zS>rGx@z%$GCVPG|hrbK{{-l1#rQ=#DucuutQj%BR^r~xH!oTal2vjX`jVMV;EJ?LW zE=mPb3`PcqmbwOpx`vh^2F6yVW>zL<+6D$z1_t#emk*+7$jwj5OsmALfiE+=7N|iI WWJ7TNL~U6v1_n=8KbLh*2~7a2#tc#b literal 1578 zcmbVMdr;GM9Pi-+#t@ZLw<$NWpq@J0Bz@A1mTQ|v>L}Jyv7STMM+(ulDM_#`(@jwr zlQBeYLuDMGLr`wI4L4;d&IdBaIXyQX;`2_Xa)`)geV}(+iq!27&p(#CB){J;pU>y} z&L@V{MUx_DM)G*PNxEdr$i3y<{YJz@?pbuGpfR{%wPrSrafHvk%nCIE>5=G$N?3`h|HA`;7FvW0*UMqmgQLWq!$$WW0Gg<)Xq0y%56 z-GLf0e9RWNQ-E14>p>yN>-7q}A^}BbLWo>04{8X7d=9~9{BG9boF-#^m=9 zkda`h9NNa!!x0}MbGduDp&*d+23Li4I@&GSgaM{2%?1(a4bP3!o*@sC``~K2t!<* zn_(?(8xgWga(2hKqL*?}4NX{BiZ)S{Gt>cwEQ+O=EXo6D(j>rg(ru@_Ot3i5V#NrW zTu0b(nsNc7*+t10SXUtukx(s@ig2-ZG-|CD(aKc`a$G1?V~7eIZ3ef*n2umW%BjjF~8F=Q#DQ5eBj|a>yh+{ zdD=lyB}$(4B9nV4^Ep z?_|VXoW<;{h+6-psHF07i-K{KmztL4KUp=+cFNJ{FSsc=ng8gsZFdXHvop4y!5hy! zc=vQn>C$O`6eFIk?P1WAk_k~go7?Sw#teRN`qpM}n4dU3XC)dNT{5G359kW3i_7-L zp4Bb8UY2}APzlD2pW*NAA6flXHApmWN;e3~YgQfn+jto5c6riEi}7)h`C%z_X~$YF zU2{q;@au*A?Tf+Ejf-n{ceii9?MaBLObw@-VvFLUKi;;u_DI#L6ln!f)muNbr08gA zSwrV9My2!c%EDIbwv@Rw*M^wNoBPunrbLYYX&@ln+6ul}TW|cR`AWe>=NaYqO;_9< zv0VcJ5}eaMa&UoSR!LipX+eMB@%rc+!{#d4%;N8chJDqYYrd_$Fc9cDJ~)y&U3YG3 z-U(pQKpkB7TYH~qXH?0a`lZe1Zr#Z4XLq&r{pByjz|5)hhvJ_!_iXrLd@&yXVE&T% zyJ`%Ds+0AVPu+(*x`rMOv~&i%{>$g>DP67B;aARTrXDZbQMNim(9QgQ|L*m5pA##3 zsy1!7e3mxGEbCL=b(9{RVeSj;1Cy%#vv(&aHnq*|j^BGJ&`CF~w>DlpaBp+VNQXBO zGyHIAu>5Du)j28Qv)^3E-Z~`l7!mljo`+wjHympnd3w8lziZ&_Et9ir^tsE+osRMq sPcG=XMwGkvLgCu0ZQ!XS!-o+t?~ZZJjwhj{33fKTqBS>Fz8|Aw&vT@O&|0Gzq(B-4CGPq*ySLlX{Oy7i>R$}GBO5r@jpHkG6Gd=uPu7&1NFr+eVo zp@UA7WG@R{oWQ%vf$_5F)R0pDg@G^D_gm!bkh{EGTu`&peA33w!;7@<75p|g%zUMj z%Qd5Bsogj0|1Do?EVnUqo1}70X_RTo4Vp1y&5jefK^_TD#g^FZshhvK;CGtEGOJ0| zC9nTf?pVq9H`2{&*5t;>uC)5aucR_d7PqY1RJHt-@~*@aT>g)=D|+Y0nSNk1tN&|a zct8LC$9Ibjerv1UHfr&x2#5JNMC9x#cD!C{XNHG{07+UHY80s2Yh8Q>*TbY_! vnV4xC7+4t?)SFyBh@vAmKP5A*5=94!2ENSf+KGzlTnr4Ju6{1-oD!M{)QAn%#Pv!r2rz1zSg$#?>qj$2e10tmFI8UbYn)kY*9 zQE79tt|L(ZFhi?POvaNHa-Ie?&{b{>-D)rqYygN_X*H=d83+!lk&SvIpE7i@g#zle ze9F3T1*9;E5S@Na9)=|3DHAn$85*vZvN9TsvhoN41A?nSt0B{9=2`ia30)qsc5gE% z-~ z8?~s#>^_`#xrz}?pMz+n7-|3~s>{=Vz`FnrXEB8l9F~+VnaElqfhAl)Bv;Dh2*t2~ zGRf8cpNcVvU>NS!_)n`$Z4v$FUcPU9!gxPAh>@5Vj2H|cQn?QRraNU~L8A5kv*fiU z^93aOYRg~X>-(ux>Qk;)SAAf}j^KddtXUr7f-S>dKfa!kdUw6D#xi`S_nB+yPJ6It z7fE=ja2L7o79ReJX=AN8d*Nbf=hm8E1_uU*YL5?QrJUPP*L_byqc)||AI=*odb+Hp zpuI21q!-_nRJVQOfBxXy1@p#EwCi37m1=4W*?jCu>C3lcL+SOSGrIqDZLpWLKK6pq z@7G|QN<~A;b6R&|;NI4p!H$e`TN@XtJBppnyN{@2YkYH@(NuwhN{c-cXlGE%Dteqw zXIFiP%d^&*N7_v<_lY@r$05ViHtdI6eGX$|VXJyt%R|3H$L8~vi(f4+Z(A{b@Apg& z()XmUY&ram~+H(AGyZ6A$Hw(_J0)gvVd-`XsI`+>uZ~A)vF>GBtE$Mz{elzlG zzGly9;1SE7zUQ)c$@tvzOXHyZa`$fOBHDgsp(E|y^j&GmEuV&T^ZtJ2a%IHac%Flf zp3Xk7jcWJaak(Z)3VM_LLZeNyXBXu6mL%oL&U+8Q9cTjmg}#{6haBmT?^c|LjM4XJKh%u!)m(sEZ> zNYA5D4YMMetfV!`7d{IO@&lW`#&3TP6c^<%x%-u9ac=GHq3iG`17CE?vEYuxr84Y7 z*RIsEoqIFXQ43oVYMp&OPog$GUa`>Q+WxAls=2|zi=d?7PP4VIft;4|-IXePvz}8K z_Sg}&{#51J=&K_8)Bf~3eWYV;CyKVMZ0vt4jT~z(?E0(tb^TVCX@E P`?n#JD8;9QXA3!ez%CJmnj!E5qW9QED=U301 zJF_lhnQfX=;)ka5Hc!MP4~OjtH+FFUBoqF_cx!;-LW3XYs>a~T-&Nc2c8~+XVD2@%@%>Bt(S60?DwomyG@pN+I=E!o7 z8UE*Y+gDm`(R8`RcDrHv0nJ-mG6E$J&Ybq|)zU@H-A=9_l5M70x-hgBbosNI-cfas zJIF4g)wsDjbK#nxgRX(D0^bS>S3cV0)yc$_I9Ye!14gGtuIwLs7PCyLn1A4==Hk<@ zzq5M3th#kPIhU#Q=I*$PrShsbF2@~x~F^a!lbgaYV-KlB|$HhH*_4=IT+Eu{l~$p z@+<$@rT?1lXu0>H&)kXjy6tx-`ZO=^1f~kr64!{5l*E!$tK_0oAjM#0VCZeBYhb8r zXc=N)Y-MU@Wn!jnU|?lnP;YYiAc~IM{FKbJN{|lh8u&7^YbPqIb1^V@y85}Sb4q9e E02V_tmjD0& literal 1675 zcmbVNdr;GM9IyC55ruJzf&*ezWFBpkmbNsbV%xORX?a;kW%y{D08!eMB+%07bm}n~ zItBIADMOhaAX8VtITW0m4?vtx6a;S^>fi=w!N+`}OA*}u;QV8`OY-~u^7(we?@LZ> z^xSbC{vIqAYn(a?iD%vt=Jp#sih1T%WS6@(v{FYeAd+dTp2S!(lrUg`+N4jx;xRp% zm0pKMuvo)UT&tsXn)$GiFmd%R4A*9|Fl-hpBGP8j8&_a7V8Bvvvy|;T`3oDsQ7Jn? zr~x$=1(u3O*-31HJz8tDuP{nbcI0dz!Ui(}CXChtHdC6Jf^AZEzb?$IUB^5&&<~+k zNZD_l(rID=1wmqfkPC8*pa=v+5El}JiN)ejfDb|-59IS8J_i!R0zM3az`(_3tdVFk z9FM35Y%x12JC&v_Fpp=oTDevMmmpJkkVGPJY4G_R2En1S%(ULdF;mk96%dRvlDLJ& z2{YhQ)EkHlTFPcTeH((wqS3q)Hd6zMVp7Jl=`B2n3-U}RS6uyQijK$rbz?|0rOmQn zym*WvGDss+kK}2CWF~j-H{=2`-oP;=&J;zTh7iUK6K1B>h?LEI;i5PShan=FN+^dE z3V}!oLQMFoFgXN@R6>1*kWj#vi$wxen6f`=r4mv~WZ@DOUnEB$8GC?>{-2ET7-x8{ z*7#4W3?4E4=UTpNd}i}*bTBhBFC;SL!w7k-m|$Dm^+mVrA9KUiXGQ<2pH$WX`ow4~lA%UICGF)_c1xnJ{C_iRCYZ0>kHA+P#`b;;#;lkSvPx(Q7*9Pphobo}(h>LtZqNYOQ@fKXP`>HJ>ct?H4vaw{XkH1^vBXL3W^OfGi*m<>atBVcr z$6IaTqxUBDOt}KjP4=#8x!>*=*H`jWNE{mQrQ-OT(1nJ54V|$aZuZxg>h^o9yQL$F z^O2=9c3keL3|tfFb0GVuVpPN4qN^e24A8+F%TM~O4;1wTc#e`(CUI*zie$bXBNwmk z*s`r+<~4)k*@d(7@}BzqJ;qJ7X2+GLUmu-mvs4-P%r3aFzo!sIH5|vh)EYx1@KOE4 zbtTuC;>9hE*m!qch`K7>d8D`eoBNH9OHVeKE5F!zx#Nf?_CQw_~W&))vgQMgI<{ka$ATirLu-?Z8apxYtQL0$P8C%>yHGk?2- nxAD4FkssrzdmL2J>gLJ1w^>noVAw7%*Y82Cj7AR2m#zH=V<(9` diff --git a/language/french/new.png b/language/french/new.png index 5ba217376fac22a15423ecadfecfb7dc22544ca0..80566d6daab2ac496ce10a62b8f3a2826045c30d 100644 GIT binary patch delta 2214 zcmY*aX*3l28~zO=Lbhy$Ya3*Vk%<};84Qy(B7_Wobwi#pQhD*lCk|mW&C0tw~ zWZz<}*A|5n*%e}x^94{wV2m@pkig8CU*839n4&iB)U3jiSJ zWo~B$K(sOdWGVnZ*bsRcfCxAMt9SsAxd2EI3f^2rv58}z7G@^k=>PMusU#Bs?ryA! z(KV;`PABaUsVU)KZ;2KuX#pZR3K|seG`TH#9zs=q=FBj2>ZzOCjOq2lJSd6aQ^z}r zRTJbP>>ValOT%dTqgg~AyyCHu{3|IJk`gsk-8@rf3bi^7>|jb3yh1QRp}hcB=*L){ z9cF*bJ?c*C?rsFf<%$XW0-bmfuor!aG#fH8K9MG*bOF$*(D)sz!HMy4b4HWOHrLg}6hFX&WIlAdr;_^csBW1sy5oetFcBAXj7XdD?yI9Ld-bR&J zk8du^tmNX_7FFjrOPq_2>T@JtAp0QrQ-`kMLf*b8F>eM8i9&r-A`n&YD~PdD{{3|P zUPem~lUPKu07TI}Mjb!ZLf6fk3<%bGciwrQzp)mU@t3{P+Zfi}12BEyCG{GY#qGtu-oGWZ+7h`188)Q7 z02+yWDeed2Rau$R^o<+yU1?IsfkE`Qp7HTk#*9{F8pz+qy-Lb$L z+tM*cjuvjay)UO!3-=abRJYZuqK-5Cf$T?QEfBI^7vG5mhlJc28zVWSViZGarzfYTv>DmYRJo|Fczi(K%ik*LFWM2`oE~|A)Grj!CF$uM z2Tb40bXh}8#e^bYn~Hr1mT=B~G!?`F4h{|Sn9Aj@^=$~N;f=_tjmWJ|3EbC#LjC2) zhUa5}{!829JG6!zzHpH&}*ciq2f(85mx6+xsLNx4$z_*l%EkZMV_*-p|e! z$takoP&4^dgfvyPufvJ2G&BmYe7+j6l9f$XdvGImGik~DzMrR{4=~s9g51xy>bf`( zcnm&qP#H9Mtz+oKRpCD%FvyA%pZ)6~l1V+;tcFodp>{gTi5`E_i z$_SY?dY^8K(msg+=Y}NHaa4OaH}9LAM@z(Bhz(q`A`;4-OI5qME)ac2?IB$Af`EH& zyT^klcxexCp|!p=jo%Nx%^D7Y@DDcjr2PC2TFk&p-&SL}G-VxQ5)WoLNa;nLv1q~A z6|qmf9f_wt&`^UJ5;XfcSkXPl+wY&`M)5$fBIY^{>REJ{LoHsMQV+F23uWRzyI20B z;3TZ!myj~m{Ps}ywwVz}W^adJ_nlnJF!VOoKwI%v&aX2o6(tnZU|rOf0*l4cCjAXR zo3tA(Ga9mW+GHt%#0}c#ZAa^2*Gko;(*-@`b0ugKYZ0B%cjpOF!QYQc8gh>|_Vo^V z$g8@U^S11#uM}?T6z=U2?t}CS^IZ*N1vpwAFS zm@W99qI|LLAQXj01err%#(0Dpfv&_p_(Mv7pNC}hyKA})v$$*=_rEB)sP;St|t$@DL65;hFV#6>{i5ZLySz5=n> z{|^lh|AwYBJc<9-`#**0-Z2qGs3(z5iKO9$gA3N)P8ESf(TF$(h2~A69RJ!y_fQIh zLJy@xfKXoM5IE>CiA}SfmS?&cKoJL>IIzSf~IYkqAhHIRaybvU0R{KsdtT zj&KJw!pzbUje3O+KNNM?NH68`04zRTUVLU@EQGnz;vMG*-Y8YLX` z`N&Ap_iI6YSMLj#@cmlQ-{nGu#Xz?Q`(K0px+Qea_VSx;g~2!D6Ujoi(}cF>nf@LJ z07%8VpzXbxczG;Y{B zfoE%19&~prO)2dADQmRUQbM%&3GP}0pH4sE=A2$_j^5Ngzt=WaJvbypMq&MrkeRLK z(^9qTeFdoJvQtqUvbcioLE_0#6qX&6w{Li4WPGZBy;fYQ6m?u+@vC6h#LsoqfOqXj z)TSe2D~6#YR#DdGylb(xd0nK|t(y(Q>y8;Z(`InpKLMXSC(fk7&!&Y18YZvt+zAGP z1&0FQ@6Y#fK^d0Mz`4jL39-*^V-u?%n!bKB*HyXtp`rF@GRxZ_u8!NjTZ)R3_5LAm zM+MzHzeA7izcy(hGR~(z>rp6VVOR$+eHk96udXa@ZZ>X7ABYd3*C@DOA_lr8i)sTa z1c})JG_6G3KyKINeLyNudZm)0cmFwPV~%h9X*k7-O0YwSlDV*g1FB%toErj(1jcJ5?s zt%na~UKW8B|ISi+z%>Zkx2Y)IBq}|8q#;&SgTHnaE+vvsJ6ycnmimL+26yh1q&QqY zwo_;GZq$T#bJ$WHg|a_*u+F`zJlWONtI0`h^|5Z> zBj_J`u!D1~ozr&O98i{h)0_z_6*Yk|0iwT!zUj%eE(u(`!+aeyy>V`!G2*cUP}Vcn z$326?t1r#r$1!JI28Rrt%|iKQ2d|Wmx2m7dFmHF2?2|%eW@gF<%W46#va7747CF}O z?{AB=pN@HuYe{VpRH-?f(yMAz5#O|wWr?x5+}{fEOJ`qG2bJ4P_L{lxE*_FUmV>1) zrLu&MNZvd-uzX^)W6^p_jL!=0%3sU&!946yBas*$UcI{hmldi2N=EI^Id%Dx?M*3V zoqWlH{P>2C3s2J5<14a1l7Hqss=}Wszkc2459zG@PCU#&PHk>r-Txq=uRd3i`Em!8|kqTFt2a|43F{)w}hqgRC@?7>}N1QNaQtbOy7ZQ{& z>yMSM0bDEPi}MJs#%fd(NcCnvfW?$=YfC+UY>3&6JgVAdd2fqd<5imAg<o^29D3kGN1tL9F1#MO;7c|^6ltHa2${juWp=Bji z2NCo$-DX^bsMoa{>I)Zrf|R@EPEpmftROG6S0)QzolOd?TrIpBYPLh8Q${VrmVeIBf%pHqC*7ky0vbzkF^jvdbcu% z7J)!=iSfvM6cu96_S;)$)GOj*SVq=bvwPGXnYIy2k+8pX>FJyfNn$w7bwr2DgaR*E zC1(BR??mh6w)bSct3*&tY|W$^D)MgikM%`MYDwBU9V|U?_I(*AUK2>OPQT<`e5L*2 zNk{#ig?d4Ud)j#R1nbpT!|(No`zHLZTSTg)xY#9KuF-u;_rDvk`Du^>|FpDn3m^vg XAbo1#v9XT%_U+Wg(G6YU5Xkx)HQd(` diff --git a/language/french/popular.png b/language/french/popular.png index af7c4d7b107542436e68a83e31ce534424c8b7f1..2f2e1bbb39c7162adc4d8bee59fbf457231b12fb 100644 GIT binary patch delta 2283 zcmV0Dy!50Qvv`0D$NK z0Cg|`0P0`>06Lfe02gqax=}m;000JJOGiWi{{a60|De66lK=n+3`s;mR9M5sSUqeb z#})p*H%oCXz!V9mumS`*5<%ia5Fn-tTT){%S|jt44?t8~{i{0>ApI?<*@SB*}ii@8udK`RLIj z2Y|J;H9mUuNPlZWB;5Tx>+?VN5{p!w?g3yP{hW0WWM(`UWE4d@K0fw2aA_`?B2}zaq#e&l z83`lM|(7rxpe%7p$0NQ&(q7c{-<0C%N)gJ~KfSK}Zx>YBjs( zRyzPeBA7>$RA9(KLy!bKeE1MouU-u&KG*d3&ws%HaU9#u&Q5ieN(qqz$^^KS3zP(h z+-l|*frO+?k}FS63F7_x_o6tC>v6qakL&Tmy?ggVp?Re%H-toDe&fmKD(};F<;oSE zm7A?r3r9ys-tBfZ=h?E3s<5R>UEKvqA+E)|49McYvZ80A&Uw>@`_~x5$ zMh_l5up~*?Znpt|o12@A) z&&BcLi!Z(yfBX2`Qdc>gS(=S$r*qOy?SHN=x!zy%4z;Q*aZ2Y_rZ*<-ic#n#rA z?d|Pxe}7+h@7~piAAV>8I2a7j>2$cizwg80kPmykh$K6m4h7g~G-9XI;cz%)r_;gK z))qhe>@$Az%{RDy{W`kcE&)sp004LH-0}VW{qYAMd=Oo~c0D^hJbc<}weawd4}UH9 zq66-7jTIt8qtW0qK}z6wGPZO);bbx~&)i&MlI-!;ty_%a=eWDO%Z-f<^m;w6udk!k zYVnOX-YA7yx7)@0@4wGht7WC4Ns^$|Y8e14#vBfZY_(e4+S=lK@4bh1yN#Wl9kknR zBuRquzwLG#ue|aK0PyoKz6c+E^nX!padGjv*I$1+9Ir*+Cq~*xlX5#>NJc zBtfs&LmbDrapMNIx3|%1wb1Q$vAn!IHNapnK;coWudn0AjT=ak1OPA`4lx`K0YFKT zsM%~z%g4L#zMH=F)?4+(#ec=cwY9ans+$HO)L3^!r^0n+7d$vPpu7JCz>fgPEQ~`4 zBxy8~vz%4)L|}7s6T{(<8yg!c3qE-m@H zBYQo6_d!K4nhL5+=!F_hvh(f? zy5oe!xv@}EC*CM%8GmO8GYcp|kX1u=YLZ-##ry$U&6=B_gL_K*(jl zV4-$aI-KRnY%ZJ^@>`23ITi$mmzLs`hJSVUONHz0gM)*gTL>@6eGGwuOE4#0$Ou6$gTrM6=~PN*L_)=hnJ@y7fyUza zMK}d>AftO8dVikgIp7h-`PGi#0Hd%#8@q!ZvKlCiGme92=5Uxt9?WVofL3F$g)BXO z`st?+eh*-D;YC)FKQ93IC4dF9;31GklbIm|qi9x-YVHsP=R$1(8Qq06O_64q zQ{W_>{XW5-bWqjDLced(A>!uq;^03^lXE@4rvo zk&(b;GV$Z_F(#9gkbII(%*fQGKTG=ixgamomX?s!~g)_R}!y6^jW-sipFYppX*j@EKA>M{@r zM9$WRL>9fVqFW8RPV_u`J-&V|;8}U_Tv!3T2nq*;5NIra5U^!X0zooJp&bcr1I-~2 z2^ihggXiI}A4g>|j45jv<46Wu#D+l3Eh5S2%v_=ACTCLT7^cn1d1X?U2ssRP1+ zO$3AJHc=eVCCbs28g-b8rNJ!r0OpZ6kpKhaQGiHB2$PG8#KXSm;zZ-MX*dk{0^uFT z!~QAC!@&t4vN#}MYK$-dcj25 zIJ5v9nY8a~E>VPs1@U-n92_1I5n&u*V$9+M!jV`k7LGu{Q79u3!ial>$)iLXF}d2` z6i6VK%AvD)bQTj>Q>6H_!gzR?sM3Fyz+iuuWpcl^Nz^cSB!vw}8Y9-0^bP3X@c*F< z#&ufkZ)ad3S#kC+#nVk zAi9_uBLR0hlg5hRe!)99;B1*(9)(E-ZAo~TNWqv+r{PR3t%w+uDUx7`u|guPkOWf{ z!3t|)f;O{6Vy!H(-?$_eHH-l=dEdCSf4Qh1a@VZDV2d)7Kn^_|r0wId7{He$BTAr~$x2EMkj|FzNIrbO;p8-BN~DEMxCkSTIIM`Y`;N9#oAOZt{A ziQpPJ@W2C~w5e@#je8H?q)M{!N@MH|npz5YvMNm;n(VC@r!B5%W=T^>?cW<0dlwe> zQ;III8x#iO;(Nzn=9Wg9_S&4w<;Hzp{4k#T!ocA;q%E?KIrDZXSNFb-^`ts%(VsYSblLoAM~C9pxA4xp z!ur5Y-t_G2N3$Ih^N4=vR=fNsLgx*pgs7QghQnGVF*_JVlBuP{;2JZZ1?55e+jQ@K zYK=`yUVcS$2Kt_}<4GR2>y`TO?Ucbk_Sh|Zr-Qy2BuI>1^%;O~q2^{+AFozTKeqo& ziJ<3{1EsVmUtG~#Q#>CC z(Hp6n(il9w6acR))>8<6%zGyBF;|@>rd`vb%~sf2t+t*M6Qh~#Ha^7f%3sd6EZTHm zVrOmZws+Egrj)|cQxoRr-k%}YU5wi(E`G8ovA#UGQ;IP^S?$;{YY@F5&F_Ysq|=TD z^`wURQcVG=D?3vu9_pzN22m*YG;qAf^I;u5Bgfp__Lp_n!hKt+E|KlGC9QiUtzeil zVb(VkpSM?Cs#RkbPXD*=lhQ&H?Db*#&5|%r;fw|Q%m>fc+o5z?_Hq51vA)W{k(L2eY-fLPz>7Zjk9Cj=!NGBAG^cmT1QQP~mQ#vc9Y^oboUhJ^$}Ke?2_zy36B39$s+3hH`B|)nR!j_Wdq(sTblmIrTN1q78b0y--4Sr zK|T*RaP^_h?|QDd*DsoUILcr!GzWbC=ASs{xk*+Iy4yQE%c`ZAL4X2* zJyj#mu0idV6`{RHB`?cm7C_#hUMWo<5(t8qDH-C9Sz2PSpd^C)dT5f^p2@gC{qF0v zwJmc~zM44r(baK=X+yM-IVN+E7*ftD22NuVocIUlhYr4}e*dO@i;3tPd@VVl=XR4R ze-6?tu!;6%{eI#6-u|+;x>Zl^_xAZQu6iZaL~aVZvry!bUwfc*itJgohf6ATd;Fp? z;()YEn=-cCwS5JbvgBlM)cW9}GJPdeMp{bRDXMGZxgBti@k)QS@m(r);mjzjj0j0v zbjnq)*>G#Tov`(Rj_^k66O{V)Oanq_dDfJk*BKo$weqwT?$G9zSq(dz&D%rQEBGhr zX6A0BpFZfBv4NXF$^IzEWj^#Zs{B*coKWZ^wmpH6Szob-Jl*f{_jdlXRLxrvZZa30 zI*y|YuY@Un+L?LF0h_U53*!lGu9GXcUgV(>IGca@1fdU_ZSn}RXm{Hez2m*S9TCi- zwCotNRGlM;l^uB8o2XXHd0TZE$p#SmmQknYaRfR-Pz{^C{o; zx_elT-dZt$}W~psSsYRGe43ViEefxX+g6lTQ7wRLbh{_>b$#Tq{g|| zp3Muw?(r7@bluCUb_zh_a(){-+dhA_CF+xY!Q#+tZyxoOdcP*0|{UF-$gR*kMu@ihPXa;5J*1vQA9;Y7>$_ z*kl6+dHYw~<51h|U}j^7mek@N6(sn~ZONGF>kYn9VYt^-9EL7vH@Gx45IVU^y7TbU et zXuB-G86gD#(1~*M^8(I8oL zS892zQUGLw@Jk0%;!$A=EeR&L_sMfe7#6vwC`Z~x;p3>ZfkVTYjiZz> ziEl_s9V~D2&aAguuy&UM7E@a#)DUa>1J}8TXuH}2Fsb6v0D|jYvTJrIJP}MA_$p0Q z{-wkOn=H_6-PW+#rr3(hk;=37SpV7I5Jgpl>pdINJUywemZnvcwVRd%J@8#$xHI(2 zj_Eb9jaII&7gpCV9g;86Ez@2xLQSNO~b|AFh(a2?fYs*MPKCO!S> zREE%2%heqNUY-qTX>N`vd$pvMuEHs|cMDC#&ryQh{BA67UnHGy|FT%O}g{c+iv|hbnONLDe_^z_r&cOL=|<8dIhOTW_0Q2OGw;S za|EAPFEanM`8uPWvXlFOU*?t*ikXZ<2bfm0^LXbdaj~%mR#jesM#{3&GyN6v9q|)# z8X6kE6QP5HN(KDNu&#}>-!?@Pn?inxu`jlr0%o&;AnBW z=%ZK0V*6OvxUKuuii(vHk3-pfzHU;O@NdR%lOB-{n-gdq-Z)~8Aj}!zHGb7NQjSr?W&#mmqAUJG#wr;rdar%@n_evTwq|}!t#tz z29`QIsCgndxGl1c*f=(SLBN@neJG~oi0UJToO-;viq`(++dGHDy@70g5~q-K2M;c+ zzKKOp#69kN6Wsky94lZ}=>~9?t29L~( z(u5BZL?TgVYodd(vHhKjpfD|kx&<<((ckFS*!pD~ku|D|zZYV{O&96+&n&k-d2)C6-r}gcAtvHO5aVrkrp8zcbW#$KF`C=yteE-v zd0$lD*^Y5WO-%*2cY-(NJu+#(-$`Y4ZSAmg=~h{N+A3zFUtnr_Fx1CJJ1Qaqc6m(O zmEB%IU}dFp6~Jk9m0`KN7-DWjBJttK2(l%VL-lK-g*2n zJ+0$DN|t#z20EoYaCzZBxs=XS7XDbo#GE^)z$D0sa~LS=^jhil=yCw(*u=!X%8auT zWbzB!3m-~^+nrO#Hl8)24Lmx_KAb-%nM{J3PNv)4SrSBDTs)Y+_bUOln5vO5(OneA zTW@G+*f}hde&j@5$$-)BJ+LDqIOu8lc4!(P@ zxKohDKS8H=1!xpKhVw23z3TYpRxlf_5}VX>B4@bpKy>^o;eJNQE7(J~#lBlM$N%;$ zfEF&`JHuBjkDwSfBQ2D5I2 zVe@y1EG_n!5e=(9APvq~F!Q=CD405|deq^LtcLHu!70+G zv#vXLEwBvLB;YcNo=Sx~e)9pAsR!!+C?rT6piP50ztlrlq;-!<(v*56ppmY$y`Bx& zp&K&lXL{!ugZ3CGWzDj3exs+Sr^AFMGc%cm?b**LHLa)VRP?;FppuP#x77Q+D@wl* zMAw=pJdkCD@2Dpac@C8h$k;d@;{KzE3RfbXwoQAE3jx`u{yz2P1!{-rNmj6f^mDnN z(53nly&aSHSAGT=tW(i5(6&g2A`eId)LiTyFH+8~!ast|jXH5k)t1@nUpF#$lE|v` zeGc>n!mnHPHTa1$TX%)Ja3^1#XI94zX@=L%%ae2&9<7FOb2*YgO5V9=Bph*EX<&PW zubO|%5BX{B`{ZKEu+V_^VXHpDMc;JGcVvo1wdrS6RlVQdwsV0J6r~a8Q&Uy464npr z4La@wtE;P4439?xo+Z3fsw&jZ4VQ0o#Gd_F#mtV@Oc|2uooE17JLj6biTlBno%05Ws*yauBK~ zkxeA*M3Wgb7-NeqM!=0t;0Oz-F#>I7fkqgEe>@OrwkS#n z+8ww3M=oh(1qoxbnP@mXCME_JV+vzLg~E+dC=?uF0yi;%N)b>Nm(C_}pmdhrPX!#n zB1ch~Y$}5eUQ{FnGosm65NW0V9D&CCB}-@hXp^*Ia1MzHH-;e=kMt8rApCzQjrI%8 zV!H$X*84w&S)N=b0CxvijOZw`bZ{Yhi>a7s`zV0KW<+^17?D4_=o-dgGgx5^CfMG? z3}y`8O{G&9F|6-+0s)Puv)Cj$8NlPLAW{Vwl}bUIm|-oDD3mGI&ceai*ufZUW`cCs zjy1+2wju58E$n}CaSU=a4WP4saw-3Ek-z0GT7kxtX2t%yruWPwih{CTYE_4WjB8QNQir6pr4m!K>9Nxd8k!ue)f$c zJwE;%lXO5RH?Fe5y7Pv3dhCAHBmdLF?M<%Dp4KY0rE4f|>c@treKiBKD!r4E3;ebD zCV>N*FL%`L_2)jS!3 zN$OBZVZp<=wR=x$lwQKrC!8+>5$5CLI;wg$+TP~V`_bCU)w)d-IiG|gcyd{5GMsUVy8xwg_C${(3cln%4Z$Kl+Jk6B&LOitW$DN>Zv7}$EFy81os^!J| z6(i@Hn*R3eG^?tuy+j|re{;9egqOrQn9Q?*XKo$!T8iUfD**;GKRO?j){@6F?+h1KlJ)TEV;^ z6bgHfYgv4Fet9>osJ)ad8U8vm_Ba<#jUV4Opk-MvsL~Z5^sf3GXgzm$=EO+@dwY8x zQii|Gb$C`v8E!bV1c^pBb8^kl7B)6*jt&i~;{&(jriyOIX}uEPZf}=Ax^3_4!$UIB z8!SDwE+&5T*{ANB1$rGbfb!c4g}QzAT2(<&(ZPhtZ)2B15b?!UanoDt6Ta56+yheUoOl+=_|}S*w_bnPxSB~O$Mq%3E$Nd; zyb|W8Hs2P1tUk5mgB<5z9aEHa`s~>^Lg5BqQA-VDFr+S3H^Q~K%%g;DbyxO9%ZGBc z@xuOFF}eMJKw+?z*-LgMY8&jz_k2vYnUz_a4H|pjOM9s?wD48DUVU><-`(sdB?J0t zv3Q0&??GP3<`L@l1M{PLIyyS$agEcn0zu%XxRJrjf4QxMULJN(ja`rkWWr?bsZM|F zzqNfUslrd-E=wXR~i%nLPq_dT}S=Yp=>Rig&Vhg`jWh8_~!8px%AGkjTguZ8XP8o+xX2Gp*tn zc%>z}kXmj}%{z1E8H!r?vYMn(S@=XGh?Q9jN@|?@JQA&}n7?B}_QU}bGp{UH!@C<+ zkKu@=ySm&PxFW@n?wp()+`1_Ru4MIfO206SNVE(QY6fYwrEky+Gn7u?tdaHX5@4E+qnK4%ZE-ueXkYnPX?)F zw2NlDOE%A}r->8(tmsu~M}LwdM7yC@O+QV&d{6Mu>jVd~qsi3mlQzN`Za`aZIlQ&C z^)BD#P<4mcEvzjb+mOpAe! zXlWbhqk@`XB zQQWo_(@NMDCC62`qsMRl-PdDoc(F;B?lw9B6Q4_6U+4^jYsWWloV+^G@a)t*8O+kk z!W3+J?dW5zq5k`uyaL{F*o-japzT%cv6AZ$LcA>?{JqE{qto zt0=A0mMQPhJ7;8zDY=#hdAj*53MRa@Kl~pCd8d3aG?BVLdPUkDC6?S@iPYD#4=vLs5TwcSC_%ht8RlnxU zW37dBjW;7u&A3;WTDtHVo1odx*7$5b{rXIwQ~3Mc2 zxlhc4J-QL)Ijk*8*ROVmo8#Y?KDy}PP0;U(O>AMN3<#Kh zYs!EAx3aTBa=2}_e)axHANE+tyKe;vsdIw?-_(LY6;aLJoi{3d7jMXT2Nzt0T~N}0 E0CayYjQ{`u diff --git a/language/german/new.png b/language/german/new.png index efc456eaa64fdb8a3f1639648e278b28f5c74653..f4c7e222aba11b6d6a17425c8f77e3e941b3af67 100644 GIT binary patch delta 660 zcmZ3*vzv8-WIYQ51B2pTKMNqmlJ4m1$iT3%pZiZDE0C{{>=ES4z)+>ez|hdb!0-zw z)bN6Vq11qZ;Z*_ygVhWM2JwP9y8>;15==?n?k)`f+xyS#2lCiUJbhi+A2SLwTNntO zP;h2oV4Uaa;uzv_{O&Y+edj=t1NG0h-jMRt^{9WsYo=7g&?(;R*b>A26V?l&)YRXfSAT69Hm@=2bXUxJ%?By)^wCTv({)tbccJXRGG(4_kUa{ki(J6&ym(Ga?p7xmNaaKuHow(*~ zW*603X~wANEX0^5kmI+p(fdvQ+u1H$ha>_gam>Bp(qMAPAh3Sg%aq=iY7@ei-d?}t zgXtmJLrjt~GK)C)3T50n9-C~L?tkKw@2497^*jF?{k~&^M9C$4-akjy?dM@RH1GH6o9-KLSsl@`2;20&!qq=(Yx@0fd?&Az ztZ|r;cRDak8udeyZp;oo&&1ge&}MwFx^mZVxG z7o`Fz1|tJQOI-s)T|>(d17j;wGbL}Jyv7STMM+(ulDM_#`(@jwr zlQBeYLuDMGLr`wI4L4;d&IdBaIXyQX;`2_Xa)`)geV}(+iq!27&p(#CB){J;pU>y} z&L@V{MUx_DM)G*PNxEdr$i3y<{YJz@?pbuGpfR{%wPrSrafHvk%nCIE>5=G$N?3`h|HA`;7FvW0*UMqmgQLWq!$$WW0Gg<)Xq0y%56 z-GLf0e9RWNQ-E14>p>yN>-7q}A^}BbLWo>04{8X7d=9~9{BG9boF-#^m=9 zkda`h9NNa!!x0}MbGduDp&*d+23Li4I@&GSgaM{2%?1(a4bP3!o*@sC``~K2t!<* zn_(?(8xgWga(2hKqL*?}4NX{BiZ)S{Gt>cwEQ+O=EXo6D(j>rg(ru@_Ot3i5V#NrW zTu0b(nsNc7*+t10SXUtukx(s@ig2-ZG-|CD(aKc`a$G1?V~7eIZ3ef*n2umW%BjjF~8F=Q#DQ5eBj|a>yh+{ zdD=lyB}$(4B9nV4^Ep z?_|VXoW<;{h+6-psHF07i-K{KmztL4KUp=+cFNJ{FSsc=ng8gsZFdXHvop4y!5hy! zc=vQn>C$O`6eFIk?P1WAk_k~go7?Sw#teRN`qpM}n4dU3XC)dNT{5G359kW3i_7-L zp4Bb8UY2}APzlD2pW*NAA6flXHApmWN;e3~YgQfn+jto5c6riEi}7)h`C%z_X~$YF zU2{q;@au*A?Tf+Ejf-n{ceii9?MaBLObw@-VvFLUKi;;u_DI#L6ln!f)muNbr08gA zSwrV9My2!c%EDIbwv@Rw*M^wNoBPunrbLYYX&@ln+6ul}TW|cR`AWe>=NaYqO;_9< zv0VcJ5}eaMa&UoSR!LipX+eMB@%rc+!{#d4%;N8chJDqYYrd_$Fc9cDJ~)y&U3YG3 z-U(pQKpkB7TYH~qXH?0a`lZe1Zr#Z4XLq&r{pByjz|5)hhvJ_!_iXrLd@&yXVE&T% zyJ`%Ds+0AVPu+(*x`rMOv~&i%{>$g>DP67B;aARTrXDZbQMNim(9QgQ|L*m5pA##3 zsy1!7e3mxGEbCL=b(9{RVeSj;1Cy%#vv(&aHnq*|j^BGJ&`CF~w>DlpaBp+VNQXBO zGyHIAu>5Du)j28Qv)^3E-Z~`l7!mljo`+wjHympnd3w8lziZ&_Et9ir^tsE+osRMq sPcG=XMwGkvLgCu0ZQ!XS!-o+t?~ZZJj-wP z&_Sn3vX_M}PT*bTz<617YDlU7!oU~n`z>;I$X#A8E~r^)K51j;;YHf_3Vxd#X1>zN z<(g5m)b5-0|CTQ`mfIM*O;Wk0G|DvP2F;kUX2*%#AdiHnVoU7y)Xm>q@H@?7nboA~ zlGlGKcdX?58|h{>YjR^`S6cnzS5lcJi(A%hs#^X^c~{~IF8@c`6}|K0Oh2%h)&Dgy zyq|ynzm0Xkxq!^403@vpH40R1HLkygZtxV0V vOf0kw46F{)QAn%#Pv!r2rz1zSg$#?>qj$2e10tmFI8UbYn)kY*9 zQE79tt|L(ZFhi?POvaNHa-Ie?&{b{>-D)rqYygN_X*H=d83+!lk&SvIpE7i@g#zle ze9F3T1*9;E5S@Na9)=|3DHAn$85*vZvN9TsvhoN41A?nSt0B{9=2`ia30)qsc5gE% z-~ z8?~s#>^_`#xrz}?pMz+n7-|3~s>{=Vz`FnrXEB8l9F~+VnaElqfhAl)Bv;Dh2*t2~ zGRf8cpNcVvU>NS!_)n`$Z4v$FUcPU9!gxPAh>@5Vj2H|cQn?QRraNU~L8A5kv*fiU z^93aOYRg~X>-(ux>Qk;)SAAf}j^KddtXUr7f-S>dKfa!kdUw6D#xi`S_nB+yPJ6It z7fE=ja2L7o79ReJX=AN8d*Nbf=hm8E1_uU*YL5?QrJUPP*L_byqc)||AI=*odb+Hp zpuI21q!-_nRJVQOfBxXy1@p#EwCi37m1=4W*?jCu>C3lcL+SOSGrIqDZLpWLKK6pq z@7G|QN<~A;b6R&|;NI4p!H$e`TN@XtJBppnyN{@2YkYH@(NuwhN{c-cXlGE%Dteqw zXIFiP%d^&*N7_v<_lY@r$05ViHtdI6eGX$|VXJyt%R|3H$L8~vi(f4+Z(A{b@Apg& z()XmUY&ram~+H(AGyZ6A$Hw(_J0)gvVd-`XsI`+>uZ~A)vF>GBtE$Mz{elzlG zzGly9;1SE7zUQ)c$@tvzOXHyZa`$fOBHDgsp(E|y^j&GmEuV&T^ZtJ2a%IHac%Flf zp3Xk7jcWJaak(Z)3VM_LLZeNyXBXu6mL%oL&U+8Q9cTjmg}#{6haBmT?^c|LjM4XJKh%u!)m(sEZ> zNYA5D4YMMetfV!`7d{IO@&lW`#&3TP6c^<%x%-u9ac=GHq3iG`17CE?vEYuxr84Y7 z*RIsEoqIFXQ43oVYMp&OPog$GUa`>Q+WxAls=2|zi=d?7PP4VIft;4|-IXePvz}8K z_Sg}&{#51J=&K_8)Bf~3eWYV;CyKVMZ0vt4jT~z(?E0(tb^TVCX@E P`?n#JD8;9QXSo?5g!kWd!hktBad}&90 z(6yeeCo5G<+fNktW%MmDaTlA@Ys8gf9>nTwxxjlWo9nALLC{># zdWz;|--*np*z{ySW?doUFU=0i#nRSN4xRi&>^r%s+5bbMfid z-&wt1R^2+DoXb>tb9Y?D()#@~zYdH2$slsRdP`(kYX@0F!Z+6H89jQ zvfi=w!N+`}OA*}u;QV8`OY-~u^7(we?@LZ> z^xSbC{vIqAYn(a?iD%vt=Jp#sih1T%WS6@(v{FYeAd+dTp2S!(lrUg`+N4jx;xRp% zm0pKMuvo)UT&tsXn)$GiFmd%R4A*9|Fl-hpBGP8j8&_a7V8Bvvvy|;T`3oDsQ7Jn? zr~x$=1(u3O*-31HJz8tDuP{nbcI0dz!Ui(}CXChtHdC6Jf^AZEzb?$IUB^5&&<~+k zNZD_l(rID=1wmqfkPC8*pa=v+5El}JiN)ejfDb|-59IS8J_i!R0zM3az`(_3tdVFk z9FM35Y%x12JC&v_Fpp=oTDevMmmpJkkVGPJY4G_R2En1S%(ULdF;mk96%dRvlDLJ& z2{YhQ)EkHlTFPcTeH((wqS3q)Hd6zMVp7Jl=`B2n3-U}RS6uyQijK$rbz?|0rOmQn zym*WvGDss+kK}2CWF~j-H{=2`-oP;=&J;zTh7iUK6K1B>h?LEI;i5PShan=FN+^dE z3V}!oLQMFoFgXN@R6>1*kWj#vi$wxen6f`=r4mv~WZ@DOUnEB$8GC?>{-2ET7-x8{ z*7#4W3?4E4=UTpNd}i}*bTBhBFC;SL!w7k-m|$Dm^+mVrA9KUiXGQ<2pH$WX`ow4~lA%UICGF)_c1xnJ{C_iRCYZ0>kHA+P#`b;;#;lkSvPx(Q7*9Pphobo}(h>LtZqNYOQ@fKXP`>HJ>ct?H4vaw{XkH1^vBXL3W^OfGi*m<>atBVcr z$6IaTqxUBDOt}KjP4=#8x!>*=*H`jWNE{mQrQ-OT(1nJ54V|$aZuZxg>h^o9yQL$F z^O2=9c3keL3|tfFb0GVuVpPN4qN^e24A8+F%TM~O4;1wTc#e`(CUI*zie$bXBNwmk z*s`r+<~4)k*@d(7@}BzqJ;qJ7X2+GLUmu-mvs4-P%r3aFzo!sIH5|vh)EYx1@KOE4 zbtTuC;>9hE*m!qch`K7>d8D`eoBNH9OHVeKE5F!zx#Nf?_CQw_~W&))vgQMgI<{ka$ATirLu-?Z8apxYtQL0$P8C%>yHGk?2- nxAD4FkssrzdmL2J>gLJ1w^>noVAw7%*Y82Cj7AR2m#zH=V<(9` diff --git a/language/lang_diff.txt b/language/lang_diff.txt new file mode 100644 index 0000000..c7bcf1a --- /dev/null +++ b/language/lang_diff.txt @@ -0,0 +1,301 @@ +Legend : ++ Added +- Removed +* Modified + +------------------------------------------------- +Version: 1.6 +Date: 15.05.2011 +------------------------------------------------- +admin.php +------------- ++ _AM_TDMDOWNLOADS_INDEX_CATEGORIES ++ _AM_TDMDOWNLOADS_FORMPERMDOWNLOAD + +* _AM_TDMDOWNLOADS_INDEX_BROKEN +* _AM_TDMDOWNLOADS_INDEX_DOWNLOADS +* _AM_TDMDOWNLOADS_INDEX_DOWNLOADSWAITING +* _AM_TDMDOWNLOADS_INDEX_MODIFIED + +- _AM_TDMDOWNLOADS_INDEX_CHANGELOG +- _AM_TDMDOWNLOADS_INDEX_UPDATE_INFO +- _AM_TDMDOWNLOADS_INDEX_VERSION_ALLOWURLFOPEN +- _AM_TDMDOWNLOADS_INDEX_VERSION_FICHIER_KO +- _AM_TDMDOWNLOADS_INDEX_VERSION_NOT_OK +- _AM_TDMDOWNLOADS_INDEX_VERSION_OK +- _AM_TDMDOWNLOADS_INDEX_ERREURFOLDER +- _AM_TDMDOWNLOADS_INDEX_ERREURPHP +- _AM_TDMDOWNLOADS_INDEX_ERREURFOLDER +- _AM_TDMDOWNLOADS_INDEX_ERREURPHP +- _AM_TDMDOWNLOADS_ABOUT_AUTHOR +- _AM_TDMDOWNLOADS_ABOUT_CREDITS +- _AM_TDMDOWNLOADS_ABOUT_LICENSE +- _AM_TDMDOWNLOADS_ABOUT_MODULEINFOS +- _AM_TDMDOWNLOADS_ABOUT_MODULEWEBSITE +- _AM_TDMDOWNLOADS_ABOUT_RELEASEDATE +- _AM_TDMDOWNLOADS_ABOUT_STATUS + +main.php +------------- + ++ _MD_TDMDOWNLOADS_SINGLEFILE_LIMITGLOBAL ++ _MD_TDMDOWNLOADS_SINGLEFILE_LIMITLID ++ _MD_TDMDOWNLOADS_BOOKMARK_ME ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_BLINKLIST ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_DELICIOUS ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_DIGG ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_FARK ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_FURL ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_NEWSVINE ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_REDDIT ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_SIMPY ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_SPURL ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_YAHOO ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_FACEBOOK ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_TWITTER ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_SCRIPSTYLE ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_STUMBLE ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_TECHNORATI ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_MIXX ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_MYSPACE ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_DESIGNFLOAT ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_BALATARIN ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_GOOGLEPLUS ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_GOOGLEREADER ++ _MD_TDMDOWNLOADS_BOOKMARK_TO_GOOGLEBOOKMARKS ++ _MD_TDMDOWNLOADS_DOWNLOAD ++ _MD_TDMDOWNLOADS_RSS ++ _MD_TDMDOWNLOADS_SINGLEFILE_NOPERM + +* _MD_TDMDOWNLOADS_CAT_POPULARITY +* _MD_TDMDOWNLOADS_CAT_POPULARITYLTOM" +* _MD_TDMDOWNLOADS_CAT_POPULARITYMTOL +* _MD_TDMDOWNLOADS_MOREDETAILS + +blocks.php +------------- ++ _MB_TDMDOWNLOADS_LOGO ++ _MB_TDMDOWNLOADS_DESCRIPTION ++ _MB_TDMDOWNLOADS_SUBMITTER ++ _MB_TDMDOWNLOADS_SUBMITDATE ++ _MB_TDMDOWNLOADS_INFORMATIONS ++ _MB_TDMDOWNLOADS_REATING ++ _MB_TDMDOWNLOADS_HITS ++ _MB_TDMDOWNLOADS_FLOAT ++ _MB_TDMDOWNLOADS_FLOAT_LEFT ++ _MB_TDMDOWNLOADS_FLOAT_RIGHT ++ _MB_TDMDOWNLOADS_WIDTH + +modinfo.php +------------- ++ _MI_TDMDOWNLOADS_PREFERENCE_BREAK_GENERAL ++ _MI_TDMDOWNLOADS_PREFERENCE_BREAK_USER ++ _MI_TDMDOWNLOADS_NBDOWCOL ++ _MI_TDMDOWNLOADS_NBCATCOL ++ _MI_TDMDOWNLOADS_PREFERENCE_BREAK_ADMIN ++ _MI_TDMDOWNLOADS_PREFERENCE_BREAK_DOWNLOADS ++ _MI_TDMDOWNLOADS_PREFERENCE_BREAK_PAYPAL ++ _MI_TDMDOWNLOADS_PREFERENCE_BREAK_COMNOTI ++ _MI_TDMDOWNLOADS_PREFERENCE_BREAK_RSS ++ _MI_TDMDOWNLOADS_PERPAGERSS ++ _MI_TDMDOWNLOADS_PERPAGERSSDSCC ++ _MI_TDMDOWNLOADS_TIMECACHERSS ++ _MI_TDMDOWNLOADS_TIMECACHERSSDSC ++ _MI_TDMDOWNLOADS_LOGORSS ++ _MI_TDMDOWNLOADS_DOWNLIMIT ++ _MI_TDMDOWNLOADS_DOWNLIMITDSC ++ _MI_TDMDOWNLOADS_LIMITGLOBAL ++ _MI_TDMDOWNLOADS_LIMITGLOBALDSC ++ _MI_TDMDOWNLOADS_LIMITLID ++ _MI_TDMDOWNLOADS_LIMITLIDDSC ++ _MI_TDMDOWNLOADS_BNAME5 ++ _MI_TDMDOWNLOADS_BNAMEDSC5 ++ _MI_TDMDOWNLOADS_SOCIAL ++ _MI_TDMDOWNLOADS_SOCIAL_DSC ++ _MI_TDMDOWNLOADS_BOOKMARK ++ _MI_TDMDOWNLOADS_BOOKMARK_DSC ++ _MI_TDMDOWNLOADS_IMGFLOAT ++ _MI_TDMDOWNLOADS_IMGFLOAT_LEFT ++ _MI_TDMDOWNLOADS_IMGFLOAT_RIGHT ++ _MI_TDMDOWNLOADS_DOWNLOADFLOAT ++ _MI_TDMDOWNLOADS_DOWNLOADFLOAT_DSC ++ _MI_TDMDOWNLOADS_DOWNLOADFLOAT_LTR ++ _MI_TDMDOWNLOADS_DOWNLOADFLOAT_RTL + +* _MI_TDMDOWNLOADS_ADMENU7 +* _MI_TDMDOWNLOADS_ADMENU9 + +- _MI_TDMDOWNLOADS_ADMENU10 +- _MI_TDMDOWNLOADS_POPULARDSC +- _MI_TDMDOWNLOADS_NEWDLSDSC +- _MI_TDMDOWNLOADS_PERPAGEDSC +- _MI_TDMDOWNLOADS_SUBCATPARENTDSC" +- _MI_TDMDOWNLOADS_BLDATEDSC +- _MI_TDMDOWNLOADS_BLPOPDSC +- _MI_TDMDOWNLOADS_BLRATINGDSC +- _MI_TDMDOWNLOADS_NBBLDSC +- _MI_TDMDOWNLOADS_LONGBLDSC +- _MI_TDMDOWNLOADS_USESHOTSDSC +- _MI_TDMDOWNLOADS_SHOTWIDTHDSC +- _MI_TDMDOWNLOADS_CHECKHOSTDSC +- _MI_TDMDOWNLOADS_REFERERSDSC +- _MI_TDMDOWNLOADS_MAXUPLOAD_SIZEDSC +- _MI_TDMDOWNLOADS_FORM_OPTIONSDSC +- _MI_TDMDOWNLOADS_TOPORDERDSC +- _MI_TDMDOWNLOADS_SEARCHORDERDSC +- _MI_TDMDOWNLOADS_PERPAGELISTEDSC +- _MI_TDMDOWNLOADS_AUTO_SUMMARYDSC +- _MI_TDMDOWNLOADS_SHOW_UPDATEDDSC +- _MI_TDMDOWNLOADS_PERMISSIONDOWNLOADDSC +- _MI_TDMDOWNLOADS_USEPAYPALDSC +- _MI_TDMDOWNLOADS_CURRENCYPAYPALDSC +- _MI_TDMDOWNLOADS_PERPAGEADMINDSC + +------------------------------------------------- +Version: 1.5 +Date: 02.04.2010 +------------------------------------------------- +admin.php +------------- + ++ _AM_TDMDOWNLOADS_PERM_DOWNLOAD ++ _AM_TDMDOWNLOADS_PERM_DOWNLOAD_DSC ++ _AM_TDMDOWNLOADS_PERM_DOWNLOAD_DSC2 ++ _AM_TDMDOWNLOADS_FORMDATEUPDATE_NO ++ _AM_TDMDOWNLOADS_FORMDATEUPDATE_YES ++ _AM_TDMDOWNLOADS_FORMPAYPAL ++ _AM_TDMDOWNLOADS_FORMSTATUS ++ _AM_TDMDOWNLOADS_FORMSTATUS_OK ++ _AM_TDMDOWNLOADS_INDEX_ERREURFOLDER ++ _AM_TDMDOWNLOADS_INDEX_ERREURPHP ++ _AM_TDMDOWNLOADS_NUMBYTES ++ _AM_TDMDOWNLOADS_PERMISSIONS_64 ++ _AM_TDMDOWNLOADS_ABOUT_FILEPROTECTION ++ _AM_TDMDOWNLOADS_ABOUT_FILEPROTECTION_INFO1 ++ _AM_TDMDOWNLOADS_ABOUT_FILEPROTECTION_INFO2 + +* _AM_TDMDOWNLOADS_PERM_SUBMIT_DSC +* _AM_TDMDOWNLOADS_PERM_VIEW_DSC +* _AM_TDMDOWNLOADS_FORMSUBMITTER +* _AM_TDMDOWNLOADS_INDEX_DOWNLOADS +* _AM_TDMDOWNLOADS_DOWNLOADS_VOTESANONYME +* _AM_TDMDOWNLOADS_DOWNLOADS_VOTESUSER +* _AM_TDMDOWNLOADS_IMPORT_CONF_MYDOWNLOADS +* _AM_TDMDOWNLOADS_IMPORT_CONF_WFDOWNLOADS +* _AM_TDMDOWNLOADS_IMPORT_WARNING +* _AM_TDMDOWNLOADS_FORMAPPROVE +* _AM_TDMDOWNLOADS_FORMSIZE +* _AM_TDMDOWNLOADS_ERREUR_SIZE +* _AM_TDMDOWNLOADS_ERREUR_WEIGHT +* _AM_TDMDOWNLOADS_REDIRECT_DELOK +* _AM_TDMDOWNLOADS_FORMIMG + +- _AM_TDMDOWNLOADS_DOWNLOADSINCAT +- _AM_TDMDOWNLOADS_THEREIS +- _MI_TDMDOWNLOADS_INDEX_ERREURPFOLDER +- _MI_TDMDOWNLOADS_INDEX_ERREURPHP +- _MD_TDMDOWNLOADS_NUMBYTES +- _AM_TDMDOWNLOADS_NUMBYTES +- _MD_TDMDOWNLOADS_SUP +- _MD_TDMDOWNLOADS_SUP_BACKOFFICE +- _MD_TDMDOWNLOADS_SUP_BLOCS +- _MD_TDMDOWNLOADS_SUP_CHANGELOG +- _MD_TDMDOWNLOADS_SUP_EVOLUTIONS +- _MD_TDMDOWNLOADS_SUP_FRONTOFFICE +- _MD_TDMDOWNLOADS_SUP_INFOS +- _MD_TDMDOWNLOADS_SUP_NOTES + +main.php +------------- ++ _MD_TDMDOWNLOADS_RATEFILE_NORATING ++ _MD_TDMDOWNLOADS_SINGLEFILE_NOPERMDOWNLOAD ++ _MD_TDMDOWNLOADS_SINGLEFILE_PAYPAL + +* _MD_TDMDOWNLOADS_CAT_THEREARE +* _MD_TDMDOWNLOADS_RATEFILE_CANTVOTEOWN +* _MD_TDMDOWNLOADS_SUBMIT_ALLPENDING +* _MD_TDMDOWNLOADS_SUBMIT_SUBMITONCE +* _MD_TDMDOWNLOADS_SEARCH_PAGETITLE +* _MD_TDMDOWNLOADS_ERREUR_NOCAT +* _MD_TDMDOWNLOADS_ERREUR_SIZE + +- _AM_TDMDOWNLOADS_FORMADD +- _AM_TDMDOWNLOADS_FORMEDIT +- _AM_TDMDOWNLOADS_FORMFILE +- _AM_TDMDOWNLOADS_FORMHOMEPAGE +- _AM_TDMDOWNLOADS_FORMINCAT +- _AM_TDMDOWNLOADS_FORMIMG +- _AM_TDMDOWNLOADS_FORMTEXTDOWNLOADS +- _AM_TDMDOWNLOADS_FORMTITLE +- _AM_TDMDOWNLOADS_FORMPATH +- _AM_TDMDOWNLOADS_FORMPLATFORM +- _AM_TDMDOWNLOADS_FORMSIZE +- _AM_TDMDOWNLOADS_FORMUPLOAD +- _AM_TDMDOWNLOADS_FORMURL +- _AM_TDMDOWNLOADS_FORMVERSION +- _MD_TDMDOWNLOADS_NUMBYTES +- _MD_TDMDOWNLOADS_SUP +- _MD_TDMDOWNLOADS_SUP_BACKOFFICE +- _MD_TDMDOWNLOADS_SUP_BLOCS +- _MD_TDMDOWNLOADS_SUP_CHANGELOG +- _MD_TDMDOWNLOADS_SUP_EVOLUTIONS +- _MD_TDMDOWNLOADS_SUP_FRONTOFFICE +- _MD_TDMDOWNLOADS_SUP_INFOS +- _MD_TDMDOWNLOADS_SUP_NOTES + +blocks.php +------------- +* _MB_TDMDOWNLOADS_CATTODISPLAY + +modinfo.php +------------- ++ _MI_TDMDOWNLOADS_PERMISSIONDOWNLOAD ++ _MI_TDMDOWNLOADS_PERMISSIONDOWNLOADDSC ++ _MI_TDMDOWNLOADS_PERMISSIONDOWNLOAD1 ++ _MI_TDMDOWNLOADS_PERMISSIONDOWNLOAD2 ++ _MI_TDMDOWNLOADS_USEPAYPAL ++ _MI_TDMDOWNLOADS_USEPAYPALDSC ++ _MI_TDMDOWNLOADS_CURRENCYPAYPAL ++ _MI_TDMDOWNLOADS_CURRENCYPAYPALDSC ++ _MI_TDMDOWNLOADS_IMAGEPAYPAL ++ _MI_TDMDOWNLOADS_IMAGEPAYPALDSC + + +* _MI_TDMDOWNLOADS_BNAME3 +* _MI_TDMDOWNLOADS_USESHOTS +* _MI_TDMDOWNLOADS_SHOTWIDTH + +- _MI_TDMDOWNLOADS_AUTOAPPROVE +- _MI_TDMDOWNLOADS_AUTOAPPROVEDSC +- _MI_TDMDOWNLOADS_ANONUPLOADS + + + +------------------------------------------------- +Version: 1.10 +Date: 11.11.2009 +------------------------------------------------- + +admin.php +------------- ++ _AM_TDMDOWNLOADS_INDEX_UPDATE_INFO ++ _AM_TDMDOWNLOADS_INDEX_VERSION_OK ++ _AM_TDMDOWNLOADS_INDEX_CHANGELOG ++ _AM_TDMDOWNLOADS_INDEX_VERSION_NOT_OK ++ _AM_TDMDOWNLOADS_INDEX_VERSION_ALLOWURLFOPEN ++ _AM_TDMDOWNLOADS_INDEX_VERSION_FICHIER_KO ++ _AM_TDMDOWNLOADS_FORMSUBMITTER ++ _AM_TDMDOWNLOADS_FORMDATEUPDATE + +modinfo.php +------------- ++ _MI_TDMDOWNLOADS_PLATEFORM ++ _MI_TDMDOWNLOADS_PLATEFORM_DSC ++ _MI_TDMDOWNLOADS_PERPAGEADMIN ++ _MI_TDMDOWNLOADS_PERPAGEADMINDSC ++ _MI_TDMDOWNLOADS_DOWNLOAD_NAME ++ _MI_TDMDOWNLOADS_DOWNLOAD_NAMEDSC ++ _MI_TDMDOWNLOADS_DOWNLOAD_PREFIX ++ _MI_TDMDOWNLOADS_DOWNLOAD_PREFIXDSC ++ _MI_TDMDOWNLOADS_USETAG ++ _MI_TDMDOWNLOADS_USETAGDSC \ No newline at end of file diff --git a/sql/tdmdownloads_2.0_migrate.yml b/sql/tdmdownloads_2.0_migrate.yml new file mode 100644 index 0000000..d4016b0 --- /dev/null +++ b/sql/tdmdownloads_2.0_migrate.yml @@ -0,0 +1,294 @@ +tdmdownloads_broken: + options: 'ENGINE=MyISAM DEFAULT CHARSET=utf8' + columns: + - + name: reportid + attributes: ' int(5) NOT NULL auto_increment' + - + name: lid + attributes: ' int(11) NOT NULL DEFAULT ''0'' ' + - + name: sender + attributes: ' int(11) NOT NULL DEFAULT ''0'' ' + - + name: ip + attributes: ' varchar(20) NOT NULL DEFAULT '''' ' + keys: + ip: + columns: ip + unique: false + lid: + columns: lid + unique: false + PRIMARY: + columns: reportid + unique: true + sender: + columns: sender + unique: false +tdmdownloads_cat: + options: 'ENGINE=MyISAM DEFAULT CHARSET=utf8' + columns: + - + name: cat_cid + attributes: ' int(5) unsigned NOT NULL auto_increment' + - + name: cat_pid + attributes: ' int(5) unsigned NOT NULL DEFAULT ''0'' ' + - + name: cat_title + attributes: ' varchar(255) NOT NULL DEFAULT '''' ' + - + name: cat_imgurl + attributes: ' varchar(255) NOT NULL DEFAULT '''' ' + - + name: cat_description_main + attributes: ' text NOT NULL ' + - + name: cat_weight + attributes: ' int(11) NOT NULL DEFAULT ''0'' ' + keys: + cat_pid: + columns: cat_pid + unique: false + PRIMARY: + columns: cat_cid + unique: true +tdmdownloads_downloads: + options: 'ENGINE=MyISAM DEFAULT CHARSET=utf8' + columns: + - + name: lid + attributes: ' int(11) unsigned NOT NULL auto_increment' + - + name: cid + attributes: ' int(5) unsigned NOT NULL DEFAULT ''0'' ' + - + name: title + attributes: ' varchar(255) NOT NULL DEFAULT '''' ' + - + name: url + attributes: ' varchar(255) NOT NULL DEFAULT '''' ' + - + name: homepage + attributes: ' varchar(255) NOT NULL DEFAULT '''' ' + - + name: version + attributes: ' varchar(20) NOT NULL DEFAULT '''' ' + - + name: size + attributes: ' varchar(15) NOT NULL DEFAULT '''' ' + - + name: platform + attributes: ' varchar(255) NOT NULL DEFAULT '''' ' + - + name: description + attributes: ' text NOT NULL ' + - + name: logourl + attributes: ' varchar(255) NOT NULL DEFAULT '''' ' + - + name: submitter + attributes: ' int(11) NOT NULL DEFAULT ''0'' ' + - + name: status + attributes: ' tinyint(2) NOT NULL DEFAULT ''0'' ' + - + name: date + attributes: ' int(10) NOT NULL DEFAULT ''0'' ' + - + name: hits + attributes: ' int(11) unsigned NOT NULL DEFAULT ''0'' ' + - + name: rating + attributes: ' double(6,4) NOT NULL DEFAULT ''0.0000'' ' + - + name: votes + attributes: ' int(11) unsigned NOT NULL DEFAULT ''0'' ' + - + name: comments + attributes: ' int(11) unsigned NOT NULL DEFAULT ''0'' ' + - + name: top + attributes: ' tinyint(2) NOT NULL DEFAULT ''0'' ' + - + name: paypal + attributes: ' varchar(255) NOT NULL DEFAULT '''' ' + keys: + cid: + columns: cid + unique: false + PRIMARY: + columns: lid + unique: true + status: + columns: status + unique: false + title: + columns: 'title (40)' + unique: false +tdmdownloads_mod: + options: 'ENGINE=MyISAM DEFAULT CHARSET=utf8' + columns: + - + name: requestid + attributes: ' int(11) unsigned NOT NULL auto_increment' + - + name: lid + attributes: ' int(11) unsigned NOT NULL DEFAULT ''0'' ' + - + name: cid + attributes: ' int(5) unsigned NOT NULL DEFAULT ''0'' ' + - + name: title + attributes: ' varchar(255) NOT NULL DEFAULT '''' ' + - + name: url + attributes: ' varchar(255) NOT NULL DEFAULT '''' ' + - + name: homepage + attributes: ' varchar(255) NOT NULL DEFAULT '''' ' + - + name: version + attributes: ' varchar(20) NOT NULL DEFAULT '''' ' + - + name: size + attributes: ' varchar(15) NOT NULL DEFAULT '''' ' + - + name: platform + attributes: ' varchar(50) NOT NULL DEFAULT '''' ' + - + name: logourl + attributes: ' varchar(255) NOT NULL DEFAULT '''' ' + - + name: description + attributes: ' text NOT NULL ' + - + name: modifysubmitter + attributes: ' int(11) NOT NULL DEFAULT ''0'' ' + keys: + PRIMARY: + columns: requestid + unique: true +tdmdownloads_votedata: + options: 'ENGINE=MyISAM DEFAULT CHARSET=utf8' + columns: + - + name: ratingid + attributes: ' int(11) unsigned NOT NULL auto_increment' + - + name: lid + attributes: ' int(11) unsigned NOT NULL DEFAULT ''0'' ' + - + name: ratinguser + attributes: ' int(11) NOT NULL DEFAULT ''0'' ' + - + name: rating + attributes: ' tinyint(3) unsigned NOT NULL DEFAULT ''0'' ' + - + name: ratinghostname + attributes: ' varchar(60) NOT NULL DEFAULT '''' ' + - + name: ratingtimestamp + attributes: ' int(10) NOT NULL DEFAULT ''0'' ' + keys: + lid: + columns: lid + unique: false + PRIMARY: + columns: ratingid + unique: true + ratinghostname: + columns: ratinghostname + unique: false + ratinguser: + columns: ratinguser + unique: false +tdmdownloads_field: + options: 'ENGINE=MyISAM DEFAULT CHARSET=utf8' + columns: + - + name: fid + attributes: ' int(11) unsigned NOT NULL auto_increment' + - + name: title + attributes: ' varchar(255) NOT NULL DEFAULT '''' ' + - + name: img + attributes: ' varchar(255) NOT NULL DEFAULT '''' ' + - + name: weight + attributes: ' int(11) NOT NULL DEFAULT ''0'' ' + - + name: status + attributes: ' int(5) unsigned NOT NULL DEFAULT ''0'' ' + - + name: search + attributes: ' int(5) unsigned NOT NULL DEFAULT ''0'' ' + - + name: status_def + attributes: ' int(5) unsigned NOT NULL DEFAULT ''0'' ' + keys: + PRIMARY: + columns: fid + unique: true +tdmdownloads_fielddata: + options: 'ENGINE=MyISAM DEFAULT CHARSET=utf8' + columns: + - + name: iddata + attributes: ' int(11) unsigned NOT NULL auto_increment' + - + name: fid + attributes: ' int(11) unsigned NOT NULL DEFAULT ''0'' ' + - + name: lid + attributes: ' int(11) unsigned NOT NULL DEFAULT ''0'' ' + - + name: data + attributes: ' varchar(255) NOT NULL DEFAULT '''' ' + keys: + PRIMARY: + columns: iddata + unique: true +tdmdownloads_modfielddata: + options: 'ENGINE=MyISAM DEFAULT CHARSET=utf8' + columns: + - + name: modiddata + attributes: ' int(11) unsigned NOT NULL auto_increment' + - + name: fid + attributes: ' int(11) unsigned NOT NULL DEFAULT ''0'' ' + - + name: lid + attributes: ' int(11) unsigned NOT NULL DEFAULT ''0'' ' + - + name: moddata + attributes: ' varchar(255) NOT NULL DEFAULT '''' ' + keys: + PRIMARY: + columns: modiddata + unique: true +tdmdownloads_downlimit: + options: 'ENGINE=MyISAM DEFAULT CHARSET=utf8' + columns: + - + name: downlimit_id + attributes: ' int(11) unsigned NOT NULL auto_increment' + - + name: downlimit_lid + attributes: ' int(11) unsigned NOT NULL DEFAULT ''0'' ' + - + name: downlimit_uid + attributes: ' int(11) NOT NULL DEFAULT ''0'' ' + - + name: downlimit_hostname + attributes: ' varchar(60) NOT NULL DEFAULT '''' ' + - + name: downlimit_date + attributes: ' int(10) NOT NULL DEFAULT ''0'' ' + keys: + PRIMARY: + columns: downlimit_id + unique: true diff --git a/testdata/uploads/index.html b/testdata/uploads/index.html new file mode 100644 index 0000000..74b6f45 --- /dev/null +++ b/testdata/uploads/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/xoops_version.php b/xoops_version.php index 4eac9f8..a182b81 100644 --- a/xoops_version.php +++ b/xoops_version.php @@ -21,6 +21,7 @@ xoops_load('xoopseditorhandler'); $editorHandler = \XoopsEditorHandler::getInstance(); $xoopsUrl = parse_url(XOOPS_URL); +$utility = new \XoopsModules\Tdmdownloads\Utility(); $modversion = [ 'name' => _MI_TDMDOWNLOADS_NAME, @@ -28,8 +29,8 @@ 'module_status' => 'Beta 1', 'release_date' => '2019/01/12', 'description' => _MI_TDMDOWNLOADS_DESC, - 'credits' => 'G. Mage, Mamba, Goffy', - 'author' => 'G. Mage', + 'credits' => 'Mage, Mamba, Goffy', + 'author' => 'Mage', 'nickname' => 'Mage', 'module_website_url' => 'www.xoops.org', 'module_website_name' => 'Support site', @@ -542,8 +543,8 @@ 'default' => 'downloads_', ]; -$iniPostMaxSize = returnBytes(ini_get('post_max_size')); -$iniUploadMaxFileSize = returnBytes(ini_get('upload_max_filesize')); +$iniPostMaxSize = $utility::returnBytes(ini_get('post_max_size')); +$iniUploadMaxFileSize = $utility::returnBytes(ini_get('upload_max_filesize')); $optionMaxsize = []; for ($i = 1; ; $i++) { if (min($iniPostMaxSize, $iniUploadMaxFileSize) < $i * 1048576) { @@ -884,19 +885,19 @@ * @param $val * @return float|int */ -function returnBytes($val) -{ - switch (mb_substr($val, -1)) { - case 'K': - case 'k': - return (int)$val * 1024; - case 'M': - case 'm': - return (int)$val * 1048576; - case 'G': - case 'g': - return (int)$val * 1073741824; - default: - return $val; - } -} +//function returnBytes($val) +//{ +// switch (mb_substr($val, -1)) { +// case 'K': +// case 'k': +// return (int)$val * 1024; +// case 'M': +// case 'm': +// return (int)$val * 1048576; +// case 'G': +// case 'g': +// return (int)$val * 1073741824; +// default: +// return $val; +// } +//} From fed6a56439c69226359034ea54011b4adbf344cd Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 21:33:16 -0400 Subject: [PATCH 12/62] updates --- CONTRIBUTING.md | 4 +- README.md | 2 +- admin/about.php | 2 +- admin/admin_footer.php | 2 +- admin/admin_header.php | 13 +- admin/blockform.php | 73 +- admin/blocksadmin.php | 57 +- admin/broken.php | 5 +- admin/category.php | 33 +- admin/downloads.php | 384 ++++---- admin/field.php | 13 +- admin/import.php | 211 ++-- admin/index.php | 12 +- admin/menu.php | 8 +- admin/migrate.php | 2 +- admin/modified.php | 21 +- admin/permissions.php | 3 +- blocks/tdmdownloads_search.php | 20 +- blocks/tdmdownloads_top.php | 39 +- brokenfile.php | 7 +- class/Broken.php | 4 +- class/BrokenHandler.php | 4 +- class/Category.php | 16 +- class/CategoryHandler.php | 4 +- class/Common/Breadcrumb.php | 2 - class/Common/Configurator.php | 12 +- class/Common/FilesManagement.php | 10 +- class/Common/FineimpuploadHandler.php | 67 +- class/Common/ImageResizer.php | 9 +- class/Common/Images.php | 8 +- class/Common/ImagesHandler.php | 6 +- class/Common/Migrate.php | 17 +- class/Common/ModuleConstants.php | 80 +- class/Common/VersionChecks.php | 85 +- class/Downlimit.php | 5 +- class/DownlimitHandler.php | 4 +- class/Downloads.php | 48 +- class/DownloadsHandler.php | 4 +- class/Field.php | 4 +- class/FieldHandler.php | 4 +- class/Fielddata.php | 4 +- class/FielddataHandler.php | 4 +- class/Form/UploadForm.php | 25 +- class/Helper.php | 18 +- class/Modified.php | 48 +- class/ModifiedHandler.php | 4 +- class/Modifiedfielddata.php | 4 +- class/ModifiedfielddataHandler.php | 4 +- class/Rating.php | 4 +- class/RatingHandler.php | 4 +- class/Tree.php | 6 +- class/Utility.php | 337 +++---- comment_delete.php | 2 +- comment_edit.php | 2 +- comment_new.php | 2 +- comment_post.php | 2 +- comment_reply.php | 2 +- config/imageconfig.php | 10 +- docs/changelog.txt | 8 + extra/plugins/sitemap/tdmdownloads.php | 2 +- extra/plugins/tag/tdmdownloads.php | 8 +- extra/plugins/waiting/tdmdownloads.php | 1 + .../whatsnew/tdmdownloads/data.inc.php | 8 +- header.php | 14 +- include/assign_globals.php | 4 +- include/comment_functions.php | 2 +- include/common.php | 2 +- include/config.php | 86 -- include/functions0.php0 | 2 +- include/notification.inc.php | 2 +- include/oninstall.php | 52 +- include/onupdate.php | 101 +- include/search.inc.php | 8 +- include/xoops_version.inc.php | 36 - index.php | 112 ++- language/english/admin.php | 5 +- language/english/blocks.php | 3 +- language/english/blocksadmin.php | 5 +- language/english/common.php | 17 +- language/english/main.php | 6 +- language/english/modinfo.php | 3 +- language/french/admin.php | 5 +- language/french/blocks.php | 3 +- language/french/blocksadmin.php | 2 +- language/french/common.php | 4 +- language/french/main.php | 7 +- language/french/modinfo.php | 10 +- language/german/admin.php | 5 +- language/german/blocks.php | 3 +- language/german/blocksadmin.php | 2 +- language/german/common.php | 5 +- language/german/main.php | 7 +- language/german/modinfo.php | 8 +- list.tag.php | 2 +- modfile.php | 77 +- notification_update.php | 2 +- preloads/autoloader.php | 42 +- preloads/core.php | 5 +- ratefile.php | 15 +- rss.php | 23 +- search.php | 65 +- singlefile.php | 51 +- submit.php | 284 +++--- templates/admin/tdmdownloads_admin_footer.tpl | 2 +- templates/admin/tdmdownloads_admin_import.tpl | 2 +- templates/tdmdownloads_rss.tpl | 1 + templates/tdmdownloads_upload.tpl | 2 +- testdata/index.php | 124 ++- upload.php | 12 +- view.tag.php | 2 +- viewcat.php | 110 ++- visit.php | 13 +- xoops_version.php | 918 +++++++++--------- 113 files changed, 1991 insertions(+), 2095 deletions(-) delete mode 100644 include/config.php delete mode 100644 include/xoops_version.inc.php diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a88517a..722ef9b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,7 @@ ![alt XOOPS CMS](https://xoops.org/images/logoXoops4GithubRepository.png) # Contributing to [XOOPS CMS](https://xoops.org) [![XOOPS CMS Module](https://img.shields.io/badge/XOOPS%20CMS-Module-blue.svg)](https://xoops.org) -[![Software License](https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat)](http://www.gnu.org/licenses/gpl-2.0.html) +[![Software License](https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat)](https://www.gnu.org/licenses/gpl-2.0.html) Contributions are **welcome** and will be fully **credited**. @@ -10,7 +10,7 @@ We accept contributions via Pull Requests on [Github](https://github.com/XoopsMo ## Pull Requests - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). -- **Add tests!** - We encourage to provide tests for your contributions. +- **Add tests!** - We encourage providing tests for your contributions. - **Document any change in behavior** - Make sure the `/docs/changelog.txt` and any other relevant documentation are kept up-to-date. - **Consider our release cycle** - We try to follow [Semantic Versioning v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. - **Create feature branches** - Don't ask us to pull from your master branch. diff --git a/README.md b/README.md index 959fde3..e5059fa 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ![alt XOOPS CMS](https://xoops.org/images/logoXoops4GithubRepository.png) ## TdmDownloads module for [XOOPS CMS 2.5.9+](https://xoops.org) [![XOOPS CMS Module](https://img.shields.io/badge/XOOPS%20CMS-Module-blue.svg)](https://xoops.org) -[![Software License](https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat)](http://www.gnu.org/licenses/gpl-2.0.html) +[![Software License](https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat)](https://www.gnu.org/licenses/gpl-2.0.html) [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/XoopsModules25x/tdmdownloads.svg?style=flat)](https://scrutinizer-ci.com/g/XoopsModules25x/tdmdownloads/?branch=master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/95b12220e0ac4056b9af52af708379c9)](https://www.codacy.com/app/mambax7/tdmdownloads_2) diff --git a/admin/about.php b/admin/about.php index 2c3f60e..5d76351 100644 --- a/admin/about.php +++ b/admin/about.php @@ -10,7 +10,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ diff --git a/admin/admin_footer.php b/admin/admin_footer.php index 7f61ed4..1ec1fd1 100644 --- a/admin/admin_footer.php +++ b/admin/admin_footer.php @@ -11,7 +11,7 @@ /** * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @package * @since * @author XOOPS Development Team diff --git a/admin/admin_header.php b/admin/admin_header.php index 131b3bc..5c56a12 100644 --- a/admin/admin_header.php +++ b/admin/admin_header.php @@ -10,9 +10,10 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + use XoopsModules\Tdmdownloads\Tree; // Include xoops admin header @@ -81,12 +82,12 @@ //permission /** @var \XoopsGroupPermHandler $grouppermHandler */ $grouppermHandler = xoops_getHandler('groupperm'); -$groups = XOOPS_GROUP_ANONYMOUS; +$groups = XOOPS_GROUP_ANONYMOUS; if (is_object($xoopsUser)) { $groups = $xoopsUser->getGroups(); } -$perm_submit = $grouppermHandler->checkRight('tdmdownloads_ac', 4, $groups, $xoopsModule->getVar('mid')) ? true : false; -$perm_modif = $grouppermHandler->checkRight('tdmdownloads_ac', 8, $groups, $xoopsModule->getVar('mid')) ? true : false; -$perm_vote = $grouppermHandler->checkRight('tdmdownloads_ac', 16, $groups, $xoopsModule->getVar('mid')) ? true : false; -$perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')) ? true : false; +$perm_submit = $grouppermHandler->checkRight('tdmdownloads_ac', 4, $groups, $xoopsModule->getVar('mid')) ? true : false; +$perm_modif = $grouppermHandler->checkRight('tdmdownloads_ac', 8, $groups, $xoopsModule->getVar('mid')) ? true : false; +$perm_vote = $grouppermHandler->checkRight('tdmdownloads_ac', 16, $groups, $xoopsModule->getVar('mid')) ? true : false; +$perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')) ? true : false; $perm_autoapprove = $grouppermHandler->checkRight('tdmdownloads_ac', 64, $groups, $xoopsModule->getVar('mid')) ? true : false; diff --git a/admin/blockform.php b/admin/blockform.php index 2905e58..4bed7b3 100644 --- a/admin/blockform.php +++ b/admin/blockform.php @@ -1,4 +1,5 @@ addElement(new \XoopsFormLabel(_AM_SYSTEM_BLOCKS_NAME, $block['name'])); } $side_select = new \XoopsFormSelect(_AM_SYSTEM_BLOCKS_TYPE, 'bside', $block['side']); -$side_select->addOptionArray([ - 0 => _AM_SYSTEM_BLOCKS_SBLEFT, - 1 => _AM_SYSTEM_BLOCKS_SBRIGHT, - 3 => _AM_SYSTEM_BLOCKS_CBLEFT, - 4 => _AM_SYSTEM_BLOCKS_CBRIGHT, - 5 => _AM_SYSTEM_BLOCKS_CBCENTER, - 7 => _AM_SYSTEM_BLOCKS_CBBOTTOMLEFT, - 8 => _AM_SYSTEM_BLOCKS_CBBOTTOMRIGHT, - 9 => _AM_SYSTEM_BLOCKS_CBBOTTOM, - ]); +$side_select->addOptionArray( + [ + 0 => _AM_SYSTEM_BLOCKS_SBLEFT, + 1 => _AM_SYSTEM_BLOCKS_SBRIGHT, + 3 => _AM_SYSTEM_BLOCKS_CBLEFT, + 4 => _AM_SYSTEM_BLOCKS_CBRIGHT, + 5 => _AM_SYSTEM_BLOCKS_CBCENTER, + 7 => _AM_SYSTEM_BLOCKS_CBBOTTOMLEFT, + 8 => _AM_SYSTEM_BLOCKS_CBBOTTOMRIGHT, + 9 => _AM_SYSTEM_BLOCKS_CBBOTTOM, + ] +); $form->addElement($side_select); $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'WEIGHT'), 'bweight', 2, 5, $block['weight'])); $form->addElement(new \XoopsFormRadioYN(constant('CO_' . $moduleDirNameUpper . '_' . 'VISIBLE'), 'bvisible', $block['visible'])); @@ -52,12 +55,14 @@ $textarea->setDescription('' . _AM_SYSTEM_BLOCKS_USEFULTAGS . '
' . sprintf(_AM_BLOCKTAG1, '{X_SITEURL}', XOOPS_URL . '/') . ''); $form->addElement($textarea, true); $ctype_select = new \XoopsFormSelect(_AM_SYSTEM_BLOCKS_CTYPE, 'bctype', $block['ctype']); - $ctype_select->addOptionArray([ - 'H' => _AM_SYSTEM_BLOCKS_HTML, - 'P' => _AM_SYSTEM_BLOCKS_PHP, - 'S' => _AM_SYSTEM_BLOCKS_AFWSMILE, - 'T' => _AM_SYSTEM_BLOCKS_AFNOSMILE, - ]); + $ctype_select->addOptionArray( + [ + 'H' => _AM_SYSTEM_BLOCKS_HTML, + 'P' => _AM_SYSTEM_BLOCKS_PHP, + 'S' => _AM_SYSTEM_BLOCKS_AFWSMILE, + 'T' => _AM_SYSTEM_BLOCKS_AFNOSMILE, + ] + ); $form->addElement($ctype_select); } else { if ('' !== $block['template']) { @@ -69,7 +74,7 @@ $form->addElement(new \XoopsFormLabel(_AM_SYSTEM_BLOCKS_CONTENT, '
' . _AM_SYSTEM_BLOCKS_EDITTPL . '')); } else { /** @var \XoopsTplfile[] $btemplate2 */ - $btemplate2 = &$tplfileHandler->find('default', 'block', $block['bid']); + $btemplate2 = $tplfileHandler->find('default', 'block', $block['bid']); if (count($btemplate2) > 0) { $form->addElement(new \XoopsFormLabel(_AM_SYSTEM_BLOCKS_CONTENT, '' . _AM_SYSTEM_BLOCKS_EDITTPL . '')); } @@ -80,19 +85,21 @@ } } $cache_select = new \XoopsFormSelect(_AM_SYSTEM_BLOCKS_BCACHETIME, 'bcachetime', $block['bcachetime']); -$cache_select->addOptionArray([ - '0' => _NOCACHE, - '30' => sprintf(_SECONDS, 30), - '60' => _MINUTE, - '300' => sprintf(_MINUTES, 5), - '1800' => sprintf(_MINUTES, 30), - '3600' => _HOUR, - '18000' => sprintf(_HOURS, 5), - '86400' => _DAY, - '259200' => sprintf(_DAYS, 3), - '604800' => _WEEK, - '2592000' => _MONTH, - ]); +$cache_select->addOptionArray( + [ + '0' => _NOCACHE, + '30' => sprintf(_SECONDS, 30), + '60' => _MINUTE, + '300' => sprintf(_MINUTES, 5), + '1800' => sprintf(_MINUTES, 30), + '3600' => _HOUR, + '18000' => sprintf(_HOURS, 5), + '86400' => _DAY, + '259200' => sprintf(_DAYS, 3), + '604800' => _WEEK, + '2592000' => _MONTH, + ] +); $form->addElement($cache_select); /** @var \XoopsGroupPermHandler $grouppermHandler */ @@ -112,7 +119,7 @@ } //Submit buttons -$buttonTray = new \XoopsFormElementTray('', ''); +$buttonTray = new \XoopsFormElementTray('', ''); $submit_button = new \XoopsFormButton('', 'submitblock', _SUBMIT, 'submit'); $buttonTray->addElement($submit_button); diff --git a/admin/blocksadmin.php b/admin/blocksadmin.php index 4f2f531..79d59b3 100644 --- a/admin/blocksadmin.php +++ b/admin/blocksadmin.php @@ -9,8 +9,8 @@ * @category Module * @author XOOPS Development Team * @copyright XOOPS Project - * @link https://www.xoops.org - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @link https://xoops.org + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) */ use Xmf\Request; @@ -60,7 +60,7 @@ function listBlocks() xoops_loadLanguage('admin/blocksadmin', 'system'); xoops_loadLanguage('admin/groups', 'system'); - /** @var XoopsModuleHandler $moduleHandler */ + /** @var \XoopsModuleHandler $moduleHandler */ $moduleHandler = xoops_getHandler('module'); /** @var \XoopsMemberHandler $memberHandler */ $memberHandler = xoops_getHandler('member'); @@ -76,7 +76,7 @@ function listBlocks() echo "

" . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . '

'; $moduleHandler = xoops_getHandler('module'); - echo "
"; + echo ""; echo $GLOBALS['xoopsSecurity']->getTokenHTML(); echo "
" @@ -90,10 +90,9 @@ function listBlocks() . '-' . _RIGHT . "" - . constant('CO_' - . $moduleDirNameUpper - . '_' - . 'WEIGHT') + . constant( + 'CO_' . $moduleDirNameUpper . '_' . 'WEIGHT' + ) . "" . constant('CO_' . $moduleDirNameUpper . '_' . 'VISIBLE') . "" @@ -284,7 +283,7 @@ function listBlocks() } /** - * @param $bid + * @param int $bid */ function cloneBlock($bid) { @@ -337,7 +336,7 @@ function cloneBlock($bid) } /** - * @param $bid + * @param int $bid * @param $bside * @param $bweight * @param $bvisible @@ -412,12 +411,12 @@ function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, } /** - * @param $bid - * @param $title - * @param $weight - * @param $visible - * @param $side - * @param $bcachetime + * @param int $bid + * @param string $title + * @param int $weight + * @param bool $visible + * @param string $side + * @param int $bcachetime */ function setOrder($bid, $title, $weight, $visible, $side, $bcachetime) { @@ -431,7 +430,7 @@ function setOrder($bid, $title, $weight, $visible, $side, $bcachetime) } /** - * @param $bid + * @param int $bid */ function editBlock($bid) { @@ -483,15 +482,15 @@ function editBlock($bid) } /** - * @param $bid - * @param $btitle - * @param $bside - * @param $bweight - * @param $bvisible - * @param $bcachetime - * @param $bmodule - * @param $options - * @param $groups + * @param int $bid + * @param string $btitle + * @param string $bside + * @param int $bweight + * @param bool $bvisible + * @param int $bcachetime + * @param array $bmodule + * @param null|array|string $options + * @param null|array $groups */ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups) { @@ -527,7 +526,7 @@ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $b $GLOBALS['xoopsDB']->query($sql); } } - redirect_header($_SERVER['PHP_SELF'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS')); + redirect_header($_SERVER['SCRIPT_NAME'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS')); } if ('list' === $op) { @@ -540,7 +539,7 @@ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $b if ('order' === $op) { if (!$GLOBALS['xoopsSecurity']->check()) { - redirect_header($_SERVER['PHP_SELF'], 3, implode('
', $GLOBALS['xoopsSecurity']->getErrors())); + redirect_header($_SERVER['SCRIPT_NAME'], 3, implode('
', $GLOBALS['xoopsSecurity']->getErrors())); } foreach (array_keys($bid) as $i) { if ($oldtitle[$i] !== $title[$i] || $oldweight[$i] !== $weight[$i] || $oldvisible[$i] !== $visible[$i] @@ -570,7 +569,7 @@ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $b } } } - redirect_header($_SERVER['PHP_SELF'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS')); + redirect_header($_SERVER['SCRIPT_NAME'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS')); } if ('clone' === $op) { cloneBlock($bid); diff --git a/admin/broken.php b/admin/broken.php index e126a71..eaf5246 100644 --- a/admin/broken.php +++ b/admin/broken.php @@ -1,4 +1,5 @@ table_link = $brokenHandler->db->prefix('tdmdownloads_downloads'); // Nom de la table en jointure $brokenHandler->field_link = 'lid'; // champ de la table en jointure $brokenHandler->field_object = 'lid'; // champ de la table courante - $brokenArray = $brokenHandler->getByLink($criteria); + $brokenArray = $brokenHandler->getByLink($criteria); $numrows = $brokenHandler->getCount($criteria); $pagenav = ''; if ($numrows > $limit) { diff --git a/admin/category.php b/admin/category.php index 1059a64..237ff72 100644 --- a/admin/category.php +++ b/admin/category.php @@ -13,7 +13,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ require __DIR__ . '/admin_header.php'; @@ -290,11 +290,15 @@ $adminObject->addItemButton(_AM_TDMDOWNLOADS_CAT_LIST, 'category.php?op=list', 'list'); $adminObject->addItemButton(_AM_TDMDOWNLOADS_CAT_NEW, 'category.php?op=new_cat', 'add'); $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); - xoops_confirm([ - 'ok' => 1, - 'downloadscat_cid' => $categoryId, - 'op' => 'del_cat', - ], $_SERVER['REQUEST_URI'], sprintf(_AM_TDMDOWNLOADS_FORMSUREDEL, $obj->getVar('cat_title')) . '

' . $message); + xoops_confirm( + [ + 'ok' => 1, + 'downloadscat_cid' => $categoryId, + 'op' => 'del_cat', + ], + $_SERVER['REQUEST_URI'], + sprintf(_AM_TDMDOWNLOADS_FORMSUREDEL, $obj->getVar('cat_title')) . '

' . $message + ); } break; @@ -304,24 +308,26 @@ redirect_header('category.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); } xoops_cp_header(); - $cat_cid = \Xmf\Request::getInt('cat_cid', 0, 'POST'); + $cat_cid = \Xmf\Request::getInt('cat_cid', 0, 'POST'); if (0 !== $cat_cid) { $obj = $categoryHandler->get($cat_cid); } else { $obj = $categoryHandler->create(); } - $erreur = false; + $erreur = false; $errorMessage = ''; // Récupération des variables: // Pour l'image require_once XOOPS_ROOT_PATH . '/class/uploader.php'; - $uploader = new \XoopsMediaUploader($uploaddir, [ + $uploader = new \XoopsMediaUploader( + $uploaddir, [ 'image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png', - ], $helper->getConfig('maxuploadsize'), null, null); + ], $helper->getConfig('maxuploadsize'), null, null + ); if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { $uploader->setPrefix('downloads_'); $uploader->fetchMedia($_POST['xoops_upload_file'][0]); @@ -338,12 +344,11 @@ $obj->setVar('cat_pid', \Xmf\Request::getInt('cat_pid', 0, 'POST')); //$_POST['cat_pid']); $obj->setVar('cat_title', \Xmf\Request::getString('cat_title', '', 'POST')); //$_POST['cat_title']); $obj->setVar('cat_description_main', \Xmf\Request::getString('cat_description_main', '', 'POST')); //$_POST['cat_description_main']); - $obj->setVar('cat_weight', \Xmf\Request::getInt('cat_weight', 0, 'POST')); - + $obj->setVar('cat_weight', \Xmf\Request::getInt('cat_weight', 0, 'POST')); if (\Xmf\Request::hasVar('cat_cid', 'REQUEST')) { if ($cat_cid === \Xmf\Request::getInt('cat_pid', 0, 'POST')) { - $erreur = true; + $erreur = true; $errorMessage .= _AM_TDMDOWNLOADS_ERREUR_CAT; } } @@ -352,7 +357,7 @@ } else { if ($categoryHandler->insert($obj)) { /** @var \XoopsModules\Tdmdownloads\Category $obj */ - $newcat_cid = $obj->getNewEnreg($db); + $newcat_cid = $obj->getNewEnreg($db); //permission pour voir $perm_id = \Xmf\Request::hasVar('cat_cid', 'POST') ? $cat_cid : $newcat_cid; /** @var \XoopsGroupPermHandler $grouppermHandler */ diff --git a/admin/downloads.php b/admin/downloads.php index 5bc1dbe..50d5500 100644 --- a/admin/downloads.php +++ b/admin/downloads.php @@ -15,7 +15,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ require __DIR__ . '/admin_header.php'; @@ -62,9 +62,9 @@ } $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); - $limit = $helper->getConfig('perpageadmin'); + $limit = $helper->getConfig('perpageadmin'); $categoryArray = $categoryHandler->getAll(); - $numrowscat = count($categoryArray); + $numrowscat = count($categoryArray); // redirection si il n'y a pas de catégories if (0 === $numrowscat) { @@ -84,7 +84,7 @@ $criteria->add(new \Criteria('status', 0, '!=')); $statusDisplay = 1; } - $documentSort = 1; + $documentSort = 1; $documentOrder = 1; if (\Xmf\Request::hasVar('document_tri')) { if (1 == \Xmf\Request::getInt('document_tri')) { @@ -126,11 +126,11 @@ $criteria->setStart($start); $criteria->setLimit($limit); //pour faire une jointure de table - $downloadsHandler->table_link = $downloadsHandler->db->prefix('tdmdownloads_cat'); // Nom de la table en jointure - $downloadsHandler->field_link = 'cat_cid'; // champ de la table en jointure + $downloadsHandler->table_link = $downloadsHandler->db->prefix('tdmdownloads_cat'); // Nom de la table en jointure + $downloadsHandler->field_link = 'cat_cid'; // champ de la table en jointure $downloadsHandler->field_object = 'cid'; // champ de la table courante - $downloadsArray = $downloadsHandler->getByLink($criteria); - $numrows = $downloadsHandler->getCount($criteria); + $downloadsArray = $downloadsHandler->getByLink($criteria); + $numrows = $downloadsHandler->getCount($criteria); $pagenav = ''; if ($numrows > $limit) { @@ -164,18 +164,18 @@ $selectOrder .= ' '; $GLOBALS['xoopsTpl']->assign('selectOrder', $selectOrder); - $mytree = new \XoopsModules\Tdmdownloads\Tree($categoryArray, 'cat_cid', 'cat_pid'); - $class = 'odd'; + $mytree = new \XoopsModules\Tdmdownloads\Tree($categoryArray, 'cat_cid', 'cat_pid'); + $class = 'odd'; $downloads = []; foreach (array_keys($downloadsArray) as $i) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloadsArray */ $download = [ - 'category' => $utility->getPathTree($mytree, $downloadsArray[$i]->getVar('cid'), $categoryArray, 'cat_title', $prefix = ' '), - 'cid' => $downloadsArray[$i]->getVar('cid'), - 'lid' => $i, - 'title' => $downloadsArray[$i]->getVar('title'), - 'hits' => $downloadsArray[$i]->getVar('hits'), - 'rating' => number_format($downloadsArray[$i]->getVar('rating'), 1), + 'category' => $utility->getPathTree($mytree, $downloadsArray[$i]->getVar('cid'), $categoryArray, 'cat_title', $prefix = ' '), + 'cid' => $downloadsArray[$i]->getVar('cid'), + 'lid' => $i, + 'title' => $downloadsArray[$i]->getVar('title'), + 'hits' => $downloadsArray[$i]->getVar('hits'), + 'rating' => number_format($downloadsArray[$i]->getVar('rating'), 1), 'statut_display' => $statusDisplay, ]; $GLOBALS['xoopsTpl']->append('downloads_list', $download); @@ -232,7 +232,7 @@ case 'del_downloads': global $xoopsModule; $downloads_lid = \Xmf\Request::getInt('downloads_lid', 0, 'GET'); - $obj = $downloadsHandler->get($downloads_lid); + $obj = $downloadsHandler->get($downloads_lid); if (\Xmf\Request::hasVar('ok') && 1 == \Xmf\Request::getInt('ok')) { if (!$GLOBALS['xoopsSecurity']->check()) { redirect_header('downloads.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); @@ -280,7 +280,7 @@ if ((1 == $helper->getConfig('usetag')) && class_exists(LinkHandler::class)) { /** @var \XoopsModules\Tag\LinkHandler $linkHandler */ $linkHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Link'); - $criteria = new \CriteriaCompo(); + $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('tag_itemid', $downloads_lid)); $downloadsTags = $linkHandler->getAll($criteria); foreach (array_keys($downloadsTags) as $i) { @@ -310,7 +310,7 @@ xoops_confirm( ['ok' => 1, 'downloads_lid' => $downloads_lid, 'op' => 'del_downloads'], $_SERVER['REQUEST_URI'], - sprintf(_AM_TDMDOWNLOADS_FORMSUREDEL, $obj->getVar('title')) . '

' . _AM_TDMDOWNLOADS_FORMWITHFILE . ' ' . $obj->getVar('url') . '
' + sprintf(_AM_TDMDOWNLOADS_FORMSUREDEL, $obj->getVar('title')) . '

' . _AM_TDMDOWNLOADS_FORMWITHFILE . ' ' . $obj->getVar('url') . '
' ); } break; @@ -336,9 +336,9 @@ //catégorie //$view_category = $categoryHandler->get($viewDownloads->getVar('cid')); $categoryArray = $categoryHandler->getAll(); - $mytree = new \XoopsModules\Tdmdownloads\Tree($categoryArray, 'cat_cid', 'cat_pid'); + $mytree = new \XoopsModules\Tdmdownloads\Tree($categoryArray, 'cat_cid', 'cat_pid'); // sortie des informations - $downloads_title = $viewDownloads->getVar('title'); + $downloads_title = $viewDownloads->getVar('title'); $downloads_description = $viewDownloads->getVar('description'); //permet d'enlever [pagebreak] du texte $downloads_description = str_replace('[pagebreak]', '', $downloads_description); @@ -346,11 +346,11 @@ $category = $utility->getPathTree($mytree, $viewDownloads->getVar('cid'), $categoryArray, 'cat_title', $prefix = ' '); // affichages des informations du téléchargement $download = [ - 'title' => $downloads_title, + 'title' => $downloads_title, 'description' => $downloads_description, - 'cid' => $viewDownloads->getVar('cid'), - 'lid' => $downloads_lid, - 'category' => $category, + 'cid' => $viewDownloads->getVar('cid'), + 'lid' => $downloads_lid, + 'category' => $category, ]; $criteria = new \CriteriaCompo(); @@ -358,7 +358,7 @@ $criteria->setOrder('ASC'); $criteria->add(new \Criteria('status', 1)); $downloads_field = $fieldHandler->getAll($criteria); - $fieldsList = []; + $fieldsList = []; foreach (array_keys($downloads_field) as $i) { /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ if (1 == $downloads_field[$i]->getVar('status_def')) { @@ -387,7 +387,7 @@ } } } else { - $contenu = ''; + $contenu = ''; $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('lid', $downloads_lid)); $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid'))); @@ -419,11 +419,11 @@ $download['logourl'] = $viewDownloads->getVar('logourl'); } } - $download['date'] = formatTimestamp($viewDownloads->getVar('date')); + $download['date'] = formatTimestamp($viewDownloads->getVar('date')); $download['submitter'] = XoopsUser::getUnameFromId($viewDownloads->getVar('submitter')); - $download['hits'] = $viewDownloads->getVar('hits'); - $download['rating'] = number_format($viewDownloads->getVar('rating'), 1); - $download['votes'] = $viewDownloads->getVar('votes'); + $download['hits'] = $viewDownloads->getVar('hits'); + $download['rating'] = number_format($viewDownloads->getVar('rating'), 1); + $download['votes'] = $viewDownloads->getVar('votes'); if (true === $helper->getConfig('use_paypal') && '' !== $viewDownloads->getVar('paypal')) { $download['paypal'] = $viewDownloads->getVar('paypal'); @@ -433,22 +433,22 @@ $GLOBALS['xoopsTpl']->assign('download', $download); // Utilisateur enregistré - $ratings = []; + $ratings = []; $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('lid', $downloads_lid)); $criteria->add(new \Criteria('ratinguser', 0, '!=')); - $votedataArray = $ratingHandler->getAll($criteria); - $votesTotal = count($votedataArray); + $votedataArray = $ratingHandler->getAll($criteria); + $votesTotal = count($votedataArray); $ratings['user_total'] = $votesTotal; - $userList = []; + $userList = []; foreach (array_keys($votedataArray) as $i) { /** @var \XoopsModules\Tdmdownloads\Rating[] $votedataArray */ $userList[] = [ - 'ratinguser' => \XoopsUser::getUnameFromId($votedataArray[$i]->getVar('ratinguser')), - 'ratinghostname' => $votedataArray[$i]->getVar('ratinghostname'), - 'rating' => $votedataArray[$i]->getVar('rating'), + 'ratinguser' => \XoopsUser::getUnameFromId($votedataArray[$i]->getVar('ratinguser')), + 'ratinghostname' => $votedataArray[$i]->getVar('ratinghostname'), + 'rating' => $votedataArray[$i]->getVar('rating'), 'ratingtimestamp' => formatTimestamp($votedataArray[$i]->getVar('ratingtimestamp')), - 'myTextForm' => myTextForm('downloads.php?op=del_vote&lid=' . $votedataArray[$i]->getVar('lid') . '&rid=' . $votedataArray[$i]->getVar('ratingid'), 'X'), + 'myTextForm' => myTextForm('downloads.php?op=del_vote&lid=' . $votedataArray[$i]->getVar('lid') . '&rid=' . $votedataArray[$i]->getVar('ratingid'), 'X'), ]; } $ratings['user_list'] = $userList; @@ -456,19 +456,19 @@ $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('lid', $downloads_lid)); $criteria->add(new \Criteria('ratinguser', 0)); - $votedataArray = $ratingHandler->getAll($criteria); - $votesTotal = count($votedataArray); + $votedataArray = $ratingHandler->getAll($criteria); + $votesTotal = count($votedataArray); $ratings['anon_total'] = $votesTotal; - $anon_list = []; + $anon_list = []; foreach (array_keys($votedataArray) as $i) { $anon_list[] = [ - 'ratinghostname' => $votedataArray[$i]->getVar('ratinghostname'), - 'rating' => $votedataArray[$i]->getVar('rating'), + 'ratinghostname' => $votedataArray[$i]->getVar('ratinghostname'), + 'rating' => $votedataArray[$i]->getVar('rating'), 'ratingtimestamp' => formatTimestamp($votedataArray[$i]->getVar('ratingtimestamp')), - 'myTextForm' => myTextForm('downloads.php?op=del_vote&lid=' . $votedataArray[$i]->getVar('lid') . '&rid=' . $votedataArray[$i]->getVar('ratingid'), 'X'), + 'myTextForm' => myTextForm('downloads.php?op=del_vote&lid=' . $votedataArray[$i]->getVar('lid') . '&rid=' . $votedataArray[$i]->getVar('ratingid'), 'X'), ]; } - $ratings['anon_list'] = $anon_list; + $ratings['anon_list'] = $anon_list; $ratings['votes_total'] = $ratings['user_total'] + $ratings['anon_total']; $GLOBALS['xoopsTpl']->assign('ratings', $ratings); $GLOBALS['xoopsTpl']->assign('download_detail', true); @@ -480,8 +480,8 @@ $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('lid', \Xmf\Request::getInt('lid'))); $votedataArray = $ratingHandler->getAll($criteria); - $votesTotal = $ratingHandler->getCount($criteria); - $obj = $downloadsHandler->get(\Xmf\Request::getInt('lid')); + $votesTotal = $ratingHandler->getCount($criteria); + $obj = $downloadsHandler->get(\Xmf\Request::getInt('lid')); if (0 === $votesTotal) { $obj->setVar('rating', number_format(0, 1)); $obj->setVar('votes', 0); @@ -519,9 +519,9 @@ } else { $obj = $downloadsHandler->create(); } - $erreur = false; + $erreur = false; $errorMessage = ''; - $donnee = []; + $donnee = []; $obj->setVar('title', \Xmf\Request::getString('title', '', 'POST')); $obj->setVar('cid', \Xmf\Request::getInt('cid', 0, 'POST')); $obj->setVar('homepage', formatURL(\Xmf\Request::getUrl('homepage', '', 'POST'))); @@ -577,14 +577,14 @@ // erreur si la description est vide if (\Xmf\Request::hasVar('description', 'POST')) { if ('' === \Xmf\Request::getString('description', '')) { - $erreur = true; + $erreur = true; $errorMessage .= _AM_TDMDOWNLOADS_ERREUR_NODESCRIPTION . '
'; } } // erreur si la catégorie est vide if (\Xmf\Request::hasVar('cid', 'POST')) { if (0 == \Xmf\Request::getInt('cid', 0, 'POST')) { - $erreur = true; + $erreur = true; $errorMessage .= _AM_TDMDOWNLOADS_ERREUR_NOCAT . '
'; } } @@ -596,7 +596,7 @@ foreach (array_keys($downloads_field) as $i) { /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ if (0 == $downloads_field[$i]->getVar('status_def')) { - $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); + $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); $donnee[$fieldName] = \Xmf\Request::getString($fieldName, '', 'POST'); } } @@ -613,156 +613,158 @@ $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); break; } - // Pour le fichier - $mediaSize = 0; - if (isset($_POST['xoops_upload_file'][0])) { - $uploader = new \XoopsMediaUploader($uploaddir_downloads, $helper->getConfig('mimetypes'), $helper->getConfig('maxuploadsize'), null, null); - if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { - if ($helper->getConfig('newnamedownload')) { - $uploader->setPrefix($helper->getConfig('prefixdownloads')); - } - $uploader->fetchMedia($_POST['xoops_upload_file'][0]); - if (!$uploader->upload()) { - $errorMessage .= $uploader->getErrors() . '
'; - $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); - $form = $obj->getForm($donnee, true); - $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); - break; - } - $mediaSize = $uploader->getMediaSize(); - $obj->setVar('url', $uploadurl_downloads . $uploader->getSavedFileName()); - } else { - if ($_FILES['attachedfile']['name'] > '') { - // file name was given, but fetchMedia failed - show error when e.g. file size exceed maxuploadsize - $errorMessage .= $uploader->getErrors() . '
'; - $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); - $form = $obj->getForm($donnee, true); - $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); - break; - } - $obj->setVar('url', \Xmf\Request::getUrl('url', '', 'POST')); + // Pour le fichier + $mediaSize = 0; + if (isset($_POST['xoops_upload_file'][0])) { + $uploader = new \XoopsMediaUploader($uploaddir_downloads, $helper->getConfig('mimetypes'), $helper->getConfig('maxuploadsize'), null, null); + if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { + if ($helper->getConfig('newnamedownload')) { + $uploader->setPrefix($helper->getConfig('prefixdownloads')); } - } else { - $obj->setVar('url', \Xmf\Request::getUrl('url', '', 'POST')); - } - // Pour l'image - if (isset($_POST['xoops_upload_file'][1])) { - $uploader_2 = new \XoopsMediaUploader($uploaddir_shots, [ - 'image/gif', - 'image/jpeg', - 'image/pjpeg', - 'image/x-png', - 'image/png', - ], $helper->getConfig('maxuploadsize'), null, null); - if ($uploader_2->fetchMedia($_POST['xoops_upload_file'][1])) { - $uploader_2->setPrefix('downloads_'); - $uploader_2->fetchMedia($_POST['xoops_upload_file'][1]); - if (!$uploader_2->upload()) { - $errorMessage .= $uploader_2->getErrors() . '
'; - $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); - $form = $obj->getForm($donnee, true); - $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); - break; - } - $obj->setVar('logourl', $uploader_2->getSavedFileName()); - } else { - if ($_FILES['attachedimage']['name'] > '') { - // file name was given, but fetchMedia failed - show error when e.g. file size exceed maxuploadsize - $errorMessage .= $uploader_2->getErrors() . '
'; - $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); - $form = $obj->getForm($donnee, true); - $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); - break; - } - $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'POST')); + $uploader->fetchMedia($_POST['xoops_upload_file'][0]); + if (!$uploader->upload()) { + $errorMessage .= $uploader->getErrors() . '
'; + $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); + $form = $obj->getForm($donnee, true); + $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); + break; } + $mediaSize = $uploader->getMediaSize(); + $obj->setVar('url', $uploadurl_downloads . $uploader->getSavedFileName()); } else { - $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'POST')); - } - //Automatic file size - if (Xmf\Request::getString('sizeValue', '') == ''){ - if ($mediaSize == 0) { - $obj->setVar('size', $utility::GetFileSize(Xmf\Request::getUrl('url', ''))); - } else { - $obj->setVar('size', $utility::FileSizeConvert($mediaSize)); - } - } else { - $obj->setVar('size', Xmf\Request::getFloat('sizeValue', 0) . ' ' . Xmf\Request::getString('sizeType', '')); - } - $timeToRedirect = 2; - if ($obj->getVar('size') == 0){ - $obj->setVar('size', ''); - $error_message = _AM_TDMDOWNLOADS_ERREUR_SIZE; - $timeToRedirect = 10; - } - // enregistrement - if ($downloadsHandler->insert($obj)) { - if (!\Xmf\Request::hasVar('downloads_modified')) { - $lidDownloads = $obj->getNewEnreg($db); - } else { - $lidDownloads = \Xmf\Request::getInt('lid'); + if ($_FILES['attachedfile']['name'] > '') { + // file name was given, but fetchMedia failed - show error when e.g. file size exceed maxuploadsize + $errorMessage .= $uploader->getErrors() . '
'; + $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); + $form = $obj->getForm($donnee, true); + $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); + break; } - //tags - if ((1 == $helper->getConfig('usetag')) && class_exists(TagHandler::class)) { - /** @var \XoopsModules\Tag\TagHandler $tagHandler */ - $tagHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Tag'); - $tagHandler->updateByItem($_POST['tag'], $lidDownloads, $moduleDirName, 0); + $obj->setVar('url', \Xmf\Request::getUrl('url', '', 'POST')); + } + } else { + $obj->setVar('url', \Xmf\Request::getUrl('url', '', 'POST')); + } + // Pour l'image + if (isset($_POST['xoops_upload_file'][1])) { + $uploader_2 = new \XoopsMediaUploader( + $uploaddir_shots, [ + 'image/gif', + 'image/jpeg', + 'image/pjpeg', + 'image/x-png', + 'image/png', + ], $helper->getConfig('maxuploadsize'), null, null + ); + if ($uploader_2->fetchMedia($_POST['xoops_upload_file'][1])) { + $uploader_2->setPrefix('downloads_'); + $uploader_2->fetchMedia($_POST['xoops_upload_file'][1]); + if (!$uploader_2->upload()) { + $errorMessage .= $uploader_2->getErrors() . '
'; + $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); + $form = $obj->getForm($donnee, true); + $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); + break; } - // Récupération des champs supplémentaires: - $criteria = new \CriteriaCompo(); - $criteria->setSort('weight ASC, title'); - $criteria->setOrder('ASC'); - $downloads_field = $fieldHandler->getAll($criteria); - foreach (array_keys($downloads_field) as $i) { - if (0 == $downloads_field[$i]->getVar('status_def')) { - $iddata = 'iddata' . $downloads_field[$i]->getVar('fid'); - if (\Xmf\Request::hasVar($iddata, 'POST')) { - if ('' === \Xmf\Request::getString($iddata, '')) { - $objdata = $fielddataHandler->create(); - } else { - $objdata = $fielddataHandler->get(\Xmf\Request::getString($iddata, '', 'POST')); - } - } else { + $obj->setVar('logourl', $uploader_2->getSavedFileName()); + } else { + if ($_FILES['attachedimage']['name'] > '') { + // file name was given, but fetchMedia failed - show error when e.g. file size exceed maxuploadsize + $errorMessage .= $uploader_2->getErrors() . '
'; + $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); + $form = $obj->getForm($donnee, true); + $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); + break; + } + $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'POST')); + } + } else { + $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'POST')); + } + //Automatic file size + if (Xmf\Request::getString('sizeValue', '') == '') { + if ($mediaSize == 0) { + $obj->setVar('size', $utility::getFileSize(Xmf\Request::getUrl('url', ''))); + } else { + $obj->setVar('size', $utility::convertFileSize($mediaSize)); + } + } else { + $obj->setVar('size', Xmf\Request::getFloat('sizeValue', 0) . ' ' . Xmf\Request::getString('sizeType', '')); + } + $timeToRedirect = 2; + if ($obj->getVar('size') == 0) { + $obj->setVar('size', ''); + $error_message = _AM_TDMDOWNLOADS_ERREUR_SIZE; + $timeToRedirect = 10; + } + // enregistrement + if ($downloadsHandler->insert($obj)) { + if (!\Xmf\Request::hasVar('downloads_modified')) { + $lidDownloads = $obj->getNewEnreg($db); + } else { + $lidDownloads = \Xmf\Request::getInt('lid'); + } + //tags + if ((1 == $helper->getConfig('usetag')) && class_exists(TagHandler::class)) { + /** @var \XoopsModules\Tag\TagHandler $tagHandler */ + $tagHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Tag'); + $tagHandler->updateByItem($_POST['tag'], $lidDownloads, $moduleDirName, 0); + } + // Récupération des champs supplémentaires: + $criteria = new \CriteriaCompo(); + $criteria->setSort('weight ASC, title'); + $criteria->setOrder('ASC'); + $downloads_field = $fieldHandler->getAll($criteria); + foreach (array_keys($downloads_field) as $i) { + if (0 == $downloads_field[$i]->getVar('status_def')) { + $iddata = 'iddata' . $downloads_field[$i]->getVar('fid'); + if (\Xmf\Request::hasVar($iddata, 'POST')) { + if ('' === \Xmf\Request::getString($iddata, '')) { $objdata = $fielddataHandler->create(); + } else { + $objdata = $fielddataHandler->get(\Xmf\Request::getString($iddata, '', 'POST')); } - $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); - $objdata->setVar('data', \Xmf\Request::getString($fieldName, '', 'POST')); - $objdata->setVar('lid', $lidDownloads); - $objdata->setVar('fid', $downloads_field[$i]->getVar('fid')); - $fielddataHandler->insert($objdata) || $objdata->getHtmlErrors(); + } else { + $objdata = $fielddataHandler->create(); } + $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); + $objdata->setVar('data', \Xmf\Request::getString($fieldName, '', 'POST')); + $objdata->setVar('lid', $lidDownloads); + $objdata->setVar('fid', $downloads_field[$i]->getVar('fid')); + $fielddataHandler->insert($objdata) || $objdata->getHtmlErrors(); } - //permission pour télécharger - if (2 == $helper->getConfig('permission_download')) { - /** @var \XoopsGroupPermHandler $grouppermHandler */ - $grouppermHandler = xoops_getHandler('groupperm'); - $criteria = new \CriteriaCompo(); - $criteria->add(new \Criteria('gperm_itemid', $lidDownloads, '=')); - $criteria->add(new \Criteria('gperm_modid', $xoopsModule->getVar('mid'), '=')); - $criteria->add(new \Criteria('gperm_name', 'tdmdownloads_download_item', '=')); - $grouppermHandler->deleteAll($criteria); - if (\Xmf\Request::hasVar('item_download', 'POST')) { - foreach ($_POST['item_download'] as $onegroup_id) { - $grouppermHandler->addRight('tdmdownloads_download_item', $lidDownloads, $onegroup_id, $xoopsModule->getVar('mid')); - } + } + //permission pour télécharger + if (2 == $helper->getConfig('permission_download')) { + /** @var \XoopsGroupPermHandler $grouppermHandler */ + $grouppermHandler = xoops_getHandler('groupperm'); + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('gperm_itemid', $lidDownloads, '=')); + $criteria->add(new \Criteria('gperm_modid', $xoopsModule->getVar('mid'), '=')); + $criteria->add(new \Criteria('gperm_name', 'tdmdownloads_download_item', '=')); + $grouppermHandler->deleteAll($criteria); + if (\Xmf\Request::hasVar('item_download', 'POST')) { + foreach ($_POST['item_download'] as $onegroup_id) { + $grouppermHandler->addRight('tdmdownloads_download_item', $lidDownloads, $onegroup_id, $xoopsModule->getVar('mid')); } } - // pour les notifications uniquement lors d'un nouveau téléchargement - if (\Xmf\Request::hasVar('downloads_modified')) { - $tags = []; - $tags['FILE_NAME'] = \Xmf\Request::getString('title', '', 'POST'); - $tags['FILE_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/singlefile.php?cid=' . \Xmf\Request::getInt('cid', 0, 'POST') . '&lid=' . $lidDownloads; - $downloadscat_cat = $categoryHandler->get(\Xmf\Request::getInt('cid', 0, 'POST')); - $tags['CATEGORY_NAME'] = $downloadscat_cat->getVar('cat_title'); - $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/viewcat.php?cid=' . \Xmf\Request::getInt('cid', 0, 'POST'); - /** @var \XoopsNotificationHandler $notificationHandler */ - $notificationHandler = xoops_getHandler('notification'); - $notificationHandler->triggerEvent('global', 0, 'new_file', $tags); - $notificationHandler->triggerEvent('category', \Xmf\Request::getInt('cid', 0, 'POST'), 'new_file', $tags); - } - redirect_header('downloads.php', $timeToRedirect, _AM_TDMDOWNLOADS_REDIRECT_SAVE . '

' . $error_message); } - $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); + // pour les notifications uniquement lors d'un nouveau téléchargement + if (\Xmf\Request::hasVar('downloads_modified')) { + $tags = []; + $tags['FILE_NAME'] = \Xmf\Request::getString('title', '', 'POST'); + $tags['FILE_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/singlefile.php?cid=' . \Xmf\Request::getInt('cid', 0, 'POST') . '&lid=' . $lidDownloads; + $downloadscat_cat = $categoryHandler->get(\Xmf\Request::getInt('cid', 0, 'POST')); + $tags['CATEGORY_NAME'] = $downloadscat_cat->getVar('cat_title'); + $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/viewcat.php?cid=' . \Xmf\Request::getInt('cid', 0, 'POST'); + /** @var \XoopsNotificationHandler $notificationHandler */ + $notificationHandler = xoops_getHandler('notification'); + $notificationHandler->triggerEvent('global', 0, 'new_file', $tags); + $notificationHandler->triggerEvent('category', \Xmf\Request::getInt('cid', 0, 'POST'), 'new_file', $tags); + } + redirect_header('downloads.php', $timeToRedirect, _AM_TDMDOWNLOADS_REDIRECT_SAVE . '

' . $error_message); + } + $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); $form = $obj->getForm($donnee, true); $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); diff --git a/admin/field.php b/admin/field.php index 011522d..bea6ad6 100644 --- a/admin/field.php +++ b/admin/field.php @@ -1,4 +1,5 @@ create(); + $obj = $fieldHandler->create(); /** @var \XoopsThemeForm $form */ $form = $obj->getForm(); $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); @@ -174,18 +175,20 @@ } else { $obj = $fieldHandler->create(); } - $erreur = false; + $erreur = false; $errorMessage = ''; // Récupération des variables: // Pour l'image require_once XOOPS_ROOT_PATH . '/class/uploader.php'; - $uploader = new \XoopsMediaUploader($uploaddir_field, [ + $uploader = new \XoopsMediaUploader( + $uploaddir_field, [ 'image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png', - ], $helper->getConfig('maxuploadsize'), 16, null); + ], $helper->getConfig('maxuploadsize'), 16, null + ); if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { $uploader->setPrefix('downloads_'); $uploader->fetchMedia($_POST['xoops_upload_file'][0]); diff --git a/admin/import.php b/admin/import.php index bcd6549..fc4b65e 100644 --- a/admin/import.php +++ b/admin/import.php @@ -1,4 +1,5 @@ queryF('INSERT INTO ' . $xoopsDB->prefix('tdmdownloads_cat') . " (cat_cid, cat_pid, cat_title, cat_imgurl, cat_description_main, cat_weight ) VALUES ('" . $donnees['cid'] . "', '" . $donnees['pid'] . "', '" . $title . "', '" . $img . "', '', '0')"); if (!$insert) { $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['title']]; @@ -75,43 +76,45 @@ function importMydownloads($path = '', $imgurl = '') //On recupere la description $requete = $xoopsDB->queryF('SELECT description FROM ' . $xoopsDB->prefix('mydownloads_text') . " WHERE lid = '" . $donnees['lid'] . "'"); list($description) = $xoopsDB->fetchRow($requete); - $insert = $xoopsDB->queryF('INSERT INTO ' - . $xoopsDB->prefix('tdmdownloads_downloads') - . " ( + $insert = $xoopsDB->queryF( + 'INSERT INTO ' + . $xoopsDB->prefix('tdmdownloads_downloads') + . " ( lid, cid, title, url, homepage, version, size, platform, description, logourl, submitter, status, date, hits, rating, votes, comments, top) VALUES ('" - . $donnees['lid'] - . "', '" - . $donnees['cid'] - . "', '" - . $donnees['title'] - . "', '" - . $donnees['url'] - . "', '" - . $donnees['homepage'] - . "', '" - . $donnees['version'] - . "', '" - . $donnees['size'] - . "', '" - . $donnees['platform'] - . "', '" - . $description - . "', '" - . $donnees['logourl'] - . "', '" - . $donnees['submitter'] - . "', '" - . $donnees['status'] - . "', '" - . $donnees['date'] - . "', '" - . $donnees['hits'] - . "', '" - . $donnees['rating'] - . "', '" - . $donnees['votes'] - . "', '0', '0' )"); + . $donnees['lid'] + . "', '" + . $donnees['cid'] + . "', '" + . $donnees['title'] + . "', '" + . $donnees['url'] + . "', '" + . $donnees['homepage'] + . "', '" + . $donnees['version'] + . "', '" + . $donnees['size'] + . "', '" + . $donnees['platform'] + . "', '" + . $description + . "', '" + . $donnees['logourl'] + . "', '" + . $donnees['submitter'] + . "', '" + . $donnees['status'] + . "', '" + . $donnees['date'] + . "', '" + . $donnees['hits'] + . "', '" + . $donnees['rating'] + . "', '" + . $donnees['votes'] + . "', '0', '0' )" + ); if (!$insert) { $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['title']]; } @@ -122,21 +125,23 @@ function importMydownloads($path = '', $imgurl = '') //Inserer les données des votes $query_vote = $xoopsDB->query('SELECT ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp FROM ' . $xoopsDB->prefix('mydownloads_votedata')); while (false !== ($donnees = $xoopsDB->fetchArray($query_vote))) { - $insert = $xoopsDB->queryF('INSERT INTO ' - . $xoopsDB->prefix('tdmdownloads_votedata') - . " (ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp ) VALUES ('" - . $donnees['ratingid'] - . "', '" - . $donnees['lid'] - . "', '" - . $donnees['ratinguser'] - . "', '" - . $donnees['rating'] - . "', '" - . $donnees['ratinghostname'] - . "', '" - . $donnees['ratingtimestamp'] - . "')"); + $insert = $xoopsDB->queryF( + 'INSERT INTO ' + . $xoopsDB->prefix('tdmdownloads_votedata') + . " (ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp ) VALUES ('" + . $donnees['ratingid'] + . "', '" + . $donnees['lid'] + . "', '" + . $donnees['ratinguser'] + . "', '" + . $donnees['rating'] + . "', '" + . $donnees['ratinghostname'] + . "', '" + . $donnees['ratingtimestamp'] + . "')" + ); if (!$insert) { $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['ratingid']]; } @@ -181,21 +186,12 @@ function importWfdownloads($shots = '', $catimg = '') $img = $donnees['imgurl']; @copy($catimg . $img, XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/cats/' . $img); } - $insert = $xoopsDB->queryF('INSERT INTO ' - . $xoopsDB->prefix('tdmdownloads_cat') - . " (cat_cid, cat_pid, cat_title, cat_imgurl, cat_description_main, cat_weight ) VALUES ('" - . $donnees['cid'] - . "', '" - . $donnees['pid'] - . "', '" - . addcslashes($donnees['title'], "'") - . "', '" - . $img - . "', '" - . addcslashes($donnees['description'], "'") - . "', '" - . $donnees['weight'] - . "')"); + $insert = $xoopsDB->queryF( + 'INSERT INTO ' . $xoopsDB->prefix('tdmdownloads_cat') . " (cat_cid, cat_pid, cat_title, cat_imgurl, cat_description_main, cat_weight ) VALUES ('" . $donnees['cid'] . "', '" . $donnees['pid'] . "', '" . addcslashes($donnees['title'], "'") . "', '" . $img . "', '" . addcslashes( + $donnees['description'], + "'" + ) . "', '" . $donnees['weight'] . "')" + ); if (!$insert) { $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['title']]; } @@ -204,51 +200,24 @@ function importWfdownloads($shots = '', $catimg = '') echo '
'; //Inserer les données des téléchargemnts - $query_links = $xoopsDB->query('SELECT lid, cid, title, url, filename, filetype, homepage, version, size, platform, screenshot, screenshot2, screenshot3, screenshot4, submitter, publisher, status, date, hits, rating, votes, comments, license, mirror, price, paypalemail, features, requirements, homepagetitle, forumid, limitations, versiontypes, dhistory, published, expired, updated, offline, summary, description, ipaddress, notifypub, formulize_idreq FROM ' - . $xoopsDB->prefix('wfdownloads_downloads')); + $query_links = $xoopsDB->query( + 'SELECT lid, cid, title, url, filename, filetype, homepage, version, size, platform, screenshot, screenshot2, screenshot3, screenshot4, submitter, publisher, status, date, hits, rating, votes, comments, license, mirror, price, paypalemail, features, requirements, homepagetitle, forumid, limitations, versiontypes, dhistory, published, expired, updated, offline, summary, description, ipaddress, notifypub, formulize_idreq FROM ' + . $xoopsDB->prefix('wfdownloads_downloads') + ); while (false !== ($donnees = $xoopsDB->fetchArray($query_links))) { if ('' === $donnees['url']) { $newurl = XOOPS_URL . '/uploads/' . $donnees['filename']; } else { $newurl = $donnees['url']; } - $insert = $xoopsDB->queryF('INSERT INTO ' - . $xoopsDB->prefix('tdmdownloads_downloads') - . " ( + $insert = $xoopsDB->queryF( + 'INSERT INTO ' . $xoopsDB->prefix('tdmdownloads_downloads') . " ( lid, cid, title, url, homepage, version, size, platform, description, logourl, submitter, status, date, hits, rating, votes, comments, top) VALUES - ('" - . $donnees['lid'] - . "', '" - . $donnees['cid'] - . "', '" - . addcslashes($donnees['title'], "'") - . "', '" - . $newurl - . "', '" - . $donnees['homepage'] - . "', '" - . $donnees['version'] - . "', '" - . $donnees['size'] - . "', '" - . $donnees['platform'] - . "', '" - . addcslashes($donnees['description'], "'") - . "', '" - . $donnees['screenshot'] - . "', '" - . $donnees['submitter'] - . "', '" - . $donnees['status'] - . "', '" - . $donnees['date'] - . "', '" - . $donnees['hits'] - . "', '" - . $donnees['rating'] - . "', '" - . $donnees['votes'] - . "', '0', '0' )"); + ('" . $donnees['lid'] . "', '" . $donnees['cid'] . "', '" . addcslashes($donnees['title'], "'") . "', '" . $newurl . "', '" . $donnees['homepage'] . "', '" . $donnees['version'] . "', '" . $donnees['size'] . "', '" . $donnees['platform'] . "', '" . addcslashes( + $donnees['description'], + "'" + ) . "', '" . $donnees['screenshot'] . "', '" . $donnees['submitter'] . "', '" . $donnees['status'] . "', '" . $donnees['date'] . "', '" . $donnees['hits'] . "', '" . $donnees['rating'] . "', '" . $donnees['votes'] . "', '0', '0' )" + ); if (!$insert) { $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['title']]; @@ -261,21 +230,23 @@ function importWfdownloads($shots = '', $catimg = '') //Inserer les données des votes $query_vote = $xoopsDB->query('SELECT ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp FROM ' . $xoopsDB->prefix('wfdownloads_votedata')); while (false !== ($donnees = $xoopsDB->fetchArray($query_vote))) { - $insert = $xoopsDB->queryF('INSERT INTO ' - . $xoopsDB->prefix('tdmdownloads_votedata') - . " (ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp ) VALUES ('" - . $donnees['ratingid'] - . "', '" - . $donnees['lid'] - . "', '" - . $donnees['ratinguser'] - . "', '" - . $donnees['rating'] - . "', '" - . $donnees['ratinghostname'] - . "', '" - . $donnees['ratingtimestamp'] - . "')"); + $insert = $xoopsDB->queryF( + 'INSERT INTO ' + . $xoopsDB->prefix('tdmdownloads_votedata') + . " (ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp ) VALUES ('" + . $donnees['ratingid'] + . "', '" + . $donnees['lid'] + . "', '" + . $donnees['ratinguser'] + . "', '" + . $donnees['rating'] + . "', '" + . $donnees['ratinghostname'] + . "', '" + . $donnees['ratingtimestamp'] + . "')" + ); if (!$insert) { echo '' . _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA . ': ' . $donnees['ratingid'] . '
'; } diff --git a/admin/index.php b/admin/index.php index c73c2a3..b611817 100644 --- a/admin/index.php +++ b/admin/index.php @@ -1,4 +1,5 @@ displayNavigation(basename(__FILE__)); //check for latest release -$newRelease = $utility::checkVerModule($helper); -if (!empty($newRelease)) { - $adminObject->addItemButton($newRelease[0], $newRelease[1], 'download', 'style="color : Red"'); -} +//$newRelease = $utility::checkVerModule($helper); +//if (!empty($newRelease)) { +// $adminObject->addItemButton($newRelease[0], $newRelease[1], 'download', 'style="color : Red"'); +//} //------------- Test Data ---------------------------- @@ -104,7 +105,6 @@ $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=load', 'add'); $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=save', 'add'); - // $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), '__DIR__ . /../../testdata/index.php?op=exportschema', 'add'); } diff --git a/admin/menu.php b/admin/menu.php index 5641e6d..9c0581b 100644 --- a/admin/menu.php +++ b/admin/menu.php @@ -1,4 +1,5 @@ loadLanguage('common'); +$helper->loadLanguage('feedback'); $pathIcon32 = \Xmf\Module\Admin::menuIconPath(''); if (is_object($helper->getModule())) { @@ -89,7 +91,7 @@ 'icon' => $pathIcon32 . '/block.png', ]; -if ($helper->getConfig('displayDeveloperTools')) { +if (is_object($helper->getModule()) && $helper->getConfig('displayDeveloperTools')) { $adminmenu[] = [ 'title' => constant('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_MIGRATE'), 'link' => 'admin/migrate.php', diff --git a/admin/migrate.php b/admin/migrate.php index dc26335..c4d024f 100644 --- a/admin/migrate.php +++ b/admin/migrate.php @@ -2,7 +2,7 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2019 XOOPS.org // +// Copyright (c) 2000-2020 XOOPS.org // // // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // diff --git a/admin/modified.php b/admin/modified.php index c43818f..c8b86dc 100644 --- a/admin/modified.php +++ b/admin/modified.php @@ -1,4 +1,5 @@ add(new \Criteria('lid', \Xmf\Request::getInt('mod_id', 0, 'REQUEST'))); $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid'))); $downloadsfieldmoddata = $modifieddataHandler->getAll($criteria); @@ -221,12 +222,16 @@ $adminObject->addItemButton(_MI_TDMDOWNLOADS_ADMENU5, 'modified.php', 'list'); $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); - xoops_confirm([ - 'ok' => 1, - 'mod_id' => \Xmf\Request::getInt('mod_id', 0, 'REQUEST'), - 'new_file' => \Xmf\Request::getString('new_file', 0, 'REQUEST'), - 'op' => 'del_moddownloads', - ], $_SERVER['REQUEST_URI'], _AM_TDMDOWNLOADS_MODIFIED_SURDEL . '
'); + xoops_confirm( + [ + 'ok' => 1, + 'mod_id' => \Xmf\Request::getInt('mod_id', 0, 'REQUEST'), + 'new_file' => \Xmf\Request::getString('new_file', 0, 'REQUEST'), + 'op' => 'del_moddownloads', + ], + $_SERVER['REQUEST_URI'], + _AM_TDMDOWNLOADS_MODIFIED_SURDEL . '
' + ); } break; // permet d'accépter la modification diff --git a/admin/permissions.php b/admin/permissions.php index 416258c..4c21807 100644 --- a/admin/permissions.php +++ b/admin/permissions.php @@ -1,4 +1,5 @@ setSort('weight ASC, title'); $criteria->setOrder('ASC'); $downloads_field = $fieldHandler->getAll($criteria); - $fieldNameBase = ''; + $fieldNameBase = ''; foreach (array_keys($downloads_field) as $i) { /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ - $title_sup = ''; - $contentArray = []; - $lid_arr = []; - $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); - $criteria = new \CriteriaCompo(); + $title_sup = ''; + $contentArray = []; + $lid_arr = []; + $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); + $criteria = new \CriteriaCompo(); $fieldContent[$downloads_field[$i]->getVar('fid')] = 999; if (1 == $downloads_field[$i]->getVar('status_def')) { $criteria->add(new \Criteria('status', 0, '!=')); @@ -96,7 +96,7 @@ function b_tdmdownloads_search_show() } if (4 == $downloads_field[$i]->getVar('fid')) { //platform - $title_sup = _AM_TDMDOWNLOADS_FORMPLATFORM; + $title_sup = _AM_TDMDOWNLOADS_FORMPLATFORM; $platformArray = explode('|', xoops_getModuleOption('platform', $moduleDirName)); foreach ($platformArray as $platform) { $contentArray[$platform] = $platform; @@ -104,7 +104,7 @@ function b_tdmdownloads_search_show() } else { $criteria->setOrder('ASC'); /** @var \XoopsModules\Tdmdownloads\DownloadsHandler $downloadsHandler */ - $downloadsHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Downloads'); + $downloadsHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Downloads'); $tdmdownloadsArray = $downloadsHandler->getAll($criteria); foreach (array_keys($tdmdownloadsArray) as $j) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $tdmdownloadsArray */ @@ -117,7 +117,7 @@ function b_tdmdownloads_search_show() $criteria->setSort('data'); $criteria->setOrder('ASC'); /** @var \XoopsModules\Tdmdownloads\FielddataHandler $fielddataHandler */ - $fielddataHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Fielddata'); + $fielddataHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Fielddata'); $tdmdownloadsArray = $fielddataHandler->getAll($criteria); foreach (array_keys($tdmdownloadsArray) as $j) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $tdmdownloadsArray */ diff --git a/blocks/tdmdownloads_top.php b/blocks/tdmdownloads_top.php index 75ac412..bc4fa30 100644 --- a/blocks/tdmdownloads_top.php +++ b/blocks/tdmdownloads_top.php @@ -9,11 +9,11 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @author Gregory Mage (Aka Mage) * @param $options * @return array + * @author Gregory Mage (Aka Mage) + * @copyright Gregory Mage (Aka Mage) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) */ /** @@ -57,13 +57,14 @@ function b_tdmdownloads_top_show($options) // Add styles global $xoTheme; + $db = null; /** @var \xos_opal_Theme $xoTheme */ $xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $moduleDirName . '/assets/css/blocks.css', null); /** @var \XoopsModules\Tdmdownloads\Utility $utility */ $utility = new \XoopsModules\Tdmdownloads\Utility(); /** @var \XoopsModules\Tdmdownloads\Helper $helper */ - $helper->loadLanguage('main'); + $helper->loadLanguage('main'); $categories = $utility->getItemIds('tdmdownloads_view', $moduleDirName); $criteria = new \CriteriaCompo(); @@ -96,28 +97,28 @@ function b_tdmdownloads_top_show($options) $downloadsArray = $downloadsHandler->getAll($criteria); foreach (array_keys($downloadsArray) as $i) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloadsArray */ - $block[$i]['lid'] = $downloadsArray[$i]->getVar('lid'); - $titleFinal = $downloadsArray[$i]->getVar('title'); + $block[$i]['lid'] = $downloadsArray[$i]->getVar('lid'); + $titleFinal = $downloadsArray[$i]->getVar('title'); if ($lenght_title > 0) { $titleFinal = mb_strlen($titleFinal) > $lenght_title ? mb_substr($titleFinal, 0, $lenght_title) . '...' : $titleFinal; } $block[$i]['title'] = $titleFinal; - $descriptionFinal = ''; + $descriptionFinal = ''; if (true == $use_description) { $description = $downloadsArray[$i]->getVar('description'); //permet d'afficher uniquement la description courte if ($length_description > 0) { - if (false === mb_strpos($description, '[pagebreak]')) { + if (false === mb_strpos($description, '[pagebreak]')) { $descriptionFinal = mb_substr($description, 0, $length_description); if (mb_strlen($description) > mb_strlen($descriptionFinal)) { $descriptionFinal .= ' ...'; } - } else { + } else { $descriptionFinal = mb_substr($description, 0, mb_strpos($description, '[pagebreak]')) . ' ...'; - } + } } else { $descriptionFinal = $description; - } + } } $block[$i]['description'] = $descriptionFinal; $logourl = ''; @@ -140,7 +141,7 @@ function b_tdmdownloads_top_show($options) $block[$i]['blockstyle'] = $blockstyle; } $GLOBALS['xoopsTpl']->assign('tdmblockstyle', $blockstyle); - + $grouppermHandler = xoops_getHandler('groupperm'); $groups = XOOPS_GROUP_ANONYMOUS; if (is_object($GLOBALS['xoopsUser'])) { @@ -150,7 +151,7 @@ function b_tdmdownloads_top_show($options) $perm_modif = $grouppermHandler->checkRight('tdmdownloads_ac', 8, $groups, $mymodule->getVar('mid')) ? true : false; $GLOBALS['xoopsTpl']->assign('perm_submit', $perm_submit); $GLOBALS['xoopsTpl']->assign('perm_modif', $perm_modif); - + return $block; } @@ -197,14 +198,14 @@ function b_tdmdownloads_top_edit($options) $checked_yes = 'checked'; $checked_no = ''; } - $form .= _MB_TDMDOWNLOADS_INFORMATIONS . ' : ' . _YES . " \n"; - $form .= '' . _NO . "

\n"; + $form .= _MB_TDMDOWNLOADS_INFORMATIONS . ' : ' . _YES . " \n"; + $form .= '' . _NO . "

\n"; $floatSelect = new \XoopsFormSelect('', 'options[6]', $options[6]); $floatSelect->addOption('left', _MB_TDMDOWNLOADS_FLOAT_LEFT); $floatSelect->addOption('right', _MB_TDMDOWNLOADS_FLOAT_RIGHT); - $form .= _MB_TDMDOWNLOADS_FLOAT . $floatSelect->render() . '
'; - $form .= _MB_TDMDOWNLOADS_WIDTH . ' (' . _MB_TDMDOWNLOADS_WIDTHDSC . '):
\n"; - $form .= _MB_TDMDOWNLOADS_DESCRIPTIONDSC . ':
\n"; + $form .= _MB_TDMDOWNLOADS_FLOAT . $floatSelect->render() . '
'; + $form .= _MB_TDMDOWNLOADS_WIDTH . ' (' . _MB_TDMDOWNLOADS_WIDTHDSC . '):
\n"; + $form .= _MB_TDMDOWNLOADS_DESCRIPTIONDSC . ':
\n"; $styleSelect = new \XoopsFormSelect('', 'options[9]', $options[9]); $styleSelect->addOption('default', 'default'); $styleSelect->addOption('simple1', 'simple1'); @@ -212,7 +213,7 @@ function b_tdmdownloads_top_edit($options) $styleSelect->addOption('simple3', 'simple3'); $styleSelect->addOption('simple4', 'simple4'); $form .= _MB_TDMDOWNLOADS_BLOCKSTYLE . ': ' . $styleSelect->render() . '
'; - + array_shift($options); array_shift($options); array_shift($options); diff --git a/brokenfile.php b/brokenfile.php index 93c8334..0b551a7 100644 --- a/brokenfile.php +++ b/brokenfile.php @@ -1,4 +1,5 @@ verify()) { $errorMessage .= $xoopsCaptcha->getMessage() . '
'; - $erreur = true; + $erreur = true; } $obj->setVar('lid', $lid); $obj->setVar('sender', $ratinguser); diff --git a/class/Broken.php b/class/Broken.php index 888ca5d..e6c84c5 100644 --- a/class/Broken.php +++ b/class/Broken.php @@ -13,11 +13,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class Broken * @package XoopsModules\Tdmdownloads diff --git a/class/BrokenHandler.php b/class/BrokenHandler.php index df48841..2072a38 100644 --- a/class/BrokenHandler.php +++ b/class/BrokenHandler.php @@ -13,11 +13,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class BrokenHandler * @package XoopsModules\Tdmdownloads diff --git a/class/Category.php b/class/Category.php index 34e1219..0bd9aad 100644 --- a/class/Category.php +++ b/class/Category.php @@ -13,14 +13,12 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ use XoopsModules\Tdmdownloads; -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class Category * @package XoopsModules\Tdmdownloads @@ -98,12 +96,12 @@ public function getForm($action = false) $editorConfigs['editor'] = $helper->getConfig('editor'); $form->addElement(new \XoopsFormEditor(_AM_TDMDOWNLOADS_FORMTEXT, 'cat_description_main', $editorConfigs), false); //image - $categoryImage = $this->getVar('cat_imgurl') ?: 'blank.gif'; - $uploadirectory = '/uploads/' . $moduleDirName . '/images/cats'; - $imgtray = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMIMG, '
'); - $imgpath = sprintf(_AM_TDMDOWNLOADS_FORMPATH, $uploadirectory); - $imageselect = new \XoopsFormSelect($imgpath, 'downloadscat_img', $categoryImage); - $topics_array = \XoopsLists:: getImgListAsArray(XOOPS_ROOT_PATH . $uploadirectory); + $categoryImage = $this->getVar('cat_imgurl') ?: 'blank.gif'; + $uploadirectory = '/uploads/' . $moduleDirName . '/images/cats'; + $imgtray = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMIMG, '
'); + $imgpath = sprintf(_AM_TDMDOWNLOADS_FORMPATH, $uploadirectory); + $imageselect = new \XoopsFormSelect($imgpath, 'downloadscat_img', $categoryImage); + $topics_array = \XoopsLists:: getImgListAsArray(XOOPS_ROOT_PATH . $uploadirectory); foreach ($topics_array as $image) { $imageselect->addOption((string)$image, $image); } diff --git a/class/CategoryHandler.php b/class/CategoryHandler.php index c773183..4ca3f0e 100644 --- a/class/CategoryHandler.php +++ b/class/CategoryHandler.php @@ -13,11 +13,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class CategoryHandler * @package XoopsModules\Tdmdownloads diff --git a/class/Common/Breadcrumb.php b/class/Common/Breadcrumb.php index a354642..8a08e98 100644 --- a/class/Common/Breadcrumb.php +++ b/class/Common/Breadcrumb.php @@ -28,8 +28,6 @@ * $breadcrumb->addLink( 'bread 3', 'index3.php' ); * echo $breadcrumb->render(); */ -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class Breadcrumb */ diff --git a/class/Common/Configurator.php b/class/Common/Configurator.php index 3341325..117db65 100644 --- a/class/Common/Configurator.php +++ b/class/Common/Configurator.php @@ -21,8 +21,6 @@ * @since 1.05 */ -// require_once dirname(dirname(__DIR__)) . '/include/common.php'; - /** * Class Configurator */ @@ -38,17 +36,14 @@ class Configurator public $oldFolders = []; public $renameTables = []; public $modCopyright; + public $icons; /** * Configurator constructor. */ public function __construct() { - $moduleDirName = basename(dirname(dirname(__DIR__))); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); - - require_once dirname(dirname(__DIR__)) . '/include/config.php'; - $config = getConfig(); + $config = include dirname(dirname(__DIR__)) . '/config/config.php'; $this->name = $config->name; $this->paths = $config->paths; @@ -60,5 +55,8 @@ public function __construct() $this->oldFolders = $config->oldFolders; $this->renameTables = $config->renameTables; $this->modCopyright = $config->modCopyright; + + $this->icons = include dirname(dirname(__DIR__)) . '/config/icons.php'; + $this->paths = include dirname(dirname(__DIR__)) . '/config/paths.php'; } } diff --git a/class/Common/FilesManagement.php b/class/Common/FilesManagement.php index 68fb728..e5248aa 100644 --- a/class/Common/FilesManagement.php +++ b/class/Common/FilesManagement.php @@ -79,10 +79,10 @@ public static function recurseCopy($src, $dst) * * @param string $src source directory to delete * - * @uses \Xmf\Module\Helper::getHelper() + * @return bool true on success * @uses \Xmf\Module\Helper::isUserAdmin() * - * @return bool true on success + * @uses \Xmf\Module\Helper::getHelper() */ public static function deleteDirectory($src) { @@ -151,7 +151,7 @@ public static function rrmdir($src) foreach ($iterator as $fObj) { if ($fObj->isFile()) { $filename = $fObj->getPathname(); - $fObj = null; // clear this iterator object to close the file + $fObj = null; // clear this iterator object to close the file if (!unlink($filename)) { return false; // couldn't delete the file } @@ -210,10 +210,10 @@ public static function rmove($src, $dest) * @param string $src - Source of files being moved * @param string $dest - Destination of files being moved * - * @uses \Xmf\Module\Helper::getHelper() + * @return bool true on success * @uses \Xmf\Module\Helper::isUserAdmin() * - * @return bool true on success + * @uses \Xmf\Module\Helper::getHelper() */ public static function rcopy($src, $dest) { diff --git a/class/Common/FineimpuploadHandler.php b/class/Common/FineimpuploadHandler.php index de0508d..39cdb31 100644 --- a/class/Common/FineimpuploadHandler.php +++ b/class/Common/FineimpuploadHandler.php @@ -103,7 +103,7 @@ class FineimpuploadHandler extends \SystemFineUploadHandler public function __construct(\stdClass $claims) { parent::__construct($claims); - $this->allowedMimeTypes = ['image/gif', 'image/jpeg', 'image/png', 'application/zip']; + $this->allowedMimeTypes = ['image/gif', 'image/jpeg', 'image/png', 'application/zip']; $this->allowedExtensions = ['gif', 'jpeg', 'jpg', 'png', 'zip']; } @@ -117,24 +117,24 @@ protected function storeUploadedFile($target, $mimeType, $uid) { $moduleDirName = basename(dirname(dirname(__DIR__))); $moduleDirNameUpper = mb_strtoupper($moduleDirName); - include_once XOOPS_ROOT_PATH .'/modules/'. $moduleDirName .'/header.php'; + require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/header.php'; $this->pathUpload = constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH'); - $utility = new \XoopsModules\Tdmdownloads\Utility(); + $utility = new \XoopsModules\Tdmdownloads\Utility(); /** @var \XoopsModules\Tdmdownloads\Helper $helper */ $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); -// if ( WGGALLERY_PERM_SUBMITAPPR === $permissionsHandler->permGlobalSubmit()) { -// $this->permUseralbum = WGGALLERY_STATE_APPROVAL_VAL; -// } else { -// $this->permUseralbum = WGGALLERY_STATE_ONLINE_VAL; -// } + // if ( WGGALLERY_PERM_SUBMITAPPR === $permissionsHandler->permGlobalSubmit()) { + // $this->permUseralbum = WGGALLERY_STATE_APPROVAL_VAL; + // } else { + // $this->permUseralbum = WGGALLERY_STATE_ONLINE_VAL; + // } $this->permUseralbum = 1; //TODO: handle an option, whether images should be online immediately or not $pathParts = pathinfo($this->getName()); $this->imageName = uniqid('img', true) . '.' . strtolower($pathParts['extension']); - $this->imageNicename = str_replace(['_', '-'], ' ', $pathParts['filename']); + $this->imageNicename = str_replace(['_', '-'], ' ', $pathParts['filename']); $this->imageNameLarge = uniqid('imgl', true) . '.' . strtolower($pathParts['extension']); $this->imagePath = $this->pathUpload . '/large/' . $this->imageNameLarge; @@ -149,20 +149,24 @@ protected function storeUploadedFile($target, $mimeType, $uid) $ret = $this->handleImageDB(); if (false === $ret) { return [ - 'error' => sprintf(_FAILSAVEIMG, $this->imageNicename) + 'error' => sprintf(_FAILSAVEIMG, $this->imageNicename), ]; } // load watermark settings - $albumObj = $albumsHandler->get($this->claims->cat); - $wmId = $albumObj->getVar('alb_wmid'); + $albumObj = $albumsHandler->get($this->claims->cat); + $wmId = $albumObj->getVar('alb_wmid'); $wmTargetM = false; $wmTargetL = false; - if ( 0 < $wmId) { + if (0 < $wmId) { $watermarksObj = $watermarksHandler->get($wmId); - $wmTarget = $watermarksObj->getVar('wm_target'); - if ( constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_A') === $wmTarget || constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_M') === $wmTarget) {$wmTargetM = true;} - if ( constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_A') === $wmTarget || constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_L') === $wmTarget) {$wmTargetL = true;} + $wmTarget = $watermarksObj->getVar('wm_target'); + if (constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_A') === $wmTarget || constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_M') === $wmTarget) { + $wmTargetM = true; + } + if (constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_A') === $wmTarget || constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_L') === $wmTarget) { + $wmTargetL = true; + } } // create medium image @@ -186,18 +190,18 @@ protected function storeUploadedFile($target, $mimeType, $uid) } // add watermark to large image - if ( true === $wmTargetL) { + if (true === $wmTargetL) { $imgWm = $this->pathUpload . '/large/' . $this->imageNameLarge; - $resWm = $watermarksHandler->watermarkImage( $wmId, $imgWm, $imgWm ); - if ( true !== $resWm) { + $resWm = $watermarksHandler->watermarkImage($wmId, $imgWm, $imgWm); + if (true !== $resWm) { return ['error' => sprintf(constant($moduleDirNameUpper . '_' . 'FAILSAVEWM_LARGE'), $this->imageNicename, $resWm)]; + } } - } // add watermark to medium image - if ( true === $wmTargetM) { + if (true === $wmTargetM) { $imgWm = $this->pathUpload . '/medium/' . $this->imageName; - $resWm = $watermarksHandler->watermarkImage( $wmId, $imgWm, $imgWm ); - if ( true !== $resWm) { + $resWm = $watermarksHandler->watermarkImage($wmId, $imgWm, $imgWm); + if (true !== $resWm) { return ['error' => sprintf(constant($moduleDirNameUpper . '_' . 'FAILSAVEWM_MEDIUM'), $this->imageNicename, $resWm)]; } } @@ -208,17 +212,18 @@ protected function storeUploadedFile($target, $mimeType, $uid) /** * @return bool */ - private function handleImageDB () { - $moduleDirName = basename(dirname(dirname(__DIR__))); - include_once XOOPS_ROOT_PATH .'/modules/'. $moduleDirName .'/header.php'; + private function handleImageDB() + { + $moduleDirName = basename(dirname(dirname(__DIR__))); + require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/header.php'; global $xoopsUser; $this->getImageDim(); $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); -// $imagesHandler = $helper->getHandler('Images'); + // $imagesHandler = $helper->getHandler('Images'); $imagesHandler = new \XoopsModules\Tdmdownloads\Common\ImagesHandler(); - $imagesObj = $imagesHandler->create(); + $imagesObj = $imagesHandler->create(); // Set Vars $imagesObj->setVar('img_title', $this->imageNicename); $imagesObj->setVar('img_desc', ''); @@ -245,8 +250,8 @@ private function handleImageDB () { /** * @return bool|string */ - private function getImageDim () { - + private function getImageDim() + { switch ($this->imageMimetype) { case'image/png': $img = imagecreatefrompng($this->imagePath); @@ -259,7 +264,7 @@ private function getImageDim () { break; case'application/zip': - $this->imageWidth = 0; + $this->imageWidth = 0; $this->imageHeight = 0; // $img = imagecreatefromgif($this->imagePath); break; diff --git a/class/Common/ImageResizer.php b/class/Common/ImageResizer.php index 0e65313..4dcafce 100644 --- a/class/Common/ImageResizer.php +++ b/class/Common/ImageResizer.php @@ -21,7 +21,6 @@ * @min_xoops 2.5.9 * @author Wedega - Email: - Website: */ - trait ImageResizer { @@ -32,7 +31,7 @@ trait ImageResizer * @param int $max_width * @param int $max_height * @param $imageMimetype - * @return string|boolean + * @return string|bool */ public function resizeImage($sourcefile, $endfile, $max_width, $max_height, $imageMimetype) @@ -65,7 +64,7 @@ public function resizeImage($sourcefile, $endfile, $max_width, $max_height, $ima $divisor = $width / $new_width; $new_height = floor($height / $divisor); } - } else if ($height < $max_height) { + } elseif ($height < $max_height) { $new_height = $height; } else { $new_height = $max_height; @@ -192,7 +191,7 @@ public function mergeImage($src_url, $dest_url, $pos, $of) $dest = imagecreatefromjpeg($dest_url); $src = imagecreatefromjpeg($src_url); // ImageCopy ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h ) -// $src = imagecreatefromjpeg($src_url); + // $src = imagecreatefromjpeg($src_url); if (4 == $of) { switch ($pos) { case 1: @@ -242,7 +241,7 @@ public function mergeImage($src_url, $dest_url, $pos, $of) * @param string $endfile * @param int $max_width * @param int $max_height - * @return string|boolean + * @return string|bool */ /* private function resizeImageSave($endfile, $max_width, $max_height){ // check file extension diff --git a/class/Common/Images.php b/class/Common/Images.php index 25fb7e9..810d6b4 100644 --- a/class/Common/Images.php +++ b/class/Common/Images.php @@ -13,16 +13,14 @@ */ /** - * @copyright 2019 XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @copyright 2020 XOOPS Project (https://xoops.org) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @link https://xoops.org * @author Wedega - Email: - Website: */ use XoopsModules\Tdmdownloads; -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class Object Images */ @@ -88,7 +86,7 @@ public function getFormImages($action = false) { $moduleDirName = basename(dirname(dirname(__DIR__))); $moduleDirNameUpper = mb_strtoupper($moduleDirName); - $helper = Tdmdownloads\Helper::getInstance(); + $helper = Tdmdownloads\Helper::getInstance(); if (false === $action) { $action = $_SERVER['REQUEST_URI']; } diff --git a/class/Common/ImagesHandler.php b/class/Common/ImagesHandler.php index 9ff1a63..b11ba37 100644 --- a/class/Common/ImagesHandler.php +++ b/class/Common/ImagesHandler.php @@ -13,16 +13,14 @@ */ /** - * @copyright 2019 XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @copyright 2020 XOOPS Project (https://xoops.org) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @link https://xoops.org * @author Wedega - Email: - Website: */ use XoopsModules\Tdmdownloads; -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class Object Handler Images */ diff --git a/class/Common/Migrate.php b/class/Common/Migrate.php index e446c3f..f490a9b 100644 --- a/class/Common/Migrate.php +++ b/class/Common/Migrate.php @@ -18,7 +18,7 @@ * @category Migrate * @author Richard Griffith * @copyright 2016 XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @link https://xoops.org */ class Migrate extends \Xmf\Database\Migrate @@ -32,9 +32,12 @@ class Migrate extends \Xmf\Database\Migrate */ public function __construct() { - require_once dirname(dirname(__DIR__)) . '/include/config.php'; - $config = getConfig(); - $this->renameTables = $config->renameTables; + $class = __NAMESPACE__ . '\\' . 'Configurator'; + if (!class_exists($class)) { + throw new \RuntimeException("Class '$class' not found"); + } + $configurator = new $class(); + $this->renameTables = $configurator->renameTables; $moduleDirName = basename(dirname(dirname(__DIR__))); parent::__construct($moduleDirName); @@ -80,8 +83,8 @@ private function moveDoColumns() { $tableName = 'newbb_posts_text'; $srcTableName = 'newbb_posts'; - if (false !== $this->tableHandler->useTable($tableName) - && false !== $this->tableHandler->useTable($srcTableName)) { + if ($this->tableHandler->useTable($tableName) + && $this->tableHandler->useTable($srcTableName)) { $attributes = $this->tableHandler->getColumnAttributes($tableName, 'dohtml'); if (false === $attributes) { $this->synchronizeTable($tableName); @@ -102,6 +105,7 @@ private function moveDoColumns() */ protected function preSyncActions() { + /* // change 'bb' table prefix to 'newbb' $this->changePrefix(); // columns dohtml, dosmiley, doxcode, doimage and dobr moved between tables as some point @@ -109,5 +113,6 @@ protected function preSyncActions() // Convert IP address columns from int to readable varchar(45) for IPv6 $this->convertIPAddresses('newbb_posts', 'poster_ip'); $this->convertIPAddresses('newbb_report', 'reporter_ip'); + */ } } diff --git a/class/Common/ModuleConstants.php b/class/Common/ModuleConstants.php index 606dc5e..539acf4 100644 --- a/class/Common/ModuleConstants.php +++ b/class/Common/ModuleConstants.php @@ -14,7 +14,7 @@ /** * @copyright XOOPS Project https://xoops.org/ - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @package * @since * @author XOOPS Development Team @@ -28,17 +28,17 @@ class ModuleConstants // const MODULE_DIRNAME0 = basename(__DIR__); // static $moddir = basename(dirname(__DIR__)); - public static $moduleDirName; - public static $mydirname2; //set in constructor + public static $moduleDirName = null; + public static $mydirname2 = null; //set in constructor - public static $moduleUrl; - public static $modulePath; - public static $imagesUrl; - public static $imagesPath; - public static $adminUrl; - public static $adminPath; - public static $uploadsUrl; - public static $uploadsPath; + public static $moduleUrl = null; + public static $modulePath = null; + public static $imagesUrl = null; + public static $imagesPath = null; + public static $adminUrl = null; + public static $adminPath = null; + public static $uploadsUrl = null; + public static $uploadsPath = null; // const ROOT = $_SERVER['DOCUMENT_ROOT']."project/"; // const MODULE_DIRNAME = basename(dirname(__DIR__)); @@ -77,119 +77,119 @@ class ModuleConstants /** * do not allow */ - const DISALLOW = 0; + public const DISALLOW = 0; /** * allow */ - const ALLOW = 1; + public const ALLOW = 1; /** * top level Category ID */ - const ALLOW_MEMBERS = 2; + public const ALLOW_MEMBERS = 2; /** * top level Category ID */ - const TOP_LEVEL_CID = 0; + public const TOP_LEVEL_CID = 0; /** * indicates default number of feed items to show */ - const DEFAULT_FEED_COUNT = 10; + public const DEFAULT_FEED_COUNT = 10; /** * maximum number of characters for feed description */ - const MAX_FEED_DESC_COUNT = 1000; + public const MAX_FEED_DESC_COUNT = 1000; /** * feed image height default */ - const FEED_IMG_HEIGHT_DEFAULT = 31; + public const FEED_IMG_HEIGHT_DEFAULT = 31; /** * feed image height maximum */ - const FEED_IMG_HEIGHT_MAX = 400; + public const FEED_IMG_HEIGHT_MAX = 400; /** * feed image width default */ - const FEED_IMG_WIDTH_DEFAULT = 88; + public const FEED_IMG_WIDTH_DEFAULT = 88; /** * feed image width maximum */ - const FEED_IMG_WIDTH_MAX = 144; + public const FEED_IMG_WIDTH_MAX = 144; /** * google magic used for page rank */ - const GOOGLE_MAGIC = 0xE6359A60; + public const GOOGLE_MAGIC = 0xE6359A60; /** * anonymous user's ID */ - const ANON_USER_ID = 0; + public const ANON_USER_ID = 0; /** * default feed type */ - const DEFAULT_FEED_TYPE = 'RSS'; + public const DEFAULT_FEED_TYPE = 'RSS'; /** * number of subcategories to display */ - const SHOW_SUBCAT_COUNT = 5; + public const SHOW_SUBCAT_COUNT = 5; /** * allow HTML in WYSIWYG editor */ - const ALLOW_HTML = 1; + public const ALLOW_HTML = 1; /** * do not allow HTML in WYSIWYG editor */ - const DISALLOW_HTML = 0; + public const DISALLOW_HTML = 0; /** * no delay XOOPS redirect delay (in seconds) */ - const REDIRECT_DELAY_NONE = 0; + public const REDIRECT_DELAY_NONE = 0; /** * short XOOPS redirect delay (in seconds) */ - const REDIRECT_DELAY_SHORT = 1; + public const REDIRECT_DELAY_SHORT = 1; /** * medium XOOPS redirect delay (in seconds) */ - const REDIRECT_DELAY_MEDIUM = 3; + public const REDIRECT_DELAY_MEDIUM = 3; /** * long XOOPS redirect delay (in seconds) */ - const REDIRECT_DELAY_LONG = 7; + public const REDIRECT_DELAY_LONG = 7; /** * maximum acceptable rating */ - const RATING_MAX = 10; + public const RATING_MAX = 10; /** * minimum acceptable rating */ - const RATING_MIN = 1; + public const RATING_MIN = 1; /** * days between ratings from single IP */ - const RATING_WAIT = 1; + public const RATING_WAIT = 1; /** * sort list by popularity */ - const SORT_BY_POPULARITY = 1; + public const SORT_BY_POPULARITY = 1; /** * sort list by rating */ - const SORT_BY_RATING = 2; + public const SORT_BY_RATING = 2; /** * sort list by most recent */ - const SORT_BY_MOST_RECENT = 3; + public const SORT_BY_MOST_RECENT = 3; /** * link status - inactive */ - const STATUS_INACTIVE = 0; + public const STATUS_INACTIVE = 0; /** * new link status */ - const STATUS_NEW = 1; + public const STATUS_NEW = 1; /** * modified link status */ - const STATUS_UPDATED = 1; + public const STATUS_UPDATED = 1; /**#@-*/ diff --git a/class/Common/VersionChecks.php b/class/Common/VersionChecks.php index 08bdbdf..c8ac687 100644 --- a/class/Common/VersionChecks.php +++ b/class/Common/VersionChecks.php @@ -68,11 +68,13 @@ public static function checkVerPhp(\XoopsModule $module = null) $module = \XoopsModule::getByDirname($moduleDirName); } xoops_loadLanguage('admin', $moduleDirName); + xoops_loadLanguage('common', $moduleDirName); + // check for minimum PHP version $success = true; $verNum = PHP_VERSION; - $reqVer =& $module->getInfo('min_php'); + $reqVer = &$module->getInfo('min_php'); if (false !== $reqVer && '' !== $reqVer) { if (version_compare($verNum, $reqVer, '<')) { @@ -101,48 +103,47 @@ public static function checkVerModule($helper, $source = 'github', $default = 'm $moduleDirNameUpper = mb_strtoupper($moduleDirName); $update = ''; $repository = 'XoopsModules25x/' . $moduleDirName; - //$repository = 'XoopsModules25x/publisher'; //for testing only - $ret = ''; - $infoReleasesUrl = "https://api.github.com/repos/$repository/releases"; + // $repository = 'XoopsModules25x/publisher'; //for testing only + $ret = ''; + $infoReleasesUrl = "https://api.github.com/repos/$repository/releases"; if ('github' === $source) { - if (function_exists('curl_init') && false !== ($curlHandle = curl_init())) { - curl_setopt($curlHandle, CURLOPT_URL, $infoReleasesUrl); - curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($curlHandle, CURLOPT_HTTPHEADER, array("User-Agent:Publisher\r\n")); - $curlReturn = curl_exec($curlHandle); - if (false === $curlReturn) { - trigger_error(curl_error($curlHandle)); - } else { - $file = json_decode($curlReturn, false); - $latestVersionLink = sprintf("https://github.com/$repository/archive/%s.zip", $file ? reset($file)->tag_name : $default); - $latestVersion = $file[0]->tag_name; - $prerelease = $file[0]->prerelease; - - if ('master' !== $latestVersionLink) { - $update = constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion; - } - //"PHP-standardized" version - $latestVersion = mb_strtolower($latestVersion); - if (false !== mb_strpos($latestVersion, 'final')) { - $latestVersion = str_replace('_', '', mb_strtolower($latestVersion)); - $latestVersion = str_replace('final', '', mb_strtolower($latestVersion)); - } - - $moduleVersion = ($helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status')); - //"PHP-standardized" version - $moduleVersion = str_replace(' ', '', mb_strtolower($moduleVersion)); - //$moduleVersion = '1.0'; //for testing only - //$moduleDirName = 'publisher'; //for testing only - - if (!$prerelease && version_compare($moduleVersion, $latestVersion, '<')) { - $ret = []; - $ret[] = $update; - $ret[] = $latestVersionLink; - } - } - curl_close($curlHandle); - } + if (function_exists('curl_init') && false !== ($curlHandle = curl_init())) { + curl_setopt($curlHandle, CURLOPT_URL, $infoReleasesUrl); + curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized' + curl_setopt($curlHandle, CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]); + $curlReturn = curl_exec($curlHandle); + if (false === $curlReturn) { + trigger_error(curl_error($curlHandle)); + } elseif (false !== strpos($curlReturn, 'Not Found')) { + trigger_error('Repository Not Found: ' . $infoReleasesUrl); + } else { + $file = json_decode($curlReturn, false); + $latestVersionLink = sprintf("https://github.com/$repository/archive/%s.zip", $file ? reset($file)->tag_name : $default); + $latestVersion = $file[0]->tag_name; + $prerelease = $file[0]->prerelease; + if ('master' !== $latestVersionLink) { + $update = constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion; + } + //"PHP-standardized" version + $latestVersion = mb_strtolower($latestVersion); + if (false !== mb_strpos($latestVersion, 'final')) { + $latestVersion = str_replace('_', '', mb_strtolower($latestVersion)); + $latestVersion = str_replace('final', '', mb_strtolower($latestVersion)); + } + $moduleVersion = ($helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status')); + //"PHP-standardized" version + $moduleVersion = str_replace(' ', '', mb_strtolower($moduleVersion)); + // $moduleVersion = '1.0'; //for testing only + // $moduleDirName = 'publisher'; //for testing only + if (!$prerelease && version_compare($moduleVersion, $latestVersion, '<')) { + $ret = []; + $ret[] = $update; + $ret[] = $latestVersionLink; + } + } + curl_close($curlHandle); + } } return $ret; } diff --git a/class/Downlimit.php b/class/Downlimit.php index 59dd143..6febed8 100644 --- a/class/Downlimit.php +++ b/class/Downlimit.php @@ -13,11 +13,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) and Hossein Azizabadi (Aka voltan) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) and Hossein Azizabadi (Aka voltan) */ -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class Downlimit * @package XoopsModules\Tdmdownloads @@ -25,6 +23,7 @@ class Downlimit extends \XoopsObject { // constructor + public function __construct() { parent::__construct(); diff --git a/class/DownlimitHandler.php b/class/DownlimitHandler.php index d9fb807..cb7f477 100644 --- a/class/DownlimitHandler.php +++ b/class/DownlimitHandler.php @@ -13,11 +13,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) and Hossein Azizabadi (Aka voltan) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) and Hossein Azizabadi (Aka voltan) */ -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class DownlimitHandler * @package XoopsModules\Tdmdownloads diff --git a/class/Downloads.php b/class/Downloads.php index 6ae97f6..40ed3ee 100644 --- a/class/Downloads.php +++ b/class/Downloads.php @@ -15,11 +15,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class Downloads * @package XoopsModules\Tdmdownloads @@ -95,10 +93,10 @@ public function getForm($donnee = [], $erreur = false, $action = false) if ($xoopsUser) { $perm_upload = true; if (!$xoopsUser->isAdmin($xoopsModule->mid())) { - $perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')) ? true : false; + $perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')); } } else { - $perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')) ? true : false; + $perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')); } //nom du formulaire selon l'action (editer ou ajouter): $title = $this->isNew() ? sprintf(_AM_TDMDOWNLOADS_FORMADD) : sprintf(_AM_TDMDOWNLOADS_FORMEDIT); @@ -168,24 +166,24 @@ public function getForm($donnee = [], $erreur = false, $action = false) } if (3 == $downloads_field[$i]->getVar('fid')) { //taille du fichier - if (1 == $downloads_field[$i]->getVar('status')) { - $size_value_arr = explode(' ', $this->getVar('size')); - $aff_size = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMSIZE, ''); - $aff_size->addElement(new \XoopsFormText('', 'sizeValue', 13, 13, $size_value_arr[0])); - if (array_key_exists (1, $size_value_arr) == false){ - $size_value_arr[1] = 'K'; - } - $type = new \XoopsFormSelect('', 'sizeType', $size_value_arr[1]); - $typeArray = [ - 'B' => _AM_TDMDOWNLOADS_BYTES, - 'K' => _AM_TDMDOWNLOADS_KBYTES, - 'M' => _AM_TDMDOWNLOADS_MBYTES, - 'G' => _AM_TDMDOWNLOADS_GBYTES, - 'T' => _AM_TDMDOWNLOADS_TBYTES - ]; - $type->addOptionArray($typeArray); - $aff_size->addElement($type); - $form->addElement($aff_size); + if (1 == $downloads_field[$i]->getVar('status')) { + $size_value_arr = explode(' ', $this->getVar('size')); + $aff_size = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMSIZE, ''); + $aff_size->addElement(new \XoopsFormText('', 'sizeValue', 13, 13, $size_value_arr[0])); + if (array_key_exists(1, $size_value_arr) === false) { + $size_value_arr[1] = 'K'; + } + $type = new \XoopsFormSelect('', 'sizeType', $size_value_arr[1]); + $typeArray = [ + 'B' => _AM_TDMDOWNLOADS_BYTES, + 'K' => _AM_TDMDOWNLOADS_KBYTES, + 'M' => _AM_TDMDOWNLOADS_MBYTES, + 'G' => _AM_TDMDOWNLOADS_GBYTES, + 'T' => _AM_TDMDOWNLOADS_TBYTES, + ]; + $type->addOptionArray($typeArray); + $aff_size->addElement($type); + $form->addElement($aff_size); } else { $form->addElement(new \XoopsFormHidden('size', '')); $form->addElement(new \XoopsFormHidden('type_size', '')); @@ -195,7 +193,7 @@ public function getForm($donnee = [], $erreur = false, $action = false) //plateforme if (1 == $downloads_field[$i]->getVar('status')) { $platformselect = new \XoopsFormSelect(_AM_TDMDOWNLOADS_FORMPLATFORM, 'platform', explode('|', $this->getVar('platform')), 5, true); - $platformArray = explode('|', $helper->getConfig('platform')); + $platformArray = explode('|', $helper->getConfig('platform')); foreach ($platformArray as $platform) { $platformselect->addOption((string)$platform, $platform); } @@ -258,7 +256,7 @@ public function getForm($donnee = [], $erreur = false, $action = false) //image if ($helper->getConfig('useshots')) { - $uploaddir = XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/shots/' . $this->getVar('logourl'); + $uploaddir = XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/shots/' . $this->getVar('logourl'); $categoryImage = $this->getVar('logourl') ?: 'blank.gif'; if (!is_file($uploaddir)) { $categoryImage = 'blank.gif'; diff --git a/class/DownloadsHandler.php b/class/DownloadsHandler.php index ec0385f..2509ab7 100644 --- a/class/DownloadsHandler.php +++ b/class/DownloadsHandler.php @@ -13,11 +13,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class DownloadsHandler * @package XoopsModules\Tdmdownloads diff --git a/class/Field.php b/class/Field.php index f8f9111..e1126ad 100644 --- a/class/Field.php +++ b/class/Field.php @@ -13,11 +13,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class Field * @package XoopsModules\Tdmdownloads diff --git a/class/FieldHandler.php b/class/FieldHandler.php index 36974dc..19a40a2 100644 --- a/class/FieldHandler.php +++ b/class/FieldHandler.php @@ -13,11 +13,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class FieldHandler * @package XoopsModules\Tdmdownloads diff --git a/class/Fielddata.php b/class/Fielddata.php index 7a12f54..e3a8897 100644 --- a/class/Fielddata.php +++ b/class/Fielddata.php @@ -13,11 +13,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class Fielddata * @package XoopsModules\Tdmdownloads diff --git a/class/FielddataHandler.php b/class/FielddataHandler.php index d2649ef..b5c119c 100644 --- a/class/FielddataHandler.php +++ b/class/FielddataHandler.php @@ -13,11 +13,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class FielddataHandler * @package XoopsModules\Tdmdownloads diff --git a/class/Form/UploadForm.php b/class/Form/UploadForm.php index 6083753..5cf7a6d 100644 --- a/class/Form/UploadForm.php +++ b/class/Form/UploadForm.php @@ -1,4 +1,6 @@ -helper */ + /** @var \XoopsModules\Tdmdownloads\Helper $this ->helper */ $this->helper = $target->helper; $this->targetObject = $target; $title = $this->targetObject->isNew() ? sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_ADD')) : sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_EDIT')); - parent::__construct('', 'form', xoops_getenv('PHP_SELF'), 'post', true); + parent::__construct('', 'form', xoops_getenv('SCRIPT_NAME'), 'post', true); $this->setExtra('enctype="multipart/form-data"'); //include ID field, it's needed so the module knows if it is a new form or an edited form @@ -64,9 +66,8 @@ public function __construct($target) $this->addElement($hidden); unset($hidden); - - $categoryHandler = new \XoopsModules\Tdmdownloads\CategoryHandler(); - $start = Request::getInt('start', 0); + $categoryHandler = new \XoopsModules\Tdmdownloads\CategoryHandler(); + $start = Request::getInt('start', 0); $catPaginationLimit = $this->helper->getConfig('userpager') ?: 10; $criteria = new \CriteriaCompo(); @@ -78,16 +79,16 @@ public function __construct($target) $catArray = $categoryHandler->getAll($criteria); // Form Select Category - $categoryIdSelect = new \XoopsFormSelect( constant('CO_' . $moduleDirNameUpper . '_' . 'SELECT'), 'cat_title', $this->targetObject->getVar('cat_cid')); + $categoryIdSelect = new \XoopsFormSelect(constant('CO_' . $moduleDirNameUpper . '_' . 'SELECT'), 'cat_title', $this->targetObject->getVar('cat_cid')); $categoryIdSelect->setExtra('onchange="submit()"'); -// $categoryIdSelect->addOption(0, ' '); + // $categoryIdSelect->addOption(0, ' '); - foreach(array_keys($catArray) as $i) { + foreach (array_keys($catArray) as $i) { $catName = $catArray[$i]->getVar('cat_title'); - $catPid = $catArray[$i]->getVar('cat_pid'); - if ( 0 < $catPid ) { + $catPid = $catArray[$i]->getVar('cat_pid'); + if (0 < $catPid) { $categoryObj = $categoryHandler->get($catPid); - if (is_object( $categoryObj)) { + if (is_object($categoryObj)) { $catName .= ' (' . $categoryObj->getVar('cat_title') . ')'; } else { $catName .= ' (' . constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR_CATPID') . ')'; diff --git a/class/Helper.php b/class/Helper.php index 2b531de..3def733 100644 --- a/class/Helper.php +++ b/class/Helper.php @@ -14,12 +14,11 @@ /** * @copyright XOOPS Project https://xoops.org/ - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @package * @since * @author XOOPS Development Team */ -//defined('XOOPS_ROOT_PATH') || die('Restricted access'); /** * Class Helper @@ -72,12 +71,17 @@ public function getDirname() */ public function getHandler($name) { - $ret = false; - $db = \XoopsDatabaseFactory::getDatabaseConnection(); - $class = __NAMESPACE__ . '\\' . ucfirst($name) . 'Handler'; - $ret = new $class($db); + $ret = false; + $class = __NAMESPACE__ . '\\' . ucfirst($name) . 'Handler'; + if (!class_exists($class)) { + throw new \RuntimeException("Class '$class' not found"); + } + /** @var \XoopsMySQLDatabase $db */ + $db = \XoopsDatabaseFactory::getDatabaseConnection(); + $helper = self::getInstance(); + $ret = new $class($db, $helper); + $this->addLog("Getting handler '{$name}'"); return $ret; } } - diff --git a/class/Modified.php b/class/Modified.php index 71a1b60..0e18021 100644 --- a/class/Modified.php +++ b/class/Modified.php @@ -13,14 +13,12 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ use XoopsModules\Tdmdownloads; -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class Modified * @package XoopsModules\Tdmdownloads @@ -81,7 +79,7 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; /** @var \XoopsGroupPermHandler $grouppermHandler */ $grouppermHandler = xoops_getHandler('groupperm'); - $perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')) ? true : false; + $perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')); //appel des class /** @var \XoopsModules\Tdmdownloads\DownloadsHandler $downloadsHandler */ $downloadsHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Downloads'); @@ -176,23 +174,23 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) if (3 == $downloads_field[$i]->getVar('fid')) { //taille du fichier if (1 == $downloads_field[$i]->getVar('status')) { - $size_value_arr = explode(' ', $viewDownloads->getVar('size')); - $aff_size = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMSIZE, ''); - $aff_size->addElement(new \XoopsFormText('', 'sizeValue', 13, 13, $size_value_arr[0])); - if (array_key_exists (1, $size_value_arr) == false){ - $size_value_arr[1] = 'K'; - } - $type = new \XoopsFormSelect('', 'sizeType', $size_value_arr[1]); - $typeArray = [ - 'B' => _AM_TDMDOWNLOADS_BYTES, - 'K' => _AM_TDMDOWNLOADS_KBYTES, - 'M' => _AM_TDMDOWNLOADS_MBYTES, - 'G' => _AM_TDMDOWNLOADS_GBYTES, - 'T' => _AM_TDMDOWNLOADS_TBYTES - ]; - $type->addOptionArray($typeArray); - $aff_size->addElement($type); - $form->addElement($aff_size); + $size_value_arr = explode(' ', $viewDownloads->getVar('size')); + $aff_size = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMSIZE, ''); + $aff_size->addElement(new \XoopsFormText('', 'sizeValue', 13, 13, $size_value_arr[0])); + if (array_key_exists(1, $size_value_arr) === false) { + $size_value_arr[1] = 'K'; + } + $type = new \XoopsFormSelect('', 'sizeType', $size_value_arr[1]); + $typeArray = [ + 'B' => _AM_TDMDOWNLOADS_BYTES, + 'K' => _AM_TDMDOWNLOADS_KBYTES, + 'M' => _AM_TDMDOWNLOADS_MBYTES, + 'G' => _AM_TDMDOWNLOADS_GBYTES, + 'T' => _AM_TDMDOWNLOADS_TBYTES, + ]; + $type->addOptionArray($typeArray); + $aff_size->addElement($type); + $form->addElement($aff_size); } else { $form->addElement(new \XoopsFormHidden('size', '')); $form->addElement(new \XoopsFormHidden('type_size', '')); @@ -202,7 +200,7 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) //plateforme if (1 == $downloads_field[$i]->getVar('status')) { $platformselect = new \XoopsFormSelect(_AM_TDMDOWNLOADS_FORMPLATFORM, 'platform', explode('|', $d_platform), 5, true); - $platformArray = explode('|', $helper->getConfig('platform')); + $platformArray = explode('|', $helper->getConfig('platform')); foreach ($platformArray as $platform) { $platformselect->addOption((string)$platform, $platform); } @@ -247,9 +245,9 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) $form->addElement(new \XoopsFormEditor(_AM_TDMDOWNLOADS_FORMTEXTDOWNLOADS, 'description', $editorConfigs), true); //image if ($helper->getConfig('useshots')) { - $uploaddir = XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/shots/' . $viewDownloads->getVar('logourl'); - $categoryImage = $viewDownloads->getVar('logourl') ?: 'blank.gif'; - $uploadirectory = '/uploads/' . $moduleDirName . '/images/shots'; + $uploaddir = XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/shots/' . $viewDownloads->getVar('logourl'); + $categoryImage = $viewDownloads->getVar('logourl') ?: 'blank.gif'; + $uploadirectory = '/uploads/' . $moduleDirName . '/images/shots'; if (!is_file($uploaddir)) { $categoryImage = 'blank.gif'; } diff --git a/class/ModifiedHandler.php b/class/ModifiedHandler.php index 4febb74..628f2f5 100644 --- a/class/ModifiedHandler.php +++ b/class/ModifiedHandler.php @@ -13,11 +13,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class ModifiedHandler * @package XoopsModules\Tdmdownloads diff --git a/class/Modifiedfielddata.php b/class/Modifiedfielddata.php index 6d853df..8a14dfc 100644 --- a/class/Modifiedfielddata.php +++ b/class/Modifiedfielddata.php @@ -13,11 +13,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class Modifiedfielddata * @package XoopsModules\Tdmdownloads diff --git a/class/ModifiedfielddataHandler.php b/class/ModifiedfielddataHandler.php index 8782885..aff96b1 100644 --- a/class/ModifiedfielddataHandler.php +++ b/class/ModifiedfielddataHandler.php @@ -13,11 +13,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class ModifiedfielddataHandler * @package XoopsModules\Tdmdownloads diff --git a/class/Rating.php b/class/Rating.php index 84fb861..ff024ba 100644 --- a/class/Rating.php +++ b/class/Rating.php @@ -13,11 +13,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class Rating * @package XoopsModules\Tdmdownloads diff --git a/class/RatingHandler.php b/class/RatingHandler.php index 9eebd4f..a2e0f5a 100644 --- a/class/RatingHandler.php +++ b/class/RatingHandler.php @@ -13,11 +13,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class RatingHandler * @package XoopsModules\Tdmdownloads diff --git a/class/Tree.php b/class/Tree.php index 558eee1..d124f33 100644 --- a/class/Tree.php +++ b/class/Tree.php @@ -13,7 +13,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ require_once $GLOBALS['xoops']->path('www/class/tree.php'); @@ -33,7 +33,7 @@ class Tree extends \XoopsObjectTree * @param $parentId * @param null $rootId */ - public function __construct(&$objectArr, $myId, $parentId, $rootId = null) + public function __construct($objectArr, $myId, $parentId, $rootId = null) { parent::__construct($objectArr, $myId, $parentId, $rootId); } @@ -92,7 +92,7 @@ protected function makeArrayTreeOptions($fieldName, $key, &$ret, $prefix_orig, $ } public function makeArrayTree($fieldName, $prefix = '-', $key = 0) { - $ret = array(); + $ret = []; $this->makeArrayTreeOptions($fieldName, $key, $ret, $prefix); return $ret; diff --git a/class/Utility.php b/class/Utility.php index 55f54ec..54e94df 100644 --- a/class/Utility.php +++ b/class/Utility.php @@ -15,156 +15,15 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ +use XoopsModules\Tdmdownloads; +use XoopsModules\Tdmdownloads\Common; +use XoopsModules\Tdmdownloads\Constants; + /** * Class Utility */ -class Utility +class Utility extends Common\SysUtility { - use Common\VersionChecks; //checkVerXoops, checkVerPhp Traits - - use Common\ServerStats; // getServerStats Trait - - use Common\FilesManagement; // Files Management Trait - - /** - * truncateHtml can truncate a string up to a number of characters while preserving whole words and HTML tags - * www.gsdesign.ro/blog/cut-html-string-without-breaking-the-tags - * www.cakephp.org - * - * @param string $text String to truncate. - * @param int $length Length of returned string, including ellipsis. - * @param string $ending Ending to be appended to the trimmed string. - * @param bool $exact If false, $text will not be cut mid-word - * @param bool $considerHtml If true, HTML tags would be handled correctly - * - * @return string Trimmed string. - */ - public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true) - { - $open_tags = []; - if ($considerHtml) { - // if the plain text is shorter than the maximum length, return the whole text - if (mb_strlen(preg_replace('/<.*?' . '>/', '', $text)) <= $length) { - return $text; - } - // splits all html-tags to scanable lines - preg_match_all('/(<.+?' . '>)?([^<>]*)/s', $text, $lines, PREG_SET_ORDER); - $total_length = mb_strlen($ending); - $truncate = ''; - foreach ($lines as $line_matchings) { - // if there is any html-tag in this line, handle it and add it (uncounted) to the output - if (!empty($line_matchings[1])) { - // if it's an "empty element" with or without xhtml-conform closing slash - if (preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) { - // do nothing - // if tag is a closing tag - } elseif (preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) { - // delete tag from $open_tags list - $pos = array_search($tag_matchings[1], $open_tags, true); - if (false !== $pos) { - unset($open_tags[$pos]); - } - // if tag is an opening tag - } elseif (preg_match('/^<\s*([^\s>!]+).*?' . '>$/s', $line_matchings[1], $tag_matchings)) { - // add tag to the beginning of $open_tags list - array_unshift($open_tags, mb_strtolower($tag_matchings[1])); - } - // add html-tag to $truncate'd text - $truncate .= $line_matchings[1]; - } - // calculate the length of the plain text part of the line; handle entities as one character - $content_length = mb_strlen(preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2])); - if ($total_length + $content_length > $length) { - // the number of characters which are left - $left = $length - $total_length; - $entities_length = 0; - // search for html entities - if (preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, PREG_OFFSET_CAPTURE)) { - // calculate the real length of all entities in the legal range - foreach ($entities[0] as $entity) { - if ($left >= $entity[1] + 1 - $entities_length) { - $left--; - $entities_length += mb_strlen($entity[0]); - } else { - // no more characters left - break; - } - } - } - $truncate .= mb_substr($line_matchings[2], 0, $left + $entities_length); - // maximum lenght is reached, so get off the loop - break; - } - $truncate .= $line_matchings[2]; - $total_length += $content_length; - - // if the maximum length is reached, get off the loop - if ($total_length >= $length) { - break; - } - } - } else { - if (mb_strlen($text) <= $length) { - return $text; - } - $truncate = mb_substr($text, 0, $length - mb_strlen($ending)); - } - // if the words shouldn't be cut in the middle... - if (!$exact) { - // ...search the last occurance of a space... - $spacepos = mb_strrpos($truncate, ' '); - if (isset($spacepos)) { - // ...and cut the text in this position - $truncate = mb_substr($truncate, 0, $spacepos); - } - } - // add the defined ending to the text - $truncate .= $ending; - if ($considerHtml) { - // close all unclosed html-tags - foreach ($open_tags as $tag) { - $truncate .= ''; - } - } - - return $truncate; - } - - /** - * @param \Xmf\Module\Helper $helper - * @param array|null $options - * @return \XoopsFormDhtmlTextArea|\XoopsFormEditor - */ - public static function getEditor($helper = null, $options = null) - { - /** @var \XoopsModules\Tdmdownloads\Helper $helper */ - if (null === $options) { - $options = []; - $options['name'] = 'Editor'; - $options['value'] = 'Editor'; - $options['rows'] = 10; - $options['cols'] = '100%'; - $options['width'] = '100%'; - $options['height'] = '400px'; - } - - $isAdmin = $helper->isUserAdmin(); - - if (class_exists('XoopsFormEditor')) { - if ($isAdmin) { - $descEditor = new \XoopsFormEditor(ucfirst($options['name']), $helper->getConfig('editorAdmin'), $options, $nohtml = false, $onfailure = 'textarea'); - } else { - $descEditor = new \XoopsFormEditor(ucfirst($options['name']), $helper->getConfig('editorUser'), $options, $nohtml = false, $onfailure = 'textarea'); - } - } else { - $descEditor = new \XoopsFormDhtmlTextArea(ucfirst($options['name']), $options['name'], $options['value'], '100%', '100%'); - } - - // $form->addElement($descEditor); - - return $descEditor; - } - //--------------- Custom module methods ----------------------------- /** @@ -315,7 +174,7 @@ public static function prettifyBytes($size) * @param string $type * @return mixed|string */ - public static function cleanVars(&$global, $key, $default = '', $type = 'int') + public static function cleanVars($global, $key, $default = '', $type = 'int') { switch ($type) { case 'string': @@ -346,7 +205,7 @@ public static function getPathTree($mytree, $key, $category_array, $title, $pref /** @var \XoopsObjectTree $mytree */ $categoryParent = $mytree->getAllParent($key); $categoryParent = array_reverse($categoryParent); - $path = ''; + $path = ''; foreach (array_keys($categoryParent) as $j) { /** @var \XoopsModules\Tdmdownloads\Category[] $categoryParent */ $path .= $categoryParent[$j]->getVar($title) . $prefix; @@ -422,19 +281,21 @@ public static function getPathTreeUrl($mytree, $key, $category_array, $title, $p return $path; } - /** - * Utility::StringSizeConvert() + + /** + * Utility::convertStringToSize() * * @param mixed $stringSize * @return mixed|int */ - public static function StringSizeConvert($stringSize){ + public static function convertStringToSize($stringSize) + { if ($stringSize != '') { - $kb = 1024; - $mb = 1024*1024; - $gb = 1024*1024*1024; - $size_value_arr = explode(' ', $stringSize); - + $kb = 1024; + $mb = 1024 * 1024; + $gb = 1024 * 1024 * 1024; + $size_value_arr = explode(' ', $stringSize); + if ($size_value_arr[1] == 'B') { $mysize = $size_value_arr[0]; } elseif ($size_value_arr[1] == 'K') { @@ -449,97 +310,100 @@ public static function StringSizeConvert($stringSize){ return 0; } } - /** - * Utility::SizeConvertString() + + /** + * Utility::convertSizeToString() * * @param mixed $sizeString * @return mixed|string */ - public static function SizeConvertString($sizeString){ - $mysizeString = ''; - if ($sizeString != '') { - $size_value_arr = explode(' ', $sizeString); - if (array_key_exists (0, $size_value_arr) == true && array_key_exists (1, $size_value_arr) == true){ - if ($size_value_arr[0] != ''){ - $mysizeString = ''; - switch ($size_value_arr[1]) { - case 'B': - $mysizeString = $size_value_arr[0] . ' ' . _AM_TDMDOWNLOADS_BYTES; - break; - - case 'K': - $mysizeString = $size_value_arr[0] . ' ' . _AM_TDMDOWNLOADS_KBYTES; - break; - - case 'M': - $mysizeString = $size_value_arr[0] . ' ' . _AM_TDMDOWNLOADS_MBYTES; - break; - - case 'G': - $mysizeString = $size_value_arr[0] . ' ' . _AM_TDMDOWNLOADS_GBYTES; - break; - - case 'T': - $mysizeString = $size_value_arr[0] . ' ' . _AM_TDMDOWNLOADS_TBYTES; - break; - } - return $mysizeString; - } - } - } - return $mysizeString; + public static function convertSizeToString($sizeString) + { + $mysizeString = ''; + if ($sizeString != '') { + $size_value_arr = explode(' ', $sizeString); + if (array_key_exists(0, $size_value_arr) === true && array_key_exists(1, $size_value_arr) === true) { + if ($size_value_arr[0] != '') { + $mysizeString = ''; + switch ($size_value_arr[1]) { + case 'B': + $mysizeString = $size_value_arr[0] . ' ' . _AM_TDMDOWNLOADS_BYTES; + break; + + case 'K': + $mysizeString = $size_value_arr[0] . ' ' . _AM_TDMDOWNLOADS_KBYTES; + break; + + case 'M': + $mysizeString = $size_value_arr[0] . ' ' . _AM_TDMDOWNLOADS_MBYTES; + break; + + case 'G': + $mysizeString = $size_value_arr[0] . ' ' . _AM_TDMDOWNLOADS_GBYTES; + break; + + case 'T': + $mysizeString = $size_value_arr[0] . ' ' . _AM_TDMDOWNLOADS_TBYTES; + break; + } + return $mysizeString; + } + } + } + return $mysizeString; } - - /** - * Utility::GetFileSize() + + /** + * Utility::getFileSize() * * @param mixed $url * @return mixed|string */ - public static function GetFileSize($url) + public static function getFileSize($url) { - if (function_exists('curl_init') && false !== ($curlHandle = curl_init($url))) { - curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, TRUE); - curl_setopt($curlHandle, CURLOPT_HEADER, TRUE); - curl_setopt($curlHandle, CURLOPT_NOBODY, TRUE); - curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, false); - $curlReturn = curl_exec($curlHandle); - if (false === $curlReturn) { - trigger_error(curl_error($curlHandle)); - $size = 0; - } else { - $size = curl_getinfo($curlHandle, CURLINFO_CONTENT_LENGTH_DOWNLOAD); - } - curl_close($curlHandle); - if ($size <= 0){ - return 0; - } else { - return Utility::FileSizeConvert($size); - } - } else { - return 0; - } + if (function_exists('curl_init') && false !== ($curlHandle = curl_init($url))) { + curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curlHandle, CURLOPT_HEADER, true); + curl_setopt($curlHandle, CURLOPT_NOBODY, true); + curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized' + $curlReturn = curl_exec($curlHandle); + if (false === $curlReturn) { + trigger_error(curl_error($curlHandle)); + $size = 0; + } else { + $size = curl_getinfo($curlHandle, CURLINFO_CONTENT_LENGTH_DOWNLOAD); + } + curl_close($curlHandle); + if ($size <= 0) { + return 0; + } else { + return self::convertFileSize($size); + } + } else { + return 0; + } } - - /** - * Utility::FileSizeConvert() + + /** + * Utility::convertFileSize() * * @param mixed $size * @return mixed|string */ - public static function FileSizeConvert($size){ + public static function convertFileSize($size) + { if ($size > 0) { $kb = 1024; - $mb = 1024*1024; - $gb = 1024*1024*1024; + $mb = 1024 * 1024; + $gb = 1024 * 1024 * 1024; if ($size >= $gb) { - $mysize = sprintf ("%01.2f",$size/$gb) . " " . 'G'; + $mysize = sprintf("%01.2f", $size / $gb) . " " . 'G'; } elseif ($size >= $mb) { - $mysize = sprintf ("%01.2f",$size/$mb) . " " . 'M'; + $mysize = sprintf("%01.2f", $size / $mb) . " " . 'M'; } elseif ($size >= $kb) { - $mysize = sprintf ("%01.2f",$size/$kb) . " " . 'K'; + $mysize = sprintf("%01.2f", $size / $kb) . " " . 'K'; } else { - $mysize = sprintf ("%01.2f",$size) . " " . 'B'; + $mysize = sprintf("%01.2f", $size) . " " . 'B'; } return $mysize; @@ -547,4 +411,25 @@ public static function FileSizeConvert($size){ return ''; } } + + /** + * @param $val + * @return float|int + */ + public static function returnBytes($val) + { + switch (mb_substr($val, -1)) { + case 'K': + case 'k': + return (int)$val * 1024; + case 'M': + case 'm': + return (int)$val * 1048576; + case 'G': + case 'g': + return (int)$val * 1073741824; + default: + return $val; + } + } } diff --git a/comment_delete.php b/comment_delete.php index e4c0625..b9dded1 100644 --- a/comment_delete.php +++ b/comment_delete.php @@ -2,7 +2,7 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2019 XOOPS.org // +// Copyright (c) 2000-2020 XOOPS.org // // // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // diff --git a/comment_edit.php b/comment_edit.php index a342f51..50d5ef5 100644 --- a/comment_edit.php +++ b/comment_edit.php @@ -2,7 +2,7 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2019 XOOPS.org // +// Copyright (c) 2000-2020 XOOPS.org // // // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // diff --git a/comment_new.php b/comment_new.php index ca97256..1bef021 100644 --- a/comment_new.php +++ b/comment_new.php @@ -2,7 +2,7 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2019 XOOPS.org // +// Copyright (c) 2000-2020 XOOPS.org // // // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // diff --git a/comment_post.php b/comment_post.php index e35c3eb..c9fe3f1 100644 --- a/comment_post.php +++ b/comment_post.php @@ -2,7 +2,7 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2019 XOOPS.org // +// Copyright (c) 2000-2020 XOOPS.org // // // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // diff --git a/comment_reply.php b/comment_reply.php index 52aa3f6..f842346 100644 --- a/comment_reply.php +++ b/comment_reply.php @@ -2,7 +2,7 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2019 XOOPS.org // +// Copyright (c) 2000-2020 XOOPS.org // // // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // diff --git a/config/imageconfig.php b/config/imageconfig.php index 3c26af5..783df73 100644 --- a/config/imageconfig.php +++ b/config/imageconfig.php @@ -1,6 +1,6 @@ 'CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG_DSC', 'formtype' => 'line_break', 'valuetype' => 'textbox', - 'default' => 'head' + 'default' => 'head', ]; $modversion['config'][] = [ @@ -23,7 +23,7 @@ 'description' => 'CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH_DSC', 'formtype' => 'textbox', 'valuetype' => 'int', - 'default' => 1200 + 'default' => 1200, ]; // =1024/16 $modversion['config'][] = [ @@ -32,7 +32,7 @@ 'description' => 'CO_' . $moduleDirNameUpper . '_' . 'IMAGE_HEIGHT_DSC', 'formtype' => 'textbox', 'valuetype' => 'int', - 'default' => 800 + 'default' => 800, ]; // =768/16 $modversion['config'][] = [ @@ -41,6 +41,6 @@ 'description' => 'CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH_DSC', 'formtype' => 'textbox', 'valuetype' => 'text', - 'default' => 'uploads/' . $modversion['dirname'] . '/images' + 'default' => 'uploads/' . $modversion['dirname'] . '/images', ]; diff --git a/docs/changelog.txt b/docs/changelog.txt index 84b8913..8add152 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -3,6 +3,14 @@ - added hits and ratings and for output of download in index.php (goffy) - added number of subcategories for output of category in index.php (goffy) - added new lang vars (goffy) +- Undefined variable $select_sup (geekwright) +- Class 'XoopsPageNav' not found error (geekwright) +- Add some category detail for theme use (geekwright) +- Turn off logger (geekwright) +- Fix xml (geekwright) +- add extra fields visibility (heyula) +- refactor Utility (mamba) +
2.0 RC 1 [2019-01-29]

diff --git a/extra/plugins/sitemap/tdmdownloads.php b/extra/plugins/sitemap/tdmdownloads.php index 555d6f7..673b494 100644 --- a/extra/plugins/sitemap/tdmdownloads.php +++ b/extra/plugins/sitemap/tdmdownloads.php @@ -10,7 +10,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ diff --git a/extra/plugins/tag/tdmdownloads.php b/extra/plugins/tag/tdmdownloads.php index bc96fdc..0c30170 100644 --- a/extra/plugins/tag/tdmdownloads.php +++ b/extra/plugins/tag/tdmdownloads.php @@ -9,13 +9,13 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @author Gregory Mage (Aka Mage) - * * @param $items * * @return bool|null + * @author Gregory Mage (Aka Mage) + * + * @copyright Gregory Mage (Aka Mage) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) */ /** diff --git a/extra/plugins/waiting/tdmdownloads.php b/extra/plugins/waiting/tdmdownloads.php index e38f678..8a63163 100644 --- a/extra/plugins/waiting/tdmdownloads.php +++ b/extra/plugins/waiting/tdmdownloads.php @@ -1,5 +1,6 @@ checkRight('tdmdownloads_ac', 4, $groups, $xoopsModule->getVar('mid')) ? true : false; -$perm_modif = $grouppermHandler->checkRight('tdmdownloads_ac', 8, $groups, $xoopsModule->getVar('mid')) ? true : false; -$perm_vote = $grouppermHandler->checkRight('tdmdownloads_ac', 16, $groups, $xoopsModule->getVar('mid')) ? true : false; -$perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')) ? true : false; -$perm_autoapprove = $grouppermHandler->checkRight('tdmdownloads_ac', 64, $groups, $xoopsModule->getVar('mid')) ? true : false; +$perm_submit = $grouppermHandler->checkRight('tdmdownloads_ac', 4, $groups, $xoopsModule->getVar('mid')); +$perm_modif = $grouppermHandler->checkRight('tdmdownloads_ac', 8, $groups, $xoopsModule->getVar('mid')); +$perm_vote = $grouppermHandler->checkRight('tdmdownloads_ac', 16, $groups, $xoopsModule->getVar('mid')); +$perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')); +$perm_autoapprove = $grouppermHandler->checkRight('tdmdownloads_ac', 64, $groups, $xoopsModule->getVar('mid')); //paramètres: // pour les images des catégories: diff --git a/include/assign_globals.php b/include/assign_globals.php index 6b96bed..1218c41 100644 --- a/include/assign_globals.php +++ b/include/assign_globals.php @@ -1,6 +1,6 @@ _ALBM_CAPTION_TOTAL, @@ -27,5 +27,5 @@ 'thumbsize' => $myalbum_thumbsize, 'colsoftableview' => $myalbum_colsoftableview, 'canrateview' => $GLOBALS['global_perms'] && GPERM_RATEVIEW, - 'canratevote' => $GLOBALS['global_perms'] && GPERM_RATEVOTE + 'canratevote' => $GLOBALS['global_perms'] && GPERM_RATEVOTE, ]; diff --git a/include/comment_functions.php b/include/comment_functions.php index 692e037..14d1924 100644 --- a/include/comment_functions.php +++ b/include/comment_functions.php @@ -2,7 +2,7 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2019 XOOPS.org // +// Copyright (c) 2000-2020 XOOPS.org // // // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // diff --git a/include/common.php b/include/common.php index bc19b07..c193bce 100644 --- a/include/common.php +++ b/include/common.php @@ -11,7 +11,7 @@ /** * @copyright XOOPS Project https://xoops.org/ - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @package * @since * @author XOOPS Development Team diff --git a/include/config.php b/include/config.php deleted file mode 100644 index 4e6d8a2..0000000 --- a/include/config.php +++ /dev/null @@ -1,86 +0,0 @@ - mb_strtoupper($moduleDirName) . ' Module Configurator', - 'paths' => [ - 'dirname' => $moduleDirName, - 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin', - 'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName, - 'modUrl' => XOOPS_URL . '/modules/' . $moduleDirName, - 'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName, - 'uploadUrl' => XOOPS_UPLOAD_URL . '/' . $moduleDirName, - ], - 'uploadFolders' => [ - XOOPS_UPLOAD_PATH . '/' . $moduleDirName, - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/downloads', - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images', - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/cats', - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/field', - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/shots', - //XOOPS_UPLOAD_PATH . '/flags' - ], - 'copyBlankFiles' => [ - XOOPS_UPLOAD_PATH . '/' . $moduleDirName, - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/downloads', - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images', - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/cats', - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/field', - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/shots', - //XOOPS_UPLOAD_PATH . '/flags' - ], - - 'copyTestFolders' => [ - // XOOPS_UPLOAD_PATH . '/' . $moduleDirName, - //[ - // constant($moduleDirNameUpper . '_PATH') . '/testdata/images', - // XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images', - //] - ], - - 'templateFolders' => [ - '/templates/', - // '/templates/blocks/', - // '/templates/admin/' - ], - 'oldFiles' => [ - '/class/request.php', - '/class/registry.php', - '/class/utilities.php', - '/class/util.php', - // '/include/constants.php', - // '/include/functions.php', - '/ajaxrating.txt', - ], - 'oldFolders' => [ - '/images', - '/css', - '/js', - ], - - 'renameTables' => [// 'XX_archive' => 'ZZZZ_archive', - ], - 'modCopyright' => " - XOOPS Project", - ]; -} diff --git a/include/functions0.php0 b/include/functions0.php0 index 8667675..cd91cba 100644 --- a/include/functions0.php0 +++ b/include/functions0.php0 @@ -10,7 +10,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) * @param mixed $permtype * @param mixed $dirname diff --git a/include/notification.inc.php b/include/notification.inc.php index 42a8090..9705332 100644 --- a/include/notification.inc.php +++ b/include/notification.inc.php @@ -2,7 +2,7 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2019 XOOPS.org // +// Copyright (c) 2000-2020 XOOPS.org // // // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // diff --git a/include/oninstall.php b/include/oninstall.php index 93aaee0..67ee43b 100644 --- a/include/oninstall.php +++ b/include/oninstall.php @@ -11,10 +11,42 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ +use XoopsModules\Tdmdownloads; +use XoopsModules\Tdmdownloads\Utility; + +/** + * Prepares system prior to attempting to install module + * @param \XoopsModule $module {@link XoopsModule} + * + * @return bool true if ready to install, false if not + */ +function xoops_module_pre_install_tdmdownloads(\XoopsModule $module) +{ + require_once dirname(dirname(dirname(__DIR__))) . '/mainfile.php'; + require_once __DIR__ . '/common.php'; + + /** @var \XoopsModules\Tdmdownloads\Utility $utility */ + $utility = new \XoopsModules\Tdmdownloads\Utility(); + + $xoopsSuccess0 = $utility::checkVerXoops($module); + $xoopsSuccess = $utility::checkVerXoops($module); + + $phpSuccess0 = $utility::checkVerPhp($module); + $phpSuccess = $utility::checkVerPhp($module); + + if (false !== $xoopsSuccess && false !== $phpSuccess) { + $mod_tables = &$module->getInfo('tables'); + foreach ($mod_tables as $table) { + $GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';'); + } + } + + return $xoopsSuccess && $phpSuccess; +} /** * @return bool */ @@ -63,7 +95,7 @@ function xoops_module_install_tdmdownloads() $obj->setVar('status_def', 1); $fieldHandler->insert($obj); - //Creation du fichier ".$namemodule."/ + //File creation ".$namemodule."/ $dir = XOOPS_ROOT_PATH . '/uploads/' . $namemodule . ''; if (!is_dir($dir)) { if (!mkdir($dir, 0777) && !is_dir($dir)) { @@ -72,7 +104,7 @@ function xoops_module_install_tdmdownloads() } chmod($dir, 0777); - //Creation du fichier ".$namemodule."/images/ + //File creation ".$namemodule."/images/ $dir = XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images'; if (!is_dir($dir)) { if (!mkdir($dir, 0777) && !is_dir($dir)) { @@ -81,7 +113,7 @@ function xoops_module_install_tdmdownloads() } chmod($dir, 0777); - //Creation du fichier ".$namemodule."/images/cat + //File creation ".$namemodule."/images/cat $dir = XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/cats'; if (!is_dir($dir)) { if (!mkdir($dir, 0777) && !is_dir($dir)) { @@ -90,7 +122,7 @@ function xoops_module_install_tdmdownloads() } chmod($dir, 0777); - //Creation du fichier ".$namemodule."/images/shots + //File creation ".$namemodule."/images/shots $dir = XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/shots'; if (!is_dir($dir)) { if (!mkdir($dir, 0777) && !is_dir($dir)) { @@ -99,7 +131,7 @@ function xoops_module_install_tdmdownloads() } chmod($dir, 0777); - //Creation du fichier ".$namemodule."/images/field + //File creation ".$namemodule."/images/field $dir = XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/field'; if (!is_dir($dir)) { if (!mkdir($dir, 0777) && !is_dir($dir)) { @@ -108,7 +140,7 @@ function xoops_module_install_tdmdownloads() } chmod($dir, 0777); - //Creation du fichier ".$namemodule."/downloads + //File creation ".$namemodule."/downloads $dir = XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/downloads'; if (!is_dir($dir)) { if (!mkdir($dir, 0777) && !is_dir($dir)) { @@ -117,7 +149,7 @@ function xoops_module_install_tdmdownloads() } chmod($dir, 0777); - //Copie des index.html + //Copy index.html $indexFile = XOOPS_ROOT_PATH . '/modules/' . $namemodule . '/include/index.html'; copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/index.html'); copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/index.html'); @@ -126,13 +158,13 @@ function xoops_module_install_tdmdownloads() copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/field/index.html'); copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/downloads/index.html'); - //Copie des blank.gif + //Copy blank.gif $blankFile = XOOPS_ROOT_PATH . '/modules/' . $namemodule . '/assets/images/blank.gif'; copy($blankFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/cats/blank.gif'); copy($blankFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/shots/blank.gif'); copy($blankFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/field/blank.gif'); - //Copie des images pour les champs + //Copy images for fields copy(XOOPS_ROOT_PATH . '/modules/' . $namemodule . '/assets/images/icons/16/homepage.png', XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/field/homepage.png'); copy(XOOPS_ROOT_PATH . '/modules/' . $namemodule . '/assets/images/icons/16/version.png', XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/field/version.png'); copy(XOOPS_ROOT_PATH . '/modules/' . $namemodule . '/assets/images/icons/16/size.png', XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/field/size.png'); diff --git a/include/onupdate.php b/include/onupdate.php index 881381c..6d3a091 100644 --- a/include/onupdate.php +++ b/include/onupdate.php @@ -1,4 +1,5 @@ getErrors(); @@ -43,52 +44,52 @@ function xoops_module_update_tdmdownloads(&$module, $prev_version = null) */ function update_tdmdownloads_v200(&$module) { - // Update size - $db = \XoopsDatabaseFactory::getDatabaseConnection(); - $sql = 'SELECT lid, size FROM ' . $db->prefix('tdmdownloads_downloads'); - $result = $db->query($sql); - $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); - $helper->loadLanguage('admin'); - while (false !== ($myrow = $db->fetchArray($result))) { - $size_value_arr = explode(' ', $myrow['size']); - switch ($size_value_arr[1]) { - case _AM_TDMDOWNLOADS_BYTES: - case 'Bytes': - $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' B\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; - $db->query($sql); - break; - - case _AM_TDMDOWNLOADS_KBYTES: - case 'kB': - $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' K\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; - $db->query($sql); - break; - - case _AM_TDMDOWNLOADS_MBYTES: - case 'MB': - $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' M\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; - $db->query($sql); - break; - - case _AM_TDMDOWNLOADS_GBYTES: - case 'GB': - $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' G\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; - $db->query($sql); - break; - - case _AM_TDMDOWNLOADS_TBYTES: - case 'TB': - $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' T\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; - $db->query($sql); - break; - } - } - // Update folder - rename(XOOPS_ROOT_PATH . '/uploads/TDMDownloads', XOOPS_ROOT_PATH . '/uploads/tdmdownloads'); - // Change TDMDownloads with tdmdownloads - $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `url` = REPLACE(`url`, \'TDMDownloads\', \'tdmdownloads\') WHERE `url` LIKE \'%TDMDownloads%\''; - $result = $db->query($sql); - return true; + // Update size + $db = \XoopsDatabaseFactory::getDatabaseConnection(); + $sql = 'SELECT lid, size FROM ' . $db->prefix('tdmdownloads_downloads'); + $result = $db->query($sql); + $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); + $helper->loadLanguage('admin'); + while (false !== ($myrow = $db->fetchArray($result))) { + $size_value_arr = explode(' ', $myrow['size']); + switch ($size_value_arr[1]) { + case _AM_TDMDOWNLOADS_BYTES: + case 'Bytes': + $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' B\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; + $db->query($sql); + break; + + case _AM_TDMDOWNLOADS_KBYTES: + case 'kB': + $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' K\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; + $db->query($sql); + break; + + case _AM_TDMDOWNLOADS_MBYTES: + case 'MB': + $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' M\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; + $db->query($sql); + break; + + case _AM_TDMDOWNLOADS_GBYTES: + case 'GB': + $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' G\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; + $db->query($sql); + break; + + case _AM_TDMDOWNLOADS_TBYTES: + case 'TB': + $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' T\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; + $db->query($sql); + break; + } + } + // Update folder + rename(XOOPS_ROOT_PATH . '/uploads/TDMDownloads', XOOPS_ROOT_PATH . '/uploads/tdmdownloads'); + // Change TDMDownloads with tdmdownloads + $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `url` = REPLACE(`url`, \'TDMDownloads\', \'tdmdownloads\') WHERE `url` LIKE \'%TDMDownloads%\''; + $result = $db->query($sql); + return true; } /** diff --git a/include/search.inc.php b/include/search.inc.php index c8a542c..a9702c1 100644 --- a/include/search.inc.php +++ b/include/search.inc.php @@ -9,15 +9,15 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @author Gregory Mage (Aka Mage) * @param $queryarray * @param $andor * @param $limit * @param $offset * @param $userid * @return array + * @copyright Gregory Mage (Aka Mage) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @author Gregory Mage (Aka Mage) */ //use XoopsModules\Tdmdownloads; @@ -35,7 +35,7 @@ function tdmdownloads_search($queryarray, $andor, $limit, $offset, $userid) $utility = new \XoopsModules\Tdmdownloads\Utility(); $categories = $utility->getItemIds('tdmdownloads_view', $moduleDirName); -// if (is_array($categories) && count($categories) > 0) { + // if (is_array($categories) && count($categories) > 0) { if ($categories && is_array($categories)) { $sql .= ' AND cid IN (' . implode(',', $categories) . ') '; } else { diff --git a/include/xoops_version.inc.php b/include/xoops_version.inc.php deleted file mode 100644 index f4f87eb..0000000 --- a/include/xoops_version.inc.php +++ /dev/null @@ -1,36 +0,0 @@ -getVar('cat_title') . ','; ++$chcount; } - $xoopsTpl->append('categories', [ - 'image' => $uploadurl . $downloadscatArray[$i]->getVar('cat_imgurl'), - 'id' => $downloadscatArray[$i]->getVar('cat_cid'), - 'title' => $downloadscatArray[$i]->getVar('cat_title'), - 'description_main' => $downloadscatArray[$i]->getVar('cat_description_main'), - 'subcategories' => $subcategories, - 'countsubs' => count($subcategories_arr), - 'totaldownloads' => $totaldownloads, - 'count' => $count, - ]); + $xoopsTpl->append( + 'categories', + [ + 'image' => $uploadurl . $downloadscatArray[$i]->getVar('cat_imgurl'), + 'id' => $downloadscatArray[$i]->getVar('cat_cid'), + 'title' => $downloadscatArray[$i]->getVar('cat_title'), + 'description_main' => $downloadscatArray[$i]->getVar('cat_description_main'), + 'subcategories' => $subcategories, + 'countsubs' => count($subcategories_arr), + 'totaldownloads' => $totaldownloads, + 'count' => $count, + ] + ); ++$count; } } @@ -97,12 +101,15 @@ $title = mb_substr($title, 0, $helper->getConfig('longbl')) . '...'; } $date = formatTimestamp($downloads_arr_date[$i]->getVar('date'), 's'); - $xoopsTpl->append('bl_date', [ - 'id' => $downloads_arr_date[$i]->getVar('lid'), - 'cid' => $downloads_arr_date[$i]->getVar('cid'), - 'date' => $date, - 'title' => $title, - ]); + $xoopsTpl->append( + 'bl_date', + [ + 'id' => $downloads_arr_date[$i]->getVar('lid'), + 'cid' => $downloads_arr_date[$i]->getVar('cid'), + 'date' => $date, + 'title' => $title, + ] + ); } } //plus téléchargés @@ -120,12 +127,15 @@ if (mb_strlen($title) >= $helper->getConfig('longbl')) { $title = mb_substr($title, 0, $helper->getConfig('longbl')) . '...'; } - $xoopsTpl->append('bl_pop', [ - 'id' => $downloads_arr_hits[$i]->getVar('lid'), - 'cid' => $downloads_arr_hits[$i]->getVar('cid'), - 'hits' => $downloads_arr_hits[$i]->getVar('hits'), - 'title' => $title, - ]); + $xoopsTpl->append( + 'bl_pop', + [ + 'id' => $downloads_arr_hits[$i]->getVar('lid'), + 'cid' => $downloads_arr_hits[$i]->getVar('cid'), + 'hits' => $downloads_arr_hits[$i]->getVar('hits'), + 'title' => $title, + ] + ); } } //mieux notés @@ -144,12 +154,15 @@ $title = mb_substr($title, 0, $helper->getConfig('longbl')) . '...'; } $rating = number_format($downloads_arr_rating[$i]->getVar('rating'), 1); - $xoopsTpl->append('bl_rating', [ - 'id' => $downloads_arr_rating[$i]->getVar('lid'), - 'cid' => $downloads_arr_rating[$i]->getVar('cid'), - 'rating' => $rating, - 'title' => $title, - ]); + $xoopsTpl->append( + 'bl_rating', + [ + 'id' => $downloads_arr_rating[$i]->getVar('lid'), + 'cid' => $downloads_arr_rating[$i]->getVar('cid'), + 'rating' => $rating, + 'title' => $title, + ] + ); } } $bl_affichage = 1; @@ -197,9 +210,9 @@ $criteria->setSort($tblsort[$sort]); $criteria->setOrder($tblorder[$order]); $downloadsArray = $downloadsHandler->getAll($criteria); - $categories = $utility->getItemIds('tdmdownloads_download', $moduleDirName); - $item = $utility->getItemIds('tdmdownloads_download_item', $moduleDirName); - $count = 1; + $categories = $utility->getItemIds('tdmdownloads_download', $moduleDirName); + $item = $utility->getItemIds('tdmdownloads_download_item', $moduleDirName); + $count = 1; foreach (array_keys($downloadsArray) as $i) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloadsArray */ if ('blank.gif' === $downloadsArray[$i]->getVar('logourl')) { @@ -252,22 +265,25 @@ $downloadPermission = false; } } - $xoopsTpl->append('file', [ - 'id' => $downloadsArray[$i]->getVar('lid'), - 'cid' => $downloadsArray[$i]->getVar('cid'), - 'title' => $downloadsArray[$i]->getVar('title'), - 'rating' => $downloadsArray[$i]->getVar('rating'), - 'hits' => $downloadsArray[$i]->getVar('hits'), - 'new' => $new, - 'pop' => $pop, - 'logourl' => $logourl, - 'updated' => $datetime, - 'description_short' => $descriptionShort, - 'adminlink' => $adminlink, - 'submitter' => $submitter, - 'perm_download' => $downloadPermission, - 'count' => $count, - ]); + $xoopsTpl->append( + 'file', + [ + 'id' => $downloadsArray[$i]->getVar('lid'), + 'cid' => $downloadsArray[$i]->getVar('cid'), + 'title' => $downloadsArray[$i]->getVar('title'), + 'rating' => $downloadsArray[$i]->getVar('rating'), + 'hits' => $downloadsArray[$i]->getVar('hits'), + 'new' => $new, + 'pop' => $pop, + 'logourl' => $logourl, + 'updated' => $datetime, + 'description_short' => $descriptionShort, + 'adminlink' => $adminlink, + 'submitter' => $submitter, + 'perm_download' => $downloadPermission, + 'count' => $count, + ] + ); //pour les mots clef $keywords .= $downloadsArray[$i]->getVar('title') . ','; ++$count; diff --git a/language/english/admin.php b/language/english/admin.php index b41b124..de8e87b 100644 --- a/language/english/admin.php +++ b/language/english/admin.php @@ -10,9 +10,10 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + // index.php define('_AM_TDMDOWNLOADS_INDEX_BROKEN', 'There are %s broken files reports'); define('_AM_TDMDOWNLOADS_INDEX_CATEGORIES', 'There are %s categories'); @@ -85,7 +86,7 @@ define('_AM_TDMDOWNLOADS_IMPORT_VOTE_IMP', "VOTES: '%s' imported;"); define( '_AM_TDMDOWNLOADS_IMPORT_WARNING', - "Attention !

Import will delete all data in TDMDownloads. It's highly recommended that you make a backup of all your data first, as well as of your website.

TDM is not responsible if you lose your data. Unfortunately, the screen shots cannot be copied." + "Attention !

Import will delete all data in TDMDownloads. It's highly recommended that you make a backup of all your data first, as well as of your website.

TDM is not responsible if you lose your data. Unfortunately, the screen shots cannot be copied." ); define('_AM_TDMDOWNLOADS_IMPORT_WFDOWNLOADS', 'Import from WF Downloads (only for V3.23 RC5)'); define('_AM_TDMDOWNLOADS_IMPORT_WFDOWNLOADS_CATIMG', 'Select Upload Directory (the path) for categories images of WF-Downloads'); diff --git a/language/english/blocks.php b/language/english/blocks.php index 81f6547..e26e8f6 100644 --- a/language/english/blocks.php +++ b/language/english/blocks.php @@ -1,4 +1,5 @@ Browse items alphabetically"); @@ -124,12 +129,13 @@ define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_NO', 'Folder "%s" does not exist. Create the specified folder with CHMOD 777.'); define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS', 'Show Development Tools Button?'); define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS_DESC', 'If yes, the "Migrate" Tab and other Development tools will be visible to the Admin.'); +define('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_FEEDBACK', 'Feedback'); //Latest Version Check define('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION', 'New Version: '); -define('CO_' . $moduleDirNameUpper . '_FOLDER_YES', 'Folder "%s" exist'); -define('CO_' . $moduleDirNameUpper . '_FOLDER_NO', 'Folder "%s" does not exist. Create the specified folder with CHMOD 777.'); +//define('CO_' . $moduleDirNameUpper . '_FOLDER_YES', 'Folder "%s" exist'); +//define('CO_' . $moduleDirNameUpper . '_FOLDER_NO', 'Folder "%s" does not exist. Create the specified folder with CHMOD 777.'); //Uploader define('CO_' . $moduleDirNameUpper . '_' . 'IMAGES_UPLOAD', 'Upload Files'); @@ -168,11 +174,6 @@ define('CO_' . $moduleDirNameUpper . '_' . 'SELECT', 'Select Category'); define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_CATPID', 'Error: parent category not found'); - - - - - //image config define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH', 'Image Display Width'); define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH_DSC', 'Display width for image'); diff --git a/language/english/main.php b/language/english/main.php index 20f8172..3951091 100644 --- a/language/english/main.php +++ b/language/english/main.php @@ -10,9 +10,10 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + // index.php define('_MD_TDMDOWNLOADS_INDEX_BLDATE', 'Recent Downloads:'); define('_MD_TDMDOWNLOADS_INDEX_BLNAME', 'Summary'); @@ -114,7 +115,7 @@ //visit.php define( '_MD_TDMDOWNLOADS_NOPERMISETOLINK', - 'This file does not belong to the website from where you are coming.

thanks for writing an email to the webmaster of the website from where you are coming and tell him:
NO OWNERSHIP OF LINKS FROM OTHER SITES! (LEECH)

Leecher definition: Someone who is lazy to link to its own server or steals the hard work done by other people

You are already registered.' + 'This file does not belong to the website from where you are coming.

thanks for writing an email to the webmaster of the website from where you are coming and tell him:
NO OWNERSHIP OF LINKS FROM OTHER SITES! (LEECH)

Leecher definition: Someone who is lazy to link to its own server or steals the hard work done by other people

You are already registered.' ); //Message d'erreur define('_MD_TDMDOWNLOADS_ERREUR_NOCAT', 'You have to choose a category!'); @@ -146,6 +147,5 @@ define('_MD_TDMDOWNLOADS_COUNTDL', 'Available downloads'); define('_MD_TDMDOWNLOADS_COUNTSUBS', 'Subcategories'); - //module admin define('_MD_TDMDOWNLOADS_ADMIN', 'Module Admin'); diff --git a/language/english/modinfo.php b/language/english/modinfo.php index cd7f971..c7f9bb7 100644 --- a/language/english/modinfo.php +++ b/language/english/modinfo.php @@ -10,9 +10,10 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + // Nom du module define('_MI_TDMDOWNLOADS_NAME', 'TDMDownloads'); define('_MI_TDMDOWNLOADS_DIRNAME', basename(dirname(dirname(__DIR__)))); diff --git a/language/french/admin.php b/language/french/admin.php index e6ba4e5..a5ffb0c 100644 --- a/language/french/admin.php +++ b/language/french/admin.php @@ -10,9 +10,10 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + // index.php define('_AM_TDMDOWNLOADS_INDEX_BROKEN', 'Il y a %s rapports de fichiers brisés'); define('_AM_TDMDOWNLOADS_INDEX_CATEGORIES', 'Il existe %s catégories'); @@ -85,7 +86,7 @@ define('_AM_TDMDOWNLOADS_IMPORT_VOTE_IMP', '« %s » votes importés ;'); define( '_AM_TDMDOWNLOADS_IMPORT_WARNING', - "Attention !

l'importation supprimera toutes les données de TDMDownloads. Il est fortement recommandé de faire une sauvegarde de toutes vos données d'abord, ainsi que de votre site internet.

TDM n'est pas responsable si vous perdez vos données. Malheureusement, les captures d'écran ne peuvent pas être copiées." + "Attention !

l'importation supprimera toutes les données de TDMDownloads. Il est fortement recommandé de faire une sauvegarde de toutes vos données d'abord, ainsi que de votre site internet.

TDM n'est pas responsable si vous perdez vos données. Malheureusement, les captures d'écran ne peuvent pas être copiées." ); define('_AM_TDMDOWNLOADS_IMPORT_WFDOWNLOADS', 'Importation de WF Downloads (Version 3.23 RC5 uniquement)'); define('_AM_TDMDOWNLOADS_IMPORT_WFDOWNLOADS_CATIMG', "Sélectionnez le répertoire Upload (le chemin d'accès) pour les images des catégories de WF-Downloads"); diff --git a/language/french/blocks.php b/language/french/blocks.php index fab5d6b..74dcd5e 100644 --- a/language/french/blocks.php +++ b/language/french/blocks.php @@ -1,4 +1,5 @@
Merci d'écrire un courrier électronique au webmestre du site d'où vous venez et dites-lui :
VOUS N'ÊTES PAS PROPRIÉTAIRE DE LIENS PROVENANT D'AUTRES SITES ! (LEECH)
Définition de leecher : Quelqu'un qui est trop paresseux pour afficher et héberger des liens sur son propre serveur ou vole le dur travail fait par d'autres personnes.

Vous êtes déjà enregistré" + "Ce fichier n'appartient pas au site d'où vous venez.

Merci d'écrire un courrier électronique au webmestre du site d'où vous venez et dites-lui :
VOUS N'ÊTES PAS PROPRIÉTAIRE DE LIENS PROVENANT D'AUTRES SITES ! (LEECH)
Définition de leecher : Quelqu'un qui est trop paresseux pour afficher et héberger des liens sur son propre serveur ou vole le dur travail fait par d'autres personnes.

Vous êtes déjà enregistré" ); //Message d'erreur define('_MD_TDMDOWNLOADS_ERREUR_NOCAT', 'Vous devez choisir une catégorie !'); @@ -144,4 +145,4 @@ define('_MD_TDMDOWNLOADS_DISPLAYMORE', 'plus de téléchargement'); define('_MD_TDMDOWNLOADS_ADDNEW', 'Soumis téléchargement'); define('_MD_TDMDOWNLOADS_COUNTDL', 'téléchargement disponible'); -define('_MD_TDMDOWNLOADS_COUNTSUBS', 'Sous catégories'); \ No newline at end of file +define('_MD_TDMDOWNLOADS_COUNTSUBS', 'Sous catégories'); diff --git a/language/french/modinfo.php b/language/french/modinfo.php index 61db7d2..f9fb12d 100644 --- a/language/french/modinfo.php +++ b/language/french/modinfo.php @@ -10,9 +10,10 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + // Nom du module define('_MI_TDMDOWNLOADS_NAME', 'TDMDownloads'); define('_MI_TDMDOWNLOADS_DIRNAME', basename(dirname(dirname(__DIR__)))); @@ -89,7 +90,7 @@ define('_MI_TDMDOWNLOADS_DOWNLOADFLOAT', 'Page de téléchargement flottante'); define( '_MI_TDMDOWNLOADS_DOWNLOADFLOAT_DSC', - "
  • De gauche à droite : Montrez la description des téléchargements du côté gauche et la colonne d'informations du côté droit
  • De droite à gauche : Montrez la description des téléchargements du côté droit et la colonne d'informations du côté gauche
" + "
  • De gauche à droite : Montrez la description des téléchargements du côté gauche et la colonne d'informations du côté droit
  • De droite à gauche : Montrez la description des téléchargements du côté droit et la colonne d'informations du côté gauche
" ); define('_MI_TDMDOWNLOADS_DOWNLOADFLOAT_LTR', 'De gauche à droite'); define('_MI_TDMDOWNLOADS_DOWNLOADFLOAT_RTL', 'De droite à gauche'); @@ -104,7 +105,10 @@ define('_MI_TDMDOWNLOADS_DOWNLOAD_PREFIX', 'Préfixe des fichiers téléchargés'); define('_MI_TDMDOWNLOADS_DOWNLOAD_PREFIXDSC', "Valide uniquement si l'option pour renommer les fichiers téléchargés est oui"); define('_MI_TDMDOWNLOADS_MAXUPLOAD_SIZE', 'Taille maximum des fichiers de téléchargement'); -define('_MI_TDMDOWNLOADS_MAXUPLOAD_SIZE_DESC', "La sélection est limitée par les valeurs de 'post_max_size' et 'upload_max_filesize' dans les paramètres php.ini
Si vous voulez augmenter les valeurs, vous devez d'abord augmenter ces paramètres dans php.ini et ensuite metre à jour le module pour faire apparaître les nouveaux choix."); +define( + '_MI_TDMDOWNLOADS_MAXUPLOAD_SIZE_DESC', + "La sélection est limitée par les valeurs de 'post_max_size' et 'upload_max_filesize' dans les paramètres php.ini
Si vous voulez augmenter les valeurs, vous devez d'abord augmenter ces paramètres dans php.ini et ensuite metre à jour le module pour faire apparaître les nouveaux choix." +); define('_MI_TDMDOWNLOADS_MAXUPLOAD_SIZE_MB', 'Mo'); define('_MI_TDMDOWNLOADS_MIMETYPE', 'Types mime autorisés '); define('_MI_TDMDOWNLOADS_MIMETYPE_DSC', 'Entrer les types mime autorisés'); diff --git a/language/german/admin.php b/language/german/admin.php index 40c3d46..ff0fb2a 100644 --- a/language/german/admin.php +++ b/language/german/admin.php @@ -10,9 +10,10 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + // index.php define('_AM_TDMDOWNLOADS_INDEX_BROKEN', 'Es gibt %s Meldungen über fehlerhafte Downloads'); define('_AM_TDMDOWNLOADS_INDEX_CATEGORIES', 'Es gibt %s Kategorien'); @@ -85,7 +86,7 @@ define('_AM_TDMDOWNLOADS_IMPORT_VOTE_IMP', "Abstimmungen: '%s' importiert;"); define( '_AM_TDMDOWNLOADS_IMPORT_WARNING', - "Achtung !

Durch den Import werden alle Daten in TDMDownloads gelöscht. Es wird dringend empfohlen, zuerst ein Backup der Daten, wenn möglich der gesamten Webseite, zu erstellen.

TDM übernimmt keinerlei Haftung für verloren gegangene Daten." + "Achtung !

Durch den Import werden alle Daten in TDMDownloads gelöscht. Es wird dringend empfohlen, zuerst ein Backup der Daten, wenn möglich der gesamten Webseite, zu erstellen.

TDM übernimmt keinerlei Haftung für verloren gegangene Daten." ); define('_AM_TDMDOWNLOADS_IMPORT_WFDOWNLOADS', 'Import von WF Downloads(nur V3.2 RC2)'); define('_AM_TDMDOWNLOADS_IMPORT_WFDOWNLOADS_CATIMG', 'Upload-Verzeichnis (Pfad) für Kategoriebilder von WF-Downloads angeben'); diff --git a/language/german/blocks.php b/language/german/blocks.php index b155df8..c0667cb 100644 --- a/language/german/blocks.php +++ b/language/german/blocks.php @@ -1,4 +1,5 @@
thanks to write an email to the webmaster of the website from where you are coming and tell him :
NO OWNERSHIP OF LINKS FROM OTHER SITES !! (LEECH)

Leecher definition : Someone who is lazy to link to its own server or steals the hard work done by other people

You are already registered.' + 'This file does not belong to the website from where you are coming.

thanks to write an email to the webmaster of the website from where you are coming and tell him :
NO OWNERSHIP OF LINKS FROM OTHER SITES !! (LEECH)

Leecher definition : Someone who is lazy to link to its own server or steals the hard work done by other people

You are already registered.' ); //Message d'erreur define('_MD_TDMDOWNLOADS_ERREUR_NOCAT', 'Sie müssen eine Kategorie wählen!'); @@ -144,4 +145,4 @@ define('_MD_TDMDOWNLOADS_DISPLAYMORE', 'Weitere Downloads anzeigen'); define('_MD_TDMDOWNLOADS_ADDNEW', 'Neuen Downloads hinzufügen'); define('_MD_TDMDOWNLOADS_COUNTDL', 'Enthaltene Downloads'); -define('_MD_TDMDOWNLOADS_COUNTSUBS', 'Unterkategorien'); \ No newline at end of file +define('_MD_TDMDOWNLOADS_COUNTSUBS', 'Unterkategorien'); diff --git a/language/german/modinfo.php b/language/german/modinfo.php index c6df4b0..8694051 100644 --- a/language/german/modinfo.php +++ b/language/german/modinfo.php @@ -10,9 +10,10 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + // The name of this module define('_MI_TDMDOWNLOADS_NAME', 'TDMDownloads'); define('_MI_TDMDOWNLOADS_DIRNAME', basename(dirname(dirname(__DIR__)))); @@ -97,7 +98,10 @@ define('_MI_TDMDOWNLOADS_DOWNLOAD_PREFIX', 'Präfix für Dateiupload'); define('_MI_TDMDOWNLOADS_DOWNLOAD_PREFIXDSC', "Nur gültig, wenn die Option 'Hochgeladene Datei umbenennen' gewählt wurde."); define('_MI_TDMDOWNLOADS_MAXUPLOAD_SIZE', 'Maximale Dateigröße für Datei-Upload'); -define('_MI_TDMDOWNLOADS_MAXUPLOAD_SIZE_DESC', "Die Auswahlbox ist entsprechend den Einstellungen 'post_max_size' und 'upload_max_filesize' in der php.ini limitiert.
Wenn Sie diese Werte erhöhen möchten dann müssen Sie zuerst die Einstellungen in der php.ini erhöhen. Danach ist ein Update des Modules erforderlich."); +define( + '_MI_TDMDOWNLOADS_MAXUPLOAD_SIZE_DESC', + "Die Auswahlbox ist entsprechend den Einstellungen 'post_max_size' und 'upload_max_filesize' in der php.ini limitiert.
Wenn Sie diese Werte erhöhen möchten dann müssen Sie zuerst die Einstellungen in der php.ini erhöhen. Danach ist ein Update des Modules erforderlich." +); define('_MI_TDMDOWNLOADS_MAXUPLOAD_SIZE_MB', 'MB'); define('_MI_TDMDOWNLOADS_MIMETYPE', 'Zulässige Mime types '); define('_MI_TDMDOWNLOADS_MIMETYPE_DSC', 'Eingabe der zulässige Mime types'); diff --git a/list.tag.php b/list.tag.php index 431c612..69a4290 100644 --- a/list.tag.php +++ b/list.tag.php @@ -10,7 +10,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Hossein Azizabadi (Aka Voltan) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Hossein Azizabadi (Aka Voltan) */ diff --git a/modfile.php b/modfile.php index 2e6b164..75b5ebe 100644 --- a/modfile.php +++ b/modfile.php @@ -1,4 +1,5 @@ get($viewDownloads->getVar('cid')); - $categories = $utility->getItemIds('tdmdownloads_view', $moduleDirName); + $categories = $utility->getItemIds('tdmdownloads_view', $moduleDirName); if (!in_array($viewDownloads->getVar('cid'), $categories)) { redirect_header('index.php', 2, _NOPERM); } @@ -60,7 +61,7 @@ $criteria->setOrder('ASC'); $criteria->add(new \Criteria('cat_cid', '(' . implode(',', $categories) . ')', 'IN')); $downloadscatArray = $categoryHandler->getAll($criteria); - $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); + $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); //navigation $navigation = $utility->getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' arrow ', true, 'ASC', true); $navigation .= ' arrow ' . $viewDownloads->getVar('title') . ''; @@ -82,7 +83,7 @@ $form = $obj->getForm($donnee = [], false, 'submit.php'); } else { /** @var \XoopsModules\Tdmdownloads\Modified $obj */ - $obj = $modifiedHandler->create(); + $obj = $modifiedHandler->create(); $form = $obj->getForm($lid, false, $donnee = []); } $xoopsTpl->assign('themeForm', $form->render()); @@ -92,10 +93,10 @@ case 'save': require_once XOOPS_ROOT_PATH . '/class/uploader.php'; /** @var \XoopsModules\Tdmdownloads\Downloads $obj */ - $obj = $modifiedHandler->create(); - $erreur = false; + $obj = $modifiedHandler->create(); + $erreur = false; $errorMessage = ''; - $donnee = []; + $donnee = []; $obj->setVar('title', \Xmf\Request::getString('title', '', 'POST')); //$_POST['title']); $donnee['title'] = \Xmf\Request::getString('title', '', 'POST'); //$_POST['title']; $obj->setVar('cid', \Xmf\Request::getInt('cid', 0, 'POST')); //$_POST['cid']); @@ -118,7 +119,7 @@ // erreur si la catégorie est vide if (\Xmf\Request::hasVar('cid')) { if (0 == \Xmf\Request::getInt('cid', 0, 'POST')) { - $erreur = true; + $erreur = true; $errorMessage .= _MD_TDMDOWNLOADS_ERREUR_NOCAT . '
'; } } @@ -129,7 +130,7 @@ $xoopsCaptcha = \XoopsCaptcha::getInstance(); if (!$xoopsCaptcha->verify()) { $errorMessage .= $xoopsCaptcha->getMessage() . '
'; - $erreur = true; + $erreur = true; } } // pour enregistrer temporairement les valeur des champs sup @@ -140,7 +141,7 @@ foreach (array_keys($downloads_field) as $i) { /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ if (0 == $downloads_field[$i]->getVar('status_def')) { - $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); + $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); $donnee[$fieldName] = \Xmf\Request::getString($fieldName, '', 'POST'); } } @@ -148,7 +149,7 @@ $xoopsTpl->assign('message_erreur', $errorMessage); } else { // Pour le fichier - $mediaSize = 0; + $mediaSize = 0; if (isset($_POST['xoops_upload_file'][0])) { $uploader = new \XoopsMediaUploader($uploaddir_downloads, $helper->getConfig('mimetypes'), $helper->getConfig('maxuploadsize'), null, null); if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { @@ -160,7 +161,7 @@ $errors = $uploader->getErrors(); redirect_header('javascript:history.go(-1)', 3, $errors); } else { - $mediaSize = $uploader->getMediaSize(); + $mediaSize = $uploader->getMediaSize(); $obj->setVar('url', $uploadurl_downloads . $uploader->getSavedFileName()); } } else { @@ -176,17 +177,19 @@ $obj->setVar('url', \Xmf\Request::getString('url', '', 'REQUEST')); } } else { - $obj->setVar('url', \Xmf\Request::getString('url', '', 'REQUEST')); - } + $obj->setVar('url', \Xmf\Request::getString('url', '', 'REQUEST')); + } // Pour l'image if (isset($_POST['xoops_upload_file'][1])) { - $uploader_2 = new \XoopsMediaUploader($uploaddir_shots, [ + $uploader_2 = new \XoopsMediaUploader( + $uploaddir_shots, [ 'image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png', - ], $helper->getConfig('maxuploadsize'), null, null); + ], $helper->getConfig('maxuploadsize'), null, null + ); if ($uploader_2->fetchMedia($_POST['xoops_upload_file'][1])) { $uploader_2->setPrefix('downloads_'); $uploader_2->fetchMedia($_POST['xoops_upload_file'][1]); @@ -208,24 +211,24 @@ $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'REQUEST')); } } else { - $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'REQUEST')); - } - //Automatic file size - if (Xmf\Request::getString('sizeValue', '') == ''){ - if ($mediaSize == 0) { - $obj->setVar('size', $utility::GetFileSize(Xmf\Request::getUrl('url', ''))); - } else { - $obj->setVar('size', $utility::FileSizeConvert($mediaSize)); - } - } else { - $obj->setVar('size', Xmf\Request::getFloat('sizeValue', 0) . ' ' . Xmf\Request::getString('sizeType', '')); - } - $timeToRedirect = 2; - if ($obj->getVar('size') == 0){ - $obj->setVar('size', ''); - $error_message = _AM_TDMDOWNLOADS_ERREUR_SIZE; - $timeToRedirect = 10; - } + $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'REQUEST')); + } + //Automatic file size + if (Xmf\Request::getString('sizeValue', '') == '') { + if ($mediaSize == 0) { + $obj->setVar('size', $utility::getFileSize(Xmf\Request::getUrl('url', ''))); + } else { + $obj->setVar('size', $utility::convertFileSize($mediaSize)); + } + } else { + $obj->setVar('size', Xmf\Request::getFloat('sizeValue', 0) . ' ' . Xmf\Request::getString('sizeType', '')); + } + $timeToRedirect = 2; + if ($obj->getVar('size') == 0) { + $obj->setVar('size', ''); + $error_message = _AM_TDMDOWNLOADS_ERREUR_SIZE; + $timeToRedirect = 10; + } if ($modifiedHandler->insert($obj)) { $lidDownloads = $obj->getNewEnreg($db); // Récupération des champs supplémentaires: @@ -237,7 +240,7 @@ /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ if (0 == $downloads_field[$i]->getVar('status_def')) { //$objdata = $modifiedfielddataHandler->create(); - $objdata = $modifieddataHandler->create(); + $objdata = $modifieddataHandler->create(); $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); $objdata->setVar('moddata', \Xmf\Request::getString($fieldName, '', 'POST')); $objdata->setVar('lid', $lidDownloads); @@ -246,12 +249,12 @@ $modifieddataHandler->insert($objdata) || $objdata->getHtmlErrors(); } } - $tags = []; + $tags = []; $tags['MODIFYREPORTS_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/admin/modified.php'; /** @var \XoopsNotificationHandler $notificationHandler */ $notificationHandler = xoops_getHandler('notification'); $notificationHandler->triggerEvent('global', 0, 'file_modify', $tags); - redirect_header('singlefile.php?lid=' . \Xmf\Request::getInt('lid', 0, 'REQUEST'), timeToRedirect, _MD_TDMDOWNLOADS_MODFILE_THANKSFORINFO . '

' . $error_message); + redirect_header('singlefile.php?lid=' . \Xmf\Request::getInt('lid', 0, 'REQUEST'), timeToRedirect, _MD_TDMDOWNLOADS_MODFILE_THANKSFORINFO . '

' . $error_message); } echo $obj->getHtmlErrors(); } diff --git a/notification_update.php b/notification_update.php index ee35836..d33fa15 100644 --- a/notification_update.php +++ b/notification_update.php @@ -10,7 +10,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ diff --git a/preloads/autoloader.php b/preloads/autoloader.php index 8b8e4bd..879a311 100644 --- a/preloads/autoloader.php +++ b/preloads/autoloader.php @@ -3,30 +3,32 @@ /** * @see http://www.php-fig.org/psr/psr-4/examples/ */ -spl_autoload_register(static function ($class) { - // project-specific namespace prefix - $prefix = 'XoopsModules\\' . ucfirst(basename(dirname(__DIR__))); +spl_autoload_register( + static function ($class) { + // project-specific namespace prefix + $prefix = 'XoopsModules\\' . ucfirst(basename(dirname(__DIR__))); - // base directory for the namespace prefix - $baseDir = dirname(__DIR__) . '/class/'; + // base directory for the namespace prefix + $baseDir = dirname(__DIR__) . '/class/'; - // does the class use the namespace prefix? - $len = mb_strlen($prefix); + // does the class use the namespace prefix? + $len = mb_strlen($prefix); - if (0 !== strncmp($prefix, $class, $len)) { - return; - } + if (0 !== strncmp($prefix, $class, $len)) { + return; + } - // get the relative class name - $relativeClass = mb_substr($class, $len); + // get the relative class name + $relativeClass = mb_substr($class, $len); - // replace the namespace prefix with the base directory, replace namespace - // separators with directory separators in the relative class name, append - // with .php - $file = $baseDir . str_replace('\\', '/', $relativeClass) . '.php'; + // replace the namespace prefix with the base directory, replace namespace + // separators with directory separators in the relative class name, append + // with .php + $file = $baseDir . str_replace('\\', '/', $relativeClass) . '.php'; - // if the file exists, require it - if (file_exists($file)) { - require_once $file; + // if the file exists, require it + if (file_exists($file)) { + require_once $file; + } } -}); +); diff --git a/preloads/core.php b/preloads/core.php index 76f25f9..b44253b 100644 --- a/preloads/core.php +++ b/preloads/core.php @@ -8,13 +8,12 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ + /** * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author XOOPS Project */ -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class TdmdownloadsCorePreload */ diff --git a/ratefile.php b/ratefile.php index bd05fc4..c968098 100644 --- a/ratefile.php +++ b/ratefile.php @@ -1,4 +1,5 @@ 10) { $errorMessage .= _MD_TDMDOWNLOADS_RATEFILE_NORATING . '
'; - $erreur = true; + $erreur = true; } xoops_load('captcha'); $xoopsCaptcha = \XoopsCaptcha::getInstance(); if (!$xoopsCaptcha->verify()) { $errorMessage .= $xoopsCaptcha->getMessage() . '
'; - $erreur = true; + $erreur = true; } $obj->setVar('lid', $lid); $obj->setVar('ratinguser', $ratinguser); @@ -140,9 +141,9 @@ if ($ratingHandler->insert($obj)) { $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('lid', $lid)); - $votesArray = $ratingHandler->getAll($criteria); - $votesTotal = $ratingHandler->getCount($criteria); - $ratingTotal = 0; + $votesArray = $ratingHandler->getAll($criteria); + $votesTotal = $ratingHandler->getCount($criteria); + $ratingTotal = 0; foreach (array_keys($votesArray) as $i) { $ratingTotal += $votesArray[$i]->getVar('rating'); } diff --git a/rss.php b/rss.php index c352dd6..deaef86 100644 --- a/rss.php +++ b/rss.php @@ -1,4 +1,5 @@ activated = false; require_once XOOPS_ROOT_PATH . '/class/template.php'; global $xoopsModuleConfig; @@ -21,7 +23,7 @@ $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); $itemsCount = $helper->getConfig('perpagerss'); -$cid = \Xmf\Request::getInt('cid', 0, 'GET'); +$cid = \Xmf\Request::getInt('cid', 0, 'GET'); if (function_exists('mb_http_output')) { mb_http_output('pass'); } @@ -88,13 +90,16 @@ } else { $descriptionShort = mb_substr($description, 0, mb_strpos($description, '[pagebreak]')); } - $xoopsTpl->append('items', [ - 'title' => htmlspecialchars($downloadsArray[$i]->getVar('title'), ENT_QUOTES), - 'link' => XOOPS_URL . '/modules/' . $moduleDirName . '/singlefile.php?cid=' . $downloadsArray[$i]->getVar('cid') . '&lid=' . $downloadsArray[$i]->getVar('lid'), - 'guid' => XOOPS_URL . '/modules/' . $moduleDirName . '/singlefile.php?cid=' . $downloadsArray[$i]->getVar('cid') . '&lid=' . $downloadsArray[$i]->getVar('lid'), - 'pubdate' => formatTimestamp($downloadsArray[$i]->getVar('date'), 'rss'), - 'description' => htmlspecialchars($descriptionShort, ENT_QUOTES), - ]); + $xoopsTpl->append( + 'items', + [ + 'title' => htmlspecialchars($downloadsArray[$i]->getVar('title'), ENT_QUOTES), + 'link' => XOOPS_URL . '/modules/' . $moduleDirName . '/singlefile.php?cid=' . $downloadsArray[$i]->getVar('cid') . '&lid=' . $downloadsArray[$i]->getVar('lid'), + 'guid' => XOOPS_URL . '/modules/' . $moduleDirName . '/singlefile.php?cid=' . $downloadsArray[$i]->getVar('cid') . '&lid=' . $downloadsArray[$i]->getVar('lid'), + 'pubdate' => formatTimestamp($downloadsArray[$i]->getVar('date'), 'rss'), + 'description' => htmlspecialchars($descriptionShort, ENT_QUOTES), + ] + ); } } header('Content-Type:text/xml; charset=' . _CHARSET); diff --git a/search.php b/search.php index 7c5e215..4b19c52 100644 --- a/search.php +++ b/search.php @@ -10,15 +10,16 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + use XoopsModules\Tdmdownloads; require_once __DIR__ . '/header.php'; /** @var \XoopsModules\Tdmdownloads\Helper $helper */ -$helper = Tdmdownloads\Helper::getInstance(); +$helper = Tdmdownloads\Helper::getInstance(); $moduleDirName = basename(__DIR__); // template d'affichage @@ -58,7 +59,7 @@ $cat_select->addOptionArray($categoryHandler->getList($criteria )); $form->addElement($cat_select);*/ $downloadscatArray = $categoryHandler->getAll($criteria); -$mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); +$mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); $form->addElement($mytree->makeSelectElement('cat', 'cat_title', '--', $cat, true, 0, '', _AM_TDMDOWNLOADS_FORMINCAT), true); //recherche champ sup. @@ -73,17 +74,17 @@ $arguments = ''; foreach (array_keys($downloads_field) as $i) { /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ - $title_sup = ''; + $title_sup = ''; $contentArray = []; - $lid_arr = []; - $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); - $criteria = new \CriteriaCompo(); + $lid_arr = []; + $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); + $criteria = new \CriteriaCompo(); if (\Xmf\Request::hasVar($fieldName, 'REQUEST')) { 999 !== \Xmf\Request::getInt($fieldName, 0, 'REQUEST') ? $fieldContent[$downloads_field[$i]->getVar('fid')] = \Xmf\Request::getInt($fieldName, 0, 'REQUEST') : $fieldContent[$downloads_field[$i]->getVar('fid')] = 999; $arguments .= $fieldName . '=' . \Xmf\Request::getInt($fieldName, 0, 'REQUEST') . '&'; } else { $fieldContent[$downloads_field[$i]->getVar('fid')] = 999; - $arguments .= $fieldName . '=&'; + $arguments .= $fieldName . '=&'; } if (1 == $downloads_field[$i]->getVar('status_def')) { $criteria->add(new \Criteria('status', 0, '!=')); @@ -107,7 +108,7 @@ } if (4 == $downloads_field[$i]->getVar('fid')) { //platform - $title_sup = _AM_TDMDOWNLOADS_FORMPLATFORM; + $title_sup = _AM_TDMDOWNLOADS_FORMPLATFORM; $platformArray = explode('|', $helper->getConfig('plateform')); foreach ($platformArray as $platform) { $contentArray[$platform] = $platform; @@ -170,16 +171,16 @@ $criteria_2->add(new \Criteria('cid', $cat)); $arguments .= 'cat=' . $cat . '&'; } -$tblsort = []; -$tblsort[1] = 'date'; -$tblsort[2] = 'date'; -$tblsort[3] = 'hits'; -$tblsort[4] = 'hits'; -$tblsort[5] = 'rating'; -$tblsort[6] = 'rating'; -$tblsort[7] = 'title'; -$tblsort[8] = 'title'; -$tblorder = []; +$tblsort = []; +$tblsort[1] = 'date'; +$tblsort[2] = 'date'; +$tblsort[3] = 'hits'; +$tblsort[4] = 'hits'; +$tblsort[5] = 'rating'; +$tblsort[6] = 'rating'; +$tblsort[7] = 'title'; +$tblsort[8] = 'title'; +$tblorder = []; $tblorder[1] = 'DESC'; $tblorder[2] = 'ASC'; $tblorder[3] = 'DESC'; @@ -188,8 +189,8 @@ $tblorder[6] = 'ASC'; $tblorder[7] = 'DESC'; $tblorder[8] = 'ASC'; -$sort = null !== $helper->getConfig('searchorder') ? $helper->getConfig('searchorder') : 1; -$order = null !== $helper->getConfig('searchorder') ? $helper->getConfig('searchorder') : 1; +$sort = null !== $helper->getConfig('searchorder') ? $helper->getConfig('searchorder') : 1; +$order = null !== $helper->getConfig('searchorder') ? $helper->getConfig('searchorder') : 1; $criteria_2->setSort($tblsort[$sort]); $criteria_2->setOrder($tblorder[$order]); $numrows = $downloadsHandler->getCount($criteria_2); @@ -208,12 +209,12 @@ $start = 0; } //pour faire une jointure de table -$downloadsHandler->table_link = $downloadsHandler->db->prefix('tdmdownloads_cat'); // Nom de la table en jointure -$downloadsHandler->field_link = 'cat_cid'; // champ de la table en jointure +$downloadsHandler->table_link = $downloadsHandler->db->prefix('tdmdownloads_cat'); // Nom de la table en jointure +$downloadsHandler->field_link = 'cat_cid'; // champ de la table en jointure $downloadsHandler->field_object = 'cid'; // champ de la table courante -$tdmdownloadsArray = $downloadsHandler->getByLink($criteria_2); +$tdmdownloadsArray = $downloadsHandler->getByLink($criteria_2); if ($numrows > $limit) { - require_once XOOPS_ROOT_PATH.'/class/pagenav.php'; + require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; $pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', $arguments); $pagenav = $pagenav->renderNav(4); } else { @@ -223,15 +224,15 @@ $xoopsTpl->assign('pagenav', $pagenav); $keywords = ''; foreach (array_keys($tdmdownloadsArray) as $i) { - $tdmdownloadsTab['lid'] = $tdmdownloadsArray[$i]->getVar('lid'); - $tdmdownloadsTab['cid'] = $tdmdownloadsArray[$i]->getVar('cid'); - $tdmdownloadsTab['title'] = $tdmdownloadsArray[$i]->getVar('title'); - $tdmdownloadsTab['cat'] = $tdmdownloadsArray[$i]->getVar('cat_title'); + $tdmdownloadsTab['lid'] = $tdmdownloadsArray[$i]->getVar('lid'); + $tdmdownloadsTab['cid'] = $tdmdownloadsArray[$i]->getVar('cid'); + $tdmdownloadsTab['title'] = $tdmdownloadsArray[$i]->getVar('title'); + $tdmdownloadsTab['cat'] = $tdmdownloadsArray[$i]->getVar('cat_title'); $tdmdownloadsTab['imgurl'] = $uploadurl . $tdmdownloadsArray[$i]->getVar('cat_imgurl'); - $tdmdownloadsTab['date'] = formatTimestamp($tdmdownloadsArray[$i]->getVar('date'), 'd/m/Y'); + $tdmdownloadsTab['date'] = formatTimestamp($tdmdownloadsArray[$i]->getVar('date'), 'd/m/Y'); $tdmdownloadsTab['rating'] = number_format($tdmdownloadsArray[$i]->getVar('rating'), 0); - $tdmdownloadsTab['hits'] = $tdmdownloadsArray[$i]->getVar('hits'); - $contenu = ''; + $tdmdownloadsTab['hits'] = $tdmdownloadsArray[$i]->getVar('hits'); + $contenu = ''; foreach (array_keys($downloads_field) as $j) { if (1 == $downloads_field[$j]->getVar('status_def')) { if (1 == $downloads_field[$j]->getVar('fid')) { diff --git a/singlefile.php b/singlefile.php index 83765cc..c8abcf9 100644 --- a/singlefile.php +++ b/singlefile.php @@ -13,7 +13,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ require_once __DIR__ . '/header.php'; @@ -135,6 +135,18 @@ } $xoopsTpl->assign('paypal', $paypal); +/** + * @param $k + * @return string + */ +function xfield_key( $k ) { + return strtolower( str_replace( + ["Ü", "ü", "Ş", "ş", "I", "ı", "Ç", "ç", "Ğ", "ğ", "Ö", "ö"], + ["u", "u", "s", "s", "i", "i", "c", "c", "g", "g", "o", "o"], + $k + ) ); +} + // pour les champs supplémentaires $criteria = new \CriteriaCompo(); $criteria->setSort('weight ASC, title'); @@ -145,6 +157,7 @@ $nb_champ = count($downloads_field); $champ_sup = ''; $champ_sup_vide = 0; +$xfields = []; foreach (array_keys($downloads_field) as $i) { /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ if (1 == $downloads_field[$i]->getVar('status_def')) { @@ -153,6 +166,8 @@ if ('' != $viewDownloads->getVar('homepage')) { $champ_sup = ' ' . _AM_TDMDOWNLOADS_FORMHOMEPAGE . ': ' . _MD_TDMDOWNLOADS_SINGLEFILE_ICI . ''; ++$champ_sup_vide; + + $xfields['homepage'] = $champ_sup; } } if (2 == $downloads_field[$i]->getVar('fid')) { @@ -160,14 +175,18 @@ if ('' != $viewDownloads->getVar('version')) { $champ_sup = ' ' . _AM_TDMDOWNLOADS_FORMVERSION . ': ' . $viewDownloads->getVar('version'); ++$champ_sup_vide; + + $xfields['version'] = $champ_sup; } } if (3 == $downloads_field[$i]->getVar('fid')) { //taille du fichier $size_value_arr = explode(' ', $viewDownloads->getVar('size')); if ('' != $size_value_arr[0]) { - $champ_sup = ' ' . _AM_TDMDOWNLOADS_FORMSIZE . ': ' . $utility::SizeConvertString($viewDownloads->getVar('size')); + $champ_sup = ' ' . _AM_TDMDOWNLOADS_FORMSIZE . ': ' . $utility::convertSizeToString($viewDownloads->getVar('size')); ++$champ_sup_vide; + + $xfields['size'] = $champ_sup; } } if (4 == $downloads_field[$i]->getVar('fid')) { @@ -175,6 +194,8 @@ if ('' != $viewDownloads->getVar('platform')) { $champ_sup = ' ' . _AM_TDMDOWNLOADS_FORMPLATFORM . $viewDownloads->getVar('platform'); ++$champ_sup_vide; + + $xfields['platform'] = $champ_sup; } } } else { @@ -191,16 +212,24 @@ if ('' != $contenu) { $champ_sup = ' ' . $downloads_field[$i]->getVar('title') . ': ' . $contenu; ++$champ_sup_vide; + + $xfield_key = xfield_key( $downloads_field[$i]->getVar('title') ); + $xfields[ $xfield_key ] = $contenu; } } if ('' != $champ_sup) { - $xoopsTpl->append('champ_sup', [ - 'image' => $uploadurl_field . $downloads_field[$i]->getVar('img'), - 'data' => $champ_sup, - ]); + $xoopsTpl->append( + 'champ_sup', + [ + 'image' => $uploadurl_field . $downloads_field[$i]->getVar('img'), + 'data' => $champ_sup, + ] + ); } $champ_sup = ''; } + +$xoopsTpl->assign('xfields', $xfields); if ($nb_champ > 0 && $champ_sup_vide > 0) { $xoopsTpl->assign('sup_aff', true); } else { @@ -242,13 +271,9 @@ } $tellafriendText = '' . _MD_TDMDOWNLOADS_SINGLEFILE_TELLAFRIEND . ''; } else { - $tellafriendText = '' . _MD_TDMDOWNLOADS_SINGLEFILE_TELLAFRIEND . ''; + $tellafriendText = '' . _MD_TDMDOWNLOADS_SINGLEFILE_TELLAFRIEND . ''; } $xoopsTpl->assign('tellafriend_texte', $tellafriendText); diff --git a/submit.php b/submit.php index f34cc44..a1c6e03 100644 --- a/submit.php +++ b/submit.php @@ -14,7 +14,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Gregory Mage (Aka Mage) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ require_once __DIR__ . '/header.php'; @@ -29,7 +29,7 @@ $xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $moduleDirName . '/assets/css/styles.css', null); //On recupere la valeur de l'argument op dans l'URL$ -$op = \Xmf\Request::getString('op', 'list'); +$op = \Xmf\Request::getString('op', 'list'); $lid = \Xmf\Request::getInt('lid', 0, 'REQUEST'); // redirection si pas de droit pour poster @@ -69,14 +69,14 @@ $newUpload = true; /** @var \XoopsModules\Tdmdownloads\Downloads $obj */ if (true === $perm_autoapprove && $lid > 0) { - $obj = $downloadsHandler->get($lid); + $obj = $downloadsHandler->get($lid); $newUpload = false; } else { $obj = $downloadsHandler->create(); } - $erreur = false; + $erreur = false; $errorMessage = ''; - $donnee = []; + $donnee = []; $obj->setVar('title', \Xmf\Request::getString('title', '', 'POST')); $donnee['title'] = \Xmf\Request::getString('title', '', 'POST'); $obj->setVar('cid', \Xmf\Request::getString('cid', '', 'POST')); @@ -116,7 +116,7 @@ // erreur si la catégorie est vide if (\Xmf\Request::hasVar('cid', 'REQUEST')) { if (0 === \Xmf\Request::getInt('cid', 0, 'REQUEST')) { - $erreur = true; + $erreur = true; $errorMessage .= _MD_TDMDOWNLOADS_ERREUR_NOCAT . '
'; } } @@ -125,7 +125,7 @@ $xoopsCaptcha = \XoopsCaptcha::getInstance(); if (!$xoopsCaptcha->verify()) { $errorMessage .= $xoopsCaptcha->getMessage() . '
'; - $erreur = true; + $erreur = true; } // pour enregistrer temporairement les valeur des champs sup $criteria = new \CriteriaCompo(); @@ -135,7 +135,7 @@ foreach (array_keys($downloads_field) as $i) { /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ if (0 === $downloads_field[$i]->getVar('status_def')) { - $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); + $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); $donnee[$fieldName] = \Xmf\Request::getString($fieldName, '', 'POST'); } } @@ -150,153 +150,155 @@ $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); break; } - $obj->setVar('size', \Xmf\Request::getString('size', '', 'POST') . ' ' . \Xmf\Request::getString('type_size', '', 'POST')); - // Pour le fichier - $mediaSize = 0; - if (isset($_POST['xoops_upload_file'][0])) { - $uploader = new \XoopsMediaUploader($uploaddir_downloads, $helper->getConfig('mimetypes'), $helper->getConfig('maxuploadsize'), null, null); - if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { - if ($helper->getConfig('newnamedownload')) { - $uploader->setPrefix($helper->getConfig('prefixdownloads')); - } - $uploader->fetchMedia($_POST['xoops_upload_file'][0]); - if (!$uploader->upload()) { - $errors = $uploader->getErrors(); - redirect_header('javascript:history.go(-1)', 3, $errors); - } else { - $mediaSize = $uploader->getMediaSize(); - $obj->setVar('url', $uploadurl_downloads . $uploader->getSavedFileName()); - } - } else { - if ($_FILES['attachedfile']['name'] > '') { - // file name was given, but fetchMedia failed - show error when e.g. file size exceed maxuploadsize - $errorMessage .= $uploader->getErrors() . '
'; - $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); - $form = $obj->getForm($donnee, true); - $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); - break; - } - $obj->setVar('url', \Xmf\Request::getString('url', '', 'REQUEST')); + $obj->setVar('size', \Xmf\Request::getString('size', '', 'POST') . ' ' . \Xmf\Request::getString('type_size', '', 'POST')); + // Pour le fichier + $mediaSize = 0; + if (isset($_POST['xoops_upload_file'][0])) { + $uploader = new \XoopsMediaUploader($uploaddir_downloads, $helper->getConfig('mimetypes'), $helper->getConfig('maxuploadsize'), null, null); + if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { + if ($helper->getConfig('newnamedownload')) { + $uploader->setPrefix($helper->getConfig('prefixdownloads')); } - } else { - $obj->setVar('url', \Xmf\Request::getString('url', '', 'REQUEST')); - } - // Pour l'image - if (isset($_POST['xoops_upload_file'][1])) { - $uploader_2 = new \XoopsMediaUploader($uploaddir_shots, [ - 'image/gif', - 'image/jpeg', - 'image/pjpeg', - 'image/x-png', - 'image/png', - ], $helper->getConfig('maxuploadsize'), null, null); - if ($uploader_2->fetchMedia($_POST['xoops_upload_file'][1])) { - $uploader_2->setPrefix('downloads_'); - $uploader_2->fetchMedia($_POST['xoops_upload_file'][1]); - if (!$uploader_2->upload()) { - $errors = $uploader_2->getErrors(); - redirect_header('javascript:history.go(-1)', 3, $errors); - } else { - $obj->setVar('logourl', $uploader_2->getSavedFileName()); - } + $uploader->fetchMedia($_POST['xoops_upload_file'][0]); + if (!$uploader->upload()) { + $errors = $uploader->getErrors(); + redirect_header('javascript:history.go(-1)', 3, $errors); } else { - if ($_FILES['attachedimage']['name'] > '') { - // file name was given, but fetchMedia failed - show error when e.g. file size exceed maxuploadsize - $errorMessage .= $uploader_2->getErrors() . '
'; - $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); - $form = $obj->getForm($donnee, true); - $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); - break; - } - $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'REQUEST')); + $mediaSize = $uploader->getMediaSize(); + $obj->setVar('url', $uploadurl_downloads . $uploader->getSavedFileName()); } } else { - $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'REQUEST')); - } - //Automatic file size - if (Xmf\Request::getString('sizeValue', '') == ''){ - if ($mediaSize == 0) { - $obj->setVar('size', $utility::GetFileSize(Xmf\Request::getUrl('url', ''))); - } else { - $obj->setVar('size', $utility::FileSizeConvert($mediaSize)); - } - } else { - $obj->setVar('size', Xmf\Request::getFloat('sizeValue', 0) . ' ' . Xmf\Request::getString('sizeType', '')); - } - $timeToRedirect = 2; - if ($obj->getVar('size') == 0){ - $obj->setVar('size', ''); - $error_message = _AM_TDMDOWNLOADS_ERREUR_SIZE; - $timeToRedirect = 10; - } - if ($downloadsHandler->insert($obj)) { - if ($newUpload) { - $lidDownloads = $obj->getNewEnreg($db); + if ($_FILES['attachedfile']['name'] > '') { + // file name was given, but fetchMedia failed - show error when e.g. file size exceed maxuploadsize + $errorMessage .= $uploader->getErrors() . '
'; + $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); + $form = $obj->getForm($donnee, true); + $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); + break; + } + $obj->setVar('url', \Xmf\Request::getString('url', '', 'REQUEST')); + } + } else { + $obj->setVar('url', \Xmf\Request::getString('url', '', 'REQUEST')); + } + // Pour l'image + if (isset($_POST['xoops_upload_file'][1])) { + $uploader_2 = new \XoopsMediaUploader( + $uploaddir_shots, [ + 'image/gif', + 'image/jpeg', + 'image/pjpeg', + 'image/x-png', + 'image/png', + ], $helper->getConfig('maxuploadsize'), null, null + ); + if ($uploader_2->fetchMedia($_POST['xoops_upload_file'][1])) { + $uploader_2->setPrefix('downloads_'); + $uploader_2->fetchMedia($_POST['xoops_upload_file'][1]); + if (!$uploader_2->upload()) { + $errors = $uploader_2->getErrors(); + redirect_header('javascript:history.go(-1)', 3, $errors); } else { - $lidDownloads = $lid; + $obj->setVar('logourl', $uploader_2->getSavedFileName()); } - //tags - if ((1 == $helper->getConfig('usetag')) && class_exists(TagHandler::class)) { - /** @var \XoopsModules\Tag\TagHandler $tagHandler */ - $tagHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Tag'); - $tagHandler->updateByItem($_POST['tag'], $lidDownloads, $moduleDirName, 0); + } else { + if ($_FILES['attachedimage']['name'] > '') { + // file name was given, but fetchMedia failed - show error when e.g. file size exceed maxuploadsize + $errorMessage .= $uploader_2->getErrors() . '
'; + $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); + $form = $obj->getForm($donnee, true); + $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); + break; } - // Récupération des champs supplémentaires: - $criteria = new \CriteriaCompo(); - $criteria->setSort('weight ASC, title'); - $criteria->setOrder('ASC'); - $downloads_field = $fieldHandler->getAll($criteria); - foreach (array_keys($downloads_field) as $i) { - if (0 === $downloads_field[$i]->getVar('status_def')) { - $objdata = $fielddataHandler->create(); - $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); - $objdata->setVar('data', \Xmf\Request::getString($fieldName, '', 'POST')); - $objdata->setVar('lid', $lidDownloads); - $objdata->setVar('fid', $downloads_field[$i]->getVar('fid')); - $fielddataHandler->insert($objdata) || $objdata->getHtmlErrors(); - } + $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'REQUEST')); + } + } else { + $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'REQUEST')); + } + //Automatic file size + if (Xmf\Request::getString('sizeValue', '') == '') { + if ($mediaSize == 0) { + $obj->setVar('size', $utility::getFileSize(Xmf\Request::getUrl('url', ''))); + } else { + $obj->setVar('size', $utility::convertFileSize($mediaSize)); + } + } else { + $obj->setVar('size', Xmf\Request::getFloat('sizeValue', 0) . ' ' . Xmf\Request::getString('sizeType', '')); + } + $timeToRedirect = 2; + if ($obj->getVar('size') == 0) { + $obj->setVar('size', ''); + $error_message = _AM_TDMDOWNLOADS_ERREUR_SIZE; + $timeToRedirect = 10; + } + if ($downloadsHandler->insert($obj)) { + if ($newUpload) { + $lidDownloads = $obj->getNewEnreg($db); + } else { + $lidDownloads = $lid; + } + //tags + if ((1 == $helper->getConfig('usetag')) && class_exists(TagHandler::class)) { + /** @var \XoopsModules\Tag\TagHandler $tagHandler */ + $tagHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Tag'); + $tagHandler->updateByItem($_POST['tag'], $lidDownloads, $moduleDirName, 0); + } + // Récupération des champs supplémentaires: + $criteria = new \CriteriaCompo(); + $criteria->setSort('weight ASC, title'); + $criteria->setOrder('ASC'); + $downloads_field = $fieldHandler->getAll($criteria); + foreach (array_keys($downloads_field) as $i) { + if (0 === $downloads_field[$i]->getVar('status_def')) { + $objdata = $fielddataHandler->create(); + $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); + $objdata->setVar('data', \Xmf\Request::getString($fieldName, '', 'POST')); + $objdata->setVar('lid', $lidDownloads); + $objdata->setVar('fid', $downloads_field[$i]->getVar('fid')); + $fielddataHandler->insert($objdata) || $objdata->getHtmlErrors(); } - if ($xoopsUser) { - if ($xoopsUser->isAdmin($xoopsModule->mid())) { - //permission pour télécharger - if (1 == $helper->getConfig('permission_download')) { - /** @var \XoopsGroupPermHandler $grouppermHandler */ - $grouppermHandler = xoops_getHandler('groupperm'); - $criteria = new \CriteriaCompo(); - $criteria->add(new \Criteria('gperm_itemid', $lidDownloads, '=')); - $criteria->add(new \Criteria('gperm_modid', $xoopsModule->getVar('mid'), '=')); - $criteria->add(new \Criteria('gperm_name', 'tdmdownloads_download_item', '=')); - $grouppermHandler->deleteAll($criteria); - if (\Xmf\Request::hasVar('item_download', 'POST')) { - foreach ($_POST['item_download'] as $onegroup_id) { - $grouppermHandler->addRight('tdmdownloads_download_item', $lidDownloads, $onegroup_id, $xoopsModule->getVar('mid')); - } + } + if ($xoopsUser) { + if ($xoopsUser->isAdmin($xoopsModule->mid())) { + //permission pour télécharger + if (1 == $helper->getConfig('permission_download')) { + /** @var \XoopsGroupPermHandler $grouppermHandler */ + $grouppermHandler = xoops_getHandler('groupperm'); + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('gperm_itemid', $lidDownloads, '=')); + $criteria->add(new \Criteria('gperm_modid', $xoopsModule->getVar('mid'), '=')); + $criteria->add(new \Criteria('gperm_name', 'tdmdownloads_download_item', '=')); + $grouppermHandler->deleteAll($criteria); + if (\Xmf\Request::hasVar('item_download', 'POST')) { + foreach ($_POST['item_download'] as $onegroup_id) { + $grouppermHandler->addRight('tdmdownloads_download_item', $lidDownloads, $onegroup_id, $xoopsModule->getVar('mid')); } } } } - /** @var \XoopsNotificationHandler $notificationHandler */ - $notificationHandler = xoops_getHandler('notification'); - $tags = []; - $tags['FILE_NAME'] = $donnee['title']; - $tags['FILE_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/singlefile.php?cid=' . $donnee['cid'] . '&lid=' . $lidDownloads; - $downloadscat_cat = $categoryHandler->get($donnee['cid']); - $tags['CATEGORY_NAME'] = $downloadscat_cat->getVar('cat_title'); - $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/viewcat.php?cid=' . $donnee['cid']; - - if (true === $perm_autoapprove) { - $notificationHandler->triggerEvent('global', 0, 'new_file', $tags); - $notificationHandler->triggerEvent('category', $donnee['cid'], 'new_file', $tags); - redirect_header('index.php', $timeToRedirect, _MD_TDMDOWNLOADS_SUBMIT_RECEIVED . '
' . _MD_TDMDOWNLOADS_SUBMIT_ISAPPROVED . '

' . $error_message); - exit; - } - $tags['WAITINGFILES_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/admin/index.php?op=listNewDownloads'; - $notificationHandler->triggerEvent('global', 0, 'file_submit', $tags); - $notificationHandler->triggerEvent('category', $donnee['cid'], 'file_submit', $tags); - redirect_header('index.php', $timeToRedirect, _MD_TDMDOWNLOADS_SUBMIT_RECEIVED . '

' . $error_message); + } + /** @var \XoopsNotificationHandler $notificationHandler */ + $notificationHandler = xoops_getHandler('notification'); + $tags = []; + $tags['FILE_NAME'] = $donnee['title']; + $tags['FILE_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/singlefile.php?cid=' . $donnee['cid'] . '&lid=' . $lidDownloads; + $downloadscat_cat = $categoryHandler->get($donnee['cid']); + $tags['CATEGORY_NAME'] = $downloadscat_cat->getVar('cat_title'); + $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/viewcat.php?cid=' . $donnee['cid']; + + if (true === $perm_autoapprove) { + $notificationHandler->triggerEvent('global', 0, 'new_file', $tags); + $notificationHandler->triggerEvent('category', $donnee['cid'], 'new_file', $tags); + redirect_header('index.php', $timeToRedirect, _MD_TDMDOWNLOADS_SUBMIT_RECEIVED . '
' . _MD_TDMDOWNLOADS_SUBMIT_ISAPPROVED . '

' . $error_message); exit; } - $errors = $obj->getHtmlErrors(); + $tags['WAITINGFILES_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/admin/index.php?op=listNewDownloads'; + $notificationHandler->triggerEvent('global', 0, 'file_submit', $tags); + $notificationHandler->triggerEvent('category', $donnee['cid'], 'file_submit', $tags); + redirect_header('index.php', $timeToRedirect, _MD_TDMDOWNLOADS_SUBMIT_RECEIVED . '

' . $error_message); + exit; + } + $errors = $obj->getHtmlErrors(); $form = $obj->getForm($donnee, true); $xoopsTpl->assign('themeForm', $form->render()); diff --git a/templates/admin/tdmdownloads_admin_footer.tpl b/templates/admin/tdmdownloads_admin_footer.tpl index bbf04f0..84d905c 100644 --- a/templates/admin/tdmdownloads_admin_footer.tpl +++ b/templates/admin/tdmdownloads_admin_footer.tpl @@ -1,4 +1,4 @@ -
XOOPS
+
XOOPS
TDMDownloads <{$smarty.const._AM_TDMDOWNLOADS_MAINTAINEDBY}> Xoops Support Team <{if $latestModRelease}> diff --git a/templates/admin/tdmdownloads_admin_import.tpl b/templates/admin/tdmdownloads_admin_import.tpl index 108c2de..553e89c 100644 --- a/templates/admin/tdmdownloads_admin_import.tpl +++ b/templates/admin/tdmdownloads_admin_import.tpl @@ -11,7 +11,7 @@ -webkit-border-radius: 4px; border-radius: 4px; line-height: 140%; - margin-top: 0px; + margin-top: 0; margin-bottom: 50px; } diff --git a/templates/tdmdownloads_rss.tpl b/templates/tdmdownloads_rss.tpl index 568fc71..b60ba1c 100644 --- a/templates/tdmdownloads_rss.tpl +++ b/templates/tdmdownloads_rss.tpl @@ -30,5 +30,6 @@ <{$item.guid}> <{/foreach}> + diff --git a/templates/tdmdownloads_upload.tpl b/templates/tdmdownloads_upload.tpl index c435139..5419e61 100644 --- a/templates/tdmdownloads_upload.tpl +++ b/templates/tdmdownloads_upload.tpl @@ -103,7 +103,7 @@ <{if $catId}> <{/if}> diff --git a/testdata/index.php b/testdata/index.php index a1d533a..65c6ee7 100644 --- a/testdata/index.php +++ b/testdata/index.php @@ -8,21 +8,51 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @package * @since 2.5.9 * @author Michael Beck (aka Mamba) */ + +use Xmf\Database\TableLoad; +use Xmf\Module\Helper; +use Xmf\Request; +use Xmf\Yaml; use XoopsModules\Tdmdownloads; use XoopsModules\Tdmdownloads\Common; - -require dirname(dirname(dirname(__DIR__))) . '/mainfile.php'; -include dirname(__DIR__) . '/preloads/autoloader.php'; -$op = \Xmf\Request::getCmd('op', ''); - +use XoopsModules\Tdmdownloads\Utility; + +require_once dirname(__DIR__, 3) . '/include/cp_header.php'; +require dirname(__DIR__) . '/preloads/autoloader.php'; +$op = Request::getCmd('op', ''); +$moduleDirName = basename(dirname(__DIR__)); +$moduleDirNameUpper = mb_strtoupper($moduleDirName); +$helper = Tdmdownloads\Helper::getInstance(); +// Load language files +$helper->loadLanguage('common'); switch ($op) { case 'load': + if (Request::hasVar('ok', 'REQUEST') && 1 === Request::getInt('ok', 0, 'REQUEST')) { + if (!$GLOBALS['xoopsSecurity']->check()) { + redirect_header('../admin/index.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); + } loadSampleData(); + } else { + xoops_cp_header(); + xoops_confirm( + [ + 'ok' => 1, + 'op' => 'load', + ], + 'index.php', + sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA_OK')), + constant( + 'CO_' . $moduleDirNameUpper . '_' . 'CONFIRM' + ), + true + ); + xoops_cp_footer(); + } break; case 'save': saveSampleData(); @@ -33,33 +63,36 @@ function loadSampleData() { - $moduleDirName = basename(dirname(__DIR__)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName - $helper = Tdmdownloads\Helper::getInstance(); - $utility = new Tdmdownloads\Utility(); - $configurator = new Common\Configurator(); - // Load language files - $helper->loadLanguage('admin'); - $helper->loadLanguage('modinfo'); - $helper->loadLanguage('common'); - - // $items = \Xmf\Yaml::readWrapped('quotes_data.yml'); - // \Xmf\Database\TableLoad::truncateTable($moduleDirName . '_quotes'); - // \Xmf\Database\TableLoad::loadTableFromArray($moduleDirName . '_quotes', $items); - - $tables = \Xmf\Module\Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); - + global $xoopsConfig; + $moduleDirName = basename(dirname(__DIR__)); + $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $utility = new Tdmdownloads\Utility(); + $configurator = new Common\Configurator(); + $tables = Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); + $language = 'english/'; + if (is_dir(__DIR__ . '/' . $xoopsConfig['language'])) { + $language = $xoopsConfig['language'] . '/'; + } foreach ($tables as $table) { - $tabledata = \Xmf\Yaml::readWrapped($table . '.yml'); - \Xmf\Database\TableLoad::truncateTable($table); - \Xmf\Database\TableLoad::loadTableFromArray($table, $tabledata); + $tabledata = Yaml::readWrapped($language . $table . '.yml'); + if (is_array($tabledata)) { + TableLoad::truncateTable($table); + TableLoad::loadTableFromArray($table, $tabledata); + } } // --- COPY test folder files --------------- - if (is_array($configurator->copyTestFolders) && count($configurator->copyTestFolders) > 0) { + if (is_array($configurator->copyTestFolders) + && count( + $configurator->copyTestFolders + ) > 0) { // $file = dirname(__DIR__) . '/testdata/images/'; - foreach (array_keys($configurator->copyTestFolders) as $i) { - $src = $configurator->copyTestFolders[$i][0]; + foreach ( + array_keys( + $configurator->copyTestFolders + ) as $i + ) { + $src = $configurator->copyTestFolders[$i][0]; $dest = $configurator->copyTestFolders[$i][1]; $utility::rcopy($src, $dest); } @@ -70,13 +103,22 @@ function loadSampleData() function saveSampleData() { - $moduleDirName = basename(dirname(__DIR__)); + global $xoopsConfig; + $moduleDirName = basename(dirname(__DIR__)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); - - $tables = \Xmf\Module\Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); - + $tables = Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); + $language = 'english/'; + if (is_dir(__DIR__ . '/' . $xoopsConfig['language'])) { + $language = $xoopsConfig['language'] . '/'; + } + $languageFolder = __DIR__ . '/' . $language; + if (!file_exists($languageFolder . '/')) { + Utility::createFolder($languageFolder . '/'); + } + $exportFolder = $languageFolder . '/Exports-' . date('Y-m-d-H-i-s') . '/'; + Utility::createFolder($exportFolder); foreach ($tables as $table) { - \Xmf\Database\TableLoad::saveTableToYamlFile($table, $table . '_' . date('Y-m-d H-i-s') . '.yml'); + TableLoad::saveTableToYamlFile($table, $exportFolder . $table . '.yml'); } redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'SAMPLEDATA_SUCCESS')); @@ -84,15 +126,15 @@ function saveSampleData() function exportSchema() { - try { - $moduleDirName = basename(dirname(__DIR__)); + $moduleDirName = basename(dirname(__DIR__)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); - - $migrate = new \Xmf\Database\Migrate($moduleDirName); - $migrate->saveCurrentSchema(); - - redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS')); - } catch (\Exception $e) { + try { + // TODO set exportSchema + // $migrate = new Tdmdownloads\Migrate($moduleDirName); + // $migrate->saveCurrentSchema(); + // + // redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS')); + } catch (Throwable $e) { exit(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR')); } } diff --git a/upload.php b/upload.php index 00edb75..3ce758f 100644 --- a/upload.php +++ b/upload.php @@ -11,7 +11,7 @@ /** * @copyright XOOPS Project https://xoops.org/ - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @link https://xoops.org/ * @min_xoops 2.5.9 * @author Wedega - Email: - Website: @@ -20,7 +20,7 @@ use Xmf\Request; use XoopsModules\Tdmdownloads; -include_once __DIR__ . '/header.php'; +require_once __DIR__ . '/header.php'; $moduleDirName = basename(__DIR__); $moduleDirNameUpper = mb_strtoupper($moduleDirName); @@ -30,7 +30,7 @@ $catId = Request::getInt('cat_cid', 0); // Template $GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_upload.tpl'; -include_once XOOPS_ROOT_PATH . '/header.php'; +require_once XOOPS_ROOT_PATH . '/header.php'; $pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16); $GLOBALS['xoopsTpl']->assign('pathIcon16', $pathIcon16); @@ -54,7 +54,6 @@ $permHelper->checkPermissionRedirect('tdmdownloads_submit', $catId, 'index.php', 3, 'You are not allowed to submit a file', false); $permissionUpload = $permHelper->checkPermission('tdmdownloads_submit', $catId, false); if ($permissionUpload) { - if (0 < $catId) { $GLOBALS['xoopsTpl']->assign('catId', $catId); @@ -137,12 +136,11 @@ $fineup_debug = 'true'; } $xoopsTpl->assign('fineup_debug', $fineup_debug); - } } // Breadcrumbs $xoBreadcrumbs[] = ['title' => constant('CO_' . $moduleDirNameUpper . '_IMAGES_UPLOAD')]; -//include __DIR__ . '/footer.php'; -include_once XOOPS_ROOT_PATH . '/footer.php'; +//require __DIR__ . '/footer.php'; +require_once XOOPS_ROOT_PATH . '/footer.php'; diff --git a/view.tag.php b/view.tag.php index 56abb33..b10fa9a 100644 --- a/view.tag.php +++ b/view.tag.php @@ -10,7 +10,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Hossein Azizabadi (Aka Voltan) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Hossein Azizabadi (Aka Voltan) */ diff --git a/viewcat.php b/viewcat.php index e4f5814..f16d8ce 100644 --- a/viewcat.php +++ b/viewcat.php @@ -1,4 +1,5 @@ assign('category_id', $cid); $cat_info = $categoryHandler->get($cid); $xoopsTpl->assign('cat_description', $cat_info->getVar('cat_description_main')); -$uploadurl = XOOPS_URL . '/uploads/' . $moduleDirName . '/images/cats/'; +$uploadurl = XOOPS_URL . '/uploads/' . $moduleDirName . '/images/cats/'; $categoryObject = $categoryHandler->get($cid); -$tempCategory = [ +$tempCategory = [ 'image' => $cat_info->getVar('cat_imgurl'), 'id' => $cat_info->getVar('cat_cid'), 'title' => $cat_info->getVar('cat_title'), @@ -99,15 +100,18 @@ $keywords .= $downloadscatArray[$i]->getVar('cat_title') . ','; ++$chcount; } - $xoopsTpl->append('subcategories', [ - 'image' => $uploadurl . $downloadscatArray[$i]->getVar('cat_imgurl'), - 'id' => $downloadscatArray[$i]->getVar('cat_cid'), - 'title' => $downloadscatArray[$i]->getVar('cat_title'), - 'description_main' => $downloadscatArray[$i]->getVar('cat_description_main'), - 'infercategories' => $subcategories, - 'totaldownloads' => $totaldownloads, - 'count' => $count, - ]); + $xoopsTpl->append( + 'subcategories', + [ + 'image' => $uploadurl . $downloadscatArray[$i]->getVar('cat_imgurl'), + 'id' => $downloadscatArray[$i]->getVar('cat_cid'), + 'title' => $downloadscatArray[$i]->getVar('cat_title'), + 'description_main' => $downloadscatArray[$i]->getVar('cat_description_main'), + 'infercategories' => $subcategories, + 'totaldownloads' => $totaldownloads, + 'count' => $count, + ] + ); ++$count; } } @@ -131,12 +135,15 @@ $title = mb_substr($title, 0, $helper->getConfig('longbl')) . '...'; } $date = formatTimestamp($downloadsArray[$i]->getVar('date'), 's'); - $xoopsTpl->append('bl_date', [ - 'id' => $downloadsArray[$i]->getVar('lid'), - 'cid' => $downloadsArray[$i]->getVar('cid'), - 'date' => $date, - 'title' => $title, - ]); + $xoopsTpl->append( + 'bl_date', + [ + 'id' => $downloadsArray[$i]->getVar('lid'), + 'cid' => $downloadsArray[$i]->getVar('cid'), + 'date' => $date, + 'title' => $title, + ] + ); } } //plus téléchargés @@ -154,12 +161,15 @@ if (mb_strlen($title) >= $helper->getConfig('longbl')) { $title = mb_substr($title, 0, $helper->getConfig('longbl')) . '...'; } - $xoopsTpl->append('bl_pop', [ - 'id' => $downloadsArray[$i]->getVar('lid'), - 'cid' => $downloadsArray[$i]->getVar('cid'), - 'hits' => $downloadsArray[$i]->getVar('hits'), - 'title' => $title, - ]); + $xoopsTpl->append( + 'bl_pop', + [ + 'id' => $downloadsArray[$i]->getVar('lid'), + 'cid' => $downloadsArray[$i]->getVar('cid'), + 'hits' => $downloadsArray[$i]->getVar('hits'), + 'title' => $title, + ] + ); } } //mieux notés @@ -178,12 +188,15 @@ $title = mb_substr($title, 0, $helper->getConfig('longbl')) . '...'; } $rating = number_format($downloadsArray[$i]->getVar('rating'), 1); - $xoopsTpl->append('bl_rating', [ - 'id' => $downloadsArray[$i]->getVar('lid'), - 'cid' => $downloadsArray[$i]->getVar('cid'), - 'rating' => $rating, - 'title' => $title, - ]); + $xoopsTpl->append( + 'bl_rating', + [ + 'id' => $downloadsArray[$i]->getVar('lid'), + 'cid' => $downloadsArray[$i]->getVar('cid'), + 'rating' => $rating, + 'title' => $title, + ] + ); } } // affichage du résumé @@ -241,7 +254,7 @@ $downloadsArray = $downloadsHandler->getAll($criteria); if ($numrows > $limit) { - require_once XOOPS_ROOT_PATH.'/class/pagenav.php'; + require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; $pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', 'limit=' . $limit . '&cid=' . \Xmf\Request::getInt('cid', 0, 'REQUEST') . '&sort=' . $sort . '&order=' . $order); $pagenav = $pagenav->renderNav(4); } else { @@ -307,22 +320,25 @@ $summary = $cpt . '- ' . $downloadsArray[$i]->getVar('title') . '
'; $xoopsTpl->append('summary', ['title' => $summary, 'count' => $cpt]); - $xoopsTpl->append('file', [ - 'id' => $downloadsArray[$i]->getVar('lid'), - 'cid' => $downloadsArray[$i]->getVar('cid'), - 'title' => $downloadsArray[$i]->getVar('title'), - 'rating' => number_format($downloadsArray[$i]->getVar('rating'), 1), - 'hits' => $downloadsArray[$i]->getVar('hits'), - 'new' => $new, - 'pop' => $pop, - 'logourl' => $logourl, - 'updated' => $datetime, - 'description_short' => $descriptionShort, - 'adminlink' => $adminlink, - 'submitter' => $submitter, - 'perm_download' => $downloadPermission, - 'count' => $cpt, - ]); + $xoopsTpl->append( + 'file', + [ + 'id' => $downloadsArray[$i]->getVar('lid'), + 'cid' => $downloadsArray[$i]->getVar('cid'), + 'title' => $downloadsArray[$i]->getVar('title'), + 'rating' => number_format($downloadsArray[$i]->getVar('rating'), 1), + 'hits' => $downloadsArray[$i]->getVar('hits'), + 'new' => $new, + 'pop' => $pop, + 'logourl' => $logourl, + 'updated' => $datetime, + 'description_short' => $descriptionShort, + 'adminlink' => $adminlink, + 'submitter' => $submitter, + 'perm_download' => $downloadPermission, + 'count' => $cpt, + ] + ); //pour les mots clef $keywords .= $downloadsArray[$i]->getVar('title') . ','; } diff --git a/visit.php b/visit.php index b78a3e2..4babcb2 100644 --- a/visit.php +++ b/visit.php @@ -1,4 +1,5 @@ activated = false; error_reporting(0); if ($helper->getConfig('check_host')) { - $goodhost = 0; - $referer = parse_url(xoops_getenv('HTTP_REFERER')); + $goodhost = 0; + $referer = parse_url(xoops_getenv('HTTP_REFERER')); $refererHost = $referer['host']; foreach ($helper->getConfig('referers') as $ref) { if (!empty($ref) && preg_match('/' . $ref . '/i', $refererHost)) { @@ -112,10 +113,10 @@ $sql = sprintf('UPDATE %s SET hits = hits+1 WHERE lid = %u AND status > 0', $xoopsDB->prefix('tdmdownloads_downloads'), $lid); $xoopsDB->queryF($sql); -$url = $viewDownloads->getVar('url', 'n'); -$contentLength = $utility::StringSizeConvert($viewDownloads->getVar('size')); +$url = $viewDownloads->getVar('url', 'n'); +$contentLength = $utility::convertStringToSize($viewDownloads->getVar('size')); if (!preg_match("/^ed2k*:\/\//i", $url)) { - header("Content-Length: $contentLength"); + header("Content-Length: $contentLength"); header("Location: $url"); } echo ''; diff --git a/xoops_version.php b/xoops_version.php index 0fc8d59..d822dbe 100644 --- a/xoops_version.php +++ b/xoops_version.php @@ -1,4 +1,5 @@ _MI_TDMDOWNLOADS_NAME, - 'version' => '2.0', - 'module_status' => 'RC 1', - 'release_date' => '2019/01/31', - 'description' => _MI_TDMDOWNLOADS_DESC, - 'credits' => 'Mage, Mamba, Goffy', - 'author' => 'Mage', - 'nickname' => 'Mage', - 'module_website_url' => 'www.xoops.org', + 'name' => _MI_TDMDOWNLOADS_NAME, + 'version' => '2.0', + 'module_status' => 'RC 1', + 'release_date' => '2019/01/31', + 'description' => _MI_TDMDOWNLOADS_DESC, + 'credits' => 'Mage, Mamba, Goffy', + 'author' => 'Mage', + 'nickname' => 'Mage', + 'module_website_url' => 'www.xoops.org', 'module_website_name' => 'Support site', - 'help' => 'page=help', - 'license' => 'GNU GPL 2.0 or later', - 'license_url' => 'www.gnu.org/licenses/gpl-2.0.html', - 'official' => 0, + 'help' => 'page=help', + 'license' => 'GNU GPL 2.0 or later', + 'license_url' => 'www.gnu.org/licenses/gpl-2.0.html', + 'official' => 0, // ------------------- Folders & Files ------------------- - 'dirname' => $moduleDirName, - 'image' => 'assets/images/logoModule.png', - 'modicons16' => 'assets/images/icons/16', - 'modicons32' => 'assets/images/icons/32', - 'release_file' => XOOPS_URL . '/modules/' . $moduleDirName . '/docs/changelog.txt', - 'onInstall' => 'include/oninstall.php', - 'onUpdate' => 'include/onupdate.php', + 'dirname' => $moduleDirName, + 'image' => 'assets/images/logoModule.png', + 'modicons16' => 'assets/images/icons/16', + 'modicons32' => 'assets/images/icons/32', + 'release_file' => XOOPS_URL . '/modules/' . $moduleDirName . '/docs/changelog.txt', + 'onInstall' => 'include/oninstall.php', + 'onUpdate' => 'include/onupdate.php', // ------------------- Min Requirements ------------------- - 'min_php' => '7.0', - 'min_xoops' => '2.5.9', - 'min_admin' => '1.1', - 'min_db' => ['mysql' => '5.0.7', 'mysqli' => '5.0.7'], + 'min_php' => '7.1', + 'min_xoops' => '2.5.10', + 'min_admin' => '1.2', + 'min_db' => ['mysql' => '5.5'], // ------------------- Admin Menu ------------------- - 'hasAdmin' => 1, - 'system_menu' => 1, - 'adminindex' => 'admin/index.php', - 'adminmenu' => 'admin/menu.php', + 'hasAdmin' => 1, + 'system_menu' => 1, + 'adminindex' => 'admin/index.php', + 'adminmenu' => 'admin/menu.php', // ------------------- Mysql ------------------- - 'sqlfile' => ['mysql' => 'sql/mysql.sql'], + 'sqlfile' => ['mysql' => 'sql/mysql.sql'], // ------------------- Tables ------------------- - 'tables' => [ + 'tables' => [ $moduleDirName . '_broken', $moduleDirName . '_cat', $moduleDirName . '_downloads', @@ -73,21 +74,21 @@ ], // ------------------- Menu ------------------- - 'hasMain' => 1, - 'sub' => [ + 'hasMain' => 1, + 'sub' => [ [ 'name' => _MI_TDMDOWNLOADS_SMNAME1, - 'url' => 'submit.php', + 'url' => 'submit.php', ], [ 'name' => _MI_TDMDOWNLOADS_SMNAME2, - 'url' => 'search.php', + 'url' => 'search.php', ], ], // ------------------- Search ------------------- 'hasSearch' => 1, - 'search' => [ + 'search' => [ 'file' => 'include/search.inc.php', 'func' => 'tdmdownloads_search', ], @@ -96,63 +97,63 @@ // Pour les blocs $modversion['blocks'][] = [ - 'file' => 'tdmdownloads_top.php', - 'name' => _MI_TDMDOWNLOADS_BNAME1, + 'file' => 'tdmdownloads_top.php', + 'name' => _MI_TDMDOWNLOADS_BNAME1, 'description' => _MI_TDMDOWNLOADS_BNAMEDSC1, - 'show_func' => 'b_tdmdownloads_top_show', - 'edit_func' => 'b_tdmdownloads_top_edit', - 'options' => 'date|10|19|1|1|1|left|90|400|0', - 'template' => $moduleDirName . '_block_new.tpl', + 'show_func' => 'b_tdmdownloads_top_show', + 'edit_func' => 'b_tdmdownloads_top_edit', + 'options' => 'date|10|19|1|1|1|left|90|400|0', + 'template' => $moduleDirName . '_block_new.tpl', ]; $modversion['blocks'][] = [ - 'file' => 'tdmdownloads_top.php', - 'name' => _MI_TDMDOWNLOADS_BNAME2, + 'file' => 'tdmdownloads_top.php', + 'name' => _MI_TDMDOWNLOADS_BNAME2, 'description' => _MI_TDMDOWNLOADS_BNAMEDSC2, - 'show_func' => 'b_tdmdownloads_top_show', - 'edit_func' => 'b_tdmdownloads_top_edit', - 'options' => 'hits|10|19|1|1|1|left|90|400|0', - 'template' => $moduleDirName . '_block_top.tpl', + 'show_func' => 'b_tdmdownloads_top_show', + 'edit_func' => 'b_tdmdownloads_top_edit', + 'options' => 'hits|10|19|1|1|1|left|90|400|0', + 'template' => $moduleDirName . '_block_top.tpl', ]; $modversion['blocks'][] = [ - 'file' => 'tdmdownloads_top.php', - 'name' => _MI_TDMDOWNLOADS_BNAME3, + 'file' => 'tdmdownloads_top.php', + 'name' => _MI_TDMDOWNLOADS_BNAME3, 'description' => _MI_TDMDOWNLOADS_BNAMEDSC3, - 'show_func' => 'b_tdmdownloads_top_show', - 'edit_func' => 'b_tdmdownloads_top_edit', - 'options' => 'rating|10|19|1|1|1|left|90|400|0', - 'template' => $moduleDirName . '_block_rating.tpl', + 'show_func' => 'b_tdmdownloads_top_show', + 'edit_func' => 'b_tdmdownloads_top_edit', + 'options' => 'rating|10|19|1|1|1|left|90|400|0', + 'template' => $moduleDirName . '_block_rating.tpl', ]; $modversion['blocks'][] = [ - 'file' => 'tdmdownloads_top.php', - 'name' => _MI_TDMDOWNLOADS_BNAME4, + 'file' => 'tdmdownloads_top.php', + 'name' => _MI_TDMDOWNLOADS_BNAME4, 'description' => _MI_TDMDOWNLOADS_BNAMEDSC4, - 'show_func' => 'b_tdmdownloads_top_show', - 'edit_func' => 'b_tdmdownloads_top_edit', - 'options' => 'random|10|19|1|1|1|left|90|400|0', - 'template' => $moduleDirName . '_block_random.tpl', + 'show_func' => 'b_tdmdownloads_top_show', + 'edit_func' => 'b_tdmdownloads_top_edit', + 'options' => 'random|10|19|1|1|1|left|90|400|0', + 'template' => $moduleDirName . '_block_random.tpl', ]; $modversion['blocks'][] = [ - 'file' => 'tdmdownloads_search.php', - 'name' => _MI_TDMDOWNLOADS_BNAME5, + 'file' => 'tdmdownloads_search.php', + 'name' => _MI_TDMDOWNLOADS_BNAME5, 'description' => _MI_TDMDOWNLOADS_BNAMEDSC5, - 'show_func' => 'b_tdmdownloads_search_show', - 'edit_func' => '', - 'options' => '', - 'template' => $moduleDirName . '_block_search.tpl', + 'show_func' => 'b_tdmdownloads_search_show', + 'edit_func' => '', + 'options' => '', + 'template' => $moduleDirName . '_block_search.tpl', ]; // Commentaires -$modversion['hasComments'] = 1; -$modversion['comments']['itemName'] = 'lid'; -$modversion['comments']['pageName'] = 'singlefile.php'; -$modversion['comments']['extraParams'] = ['cid']; -$modversion['comments']['callbackFile'] = 'include/comment_functions.php'; +$modversion['hasComments'] = 1; +$modversion['comments']['itemName'] = 'lid'; +$modversion['comments']['pageName'] = 'singlefile.php'; +$modversion['comments']['extraParams'] = ['cid']; +$modversion['comments']['callbackFile'] = 'include/comment_functions.php'; $modversion['comments']['callback']['approve'] = 'tdmdownloads_com_approve'; -$modversion['comments']['callback']['update'] = 'tdmdownloads_com_update'; +$modversion['comments']['callback']['update'] = 'tdmdownloads_com_update'; // Templates $modversion['templates'] = [ @@ -200,154 +201,154 @@ // Préférences $modversion['config'][] = [ - 'name' => 'break', - 'title' => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_GENERAL', + 'name' => 'break', + 'title' => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_GENERAL', 'description' => '', - 'formtype' => 'line_break', - 'valuetype' => 'textbox', - 'default' => 'head', + 'formtype' => 'line_break', + 'valuetype' => 'textbox', + 'default' => 'head', ]; $modversion['config'][] = [ - 'name' => 'popular', - 'title' => '_MI_TDMDOWNLOADS_POPULAR', + 'name' => 'popular', + 'title' => '_MI_TDMDOWNLOADS_POPULAR', 'description' => '', - 'formtype' => 'textbox', - 'valuetype' => 'int', - 'default' => 100, + 'formtype' => 'textbox', + 'valuetype' => 'int', + 'default' => 100, ]; $modversion['config'][] = [ - 'name' => 'autosummary', - 'title' => '_MI_TDMDOWNLOADS_AUTO_SUMMARY', + 'name' => 'autosummary', + 'title' => '_MI_TDMDOWNLOADS_AUTO_SUMMARY', 'description' => '', - 'formtype' => 'yesno', - 'valuetype' => 'int', - 'default' => 0, + 'formtype' => 'yesno', + 'valuetype' => 'int', + 'default' => 0, ]; $modversion['config'][] = [ - 'name' => 'showupdated', - 'title' => '_MI_TDMDOWNLOADS_SHOW_UPDATED', + 'name' => 'showupdated', + 'title' => '_MI_TDMDOWNLOADS_SHOW_UPDATED', 'description' => '', - 'formtype' => 'yesno', - 'valuetype' => 'int', - 'default' => 1, + 'formtype' => 'yesno', + 'valuetype' => 'int', + 'default' => 1, ]; $modversion['config'][] = [ - 'name' => 'useshots', - 'title' => '_MI_TDMDOWNLOADS_USESHOTS', + 'name' => 'useshots', + 'title' => '_MI_TDMDOWNLOADS_USESHOTS', 'description' => '', - 'formtype' => 'yesno', - 'valuetype' => 'int', - 'default' => 1, + 'formtype' => 'yesno', + 'valuetype' => 'int', + 'default' => 1, ]; $modversion['config'][] = [ - 'name' => 'shotwidth', - 'title' => '_MI_TDMDOWNLOADS_SHOTWIDTH', + 'name' => 'shotwidth', + 'title' => '_MI_TDMDOWNLOADS_SHOTWIDTH', 'description' => '', - 'formtype' => 'textbox', - 'valuetype' => 'int', - 'default' => 90, + 'formtype' => 'textbox', + 'valuetype' => 'int', + 'default' => 90, ]; $modversion['config'][] = [ - 'name' => 'img_float', - 'title' => '_MI_TDMDOWNLOADS_IMGFLOAT', + 'name' => 'img_float', + 'title' => '_MI_TDMDOWNLOADS_IMGFLOAT', 'description' => '', - 'formtype' => 'select', - 'valuetype' => 'text', - 'default' => 'left', - 'options' => [_MI_TDMDOWNLOADS_IMGFLOAT_LEFT => 'left', _MI_TDMDOWNLOADS_IMGFLOAT_RIGHT => 'Aaright'], + 'formtype' => 'select', + 'valuetype' => 'text', + 'default' => 'left', + 'options' => [_MI_TDMDOWNLOADS_IMGFLOAT_LEFT => 'left', _MI_TDMDOWNLOADS_IMGFLOAT_RIGHT => 'Aaright'], ]; $modversion['config'][] = [ - 'name' => 'platform', - 'title' => '_MI_TDMDOWNLOADS_PLATEFORM', + 'name' => 'platform', + 'title' => '_MI_TDMDOWNLOADS_PLATEFORM', 'description' => '_MI_TDMDOWNLOADS_PLATEFORM_DSC', - 'formtype' => 'textarea', - 'valuetype' => 'text', - 'default' => 'None|XOOPS 2.0.x|XOOPS 2.2.x|XOOPS 2.3.x|XOOPS 2.4.x|XOOPS 2.5.x|XOOPS 2.6.x|Other', + 'formtype' => 'textarea', + 'valuetype' => 'text', + 'default' => 'None|XOOPS 2.0.x|XOOPS 2.2.x|XOOPS 2.3.x|XOOPS 2.4.x|XOOPS 2.5.x|XOOPS 2.6.x|Other', ]; $modversion['config'][] = [ - 'name' => 'usetellafriend', - 'title' => '_MI_TDMDOWNLOADS_USETELLAFRIEND', + 'name' => 'usetellafriend', + 'title' => '_MI_TDMDOWNLOADS_USETELLAFRIEND', 'description' => '_MI_TDMDOWNLOADS_USETELLAFRIENDDSC', - 'formtype' => 'yesno', - 'valuetype' => 'int', - 'default' => 0, + 'formtype' => 'yesno', + 'valuetype' => 'int', + 'default' => 0, ]; $modversion['config'][] = [ - 'name' => 'usetag', - 'title' => '_MI_TDMDOWNLOADS_USETAG', + 'name' => 'usetag', + 'title' => '_MI_TDMDOWNLOADS_USETAG', 'description' => '_MI_TDMDOWNLOADS_USETAGDSC', - 'formtype' => 'yesno', - 'valuetype' => 'int', - 'default' => 0, + 'formtype' => 'yesno', + 'valuetype' => 'int', + 'default' => 0, ]; //xoops_load('xoopseditorhandler'); //$editorHandler = \XoopsEditorHandler::getInstance(); $modversion['config'][] = [ - 'name' => 'editor', - 'title' => '_MI_TDMDOWNLOADS_FORM_OPTIONS', + 'name' => 'editor', + 'title' => '_MI_TDMDOWNLOADS_FORM_OPTIONS', 'description' => '', - 'formtype' => 'select', - 'valuetype' => 'text', - 'default' => 'dhtmltextarea', - 'options' => array_flip($editorHandler->getList()), + 'formtype' => 'select', + 'valuetype' => 'text', + 'default' => 'dhtmltextarea', + 'options' => array_flip($editorHandler->getList()), ]; $modversion['config'][] = [ - 'name' => 'break', - 'title' => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_USER', + 'name' => 'break', + 'title' => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_USER', 'description' => '', - 'formtype' => 'line_break', - 'valuetype' => 'textbox', - 'default' => 'head', + 'formtype' => 'line_break', + 'valuetype' => 'textbox', + 'default' => 'head', ]; $modversion['config'][] = [ - 'name' => 'perpage', - 'title' => '_MI_TDMDOWNLOADS_PERPAGE', + 'name' => 'perpage', + 'title' => '_MI_TDMDOWNLOADS_PERPAGE', 'description' => '', - 'formtype' => 'textbox', - 'valuetype' => 'int', - 'default' => 10, + 'formtype' => 'textbox', + 'valuetype' => 'int', + 'default' => 10, ]; $modversion['config'][] = [ - 'name' => 'nb_dowcol', - 'title' => '_MI_TDMDOWNLOADS_NBDOWCOL', + 'name' => 'nb_dowcol', + 'title' => '_MI_TDMDOWNLOADS_NBDOWCOL', 'description' => '', - 'formtype' => 'select', - 'valuetype' => 'int', - 'default' => 1, - 'options' => ['1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5], + 'formtype' => 'select', + 'valuetype' => 'int', + 'default' => 1, + 'options' => ['1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5], ]; $modversion['config'][] = [ - 'name' => 'newdownloads', - 'title' => '_MI_TDMDOWNLOADS_NEWDLS', + 'name' => 'newdownloads', + 'title' => '_MI_TDMDOWNLOADS_NEWDLS', 'description' => '', - 'formtype' => 'textbox', - 'valuetype' => 'int', - 'default' => 10, + 'formtype' => 'textbox', + 'valuetype' => 'int', + 'default' => 10, ]; $modversion['config'][] = [ - 'name' => 'toporder', - 'title' => '_MI_TDMDOWNLOADS_TOPORDER', + 'name' => 'toporder', + 'title' => '_MI_TDMDOWNLOADS_TOPORDER', 'description' => '', - 'formtype' => 'select', - 'valuetype' => 'int', - 'default' => 1, - 'options' => [ + 'formtype' => 'select', + 'valuetype' => 'int', + 'default' => 1, + 'options' => [ '_MI_TDMDOWNLOADS_TOPORDER1' => 1, '_MI_TDMDOWNLOADS_TOPORDER2' => 2, '_MI_TDMDOWNLOADS_TOPORDER3' => 3, @@ -360,22 +361,22 @@ ]; $modversion['config'][] = [ - 'name' => 'perpageliste', - 'title' => '_MI_TDMDOWNLOADS_PERPAGELISTE', + 'name' => 'perpageliste', + 'title' => '_MI_TDMDOWNLOADS_PERPAGELISTE', 'description' => '', - 'formtype' => 'textbox', - 'valuetype' => 'int', - 'default' => 15, + 'formtype' => 'textbox', + 'valuetype' => 'int', + 'default' => 15, ]; $modversion['config'][] = [ - 'name' => 'searchorder', - 'title' => '_MI_TDMDOWNLOADS_SEARCHORDER', + 'name' => 'searchorder', + 'title' => '_MI_TDMDOWNLOADS_SEARCHORDER', 'description' => '', - 'formtype' => 'select', - 'valuetype' => 'int', - 'default' => 8, - 'options' => [ + 'formtype' => 'select', + 'valuetype' => 'int', + 'default' => 8, + 'options' => [ '_MI_TDMDOWNLOADS_TOPORDER1' => 1, '_MI_TDMDOWNLOADS_TOPORDER2' => 2, '_MI_TDMDOWNLOADS_TOPORDER3' => 3, @@ -388,300 +389,308 @@ ]; $modversion['config'][] = [ - 'name' => 'nbsouscat', - 'title' => '_MI_TDMDOWNLOADS_SUBCATPARENT', + 'name' => 'nbsouscat', + 'title' => '_MI_TDMDOWNLOADS_SUBCATPARENT', 'description' => '', - 'formtype' => 'textbox', - 'valuetype' => 'int', - 'default' => 5, + 'formtype' => 'textbox', + 'valuetype' => 'int', + 'default' => 5, ]; $modversion['config'][] = [ - 'name' => 'nb_catcol', - 'title' => '_MI_TDMDOWNLOADS_NBCATCOL', + 'name' => 'nb_catcol', + 'title' => '_MI_TDMDOWNLOADS_NBCATCOL', 'description' => '', - 'formtype' => 'select', - 'valuetype' => 'int', - 'default' => 3, - 'options' => ['1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5], + 'formtype' => 'select', + 'valuetype' => 'int', + 'default' => 3, + 'options' => ['1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5], ]; $modversion['config'][] = [ - 'name' => 'bldate', - 'title' => '_MI_TDMDOWNLOADS_BLDATE', + 'name' => 'bldate', + 'title' => '_MI_TDMDOWNLOADS_BLDATE', 'description' => '', - 'formtype' => 'yesno', - 'valuetype' => 'int', - 'default' => 1, + 'formtype' => 'yesno', + 'valuetype' => 'int', + 'default' => 1, ]; $modversion['config'][] = [ - 'name' => 'blpop', - 'title' => '_MI_TDMDOWNLOADS_BLPOP', + 'name' => 'blpop', + 'title' => '_MI_TDMDOWNLOADS_BLPOP', 'description' => '', - 'formtype' => 'yesno', - 'valuetype' => 'int', - 'default' => 1, + 'formtype' => 'yesno', + 'valuetype' => 'int', + 'default' => 1, ]; $modversion['config'][] = [ - 'name' => 'blrating', - 'title' => '_MI_TDMDOWNLOADS_BLRATING', + 'name' => 'blrating', + 'title' => '_MI_TDMDOWNLOADS_BLRATING', 'description' => '', - 'formtype' => 'yesno', - 'valuetype' => 'int', - 'default' => 1, + 'formtype' => 'yesno', + 'valuetype' => 'int', + 'default' => 1, ]; $modversion['config'][] = [ - 'name' => 'nbbl', - 'title' => '_MI_TDMDOWNLOADS_NBBL', + 'name' => 'nbbl', + 'title' => '_MI_TDMDOWNLOADS_NBBL', 'description' => '', - 'formtype' => 'textbox', - 'valuetype' => 'int', - 'default' => 5, + 'formtype' => 'textbox', + 'valuetype' => 'int', + 'default' => 5, ]; $modversion['config'][] = [ - 'name' => 'longbl', - 'title' => '_MI_TDMDOWNLOADS_LONGBL', + 'name' => 'longbl', + 'title' => '_MI_TDMDOWNLOADS_LONGBL', 'description' => '', - 'formtype' => 'textbox', - 'valuetype' => 'int', - 'default' => 20, + 'formtype' => 'textbox', + 'valuetype' => 'int', + 'default' => 20, ]; $modversion['config'][] = [ - 'name' => 'show_bookmark', - 'title' => '_MI_TDMDOWNLOADS_BOOKMARK', + 'name' => 'show_bookmark', + 'title' => '_MI_TDMDOWNLOADS_BOOKMARK', 'description' => '_MI_TDMDOWNLOADS_BOOKMARK_DSC', - 'formtype' => 'yesno', - 'valuetype' => 'int', - 'default' => 1, + 'formtype' => 'yesno', + 'valuetype' => 'int', + 'default' => 1, ]; $modversion['config'][] = [ - 'name' => 'show_social', - 'title' => '_MI_TDMDOWNLOADS_SOCIAL', + 'name' => 'show_social', + 'title' => '_MI_TDMDOWNLOADS_SOCIAL', 'description' => '_MI_TDMDOWNLOADS_SOCIAL_DSC', - 'formtype' => 'yesno', - 'valuetype' => 'int', - 'default' => 1, + 'formtype' => 'yesno', + 'valuetype' => 'int', + 'default' => 1, ]; $modversion['config'][] = [ - 'name' => 'download_float', - 'title' => '_MI_TDMDOWNLOADS_DOWNLOADFLOAT', + 'name' => 'download_float', + 'title' => '_MI_TDMDOWNLOADS_DOWNLOADFLOAT', 'description' => '_MI_TDMDOWNLOADS_DOWNLOADFLOAT_DSC', - 'formtype' => 'select', - 'valuetype' => 'text', - 'default' => 'ltr', - 'options' => [_MI_TDMDOWNLOADS_DOWNLOADFLOAT_LTR => 'ltr', _MI_TDMDOWNLOADS_DOWNLOADFLOAT_RTL => 'rtl'], + 'formtype' => 'select', + 'valuetype' => 'text', + 'default' => 'ltr', + 'options' => [_MI_TDMDOWNLOADS_DOWNLOADFLOAT_LTR => 'ltr', _MI_TDMDOWNLOADS_DOWNLOADFLOAT_RTL => 'rtl'], ]; $modversion['config'][] = [ - 'name' => 'show_latest_files', - 'title' => '_MI_TDMDOWNLOADS_SHOW_LATEST_FILES', + 'name' => 'show_latest_files', + 'title' => '_MI_TDMDOWNLOADS_SHOW_LATEST_FILES', 'description' => '_MI_TDMDOWNLOADS_SHOW_LATEST_FILES_DSC', - 'formtype' => 'yesno', - 'valuetype' => 'int', - 'default' => 1, + 'formtype' => 'yesno', + 'valuetype' => 'int', + 'default' => 1, ]; $modversion['config'][] = [ - 'name' => 'break', - 'title' => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_ADMIN', + 'name' => 'break', + 'title' => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_ADMIN', 'description' => '', - 'formtype' => 'line_break', - 'valuetype' => 'textbox', - 'default' => 'head', + 'formtype' => 'line_break', + 'valuetype' => 'textbox', + 'default' => 'head', ]; $modversion['config'][] = [ - 'name' => 'perpageadmin', - 'title' => '_MI_TDMDOWNLOADS_PERPAGEADMIN', + 'name' => 'perpageadmin', + 'title' => '_MI_TDMDOWNLOADS_PERPAGEADMIN', 'description' => '', - 'formtype' => 'textbox', - 'valuetype' => 'int', - 'default' => 15, + 'formtype' => 'textbox', + 'valuetype' => 'int', + 'default' => 15, ]; $modversion['config'][] = [ - 'name' => 'break', - 'title' => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_DOWNLOADS', + 'name' => 'break', + 'title' => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_DOWNLOADS', 'description' => '', - 'formtype' => 'line_break', - 'valuetype' => 'textbox', - 'default' => 'head', + 'formtype' => 'line_break', + 'valuetype' => 'textbox', + 'default' => 'head', ]; $modversion['config'][] = [ - 'name' => 'permission_download', - 'title' => '_MI_TDMDOWNLOADS_PERMISSIONDOWNLOAD', + 'name' => 'permission_download', + 'title' => '_MI_TDMDOWNLOADS_PERMISSIONDOWNLOAD', 'description' => '', - 'formtype' => 'select', - 'valuetype' => 'int', - 'default' => 1, - 'options' => ['_MI_TDMDOWNLOADS_PERMISSIONDOWNLOAD1' => 1, '_MI_TDMDOWNLOADS_PERMISSIONDOWNLOAD2' => 2], + 'formtype' => 'select', + 'valuetype' => 'int', + 'default' => 1, + 'options' => ['_MI_TDMDOWNLOADS_PERMISSIONDOWNLOAD1' => 1, '_MI_TDMDOWNLOADS_PERMISSIONDOWNLOAD2' => 2], ]; $modversion['config'][] = [ - 'name' => 'newnamedownload', - 'title' => '_MI_TDMDOWNLOADS_DOWNLOAD_NAME', + 'name' => 'newnamedownload', + 'title' => '_MI_TDMDOWNLOADS_DOWNLOAD_NAME', 'description' => '_MI_TDMDOWNLOADS_DOWNLOAD_NAMEDSC', - 'formtype' => 'yesno', - 'valuetype' => 'int', - 'default' => 1, + 'formtype' => 'yesno', + 'valuetype' => 'int', + 'default' => 1, ]; $modversion['config'][] = [ - 'name' => 'prefixdownloads', - 'title' => '_MI_TDMDOWNLOADS_DOWNLOAD_PREFIX', + 'name' => 'prefixdownloads', + 'title' => '_MI_TDMDOWNLOADS_DOWNLOAD_PREFIX', 'description' => '_MI_TDMDOWNLOADS_DOWNLOAD_PREFIXDSC', - 'formtype' => 'textbox', - 'valuetype' => 'text', - 'default' => 'downloads_', + 'formtype' => 'textbox', + 'valuetype' => 'text', + 'default' => 'downloads_', ]; -include_once XOOPS_ROOT_PATH . '/modules/tdmdownloads/include/xoops_version.inc.php'; -$iniPostMaxSize = tdmdownloadsReturnBytes(ini_get('post_max_size')); -$iniUploadMaxFileSize = tdmdownloadsReturnBytes(ini_get('upload_max_filesize')); -$maxSize = min($iniPostMaxSize, $iniUploadMaxFileSize); +$iniPostMaxSize = \XoopsModules\Tdmdownloads\Utility::returnBytes(ini_get('post_max_size')); +$iniUploadMaxFileSize = \XoopsModules\Tdmdownloads\Utility::returnBytes(ini_get('upload_max_filesize')); +$maxSize = min($iniPostMaxSize, $iniUploadMaxFileSize); if ($maxSize > 10000 * 1048576) { $increment = 500; } -if ($maxSize <= 10000 * 1048576){ +if ($maxSize <= 10000 * 1048576) { $increment = 200; } -if ($maxSize <= 5000 * 1048576){ +if ($maxSize <= 5000 * 1048576) { $increment = 100; } -if ($maxSize <= 2500 * 1048576){ +if ($maxSize <= 2500 * 1048576) { $increment = 50; } -if ($maxSize <= 1000 * 1048576){ +if ($maxSize <= 1000 * 1048576) { $increment = 20; } -if ($maxSize <= 500 * 1048576){ +if ($maxSize <= 500 * 1048576) { $increment = 10; } -if ($maxSize <= 100 * 1048576){ +if ($maxSize <= 100 * 1048576) { $increment = 2; } -if ($maxSize <= 50 * 1048576){ +if ($maxSize <= 50 * 1048576) { $increment = 1; } -if ($maxSize <= 25 * 1048576){ +if ($maxSize <= 25 * 1048576) { $increment = 0.5; } $optionMaxsize = []; -$i = $increment; -while ($i* 1048576 <= $maxSize) { +$i = $increment; +while ($i * 1048576 <= $maxSize) { $optionMaxsize[$i . ' ' . _MI_TDMDOWNLOADS_MAXUPLOAD_SIZE_MB] = $i * 1048576; - $i += $increment; + $i += $increment; } $modversion['config'][] = [ - 'name' => 'maxuploadsize', - 'title' => '_MI_TDMDOWNLOADS_MAXUPLOAD_SIZE', + 'name' => 'maxuploadsize', + 'title' => '_MI_TDMDOWNLOADS_MAXUPLOAD_SIZE', 'description' => '_MI_TDMDOWNLOADS_MAXUPLOAD_SIZE_DESC', - 'formtype' => 'select', - 'valuetype' => 'int', - 'default' => 1048576, - 'options' => $optionMaxsize, + 'formtype' => 'select', + 'valuetype' => 'int', + 'default' => 1048576, + 'options' => $optionMaxsize, ]; $modversion['config'][] = [ - 'name' => 'mimetypes', - 'title' => '_MI_TDMDOWNLOADS_MIMETYPE', + 'name' => 'mimetypes', + 'title' => '_MI_TDMDOWNLOADS_MIMETYPE', 'description' => '_MI_TDMDOWNLOADS_MIMETYPE_DSC', - 'formtype' => 'select_multi', - 'valuetype' => 'array', - 'default' => [ - 'image/gif', 'image/jpeg', 'image/png', - 'application/zip', 'application/rar', 'application/pdf', 'application/x-gtar', 'application/x-tar', - 'application/msword', 'application/vnd.ms-excel', 'application/vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.spreadsheet', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'formtype' => 'select_multi', + 'valuetype' => 'array', + 'default' => [ + 'image/gif', + 'image/jpeg', + 'image/png', + 'application/zip', + 'application/rar', + 'application/pdf', + 'application/x-gtar', + 'application/x-tar', + 'application/msword', + 'application/vnd.ms-excel', + 'application/vnd.oasis.opendocument.text', + 'application/vnd.oasis.opendocument.spreadsheet', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', ], - 'options' => include $GLOBALS['xoops']->path('include/mimetypes.inc.php'), + 'options' => require $GLOBALS['xoops']->path('include/mimetypes.inc.php'), ]; //---------------- picture ------------------------- -include_once __DIR__ . '/config/imageconfig.php'; +require_once __DIR__ . '/config/imageconfig.php'; //---------------- picture ------------------------- - $modversion['config'][] = [ - 'name' => 'check_host', - 'title' => '_MI_TDMDOWNLOADS_CHECKHOST', + 'name' => 'check_host', + 'title' => '_MI_TDMDOWNLOADS_CHECKHOST', 'description' => '', - 'formtype' => 'yesno', - 'valuetype' => 'int', - 'default' => 0, + 'formtype' => 'yesno', + 'valuetype' => 'int', + 'default' => 0, ]; -$xoopsUrl = parse_url(XOOPS_URL); +$xoopsUrl = parse_url(XOOPS_URL); $modversion['config'][] = [ - 'name' => 'referers', - 'title' => '_MI_TDMDOWNLOADS_REFERERS', + 'name' => 'referers', + 'title' => '_MI_TDMDOWNLOADS_REFERERS', 'description' => '', - 'formtype' => 'textarea', - 'valuetype' => 'array', - 'default' => [$xoopsUrl['host']], + 'formtype' => 'textarea', + 'valuetype' => 'array', + 'default' => [$xoopsUrl['host']], ]; $modversion['config'][] = [ - 'name' => 'downlimit', - 'title' => '_MI_TDMDOWNLOADS_DOWNLIMIT', + 'name' => 'downlimit', + 'title' => '_MI_TDMDOWNLOADS_DOWNLIMIT', 'description' => '_MI_TDMDOWNLOADS_DOWNLIMITDSC', - 'formtype' => 'yesno', - 'valuetype' => 'int', - 'default' => 0, + 'formtype' => 'yesno', + 'valuetype' => 'int', + 'default' => 0, ]; $modversion['config'][] = [ - 'name' => 'limitglobal', - 'title' => '_MI_TDMDOWNLOADS_LIMITGLOBAL', + 'name' => 'limitglobal', + 'title' => '_MI_TDMDOWNLOADS_LIMITGLOBAL', 'description' => '_MI_TDMDOWNLOADS_LIMITGLOBALDSC', - 'formtype' => 'textbox', - 'valuetype' => 'int', - 'default' => 10, + 'formtype' => 'textbox', + 'valuetype' => 'int', + 'default' => 10, ]; $modversion['config'][] = [ - 'name' => 'limitlid', - 'title' => '_MI_TDMDOWNLOADS_LIMITLID', + 'name' => 'limitlid', + 'title' => '_MI_TDMDOWNLOADS_LIMITLID', 'description' => '_MI_TDMDOWNLOADS_LIMITLIDDSC', - 'formtype' => 'textbox', - 'valuetype' => 'int', - 'default' => 2, + 'formtype' => 'textbox', + 'valuetype' => 'int', + 'default' => 2, ]; $modversion['config'][] = [ - 'name' => 'break', - 'title' => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_PAYPAL', + 'name' => 'break', + 'title' => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_PAYPAL', 'description' => '', - 'formtype' => 'line_break', - 'valuetype' => 'textbox', - 'default' => 'head', + 'formtype' => 'line_break', + 'valuetype' => 'textbox', + 'default' => 'head', ]; $modversion['config'][] = [ - 'name' => 'use_paypal', - 'title' => '_MI_TDMDOWNLOADS_USEPAYPAL', + 'name' => 'use_paypal', + 'title' => '_MI_TDMDOWNLOADS_USEPAYPAL', 'description' => '', - 'formtype' => 'yesno', - 'valuetype' => 'int', - 'default' => 0, + 'formtype' => 'yesno', + 'valuetype' => 'int', + 'default' => 0, ]; $modversion['config'][] = [ - 'name' => 'currency_paypal', - 'title' => '_MI_TDMDOWNLOADS_CURRENCYPAYPAL', + 'name' => 'currency_paypal', + 'title' => '_MI_TDMDOWNLOADS_CURRENCYPAYPAL', 'description' => '', - 'formtype' => 'select', - 'valuetype' => 'text', - 'default' => 'EUR', - 'options' => [ + 'formtype' => 'select', + 'valuetype' => 'text', + 'default' => 'EUR', + 'options' => [ 'AUD' => 'AUD', 'BRL' => 'BRL', 'CAD' => 'CAD', @@ -708,223 +717,202 @@ ]; $modversion['config'][] = [ - 'name' => 'image_paypal', - 'title' => '_MI_TDMDOWNLOADS_IMAGEPAYPAL', + 'name' => 'image_paypal', + 'title' => '_MI_TDMDOWNLOADS_IMAGEPAYPAL', 'description' => '_MI_TDMDOWNLOADS_IMAGEPAYPALDSC', - 'formtype' => 'textbox', - 'valuetype' => 'text', - 'default' => 'https://www.paypal.com/fr_FR/FR/i/btn/btn_donateCC_LG.gif', + 'formtype' => 'textbox', + 'valuetype' => 'text', + 'default' => 'https://www.paypal.com/fr_FR/FR/i/btn/btn_donateCC_LG.gif', ]; $modversion['config'][] = [ - 'name' => 'break', - 'title' => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_RSS', + 'name' => 'break', + 'title' => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_RSS', 'description' => '', - 'formtype' => 'line_break', - 'valuetype' => 'textbox', - 'default' => 'head', + 'formtype' => 'line_break', + 'valuetype' => 'textbox', + 'default' => 'head', ]; $modversion['config'][] = [ - 'name' => 'perpagerss', - 'title' => '_MI_TDMDOWNLOADS_PERPAGERSS', + 'name' => 'perpagerss', + 'title' => '_MI_TDMDOWNLOADS_PERPAGERSS', 'description' => '_MI_TDMDOWNLOADS_PERPAGERSSDSC', - 'formtype' => 'textbox', - 'valuetype' => 'int', - 'default' => 10, + 'formtype' => 'textbox', + 'valuetype' => 'int', + 'default' => 10, ]; $modversion['config'][] = [ - 'name' => 'timecacherss', - 'title' => '_MI_TDMDOWNLOADS_TIMECACHERSS', + 'name' => 'timecacherss', + 'title' => '_MI_TDMDOWNLOADS_TIMECACHERSS', 'description' => '_MI_TDMDOWNLOADS_TIMECACHERSSDSC', - 'formtype' => 'textbox', - 'valuetype' => 'int', - 'default' => 60, + 'formtype' => 'textbox', + 'valuetype' => 'int', + 'default' => 60, ]; $modversion['config'][] = [ - 'name' => 'logorss', - 'title' => '_MI_TDMDOWNLOADS_LOGORSS', + 'name' => 'logorss', + 'title' => '_MI_TDMDOWNLOADS_LOGORSS', 'description' => '', - 'formtype' => 'textbox', - 'valuetype' => 'text', - 'default' => '/modules/tdmdownloads/assets/images/mydl_slogo.png', + 'formtype' => 'textbox', + 'valuetype' => 'text', + 'default' => '/modules/tdmdownloads/assets/images/mydl_slogo.png', ]; $modversion['config'][] = [ - 'name' => 'break', - 'title' => '_MI_TDMDOWNLOADS_CONFCAT_OTHERS', + 'name' => 'break', + 'title' => '_MI_TDMDOWNLOADS_CONFCAT_OTHERS', 'description' => '', - 'formtype' => 'line_break', - 'valuetype' => 'textbox', - 'default' => 'head', + 'formtype' => 'line_break', + 'valuetype' => 'textbox', + 'default' => 'head', ]; /** * Make Sample button visible? */ $modversion['config'][] = [ - 'name' => 'displaySampleButton', - 'title' => '_MI_TDMDOWNLOADS_SHOW_SAMPLE_BUTTON', + 'name' => 'displaySampleButton', + 'title' => '_MI_TDMDOWNLOADS_SHOW_SAMPLE_BUTTON', 'description' => '_MI_TDMDOWNLOADS_SHOW_SAMPLE_BUTTON_DESC', - 'formtype' => 'yesno', - 'valuetype' => 'int', - 'default' => 1, + 'formtype' => 'yesno', + 'valuetype' => 'int', + 'default' => 1, ]; /** * Show Developer Tools? */ $modversion['config'][] = [ - 'name' => 'displayDeveloperTools', - 'title' => '_MI_TDMDOWNLOADS_SHOW_DEV_TOOLS', + 'name' => 'displayDeveloperTools', + 'title' => '_MI_TDMDOWNLOADS_SHOW_DEV_TOOLS', 'description' => '_MI_TDMDOWNLOADS_SHOW_DEV_TOOLS_DESC', - 'formtype' => 'yesno', - 'valuetype' => 'int', - 'default' => 0, + 'formtype' => 'yesno', + 'valuetype' => 'int', + 'default' => 0, ]; // ------------------- Notifications ------------------- -$modversion['config'][] = [ - 'name' => 'break', - 'title' => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_COMNOTI', +$modversion['config'][] = [ + 'name' => 'break', + 'title' => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_COMNOTI', 'description' => '', - 'formtype' => 'line_break', - 'valuetype' => 'textbox', - 'default' => 'head', + 'formtype' => 'line_break', + 'valuetype' => 'textbox', + 'default' => 'head', ]; -$modversion['hasNotification'] = 1; +$modversion['hasNotification'] = 1; $modversion['notification']['lookup_file'] = 'include/notification.inc.php'; $modversion['notification']['lookup_func'] = 'tdmdownloads_notify_iteminfo'; $modversion['notification']['category'][] = [ - 'name' => 'global', - 'title' => _MI_TDMDOWNLOADS_GLOBAL_NOTIFY, - 'description' => _MI_TDMDOWNLOADS_GLOBAL_NOTIFYDSC, + 'name' => 'global', + 'title' => _MI_TDMDOWNLOADS_GLOBAL_NOTIFY, + 'description' => _MI_TDMDOWNLOADS_GLOBAL_NOTIFYDSC, 'subscribe_from' => ['index.php', 'viewcat.php', 'singlefile.php'], ]; $modversion['notification']['category'][] = [ - 'name' => 'category', - 'title' => _MI_TDMDOWNLOADS_CATEGORY_NOTIFY, - 'description' => _MI_TDMDOWNLOADS_CATEGORY_NOTIFYDSC, + 'name' => 'category', + 'title' => _MI_TDMDOWNLOADS_CATEGORY_NOTIFY, + 'description' => _MI_TDMDOWNLOADS_CATEGORY_NOTIFYDSC, 'subscribe_from' => ['viewcat.php', 'singlefile.php'], - 'item_name' => 'cid', + 'item_name' => 'cid', 'allow_bookmark' => 1, ]; $modversion['notification']['category'][] = [ - 'name' => 'file', - 'title' => _MI_TDMDOWNLOADS_FILE_NOTIFY, - 'description' => _MI_TDMDOWNLOADS_FILE_NOTIFYDSC, + 'name' => 'file', + 'title' => _MI_TDMDOWNLOADS_FILE_NOTIFY, + 'description' => _MI_TDMDOWNLOADS_FILE_NOTIFYDSC, 'subscribe_from' => 'singlefile.php', - 'item_name' => 'lid', + 'item_name' => 'lid', 'allow_bookmark' => 1, ]; $modversion['notification']['event'][] = [ - 'name' => 'new_category', - 'category' => 'global', - 'title' => _MI_TDMDOWNLOADS_GLOBAL_NEWCATEGORY_NOTIFY, - 'caption' => _MI_TDMDOWNLOADS_GLOBAL_NEWCATEGORY_NOTIFYCAP, - 'description' => _MI_TDMDOWNLOADS_GLOBAL_NEWCATEGORY_NOTIFYDSC, + 'name' => 'new_category', + 'category' => 'global', + 'title' => _MI_TDMDOWNLOADS_GLOBAL_NEWCATEGORY_NOTIFY, + 'caption' => _MI_TDMDOWNLOADS_GLOBAL_NEWCATEGORY_NOTIFYCAP, + 'description' => _MI_TDMDOWNLOADS_GLOBAL_NEWCATEGORY_NOTIFYDSC, 'mail_template' => 'global_newcategory_notify', - 'mail_subject' => _MI_TDMDOWNLOADS_GLOBAL_NEWCATEGORY_NOTIFYSBJ, + 'mail_subject' => _MI_TDMDOWNLOADS_GLOBAL_NEWCATEGORY_NOTIFYSBJ, ]; $modversion['notification']['event'][] = [ - 'name' => 'file_modify', - 'category' => 'global', - 'admin_only' => 1, - 'title' => _MI_TDMDOWNLOADS_GLOBAL_FILEMODIFY_NOTIFY, - 'caption' => _MI_TDMDOWNLOADS_GLOBAL_FILEMODIFY_NOTIFYCAP, - 'description' => _MI_TDMDOWNLOADS_GLOBAL_FILEMODIFY_NOTIFYDSC, + 'name' => 'file_modify', + 'category' => 'global', + 'admin_only' => 1, + 'title' => _MI_TDMDOWNLOADS_GLOBAL_FILEMODIFY_NOTIFY, + 'caption' => _MI_TDMDOWNLOADS_GLOBAL_FILEMODIFY_NOTIFYCAP, + 'description' => _MI_TDMDOWNLOADS_GLOBAL_FILEMODIFY_NOTIFYDSC, 'mail_template' => 'global_filemodify_notify', - 'mail_subject' => _MI_TDMDOWNLOADS_GLOBAL_FILEMODIFY_NOTIFYSBJ, + 'mail_subject' => _MI_TDMDOWNLOADS_GLOBAL_FILEMODIFY_NOTIFYSBJ, ]; $modversion['notification']['event'][] = [ - 'name' => 'file_submit', - 'category' => 'global', - 'admin_only' => 1, - 'title' => _MI_TDMDOWNLOADS_GLOBAL_FILESUBMIT_NOTIFY, - 'caption' => _MI_TDMDOWNLOADS_GLOBAL_FILESUBMIT_NOTIFYCAP, - 'description' => _MI_TDMDOWNLOADS_GLOBAL_FILESUBMIT_NOTIFYDSC, + 'name' => 'file_submit', + 'category' => 'global', + 'admin_only' => 1, + 'title' => _MI_TDMDOWNLOADS_GLOBAL_FILESUBMIT_NOTIFY, + 'caption' => _MI_TDMDOWNLOADS_GLOBAL_FILESUBMIT_NOTIFYCAP, + 'description' => _MI_TDMDOWNLOADS_GLOBAL_FILESUBMIT_NOTIFYDSC, 'mail_template' => 'global_filesubmit_notify', - 'mail_subject' => _MI_TDMDOWNLOADS_GLOBAL_FILESUBMIT_NOTIFYSBJ, + 'mail_subject' => _MI_TDMDOWNLOADS_GLOBAL_FILESUBMIT_NOTIFYSBJ, ]; $modversion['notification']['event'][] = [ - 'name' => 'file_broken', - 'category' => 'global', - 'admin_only' => 1, - 'title' => _MI_TDMDOWNLOADS_GLOBAL_FILEBROKEN_NOTIFY, - 'caption' => _MI_TDMDOWNLOADS_GLOBAL_FILEBROKEN_NOTIFYCAP, - 'description' => _MI_TDMDOWNLOADS_GLOBAL_FILEBROKEN_NOTIFYDSC, + 'name' => 'file_broken', + 'category' => 'global', + 'admin_only' => 1, + 'title' => _MI_TDMDOWNLOADS_GLOBAL_FILEBROKEN_NOTIFY, + 'caption' => _MI_TDMDOWNLOADS_GLOBAL_FILEBROKEN_NOTIFYCAP, + 'description' => _MI_TDMDOWNLOADS_GLOBAL_FILEBROKEN_NOTIFYDSC, 'mail_template' => 'global_filebroken_notify', - 'mail_subject' => _MI_TDMDOWNLOADS_GLOBAL_FILEBROKEN_NOTIFYSBJ, + 'mail_subject' => _MI_TDMDOWNLOADS_GLOBAL_FILEBROKEN_NOTIFYSBJ, ]; $modversion['notification']['event'][] = [ - 'name' => 'new_file', - 'category' => 'global', - 'title' => _MI_TDMDOWNLOADS_GLOBAL_NEWFILE_NOTIFY, - 'caption' => _MI_TDMDOWNLOADS_GLOBAL_NEWFILE_NOTIFYCAP, - 'description' => _MI_TDMDOWNLOADS_GLOBAL_NEWFILE_NOTIFYDSC, + 'name' => 'new_file', + 'category' => 'global', + 'title' => _MI_TDMDOWNLOADS_GLOBAL_NEWFILE_NOTIFY, + 'caption' => _MI_TDMDOWNLOADS_GLOBAL_NEWFILE_NOTIFYCAP, + 'description' => _MI_TDMDOWNLOADS_GLOBAL_NEWFILE_NOTIFYDSC, 'mail_template' => 'global_newfile_notify', - 'mail_subject' => _MI_TDMDOWNLOADS_GLOBAL_NEWFILE_NOTIFYSBJ, + 'mail_subject' => _MI_TDMDOWNLOADS_GLOBAL_NEWFILE_NOTIFYSBJ, ]; $modversion['notification']['event'][] = [ - 'name' => 'file_submit', - 'category' => 'category', - 'admin_only' => 1, - 'title' => _MI_TDMDOWNLOADS_CATEGORY_FILESUBMIT_NOTIFY, - 'caption' => _MI_TDMDOWNLOADS_CATEGORY_FILESUBMIT_NOTIFYCAP, - 'description' => _MI_TDMDOWNLOADS_CATEGORY_FILESUBMIT_NOTIFYDSC, + 'name' => 'file_submit', + 'category' => 'category', + 'admin_only' => 1, + 'title' => _MI_TDMDOWNLOADS_CATEGORY_FILESUBMIT_NOTIFY, + 'caption' => _MI_TDMDOWNLOADS_CATEGORY_FILESUBMIT_NOTIFYCAP, + 'description' => _MI_TDMDOWNLOADS_CATEGORY_FILESUBMIT_NOTIFYDSC, 'mail_template' => 'category_filesubmit_notify', - 'mail_subject' => _MI_TDMDOWNLOADS_CATEGORY_FILESUBMIT_NOTIFYSBJ, + 'mail_subject' => _MI_TDMDOWNLOADS_CATEGORY_FILESUBMIT_NOTIFYSBJ, ]; $modversion['notification']['event'][] = [ - 'name' => 'new_file', - 'category' => 'category', - 'title' => _MI_TDMDOWNLOADS_CATEGORY_NEWFILE_NOTIFY, - 'caption' => _MI_TDMDOWNLOADS_CATEGORY_NEWFILE_NOTIFYCAP, - 'description' => _MI_TDMDOWNLOADS_CATEGORY_NEWFILE_NOTIFYDSC, + 'name' => 'new_file', + 'category' => 'category', + 'title' => _MI_TDMDOWNLOADS_CATEGORY_NEWFILE_NOTIFY, + 'caption' => _MI_TDMDOWNLOADS_CATEGORY_NEWFILE_NOTIFYCAP, + 'description' => _MI_TDMDOWNLOADS_CATEGORY_NEWFILE_NOTIFYDSC, 'mail_template' => 'category_newfile_notify', - 'mail_subject' => _MI_TDMDOWNLOADS_CATEGORY_NEWFILE_NOTIFYSBJ, + 'mail_subject' => _MI_TDMDOWNLOADS_CATEGORY_NEWFILE_NOTIFYSBJ, ]; $modversion['notification']['event'][] = [ - 'name' => 'approve', - 'category' => 'file', - 'invisible' => 1, - 'title' => _MI_TDMDOWNLOADS_FILE_APPROVE_NOTIFY, - 'caption' => _MI_TDMDOWNLOADS_FILE_APPROVE_NOTIFYCAP, - 'description' => _MI_TDMDOWNLOADS_FILE_APPROVE_NOTIFYDSC, + 'name' => 'approve', + 'category' => 'file', + 'invisible' => 1, + 'title' => _MI_TDMDOWNLOADS_FILE_APPROVE_NOTIFY, + 'caption' => _MI_TDMDOWNLOADS_FILE_APPROVE_NOTIFYCAP, + 'description' => _MI_TDMDOWNLOADS_FILE_APPROVE_NOTIFYDSC, 'mail_template' => 'file_approve_notify', - 'mail_subject' => _MI_TDMDOWNLOADS_FILE_APPROVE_NOTIFYSBJ, + 'mail_subject' => _MI_TDMDOWNLOADS_FILE_APPROVE_NOTIFYSBJ, ]; - -/** - * @param $val - * @return float|int - */ -//function returnBytes($val) -//{ -// switch (mb_substr($val, -1)) { -// case 'K': -// case 'k': -// return (int)$val * 1024; -// case 'M': -// case 'm': -// return (int)$val * 1048576; -// case 'G': -// case 'g': -// return (int)$val * 1073741824; -// default: -// return $val; -// } -//} From f6692533fb407d443431eb5af0be84ef4d6a45a9 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 21:33:34 -0400 Subject: [PATCH 13/62] extra files --- class/Common/SysUtility.php | 204 ++++++++++++++++++++ class/Utilities.php | 370 ++++++++++++++++++++++++++++++++++++ config/admin.yml | 1 + config/config.php | 89 +++++++++ config/icons.php | 19 ++ config/paths.php | 25 +++ 6 files changed, 708 insertions(+) create mode 100644 class/Common/SysUtility.php create mode 100644 class/Utilities.php create mode 100644 config/admin.yml create mode 100644 config/config.php create mode 100644 config/icons.php create mode 100644 config/paths.php diff --git a/class/Common/SysUtility.php b/class/Common/SysUtility.php new file mode 100644 index 0000000..5dfa41a --- /dev/null +++ b/class/Common/SysUtility.php @@ -0,0 +1,204 @@ + + * @author Mamba + */ + +use MyTextSanitizer; +use XoopsFormDhtmlTextArea; +use XoopsFormTextArea; +use XoopsModules\Tdmdownloads; + +/** + * Class SysUtility + */ +class SysUtility +{ + use VersionChecks; + + //checkVerXoops, checkVerPhp Traits + + use ServerStats; + + // getServerStats Trait + + use FilesManagement; + + // Files Management Trait + + /** + * truncateHtml can truncate a string up to a number of characters while preserving whole words and HTML tags + * www.gsdesign.ro/blog/cut-html-string-without-breaking-the-tags + * www.cakephp.org + * + * @param string $text String to truncate. + * @param int $length Length of returned string, including ellipsis. + * @param string $ending Ending to be appended to the trimmed string. + * @param bool $exact If false, $text will not be cut mid-word + * @param bool $considerHtml If true, HTML tags would be handled correctly + * + * @return string Trimmed string. + */ + public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true) + { + if ($considerHtml) { + // if the plain text is shorter than the maximum length, return the whole text + if (mb_strlen(preg_replace('/<.*?' . '>/', '', $text)) <= $length) { + return $text; + } + // splits all html-tags to scanable lines + preg_match_all('/(<.+?' . '>)?([^<>]*)/s', $text, $lines, PREG_SET_ORDER); + $total_length = mb_strlen($ending); + $open_tags = []; + $truncate = ''; + foreach ($lines as $line_matchings) { + // if there is any html-tag in this line, handle it and add it (uncounted) to the output + if (!empty($line_matchings[1])) { + // if it's an "empty element" with or without xhtml-conform closing slash + if (preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) { + // do nothing + // if tag is a closing tag + } elseif (preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) { + // delete tag from $open_tags list + $pos = array_search($tag_matchings[1], $open_tags, true); + if (false !== $pos) { + unset($open_tags[$pos]); + } + // if tag is an opening tag + } elseif (preg_match('/^<\s*([^\s>!]+).*?' . '>$/s', $line_matchings[1], $tag_matchings)) { + // add tag to the beginning of $open_tags list + array_unshift($open_tags, mb_strtolower($tag_matchings[1])); + } + // add html-tag to $truncate'd text + $truncate .= $line_matchings[1]; + } + // calculate the length of the plain text part of the line; handle entities as one character + $content_length = mb_strlen(preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2])); + if ($total_length + $content_length > $length) { + // the number of characters which are left + $left = $length - $total_length; + $entities_length = 0; + // search for html entities + if (preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, PREG_OFFSET_CAPTURE)) { + // calculate the real length of all entities in the legal range + foreach ($entities[0] as $entity) { + if ($left >= $entity[1] + 1 - $entities_length) { + $left--; + $entities_length += mb_strlen($entity[0]); + } else { + // no more characters left + break; + } + } + } + $truncate .= mb_substr($line_matchings[2], 0, $left + $entities_length); + // maximum lenght is reached, so get off the loop + break; + } + $truncate .= $line_matchings[2]; + $total_length += $content_length; + + // if the maximum length is reached, get off the loop + if ($total_length >= $length) { + break; + } + } + } else { + if (mb_strlen($text) <= $length) { + return $text; + } + $truncate = mb_substr($text, 0, $length - mb_strlen($ending)); + } + // if the words shouldn't be cut in the middle... + if (!$exact) { + // ...search the last occurance of a space... + $spacepos = mb_strrpos($truncate, ' '); + if (isset($spacepos)) { + // ...and cut the text in this position + $truncate = mb_substr($truncate, 0, $spacepos); + } + } + // add the defined ending to the text + $truncate .= $ending; + if ($considerHtml) { + // close all unclosed html-tags + foreach ($open_tags as $tag) { + $truncate .= ''; + } + } + + return $truncate; + } + + /** + * @param \Xmf\Module\Helper $helper + * @param array|null $options + * @return \XoopsFormDhtmlTextArea|\XoopsFormEditor + */ + public static function getEditor($helper = null, $options = null) + { + /** @var Helper $helper */ + if (null === $options) { + $options = []; + $options['name'] = 'Editor'; + $options['value'] = 'Editor'; + $options['rows'] = 10; + $options['cols'] = '100%'; + $options['width'] = '100%'; + $options['height'] = '400px'; + } + + if (null === $helper) { + $helper = Helper::getInstance(); + } + + $isAdmin = $helper->isUserAdmin(); + + if (class_exists('XoopsFormEditor')) { + if ($isAdmin) { + $descEditor = new \XoopsFormEditor(ucfirst($options['name']), $helper->getConfig('editorAdmin'), $options, $nohtml = false, $onfailure = 'textarea'); + } else { + $descEditor = new \XoopsFormEditor(ucfirst($options['name']), $helper->getConfig('editorUser'), $options, $nohtml = false, $onfailure = 'textarea'); + } + } else { + $descEditor = new \XoopsFormDhtmlTextArea(ucfirst($options['name']), $options['name'], $options['value'], '100%', '100%'); + } + + // $form->addElement($descEditor); + + return $descEditor; + } + + /** + * @param $fieldname + * @param $table + * + * @return bool + */ + public function fieldExists($fieldname, $table) + { + global $xoopsDB; + $result = $xoopsDB->queryF("SHOW COLUMNS FROM $table LIKE '$fieldname'"); + + return ($xoopsDB->getRowsNum($result) > 0); + } +} diff --git a/class/Utilities.php b/class/Utilities.php new file mode 100644 index 0000000..8664d0a --- /dev/null +++ b/class/Utilities.php @@ -0,0 +1,370 @@ +db = $db; + // $this->helper = $helper; + // } + + /** + * @param $permtype + * @param $dirname + * @return mixed + */ + public static function getItemIds($permtype, $dirname) + { + global $xoopsUser; + $permissions = []; + if (is_array($permissions) && array_key_exists($permtype, $permissions)) { + return $permissions[$permtype]; + } + $moduleHandler = xoops_getHandler('module'); + $tdmModule = $moduleHandler->getByDirname($dirname); + $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; + $grouppermHandler = xoops_getHandler('groupperm'); + $categories = $grouppermHandler->getItemIds($permtype, $groups, $tdmModule->getVar('mid')); + + return $categories; + } + + /** + * returns the number of updates downloads in the categories of children category + * + * @param $mytree + * @param $categories + * @param $entries + * @param $cid + * + * @return int + */ + public static function getNumbersOfEntries($mytree, $categories, $entries, $cid) + { + $count = 0; + $child_arr = []; + if (in_array($cid, $categories)) { + $child = $mytree->getAllChild($cid); + foreach (array_keys($entries) as $i) { + if ($entries[$i]->getVar('cid') === $cid) { + ++$count; + } + foreach (array_keys($child) as $j) { + if ($entries[$i]->getVar('cid') === $j) { + ++$count; + } + } + } + } + + return $count; + } + + /** + * returns an image "new" or "updated" + * @param $time + * @param $status + * @return string + */ + public static function getStatusImage($time, $status) + { + $moduleDirName = basename(dirname(__DIR__)); + /** @var Tdmdownloads\Helper $helper */ + $helper = Tdmdownloads\Helper::getInstance(); + + $count = 7; + $new = ''; + $startdate = (time() - (86400 * $count)); + if (1 == $helper->getConfig('showupdated')) { + if ($startdate < $time) { + $language = $GLOBALS['xoopsConfig']['language']; + if (!is_dir(XOOPS_ROOT_PATH . "/modules/$moduleDirName/language/" . $language . '/')) { + $language = 'english'; + } + $img_path = XOOPS_ROOT_PATH . "/modules/$moduleDirName/language/" . $language . '/'; + $img_url = XOOPS_URL . "/modules/$moduleDirName/language/" . $language . '/'; + if (1 == $status) { + if (is_readable($img_path . 'new.png')) { + $new = ' ' . _MD_TDMDOWNLOADS_INDEX_NEWTHISWEEK . ''; + } else { + $new = ' ' . _MD_TDMDOWNLOADS_INDEX_NEWTHISWEEK . ''; + } + } elseif (2 == $status) { + if (is_readable($img_path . 'updated.png')) { + $new = ' ' . _MD_TDMDOWNLOADS_INDEX_UPTHISWEEK . ''; + } else { + $new = ' ' . _MD_TDMDOWNLOADS_INDEX_UPTHISWEEK . ''; + } + } + } + } + + return $new; + } + + /** + * retourne une image "populaire" + * @param $hits + * @return string + */ + public static function getPopularImage($hits) + { + /** @var Tdmdownloads\Helper $helper */ + $helper = Tdmdownloads\Helper::getInstance(); + + $moduleDirName = basename(dirname(__DIR__)); + $pop = ''; + if ($hits >= $helper->getConfig('popular')) { + $language = $GLOBALS['xoopsConfig']['language']; + if (!is_dir(XOOPS_ROOT_PATH . "/modules/$moduleDirName/language/" . $language . '/')) { + $language = 'english'; + } + $img_path = XOOPS_ROOT_PATH . "/modules/$moduleDirName/language/" . $language . '/'; + $img_url = XOOPS_URL . "/modules/$moduleDirName/language/" . $language . '/'; + if (is_readable($img_path . 'popular.png')) { + $pop = ' ' . _MD_TDMDOWNLOADS_INDEX_POPULAR . ''; + } else { + $pop = ' ' . _MD_TDMDOWNLOADS_INDEX_POPULAR . ''; + } + } + + return $pop; + } + + /** + * @param $size + * @param mixed $global + * @param mixed $key + * @param mixed $default + * @param mixed $type + * + * @return string + */ + // public static function convertFileSize($size) + // { + // if ($size > 0) { + // $mb = 1024 * 1024; + // if ($size > $mb) { + // $mysize = sprintf("%01.2f", $size / $mb) . " MB"; + // } elseif ($size >= 1024) { + // $mysize = sprintf("%01.2f", $size / 1024) . " KB"; + // } else { + // $mysize = sprintf(_AM_TDMDOWNLOADS_NUMBYTES, $size); + // } + // + // return $mysize; + // } else { + // return ''; + // } + // } + + /** + * @param $global + * @param $key + * @param string $default + * @param string $type + * + * @return mixed|string + */ + public static function cleanVars($global, $key, $default = '', $type = 'int') + { + switch ($type) { + case 'string': + if (defined('FILTER_SANITIZE_ADD_SLASHES')) { + $ret = isset($global[$key]) ? filter_var($global[$key], FILTER_SANITIZE_ADD_SLASHES) : $default; + } else { + $ret = isset($global[$key]) ? filter_var($global[$key], FILTER_SANITIZE_MAGIC_QUOTES) : $default; + } + break; + case 'int': + default: + $ret = isset($global[$key]) ? filter_var($global[$key], FILTER_SANITIZE_NUMBER_INT) : $default; + break; + } + if (false === $ret) { + return $default; + } + + return $ret; + } + + /** + * @param $mytree + * @param $key + * @param $category_array + * @param $title + * @param string $prefix + * + * @return string + */ + public static function getPathTree($mytree, $key, $category_array, $title, $prefix = '') + { + $category_parent = $mytree->getAllParent($key); + $category_parent = array_reverse($category_parent); + $Path = ''; + foreach (array_keys($category_parent) as $j) { + $Path .= $category_parent[$j]->getVar($title) . $prefix; + } + $first_category = ''; + if (array_key_exists($key, $category_array)) { + $first_category = $category_array[$key]->getVar($title); + } + $Path .= $first_category; + + return $Path; + } + + /** + * @param $mytree + * @param $key + * @param $category_array + * @param $title + * @param string $prefix + * @param bool $link + * @param string $order + * @param bool $lasturl + * + * @return string + */ + public static function getPathTreeUrl( + $mytree, + $key, + $category_array, + $title, + $prefix = '', + $link = false, + $order = 'ASC', + $lasturl = false + ) { + global $xoopsModule; + $category_parent = $mytree->getAllParent($key); + if ('ASC' === $order) { + $category_parent = array_reverse($category_parent); + if (true === $link) { + $Path = '' . $xoopsModule->name() . '' . $prefix; + } else { + $Path = $xoopsModule->name() . $prefix; + } + } else { + $first_category = ''; + if (array_key_exists($key, $category_array)) { + $first_category = $category_array[$key]->getVar($title); + } + $Path = $first_category . $prefix; + } + foreach (array_keys($category_parent) as $j) { + if (true === $link) { + $Path .= '' . $category_parent[$j]->getVar($title) . '' . $prefix; + } else { + $Path .= $category_parent[$j]->getVar($title) . $prefix; + } + } + if ('ASC' === $order) { + if (array_key_exists($key, $category_array)) { + if (true === $lasturl) { + $first_category = '' . $category_array[$key]->getVar($title) . ''; + } else { + $first_category = $category_array[$key]->getVar($title); + } + } else { + $first_category = ''; + } + $Path .= $first_category; + } else { + if (true === $link) { + $Path .= '' . $xoopsModule->name() . ''; + } else { + $Path .= $xoopsModule->name(); + } + } + + return $Path; + } + + /** + * @param $path + * @param int $mode + * @param $fileSource + * @param null $fileTarget + * @throws \RuntimeException + */ + public static function createFolder($path, $mode, $fileSource, $fileTarget = null) + { + if (!@mkdir($path, $mode) && !is_dir($path)) { + throw new \RuntimeException(sprintf('Unable to create the %s directory', $path)); + } + + file_put_contents($path . '/index.html', ''); + if (!empty($fileSource) && !empty($fileTarget)) { + @copy($fileSource, $fileTarget); + } + + chmod($path, $mode); + } + + /** + * @param $pathSource + * @param $pathTarget + * @throws \RuntimeException + */ + public static function cloneFolder($pathSource, $pathTarget) + { + if (is_dir($pathSource)) { + // Create new dir + if (!mkdir($pathTarget) && !is_dir($pathTarget)) { + throw new \RuntimeException(sprintf('Unable to create the %s directory', $pathTarget)); + } + // check all files in dir, and process it + $handle = opendir($pathSource); + if ($handle) { + while ($file = readdir($handle)) { + if ('.' !== $file && '..' !== $file) { + self::cloneFolder("$pathSource/$file", "$pathTarget/$file"); + } + } + closedir($handle); + } + } else { + copy($pathSource, $pathTarget); + } + } + + /** + * Function responsible for checking if a directory exists, we can also write in and create an index.html file + * + * @param string $folder Le chemin complet du répertoire à vérifier + * + * @throws \RuntimeException + */ + public static function prepareFolder($folder) + { + if (!@mkdir($folder) && !is_dir($folder)) { + throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); + } + file_put_contents($folder . '/index.html', ''); + } +} diff --git a/config/admin.yml b/config/admin.yml new file mode 100644 index 0000000..01b1f3f --- /dev/null +++ b/config/admin.yml @@ -0,0 +1 @@ +displaySampleButton: 1 \ No newline at end of file diff --git a/config/config.php b/config/config.php new file mode 100644 index 0000000..5330f97 --- /dev/null +++ b/config/config.php @@ -0,0 +1,89 @@ + $moduleDirNameUpper . ' Module Configurator', + 'paths' => [ + 'dirname' => $moduleDirName, + 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin', + 'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName, + 'modUrl' => XOOPS_URL . '/modules/' . $moduleDirName, + 'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName, + 'uploadUrl' => XOOPS_UPLOAD_URL . '/' . $moduleDirName, + ], + 'uploadFolders' => [ + XOOPS_UPLOAD_PATH . '/' . $moduleDirName, + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/downloads', + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images', + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/cats', + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/field', + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/shots', + //XOOPS_UPLOAD_PATH . '/flags' + ], + 'copyBlankFiles' => [ + XOOPS_UPLOAD_PATH . '/' . $moduleDirName, + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/downloads', + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images', + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/cats', + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/field', + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/shots', + //XOOPS_UPLOAD_PATH . '/flags' + ], + + 'copyTestFolders' => [ + [ + XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/testdata/uploads', + XOOPS_UPLOAD_PATH . '/' . $moduleDirName, + ], + ], + + 'templateFolders' => [ + '/templates/', + // '/templates/blocks/', + // '/templates/admin/' + ], + 'oldFiles' => [ + '/class/request.php', + '/class/registry.php', + '/class/utilities.php', + '/class/util.php', + // '/include/constants.php', + // '/include/functions.php', + '/ajaxrating.txt', + ], + 'oldFolders' => [ + '/images', + '/css', + '/js', + ], + + 'renameTables' => [// 'XX_archive' => 'ZZZZ_archive', + ], + 'moduleStats' => [ + // 'totalcategories' => $helper->getHandler('Category')->getCategoriesCount(-1), + // 'totalitems' => $helper->getHandler('Item')->getItemsCount(), + // 'totalsubmitted' => $helper->getHandler('Item')->getItemsCount(-1, [Constants::PUBLISHER_STATUS_SUBMITTED]), + ], + 'modCopyright' => " + XOOPS Project", +]; + diff --git a/config/icons.php b/config/icons.php new file mode 100644 index 0000000..58c688b --- /dev/null +++ b/config/icons.php @@ -0,0 +1,19 @@ + mb_strtoupper($moduleDirName) . ' IconConfigurator', + 'icons' => [ + 'edit' => " . _EDIT . ", + 'delete' => "" . _DELETE . "", + 'clone' => "" . _CLONE . "", + 'preview' => "" . _PREVIEW . "", + 'print' => "" . _CLONE . "", + 'pdf' => "" . _CLONE . "", + 'add' => "" . _ADD . "", + '0' => "" . 0 . "", + '1' => "" . 1 . "", + ], +]; diff --git a/config/paths.php b/config/paths.php new file mode 100644 index 0000000..fd7548a --- /dev/null +++ b/config/paths.php @@ -0,0 +1,25 @@ + mb_strtoupper($moduleDirName) . ' PathConfigurator', + 'paths' => [ + 'dirname' => $moduleDirName, + 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin', + 'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName, + 'modUrl' => XOOPS_URL . '/modules/' . $moduleDirName, + 'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName, + 'uploadUrl' => XOOPS_UPLOAD_URL . '/' . $moduleDirName, + ], + 'uploadFolders' => [ + XOOPS_UPLOAD_PATH . '/' . $moduleDirName, + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/category', + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/screenshots', + //XOOPS_UPLOAD_PATH . '/flags' + ], +]; From 0c703ac09227774eaccca1a0a3623c657f105094 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 21:33:54 -0400 Subject: [PATCH 14/62] Unnecessary type casting --- class/Category.php | 2 +- class/Downloads.php | 2 +- class/Field.php | 2 +- class/Modified.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/class/Category.php b/class/Category.php index 0bd9aad..55e359d 100644 --- a/class/Category.php +++ b/class/Category.php @@ -103,7 +103,7 @@ public function getForm($action = false) $imageselect = new \XoopsFormSelect($imgpath, 'downloadscat_img', $categoryImage); $topics_array = \XoopsLists:: getImgListAsArray(XOOPS_ROOT_PATH . $uploadirectory); foreach ($topics_array as $image) { - $imageselect->addOption((string)$image, $image); + $imageselect->addOption($image, $image); } $imageselect->setExtra("onchange='showImgSelected(\"image3\", \"downloadscat_img\", \"" . $uploadirectory . '", "", "' . XOOPS_URL . "\")'"); $imgtray->addElement($imageselect, false); diff --git a/class/Downloads.php b/class/Downloads.php index 40ed3ee..66f1ad3 100644 --- a/class/Downloads.php +++ b/class/Downloads.php @@ -267,7 +267,7 @@ public function getForm($donnee = [], $erreur = false, $action = false) $imageselect = new \XoopsFormSelect($imgpath, 'logo_img', $categoryImage); $topics_array = \XoopsLists:: getImgListAsArray(XOOPS_ROOT_PATH . $uploadirectory); foreach ($topics_array as $image) { - $imageselect->addOption((string)$image, $image); + $imageselect->addOption($image, $image); } $imageselect->setExtra("onchange='showImgSelected(\"image3\", \"logo_img\", \"" . $uploadirectory . '", "", "' . XOOPS_URL . "\")'"); $imgtray->addElement($imageselect, false); diff --git a/class/Field.php b/class/Field.php index e1126ad..029d217 100644 --- a/class/Field.php +++ b/class/Field.php @@ -89,7 +89,7 @@ public function getForm($action = false) $imageselect = new \XoopsFormSelect($imgpath, 'downloadsfield_img', $downloadsfield_img); $topics_array = \XoopsLists:: getImgListAsArray(XOOPS_ROOT_PATH . $uploadirectory); foreach ($topics_array as $image) { - $imageselect->addOption((string)$image, $image); + $imageselect->addOption($image, $image); } $imageselect->setExtra("onchange='showImgSelected(\"image3\", \"downloadsfield_img\", \"" . $uploadirectory . '", "", "' . XOOPS_URL . "\")'"); $imgtray->addElement($imageselect, false); diff --git a/class/Modified.php b/class/Modified.php index 0e18021..00be50d 100644 --- a/class/Modified.php +++ b/class/Modified.php @@ -256,7 +256,7 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) $imageselect = new \XoopsFormSelect($imgpath, 'logo_img', $categoryImage); $topics_array = \XoopsLists:: getImgListAsArray(XOOPS_ROOT_PATH . $uploadirectory); foreach ($topics_array as $image) { - $imageselect->addOption((string)$image, $image); + $imageselect->addOption($image, $image); } $imageselect->setExtra("onchange='showImgSelected(\"image3\", \"logo_img\", \"" . $uploadirectory . '", "", "' . XOOPS_URL . "\")'"); $imgtray->addElement($imageselect, false); From a968a7661dd1f9bd786f3daaba15a4d28cfd4e4b Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 21:35:58 -0400 Subject: [PATCH 15/62] Redundant 'else' keyword --- class/Utility.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/class/Utility.php b/class/Utility.php index 54e94df..6a400db 100644 --- a/class/Utility.php +++ b/class/Utility.php @@ -306,9 +306,9 @@ public static function convertStringToSize($stringSize) $mysize = $size_value_arr[0] * $gb; } return $mysize; - } else { - return 0; } + + return 0; } /** @@ -376,9 +376,9 @@ public static function getFileSize($url) curl_close($curlHandle); if ($size <= 0) { return 0; - } else { - return self::convertFileSize($size); } + + return self::convertFileSize($size); } else { return 0; } @@ -407,9 +407,9 @@ public static function convertFileSize($size) } return $mysize; - } else { - return ''; } + + return ''; } /** From 772abb069824bbe4085253df946dbdc521d5c095 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 21:36:41 -0400 Subject: [PATCH 16/62] Null coalescing operator --- index.php | 4 ++-- search.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index 995a69a..c057779 100644 --- a/index.php +++ b/index.php @@ -205,8 +205,8 @@ $tblorder[6] = 'ASC'; $tblorder[7] = 'DESC'; $tblorder[8] = 'ASC'; - $sort = null !== $helper->getConfig('toporder') ? $helper->getConfig('toporder') : 1; - $order = null !== $helper->getConfig('toporder') ? $helper->getConfig('toporder') : 1; + $sort = $helper->getConfig('toporder') ?? 1; + $order = $helper->getConfig('toporder') ?? 1; $criteria->setSort($tblsort[$sort]); $criteria->setOrder($tblorder[$order]); $downloadsArray = $downloadsHandler->getAll($criteria); diff --git a/search.php b/search.php index 4b19c52..6f6139a 100644 --- a/search.php +++ b/search.php @@ -189,8 +189,8 @@ $tblorder[6] = 'ASC'; $tblorder[7] = 'DESC'; $tblorder[8] = 'ASC'; -$sort = null !== $helper->getConfig('searchorder') ? $helper->getConfig('searchorder') : 1; -$order = null !== $helper->getConfig('searchorder') ? $helper->getConfig('searchorder') : 1; +$sort = $helper->getConfig('searchorder') ?? 1; +$order = $helper->getConfig('searchorder') ?? 1; $criteria_2->setSort($tblsort[$sort]); $criteria_2->setOrder($tblorder[$order]); $numrows = $downloadsHandler->getCount($criteria_2); From 9f7434d517031ba48fa50c9174e06a21d85ab2c8 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 21:38:04 -0400 Subject: [PATCH 17/62] Short list syntax --- admin/import.php | 10 +++++----- class/Common/ImageResizer.php | 2 +- extra/plugins/waiting/tdmdownloads.php | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/admin/import.php b/admin/import.php index fc4b65e..7b59f53 100644 --- a/admin/import.php +++ b/admin/import.php @@ -75,7 +75,7 @@ function importMydownloads($path = '', $imgurl = '') while (false !== ($donnees = $xoopsDB->fetchArray($query_links))) { //On recupere la description $requete = $xoopsDB->queryF('SELECT description FROM ' . $xoopsDB->prefix('mydownloads_text') . " WHERE lid = '" . $donnees['lid'] . "'"); - list($description) = $xoopsDB->fetchRow($requete); + [$description] = $xoopsDB->fetchRow($requete); $insert = $xoopsDB->queryF( 'INSERT INTO ' . $xoopsDB->prefix('tdmdownloads_downloads') @@ -287,7 +287,7 @@ function importWfdownloads($shots = '', $catimg = '') global $xoopsDB; $sql = $xoopsDB->query('SELECT COUNT(lid) AS count FROM ' . $xoopsDB->prefix('mydownloads_downloads')); - list($count_downloads) = $xoopsDB->fetchRow($sql); + [$count_downloads] = $xoopsDB->fetchRow($sql); if ($count_downloads < 1) { $check .= '
  • ' . _AM_TDMDOWNLOADS_IMPORT_DONT_DOWNLOADS . '
  • '; } else { @@ -295,7 +295,7 @@ function importWfdownloads($shots = '', $catimg = '') $counter++; } $sql = $xoopsDB->query('SELECT COUNT(cid) AS count FROM ' . $xoopsDB->prefix('mydownloads_cat')); - list($count_topic) = $xoopsDB->fetchRow($sql); + [$count_topic] = $xoopsDB->fetchRow($sql); if ($count_topic < 1) { $check .= '
  • ' . _AM_TDMDOWNLOADS_IMPORT_DONT_TOPIC . '
  • '; @@ -339,7 +339,7 @@ function importWfdownloads($shots = '', $catimg = '') $check = '
      '; $sql = $xoopsDB->query('SELECT COUNT(lid) AS count FROM ' . $xoopsDB->prefix('wfdownloads_downloads')); - list($count_downloads) = $xoopsDB->fetchRow($sql); + [$count_downloads] = $xoopsDB->fetchRow($sql); if ($count_downloads < 1) { $check .= '
    • ' . _AM_TDMDOWNLOADS_IMPORT_DONT_DOWNLOADS . '
    • '; } else { @@ -347,7 +347,7 @@ function importWfdownloads($shots = '', $catimg = '') $counter++; } $sql = $xoopsDB->query('SELECT COUNT(cid) AS count FROM ' . $xoopsDB->prefix('wfdownloads_cat')); - list($count_topic) = $xoopsDB->fetchRow($sql); + [$count_topic] = $xoopsDB->fetchRow($sql); if ($count_topic < 1) { $check .= '
    • ' . _AM_TDMDOWNLOADS_IMPORT_DONT_TOPIC . '
    • '; } else { diff --git a/class/Common/ImageResizer.php b/class/Common/ImageResizer.php index 4dcafce..c095bc6 100644 --- a/class/Common/ImageResizer.php +++ b/class/Common/ImageResizer.php @@ -134,7 +134,7 @@ public function resizeAndCrop($src_url, $src_mimetype, $dest_url, $dest_w, $dest } // GET ORIGINAL IMAGE DIMENSIONS - list($original_w, $original_h) = getimagesize($src_url); + [$original_w, $original_h] = getimagesize($src_url); // RESIZE IMAGE AND PRESERVE PROPORTIONS $dest_w_resize = $dest_w; diff --git a/extra/plugins/waiting/tdmdownloads.php b/extra/plugins/waiting/tdmdownloads.php index 8a63163..63ded54 100644 --- a/extra/plugins/waiting/tdmdownloads.php +++ b/extra/plugins/waiting/tdmdownloads.php @@ -24,7 +24,7 @@ function b_waiting_tdmdownloads() $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('tdmdownloads_downloads') . ' WHERE status=0'); if ($result) { $block['adminlink'] = XOOPS_URL . "/modules/$moduleDirName/admin/downloads.php?op=liste&statut_display=0"; - list($block['pendingnum']) = $xoopsDB->fetchRow($result); + [$block['pendingnum']] = $xoopsDB->fetchRow($result); $block['lang_linkname'] = _PI_WAITING_WAITINGS; } $ret[] = $block; @@ -34,7 +34,7 @@ function b_waiting_tdmdownloads() $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('tdmdownloads_broken')); if ($result) { $block['adminlink'] = XOOPS_URL . "/modules/$moduleDirName/admin/broken.php"; - list($block['pendingnum']) = $xoopsDB->fetchRow($result); + [$block['pendingnum']] = $xoopsDB->fetchRow($result); $block['lang_linkname'] = _PI_WAITING_BROKENS; } $ret[] = $block; @@ -44,7 +44,7 @@ function b_waiting_tdmdownloads() $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('tdmdownloads_mod')); if ($result) { $block['adminlink'] = XOOPS_URL . "/modules/$moduleDirName/admin/modified.php"; - list($block['pendingnum']) = $xoopsDB->fetchRow($result); + [$block['pendingnum']] = $xoopsDB->fetchRow($result); $block['lang_linkname'] = _PI_WAITING_MODREQS; } $ret[] = $block; From 3b0d2c2abe60c7480a9fb54535f409d66ea30acc Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 21:39:23 -0400 Subject: [PATCH 18/62] Unqualified function/constant reference --- class/Broken.php | 12 ++-- class/Category.php | 34 ++++----- class/Common/Breadcrumb.php | 4 +- class/Common/Configurator.php | 6 +- class/Common/FilesManagement.php | 46 ++++++------ class/Common/FineimpuploadHandler.php | 50 ++++++------- class/Common/ImageResizer.php | 88 +++++++++++------------ class/Common/Images.php | 100 +++++++++++++------------- class/Common/ImagesHandler.php | 12 ++-- class/Common/Migrate.php | 8 +-- class/Common/ModuleConstants.php | 4 +- class/Common/ServerStats.php | 32 ++++----- class/Common/SysUtility.php | 40 +++++------ class/Common/VersionChecks.php | 68 +++++++++--------- class/Downlimit.php | 10 +-- class/Downloads.php | 90 +++++++++++------------ class/Field.php | 24 +++---- class/Fielddata.php | 10 +-- class/Form/UploadForm.php | 20 +++--- class/Helper.php | 6 +- class/Modified.php | 58 +++++++-------- class/Modifiedfielddata.php | 10 +-- class/Rating.php | 12 ++-- class/Utilities.php | 78 ++++++++++---------- class/Utility.php | 84 +++++++++++----------- 25 files changed, 453 insertions(+), 453 deletions(-) diff --git a/class/Broken.php b/class/Broken.php index e6c84c5..486a982 100644 --- a/class/Broken.php +++ b/class/Broken.php @@ -27,13 +27,13 @@ class Broken extends \XoopsObject public function __construct() { parent::__construct(); - $this->initVar('reportid', XOBJ_DTYPE_INT, null, false, 5); - $this->initVar('lid', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('sender', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('ip', XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('reportid', \XOBJ_DTYPE_INT, null, false, 5); + $this->initVar('lid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('sender', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('ip', \XOBJ_DTYPE_TXTBOX, null, false); //pour les jointures: - $this->initVar('title', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('cid', XOBJ_DTYPE_INT, null, false, 5); + $this->initVar('title', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('cid', \XOBJ_DTYPE_INT, null, false, 5); } /** diff --git a/class/Category.php b/class/Category.php index 55e359d..28f2ab1 100644 --- a/class/Category.php +++ b/class/Category.php @@ -36,14 +36,14 @@ public function __construct() /** @var Tdmdownloads\Helper $helper */ $this->helper = Tdmdownloads\Helper::getInstance(); $this->permHelper = new \Xmf\Module\Helper\Permission(); - $this->initVar('cat_cid', XOBJ_DTYPE_INT, null, false, 5); - $this->initVar('cat_pid', XOBJ_DTYPE_INT, null, false, 5); - $this->initVar('cat_title', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('cat_imgurl', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('cat_description_main', XOBJ_DTYPE_TXTAREA, null, false); + $this->initVar('cat_cid', \XOBJ_DTYPE_INT, null, false, 5); + $this->initVar('cat_pid', \XOBJ_DTYPE_INT, null, false, 5); + $this->initVar('cat_title', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('cat_imgurl', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('cat_description_main', \XOBJ_DTYPE_TXTAREA, null, false); // Pour autoriser le html - $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); - $this->initVar('cat_weight', XOBJ_DTYPE_INT, 0, false, 11); + $this->initVar('dohtml', \XOBJ_DTYPE_INT, 1, false); + $this->initVar('cat_weight', \XOBJ_DTYPE_INT, 0, false, 11); } /** @@ -74,11 +74,11 @@ public function getForm($action = false) if (false === $action) { $action = $_SERVER['REQUEST_URI']; } - $moduleDirName = basename(dirname(__DIR__)); + $moduleDirName = \basename(\dirname(__DIR__)); require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; //nom du formulaire selon l'action (editer ou ajouter): - $title = $this->isNew() ? sprintf(_AM_TDMDOWNLOADS_FORMADD) : sprintf(_AM_TDMDOWNLOADS_FORMEDIT); + $title = $this->isNew() ? \sprintf(_AM_TDMDOWNLOADS_FORMADD) : \sprintf(_AM_TDMDOWNLOADS_FORMEDIT); //création du formulaire $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); @@ -99,7 +99,7 @@ public function getForm($action = false) $categoryImage = $this->getVar('cat_imgurl') ?: 'blank.gif'; $uploadirectory = '/uploads/' . $moduleDirName . '/images/cats'; $imgtray = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMIMG, '
      '); - $imgpath = sprintf(_AM_TDMDOWNLOADS_FORMPATH, $uploadirectory); + $imgpath = \sprintf(_AM_TDMDOWNLOADS_FORMPATH, $uploadirectory); $imageselect = new \XoopsFormSelect($imgpath, 'downloadscat_img', $categoryImage); $topics_array = \XoopsLists:: getImgListAsArray(XOOPS_ROOT_PATH . $uploadirectory); foreach ($topics_array as $image) { @@ -128,21 +128,21 @@ public function getForm($action = false) //permissions /** @var \XoopsMemberHandler $memberHandler */ - $memberHandler = xoops_getHandler('member'); + $memberHandler = \xoops_getHandler('member'); $group_list = $memberHandler->getGroupList(); /** @var \XoopsGroupPermHandler $grouppermHandler */ - $grouppermHandler = xoops_getHandler('groupperm'); - $full_list = array_keys($group_list); + $grouppermHandler = \xoops_getHandler('groupperm'); + $full_list = \array_keys($group_list); global $xoopsModule; if (!$this->isNew()) { $groups_ids_view = $grouppermHandler->getGroupIds('tdmdownloads_view', $this->getVar('cat_cid'), $xoopsModule->getVar('mid')); $groups_ids_submit = $grouppermHandler->getGroupIds('tdmdownloads_submit', $this->getVar('cat_cid'), $xoopsModule->getVar('mid')); $groups_ids_download = $grouppermHandler->getGroupIds('tdmdownloads_download', $this->getVar('cat_cid'), $xoopsModule->getVar('mid')); - $groups_ids_view = array_values($groups_ids_view); + $groups_ids_view = \array_values($groups_ids_view); $groups_news_can_view_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_PERM_VIEW_DSC, 'groups_view[]', $groups_ids_view); - $groups_ids_submit = array_values($groups_ids_submit); + $groups_ids_submit = \array_values($groups_ids_submit); $groups_news_can_submit_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_PERM_SUBMIT_DSC, 'groups_submit[]', $groups_ids_submit); - $groups_ids_download = array_values($groups_ids_download); + $groups_ids_download = \array_values($groups_ids_download); $groups_news_can_download_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_PERM_DOWNLOAD_DSC, 'groups_download[]', $groups_ids_download); } else { $groups_news_can_view_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_PERM_VIEW_DSC, 'groups_view[]', $full_list); @@ -169,7 +169,7 @@ public function getForm($action = false) //pour enregistrer le formulaire $form->addElement(new \XoopsFormHidden('op', 'save_cat')); //boutton d'envoi du formulaire - $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', 'submit', false)); + $form->addElement(new \XoopsFormButtonTray('', \_SUBMIT, 'submit', 'submit', false)); return $form; } diff --git a/class/Common/Breadcrumb.php b/class/Common/Breadcrumb.php index 8a08e98..569cac4 100644 --- a/class/Common/Breadcrumb.php +++ b/class/Common/Breadcrumb.php @@ -38,7 +38,7 @@ class Breadcrumb public function __construct() { - $this->dirname = basename(dirname(dirname(__DIR__))); + $this->dirname = \basename(\dirname(\dirname(__DIR__))); } /** @@ -60,7 +60,7 @@ public function addLink($title = '', $link = '') */ public function render() { - if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) { + if (!isset($GLOBALS['xoTheme']) || !\is_object($GLOBALS['xoTheme'])) { require_once $GLOBALS['xoops']->path('class/theme.php'); $GLOBALS['xoTheme'] = new \xos_opal_Theme(); } diff --git a/class/Common/Configurator.php b/class/Common/Configurator.php index 117db65..f0251f2 100644 --- a/class/Common/Configurator.php +++ b/class/Common/Configurator.php @@ -43,7 +43,7 @@ class Configurator */ public function __construct() { - $config = include dirname(dirname(__DIR__)) . '/config/config.php'; + $config = include \dirname(\dirname(__DIR__)) . '/config/config.php'; $this->name = $config->name; $this->paths = $config->paths; @@ -56,7 +56,7 @@ public function __construct() $this->renameTables = $config->renameTables; $this->modCopyright = $config->modCopyright; - $this->icons = include dirname(dirname(__DIR__)) . '/config/icons.php'; - $this->paths = include dirname(dirname(__DIR__)) . '/config/paths.php'; + $this->icons = include \dirname(\dirname(__DIR__)) . '/config/icons.php'; + $this->paths = include \dirname(\dirname(__DIR__)) . '/config/paths.php'; } } diff --git a/class/Common/FilesManagement.php b/class/Common/FilesManagement.php index e5248aa..6ac1944 100644 --- a/class/Common/FilesManagement.php +++ b/class/Common/FilesManagement.php @@ -29,9 +29,9 @@ trait FilesManagement public static function createFolder($folder) { try { - if (!file_exists($folder)) { - if (!is_dir($folder) && !mkdir($folder) && !is_dir($folder)) { - throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); + if (!\file_exists($folder)) { + if (!\is_dir($folder) && !\mkdir($folder) && !\is_dir($folder)) { + throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder)); } file_put_contents($folder . '/index.html', ''); @@ -48,7 +48,7 @@ public static function createFolder($folder) */ public static function copyFile($file, $folder) { - return copy($file, $folder); + return \copy($file, $folder); } /** @@ -58,20 +58,20 @@ public static function copyFile($file, $folder) */ public static function recurseCopy($src, $dst) { - $dir = opendir($src); - if (!mkdir($dst) && !is_dir($dst)) { + $dir = \opendir($src); + if (!\mkdir($dst) && !\is_dir($dst)) { throw new \RuntimeException('The directory ' . $dst . ' could not be created.'); } - while (false !== ($file = readdir($dir))) { + while (false !== ($file = \readdir($dir))) { if (('.' !== $file) && ('..' !== $file)) { - if (is_dir($src . '/' . $file)) { + if (\is_dir($src . '/' . $file)) { self::recurseCopy($src . '/' . $file, $dst . '/' . $file); } else { - copy($src . '/' . $file, $dst . '/' . $file); + \copy($src . '/' . $file, $dst . '/' . $file); } } } - closedir($dir); + \closedir($dir); } /** @@ -96,7 +96,7 @@ public static function deleteDirectory($src) $dirInfo = new \SplFileInfo($src); // validate is a directory if ($dirInfo->isDir()) { - $fileList = array_diff(scandir($src, SCANDIR_SORT_NONE), ['..', '.']); + $fileList = \array_diff(\scandir($src, \SCANDIR_SORT_NONE), ['..', '.']); foreach ($fileList as $k => $v) { $fileInfo = new \SplFileInfo("{$src}/{$v}"); if ($fileInfo->isDir()) { @@ -106,14 +106,14 @@ public static function deleteDirectory($src) } } else { // delete the file - if (!($success = unlink($fileInfo->getRealPath()))) { + if (!($success = \unlink($fileInfo->getRealPath()))) { break; } } } // now delete this (sub)directory if all the files are gone if ($success) { - $success = rmdir($dirInfo->getRealPath()); + $success = \rmdir($dirInfo->getRealPath()); } } else { // input is not a valid directory @@ -140,7 +140,7 @@ public static function rrmdir($src) } // If source is not a directory stop processing - if (!is_dir($src)) { + if (!\is_dir($src)) { return false; } @@ -152,7 +152,7 @@ public static function rrmdir($src) if ($fObj->isFile()) { $filename = $fObj->getPathname(); $fObj = null; // clear this iterator object to close the file - if (!unlink($filename)) { + if (!\unlink($filename)) { return false; // couldn't delete the file } } elseif (!$fObj->isDot() && $fObj->isDir()) { @@ -161,7 +161,7 @@ public static function rrmdir($src) } } $iterator = null; // clear iterator Obj to close file/directory - return rmdir($src); // remove the directory & return results + return \rmdir($src); // remove the directory & return results } /** @@ -180,12 +180,12 @@ public static function rmove($src, $dest) } // If source is not a directory stop processing - if (!is_dir($src)) { + if (!\is_dir($src)) { return false; } // If the destination directory does not exist and could not be created stop processing - if (!is_dir($dest) && !mkdir($dest) && !is_dir($dest)) { + if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) { return false; } @@ -193,7 +193,7 @@ public static function rmove($src, $dest) $iterator = new \DirectoryIterator($src); foreach ($iterator as $fObj) { if ($fObj->isFile()) { - rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); + \rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); } elseif (!$fObj->isDot() && $fObj->isDir()) { // Try recursively on directory self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); @@ -201,7 +201,7 @@ public static function rmove($src, $dest) } } $iterator = null; // clear iterator Obj to close file/directory - return rmdir($src); // remove the directory & return results + return \rmdir($src); // remove the directory & return results } /** @@ -223,12 +223,12 @@ public static function rcopy($src, $dest) } // If source is not a directory stop processing - if (!is_dir($src)) { + if (!\is_dir($src)) { return false; } // If the destination directory does not exist and could not be created stop processing - if (!is_dir($dest) && !mkdir($dest) && !is_dir($dest)) { + if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) { return false; } @@ -236,7 +236,7 @@ public static function rcopy($src, $dest) $iterator = new \DirectoryIterator($src); foreach ($iterator as $fObj) { if ($fObj->isFile()) { - copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); + \copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); } elseif (!$fObj->isDot() && $fObj->isDir()) { self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); } diff --git a/class/Common/FineimpuploadHandler.php b/class/Common/FineimpuploadHandler.php index 39cdb31..3f0d05a 100644 --- a/class/Common/FineimpuploadHandler.php +++ b/class/Common/FineimpuploadHandler.php @@ -115,10 +115,10 @@ public function __construct(\stdClass $claims) */ protected function storeUploadedFile($target, $mimeType, $uid) { - $moduleDirName = basename(dirname(dirname(__DIR__))); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/header.php'; - $this->pathUpload = constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH'); + $this->pathUpload = \constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH'); $utility = new \XoopsModules\Tdmdownloads\Utility(); /** @var \XoopsModules\Tdmdownloads\Helper $helper */ $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); @@ -131,14 +131,14 @@ protected function storeUploadedFile($target, $mimeType, $uid) $this->permUseralbum = 1; //TODO: handle an option, whether images should be online immediately or not - $pathParts = pathinfo($this->getName()); + $pathParts = \pathinfo($this->getName()); - $this->imageName = uniqid('img', true) . '.' . strtolower($pathParts['extension']); - $this->imageNicename = str_replace(['_', '-'], ' ', $pathParts['filename']); - $this->imageNameLarge = uniqid('imgl', true) . '.' . strtolower($pathParts['extension']); + $this->imageName = \uniqid('img', true) . '.' . \strtolower($pathParts['extension']); + $this->imageNicename = \str_replace(['_', '-'], ' ', $pathParts['filename']); + $this->imageNameLarge = \uniqid('imgl', true) . '.' . \strtolower($pathParts['extension']); $this->imagePath = $this->pathUpload . '/large/' . $this->imageNameLarge; - if (false === move_uploaded_file($_FILES[$this->inputName]['tmp_name'], $this->imagePath)) { + if (false === \move_uploaded_file($_FILES[$this->inputName]['tmp_name'], $this->imagePath)) { return false; } @@ -149,7 +149,7 @@ protected function storeUploadedFile($target, $mimeType, $uid) $ret = $this->handleImageDB(); if (false === $ret) { return [ - 'error' => sprintf(_FAILSAVEIMG, $this->imageNicename), + 'error' => \sprintf(\_FAILSAVEIMG, $this->imageNicename), ]; } @@ -161,10 +161,10 @@ protected function storeUploadedFile($target, $mimeType, $uid) if (0 < $wmId) { $watermarksObj = $watermarksHandler->get($wmId); $wmTarget = $watermarksObj->getVar('wm_target'); - if (constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_A') === $wmTarget || constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_M') === $wmTarget) { + if (\constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_A') === $wmTarget || \constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_M') === $wmTarget) { $wmTargetM = true; } - if (constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_A') === $wmTarget || constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_L') === $wmTarget) { + if (\constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_A') === $wmTarget || \constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_L') === $wmTarget) { $wmTargetL = true; } } @@ -173,20 +173,20 @@ protected function storeUploadedFile($target, $mimeType, $uid) // $ret = $this->resizeImage($this->pathUpload . '/medium/' . $this->imageName, $helper->getConfig('maxwidth_medium'), $helper->getConfig('maxheight_medium')); $ret = $utility->resizeImage($this->imagePath, $this->pathUpload . '/medium/' . $this->imageName, $helper->getConfig('maxwidth_medium'), $helper->getConfig('maxheight_medium'), $this->imageMimetype); if (false === $ret) { - return ['error' => sprintf(constant($moduleDirNameUpper . '_' . 'FAILSAVEIMG_MEDIUM'), $this->imageNicename)]; + return ['error' => \sprintf(\constant($moduleDirNameUpper . '_' . 'FAILSAVEIMG_MEDIUM'), $this->imageNicename)]; } if ('copy' === $ret) { - copy($this->pathUpload . '/large/' . $this->imageNameLarge, $this->pathUpload . '/medium/' . $this->imageName); + \copy($this->pathUpload . '/large/' . $this->imageNameLarge, $this->pathUpload . '/medium/' . $this->imageName); } // create thumb // $ret = $this->resizeImage($this->pathUpload . '/thumbs/' . $this->imageName, $helper->getConfig('maxwidth_thumbs'), $helper->getConfig('maxheight_thumbs')); $ret = $utility->resizeImage($this->imagePath, $this->pathUpload . '/thumbs/' . $this->imageName, $helper->getConfig('maxwidth_thumbs'), $helper->getConfig('maxheight_thumbs'), $this->imageMimetype); if (false === $ret) { - return ['error' => sprintf(constant($moduleDirNameUpper . '_' . 'FAILSAVEIMG_THUMBS'), $this->imageNicename)]; + return ['error' => \sprintf(\constant($moduleDirNameUpper . '_' . 'FAILSAVEIMG_THUMBS'), $this->imageNicename)]; } if ('copy' === $ret) { - copy($this->pathUpload . '/large/' . $this->imageNameLarge, $this->pathUpload . '/thumbs/' . $this->imageName); + \copy($this->pathUpload . '/large/' . $this->imageNameLarge, $this->pathUpload . '/thumbs/' . $this->imageName); } // add watermark to large image @@ -194,7 +194,7 @@ protected function storeUploadedFile($target, $mimeType, $uid) $imgWm = $this->pathUpload . '/large/' . $this->imageNameLarge; $resWm = $watermarksHandler->watermarkImage($wmId, $imgWm, $imgWm); if (true !== $resWm) { - return ['error' => sprintf(constant($moduleDirNameUpper . '_' . 'FAILSAVEWM_LARGE'), $this->imageNicename, $resWm)]; + return ['error' => \sprintf(\constant($moduleDirNameUpper . '_' . 'FAILSAVEWM_LARGE'), $this->imageNicename, $resWm)]; } } // add watermark to medium image @@ -202,7 +202,7 @@ protected function storeUploadedFile($target, $mimeType, $uid) $imgWm = $this->pathUpload . '/medium/' . $this->imageName; $resWm = $watermarksHandler->watermarkImage($wmId, $imgWm, $imgWm); if (true !== $resWm) { - return ['error' => sprintf(constant($moduleDirNameUpper . '_' . 'FAILSAVEWM_MEDIUM'), $this->imageNicename, $resWm)]; + return ['error' => \sprintf(\constant($moduleDirNameUpper . '_' . 'FAILSAVEWM_MEDIUM'), $this->imageNicename, $resWm)]; } } @@ -214,7 +214,7 @@ protected function storeUploadedFile($target, $mimeType, $uid) */ private function handleImageDB() { - $moduleDirName = basename(dirname(dirname(__DIR__))); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/header.php'; global $xoopsUser; @@ -236,7 +236,7 @@ private function handleImageDB() $imagesObj->setVar('img_resy', $this->imageHeight); $imagesObj->setVar('img_albid', $this->claims->cat); $imagesObj->setVar('img_state', $this->permUseralbum); - $imagesObj->setVar('img_date', time()); + $imagesObj->setVar('img_date', \time()); $imagesObj->setVar('img_submitter', $xoopsUser->id()); $imagesObj->setVar('img_ip', $_SERVER['REMOTE_ADDR']); // Insert Data @@ -254,13 +254,13 @@ private function getImageDim() { switch ($this->imageMimetype) { case'image/png': - $img = imagecreatefrompng($this->imagePath); + $img = \imagecreatefrompng($this->imagePath); break; case'image/jpeg': - $img = imagecreatefromjpeg($this->imagePath); + $img = \imagecreatefromjpeg($this->imagePath); break; case'image/gif': - $img = imagecreatefromgif($this->imagePath); + $img = \imagecreatefromgif($this->imagePath); break; case'application/zip': @@ -274,10 +274,10 @@ private function getImageDim() $this->imageHeight = 0; return 'Unsupported format'; } - $this->imageWidth = imagesx($img); - $this->imageHeight = imagesy($img); + $this->imageWidth = \imagesx($img); + $this->imageHeight = \imagesy($img); - imagedestroy($img); + \imagedestroy($img); return true; } diff --git a/class/Common/ImageResizer.php b/class/Common/ImageResizer.php index c095bc6..074c748 100644 --- a/class/Common/ImageResizer.php +++ b/class/Common/ImageResizer.php @@ -39,20 +39,20 @@ public function resizeImage($sourcefile, $endfile, $max_width, $max_height, $ima // check file extension switch ($imageMimetype) { case'image/png': - $img = imagecreatefrompng($sourcefile); + $img = \imagecreatefrompng($sourcefile); break; case'image/jpeg': - $img = imagecreatefromjpeg($sourcefile); + $img = \imagecreatefromjpeg($sourcefile); break; case'image/gif': - $img = imagecreatefromgif($sourcefile); + $img = \imagecreatefromgif($sourcefile); break; default: return 'Unsupported format'; } - $width = imagesx($img); - $height = imagesy($img); + $width = \imagesx($img); + $height = \imagesy($img); if ($width > $max_width || $height > $max_height) { // recalc image size based on max_width/max_height @@ -62,44 +62,44 @@ public function resizeImage($sourcefile, $endfile, $max_width, $max_height, $ima } else { $new_width = $max_width; $divisor = $width / $new_width; - $new_height = floor($height / $divisor); + $new_height = \floor($height / $divisor); } } elseif ($height < $max_height) { $new_height = $height; } else { $new_height = $max_height; $divisor = $height / $new_height; - $new_width = floor($width / $divisor); + $new_width = \floor($width / $divisor); } // Create a new temporary image. - $tmpimg = imagecreatetruecolor($new_width, $new_height); + $tmpimg = \imagecreatetruecolor($new_width, $new_height); imagealphablending($tmpimg, false); imagesavealpha($tmpimg, true); // Copy and resize old image into new image. - imagecopyresampled($tmpimg, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); + \imagecopyresampled($tmpimg, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); - unlink($endfile); + \unlink($endfile); //compressing the file switch ($imageMimetype) { case'image/png': - imagepng($tmpimg, $endfile, 0); + \imagepng($tmpimg, $endfile, 0); break; case'image/jpeg': - imagejpeg($tmpimg, $endfile, 100); + \imagejpeg($tmpimg, $endfile, 100); break; case'image/gif': - imagegif($tmpimg, $endfile); + \imagegif($tmpimg, $endfile); break; } // release the memory - imagedestroy($tmpimg); + \imagedestroy($tmpimg); } else { return 'copy'; } - imagedestroy($img); + \imagedestroy($img); return true; } @@ -117,13 +117,13 @@ public function resizeAndCrop($src_url, $src_mimetype, $dest_url, $dest_w, $dest // check file extension switch ($src_mimetype) { case 'image/png': - $original = imagecreatefrompng($src_url); + $original = \imagecreatefrompng($src_url); break; case 'image/jpeg': - $original = imagecreatefromjpeg($src_url); + $original = \imagecreatefromjpeg($src_url); break; case 'image/gif': - $original = imagecreatefromgif($src_url); + $original = \imagecreatefromgif($src_url); break; default: return 'Unsupported format'; @@ -134,47 +134,47 @@ public function resizeAndCrop($src_url, $src_mimetype, $dest_url, $dest_w, $dest } // GET ORIGINAL IMAGE DIMENSIONS - [$original_w, $original_h] = getimagesize($src_url); + [$original_w, $original_h] = \getimagesize($src_url); // RESIZE IMAGE AND PRESERVE PROPORTIONS $dest_w_resize = $dest_w; $dest_h_resize = $dest_h; if ($original_w > $original_h) { $dest_h_ratio = $dest_h / $original_h; - $dest_w_resize = (int)round($original_w * $dest_h_ratio); + $dest_w_resize = (int)\round($original_w * $dest_h_ratio); } else { $dest_w_ratio = $dest_w / $original_w; - $dest_h_resize = (int)round($original_h * $dest_w_ratio); + $dest_h_resize = (int)\round($original_h * $dest_w_ratio); } if ($dest_w_resize < $dest_w) { $dest_h_ratio = $dest_w / $dest_w_resize; - $dest_h_resize = (int)round($dest_h * $dest_h_ratio); + $dest_h_resize = (int)\round($dest_h * $dest_h_ratio); $dest_w_resize = $dest_w; } // CREATE THE PROPORTIONAL IMAGE RESOURCE - $thumb = imagecreatetruecolor($dest_w_resize, $dest_h_resize); - if (!imagecopyresampled($thumb, $original, 0, 0, 0, 0, $dest_w_resize, $dest_h_resize, $original_w, $original_h)) { + $thumb = \imagecreatetruecolor($dest_w_resize, $dest_h_resize); + if (!\imagecopyresampled($thumb, $original, 0, 0, 0, 0, $dest_w_resize, $dest_h_resize, $original_w, $original_h)) { return false; } // CREATE THE CENTERED CROPPED IMAGE TO THE SPECIFIED DIMENSIONS - $final = imagecreatetruecolor($dest_w, $dest_h); + $final = \imagecreatetruecolor($dest_w, $dest_h); $dest_w_offset = 0; $dest_h_offset = 0; if ($dest_w < $dest_w_resize) { - $dest_w_offset = (int)round(($dest_w_resize - $dest_w) / 2); + $dest_w_offset = (int)\round(($dest_w_resize - $dest_w) / 2); } else { - $dest_h_offset = (int)round(($dest_h_resize - $dest_h) / 2); + $dest_h_offset = (int)\round(($dest_h_resize - $dest_h) / 2); } - if (!imagecopy($final, $thumb, 0, 0, $dest_w_offset, $dest_h_offset, $dest_w_resize, $dest_h_resize)) { + if (!\imagecopy($final, $thumb, 0, 0, $dest_w_offset, $dest_h_offset, $dest_w_resize, $dest_h_resize)) { return false; } // STORE THE FINAL IMAGE - WILL OVERWRITE $dest_url - if (!imagejpeg($final, $dest_url, $quality)) { + if (!\imagejpeg($final, $dest_url, $quality)) { return false; } return true; @@ -188,52 +188,52 @@ public function resizeAndCrop($src_url, $src_mimetype, $dest_url, $dest_w, $dest */ public function mergeImage($src_url, $dest_url, $pos, $of) { - $dest = imagecreatefromjpeg($dest_url); - $src = imagecreatefromjpeg($src_url); + $dest = \imagecreatefromjpeg($dest_url); + $src = \imagecreatefromjpeg($src_url); // ImageCopy ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h ) // $src = imagecreatefromjpeg($src_url); if (4 == $of) { switch ($pos) { case 1: - imagecopy($dest, $src, 0, 0, 0, 0, 199, 149); //top left + \imagecopy($dest, $src, 0, 0, 0, 0, 199, 149); //top left break; case 2: - imagecopy($dest, $src, 201, 0, 0, 0, 199, 149); //top right + \imagecopy($dest, $src, 201, 0, 0, 0, 199, 149); //top right break; case 3: - imagecopy($dest, $src, 0, 151, 0, 0, 199, 149); //bottom left + \imagecopy($dest, $src, 0, 151, 0, 0, 199, 149); //bottom left break; case 4: - imagecopy($dest, $src, 201, 151, 0, 0, 199, 149); //bottom right + \imagecopy($dest, $src, 201, 151, 0, 0, 199, 149); //bottom right break; } } if (6 == $of) { switch ($pos) { case 1: - imagecopy($dest, $src, 0, 0, 0, 0, 133, 149); //top left + \imagecopy($dest, $src, 0, 0, 0, 0, 133, 149); //top left break; case 2: - imagecopy($dest, $src, 134, 0, 0, 0, 133, 149); //top center + \imagecopy($dest, $src, 134, 0, 0, 0, 133, 149); //top center break; case 3: - imagecopy($dest, $src, 268, 0, 0, 0, 133, 149); //top right + \imagecopy($dest, $src, 268, 0, 0, 0, 133, 149); //top right break; case 4: - imagecopy($dest, $src, 0, 151, 0, 0, 133, 149); //bottom left + \imagecopy($dest, $src, 0, 151, 0, 0, 133, 149); //bottom left break; case 5: - imagecopy($dest, $src, 134, 151, 0, 0, 133, 149); //bottom center + \imagecopy($dest, $src, 134, 151, 0, 0, 133, 149); //bottom center break; case 6: - imagecopy($dest, $src, 268, 151, 0, 0, 133, 149); //bottom right + \imagecopy($dest, $src, 268, 151, 0, 0, 133, 149); //bottom right break; } } - imagejpeg($dest, $dest_url); + \imagejpeg($dest, $dest_url); - imagedestroy($src); - imagedestroy($dest); + \imagedestroy($src); + \imagedestroy($dest); } /** diff --git a/class/Common/Images.php b/class/Common/Images.php index 810d6b4..f8f2f18 100644 --- a/class/Common/Images.php +++ b/class/Common/Images.php @@ -33,26 +33,26 @@ class Images extends \XoopsObject */ public function __construct() { - $this->initVar('img_id', XOBJ_DTYPE_INT); - $this->initVar('img_title', XOBJ_DTYPE_TXTBOX); - $this->initVar('img_desc', XOBJ_DTYPE_TXTAREA); - $this->initVar('img_name', XOBJ_DTYPE_TXTBOX); - $this->initVar('img_namelarge', XOBJ_DTYPE_TXTBOX); - $this->initVar('img_nameorig', XOBJ_DTYPE_TXTBOX); - $this->initVar('img_mimetype', XOBJ_DTYPE_TXTBOX); - $this->initVar('img_size', XOBJ_DTYPE_INT); - $this->initVar('img_resx', XOBJ_DTYPE_INT); - $this->initVar('img_resy', XOBJ_DTYPE_INT); - $this->initVar('img_downloads', XOBJ_DTYPE_INT); - $this->initVar('img_ratinglikes', XOBJ_DTYPE_INT); - $this->initVar('img_votes', XOBJ_DTYPE_INT); - $this->initVar('img_weight', XOBJ_DTYPE_INT); - $this->initVar('img_albid', XOBJ_DTYPE_INT); - $this->initVar('img_state', XOBJ_DTYPE_INT); - $this->initVar('img_date', XOBJ_DTYPE_INT); - $this->initVar('img_submitter', XOBJ_DTYPE_INT); - $this->initVar('img_ip', XOBJ_DTYPE_TXTAREA); - $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); + $this->initVar('img_id', \XOBJ_DTYPE_INT); + $this->initVar('img_title', \XOBJ_DTYPE_TXTBOX); + $this->initVar('img_desc', \XOBJ_DTYPE_TXTAREA); + $this->initVar('img_name', \XOBJ_DTYPE_TXTBOX); + $this->initVar('img_namelarge', \XOBJ_DTYPE_TXTBOX); + $this->initVar('img_nameorig', \XOBJ_DTYPE_TXTBOX); + $this->initVar('img_mimetype', \XOBJ_DTYPE_TXTBOX); + $this->initVar('img_size', \XOBJ_DTYPE_INT); + $this->initVar('img_resx', \XOBJ_DTYPE_INT); + $this->initVar('img_resy', \XOBJ_DTYPE_INT); + $this->initVar('img_downloads', \XOBJ_DTYPE_INT); + $this->initVar('img_ratinglikes', \XOBJ_DTYPE_INT); + $this->initVar('img_votes', \XOBJ_DTYPE_INT); + $this->initVar('img_weight', \XOBJ_DTYPE_INT); + $this->initVar('img_albid', \XOBJ_DTYPE_INT); + $this->initVar('img_state', \XOBJ_DTYPE_INT); + $this->initVar('img_date', \XOBJ_DTYPE_INT); + $this->initVar('img_submitter', \XOBJ_DTYPE_INT); + $this->initVar('img_ip', \XOBJ_DTYPE_TXTAREA); + $this->initVar('dohtml', \XOBJ_DTYPE_INT, 1, false); } /** @@ -84,20 +84,20 @@ public function getNewInsertedIdImages() */ public function getFormImages($action = false) { - $moduleDirName = basename(dirname(dirname(__DIR__))); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); $helper = Tdmdownloads\Helper::getInstance(); if (false === $action) { $action = $_SERVER['REQUEST_URI']; } // Title - $title = $this->isNew() ? sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_ADD')) : sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_EDIT')); + $title = $this->isNew() ? \sprintf(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_ADD')) : \sprintf(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_EDIT')); // Get Theme Form - xoops_load('XoopsFormLoader'); + \xoops_load('XoopsFormLoader'); $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); $form->setExtra('enctype="multipart/form-data"'); // Form Text ImgTitle - $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_TITLE'), 'img_title', 50, 255, $this->getVar('img_title'))); + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_TITLE'), 'img_title', 50, 255, $this->getVar('img_title'))); // Form editor ImgDesc $editorConfigs = []; $editorConfigs['name'] = 'img_desc'; @@ -107,59 +107,59 @@ public function getFormImages($action = false) $editorConfigs['width'] = '100%'; $editorConfigs['height'] = '400px'; $editorConfigs['editor'] = $helper->getConfig('editor'); - $form->addElement(new \XoopsFormEditor(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_DESC'), 'img_desc', $editorConfigs)); + $form->addElement(new \XoopsFormEditor(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_DESC'), 'img_desc', $editorConfigs)); // Form Text ImgName - $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_NAME'), 'img_name', 50, 255, $this->getVar('img_name')), true); + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_NAME'), 'img_name', 50, 255, $this->getVar('img_name')), true); // Form Text ImgNameLarge - $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_NAMELARGE'), 'img_namelarge', 50, 255, $this->getVar('img_namelarge')), true); + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_NAMELARGE'), 'img_namelarge', 50, 255, $this->getVar('img_namelarge')), true); // Form Text ImgOrigname - $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_NAMEORIG'), 'img_nameorig', 50, 255, $this->getVar('img_nameorig')), true); + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_NAMEORIG'), 'img_nameorig', 50, 255, $this->getVar('img_nameorig')), true); // Form Text ImgMimetype $imgMimetype = $this->isNew() ? '0' : $this->getVar('img_mimetype'); - $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_MIMETYPE'), 'img_mimetype', 20, 150, $imgMimetype)); + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_MIMETYPE'), 'img_mimetype', 20, 150, $imgMimetype)); // Form Text ImgSize $imgSize = $this->isNew() ? '0' : $this->getVar('img_size'); - $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_SIZE'), 'img_size', 20, 150, $imgSize)); + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_SIZE'), 'img_size', 20, 150, $imgSize)); // Form Text ImgResx $imgResx = $this->isNew() ? '0' : $this->getVar('img_resx'); - $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_RESX'), 'img_resx', 20, 150, $imgResx)); + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_RESX'), 'img_resx', 20, 150, $imgResx)); // Form Text ImgResy $imgResy = $this->isNew() ? '0' : $this->getVar('img_resy'); - $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_RESY'), 'img_resy', 20, 150, $imgResy)); + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_RESY'), 'img_resy', 20, 150, $imgResy)); // Form Text ImgDownloads $imgDownloads = $this->isNew() ? '0' : $this->getVar('img_downloads'); - $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_DOWNLOADS'), 'img_downloads', 20, 150, $imgDownloads)); + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_DOWNLOADS'), 'img_downloads', 20, 150, $imgDownloads)); // Form Text ImgRatinglikes $imgRatinglikes = $this->isNew() ? '0' : $this->getVar('img_ratinglikes'); - $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_RATINGLIKES'), 'img_ratinglikes', 20, 150, $imgRatinglikes)); + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_RATINGLIKES'), 'img_ratinglikes', 20, 150, $imgRatinglikes)); // Form Text ImgVotes $imgVotes = $this->isNew() ? '0' : $this->getVar('img_votes'); - $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_VOTES'), 'img_votes', 20, 150, $imgVotes)); + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_VOTES'), 'img_votes', 20, 150, $imgVotes)); // Form Text ImgWeight $imgWeight = $this->isNew() ? '0' : $this->getVar('img_weight'); - $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WEIGHT'), 'img_weight', 20, 150, $imgWeight)); + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WEIGHT'), 'img_weight', 20, 150, $imgWeight)); // Form Table albums $albumsHandler = $helper->getHandler('Albums'); - $imgAlbidSelect = new \XoopsFormSelect(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_ALBID'), 'img_albid', $this->getVar('img_albid')); + $imgAlbidSelect = new \XoopsFormSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_ALBID'), 'img_albid', $this->getVar('img_albid')); $imgAlbidSelect->addOptionArray($albumsHandler->getList()); $form->addElement($imgAlbidSelect, true); // Images handler $imagesHandler = $helper->getHandler('Images'); // Form Select Images - $imgStateSelect = new \XoopsFormSelect(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_STATE'), 'img_state', $this->getVar('img_state')); + $imgStateSelect = new \XoopsFormSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_STATE'), 'img_state', $this->getVar('img_state')); $imgStateSelect->addOption('Empty'); $imgStateSelect->addOptionArray($imagesHandler->getList()); $form->addElement($imgStateSelect, true); // Form Text Date Select ImgDate $imgDate = $this->isNew() ? 0 : $this->getVar('img_date'); - $form->addElement(new \XoopsFormTextDateSelect(constant('CO_' . $moduleDirNameUpper . '_' . 'DATE'), 'img_date', '', $imgDate)); + $form->addElement(new \XoopsFormTextDateSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'DATE'), 'img_date', '', $imgDate)); // Form Select User ImgSubmitter - $form->addElement(new \XoopsFormSelectUser(constant('CO_' . $moduleDirNameUpper . '_' . 'SUBMITTER'), 'img_submitter', false, $this->getVar('img_submitter'))); + $form->addElement(new \XoopsFormSelectUser(\constant('CO_' . $moduleDirNameUpper . '_' . 'SUBMITTER'), 'img_submitter', false, $this->getVar('img_submitter'))); // Form Text ImgIp - $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_IP'), 'img_ip', 50, 255, $this->getVar('img_ip'))); + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_IP'), 'img_ip', 50, 255, $this->getVar('img_ip'))); // To Save $form->addElement(new \XoopsFormHidden('op', 'save')); - $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); + $form->addElement(new \XoopsFormButtonTray('', \_SUBMIT, 'submit', '', false)); return $form; } @@ -172,8 +172,8 @@ public function getFormImages($action = false) */ public function getValuesImages($keys = null, $format = null, $maxDepth = null) { - $moduleDirName = basename(dirname(dirname(__DIR__))); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); $helper = Tdmdownloads\Helper::getInstance(); $ret = $this->getValues($keys, $format, $maxDepth); $ret['id'] = $this->getVar('img_id'); @@ -198,12 +198,12 @@ public function getValuesImages($keys = null, $format = null, $maxDepth = null) //} $ret['state'] = $this->getVar('img_state'); $ret['state_text'] = $helper->getStateText($this->getVar('img_state')); - $ret['date'] = formatTimestamp($this->getVar('img_date'), 's'); + $ret['date'] = \formatTimestamp($this->getVar('img_date'), 's'); $ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('img_submitter')); $ret['ip'] = $this->getVar('img_ip'); - $ret['large'] = constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_URL') . '/large/' . $this->getVar('img_namelarge'); - $ret['medium'] = constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_URL') . '/medium/' . $this->getVar('img_name'); - $ret['thumb'] = constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_URL') . '/thumbs/' . $this->getVar('img_name'); + $ret['large'] = \constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_URL') . '/large/' . $this->getVar('img_namelarge'); + $ret['medium'] = \constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_URL') . '/medium/' . $this->getVar('img_name'); + $ret['thumb'] = \constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_URL') . '/thumbs/' . $this->getVar('img_name'); return $ret; } @@ -216,7 +216,7 @@ public function toArrayImages() { $ret = []; $vars = $this->getVars(); - foreach (array_keys($vars) as $var) { + foreach (\array_keys($vars) as $var) { $ret[$var] = $this->getVar('"{$var}"'); } return $ret; diff --git a/class/Common/ImagesHandler.php b/class/Common/ImagesHandler.php index b11ba37..1b8ab8d 100644 --- a/class/Common/ImagesHandler.php +++ b/class/Common/ImagesHandler.php @@ -119,16 +119,16 @@ private function getImagesCriteria($crImages, $albId, $start, $limit, $sort, $or */ public function unlinkImages($imageName) { - unlink(constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/large/' . $imageName); - if (file_exists(constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/large/' . $imageName)) { + \unlink(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/large/' . $imageName); + if (\file_exists(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/large/' . $imageName)) { return false; } - unlink(constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/medium/' . $imageName); - if (file_exists(constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/medium/' . $imageName)) { + \unlink(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/medium/' . $imageName); + if (\file_exists(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/medium/' . $imageName)) { return false; } - unlink(constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/thumbs/' . $imageName); - if (file_exists(constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/thumbs/' . $imageName)) { + \unlink(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/thumbs/' . $imageName); + if (\file_exists(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/thumbs/' . $imageName)) { return false; } diff --git a/class/Common/Migrate.php b/class/Common/Migrate.php index f490a9b..c11fff8 100644 --- a/class/Common/Migrate.php +++ b/class/Common/Migrate.php @@ -33,13 +33,13 @@ class Migrate extends \Xmf\Database\Migrate public function __construct() { $class = __NAMESPACE__ . '\\' . 'Configurator'; - if (!class_exists($class)) { + if (!\class_exists($class)) { throw new \RuntimeException("Class '$class' not found"); } $configurator = new $class(); $this->renameTables = $configurator->renameTables; - $moduleDirName = basename(dirname(dirname(__DIR__))); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); parent::__construct($moduleDirName); } @@ -65,8 +65,8 @@ private function convertIPAddresses($tableName, $columnName) { if ($this->tableHandler->useTable($tableName)) { $attributes = $this->tableHandler->getColumnAttributes($tableName, $columnName); - if (false !== mb_strpos($attributes, ' int(')) { - if (false === mb_strpos($attributes, 'unsigned')) { + if (false !== \mb_strpos($attributes, ' int(')) { + if (false === \mb_strpos($attributes, 'unsigned')) { $this->tableHandler->alterColumn($tableName, $columnName, " bigint(16) NOT NULL DEFAULT '0' "); $this->tableHandler->update($tableName, [$columnName => "4294967296 + $columnName"], "WHERE $columnName < 0", false); } diff --git a/class/Common/ModuleConstants.php b/class/Common/ModuleConstants.php index 539acf4..6d5ad6e 100644 --- a/class/Common/ModuleConstants.php +++ b/class/Common/ModuleConstants.php @@ -195,7 +195,7 @@ class ModuleConstants public function __construct() { - self::$mydirname2 = basename(dirname(__DIR__)); + self::$mydirname2 = \basename(\dirname(__DIR__)); } /** @@ -204,7 +204,7 @@ public function __construct() public static function mydirname() { if (null === self::$moduleDirName) { - self::$moduleDirName = basename(dirname(__DIR__)); + self::$moduleDirName = \basename(\dirname(__DIR__)); } return self::$moduleDirName; diff --git a/class/Common/ServerStats.php b/class/Common/ServerStats.php index 2ed5f4f..6ca20d7 100644 --- a/class/Common/ServerStats.php +++ b/class/Common/ServerStats.php @@ -27,28 +27,28 @@ trait ServerStats public static function getServerStats() { //mb $wfdownloads = WfdownloadsWfdownloads::getInstance(); - $moduleDirName = basename(dirname(dirname(__DIR__))); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); - xoops_loadLanguage('common', $moduleDirName); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); + \xoops_loadLanguage('common', $moduleDirName); $html = ''; // $sql = 'SELECT metavalue'; // $sql .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_meta'); // $sql .= " WHERE metakey='version' LIMIT 1"; // $query = $GLOBALS['xoopsDB']->query($sql); // list($meta) = $GLOBALS['xoopsDB']->fetchRow($query); - $html .= "
      " . constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "\n"; + $html .= "
      " . \constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "\n"; $html .= "
      \n"; // $html .= '
      ' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "
      \n"; // $html .= "
      \n"; // $html .= "
      \n"; - $html .= '
      ' . constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "
      \n"; + $html .= '
      ' . \constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "
      \n"; $html .= "
        \n"; - $gdlib = function_exists('gd_info') ? '' . constant('CO_' . $moduleDirNameUpper . '_GDON') . '' : '' . constant('CO_' . $moduleDirNameUpper . '_GDOFF') . ''; - $html .= '
      • ' . constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; - if (function_exists('gd_info')) { + $gdlib = \function_exists('gd_info') ? '' . \constant('CO_' . $moduleDirNameUpper . '_GDON') . '' : '' . \constant('CO_' . $moduleDirNameUpper . '_GDOFF') . ''; + $html .= '
      • ' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; + if (\function_exists('gd_info')) { if (true === $gdlib = gd_info()) { - $html .= '
      • ' . constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '' . $gdlib['GD Version'] . ''; + $html .= '
      • ' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '' . $gdlib['GD Version'] . ''; } } // @@ -58,18 +58,18 @@ public static function getServerStats() // $registerglobals = (!ini_get('register_globals')) ? "" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '' : "" . constant('CO_' . $moduleDirNameUpper . '_ON') . ''; // $html .= '
      • ' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals; // - $downloads = ini_get('file_uploads') ? '' . constant('CO_' . $moduleDirNameUpper . '_ON') . '' : '' . constant('CO_' . $moduleDirNameUpper . '_OFF') . ''; - $html .= '
      • ' . constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; + $downloads = \ini_get('file_uploads') ? '' . \constant('CO_' . $moduleDirNameUpper . '_ON') . '' : '' . \constant('CO_' . $moduleDirNameUpper . '_OFF') . ''; + $html .= '
      • ' . \constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; - $html .= '
      • ' . constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' ' . ini_get('upload_max_filesize') . "\n"; - $html .= '
      • ' . constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' ' . ini_get('post_max_size') . "\n"; - $html .= '
      • ' . constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' ' . ini_get('memory_limit') . "\n"; + $html .= '
      • ' . \constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' ' . \ini_get('upload_max_filesize') . "\n"; + $html .= '
      • ' . \constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' ' . \ini_get('post_max_size') . "\n"; + $html .= '
      • ' . \constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' ' . \ini_get('memory_limit') . "\n"; $html .= "
      \n"; $html .= "
        \n"; - $html .= '
      • ' . constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' ' . XOOPS_ROOT_PATH . "\n"; + $html .= '
      • ' . \constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' ' . XOOPS_ROOT_PATH . "\n"; $html .= "
      \n"; $html .= "
      \n"; - $html .= constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n"; + $html .= \constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n"; $html .= '
      '; $html .= '

      '; diff --git a/class/Common/SysUtility.php b/class/Common/SysUtility.php index 5dfa41a..cb80f2a 100644 --- a/class/Common/SysUtility.php +++ b/class/Common/SysUtility.php @@ -62,55 +62,55 @@ public static function truncateHtml($text, $length = 100, $ending = '...', $exac { if ($considerHtml) { // if the plain text is shorter than the maximum length, return the whole text - if (mb_strlen(preg_replace('/<.*?' . '>/', '', $text)) <= $length) { + if (\mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) { return $text; } // splits all html-tags to scanable lines - preg_match_all('/(<.+?' . '>)?([^<>]*)/s', $text, $lines, PREG_SET_ORDER); - $total_length = mb_strlen($ending); + \preg_match_all('/(<.+?' . '>)?([^<>]*)/s', $text, $lines, \PREG_SET_ORDER); + $total_length = \mb_strlen($ending); $open_tags = []; $truncate = ''; foreach ($lines as $line_matchings) { // if there is any html-tag in this line, handle it and add it (uncounted) to the output if (!empty($line_matchings[1])) { // if it's an "empty element" with or without xhtml-conform closing slash - if (preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) { + if (\preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) { // do nothing // if tag is a closing tag - } elseif (preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) { + } elseif (\preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) { // delete tag from $open_tags list - $pos = array_search($tag_matchings[1], $open_tags, true); + $pos = \array_search($tag_matchings[1], $open_tags, true); if (false !== $pos) { unset($open_tags[$pos]); } // if tag is an opening tag - } elseif (preg_match('/^<\s*([^\s>!]+).*?' . '>$/s', $line_matchings[1], $tag_matchings)) { + } elseif (\preg_match('/^<\s*([^\s>!]+).*?' . '>$/s', $line_matchings[1], $tag_matchings)) { // add tag to the beginning of $open_tags list - array_unshift($open_tags, mb_strtolower($tag_matchings[1])); + \array_unshift($open_tags, \mb_strtolower($tag_matchings[1])); } // add html-tag to $truncate'd text $truncate .= $line_matchings[1]; } // calculate the length of the plain text part of the line; handle entities as one character - $content_length = mb_strlen(preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2])); + $content_length = \mb_strlen(\preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2])); if ($total_length + $content_length > $length) { // the number of characters which are left $left = $length - $total_length; $entities_length = 0; // search for html entities - if (preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, PREG_OFFSET_CAPTURE)) { + if (\preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, \PREG_OFFSET_CAPTURE)) { // calculate the real length of all entities in the legal range foreach ($entities[0] as $entity) { if ($left >= $entity[1] + 1 - $entities_length) { $left--; - $entities_length += mb_strlen($entity[0]); + $entities_length += \mb_strlen($entity[0]); } else { // no more characters left break; } } } - $truncate .= mb_substr($line_matchings[2], 0, $left + $entities_length); + $truncate .= \mb_substr($line_matchings[2], 0, $left + $entities_length); // maximum lenght is reached, so get off the loop break; } @@ -123,18 +123,18 @@ public static function truncateHtml($text, $length = 100, $ending = '...', $exac } } } else { - if (mb_strlen($text) <= $length) { + if (\mb_strlen($text) <= $length) { return $text; } - $truncate = mb_substr($text, 0, $length - mb_strlen($ending)); + $truncate = \mb_substr($text, 0, $length - \mb_strlen($ending)); } // if the words shouldn't be cut in the middle... if (!$exact) { // ...search the last occurance of a space... - $spacepos = mb_strrpos($truncate, ' '); + $spacepos = \mb_strrpos($truncate, ' '); if (isset($spacepos)) { // ...and cut the text in this position - $truncate = mb_substr($truncate, 0, $spacepos); + $truncate = \mb_substr($truncate, 0, $spacepos); } } // add the defined ending to the text @@ -173,14 +173,14 @@ public static function getEditor($helper = null, $options = null) $isAdmin = $helper->isUserAdmin(); - if (class_exists('XoopsFormEditor')) { + if (\class_exists('XoopsFormEditor')) { if ($isAdmin) { - $descEditor = new \XoopsFormEditor(ucfirst($options['name']), $helper->getConfig('editorAdmin'), $options, $nohtml = false, $onfailure = 'textarea'); + $descEditor = new \XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorAdmin'), $options, $nohtml = false, $onfailure = 'textarea'); } else { - $descEditor = new \XoopsFormEditor(ucfirst($options['name']), $helper->getConfig('editorUser'), $options, $nohtml = false, $onfailure = 'textarea'); + $descEditor = new \XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorUser'), $options, $nohtml = false, $onfailure = 'textarea'); } } else { - $descEditor = new \XoopsFormDhtmlTextArea(ucfirst($options['name']), $options['name'], $options['value'], '100%', '100%'); + $descEditor = new \XoopsFormDhtmlTextArea(\ucfirst($options['name']), $options['name'], $options['value'], '100%', '100%'); } // $form->addElement($descEditor); diff --git a/class/Common/VersionChecks.php b/class/Common/VersionChecks.php index c8ac687..6a889a3 100644 --- a/class/Common/VersionChecks.php +++ b/class/Common/VersionChecks.php @@ -30,23 +30,23 @@ trait VersionChecks */ public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null) { - $moduleDirName = basename(dirname(dirname(__DIR__))); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); if (null === $module) { $module = \XoopsModule::getByDirname($moduleDirName); } - xoops_loadLanguage('admin', $moduleDirName); + \xoops_loadLanguage('admin', $moduleDirName); //check for minimum XOOPS version - $currentVer = mb_substr(XOOPS_VERSION, 6); // get the numeric part of string + $currentVer = \mb_substr(\XOOPS_VERSION, 6); // get the numeric part of string if (null === $requiredVer) { $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string } $success = true; - if (version_compare($currentVer, $requiredVer, '<')) { + if (\version_compare($currentVer, $requiredVer, '<')) { $success = false; - $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer)); + $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer)); } return $success; @@ -62,23 +62,23 @@ public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = */ public static function checkVerPhp(\XoopsModule $module = null) { - $moduleDirName = basename(dirname(dirname(__DIR__))); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); if (null === $module) { $module = \XoopsModule::getByDirname($moduleDirName); } - xoops_loadLanguage('admin', $moduleDirName); - xoops_loadLanguage('common', $moduleDirName); + \xoops_loadLanguage('admin', $moduleDirName); + \xoops_loadLanguage('common', $moduleDirName); // check for minimum PHP version $success = true; - $verNum = PHP_VERSION; + $verNum = \PHP_VERSION; $reqVer = &$module->getInfo('min_php'); if (false !== $reqVer && '' !== $reqVer) { - if (version_compare($verNum, $reqVer, '<')) { - $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum)); + if (\version_compare($verNum, $reqVer, '<')) { + $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum)); $success = false; } } @@ -99,50 +99,50 @@ public static function checkVerPhp(\XoopsModule $module = null) public static function checkVerModule($helper, $source = 'github', $default = 'master') { - $moduleDirName = basename(dirname(dirname(__DIR__))); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); $update = ''; $repository = 'XoopsModules25x/' . $moduleDirName; // $repository = 'XoopsModules25x/publisher'; //for testing only $ret = ''; $infoReleasesUrl = "https://api.github.com/repos/$repository/releases"; if ('github' === $source) { - if (function_exists('curl_init') && false !== ($curlHandle = curl_init())) { - curl_setopt($curlHandle, CURLOPT_URL, $infoReleasesUrl); - curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized' - curl_setopt($curlHandle, CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]); - $curlReturn = curl_exec($curlHandle); + if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init())) { + \curl_setopt($curlHandle, \CURLOPT_URL, $infoReleasesUrl); + \curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); + \curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized' + \curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]); + $curlReturn = \curl_exec($curlHandle); if (false === $curlReturn) { - trigger_error(curl_error($curlHandle)); - } elseif (false !== strpos($curlReturn, 'Not Found')) { - trigger_error('Repository Not Found: ' . $infoReleasesUrl); + \trigger_error(\curl_error($curlHandle)); + } elseif (false !== \strpos($curlReturn, 'Not Found')) { + \trigger_error('Repository Not Found: ' . $infoReleasesUrl); } else { - $file = json_decode($curlReturn, false); - $latestVersionLink = sprintf("https://github.com/$repository/archive/%s.zip", $file ? reset($file)->tag_name : $default); + $file = \json_decode($curlReturn, false); + $latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default); $latestVersion = $file[0]->tag_name; $prerelease = $file[0]->prerelease; if ('master' !== $latestVersionLink) { - $update = constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion; + $update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion; } //"PHP-standardized" version - $latestVersion = mb_strtolower($latestVersion); - if (false !== mb_strpos($latestVersion, 'final')) { - $latestVersion = str_replace('_', '', mb_strtolower($latestVersion)); - $latestVersion = str_replace('final', '', mb_strtolower($latestVersion)); + $latestVersion = \mb_strtolower($latestVersion); + if (false !== \mb_strpos($latestVersion, 'final')) { + $latestVersion = \str_replace('_', '', \mb_strtolower($latestVersion)); + $latestVersion = \str_replace('final', '', \mb_strtolower($latestVersion)); } $moduleVersion = ($helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status')); //"PHP-standardized" version - $moduleVersion = str_replace(' ', '', mb_strtolower($moduleVersion)); + $moduleVersion = \str_replace(' ', '', \mb_strtolower($moduleVersion)); // $moduleVersion = '1.0'; //for testing only // $moduleDirName = 'publisher'; //for testing only - if (!$prerelease && version_compare($moduleVersion, $latestVersion, '<')) { + if (!$prerelease && \version_compare($moduleVersion, $latestVersion, '<')) { $ret = []; $ret[] = $update; $ret[] = $latestVersionLink; } } - curl_close($curlHandle); + \curl_close($curlHandle); } } return $ret; diff --git a/class/Downlimit.php b/class/Downlimit.php index 6febed8..5650f47 100644 --- a/class/Downlimit.php +++ b/class/Downlimit.php @@ -27,10 +27,10 @@ class Downlimit extends \XoopsObject public function __construct() { parent::__construct(); - $this->initVar('downlimit_id', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('downlimit_lid', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('downlimit_uid', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('downlimit_hostname', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('downlimit_date', XOBJ_DTYPE_INT, null, false, 10); + $this->initVar('downlimit_id', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('downlimit_lid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('downlimit_uid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('downlimit_hostname', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('downlimit_date', \XOBJ_DTYPE_INT, null, false, 10); } } diff --git a/class/Downloads.php b/class/Downloads.php index 66f1ad3..f15932f 100644 --- a/class/Downloads.php +++ b/class/Downloads.php @@ -27,31 +27,31 @@ class Downloads extends \XoopsObject // constructor public function __construct() { - $this->initVar('lid', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('cid', XOBJ_DTYPE_INT, null, false, 5); - $this->initVar('title', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('url', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('homepage', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('version', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('size', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('platform', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false); + $this->initVar('lid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('cid', \XOBJ_DTYPE_INT, null, false, 5); + $this->initVar('title', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('url', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('homepage', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('version', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('size', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('platform', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('description', \XOBJ_DTYPE_TXTAREA, null, false); // Pour autoriser le html - $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); - $this->initVar('logourl', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('submitter', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('status', XOBJ_DTYPE_INT, null, false, 2); - $this->initVar('date', XOBJ_DTYPE_INT, null, false, 10); - $this->initVar('hits', XOBJ_DTYPE_INT, null, false, 10); - $this->initVar('rating', XOBJ_DTYPE_OTHER, null, false, 10); - $this->initVar('votes', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('comments', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('top', XOBJ_DTYPE_INT, null, false, 2); - $this->initVar('paypal', XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('dohtml', \XOBJ_DTYPE_INT, 1, false); + $this->initVar('logourl', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('submitter', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('status', \XOBJ_DTYPE_INT, null, false, 2); + $this->initVar('date', \XOBJ_DTYPE_INT, null, false, 10); + $this->initVar('hits', \XOBJ_DTYPE_INT, null, false, 10); + $this->initVar('rating', \XOBJ_DTYPE_OTHER, null, false, 10); + $this->initVar('votes', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('comments', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('top', \XOBJ_DTYPE_INT, null, false, 2); + $this->initVar('paypal', \XOBJ_DTYPE_TXTBOX, null, false); //pour les jointures: - $this->initVar('cat_title', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('cat_imgurl', XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('cat_title', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('cat_imgurl', \XOBJ_DTYPE_TXTBOX, null, false); } /** @@ -82,14 +82,14 @@ public function getForm($donnee = [], $erreur = false, $action = false) $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); /** @var \XoopsModules\Tdmdownloads\Utility $utility */ $utility = new \XoopsModules\Tdmdownloads\Utility(); - $moduleDirName = basename(dirname(__DIR__)); + $moduleDirName = \basename(\dirname(__DIR__)); if (false === $action) { $action = $_SERVER['REQUEST_URI']; } //permission pour uploader /** @var \XoopsGroupPermHandler $grouppermHandler */ - $grouppermHandler = xoops_getHandler('groupperm'); - $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; + $grouppermHandler = \xoops_getHandler('groupperm'); + $groups = \is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; if ($xoopsUser) { $perm_upload = true; if (!$xoopsUser->isAdmin($xoopsModule->mid())) { @@ -99,7 +99,7 @@ public function getForm($donnee = [], $erreur = false, $action = false) $perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')); } //nom du formulaire selon l'action (editer ou ajouter): - $title = $this->isNew() ? sprintf(_AM_TDMDOWNLOADS_FORMADD) : sprintf(_AM_TDMDOWNLOADS_FORMEDIT); + $title = $this->isNew() ? \sprintf(_AM_TDMDOWNLOADS_FORMADD) : \sprintf(_AM_TDMDOWNLOADS_FORMEDIT); //création du formulaire $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); @@ -125,14 +125,14 @@ public function getForm($donnee = [], $erreur = false, $action = false) $criteria->setOrder('ASC'); if ($xoopsUser) { if (!$xoopsUser->isAdmin($xoopsModule->mid())) { - $criteria->add(new \Criteria('cat_cid', '(' . implode(',', $categories) . ')', 'IN')); + $criteria->add(new \Criteria('cat_cid', '(' . \implode(',', $categories) . ')', 'IN')); } } else { - $criteria->add(new \Criteria('cat_cid', '(' . implode(',', $categories) . ')', 'IN')); + $criteria->add(new \Criteria('cat_cid', '(' . \implode(',', $categories) . ')', 'IN')); } $downloadscatArray = $categoryHandler->getAll($criteria); if (empty($downloadscatArray)) { - redirect_header('index.php', 2, _NOPERM); + \redirect_header('index.php', 2, \_NOPERM); } $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); $form->addElement($mytree->makeSelectElement('cid', 'cat_title', '--', $this->getVar('cid'), true, 0, '', _AM_TDMDOWNLOADS_FORMINCAT), true); @@ -145,7 +145,7 @@ public function getForm($donnee = [], $erreur = false, $action = false) $criteria->setOrder('ASC'); /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloads_field */ $downloads_field = $fieldHandler->getAll($criteria); - foreach (array_keys($downloads_field) as $i) { + foreach (\array_keys($downloads_field) as $i) { /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ if (1 == $downloads_field[$i]->getVar('status_def')) { if (1 == $downloads_field[$i]->getVar('fid')) { @@ -167,10 +167,10 @@ public function getForm($donnee = [], $erreur = false, $action = false) if (3 == $downloads_field[$i]->getVar('fid')) { //taille du fichier if (1 == $downloads_field[$i]->getVar('status')) { - $size_value_arr = explode(' ', $this->getVar('size')); + $size_value_arr = \explode(' ', $this->getVar('size')); $aff_size = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMSIZE, ''); $aff_size->addElement(new \XoopsFormText('', 'sizeValue', 13, 13, $size_value_arr[0])); - if (array_key_exists(1, $size_value_arr) === false) { + if (\array_key_exists(1, $size_value_arr) === false) { $size_value_arr[1] = 'K'; } $type = new \XoopsFormSelect('', 'sizeType', $size_value_arr[1]); @@ -192,8 +192,8 @@ public function getForm($donnee = [], $erreur = false, $action = false) if (4 == $downloads_field[$i]->getVar('fid')) { //plateforme if (1 == $downloads_field[$i]->getVar('status')) { - $platformselect = new \XoopsFormSelect(_AM_TDMDOWNLOADS_FORMPLATFORM, 'platform', explode('|', $this->getVar('platform')), 5, true); - $platformArray = explode('|', $helper->getConfig('platform')); + $platformselect = new \XoopsFormSelect(_AM_TDMDOWNLOADS_FORMPLATFORM, 'platform', \explode('|', $this->getVar('platform')), 5, true); + $platformArray = \explode('|', $helper->getConfig('platform')); foreach ($platformArray as $platform) { $platformselect->addOption((string)$platform, $platform); } @@ -212,7 +212,7 @@ public function getForm($donnee = [], $erreur = false, $action = false) $criteria->add(new \Criteria('lid', $this->getVar('lid'))); $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid'))); $downloadsfielddata = $fielddataHandler->getAll($criteria); - foreach (array_keys($downloadsfielddata) as $j) { + foreach (\array_keys($downloadsfielddata) as $j) { /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloadsfielddata */ if (true === $erreur) { $contenu = $donnee[$fieldName]; @@ -246,7 +246,7 @@ public function getForm($donnee = [], $erreur = false, $action = false) $form->addElement(new \XoopsFormEditor(_AM_TDMDOWNLOADS_FORMTEXTDOWNLOADS, 'description', $editorConfigs), true); //tag - if ((1 == $helper->getConfig('usetag')) && class_exists(FormTag::class)) { + if ((1 == $helper->getConfig('usetag')) && \class_exists(FormTag::class)) { $tagId = $this->isNew() ? 0 : $this->getVar('lid'); if (true === $erreur) { $tagId = $donnee['TAG']; @@ -258,12 +258,12 @@ public function getForm($donnee = [], $erreur = false, $action = false) if ($helper->getConfig('useshots')) { $uploaddir = XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/shots/' . $this->getVar('logourl'); $categoryImage = $this->getVar('logourl') ?: 'blank.gif'; - if (!is_file($uploaddir)) { + if (!\is_file($uploaddir)) { $categoryImage = 'blank.gif'; } $uploadirectory = '/uploads/' . $moduleDirName . '/images/shots'; $imgtray = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMIMG, '
      '); - $imgpath = sprintf(_AM_TDMDOWNLOADS_FORMPATH, $uploadirectory); + $imgpath = \sprintf(_AM_TDMDOWNLOADS_FORMPATH, $uploadirectory); $imageselect = new \XoopsFormSelect($imgpath, 'logo_img', $categoryImage); $topics_array = \XoopsLists:: getImgListAsArray(XOOPS_ROOT_PATH . $uploadirectory); foreach ($topics_array as $image) { @@ -306,12 +306,12 @@ public function getForm($donnee = [], $erreur = false, $action = false) $selection_date = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMDATEUPDATE); $date = new \XoopsFormRadio('', 'date_update', $date_update); $options = [ - 'N' => _AM_TDMDOWNLOADS_FORMDATEUPDATE_NO . ' (' . formatTimestamp($v_date, 's') . ')', + 'N' => _AM_TDMDOWNLOADS_FORMDATEUPDATE_NO . ' (' . \formatTimestamp($v_date, 's') . ')', 'Y' => _AM_TDMDOWNLOADS_FORMDATEUPDATE_YES, ]; $date->addOptionArray($options); $selection_date->addElement($date); - $selection_date->addElement(new \XoopsFormTextDateSelect('', 'date', '', time())); + $selection_date->addElement(new \XoopsFormTextDateSelect('', 'date', '', \time())); $form->addElement($selection_date); } $status = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_FORMSTATUS, 'status', $v_status); @@ -320,14 +320,14 @@ public function getForm($donnee = [], $erreur = false, $action = false) //permissions pour télécharger if (2 == $helper->getConfig('permission_download')) { /** @var \XoopsMemberHandler $memberHandler */ - $memberHandler = xoops_getHandler('member'); + $memberHandler = \xoops_getHandler('member'); $group_list = $memberHandler->getGroupList(); - $grouppermHandler = xoops_getHandler('groupperm'); - $full_list = array_keys($group_list); + $grouppermHandler = \xoops_getHandler('groupperm'); + $full_list = \array_keys($group_list); global $xoopsModule; if (!$this->isNew()) { $item_ids_download = $grouppermHandler->getGroupIds('tdmdownloads_download_item', $this->getVar('lid'), $xoopsModule->getVar('mid')); - $item_ids_downloa = array_values($item_ids_download); + $item_ids_downloa = \array_values($item_ids_download); $item_news_can_download_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_FORMPERMDOWNLOAD, 'item_download[]', $item_ids_download); } else { $item_news_can_download_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_FORMPERMDOWNLOAD, 'item_download[]', $full_list); @@ -353,7 +353,7 @@ public function getForm($donnee = [], $erreur = false, $action = false) //pour enregistrer le formulaire $form->addElement(new \XoopsFormHidden('op', 'save_downloads')); //bouton d'envoi du formulaire - $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', 'submit', false)); + $form->addElement(new \XoopsFormButtonTray('', \_SUBMIT, 'submit', 'submit', false)); return $form; } diff --git a/class/Field.php b/class/Field.php index 029d217..3c8fca5 100644 --- a/class/Field.php +++ b/class/Field.php @@ -25,16 +25,16 @@ class Field extends \XoopsObject // constructor public function __construct() { - $this->initVar('fid', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('title', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('img', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('weight', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('status', XOBJ_DTYPE_INT, null, false, 5); - $this->initVar('search', XOBJ_DTYPE_INT, null, false, 5); - $this->initVar('status_def', XOBJ_DTYPE_INT, null, false, 5); + $this->initVar('fid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('title', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('img', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('weight', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('status', \XOBJ_DTYPE_INT, null, false, 5); + $this->initVar('search', \XOBJ_DTYPE_INT, null, false, 5); + $this->initVar('status_def', \XOBJ_DTYPE_INT, null, false, 5); //pour les jointures - $this->initVar('data', XOBJ_DTYPE_TXTAREA, null, false); + $this->initVar('data', \XOBJ_DTYPE_TXTAREA, null, false); } /** @@ -62,14 +62,14 @@ public function getForm($action = false) /** @var \XoopsModules\Tdmdownloads\Helper $helper */ $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); - $moduleDirName = basename(dirname(__DIR__)); + $moduleDirName = \basename(\dirname(__DIR__)); if (false === $action) { $action = $_SERVER['REQUEST_URI']; } require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; //nom du formulaire selon l'action (editer ou ajouter): - $title = $this->isNew() ? sprintf(_AM_TDMDOWNLOADS_FORMADD) : sprintf(_AM_TDMDOWNLOADS_FORMEDIT); + $title = $this->isNew() ? \sprintf(_AM_TDMDOWNLOADS_FORMADD) : \sprintf(_AM_TDMDOWNLOADS_FORMEDIT); //création du formulaire $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); @@ -85,7 +85,7 @@ public function getForm($action = false) $downloadsfield_img = $this->getVar('img') ?: 'blank.gif'; $uploadirectory = '/uploads/' . $moduleDirName . '/images/field'; $imgtray = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMIMAGE, '
      '); - $imgpath = sprintf(_AM_TDMDOWNLOADS_FORMPATH, $uploadirectory); + $imgpath = \sprintf(_AM_TDMDOWNLOADS_FORMPATH, $uploadirectory); $imageselect = new \XoopsFormSelect($imgpath, 'downloadsfield_img', $downloadsfield_img); $topics_array = \XoopsLists:: getImgListAsArray(XOOPS_ROOT_PATH . $uploadirectory); foreach ($topics_array as $image) { @@ -117,7 +117,7 @@ public function getForm($action = false) //pour enregistrer le formulaire $form->addElement(new \XoopsFormHidden('op', 'save_field')); //boutton d'envoi du formulaire - $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', 'submit', false)); + $form->addElement(new \XoopsFormButtonTray('', \_SUBMIT, 'submit', 'submit', false)); return $form; } diff --git a/class/Fielddata.php b/class/Fielddata.php index e3a8897..6d5f6c7 100644 --- a/class/Fielddata.php +++ b/class/Fielddata.php @@ -25,10 +25,10 @@ class Fielddata extends \XoopsObject // constructor public function __construct() { - $this->initVar('iddata', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('fid', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('lid', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('data', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); + $this->initVar('iddata', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('fid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('lid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('data', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('dohtml', \XOBJ_DTYPE_INT, 1, false); } } diff --git a/class/Form/UploadForm.php b/class/Form/UploadForm.php index 5cf7a6d..9fe205d 100644 --- a/class/Form/UploadForm.php +++ b/class/Form/UploadForm.php @@ -27,13 +27,13 @@ use Xmf\Request; use XoopsModules\Tdmdownloads; -require_once dirname(dirname(__DIR__)) . '/include/common.php'; +require_once \dirname(\dirname(__DIR__)) . '/include/common.php'; //$moduleDirName = basename(dirname(dirname(__DIR__))); //$helper = Tdmdownloads\Helper::getInstance(); $permHelper = new \Xmf\Module\Helper\Permission(); -xoops_load('XoopsFormLoader'); +\xoops_load('XoopsFormLoader'); /** * Class FieldForm @@ -50,14 +50,14 @@ class UploadForm extends \XoopsThemeForm */ public function __construct($target) { - $moduleDirName = basename(dirname(dirname(__DIR__))); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); /** @var \XoopsModules\Tdmdownloads\Helper $this ->helper */ $this->helper = $target->helper; $this->targetObject = $target; - $title = $this->targetObject->isNew() ? sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_ADD')) : sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_EDIT')); - parent::__construct('', 'form', xoops_getenv('SCRIPT_NAME'), 'post', true); + $title = $this->targetObject->isNew() ? \sprintf(\constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_ADD')) : \sprintf(\constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_EDIT')); + parent::__construct('', 'form', \xoops_getenv('SCRIPT_NAME'), 'post', true); $this->setExtra('enctype="multipart/form-data"'); //include ID field, it's needed so the module knows if it is a new form or an edited form @@ -79,19 +79,19 @@ public function __construct($target) $catArray = $categoryHandler->getAll($criteria); // Form Select Category - $categoryIdSelect = new \XoopsFormSelect(constant('CO_' . $moduleDirNameUpper . '_' . 'SELECT'), 'cat_title', $this->targetObject->getVar('cat_cid')); + $categoryIdSelect = new \XoopsFormSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'SELECT'), 'cat_title', $this->targetObject->getVar('cat_cid')); $categoryIdSelect->setExtra('onchange="submit()"'); // $categoryIdSelect->addOption(0, ' '); - foreach (array_keys($catArray) as $i) { + foreach (\array_keys($catArray) as $i) { $catName = $catArray[$i]->getVar('cat_title'); $catPid = $catArray[$i]->getVar('cat_pid'); if (0 < $catPid) { $categoryObj = $categoryHandler->get($catPid); - if (is_object($categoryObj)) { + if (\is_object($categoryObj)) { $catName .= ' (' . $categoryObj->getVar('cat_title') . ')'; } else { - $catName .= ' (' . constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR_CATPID') . ')'; + $catName .= ' (' . \constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR_CATPID') . ')'; } } $categoryIdSelect->addOption($catArray[$i]->getVar('cat_cid'), $catName); diff --git a/class/Helper.php b/class/Helper.php index 3def733..82d9e97 100644 --- a/class/Helper.php +++ b/class/Helper.php @@ -35,7 +35,7 @@ class Helper extends \Xmf\Module\Helper public function __construct($debug = false) { $this->debug = $debug; - $moduleDirName = basename(dirname(__DIR__)); + $moduleDirName = \basename(\dirname(__DIR__)); parent::__construct($moduleDirName); } @@ -73,8 +73,8 @@ public function getHandler($name) { $ret = false; - $class = __NAMESPACE__ . '\\' . ucfirst($name) . 'Handler'; - if (!class_exists($class)) { + $class = __NAMESPACE__ . '\\' . \ucfirst($name) . 'Handler'; + if (!\class_exists($class)) { throw new \RuntimeException("Class '$class' not found"); } /** @var \XoopsMySQLDatabase $db */ diff --git a/class/Modified.php b/class/Modified.php index 00be50d..83e9074 100644 --- a/class/Modified.php +++ b/class/Modified.php @@ -28,20 +28,20 @@ class Modified extends \XoopsObject // constructor public function __construct() { - $this->initVar('requestid', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('lid', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('cid', XOBJ_DTYPE_INT, null, false, 5); - $this->initVar('title', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('url', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('homepage', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('version', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('size', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('platform', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('logourl', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false); + $this->initVar('requestid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('lid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('cid', \XOBJ_DTYPE_INT, null, false, 5); + $this->initVar('title', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('url', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('homepage', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('version', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('size', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('platform', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('logourl', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('description', \XOBJ_DTYPE_TXTAREA, null, false); // Pour autoriser le html - $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); - $this->initVar('modifysubmitter', XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('dohtml', \XOBJ_DTYPE_INT, 1, false); + $this->initVar('modifysubmitter', \XOBJ_DTYPE_INT, null, false, 11); } /** @@ -72,13 +72,13 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) /** @var \XoopsModules\Tdmdownloads\Helper $helper */ $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); - $moduleDirName = basename(dirname(__DIR__)); + $moduleDirName = \basename(\dirname(__DIR__)); if (false === $action) { $action = $_SERVER['REQUEST_URI']; } - $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; + $groups = \is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; /** @var \XoopsGroupPermHandler $grouppermHandler */ - $grouppermHandler = xoops_getHandler('groupperm'); + $grouppermHandler = \xoops_getHandler('groupperm'); $perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')); //appel des class /** @var \XoopsModules\Tdmdownloads\DownloadsHandler $downloadsHandler */ @@ -106,7 +106,7 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) } //nom du formulaire - $title = sprintf(_AM_TDMDOWNLOADS_FORMEDIT); + $title = \sprintf(_AM_TDMDOWNLOADS_FORMEDIT); //création du formulaire $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); @@ -134,14 +134,14 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) $criteria->setOrder('ASC'); if ($xoopsUser) { if (!$xoopsUser->isAdmin($xoopsModule->mid())) { - $criteria->add(new \Criteria('cat_cid', '(' . implode(',', $categories) . ')', 'IN')); + $criteria->add(new \Criteria('cat_cid', '(' . \implode(',', $categories) . ')', 'IN')); } } else { - $criteria->add(new \Criteria('cat_cid', '(' . implode(',', $categories) . ')', 'IN')); + $criteria->add(new \Criteria('cat_cid', '(' . \implode(',', $categories) . ')', 'IN')); } $downloadscatArray = $categoryHandler->getAll($criteria); if (empty($downloadscatArray)) { - redirect_header('index.php', 2, _NOPERM); + \redirect_header('index.php', 2, \_NOPERM); } $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); $form->addElement($mytree->makeSelectElement('cid', 'cat_title', '--', $d_cid, true, 0, '', _AM_TDMDOWNLOADS_FORMINCAT), true); @@ -152,7 +152,7 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) $criteria->setSort('weight ASC, title'); $criteria->setOrder('ASC'); $downloads_field = $fieldHandler->getAll($criteria); - foreach (array_keys($downloads_field) as $i) { + foreach (\array_keys($downloads_field) as $i) { /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ if (1 == $downloads_field[$i]->getVar('status_def')) { if (1 == $downloads_field[$i]->getVar('fid')) { @@ -174,10 +174,10 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) if (3 == $downloads_field[$i]->getVar('fid')) { //taille du fichier if (1 == $downloads_field[$i]->getVar('status')) { - $size_value_arr = explode(' ', $viewDownloads->getVar('size')); + $size_value_arr = \explode(' ', $viewDownloads->getVar('size')); $aff_size = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMSIZE, ''); $aff_size->addElement(new \XoopsFormText('', 'sizeValue', 13, 13, $size_value_arr[0])); - if (array_key_exists(1, $size_value_arr) === false) { + if (\array_key_exists(1, $size_value_arr) === false) { $size_value_arr[1] = 'K'; } $type = new \XoopsFormSelect('', 'sizeType', $size_value_arr[1]); @@ -199,8 +199,8 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) if (4 == $downloads_field[$i]->getVar('fid')) { //plateforme if (1 == $downloads_field[$i]->getVar('status')) { - $platformselect = new \XoopsFormSelect(_AM_TDMDOWNLOADS_FORMPLATFORM, 'platform', explode('|', $d_platform), 5, true); - $platformArray = explode('|', $helper->getConfig('platform')); + $platformselect = new \XoopsFormSelect(_AM_TDMDOWNLOADS_FORMPLATFORM, 'platform', \explode('|', $d_platform), 5, true); + $platformArray = \explode('|', $helper->getConfig('platform')); foreach ($platformArray as $platform) { $platformselect->addOption((string)$platform, $platform); } @@ -218,7 +218,7 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) $criteria->add(new \Criteria('lid', $viewDownloads->getVar('lid'))); $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid'))); $downloadsfielddata = $fielddataHandler->getAll($criteria); - foreach (array_keys($downloadsfielddata) as $j) { + foreach (\array_keys($downloadsfielddata) as $j) { /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloadsfielddata */ if (true === $erreur) { $contenu = $donnee[$fieldName]; @@ -248,11 +248,11 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) $uploaddir = XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/shots/' . $viewDownloads->getVar('logourl'); $categoryImage = $viewDownloads->getVar('logourl') ?: 'blank.gif'; $uploadirectory = '/uploads/' . $moduleDirName . '/images/shots'; - if (!is_file($uploaddir)) { + if (!\is_file($uploaddir)) { $categoryImage = 'blank.gif'; } $imgtray = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMIMG, '
      '); - $imgpath = sprintf(_AM_TDMDOWNLOADS_FORMPATH, $uploadirectory); + $imgpath = \sprintf(_AM_TDMDOWNLOADS_FORMPATH, $uploadirectory); $imageselect = new \XoopsFormSelect($imgpath, 'logo_img', $categoryImage); $topics_array = \XoopsLists:: getImgListAsArray(XOOPS_ROOT_PATH . $uploadirectory); foreach ($topics_array as $image) { @@ -273,7 +273,7 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) //pour enregistrer le formulaire $form->addElement(new \XoopsFormHidden('op', 'save')); //bouton d'envoi du formulaire - $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', 'submit', false)); + $form->addElement(new \XoopsFormButtonTray('', \_SUBMIT, 'submit', 'submit', false)); return $form; } diff --git a/class/Modifiedfielddata.php b/class/Modifiedfielddata.php index 8a14dfc..50f03f8 100644 --- a/class/Modifiedfielddata.php +++ b/class/Modifiedfielddata.php @@ -25,10 +25,10 @@ class Modifiedfielddata extends \XoopsObject // constructor public function __construct() { - $this->initVar('modiddata', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('fid', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('lid', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('moddata', XOBJ_DTYPE_TXTAREA, null, false); - $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); + $this->initVar('modiddata', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('fid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('lid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('moddata', \XOBJ_DTYPE_TXTAREA, null, false); + $this->initVar('dohtml', \XOBJ_DTYPE_INT, 1, false); } } diff --git a/class/Rating.php b/class/Rating.php index ff024ba..c152b51 100644 --- a/class/Rating.php +++ b/class/Rating.php @@ -25,12 +25,12 @@ class Rating extends \XoopsObject // constructor public function __construct() { - $this->initVar('ratingid', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('lid', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('ratinguser', XOBJ_DTYPE_INT, null, false, 11); - $this->initVar('rating', XOBJ_DTYPE_OTHER, null, false, 3); - $this->initVar('ratinghostname', XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar('ratingtimestamp', XOBJ_DTYPE_INT, null, false, 10); + $this->initVar('ratingid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('lid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('ratinguser', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('rating', \XOBJ_DTYPE_OTHER, null, false, 3); + $this->initVar('ratinghostname', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('ratingtimestamp', \XOBJ_DTYPE_INT, null, false, 10); } /** diff --git a/class/Utilities.php b/class/Utilities.php index 8664d0a..c97b405 100644 --- a/class/Utilities.php +++ b/class/Utilities.php @@ -41,13 +41,13 @@ public static function getItemIds($permtype, $dirname) { global $xoopsUser; $permissions = []; - if (is_array($permissions) && array_key_exists($permtype, $permissions)) { + if (\is_array($permissions) && \array_key_exists($permtype, $permissions)) { return $permissions[$permtype]; } - $moduleHandler = xoops_getHandler('module'); + $moduleHandler = \xoops_getHandler('module'); $tdmModule = $moduleHandler->getByDirname($dirname); - $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; - $grouppermHandler = xoops_getHandler('groupperm'); + $groups = \is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; + $grouppermHandler = \xoops_getHandler('groupperm'); $categories = $grouppermHandler->getItemIds($permtype, $groups, $tdmModule->getVar('mid')); return $categories; @@ -67,13 +67,13 @@ public static function getNumbersOfEntries($mytree, $categories, $entries, $cid) { $count = 0; $child_arr = []; - if (in_array($cid, $categories)) { + if (\in_array($cid, $categories)) { $child = $mytree->getAllChild($cid); - foreach (array_keys($entries) as $i) { + foreach (\array_keys($entries) as $i) { if ($entries[$i]->getVar('cid') === $cid) { ++$count; } - foreach (array_keys($child) as $j) { + foreach (\array_keys($child) as $j) { if ($entries[$i]->getVar('cid') === $j) { ++$count; } @@ -92,29 +92,29 @@ public static function getNumbersOfEntries($mytree, $categories, $entries, $cid) */ public static function getStatusImage($time, $status) { - $moduleDirName = basename(dirname(__DIR__)); + $moduleDirName = \basename(\dirname(__DIR__)); /** @var Tdmdownloads\Helper $helper */ $helper = Tdmdownloads\Helper::getInstance(); $count = 7; $new = ''; - $startdate = (time() - (86400 * $count)); + $startdate = (\time() - (86400 * $count)); if (1 == $helper->getConfig('showupdated')) { if ($startdate < $time) { $language = $GLOBALS['xoopsConfig']['language']; - if (!is_dir(XOOPS_ROOT_PATH . "/modules/$moduleDirName/language/" . $language . '/')) { + if (!\is_dir(XOOPS_ROOT_PATH . "/modules/$moduleDirName/language/" . $language . '/')) { $language = 'english'; } $img_path = XOOPS_ROOT_PATH . "/modules/$moduleDirName/language/" . $language . '/'; $img_url = XOOPS_URL . "/modules/$moduleDirName/language/" . $language . '/'; if (1 == $status) { - if (is_readable($img_path . 'new.png')) { + if (\is_readable($img_path . 'new.png')) { $new = ' ' . _MD_TDMDOWNLOADS_INDEX_NEWTHISWEEK . ''; } else { $new = ' ' . _MD_TDMDOWNLOADS_INDEX_NEWTHISWEEK . ''; } } elseif (2 == $status) { - if (is_readable($img_path . 'updated.png')) { + if (\is_readable($img_path . 'updated.png')) { $new = ' ' . _MD_TDMDOWNLOADS_INDEX_UPTHISWEEK . ''; } else { $new = ' ' . _MD_TDMDOWNLOADS_INDEX_UPTHISWEEK . ''; @@ -136,16 +136,16 @@ public static function getPopularImage($hits) /** @var Tdmdownloads\Helper $helper */ $helper = Tdmdownloads\Helper::getInstance(); - $moduleDirName = basename(dirname(__DIR__)); + $moduleDirName = \basename(\dirname(__DIR__)); $pop = ''; if ($hits >= $helper->getConfig('popular')) { $language = $GLOBALS['xoopsConfig']['language']; - if (!is_dir(XOOPS_ROOT_PATH . "/modules/$moduleDirName/language/" . $language . '/')) { + if (!\is_dir(XOOPS_ROOT_PATH . "/modules/$moduleDirName/language/" . $language . '/')) { $language = 'english'; } $img_path = XOOPS_ROOT_PATH . "/modules/$moduleDirName/language/" . $language . '/'; $img_url = XOOPS_URL . "/modules/$moduleDirName/language/" . $language . '/'; - if (is_readable($img_path . 'popular.png')) { + if (\is_readable($img_path . 'popular.png')) { $pop = ' ' . _MD_TDMDOWNLOADS_INDEX_POPULAR . ''; } else { $pop = ' ' . _MD_TDMDOWNLOADS_INDEX_POPULAR . ''; @@ -194,15 +194,15 @@ public static function cleanVars($global, $key, $default = '', $type = 'int') { switch ($type) { case 'string': - if (defined('FILTER_SANITIZE_ADD_SLASHES')) { - $ret = isset($global[$key]) ? filter_var($global[$key], FILTER_SANITIZE_ADD_SLASHES) : $default; + if (\defined('FILTER_SANITIZE_ADD_SLASHES')) { + $ret = isset($global[$key]) ? \filter_var($global[$key], \FILTER_SANITIZE_ADD_SLASHES) : $default; } else { - $ret = isset($global[$key]) ? filter_var($global[$key], FILTER_SANITIZE_MAGIC_QUOTES) : $default; + $ret = isset($global[$key]) ? \filter_var($global[$key], \FILTER_SANITIZE_MAGIC_QUOTES) : $default; } break; case 'int': default: - $ret = isset($global[$key]) ? filter_var($global[$key], FILTER_SANITIZE_NUMBER_INT) : $default; + $ret = isset($global[$key]) ? \filter_var($global[$key], \FILTER_SANITIZE_NUMBER_INT) : $default; break; } if (false === $ret) { @@ -224,13 +224,13 @@ public static function cleanVars($global, $key, $default = '', $type = 'int') public static function getPathTree($mytree, $key, $category_array, $title, $prefix = '') { $category_parent = $mytree->getAllParent($key); - $category_parent = array_reverse($category_parent); + $category_parent = \array_reverse($category_parent); $Path = ''; - foreach (array_keys($category_parent) as $j) { + foreach (\array_keys($category_parent) as $j) { $Path .= $category_parent[$j]->getVar($title) . $prefix; } $first_category = ''; - if (array_key_exists($key, $category_array)) { + if (\array_key_exists($key, $category_array)) { $first_category = $category_array[$key]->getVar($title); } $Path .= $first_category; @@ -263,7 +263,7 @@ public static function getPathTreeUrl( global $xoopsModule; $category_parent = $mytree->getAllParent($key); if ('ASC' === $order) { - $category_parent = array_reverse($category_parent); + $category_parent = \array_reverse($category_parent); if (true === $link) { $Path = '' . $xoopsModule->name() . '' . $prefix; } else { @@ -271,12 +271,12 @@ public static function getPathTreeUrl( } } else { $first_category = ''; - if (array_key_exists($key, $category_array)) { + if (\array_key_exists($key, $category_array)) { $first_category = $category_array[$key]->getVar($title); } $Path = $first_category . $prefix; } - foreach (array_keys($category_parent) as $j) { + foreach (\array_keys($category_parent) as $j) { if (true === $link) { $Path .= '' . $category_parent[$j]->getVar($title) . '' . $prefix; } else { @@ -284,7 +284,7 @@ public static function getPathTreeUrl( } } if ('ASC' === $order) { - if (array_key_exists($key, $category_array)) { + if (\array_key_exists($key, $category_array)) { if (true === $lasturl) { $first_category = '' . $category_array[$key]->getVar($title) . ''; } else { @@ -314,16 +314,16 @@ public static function getPathTreeUrl( */ public static function createFolder($path, $mode, $fileSource, $fileTarget = null) { - if (!@mkdir($path, $mode) && !is_dir($path)) { - throw new \RuntimeException(sprintf('Unable to create the %s directory', $path)); + if (!@\mkdir($path, $mode) && !\is_dir($path)) { + throw new \RuntimeException(\sprintf('Unable to create the %s directory', $path)); } file_put_contents($path . '/index.html', ''); if (!empty($fileSource) && !empty($fileTarget)) { - @copy($fileSource, $fileTarget); + @\copy($fileSource, $fileTarget); } - chmod($path, $mode); + \chmod($path, $mode); } /** @@ -333,23 +333,23 @@ public static function createFolder($path, $mode, $fileSource, $fileTarget = nul */ public static function cloneFolder($pathSource, $pathTarget) { - if (is_dir($pathSource)) { + if (\is_dir($pathSource)) { // Create new dir - if (!mkdir($pathTarget) && !is_dir($pathTarget)) { - throw new \RuntimeException(sprintf('Unable to create the %s directory', $pathTarget)); + if (!\mkdir($pathTarget) && !\is_dir($pathTarget)) { + throw new \RuntimeException(\sprintf('Unable to create the %s directory', $pathTarget)); } // check all files in dir, and process it - $handle = opendir($pathSource); + $handle = \opendir($pathSource); if ($handle) { - while ($file = readdir($handle)) { + while ($file = \readdir($handle)) { if ('.' !== $file && '..' !== $file) { self::cloneFolder("$pathSource/$file", "$pathTarget/$file"); } } - closedir($handle); + \closedir($handle); } } else { - copy($pathSource, $pathTarget); + \copy($pathSource, $pathTarget); } } @@ -362,8 +362,8 @@ public static function cloneFolder($pathSource, $pathTarget) */ public static function prepareFolder($folder) { - if (!@mkdir($folder) && !is_dir($folder)) { - throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); + if (!@\mkdir($folder) && !\is_dir($folder)) { + throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder)); } file_put_contents($folder . '/index.html', ''); } diff --git a/class/Utility.php b/class/Utility.php index 6a400db..2e0c4e3 100644 --- a/class/Utility.php +++ b/class/Utility.php @@ -35,16 +35,16 @@ public function getItemIds($permtype, $dirname) { global $xoopsUser; static $permissions = []; - if (is_array($permissions) && array_key_exists($permtype, $permissions)) { + if (\is_array($permissions) && \array_key_exists($permtype, $permissions)) { return $permissions[$permtype]; } /** @var \XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); + $moduleHandler = \xoops_getHandler('module'); $tdmModule = $moduleHandler->getByDirname($dirname); - $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; + $groups = \is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; /** @var \XoopsGroupPermHandler $grouppermHandler */ - $grouppermHandler = xoops_getHandler('groupperm'); + $grouppermHandler = \xoops_getHandler('groupperm'); $categories = $grouppermHandler->getItemIds($permtype, $groups, $tdmModule->getVar('mid')); return $categories; @@ -62,14 +62,14 @@ public function getNumbersOfEntries($mytree, $categories, $entries, $cid) { $count = 0; $child_arr = []; - if (in_array($cid, $categories)) { + if (\in_array($cid, $categories)) { $child = $mytree->getAllChild($cid); - foreach (array_keys($entries) as $i) { + foreach (\array_keys($entries) as $i) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $entries */ if ($entries[$i]->getVar('cid') == $cid) { $count++; } - foreach (array_keys($child) as $j) { + foreach (\array_keys($child) as $j) { if ($entries[$i]->getVar('cid') == $j) { $count++; } @@ -91,23 +91,23 @@ public function getStatusImage($time, $status) global $xoopsModuleConfig; $count = 7; $new = ''; - $startdate = (time() - (86400 * $count)); + $startdate = (\time() - (86400 * $count)); if (1 == $xoopsModuleConfig['showupdated']) { if ($startdate < $time) { $language = $GLOBALS['xoopsConfig']['language']; - if (!is_dir(XOOPS_ROOT_PATH . '/modules/tdmdownloads/language/' . $language . '/')) { + if (!\is_dir(XOOPS_ROOT_PATH . '/modules/tdmdownloads/language/' . $language . '/')) { $language = 'english'; } $img_path = XOOPS_ROOT_PATH . '/modules/tdmdownloads/language/' . $language . '/'; $img_url = XOOPS_URL . '/modules/tdmdownloads/language/' . $language . '/'; if (1 == $status) { - if (is_readable($img_path . 'new.png')) { + if (\is_readable($img_path . 'new.png')) { $new = ' ' . _MD_TDMDOWNLOADS_INDEX_NEWTHISWEEK . ''; } else { $new = ' ' . _MD_TDMDOWNLOADS_INDEX_NEWTHISWEEK . ''; } } elseif (2 == $status) { - if (is_readable($img_path . 'updated.png')) { + if (\is_readable($img_path . 'updated.png')) { $new = ' ' . _MD_TDMDOWNLOADS_INDEX_UPTHISWEEK . ''; } else { $new = ' ' . _MD_TDMDOWNLOADS_INDEX_UPTHISWEEK . ''; @@ -130,12 +130,12 @@ public function getPopularImage($hits) $pop = ''; if ($hits >= $xoopsModuleConfig['popular']) { $language = $GLOBALS['xoopsConfig']['language']; - if (!is_dir(XOOPS_ROOT_PATH . '/modules/tdmdownloads/language/' . $language . '/')) { + if (!\is_dir(XOOPS_ROOT_PATH . '/modules/tdmdownloads/language/' . $language . '/')) { $language = 'english'; } $img_path = XOOPS_ROOT_PATH . '/modules/tdmdownloads/language/' . $language . '/'; $img_url = XOOPS_URL . '/modules/tdmdownloads/language/' . $language . '/'; - if (is_readable($img_path . 'popular.png')) { + if (\is_readable($img_path . 'popular.png')) { $pop = ' ' . _MD_TDMDOWNLOADS_INDEX_POPULAR . ''; } else { $pop = ' ' . _MD_TDMDOWNLOADS_INDEX_POPULAR . ''; @@ -154,11 +154,11 @@ public static function prettifyBytes($size) if ($size > 0) { $mb = 1024 * 1024; if ($size > $mb) { - $mysize = sprintf('%01.2f', $size / $mb) . ' MB'; + $mysize = \sprintf('%01.2f', $size / $mb) . ' MB'; } elseif ($size >= 1024) { - $mysize = sprintf('%01.2f', $size / 1024) . ' KB'; + $mysize = \sprintf('%01.2f', $size / 1024) . ' KB'; } else { - $mysize = sprintf(_AM_TDMDOWNLOADS_NUMBYTES, $size); + $mysize = \sprintf(_AM_TDMDOWNLOADS_NUMBYTES, $size); } return $mysize; @@ -178,11 +178,11 @@ public static function cleanVars($global, $key, $default = '', $type = 'int') { switch ($type) { case 'string': - $ret = isset($global[$key]) ? filter_var($global[$key], FILTER_SANITIZE_MAGIC_QUOTES) : $default; + $ret = isset($global[$key]) ? \filter_var($global[$key], \FILTER_SANITIZE_MAGIC_QUOTES) : $default; break; case 'int': default: - $ret = isset($global[$key]) ? filter_var($global[$key], FILTER_SANITIZE_NUMBER_INT) : $default; + $ret = isset($global[$key]) ? \filter_var($global[$key], \FILTER_SANITIZE_NUMBER_INT) : $default; break; } if (false === $ret) { @@ -204,13 +204,13 @@ public static function getPathTree($mytree, $key, $category_array, $title, $pref { /** @var \XoopsObjectTree $mytree */ $categoryParent = $mytree->getAllParent($key); - $categoryParent = array_reverse($categoryParent); + $categoryParent = \array_reverse($categoryParent); $path = ''; - foreach (array_keys($categoryParent) as $j) { + foreach (\array_keys($categoryParent) as $j) { /** @var \XoopsModules\Tdmdownloads\Category[] $categoryParent */ $path .= $categoryParent[$j]->getVar($title) . $prefix; } - if (array_key_exists($key, $category_array)) { + if (\array_key_exists($key, $category_array)) { /** @var \XoopsModules\Tdmdownloads\Category[] $category_array */ $firstCategory = $category_array[$key]->getVar($title); } else { @@ -237,14 +237,14 @@ public static function getPathTreeUrl($mytree, $key, $category_array, $title, $p global $xoopsModule; $categoryParent = $mytree->getAllParent($key); if ('ASC' === $order) { - $categoryParent = array_reverse($categoryParent); + $categoryParent = \array_reverse($categoryParent); if (true === $link) { $path = '' . $xoopsModule->name() . '' . $prefix; } else { $path = $xoopsModule->name() . $prefix; } } else { - if (array_key_exists($key, $category_array)) { + if (\array_key_exists($key, $category_array)) { /** @var \XoopsModules\Tdmdownloads\Category[] $category_array */ $firstCategory = $category_array[$key]->getVar($title); } else { @@ -252,7 +252,7 @@ public static function getPathTreeUrl($mytree, $key, $category_array, $title, $p } $path = $firstCategory . $prefix; } - foreach (array_keys($categoryParent) as $j) { + foreach (\array_keys($categoryParent) as $j) { /** @var \XoopsModules\Tdmdownloads\Category[] $categoryParent */ if (true === $link) { $path .= '' . $categoryParent[$j]->getVar($title) . '' . $prefix; @@ -261,7 +261,7 @@ public static function getPathTreeUrl($mytree, $key, $category_array, $title, $p } } if ('ASC' === $order) { - if (array_key_exists($key, $category_array)) { + if (\array_key_exists($key, $category_array)) { if (true === $lasturl) { $firstCategory = '' . $category_array[$key]->getVar($title) . ''; } else { @@ -294,7 +294,7 @@ public static function convertStringToSize($stringSize) $kb = 1024; $mb = 1024 * 1024; $gb = 1024 * 1024 * 1024; - $size_value_arr = explode(' ', $stringSize); + $size_value_arr = \explode(' ', $stringSize); if ($size_value_arr[1] == 'B') { $mysize = $size_value_arr[0]; @@ -321,8 +321,8 @@ public static function convertSizeToString($sizeString) { $mysizeString = ''; if ($sizeString != '') { - $size_value_arr = explode(' ', $sizeString); - if (array_key_exists(0, $size_value_arr) === true && array_key_exists(1, $size_value_arr) === true) { + $size_value_arr = \explode(' ', $sizeString); + if (\array_key_exists(0, $size_value_arr) === true && \array_key_exists(1, $size_value_arr) === true) { if ($size_value_arr[0] != '') { $mysizeString = ''; switch ($size_value_arr[1]) { @@ -361,19 +361,19 @@ public static function convertSizeToString($sizeString) */ public static function getFileSize($url) { - if (function_exists('curl_init') && false !== ($curlHandle = curl_init($url))) { - curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curlHandle, CURLOPT_HEADER, true); - curl_setopt($curlHandle, CURLOPT_NOBODY, true); - curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized' - $curlReturn = curl_exec($curlHandle); + if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init($url))) { + \curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); + \curl_setopt($curlHandle, \CURLOPT_HEADER, true); + \curl_setopt($curlHandle, \CURLOPT_NOBODY, true); + \curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized' + $curlReturn = \curl_exec($curlHandle); if (false === $curlReturn) { - trigger_error(curl_error($curlHandle)); + \trigger_error(\curl_error($curlHandle)); $size = 0; } else { - $size = curl_getinfo($curlHandle, CURLINFO_CONTENT_LENGTH_DOWNLOAD); + $size = \curl_getinfo($curlHandle, \CURLINFO_CONTENT_LENGTH_DOWNLOAD); } - curl_close($curlHandle); + \curl_close($curlHandle); if ($size <= 0) { return 0; } @@ -397,13 +397,13 @@ public static function convertFileSize($size) $mb = 1024 * 1024; $gb = 1024 * 1024 * 1024; if ($size >= $gb) { - $mysize = sprintf("%01.2f", $size / $gb) . " " . 'G'; + $mysize = \sprintf("%01.2f", $size / $gb) . " " . 'G'; } elseif ($size >= $mb) { - $mysize = sprintf("%01.2f", $size / $mb) . " " . 'M'; + $mysize = \sprintf("%01.2f", $size / $mb) . " " . 'M'; } elseif ($size >= $kb) { - $mysize = sprintf("%01.2f", $size / $kb) . " " . 'K'; + $mysize = \sprintf("%01.2f", $size / $kb) . " " . 'K'; } else { - $mysize = sprintf("%01.2f", $size) . " " . 'B'; + $mysize = \sprintf("%01.2f", $size) . " " . 'B'; } return $mysize; @@ -418,7 +418,7 @@ public static function convertFileSize($size) */ public static function returnBytes($val) { - switch (mb_substr($val, -1)) { + switch (\mb_substr($val, -1)) { case 'K': case 'k': return (int)$val * 1024; From d90bceb4b0a809318e374fdc5c73b486d5b3b729 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 21:44:32 -0400 Subject: [PATCH 19/62] move Constants --- class/Common/SysUtility.php | 1 + class/{Common/ModuleConstants.php => Constants.php} | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) rename class/{Common/ModuleConstants.php => Constants.php} (98%) diff --git a/class/Common/SysUtility.php b/class/Common/SysUtility.php index cb80f2a..e62ae01 100644 --- a/class/Common/SysUtility.php +++ b/class/Common/SysUtility.php @@ -27,6 +27,7 @@ use XoopsFormDhtmlTextArea; use XoopsFormTextArea; use XoopsModules\Tdmdownloads; +use XoopsModules\Tdmdownloads\Helper; /** * Class SysUtility diff --git a/class/Common/ModuleConstants.php b/class/Constants.php similarity index 98% rename from class/Common/ModuleConstants.php rename to class/Constants.php index 6d5ad6e..4973d6c 100644 --- a/class/Common/ModuleConstants.php +++ b/class/Constants.php @@ -1,6 +1,6 @@ Date: Sun, 17 May 2020 21:44:43 -0400 Subject: [PATCH 20/62] delete assign_globals.php --- include/assign_globals.php | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 include/assign_globals.php diff --git a/include/assign_globals.php b/include/assign_globals.php deleted file mode 100644 index 1218c41..0000000 --- a/include/assign_globals.php +++ /dev/null @@ -1,31 +0,0 @@ - _ALBM_CAPTION_TOTAL, - 'mod_url' => $mod_url, - 'mod_copyright' => $mod_copyright, - 'lang_latest_list' => _ALBM_LATESTLIST, - 'lang_descriptionc' => _ALBM_DESCRIPTIONC, - 'lang_lastupdatec' => _ALBM_LASTUPDATEC, - 'lang_submitter' => _ALBM_SUBMITTER, - 'lang_hitsc' => _ALBM_HITSC, - 'lang_commentsc' => _ALBM_COMMENTSC, - 'lang_new' => _ALBM_NEW, - 'lang_updated' => _ALBM_UPDATED, - 'lang_popular' => _ALBM_POPULAR, - 'lang_ratethisphoto' => _ALBM_RATETHISPHOTO, - 'lang_editthisphoto' => _ALBM_EDITTHISPHOTO, - 'lang_deletethisphoto' => _ALBM_DELETE_THIS_PHOTO, - 'lang_guestname' => _ALBM_CAPTION_GUESTNAME, - 'lang_category' => _ALBM_CAPTION_CATEGORY, - 'lang_nomatch' => _ALBM_NOMATCH, - 'lang_directcatsel' => _ALBM_DIRECTCATSEL, - 'photos_url' => $photos_url, - 'thumbs_url' => $thumbs_url, - 'thumbsize' => $myalbum_thumbsize, - 'colsoftableview' => $myalbum_colsoftableview, - 'canrateview' => $GLOBALS['global_perms'] && GPERM_RATEVIEW, - 'canratevote' => $GLOBALS['global_perms'] && GPERM_RATEVOTE, -]; From 7ca7d0901f0c95804def5d93bdb6d7fbedf72ae9 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 22:11:35 -0400 Subject: [PATCH 21/62] Request::getCmd() --- admin/broken.php | 2 +- admin/category.php | 2 +- admin/downloads.php | 2 +- admin/field.php | 2 +- admin/import.php | 2 +- admin/modified.php | 2 +- modfile.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/admin/broken.php b/admin/broken.php index eaf5246..8eb12c0 100644 --- a/admin/broken.php +++ b/admin/broken.php @@ -23,7 +23,7 @@ $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); //On recupere la valeur de l'argument op dans l'URL$ -$op = \Xmf\Request::getString('op', 'list'); +$op = \Xmf\Request::getCmd('op', 'list'); //Les valeurs de op qui vont permettre d'aller dans les differentes parties de la page switch ($op) { diff --git a/admin/category.php b/admin/category.php index 237ff72..81658d4 100644 --- a/admin/category.php +++ b/admin/category.php @@ -23,7 +23,7 @@ /** @var \XoopsModules\Tdmdownloads\Helper $helper */ $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); //On recupere la valeur de l'argument op dans l'URL$ -$op = \Xmf\Request::getString('op', 'list'); +$op = \Xmf\Request::getCmd('op', 'list'); //Les valeurs de op qui vont permettre d'aller dans les differentes parties de la page switch ($op) { diff --git a/admin/downloads.php b/admin/downloads.php index 50d5500..6594fad 100644 --- a/admin/downloads.php +++ b/admin/downloads.php @@ -29,7 +29,7 @@ $myts = \MyTextSanitizer::getInstance(); //On recupere la valeur de l'argument op dans l'URL$ -$op = \Xmf\Request::getString('op', 'list'); +$op = \Xmf\Request::getCmd('op', 'list'); // compte le nombre de téléchargement non validé $criteria = new \CriteriaCompo(); diff --git a/admin/field.php b/admin/field.php index bea6ad6..5475189 100644 --- a/admin/field.php +++ b/admin/field.php @@ -23,7 +23,7 @@ $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); //On recupere la valeur de l'argument op dans l'URL$ -$op = \Xmf\Request::getString('op', 'list'); +$op = \Xmf\Request::getCmd('op', 'list'); //Les valeurs de op qui vont permettre d'aller dans les differentes parties de la page switch ($op) { diff --git a/admin/import.php b/admin/import.php index 7b59f53..2c7b7c7 100644 --- a/admin/import.php +++ b/admin/import.php @@ -25,7 +25,7 @@ //Action dans switch $op = 'index'; if (\Xmf\Request::hasVar('op', 'REQUEST')) { - $op = \Xmf\Request::getString('op', '', 'REQUEST'); + $op = \Xmf\Request::getCmd('op', '', 'REQUEST'); } $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); diff --git a/admin/modified.php b/admin/modified.php index c8b86dc..930726b 100644 --- a/admin/modified.php +++ b/admin/modified.php @@ -23,7 +23,7 @@ $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); //On recupere la valeur de l'argument op dans l'URL$ -$op = \Xmf\Request::getString('op', 'list'); +$op = \Xmf\Request::getCmd('op', 'list'); xoops_cp_header(); diff --git a/modfile.php b/modfile.php index 75b5ebe..b1833a7 100644 --- a/modfile.php +++ b/modfile.php @@ -28,7 +28,7 @@ $xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $moduleDirName . '/assets/css/styles.css', null); //On recupere la valeur de l'argument op dans l'URL$ -$op = \Xmf\Request::getString('op', 'list'); +$op = \Xmf\Request::getCmd('op', 'list'); // redirection si pas de droit pour poster if (false === $perm_modif) { From ac988face1b5c99a50a42254e17027f6be1490a7 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 22:12:03 -0400 Subject: [PATCH 22/62] missing language constants --- language/english/blocksadmin.php | 3 +++ language/french/blocksadmin.php | 3 +++ language/german/blocksadmin.php | 3 +++ 3 files changed, 9 insertions(+) diff --git a/language/english/blocksadmin.php b/language/english/blocksadmin.php index 6d005af..838bf7c 100644 --- a/language/english/blocksadmin.php +++ b/language/english/blocksadmin.php @@ -37,3 +37,6 @@ define('_AM_ALLMODULEPAGES', 'Groups'); define('_AM_SYSTEMLEVEL', '_AM_SYSTEMLEVEL'); define('_AM_ADMINBLOCK', '_AM_ADMINBLOCK'); +define('_AM_BLOCKTAG1', '%s will print %s'); +define('_AM_ADDBLOCK', 'Add Block'); +define('_AM_NOTSELNG', 'Not Sel'); diff --git a/language/french/blocksadmin.php b/language/french/blocksadmin.php index 991a175..033db41 100644 --- a/language/french/blocksadmin.php +++ b/language/french/blocksadmin.php @@ -34,3 +34,6 @@ define('_AM_ALLMODULEPAGES', 'Groups'); define('_AM_SYSTEMLEVEL', '_AM_SYSTEMLEVEL'); define('_AM_ADMINBLOCK', '_AM_ADMINBLOCK'); +define('_AM_BLOCKTAG1', '%s will print %s'); +define('_AM_ADDBLOCK', 'Add Block'); +define('_AM_NOTSELNG', 'Not Sel'); diff --git a/language/german/blocksadmin.php b/language/german/blocksadmin.php index 4c15784..7da91a2 100644 --- a/language/german/blocksadmin.php +++ b/language/german/blocksadmin.php @@ -34,3 +34,6 @@ define('_AM_ALLMODULEPAGES', 'Gruppen'); define('_AM_SYSTEMLEVEL', '_AM_SYSTEMLEVEL'); define('_AM_ADMINBLOCK', '_AM_ADMINBLOCK'); +define('_AM_BLOCKTAG1', '%s will print %s'); +define('_AM_ADDBLOCK', 'Add Block'); +define('_AM_NOTSELNG', 'Not Sel'); From c190f54eaa77ec1528ef7a5243d20be974003ef8 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 22:12:23 -0400 Subject: [PATCH 23/62] ImageResizer trait --- class/Common/SysUtility.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/class/Common/SysUtility.php b/class/Common/SysUtility.php index e62ae01..8fa794e 100644 --- a/class/Common/SysUtility.php +++ b/class/Common/SysUtility.php @@ -46,6 +46,8 @@ class SysUtility // Files Management Trait + use ImageResizer; + /** * truncateHtml can truncate a string up to a number of characters while preserving whole words and HTML tags * www.gsdesign.ro/blog/cut-html-string-without-breaking-the-tags From 5a9e64196d265d4d3f37cafa11e2d9c61d572a0e Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 22:12:40 -0400 Subject: [PATCH 24/62] dynamic variables --- class/Category.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/class/Category.php b/class/Category.php index 28f2ab1..a9c5000 100644 --- a/class/Category.php +++ b/class/Category.php @@ -26,6 +26,8 @@ class Category extends \XoopsObject { // constructor + public $helper; + public $permHelper; /** * Category constructor. From efb371a0615d2dbae3195fea12f46d0a259f0e78 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 22:12:47 -0400 Subject: [PATCH 25/62] cosmetics --- class/Form/UploadForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/Form/UploadForm.php b/class/Form/UploadForm.php index 9fe205d..75281f7 100644 --- a/class/Form/UploadForm.php +++ b/class/Form/UploadForm.php @@ -52,7 +52,7 @@ public function __construct($target) { $moduleDirName = \basename(\dirname(\dirname(__DIR__))); $moduleDirNameUpper = \mb_strtoupper($moduleDirName); - /** @var \XoopsModules\Tdmdownloads\Helper $this ->helper */ + /** @var \XoopsModules\Tdmdownloads\Helper $this->helper */ $this->helper = $target->helper; $this->targetObject = $target; From c1d59069e01326286b1cfdddc23508f4fadf9e93 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 22:15:24 -0400 Subject: [PATCH 26/62] PSR-12 Short form of type keywords --- class/Common/ImagesHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/Common/ImagesHandler.php b/class/Common/ImagesHandler.php index 1b8ab8d..ba2c495 100644 --- a/class/Common/ImagesHandler.php +++ b/class/Common/ImagesHandler.php @@ -52,7 +52,7 @@ public function get($i = null, $fields = null) * get inserted id * * @param null - * @return integer reference to the {@link Get} object + * @return int reference to the {@link Get} object */ public function getInsertId() { From 3342e1a31f2e6290eaf5629dcc37aaaf9bf08350 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 22:16:36 -0400 Subject: [PATCH 27/62] 'FILTER_SANITIZE_ADD_SLASHES' starts in 7.3 PHP --- class/Utilities.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/class/Utilities.php b/class/Utilities.php index c97b405..ff79824 100644 --- a/class/Utilities.php +++ b/class/Utilities.php @@ -195,9 +195,9 @@ public static function cleanVars($global, $key, $default = '', $type = 'int') switch ($type) { case 'string': if (\defined('FILTER_SANITIZE_ADD_SLASHES')) { - $ret = isset($global[$key]) ? \filter_var($global[$key], \FILTER_SANITIZE_ADD_SLASHES) : $default; + $ret = isset($global[$key]) ? \filter_var($global[$key]) : $default; } else { - $ret = isset($global[$key]) ? \filter_var($global[$key], \FILTER_SANITIZE_MAGIC_QUOTES) : $default; + $ret = isset($global[$key]) ? \filter_var($global[$key]) : $default; } break; case 'int': From dec4adee5b0728c8e843c40a01afbc56c4b943e3 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 22:18:35 -0400 Subject: [PATCH 28/62] Yoda --- admin/downloads.php | 6 +++--- class/Downloads.php | 2 +- class/Modified.php | 2 +- class/Utility.php | 14 +++++++------- modfile.php | 6 +++--- submit.php | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/admin/downloads.php b/admin/downloads.php index 6594fad..5012a2e 100644 --- a/admin/downloads.php +++ b/admin/downloads.php @@ -682,8 +682,8 @@ $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'POST')); } //Automatic file size - if (Xmf\Request::getString('sizeValue', '') == '') { - if ($mediaSize == 0) { + if ('' == Xmf\Request::getString('sizeValue', '')) { + if (0 == $mediaSize) { $obj->setVar('size', $utility::getFileSize(Xmf\Request::getUrl('url', ''))); } else { $obj->setVar('size', $utility::convertFileSize($mediaSize)); @@ -692,7 +692,7 @@ $obj->setVar('size', Xmf\Request::getFloat('sizeValue', 0) . ' ' . Xmf\Request::getString('sizeType', '')); } $timeToRedirect = 2; - if ($obj->getVar('size') == 0) { + if (0 == $obj->getVar('size')) { $obj->setVar('size', ''); $error_message = _AM_TDMDOWNLOADS_ERREUR_SIZE; $timeToRedirect = 10; diff --git a/class/Downloads.php b/class/Downloads.php index f15932f..6361e60 100644 --- a/class/Downloads.php +++ b/class/Downloads.php @@ -170,7 +170,7 @@ public function getForm($donnee = [], $erreur = false, $action = false) $size_value_arr = \explode(' ', $this->getVar('size')); $aff_size = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMSIZE, ''); $aff_size->addElement(new \XoopsFormText('', 'sizeValue', 13, 13, $size_value_arr[0])); - if (\array_key_exists(1, $size_value_arr) === false) { + if (false === \array_key_exists(1, $size_value_arr)) { $size_value_arr[1] = 'K'; } $type = new \XoopsFormSelect('', 'sizeType', $size_value_arr[1]); diff --git a/class/Modified.php b/class/Modified.php index 83e9074..041301a 100644 --- a/class/Modified.php +++ b/class/Modified.php @@ -177,7 +177,7 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) $size_value_arr = \explode(' ', $viewDownloads->getVar('size')); $aff_size = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMSIZE, ''); $aff_size->addElement(new \XoopsFormText('', 'sizeValue', 13, 13, $size_value_arr[0])); - if (\array_key_exists(1, $size_value_arr) === false) { + if (false === \array_key_exists(1, $size_value_arr)) { $size_value_arr[1] = 'K'; } $type = new \XoopsFormSelect('', 'sizeType', $size_value_arr[1]); diff --git a/class/Utility.php b/class/Utility.php index 2e0c4e3..0c082e5 100644 --- a/class/Utility.php +++ b/class/Utility.php @@ -290,17 +290,17 @@ public static function getPathTreeUrl($mytree, $key, $category_array, $title, $p */ public static function convertStringToSize($stringSize) { - if ($stringSize != '') { + if ('' != $stringSize) { $kb = 1024; $mb = 1024 * 1024; $gb = 1024 * 1024 * 1024; $size_value_arr = \explode(' ', $stringSize); - if ($size_value_arr[1] == 'B') { + if ('B' == $size_value_arr[1]) { $mysize = $size_value_arr[0]; - } elseif ($size_value_arr[1] == 'K') { + } elseif ('K' == $size_value_arr[1]) { $mysize = $size_value_arr[0] * $kb; - } elseif ($size_value_arr[1] == 'M') { + } elseif ('M' == $size_value_arr[1]) { $mysize = $size_value_arr[0] * $mb; } else { $mysize = $size_value_arr[0] * $gb; @@ -320,10 +320,10 @@ public static function convertStringToSize($stringSize) public static function convertSizeToString($sizeString) { $mysizeString = ''; - if ($sizeString != '') { + if ('' != $sizeString) { $size_value_arr = \explode(' ', $sizeString); - if (\array_key_exists(0, $size_value_arr) === true && \array_key_exists(1, $size_value_arr) === true) { - if ($size_value_arr[0] != '') { + if (true === \array_key_exists(0, $size_value_arr) && true === \array_key_exists(1, $size_value_arr)) { + if ('' != $size_value_arr[0]) { $mysizeString = ''; switch ($size_value_arr[1]) { case 'B': diff --git a/modfile.php b/modfile.php index b1833a7..07f428a 100644 --- a/modfile.php +++ b/modfile.php @@ -214,8 +214,8 @@ $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'REQUEST')); } //Automatic file size - if (Xmf\Request::getString('sizeValue', '') == '') { - if ($mediaSize == 0) { + if ('' == Xmf\Request::getString('sizeValue', '')) { + if (0 == $mediaSize) { $obj->setVar('size', $utility::getFileSize(Xmf\Request::getUrl('url', ''))); } else { $obj->setVar('size', $utility::convertFileSize($mediaSize)); @@ -224,7 +224,7 @@ $obj->setVar('size', Xmf\Request::getFloat('sizeValue', 0) . ' ' . Xmf\Request::getString('sizeType', '')); } $timeToRedirect = 2; - if ($obj->getVar('size') == 0) { + if (0 == $obj->getVar('size')) { $obj->setVar('size', ''); $error_message = _AM_TDMDOWNLOADS_ERREUR_SIZE; $timeToRedirect = 10; diff --git a/submit.php b/submit.php index a1c6e03..0ffe3d7 100644 --- a/submit.php +++ b/submit.php @@ -216,8 +216,8 @@ $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'REQUEST')); } //Automatic file size - if (Xmf\Request::getString('sizeValue', '') == '') { - if ($mediaSize == 0) { + if ('' == Xmf\Request::getString('sizeValue', '')) { + if (0 == $mediaSize) { $obj->setVar('size', $utility::getFileSize(Xmf\Request::getUrl('url', ''))); } else { $obj->setVar('size', $utility::convertFileSize($mediaSize)); @@ -226,7 +226,7 @@ $obj->setVar('size', Xmf\Request::getFloat('sizeValue', 0) . ' ' . Xmf\Request::getString('sizeType', '')); } $timeToRedirect = 2; - if ($obj->getVar('size') == 0) { + if (0 == $obj->getVar('size')) { $obj->setVar('size', ''); $error_message = _AM_TDMDOWNLOADS_ERREUR_SIZE; $timeToRedirect = 10; From 0efc8dab8f049692c67f7a58fea52371a1c6afdc Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 22:19:55 -0400 Subject: [PATCH 29/62] Redundant 'else' keyword --- class/Utility.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/class/Utility.php b/class/Utility.php index 0c082e5..09a6b6e 100644 --- a/class/Utility.php +++ b/class/Utility.php @@ -379,9 +379,9 @@ public static function getFileSize($url) } return self::convertFileSize($size); - } else { - return 0; } + + return 0; } /** From c0855dd4cb4034e3bf4c645230900618ac9fe4bb Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 22:23:28 -0400 Subject: [PATCH 30/62] duplicates --- language/french/admin.php | 1 - language/german/admin.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/language/french/admin.php b/language/french/admin.php index a5ffb0c..e2c893a 100644 --- a/language/french/admin.php +++ b/language/french/admin.php @@ -186,4 +186,3 @@ define('_AM_TDMDOWNLOADS_ERROR_BAD_REMOVE', 'Impossible de supprimer %s'); define('_AM_TDMDOWNLOADS_ERROR_NO_PLUGIN', 'Impossible de charger le plug-in'); define('_AM_TDMDOWNLOADS_NUMBYTES', '%s octets'); -define('_AM_TDMDOWNLOADS_NUMBYTES', '%s octets'); diff --git a/language/german/admin.php b/language/german/admin.php index ff0fb2a..bd13861 100644 --- a/language/german/admin.php +++ b/language/german/admin.php @@ -123,7 +123,7 @@ define('_AM_TDMDOWNLOADS_FORMPLATFORM', 'Plattform: '); define('_AM_TDMDOWNLOADS_FORMPOSTER', 'Eingesendet von '); define('_AM_TDMDOWNLOADS_FORMRATING', 'Bewertung'); -define('_AM_TDMDOWNLOADS_FORMSIZE', 'Dateigröße'); +//define('_AM_TDMDOWNLOADS_FORMSIZE', 'Dateigröße'); define('_AM_TDMDOWNLOADS_FORMSIZE', "Dateigröße
      Um das automatische System zur Berechnung der Dateigröße zu verwenden, lassen Sie dieses Feld leer."); define('_AM_TDMDOWNLOADS_FORMSTATUS', 'Download Status'); define('_AM_TDMDOWNLOADS_FORMSTATUS_OK', 'Bestätigt'); From c5f51d7c471841db17c7dddb1235b3d76da9832b Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 22:25:47 -0400 Subject: [PATCH 31/62] English --- CONTRIBUTING.md | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 722ef9b..fa7d1a0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,7 +11,7 @@ We accept contributions via Pull Requests on [Github](https://github.com/XoopsMo - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). - **Add tests!** - We encourage providing tests for your contributions. -- **Document any change in behavior** - Make sure the `/docs/changelog.txt` and any other relevant documentation are kept up-to-date. +- **Document any change in behavior** - Make sure the `/docs/changelog.txt` and any other relevant documentation are up-to-date. - **Consider our release cycle** - We try to follow [Semantic Versioning v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. - **Create feature branches** - Don't ask us to pull from your master branch. - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. diff --git a/README.md b/README.md index e5059fa..57f63f4 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ [![Latest Pre-Release](https://img.shields.io/github/tag/XoopsModules25x/tdmdownloads.svg?style=flat)](https://github.com/XoopsModules25x/tdmdownloads/tags/) [![Latest Version](https://img.shields.io/github/release/XoopsModules25x/tdmdownloads.svg?style=flat)](https://github.com/XoopsModules25x/tdmdownloads/releases/) -**TdmDownloads** module for [XOOPS CMS](https://xoops.org) creates a downloads section where users can download/submit/rate various files.. +**TdmDownloads** module for [XOOPS CMS](https://xoops.org) creates a Downloads section where users can download/submit/rate various files. [![Tutorial Available](https://xoops.org/images/tutorial-available-blue.svg)](https://xoops.gitbook.io/tdmdownloads-tutorial/) Tutorial: see [GitBook](https://xoops.gitbook.io/tdmdownloads-tutorial/). To contribute to the Tutorial, [fork it on GitHub](https://github.com/XoopsDocs/tdmdownloads-tutorial) @@ -19,4 +19,4 @@ To contribute to the Tutorial, [fork it on GitHub](https://github.com/XoopsDocs/ Please visit us on https://xoops.org -Current and upcoming "next generation" versions of XOOPS CMS are being crafted on GitHub at: https://github.com/XOOPS +Current and upcoming "next generation" versions of XOOPS CMS are crafted on GitHub at: https://github.com/XOOPS From 4e337f7557ae4968a370a5c5ccc11b2c194bf827 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 23:06:28 -0400 Subject: [PATCH 32/62] PHP 7.1 --- admin/about.php | 4 +- admin/admin_footer.php | 4 +- admin/admin_header.php | 6 +- admin/blockform.php | 14 +- admin/blocksadmin.php | 246 +++++++++++++--- admin/broken.php | 22 +- admin/category.php | 223 +++++++++++++-- admin/downloads.php | 258 +++++++++++++++-- admin/field.php | 51 +++- admin/import.php | 81 +++++- admin/index.php | 6 +- admin/menu.php | 4 +- admin/migrate.php | 6 +- admin/modified.php | 98 ++++++- admin/permissions.php | 16 +- blocks/tdmdownloads_search.php | 117 +++++++- blocks/tdmdownloads_top.php | 211 +++++++++++--- brokenfile.php | 23 +- class/Broken.php | 21 +- class/BrokenHandler.php | 5 +- class/Category.php | 149 ++++++++-- class/CategoryHandler.php | 5 +- class/Common/Breadcrumb.php | 10 +- class/Common/Configurator.php | 40 ++- class/Common/FilesManagement.php | 41 ++- class/Common/FineimpuploadHandler.php | 130 +++++++-- class/Common/ImageResizer.php | 75 +++-- class/Common/Images.php | 206 +++++++++++--- class/Common/ImagesHandler.php | 29 +- class/Common/Migrate.php | 25 +- class/Common/ServerStats.php | 45 ++- class/Common/SysUtility.php | 77 +++-- class/Common/VersionChecks.php | 80 ++++-- class/Constants.php | 58 +++- class/Downlimit.php | 8 +- class/DownlimitHandler.php | 5 +- class/Downloads.php | 263 +++++++++++++++--- class/DownloadsHandler.php | 5 +- class/Field.php | 65 ++++- class/FieldHandler.php | 5 +- class/Fielddata.php | 8 +- class/FielddataHandler.php | 5 +- class/Form/UploadForm.php | 39 ++- class/Helper.php | 18 +- class/Modified.php | 208 +++++++++++--- class/ModifiedHandler.php | 5 +- class/Modifiedfielddata.php | 8 +- class/ModifiedfielddataHandler.php | 5 +- class/Rating.php | 28 +- class/RatingHandler.php | 5 +- class/Tree.php | 8 +- class/Utilities.php | 113 ++++++-- class/Utility.php | 121 +++++--- comment_delete.php | 3 +- comment_edit.php | 3 +- comment_new.php | 14 +- comment_post.php | 3 +- comment_reply.php | 3 +- config/config.php | 5 +- config/icons.php | 2 +- config/imageconfig.php | 3 +- config/paths.php | 6 +- extra/plugins/sitemap/tdmdownloads.php | 7 +- extra/plugins/tag/tdmdownloads.php | 22 +- extra/plugins/waiting/tdmdownloads.php | 34 ++- .../whatsnew/tdmdownloads/data.inc.php | 57 ++-- header.php | 5 +- include/comment_functions.php | 8 +- include/common.php | 17 +- include/notification.inc.php | 44 ++- include/oninstall.php | 87 +++++- include/onupdate.php | 80 +++++- include/search.inc.php | 32 ++- index.php | 143 ++++++++-- language/english/admin.php | 5 +- language/english/blocks.php | 2 +- language/english/blocksadmin.php | 3 +- language/english/common.php | 4 +- language/english/main.php | 3 +- language/english/modinfo.php | 4 +- language/french/admin.php | 3 +- language/french/blocks.php | 2 +- language/french/blocksadmin.php | 3 +- language/french/common.php | 4 +- language/french/main.php | 3 +- language/french/modinfo.php | 3 +- language/german/admin.php | 3 +- language/german/blocks.php | 2 +- language/german/blocksadmin.php | 3 +- language/german/common.php | 4 +- language/german/main.php | 3 +- language/german/modinfo.php | 3 +- list.tag.php | 4 +- modfile.php | 94 ++++++- notification_update.php | 4 +- preloads/autoloader.php | 10 +- preloads/core.php | 5 +- ratefile.php | 47 +++- rss.php | 29 +- search.php | 111 +++++++- singlefile.php | 72 +++-- submit.php | 120 ++++++-- templates/admin/tdmdownloads_admin_footer.tpl | 4 +- .../blocks/tdmdownloads_block_stylesimple.tpl | 71 ++--- templates/tdmdownloads_footer.tpl | 5 +- testdata/index.php | 58 +++- upload.php | 47 +++- view.tag.php | 4 +- viewcat.php | 131 ++++++++- visit.php | 43 ++- xoops_version.php | 7 +- 111 files changed, 3926 insertions(+), 883 deletions(-) diff --git a/admin/about.php b/admin/about.php index 5d76351..81db103 100644 --- a/admin/about.php +++ b/admin/about.php @@ -1,4 +1,5 @@ -display("db:{$templateMain}"); } diff --git a/admin/admin_header.php b/admin/admin_header.php index 5c56a12..26192b9 100644 --- a/admin/admin_header.php +++ b/admin/admin_header.php @@ -1,4 +1,5 @@ -isAdmin($xoopsModule->mid())) { redirect_header(XOOPS_URL . '/', 3, _NOPERM); } @@ -49,6 +51,7 @@ if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) { require_once $GLOBALS['xoops']->path('class/template.php'); + $xoopsTpl = new \XoopsTpl(); } @@ -62,6 +65,7 @@ if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) { require_once $GLOBALS['xoops']->path('class/theme.php'); + $GLOBALS['xoTheme'] = new \xos_opal_Theme(); } diff --git a/admin/blockform.php b/admin/blockform.php index 4bed7b3..408bda6 100644 --- a/admin/blockform.php +++ b/admin/blockform.php @@ -1,4 +1,4 @@ -addElement(new \XoopsFormText(_AM_TITLE, 'btitle', 50, 255, $block['title']), false); if ($block['is_custom']) { $textarea = new \XoopsFormDhtmlTextArea(_AM_SYSTEM_BLOCKS_CONTENT, 'bcontent', $block['content'], 15, 70); + $textarea->setDescription('' . _AM_SYSTEM_BLOCKS_USEFULTAGS . '
      ' . sprintf(_AM_BLOCKTAG1, '{X_SITEURL}', XOOPS_URL . '/') . ''); + $form->addElement($textarea, true); + $ctype_select = new \XoopsFormSelect(_AM_SYSTEM_BLOCKS_CTYPE, 'bctype', $block['ctype']); + $ctype_select->addOptionArray( [ 'H' => _AM_SYSTEM_BLOCKS_HTML, @@ -63,23 +67,31 @@ 'T' => _AM_SYSTEM_BLOCKS_AFNOSMILE, ] ); + $form->addElement($ctype_select); } else { if ('' !== $block['template']) { /** @var XoopsTplfileHandler $tplfileHandler */ + $tplfileHandler = xoops_getHandler('tplfile'); + /** @var \XoopsTplfile[] $btemplate */ + $btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']); + if (count($btemplate) > 0) { $form->addElement(new \XoopsFormLabel(_AM_SYSTEM_BLOCKS_CONTENT, '' . _AM_SYSTEM_BLOCKS_EDITTPL . '')); } else { /** @var \XoopsTplfile[] $btemplate2 */ + $btemplate2 = $tplfileHandler->find('default', 'block', $block['bid']); + if (count($btemplate2) > 0) { $form->addElement(new \XoopsFormLabel(_AM_SYSTEM_BLOCKS_CONTENT, '' . _AM_SYSTEM_BLOCKS_EDITTPL . '')); } } } + if (false !== $block['edit_form']) { $form->addElement(new \XoopsFormLabel(_AM_SYSTEM_BLOCKS_OPTIONS, $block['edit_form'])); } diff --git a/admin/blocksadmin.php b/admin/blocksadmin.php index 79d59b3..1844a88 100644 --- a/admin/blocksadmin.php +++ b/admin/blocksadmin.php @@ -1,4 +1,5 @@ -isAdmin($xoopsModule->mid())) { require_once XOOPS_ROOT_PATH . '/class/xoopsblock.php'; + $op = 'list'; + if (isset($_POST)) { foreach ($_POST as $k => $v) { ${$k} = $v; } } + /* if (Request::hasVar('op')) { if ($_GET['op'] === "edit" || $_GET['op'] === "delete" || $_GET['op'] === "delete_ok" || $_GET['op'] === "clone" @@ -44,6 +48,7 @@ */ $op = Request::getString('op', $op); + if (in_array($op, ['edit', 'delete', 'delete_ok', 'clone'])) { $bid = Request::getInt('bid', 0, 'GET'); } @@ -51,33 +56,58 @@ function listBlocks() { global $xoopsModule, $pathIcon16; + require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; - $moduleDirName = basename(dirname(__DIR__)); + + $moduleDirName = basename(dirname(__DIR__)); + $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName + /** @var \XoopsMySQLDatabase $db */ + $db = \XoopsDatabaseFactory::getDatabaseConnection(); + xoops_loadLanguage('admin', 'system'); + xoops_loadLanguage('admin/blocksadmin', 'system'); + xoops_loadLanguage('admin/groups', 'system'); /** @var \XoopsModuleHandler $moduleHandler */ + $moduleHandler = xoops_getHandler('module'); + /** @var \XoopsMemberHandler $memberHandler */ + $memberHandler = xoops_getHandler('member'); + /** @var \XoopsGroupPermHandler $grouppermHandler */ + $grouppermHandler = xoops_getHandler('groupperm'); - $groups = $memberHandler->getGroups(); - $criteria = new \CriteriaCompo(new \Criteria('hasmain', 1)); + + $groups = $memberHandler->getGroups(); + + $criteria = new \CriteriaCompo(new \Criteria('hasmain', 1)); + $criteria->add(new \Criteria('isactive', 1)); - $module_list = $moduleHandler->getList($criteria); + + $module_list = $moduleHandler->getList($criteria); + $module_list[-1] = _AM_SYSTEM_BLOCKS_TOPPAGE; - $module_list[0] = _AM_SYSTEM_BLOCKS_ALLPAGES; + + $module_list[0] = _AM_SYSTEM_BLOCKS_ALLPAGES; + ksort($module_list); + echo "

      " . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . '

      '; + $moduleHandler = xoops_getHandler('module'); + echo ""; + echo $GLOBALS['xoopsSecurity']->getTokenHTML(); + echo " '; - $block_arr = \XoopsBlock::getByModule($xoopsModule->mid()); + $block_arr = \XoopsBlock::getByModule($xoopsModule->mid()); + $block_count = count($block_arr); - $class = 'even'; - $cachetimes = [ + + $class = 'even'; + + $cachetimes = [ '0' => _NOCACHE, '30' => sprintf(_SECONDS, 30), '60' => _MINUTE, @@ -122,17 +155,24 @@ function listBlocks() '604800' => _WEEK, '2592000' => _MONTH, ]; + foreach ($block_arr as $i) { /** @var \XoopsBlock $i */ + $groups_perms = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid')); - $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid'); - $result = $db->query($sql); - $modules = []; + + $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid'); + + $result = $db->query($sql); + + $modules = []; + while (false !== ($row = $db->fetchArray($result))) { $modules[] = (int)$row['module_id']; } $cachetime_options = ''; + foreach ($cachetimes as $cachetime => $cachetime_name) { if ($i->getVar('bcachetime') == $cachetime) { $cachetime_options .= "\n"; @@ -142,11 +182,13 @@ function listBlocks() } $sel0 = $sel1 = $ssel0 = $ssel1 = $ssel2 = $ssel3 = $ssel4 = $ssel5 = $ssel6 = $ssel7 = ''; + if (1 === $i->getVar('visible')) { $sel1 = ' checked'; } else { $sel0 = ' checked'; } + if (XOOPS_SIDEBLOCK_LEFT === $i->getVar('side')) { $ssel0 = ' checked'; } elseif (XOOPS_SIDEBLOCK_RIGHT === $i->getVar('side')) { @@ -164,12 +206,15 @@ function listBlocks() } elseif (XOOPS_CENTERBLOCK_BOTTOM === $i->getVar('side')) { $ssel7 = ' checked'; } + if ('' === $i->getVar('title')) { $title = ' '; } else { $title = $i->getVar('title'); } + $name = $i->getVar('name'); + echo "'; echo "'; // Cache lifetime + echo ''; @@ -257,10 +308,12 @@ function listBlocks() echo " "; - $class = ('even' === $class) ? 'odd' : 'even'; + + $class = 'even' === $class ? 'odd' : 'even'; } + echo "'; + $compare['cfields'][] = ['info' => $downloads_field[$i]->getVar('title'), 'current' => $contenu, 'modified' => $contentModified]; } } @@ -196,30 +236,46 @@ if (true === \Xmf\Request::getBool('new_file', false, 'REQUEST')) { $urlfile = substr_replace($obj->getVar('url'), '', 0, mb_strlen($uploadurl_downloads)); + // permet de donner le chemin du fichier + $urlfile = $uploaddir_downloads . $urlfile; + // si le fichier est sur le serveur il es détruit + if (is_file($urlfile)) { chmod($urlfile, 0777); + unlink($urlfile); } } + // supression des data des champs sup + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('lid', \Xmf\Request::getInt('mod_id', 0, 'REQUEST'))); + $downloads_fielddata = $modifieddataHandler->getAll($criteria); + foreach (array_keys($downloads_fielddata) as $i) { /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloads_fielddata */ + $objfielddata = $modifieddataHandler->get($downloads_fielddata[$i]->getVar('modiddata')); + $modifieddataHandler->delete($objfielddata) || $objvfielddata->getHtmlErrors(); } + if ($modifiedHandler->delete($obj)) { redirect_header('modified.php', 1, _AM_TDMDOWNLOADS_REDIRECT_DELOK); } + $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); } else { $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); + $adminObject->addItemButton(_MI_TDMDOWNLOADS_ADMENU5, 'modified.php', 'list'); + $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); xoops_confirm( @@ -242,11 +298,16 @@ // delete the current file if a new proposed file is accepted. if (true === \Xmf\Request::getBool('new_file', false, 'REQUEST')) { $urlfile = substr_replace($obj->getVar('url'), '', 0, mb_strlen($uploadurl_downloads)); + // permet de donner le chemin du fichier + $urlfile = $uploaddir_downloads . $urlfile; + // si le fichier est sur le serveur il es détruit + if (is_file($urlfile)) { chmod($urlfile, 0777); + unlink($urlfile); } } @@ -269,33 +330,52 @@ $downloads_field = $fieldHandler->getAll($criteria); foreach (array_keys($downloads_field) as $i) { /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ + $contenu = ''; - $iddata = 0; + + $iddata = 0; + if (0 == $downloads_field[$i]->getVar('status_def')) { $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('lid', $viewModdownloads->getVar('requestid'))); + $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid'))); + $downloadsfieldmoddata = $modifieddataHandler->getAll($criteria); + foreach (array_keys($downloadsfieldmoddata) as $j) { /** @var \XoopsModules\Tdmdownloads\Modified[] $downloadsfieldmoddata */ + $contenu = $downloadsfieldmoddata[$j]->getVar('moddata'); } + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('lid', $viewModdownloads->getVar('lid'))); + $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid'))); + $downloadsfielddata = $fielddataHandler->getAll($criteria); + foreach (array_keys($downloadsfielddata) as $j) { /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloadsfielddata */ + $iddata = $downloadsfielddata[$j]->getVar('iddata'); } + if (0 == $iddata) { $objdata = $fielddataHandler->create(); + $objdata->setVar('fid', $downloads_field[$i]->getVar('fid')); + $objdata->setVar('lid', $viewModdownloads->getVar('lid')); } else { $objdata = $fielddataHandler->get($iddata); } + $objdata->setVar('data', $contenu); + $fielddataHandler->insert($objdata) || $objdata->getHtmlErrors(); } } @@ -308,7 +388,9 @@ $downloads_fielddata = $modifieddataHandler->getAll($criteria); foreach (array_keys($downloads_fielddata) as $i) { /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloads_fielddata */ + $objfielddata = $modifieddataHandler->get($downloads_fielddata[$i]->getVar('modiddata')); + $modifieddataHandler->delete($objfielddata) || $objvfielddata->getHtmlErrors(); } // enregistrement @@ -322,9 +404,11 @@ // Local icons path if (is_object($helper->getModule())) { $pathModIcon16 = $helper->getModule()->getInfo('modicons16'); + $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16); + $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32); } diff --git a/admin/permissions.php b/admin/permissions.php index 4c21807..1df424c 100644 --- a/admin/permissions.php +++ b/admin/permissions.php @@ -1,4 +1,4 @@ -getConfig('permission_download')) { $permissionDescription = _AM_TDMDOWNLOADS_PERM_DOWNLOAD_DSC; - $permissionName = 'tdmdownloads_download'; + + $permissionName = 'tdmdownloads_download'; } else { $permissionDescription = _AM_TDMDOWNLOADS_PERM_DOWNLOAD_DSC2; - $permissionName = 'tdmdownloads_download_item'; + + $permissionName = 'tdmdownloads_download_item'; } break; case 4: @@ -89,16 +91,20 @@ } } else { if (3 === $permission && 2 === $helper->getConfig('permission_download')) { - $sql = 'SELECT lid, cid, title FROM ' . $xoopsDB->prefix('tdmdownloads_downloads') . ' ORDER BY title'; + $sql = 'SELECT lid, cid, title FROM ' . $xoopsDB->prefix('tdmdownloads_downloads') . ' ORDER BY title'; + $result = $xoopsDB->query($sql); + if ($result) { while (false !== ($row = $xoopsDB->fetchArray($result))) { $permissionsForm->addItem($row['lid'], $row['title']); } } } else { - $sql = 'SELECT cat_cid, cat_pid, cat_title FROM ' . $xoopsDB->prefix('tdmdownloads_cat') . ' ORDER BY cat_title'; + $sql = 'SELECT cat_cid, cat_pid, cat_title FROM ' . $xoopsDB->prefix('tdmdownloads_cat') . ' ORDER BY cat_title'; + $result = $xoopsDB->query($sql); + if ($result) { while (false !== ($row = $xoopsDB->fetchArray($result))) { $permissionsForm->addItem($row['cat_cid'], $row['cat_title'], $row['cat_pid']); diff --git a/blocks/tdmdownloads_search.php b/blocks/tdmdownloads_search.php index f196aa5..b4d5f35 100644 --- a/blocks/tdmdownloads_search.php +++ b/blocks/tdmdownloads_search.php @@ -1,4 +1,5 @@ -loadLanguage('admin'); + $helper->loadLanguage('main'); + $helper->loadLanguage('common'); /** @var \XoopsModules\Tdmdownloads\Utility $utility */ - $utility = new \XoopsModules\Tdmdownloads\Utility(); + + $utility = new \XoopsModules\Tdmdownloads\Utility(); + $categories = $utility->getItemIds('tdmdownloads_view', $moduleDirName); + /** @var \XoopsModules\Tdmdownloads\CategoryHandler $categoryHandler */ + $categoryHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Category'); $block = []; //formulaire de recherche + $form = new \XoopsThemeForm(_MD_TDMDOWNLOADS_SEARCH, 'search', XOOPS_URL . '/modules/' . $moduleDirName . '/search.php', 'post'); + $form->setExtra('enctype="multipart/form-data"'); + //recherche par titre + $form->addElement(new \XoopsFormText(_MD_TDMDOWNLOADS_SEARCH_TITLE, 'title', 25, 255, '')); + //recherche par catégorie + $criteria = new \CriteriaCompo(); + $criteria->setSort('cat_weight ASC, cat_title'); + $criteria->setOrder('ASC'); + $criteria->add(new \Criteria('cat_cid', '(' . implode(',', $categories) . ')', 'IN')); + $downloadscatArray = $categoryHandler->getAll($criteria); - $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); + + $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); + $form->addElement($mytree->makeSelectElement('cat', 'cat_title', '--', '', true, 0, '', _AM_TDMDOWNLOADS_FORMINCAT), true); + //recherche champ sup. + /** @var \XoopsModules\Tdmdownloads\FieldHandler $fieldHandler */ + $fieldHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Field'); - $criteria = new \CriteriaCompo(); + + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('search', 1)); + $criteria->add(new \Criteria('status', 1)); + $criteria->setSort('weight ASC, title'); + $criteria->setOrder('ASC'); + $downloads_field = $fieldHandler->getAll($criteria); - $fieldNameBase = ''; + + $fieldNameBase = ''; + foreach (array_keys($downloads_field) as $i) { /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ - $title_sup = ''; - $contentArray = []; - $lid_arr = []; - $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); - $criteria = new \CriteriaCompo(); + + $title_sup = ''; + + $contentArray = []; + + $lid_arr = []; + + $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); + + $criteria = new \CriteriaCompo(); + $fieldContent[$downloads_field[$i]->getVar('fid')] = 999; + if (1 == $downloads_field[$i]->getVar('status_def')) { $criteria->add(new \Criteria('status', 0, '!=')); + if (1 == $downloads_field[$i]->getVar('fid')) { //page d'accueil + $title_sup = _AM_TDMDOWNLOADS_FORMHOMEPAGE; + $criteria->setSort('homepage'); + $fieldNameBase = 'homepage'; } + if (2 == $downloads_field[$i]->getVar('fid')) { //version + $title_sup = _AM_TDMDOWNLOADS_FORMVERSION; + $criteria->setSort('version'); + $fieldNameBase = 'version'; } + if (3 == $downloads_field[$i]->getVar('fid')) { //taille du fichier + $title_sup = _AM_TDMDOWNLOADS_FORMSIZE; + $criteria->setSort('size'); + $fieldNameBase = 'size'; } + if (4 == $downloads_field[$i]->getVar('fid')) { //platform - $title_sup = _AM_TDMDOWNLOADS_FORMPLATFORM; + + $title_sup = _AM_TDMDOWNLOADS_FORMPLATFORM; + $platformArray = explode('|', xoops_getModuleOption('platform', $moduleDirName)); + foreach ($platformArray as $platform) { $contentArray[$platform] = $platform; } } else { $criteria->setOrder('ASC'); + /** @var \XoopsModules\Tdmdownloads\DownloadsHandler $downloadsHandler */ - $downloadsHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Downloads'); + + $downloadsHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Downloads'); + $tdmdownloadsArray = $downloadsHandler->getAll($criteria); + foreach (array_keys($tdmdownloadsArray) as $j) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $tdmdownloadsArray */ - $contentArray[$tdmdownloadsArray[$j]->getVar($fieldNameBase)] = $tdmdownloadsArray[$j]->getVar($fieldNameBase); + $temp = $tdmdownloadsArray[$j]->getVar($fieldNameBase); + $contentArray[$temp] = $temp; } } } else { $title_sup = $downloads_field[$i]->getVar('title'); + $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid'))); + $criteria->setSort('data'); + $criteria->setOrder('ASC'); + /** @var \XoopsModules\Tdmdownloads\FielddataHandler $fielddataHandler */ - $fielddataHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Fielddata'); + + $fielddataHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Fielddata'); + $tdmdownloadsArray = $fielddataHandler->getAll($criteria); + foreach (array_keys($tdmdownloadsArray) as $j) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $tdmdownloadsArray */ + $contentArray[$tdmdownloadsArray[$j]->getVar('data', 'n')] = $tdmdownloadsArray[$j]->getVar('data'); } + if ('' != $fieldContent[$downloads_field[$i]->getVar('fid')]) { $criteria_1 = new \CriteriaCompo(); + $criteria_1->add(new \Criteria('data', $fieldContent[$downloads_field[$i]->getVar('fid')])); + /** @var \XoopsModules\Tdmdownloads\Fielddata $dataArray */ + $dataArray = $fielddataHandler->getAll($criteria_1); + foreach (array_keys($dataArray) as $k) { /** @var \XoopsModules\Tdmdownloads\Fielddata[] $dataArray */ + $lid_arr[] = $dataArray[$k]->getVar('lid'); } } + $form->addElement($select_sup); } + $select_sup = new \XoopsFormSelect($title_sup, $fieldName, $fieldContent[$downloads_field[$i]->getVar('fid')]); + $select_sup->addOption(999, _MD_TDMDOWNLOADS_SEARCH_ALL1); + $select_sup->addOptionArray($contentArray); + $form->addElement($select_sup); + unset($select_sup); } + //bouton validation + $buttonTray = new \XoopsFormElementTray('', ''); + $buttonTray->addElement(new \XoopsFormButton('', 'submit', _MD_TDMDOWNLOADS_SEARCH_BT, 'submit')); + $form->addElement($buttonTray); + $block['form'] = $form->render(); return $block; diff --git a/blocks/tdmdownloads_top.php b/blocks/tdmdownloads_top.php index bc4fa30..f0d9507 100644 --- a/blocks/tdmdownloads_top.php +++ b/blocks/tdmdownloads_top.php @@ -1,4 +1,5 @@ -getByDirname($moduleDirName); + + $mymodule = $moduleHandler->getByDirname($moduleDirName); + //appel de la class + /** @var \XoopsModules\Tdmdownloads\DownloadsHandler $downloadsHandler */ - $downloadsHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Downloads'); - $block = []; - $type_block = $options[0]; - $nb_entree = $options[1]; - $lenght_title = (int)$options[2]; - $use_logo = $options[3]; - $use_description = $options[4]; - $show_information = $options[5]; - $logo_float = $options[6]; - $logo_width = $options[7]; + + $downloadsHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Downloads'); + + $block = []; + + $type_block = $options[0]; + + $nb_entree = $options[1]; + + $lenght_title = (int)$options[2]; + + $use_logo = $options[3]; + + $use_description = $options[4]; + + $show_information = $options[5]; + + $logo_float = $options[6]; + + $logo_width = $options[7]; + $length_description = (int)$options[8]; - $blockstyle = $options[9]; + + $blockstyle = $options[9]; array_shift($options); + array_shift($options); + array_shift($options); + array_shift($options); + array_shift($options); + array_shift($options); + array_shift($options); + array_shift($options); + array_shift($options); + array_shift($options); // Add styles + global $xoTheme; + $db = null; /** @var \xos_opal_Theme $xoTheme */ + $xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $moduleDirName . '/assets/css/blocks.css', null); + /** @var \XoopsModules\Tdmdownloads\Utility $utility */ + $utility = new \XoopsModules\Tdmdownloads\Utility(); + /** @var \XoopsModules\Tdmdownloads\Helper $helper */ + $helper->loadLanguage('main'); $categories = $utility->getItemIds('tdmdownloads_view', $moduleDirName); - $criteria = new \CriteriaCompo(); + + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('cid', '(' . implode(',', $categories) . ')', 'IN')); - if (!(0 == $options[0] && 1 === count($options))) { + + if (!0 == $options[0] && 1 === count($options)) { $criteria->add(new \Criteria('cid', '(' . implode(',', $options) . ')', 'IN')); } + $criteria->add(new \Criteria('status', 0, '!=')); + switch ($type_block) { // pour le bloc: dernier fichier case 'date': $criteria->setSort('date'); @@ -93,23 +135,35 @@ function b_tdmdownloads_top_show($options) $criteria->setSort('RAND()'); break; } + $criteria->setLimit($nb_entree); + $downloadsArray = $downloadsHandler->getAll($criteria); + foreach (array_keys($downloadsArray) as $i) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloadsArray */ + $block[$i]['lid'] = $downloadsArray[$i]->getVar('lid'); - $titleFinal = $downloadsArray[$i]->getVar('title'); + + $titleFinal = $downloadsArray[$i]->getVar('title'); + if ($lenght_title > 0) { $titleFinal = mb_strlen($titleFinal) > $lenght_title ? mb_substr($titleFinal, 0, $lenght_title) . '...' : $titleFinal; } + $block[$i]['title'] = $titleFinal; - $descriptionFinal = ''; + + $descriptionFinal = ''; + if (true == $use_description) { $description = $downloadsArray[$i]->getVar('description'); + //permet d'afficher uniquement la description courte + if ($length_description > 0) { if (false === mb_strpos($description, '[pagebreak]')) { $descriptionFinal = mb_substr($description, 0, $length_description); + if (mb_strlen($description) > mb_strlen($descriptionFinal)) { $descriptionFinal .= ' ...'; } @@ -120,8 +174,10 @@ function b_tdmdownloads_top_show($options) $descriptionFinal = $description; } } + $block[$i]['description'] = $descriptionFinal; - $logourl = ''; + + $logourl = ''; if (true == $use_logo) { if ('blank.gif' === $downloadsArray[$i]->getVar('logourl') || '' === $downloadsArray[$i]->getVar('logourl')) { @@ -130,26 +186,42 @@ function b_tdmdownloads_top_show($options) $logourl = XOOPS_URL . '/uploads/' . $moduleDirName . '/images/shots/' . $downloadsArray[$i]->getVar('logourl'); } } - $block[$i]['logourl'] = $logourl; + + $block[$i]['logourl'] = $logourl; + $block[$i]['logourl_class'] = $logo_float; + $block[$i]['logourl_width'] = $logo_width; - $block[$i]['hits'] = $downloadsArray[$i]->getVar('hits'); - $block[$i]['rating'] = number_format($downloadsArray[$i]->getVar('rating'), 1); - $block[$i]['date'] = formatTimestamp($downloadsArray[$i]->getVar('date'), 's'); - $block[$i]['submitter'] = \XoopsUser::getUnameFromId($downloadsArray[$i]->getVar('submitter')); - $block[$i]['inforation'] = $show_information; - $block[$i]['blockstyle'] = $blockstyle; + + $block[$i]['hits'] = $downloadsArray[$i]->getVar('hits'); + + $block[$i]['rating'] = number_format($downloadsArray[$i]->getVar('rating'), 1); + + $block[$i]['date'] = formatTimestamp($downloadsArray[$i]->getVar('date'), 's'); + + $block[$i]['submitter'] = \XoopsUser::getUnameFromId($downloadsArray[$i]->getVar('submitter')); + + $block[$i]['inforation'] = $show_information; + + $block[$i]['blockstyle'] = $blockstyle; } + $GLOBALS['xoopsTpl']->assign('tdmblockstyle', $blockstyle); $grouppermHandler = xoops_getHandler('groupperm'); - $groups = XOOPS_GROUP_ANONYMOUS; + + $groups = XOOPS_GROUP_ANONYMOUS; + if (is_object($GLOBALS['xoopsUser'])) { $groups = $GLOBALS['xoopsUser']->getGroups(); } + $perm_submit = $grouppermHandler->checkRight('tdmdownloads_ac', 4, $groups, $mymodule->getVar('mid')) ? true : false; - $perm_modif = $grouppermHandler->checkRight('tdmdownloads_ac', 8, $groups, $mymodule->getVar('mid')) ? true : false; + + $perm_modif = $grouppermHandler->checkRight('tdmdownloads_ac', 8, $groups, $mymodule->getVar('mid')) ? true : false; + $GLOBALS['xoopsTpl']->assign('perm_submit', $perm_submit); + $GLOBALS['xoopsTpl']->assign('perm_modif', $perm_modif); return $block; @@ -163,72 +235,123 @@ function b_tdmdownloads_top_show($options) function b_tdmdownloads_top_edit($options) { //appel de la class - $moduleDirName = basename(dirname(__DIR__)); + + $moduleDirName = basename(dirname(__DIR__)); + $categoryHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Category'); - $criteria = new \CriteriaCompo(); + + $criteria = new \CriteriaCompo(); + $criteria->setSort('cat_weight ASC, cat_title'); + $criteria->setOrder('ASC'); + $downloadscatArray = $categoryHandler->getAll($criteria); - $form = _MB_TDMDOWNLOADS_DISP . " \n"; - $form .= '\n"; - $form .= ' ' . _MB_TDMDOWNLOADS_FILES . "
      \n"; - $form .= _MB_TDMDOWNLOADS_CHARS . ' (' . _MB_TDMDOWNLOADS_CHARSDSC . '):
      \n"; + + $form = _MB_TDMDOWNLOADS_DISP . " \n"; + + $form .= '\n"; + + $form .= ' ' . _MB_TDMDOWNLOADS_FILES . "
      \n"; + + $form .= _MB_TDMDOWNLOADS_CHARS . ' (' . _MB_TDMDOWNLOADS_CHARSDSC . '):
      \n"; + if (false == $options[3]) { $checked_yes = ''; - $checked_no = 'checked'; + + $checked_no = 'checked'; } else { $checked_yes = 'checked'; - $checked_no = ''; + + $checked_no = ''; } + $form .= _MB_TDMDOWNLOADS_LOGO . ' : ' . _YES . " \n"; + $form .= '' . _NO . "
      \n"; + if (false == $options[4]) { $checked_yes = ''; - $checked_no = 'checked'; + + $checked_no = 'checked'; } else { $checked_yes = 'checked'; - $checked_no = ''; + + $checked_no = ''; } + $form .= _MB_TDMDOWNLOADS_DESCRIPTION . ' : ' . _YES . " \n"; + $form .= '' . _NO . "
      \n"; + if (false == $options[5]) { $checked_yes = ''; - $checked_no = 'checked'; + + $checked_no = 'checked'; } else { $checked_yes = 'checked'; - $checked_no = ''; + + $checked_no = ''; } - $form .= _MB_TDMDOWNLOADS_INFORMATIONS . ' : ' . _YES . " \n"; - $form .= '' . _NO . "

      \n"; + + $form .= _MB_TDMDOWNLOADS_INFORMATIONS . ' : ' . _YES . " \n"; + + $form .= '' . _NO . "

      \n"; + $floatSelect = new \XoopsFormSelect('', 'options[6]', $options[6]); + $floatSelect->addOption('left', _MB_TDMDOWNLOADS_FLOAT_LEFT); + $floatSelect->addOption('right', _MB_TDMDOWNLOADS_FLOAT_RIGHT); - $form .= _MB_TDMDOWNLOADS_FLOAT . $floatSelect->render() . '
      '; - $form .= _MB_TDMDOWNLOADS_WIDTH . ' (' . _MB_TDMDOWNLOADS_WIDTHDSC . '):
      \n"; - $form .= _MB_TDMDOWNLOADS_DESCRIPTIONDSC . ':
      \n"; + + $form .= _MB_TDMDOWNLOADS_FLOAT . $floatSelect->render() . '
      '; + + $form .= _MB_TDMDOWNLOADS_WIDTH . ' (' . _MB_TDMDOWNLOADS_WIDTHDSC . '):
      \n"; + + $form .= _MB_TDMDOWNLOADS_DESCRIPTIONDSC . ':
      \n"; + $styleSelect = new \XoopsFormSelect('', 'options[9]', $options[9]); + $styleSelect->addOption('default', 'default'); + $styleSelect->addOption('simple1', 'simple1'); + $styleSelect->addOption('simple2', 'simple2'); + $styleSelect->addOption('simple3', 'simple3'); + $styleSelect->addOption('simple4', 'simple4'); + $form .= _MB_TDMDOWNLOADS_BLOCKSTYLE . ': ' . $styleSelect->render() . '
      '; array_shift($options); + array_shift($options); + array_shift($options); + array_shift($options); + array_shift($options); + array_shift($options); + array_shift($options); + array_shift($options); + array_shift($options); + $form .= _MB_TDMDOWNLOADS_CATTODISPLAY . "
      \n"; return $form; diff --git a/brokenfile.php b/brokenfile.php index 0b551a7..113a7ba 100644 --- a/brokenfile.php +++ b/brokenfile.php @@ -1,4 +1,4 @@ -add(new \Criteria('lid', $lid)); + $brokenArray = $brokenHandler->getAll($criteria); + foreach (array_keys($brokenArray) as $i) { /** @var \XoopsModules\Tdmdownloads\Broken[] $brokenArray */ + if ($brokenArray[$i]->getVar('sender') == $ratinguser) { redirect_header('singlefile.php?lid=' . $lid, 2, _MD_TDMDOWNLOADS_BROKENFILE_ALREADYREPORTED); } } } else { // si c'est un utilisateur anonyme on vérifie qu'il n'envoie pas 2 fois un rapport + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('lid', $lid)); + $criteria->add(new \Criteria('sender', 0)); + $criteria->add(new \Criteria('ip', getenv('REMOTE_ADDR'))); + if ($brokenHandler->getCount($criteria) >= 1) { redirect_header('singlefile.php?lid=' . $lid, 2, _MD_TDMDOWNLOADS_BROKENFILE_ALREADYREPORTED); } @@ -110,7 +120,8 @@ $xoopsCaptcha = \XoopsCaptcha::getInstance(); if (!$xoopsCaptcha->verify()) { $errorMessage .= $xoopsCaptcha->getMessage() . '
      '; - $erreur = true; + + $erreur = true; } $obj->setVar('lid', $lid); $obj->setVar('sender', $ratinguser); @@ -119,13 +130,19 @@ $xoopsTpl->assign('message_erreur', $errorMessage); } else { if ($brokenHandler->insert($obj)) { - $tags = []; + $tags = []; + $tags['BROKENREPORTS_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/admin/broken.php'; + /** @var \XoopsNotificationHandler $notificationHandler */ + $notificationHandler = xoops_getHandler('notification'); + $notificationHandler->triggerEvent('global', 0, 'file_broken', $tags); + redirect_header('singlefile.php?lid=' . $lid, 2, _MD_TDMDOWNLOADS_BROKENFILE_THANKSFORINFO); } + echo $obj->getHtmlErrors(); } //Affichage du formulaire de notation des téléchargements diff --git a/class/Broken.php b/class/Broken.php index 486a982..6055842 100644 --- a/class/Broken.php +++ b/class/Broken.php @@ -1,4 +1,4 @@ -initVar('reportid', \XOBJ_DTYPE_INT, null, false, 5); + $this->initVar('lid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('sender', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('ip', \XOBJ_DTYPE_TXTBOX, null, false); + //pour les jointures: + $this->initVar('title', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('cid', \XOBJ_DTYPE_INT, null, false, 5); } @@ -45,18 +53,27 @@ public function __construct() public function getForm($lid, $action = false) { // global $xoopsDB, $xoopsModule, $xoopsModuleConfig; - if (false === $action) { + + if (!$action) { $action = $_SERVER['REQUEST_URI']; } $form = new \XoopsThemeForm(_MD_TDMDOWNLOADS_BROKENFILE_REPORTBROKEN, 'brokenform', 'brokenfile.php', 'post'); + $form->setExtra('enctype="multipart/form-data"'); + $form->addElement(new \XoopsFormCaptcha(), true); + $form->addElement(new \XoopsFormHidden('op', 'save')); + $form->addElement(new \XoopsFormHidden('lid', $lid)); + // Submit button + $buttonTray = new \XoopsFormElementTray(_MD_TDMDOWNLOADS_BROKENFILE_REPORTBROKEN, '', ''); + $buttonTray->addElement(new \XoopsFormButton('', 'post', _MD_TDMDOWNLOADS_BROKENFILE_REPORTBROKEN, 'submit')); + $form->addElement($buttonTray); return $form; diff --git a/class/BrokenHandler.php b/class/BrokenHandler.php index 2072a38..daea1ff 100644 --- a/class/BrokenHandler.php +++ b/class/BrokenHandler.php @@ -1,4 +1,4 @@ -helper = Tdmdownloads\Helper::getInstance(); + + /** @var Tdmdownloads\Helper $helper */ + + $this->helper = Tdmdownloads\Helper::getInstance(); + $this->permHelper = new \Xmf\Module\Helper\Permission(); + $this->initVar('cat_cid', \XOBJ_DTYPE_INT, null, false, 5); + $this->initVar('cat_pid', \XOBJ_DTYPE_INT, null, false, 5); + $this->initVar('cat_title', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('cat_imgurl', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('cat_description_main', \XOBJ_DTYPE_TXTAREA, null, false); + // Pour autoriser le html + $this->initVar('dohtml', \XOBJ_DTYPE_INT, 1, false); + $this->initVar('cat_weight', \XOBJ_DTYPE_INT, 0, false, 11); } @@ -55,7 +67,9 @@ public function __construct() public function getNewEnreg($db = null) { $newEnreg = 0; + /** @var \XoopsMySQLDatabase $db */ + if (null !== $db) { $newEnreg = $db->getInsertId(); } @@ -71,106 +85,183 @@ public function getNewEnreg($db = null) public function getForm($action = false) { /** @var \XoopsModules\Tdmdownloads\Helper $helper */ + $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); - if (false === $action) { + if (!$action) { $action = $_SERVER['REQUEST_URI']; } + $moduleDirName = \basename(\dirname(__DIR__)); + require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; //nom du formulaire selon l'action (editer ou ajouter): + $title = $this->isNew() ? \sprintf(_AM_TDMDOWNLOADS_FORMADD) : \sprintf(_AM_TDMDOWNLOADS_FORMEDIT); //création du formulaire + $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); + $form->setExtra('enctype="multipart/form-data"'); + //titre + $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_FORMTITLE, 'cat_title', 50, 255, $this->getVar('cat_title')), true); + //editeur - $editorConfigs = []; - $editorConfigs['name'] = 'cat_description_main'; - $editorConfigs['value'] = $this->getVar('cat_description_main', 'e'); - $editorConfigs['rows'] = 20; - $editorConfigs['cols'] = 160; - $editorConfigs['width'] = '100%'; + + $editorConfigs = []; + + $editorConfigs['name'] = 'cat_description_main'; + + $editorConfigs['value'] = $this->getVar('cat_description_main', 'e'); + + $editorConfigs['rows'] = 20; + + $editorConfigs['cols'] = 160; + + $editorConfigs['width'] = '100%'; + $editorConfigs['height'] = '400px'; + $editorConfigs['editor'] = $helper->getConfig('editor'); + $form->addElement(new \XoopsFormEditor(_AM_TDMDOWNLOADS_FORMTEXT, 'cat_description_main', $editorConfigs), false); + //image - $categoryImage = $this->getVar('cat_imgurl') ?: 'blank.gif'; + + $categoryImage = $this->getVar('cat_imgurl') ?: 'blank.gif'; + $uploadirectory = '/uploads/' . $moduleDirName . '/images/cats'; - $imgtray = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMIMG, '
      '); - $imgpath = \sprintf(_AM_TDMDOWNLOADS_FORMPATH, $uploadirectory); - $imageselect = new \XoopsFormSelect($imgpath, 'downloadscat_img', $categoryImage); - $topics_array = \XoopsLists:: getImgListAsArray(XOOPS_ROOT_PATH . $uploadirectory); + + $imgtray = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMIMG, '
      '); + + $imgpath = \sprintf(_AM_TDMDOWNLOADS_FORMPATH, $uploadirectory); + + $imageselect = new \XoopsFormSelect($imgpath, 'downloadscat_img', $categoryImage); + + $topics_array = \XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . $uploadirectory); + foreach ($topics_array as $image) { $imageselect->addOption($image, $image); } + $imageselect->setExtra("onchange='showImgSelected(\"image3\", \"downloadscat_img\", \"" . $uploadirectory . '", "", "' . XOOPS_URL . "\")'"); + $imgtray->addElement($imageselect, false); + $imgtray->addElement(new \XoopsFormLabel('', "
      ")); + $fileseltray = new \XoopsFormElementTray('', '
      '); + $fileseltray->addElement(new \XoopsFormFile(_AM_TDMDOWNLOADS_FORMUPLOAD, 'attachedfile', $helper->getConfig('maxuploadsize')), false); + $fileseltray->addElement(new \XoopsFormLabel(''), false); + $imgtray->addElement($fileseltray); + $form->addElement($imgtray); + // Pour faire une sous-catégorie /** @var \XoopsModules\Tdmdownloads\CategoryHandler $categoryHandler */ + $categoryHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Category'); - $criteria = new \CriteriaCompo(); + + $criteria = new \CriteriaCompo(); + $criteria->setSort('cat_weight ASC, cat_title'); + $criteria->setOrder('ASC'); + $downloadscatArray = $categoryHandler->getAll($criteria); - $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); + + $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); + $form->addElement($mytree->makeSelectElement('cat_pid', 'cat_title', '--', $this->getVar('cat_pid'), true, 0, '', _AM_TDMDOWNLOADS_FORMINCAT), true); + //poids de la catégorie + $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_FORMWEIGHT, 'cat_weight', 5, 5, $this->getVar('cat_weight', 'e')), false); //permissions + /** @var \XoopsMemberHandler $memberHandler */ + $memberHandler = \xoops_getHandler('member'); - $group_list = $memberHandler->getGroupList(); + + $group_list = $memberHandler->getGroupList(); + /** @var \XoopsGroupPermHandler $grouppermHandler */ + $grouppermHandler = \xoops_getHandler('groupperm'); - $full_list = \array_keys($group_list); + + $full_list = \array_keys($group_list); + global $xoopsModule; + if (!$this->isNew()) { - $groups_ids_view = $grouppermHandler->getGroupIds('tdmdownloads_view', $this->getVar('cat_cid'), $xoopsModule->getVar('mid')); - $groups_ids_submit = $grouppermHandler->getGroupIds('tdmdownloads_submit', $this->getVar('cat_cid'), $xoopsModule->getVar('mid')); - $groups_ids_download = $grouppermHandler->getGroupIds('tdmdownloads_download', $this->getVar('cat_cid'), $xoopsModule->getVar('mid')); - $groups_ids_view = \array_values($groups_ids_view); - $groups_news_can_view_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_PERM_VIEW_DSC, 'groups_view[]', $groups_ids_view); - $groups_ids_submit = \array_values($groups_ids_submit); - $groups_news_can_submit_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_PERM_SUBMIT_DSC, 'groups_submit[]', $groups_ids_submit); - $groups_ids_download = \array_values($groups_ids_download); + $groups_ids_view = $grouppermHandler->getGroupIds('tdmdownloads_view', $this->getVar('cat_cid'), $xoopsModule->getVar('mid')); + + $groups_ids_submit = $grouppermHandler->getGroupIds('tdmdownloads_submit', $this->getVar('cat_cid'), $xoopsModule->getVar('mid')); + + $groups_ids_download = $grouppermHandler->getGroupIds('tdmdownloads_download', $this->getVar('cat_cid'), $xoopsModule->getVar('mid')); + + $groups_ids_view = \array_values($groups_ids_view); + + $groups_news_can_view_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_PERM_VIEW_DSC, 'groups_view[]', $groups_ids_view); + + $groups_ids_submit = \array_values($groups_ids_submit); + + $groups_news_can_submit_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_PERM_SUBMIT_DSC, 'groups_submit[]', $groups_ids_submit); + + $groups_ids_download = \array_values($groups_ids_download); + $groups_news_can_download_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_PERM_DOWNLOAD_DSC, 'groups_download[]', $groups_ids_download); } else { - $groups_news_can_view_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_PERM_VIEW_DSC, 'groups_view[]', $full_list); - $groups_news_can_submit_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_PERM_SUBMIT_DSC, 'groups_submit[]', $full_list); + $groups_news_can_view_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_PERM_VIEW_DSC, 'groups_view[]', $full_list); + + $groups_news_can_submit_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_PERM_SUBMIT_DSC, 'groups_submit[]', $full_list); + $groups_news_can_download_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_PERM_DOWNLOAD_DSC, 'groups_download[]', $full_list); } + // pour voir + $groups_news_can_view_checkbox->addOptionArray($group_list); + $form->addElement($groups_news_can_view_checkbox); + // pour editer + $groups_news_can_submit_checkbox->addOptionArray($group_list); + $form->addElement($groups_news_can_submit_checkbox); + // pour télécharger + if (1 == $helper->getConfig('permission_download')) { $groups_news_can_download_checkbox->addOptionArray($group_list); + $form->addElement($groups_news_can_download_checkbox); } // pour passer "cid" si on modifie la catégorie + if (!$this->isNew()) { $form->addElement(new \XoopsFormHidden('cat_cid', $this->getVar('cat_cid'))); + $form->addElement(new \XoopsFormHidden('categorie_modified', true)); } + //pour enregistrer le formulaire + $form->addElement(new \XoopsFormHidden('op', 'save_cat')); + //boutton d'envoi du formulaire + $form->addElement(new \XoopsFormButtonTray('', \_SUBMIT, 'submit', 'submit', false)); return $form; diff --git a/class/CategoryHandler.php b/class/CategoryHandler.php index 4ca3f0e..c6a3d18 100644 --- a/class/CategoryHandler.php +++ b/class/CategoryHandler.php @@ -1,4 +1,4 @@ -addLink( 'bread 3', 'index3.php' ); * echo $breadcrumb->render(); */ + /** * Class Breadcrumb */ class Breadcrumb { - public $dirname; + public $dirname; private $bread = []; public function __construct() @@ -62,13 +63,18 @@ public function render() { if (!isset($GLOBALS['xoTheme']) || !\is_object($GLOBALS['xoTheme'])) { require_once $GLOBALS['xoops']->path('class/theme.php'); + $GLOBALS['xoTheme'] = new \xos_opal_Theme(); } require_once $GLOBALS['xoops']->path('class/template.php'); + $breadcrumbTpl = new \XoopsTpl(); + $breadcrumbTpl->assign('breadcrumb', $this->bread); + $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl'); + unset($breadcrumbTpl); return $html; diff --git a/class/Common/Configurator.php b/class/Common/Configurator.php index f0251f2..4dbecb8 100644 --- a/class/Common/Configurator.php +++ b/class/Common/Configurator.php @@ -1,4 +1,4 @@ -name = $config->name; - $this->paths = $config->paths; - $this->uploadFolders = $config->uploadFolders; - $this->copyBlankFiles = $config->copyBlankFiles; + $this->name = $config->name; + + $this->paths = $config->paths; + + $this->uploadFolders = $config->uploadFolders; + + $this->copyBlankFiles = $config->copyBlankFiles; + $this->copyTestFolders = $config->copyTestFolders; + $this->templateFolders = $config->templateFolders; - $this->oldFiles = $config->oldFiles; - $this->oldFolders = $config->oldFolders; - $this->renameTables = $config->renameTables; - $this->modCopyright = $config->modCopyright; + + $this->oldFiles = $config->oldFiles; + + $this->oldFolders = $config->oldFolders; + + $this->renameTables = $config->renameTables; + + $this->modCopyright = $config->modCopyright; $this->icons = include \dirname(\dirname(__DIR__)) . '/config/icons.php'; + $this->paths = include \dirname(\dirname(__DIR__)) . '/config/paths.php'; } } diff --git a/class/Common/FilesManagement.php b/class/Common/FilesManagement.php index 6ac1944..8163817 100644 --- a/class/Common/FilesManagement.php +++ b/class/Common/FilesManagement.php @@ -1,4 +1,4 @@ -history.go(-1);'); } - } catch (\Exception $e) { + } catch (\Throwable $e) { echo 'Caught exception: ', $e->getMessage(), "\n", '
      '; } } @@ -59,9 +59,11 @@ public static function copyFile($file, $folder) public static function recurseCopy($src, $dst) { $dir = \opendir($src); + if (!\mkdir($dst) && !\is_dir($dst)) { throw new \RuntimeException('The directory ' . $dst . ' could not be created.'); } + while (false !== ($file = \readdir($dir))) { if (('.' !== $file) && ('..' !== $file)) { if (\is_dir($src . '/' . $file)) { @@ -71,6 +73,7 @@ public static function recurseCopy($src, $dst) } } } + \closedir($dir); } @@ -87,36 +90,48 @@ public static function recurseCopy($src, $dst) public static function deleteDirectory($src) { // Only continue if user is a 'global' Admin + if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { return false; } $success = true; + // remove old files + $dirInfo = new \SplFileInfo($src); + // validate is a directory + if ($dirInfo->isDir()) { $fileList = \array_diff(\scandir($src, \SCANDIR_SORT_NONE), ['..', '.']); + foreach ($fileList as $k => $v) { $fileInfo = new \SplFileInfo("{$src}/{$v}"); + if ($fileInfo->isDir()) { // recursively handle subdirectories + if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { break; } } else { // delete the file + if (!($success = \unlink($fileInfo->getRealPath()))) { break; } } } + // now delete this (sub)directory if all the files are gone + if ($success) { $success = \rmdir($dirInfo->getRealPath()); } } else { // input is not a valid directory + $success = false; } @@ -135,11 +150,13 @@ public static function deleteDirectory($src) public static function rrmdir($src) { // Only continue if user is a 'global' Admin + if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { return false; } // If source is not a directory stop processing + if (!\is_dir($src)) { return false; } @@ -147,19 +164,25 @@ public static function rrmdir($src) $success = true; // Open the source directory to read in files + $iterator = new \DirectoryIterator($src); + foreach ($iterator as $fObj) { if ($fObj->isFile()) { $filename = $fObj->getPathname(); - $fObj = null; // clear this iterator object to close the file + + $fObj = null; // clear this iterator object to close the file + if (!\unlink($filename)) { return false; // couldn't delete the file } } elseif (!$fObj->isDot() && $fObj->isDir()) { // Try recursively on directory + self::rrmdir($fObj->getPathname()); } } + $iterator = null; // clear iterator Obj to close file/directory return \rmdir($src); // remove the directory & return results } @@ -175,31 +198,38 @@ public static function rrmdir($src) public static function rmove($src, $dest) { // Only continue if user is a 'global' Admin + if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { return false; } // If source is not a directory stop processing + if (!\is_dir($src)) { return false; } // If the destination directory does not exist and could not be created stop processing + if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) { return false; } // Open the source directory to read in files + $iterator = new \DirectoryIterator($src); + foreach ($iterator as $fObj) { if ($fObj->isFile()) { \rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); } elseif (!$fObj->isDot() && $fObj->isDir()) { // Try recursively on directory + self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); // rmdir($fObj->getPath()); // now delete the directory } } + $iterator = null; // clear iterator Obj to close file/directory return \rmdir($src); // remove the directory & return results } @@ -218,22 +248,27 @@ public static function rmove($src, $dest) public static function rcopy($src, $dest) { // Only continue if user is a 'global' Admin + if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { return false; } // If source is not a directory stop processing + if (!\is_dir($src)) { return false; } // If the destination directory does not exist and could not be created stop processing + if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) { return false; } // Open the source directory to read in files + $iterator = new \DirectoryIterator($src); + foreach ($iterator as $fObj) { if ($fObj->isFile()) { \copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); diff --git a/class/Common/FineimpuploadHandler.php b/class/Common/FineimpuploadHandler.php index 3f0d05a..3be2404 100644 --- a/class/Common/FineimpuploadHandler.php +++ b/class/Common/FineimpuploadHandler.php @@ -1,4 +1,4 @@ -allowedMimeTypes = ['image/gif', 'image/jpeg', 'image/png', 'application/zip']; + + $this->allowedMimeTypes = ['image/gif', 'image/jpeg', 'image/png', 'application/zip']; + $this->allowedExtensions = ['gif', 'jpeg', 'jpg', 'png', 'zip']; } @@ -115,92 +127,131 @@ public function __construct(\stdClass $claims) */ protected function storeUploadedFile($target, $mimeType, $uid) { - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); + require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/header.php'; + $this->pathUpload = \constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH'); - $utility = new \XoopsModules\Tdmdownloads\Utility(); + + $utility = new \XoopsModules\Tdmdownloads\Utility(); + /** @var \XoopsModules\Tdmdownloads\Helper $helper */ + $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); // if ( WGGALLERY_PERM_SUBMITAPPR === $permissionsHandler->permGlobalSubmit()) { + // $this->permUseralbum = WGGALLERY_STATE_APPROVAL_VAL; + // } else { + // $this->permUseralbum = WGGALLERY_STATE_ONLINE_VAL; + // } $this->permUseralbum = 1; //TODO: handle an option, whether images should be online immediately or not $pathParts = \pathinfo($this->getName()); - $this->imageName = \uniqid('img', true) . '.' . \strtolower($pathParts['extension']); - $this->imageNicename = \str_replace(['_', '-'], ' ', $pathParts['filename']); - $this->imageNameLarge = \uniqid('imgl', true) . '.' . \strtolower($pathParts['extension']); - $this->imagePath = $this->pathUpload . '/large/' . $this->imageNameLarge; + $this->imageName = \uniqid('img', true) . '.' . \mb_strtolower($pathParts['extension']); + + $this->imageNicename = \str_replace(['_', '-'], ' ', $pathParts['filename']); + + $this->imageNameLarge = \uniqid('imgl', true) . '.' . \mb_strtolower($pathParts['extension']); - if (false === \move_uploaded_file($_FILES[$this->inputName]['tmp_name'], $this->imagePath)) { + $this->imagePath = $this->pathUpload . '/large/' . $this->imageNameLarge; + + if (!\move_uploaded_file($_FILES[$this->inputName]['tmp_name'], $this->imagePath)) { return false; } $this->imageNameOrig = $_FILES[$this->inputName]['name']; + $this->imageMimetype = $_FILES[$this->inputName]['type']; - $this->imageSize = $_FILES[$this->inputName]['size']; + + $this->imageSize = $_FILES[$this->inputName]['size']; $ret = $this->handleImageDB(); - if (false === $ret) { + + if (!$ret) { return [ 'error' => \sprintf(\_FAILSAVEIMG, $this->imageNicename), ]; } // load watermark settings - $albumObj = $albumsHandler->get($this->claims->cat); - $wmId = $albumObj->getVar('alb_wmid'); + + $albumObj = $albumsHandler->get($this->claims->cat); + + $wmId = $albumObj->getVar('alb_wmid'); + $wmTargetM = false; + $wmTargetL = false; - if (0 < $wmId) { + + if ($wmId > 0) { $watermarksObj = $watermarksHandler->get($wmId); - $wmTarget = $watermarksObj->getVar('wm_target'); + + $wmTarget = $watermarksObj->getVar('wm_target'); + if (\constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_A') === $wmTarget || \constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_M') === $wmTarget) { $wmTargetM = true; } + if (\constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_A') === $wmTarget || \constant($moduleDirNameUpper . '_' . 'WATERMARK_TARGET_L') === $wmTarget) { $wmTargetL = true; } } // create medium image + // $ret = $this->resizeImage($this->pathUpload . '/medium/' . $this->imageName, $helper->getConfig('maxwidth_medium'), $helper->getConfig('maxheight_medium')); + $ret = $utility->resizeImage($this->imagePath, $this->pathUpload . '/medium/' . $this->imageName, $helper->getConfig('maxwidth_medium'), $helper->getConfig('maxheight_medium'), $this->imageMimetype); + if (false === $ret) { return ['error' => \sprintf(\constant($moduleDirNameUpper . '_' . 'FAILSAVEIMG_MEDIUM'), $this->imageNicename)]; } + if ('copy' === $ret) { \copy($this->pathUpload . '/large/' . $this->imageNameLarge, $this->pathUpload . '/medium/' . $this->imageName); } // create thumb + // $ret = $this->resizeImage($this->pathUpload . '/thumbs/' . $this->imageName, $helper->getConfig('maxwidth_thumbs'), $helper->getConfig('maxheight_thumbs')); + $ret = $utility->resizeImage($this->imagePath, $this->pathUpload . '/thumbs/' . $this->imageName, $helper->getConfig('maxwidth_thumbs'), $helper->getConfig('maxheight_thumbs'), $this->imageMimetype); + if (false === $ret) { return ['error' => \sprintf(\constant($moduleDirNameUpper . '_' . 'FAILSAVEIMG_THUMBS'), $this->imageNicename)]; } + if ('copy' === $ret) { \copy($this->pathUpload . '/large/' . $this->imageNameLarge, $this->pathUpload . '/thumbs/' . $this->imageName); } // add watermark to large image - if (true === $wmTargetL) { + + if ($wmTargetL) { $imgWm = $this->pathUpload . '/large/' . $this->imageNameLarge; + $resWm = $watermarksHandler->watermarkImage($wmId, $imgWm, $imgWm); + if (true !== $resWm) { return ['error' => \sprintf(\constant($moduleDirNameUpper . '_' . 'FAILSAVEWM_LARGE'), $this->imageNicename, $resWm)]; } } + // add watermark to medium image - if (true === $wmTargetM) { + + if ($wmTargetM) { $imgWm = $this->pathUpload . '/medium/' . $this->imageName; + $resWm = $watermarksHandler->watermarkImage($wmId, $imgWm, $imgWm); + if (true !== $resWm) { return ['error' => \sprintf(\constant($moduleDirNameUpper . '_' . 'FAILSAVEWM_MEDIUM'), $this->imageNicename, $resWm)]; } @@ -215,35 +266,59 @@ protected function storeUploadedFile($target, $mimeType, $uid) private function handleImageDB() { $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/header.php'; + global $xoopsUser; $this->getImageDim(); $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); + // $imagesHandler = $helper->getHandler('Images'); + $imagesHandler = new \XoopsModules\Tdmdownloads\Common\ImagesHandler(); - $imagesObj = $imagesHandler->create(); + + $imagesObj = $imagesHandler->create(); + // Set Vars + $imagesObj->setVar('img_title', $this->imageNicename); + $imagesObj->setVar('img_desc', ''); + $imagesObj->setVar('img_name', $this->imageName); + $imagesObj->setVar('img_namelarge', $this->imageNameLarge); + $imagesObj->setVar('img_nameorig', $this->imageNameOrig); + $imagesObj->setVar('img_mimetype', $this->imageMimetype); + $imagesObj->setVar('img_size', $this->imageSize); + $imagesObj->setVar('img_resx', $this->imageWidth); + $imagesObj->setVar('img_resy', $this->imageHeight); + $imagesObj->setVar('img_albid', $this->claims->cat); + $imagesObj->setVar('img_state', $this->permUseralbum); + $imagesObj->setVar('img_date', \time()); + $imagesObj->setVar('img_submitter', $xoopsUser->id()); + $imagesObj->setVar('img_ip', $_SERVER['REMOTE_ADDR']); + // Insert Data + if ($imagesHandler->insert($imagesObj)) { $this->imageId = $imagesHandler->getInsertId(); + return true; } + return false; } @@ -253,28 +328,29 @@ private function handleImageDB() private function getImageDim() { switch ($this->imageMimetype) { - case'image/png': + case 'image/png': $img = \imagecreatefrompng($this->imagePath); break; - case'image/jpeg': + case 'image/jpeg': $img = \imagecreatefromjpeg($this->imagePath); break; - case'image/gif': + case 'image/gif': $img = \imagecreatefromgif($this->imagePath); break; - - case'application/zip': + case 'application/zip': $this->imageWidth = 0; $this->imageHeight = 0; // $img = imagecreatefromgif($this->imagePath); break; - default: $this->imageWidth = 0; $this->imageHeight = 0; + return 'Unsupported format'; } - $this->imageWidth = \imagesx($img); + + $this->imageWidth = \imagesx($img); + $this->imageHeight = \imagesy($img); \imagedestroy($img); diff --git a/class/Common/ImageResizer.php b/class/Common/ImageResizer.php index 074c748..529a454 100644 --- a/class/Common/ImageResizer.php +++ b/class/Common/ImageResizer.php @@ -1,4 +1,4 @@ - $max_width || $height > $max_height) { // recalc image size based on max_width/max_height + if ($width > $height) { if ($width < $max_width) { $new_width = $width; } else { - $new_width = $max_width; - $divisor = $width / $new_width; + $new_width = $max_width; + + $divisor = $width / $new_width; + $new_height = \floor($height / $divisor); } } elseif ($height < $max_height) { $new_height = $height; } else { $new_height = $max_height; - $divisor = $height / $new_height; - $new_width = \floor($width / $divisor); + + $divisor = $height / $new_height; + + $new_width = \floor($width / $divisor); } // Create a new temporary image. + $tmpimg = \imagecreatetruecolor($new_width, $new_height); + imagealphablending($tmpimg, false); + imagesavealpha($tmpimg, true); // Copy and resize old image into new image. + \imagecopyresampled($tmpimg, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); \unlink($endfile); + //compressing the file + switch ($imageMimetype) { - case'image/png': + case 'image/png': \imagepng($tmpimg, $endfile, 0); break; - case'image/jpeg': + case 'image/jpeg': \imagejpeg($tmpimg, $endfile, 100); break; - case'image/gif': + case 'image/gif': \imagegif($tmpimg, $endfile); break; } // release the memory + \imagedestroy($tmpimg); } else { return 'copy'; } + \imagedestroy($img); + return true; } @@ -115,6 +128,7 @@ public function resizeImage($sourcefile, $endfile, $max_width, $max_height, $ima public function resizeAndCrop($src_url, $src_mimetype, $dest_url, $dest_w, $dest_h, $quality = 90) { // check file extension + switch ($src_mimetype) { case 'image/png': $original = \imagecreatefrompng($src_url); @@ -134,35 +148,49 @@ public function resizeAndCrop($src_url, $src_mimetype, $dest_url, $dest_w, $dest } // GET ORIGINAL IMAGE DIMENSIONS + [$original_w, $original_h] = \getimagesize($src_url); // RESIZE IMAGE AND PRESERVE PROPORTIONS + $dest_w_resize = $dest_w; + $dest_h_resize = $dest_h; + if ($original_w > $original_h) { - $dest_h_ratio = $dest_h / $original_h; + $dest_h_ratio = $dest_h / $original_h; + $dest_w_resize = (int)\round($original_w * $dest_h_ratio); } else { - $dest_w_ratio = $dest_w / $original_w; + $dest_w_ratio = $dest_w / $original_w; + $dest_h_resize = (int)\round($original_h * $dest_w_ratio); } + if ($dest_w_resize < $dest_w) { - $dest_h_ratio = $dest_w / $dest_w_resize; + $dest_h_ratio = $dest_w / $dest_w_resize; + $dest_h_resize = (int)\round($dest_h * $dest_h_ratio); + $dest_w_resize = $dest_w; } // CREATE THE PROPORTIONAL IMAGE RESOURCE + $thumb = \imagecreatetruecolor($dest_w_resize, $dest_h_resize); + if (!\imagecopyresampled($thumb, $original, 0, 0, 0, 0, $dest_w_resize, $dest_h_resize, $original_w, $original_h)) { return false; } // CREATE THE CENTERED CROPPED IMAGE TO THE SPECIFIED DIMENSIONS + $final = \imagecreatetruecolor($dest_w, $dest_h); $dest_w_offset = 0; + $dest_h_offset = 0; + if ($dest_w < $dest_w_resize) { $dest_w_offset = (int)\round(($dest_w_resize - $dest_w) / 2); } else { @@ -174,9 +202,11 @@ public function resizeAndCrop($src_url, $src_mimetype, $dest_url, $dest_w, $dest } // STORE THE FINAL IMAGE - WILL OVERWRITE $dest_url + if (!\imagejpeg($final, $dest_url, $quality)) { return false; } + return true; } @@ -189,9 +219,13 @@ public function resizeAndCrop($src_url, $src_mimetype, $dest_url, $dest_w, $dest public function mergeImage($src_url, $dest_url, $pos, $of) { $dest = \imagecreatefromjpeg($dest_url); - $src = \imagecreatefromjpeg($src_url); + + $src = \imagecreatefromjpeg($src_url); + // ImageCopy ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h ) + // $src = imagecreatefromjpeg($src_url); + if (4 == $of) { switch ($pos) { case 1: @@ -208,6 +242,7 @@ public function mergeImage($src_url, $dest_url, $pos, $of) break; } } + if (6 == $of) { switch ($pos) { case 1: @@ -230,9 +265,11 @@ public function mergeImage($src_url, $dest_url, $pos, $of) break; } } + \imagejpeg($dest, $dest_url); \imagedestroy($src); + \imagedestroy($dest); } diff --git a/class/Common/Images.php b/class/Common/Images.php index f8f2f18..e2cae74 100644 --- a/class/Common/Images.php +++ b/class/Common/Images.php @@ -1,4 +1,4 @@ -initVar('img_id', \XOBJ_DTYPE_INT); + $this->initVar('img_title', \XOBJ_DTYPE_TXTBOX); + $this->initVar('img_desc', \XOBJ_DTYPE_TXTAREA); + $this->initVar('img_name', \XOBJ_DTYPE_TXTBOX); + $this->initVar('img_namelarge', \XOBJ_DTYPE_TXTBOX); + $this->initVar('img_nameorig', \XOBJ_DTYPE_TXTBOX); + $this->initVar('img_mimetype', \XOBJ_DTYPE_TXTBOX); + $this->initVar('img_size', \XOBJ_DTYPE_INT); + $this->initVar('img_resx', \XOBJ_DTYPE_INT); + $this->initVar('img_resy', \XOBJ_DTYPE_INT); + $this->initVar('img_downloads', \XOBJ_DTYPE_INT); + $this->initVar('img_ratinglikes', \XOBJ_DTYPE_INT); + $this->initVar('img_votes', \XOBJ_DTYPE_INT); + $this->initVar('img_weight', \XOBJ_DTYPE_INT); + $this->initVar('img_albid', \XOBJ_DTYPE_INT); + $this->initVar('img_state', \XOBJ_DTYPE_INT); + $this->initVar('img_date', \XOBJ_DTYPE_INT); + $this->initVar('img_submitter', \XOBJ_DTYPE_INT); + $this->initVar('img_ip', \XOBJ_DTYPE_TXTAREA); + $this->initVar('dohtml', \XOBJ_DTYPE_INT, 1, false); } @@ -63,18 +82,18 @@ public function __construct() public static function getInstance() { static $instance = false; + if (!$instance) { $instance = new self(); } } /** - * @return int $newInsertedId + * @return int */ public function getNewInsertedIdImages() { - $newInsertedId = $GLOBALS['xoopsDB']->getInsertId(); - return $newInsertedId; + return $GLOBALS['xoopsDB']->getInsertId(); } /** @@ -84,82 +103,156 @@ public function getNewInsertedIdImages() */ public function getFormImages($action = false) { - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); - $helper = Tdmdownloads\Helper::getInstance(); - if (false === $action) { + + $helper = Tdmdownloads\Helper::getInstance(); + + if (!$action) { $action = $_SERVER['REQUEST_URI']; } + // Title + $title = $this->isNew() ? \sprintf(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_ADD')) : \sprintf(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_EDIT')); + // Get Theme Form + \xoops_load('XoopsFormLoader'); + $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); + $form->setExtra('enctype="multipart/form-data"'); + // Form Text ImgTitle + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_TITLE'), 'img_title', 50, 255, $this->getVar('img_title'))); + // Form editor ImgDesc - $editorConfigs = []; - $editorConfigs['name'] = 'img_desc'; - $editorConfigs['value'] = $this->getVar('img_desc', 'e'); - $editorConfigs['rows'] = 5; - $editorConfigs['cols'] = 40; - $editorConfigs['width'] = '100%'; + + $editorConfigs = []; + + $editorConfigs['name'] = 'img_desc'; + + $editorConfigs['value'] = $this->getVar('img_desc', 'e'); + + $editorConfigs['rows'] = 5; + + $editorConfigs['cols'] = 40; + + $editorConfigs['width'] = '100%'; + $editorConfigs['height'] = '400px'; + $editorConfigs['editor'] = $helper->getConfig('editor'); + $form->addElement(new \XoopsFormEditor(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_DESC'), 'img_desc', $editorConfigs)); + // Form Text ImgName + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_NAME'), 'img_name', 50, 255, $this->getVar('img_name')), true); + // Form Text ImgNameLarge + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_NAMELARGE'), 'img_namelarge', 50, 255, $this->getVar('img_namelarge')), true); + // Form Text ImgOrigname + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_NAMEORIG'), 'img_nameorig', 50, 255, $this->getVar('img_nameorig')), true); + // Form Text ImgMimetype + $imgMimetype = $this->isNew() ? '0' : $this->getVar('img_mimetype'); + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_MIMETYPE'), 'img_mimetype', 20, 150, $imgMimetype)); + // Form Text ImgSize + $imgSize = $this->isNew() ? '0' : $this->getVar('img_size'); + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_SIZE'), 'img_size', 20, 150, $imgSize)); + // Form Text ImgResx + $imgResx = $this->isNew() ? '0' : $this->getVar('img_resx'); + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_RESX'), 'img_resx', 20, 150, $imgResx)); + // Form Text ImgResy + $imgResy = $this->isNew() ? '0' : $this->getVar('img_resy'); + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_RESY'), 'img_resy', 20, 150, $imgResy)); + // Form Text ImgDownloads + $imgDownloads = $this->isNew() ? '0' : $this->getVar('img_downloads'); + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_DOWNLOADS'), 'img_downloads', 20, 150, $imgDownloads)); + // Form Text ImgRatinglikes + $imgRatinglikes = $this->isNew() ? '0' : $this->getVar('img_ratinglikes'); + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_RATINGLIKES'), 'img_ratinglikes', 20, 150, $imgRatinglikes)); + // Form Text ImgVotes + $imgVotes = $this->isNew() ? '0' : $this->getVar('img_votes'); + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_VOTES'), 'img_votes', 20, 150, $imgVotes)); + // Form Text ImgWeight + $imgWeight = $this->isNew() ? '0' : $this->getVar('img_weight'); + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WEIGHT'), 'img_weight', 20, 150, $imgWeight)); + // Form Table albums - $albumsHandler = $helper->getHandler('Albums'); + + $albumsHandler = $helper->getHandler('Albums'); + $imgAlbidSelect = new \XoopsFormSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_ALBID'), 'img_albid', $this->getVar('img_albid')); + $imgAlbidSelect->addOptionArray($albumsHandler->getList()); + $form->addElement($imgAlbidSelect, true); + // Images handler + $imagesHandler = $helper->getHandler('Images'); + // Form Select Images + $imgStateSelect = new \XoopsFormSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_STATE'), 'img_state', $this->getVar('img_state')); + $imgStateSelect->addOption('Empty'); + $imgStateSelect->addOptionArray($imagesHandler->getList()); + $form->addElement($imgStateSelect, true); + // Form Text Date Select ImgDate + $imgDate = $this->isNew() ? 0 : $this->getVar('img_date'); + $form->addElement(new \XoopsFormTextDateSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'DATE'), 'img_date', '', $imgDate)); + // Form Select User ImgSubmitter + $form->addElement(new \XoopsFormSelectUser(\constant('CO_' . $moduleDirNameUpper . '_' . 'SUBMITTER'), 'img_submitter', false, $this->getVar('img_submitter'))); + // Form Text ImgIp + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_IP'), 'img_ip', 50, 255, $this->getVar('img_ip'))); + // To Save + $form->addElement(new \XoopsFormHidden('op', 'save')); + $form->addElement(new \XoopsFormButtonTray('', \_SUBMIT, 'submit', '', false)); + return $form; } @@ -172,38 +265,70 @@ public function getFormImages($action = false) */ public function getValuesImages($keys = null, $format = null, $maxDepth = null) { - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); - $helper = Tdmdownloads\Helper::getInstance(); - $ret = $this->getValues($keys, $format, $maxDepth); - $ret['id'] = $this->getVar('img_id'); - $ret['title'] = $this->getVar('img_title'); - $ret['desc'] = $this->getVar('img_desc', 'n'); - $ret['name'] = $this->getVar('img_name'); - $ret['namelarge'] = $this->getVar('img_namelarge'); - $ret['nameorig'] = $this->getVar('img_nameorig'); - $ret['mimetype'] = $this->getVar('img_mimetype'); - $ret['size'] = $this->getVar('img_size'); - $ret['resx'] = $this->getVar('img_resx'); - $ret['resy'] = $this->getVar('img_resy'); - $ret['downloads'] = $this->getVar('img_downloads'); + + $helper = Tdmdownloads\Helper::getInstance(); + + $ret = $this->getValues($keys, $format, $maxDepth); + + $ret['id'] = $this->getVar('img_id'); + + $ret['title'] = $this->getVar('img_title'); + + $ret['desc'] = $this->getVar('img_desc', 'n'); + + $ret['name'] = $this->getVar('img_name'); + + $ret['namelarge'] = $this->getVar('img_namelarge'); + + $ret['nameorig'] = $this->getVar('img_nameorig'); + + $ret['mimetype'] = $this->getVar('img_mimetype'); + + $ret['size'] = $this->getVar('img_size'); + + $ret['resx'] = $this->getVar('img_resx'); + + $ret['resy'] = $this->getVar('img_resy'); + + $ret['downloads'] = $this->getVar('img_downloads'); + $ret['ratinglikes'] = $this->getVar('img_ratinglikes'); - $ret['votes'] = $this->getVar('img_votes'); - $ret['weight'] = $this->getVar('img_weight'); - $ret['albid'] = $this->getVar('img_albid'); + + $ret['votes'] = $this->getVar('img_votes'); + + $ret['weight'] = $this->getVar('img_weight'); + + $ret['albid'] = $this->getVar('img_albid'); + //$albums = $helper->getHandler('Albums'); + //$albumsObj = $albums->get($this->getVar('img_albid')); + //if (isset($albumsObj) && is_object($albumsObj)) { + //$ret['alb_name'] = $albumsObj->getVar('alb_name'); + //} - $ret['state'] = $this->getVar('img_state'); + + $ret['state'] = $this->getVar('img_state'); + $ret['state_text'] = $helper->getStateText($this->getVar('img_state')); - $ret['date'] = \formatTimestamp($this->getVar('img_date'), 's'); - $ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('img_submitter')); - $ret['ip'] = $this->getVar('img_ip'); - $ret['large'] = \constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_URL') . '/large/' . $this->getVar('img_namelarge'); - $ret['medium'] = \constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_URL') . '/medium/' . $this->getVar('img_name'); - $ret['thumb'] = \constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_URL') . '/thumbs/' . $this->getVar('img_name'); + + $ret['date'] = \formatTimestamp($this->getVar('img_date'), 's'); + + $ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('img_submitter')); + + $ret['ip'] = $this->getVar('img_ip'); + + $ret['large'] = \constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_URL') . '/large/' . $this->getVar('img_namelarge'); + + $ret['medium'] = \constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_URL') . '/medium/' . $this->getVar('img_name'); + + $ret['thumb'] = \constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_URL') . '/thumbs/' . $this->getVar('img_name'); + return $ret; } @@ -214,11 +339,14 @@ public function getValuesImages($keys = null, $format = null, $maxDepth = null) */ public function toArrayImages() { - $ret = []; + $ret = []; + $vars = $this->getVars(); + foreach (\array_keys($vars) as $var) { $ret[$var] = $this->getVar('"{$var}"'); } + return $ret; } } diff --git a/class/Common/ImagesHandler.php b/class/Common/ImagesHandler.php index ba2c495..bef5812 100644 --- a/class/Common/ImagesHandler.php +++ b/class/Common/ImagesHandler.php @@ -1,4 +1,4 @@ - - Website: */ -use XoopsModules\Tdmdownloads; - /** * Class Object Handler Images */ @@ -28,10 +26,9 @@ class ImagesHandler extends \XoopsPersistableObjectHandler { /** * Constructor - * - * @param null|\XoopsDatabase $db + * @param \XoopsDatabase|null $db */ - public function __construct(\XoopsDatabase $db = null) + public function __construct(?\XoopsDatabase $db = null) { parent::__construct($db, 'tdmdownloads_images', Images::class, 'img_id', 'img_name'); } @@ -39,8 +36,8 @@ public function __construct(\XoopsDatabase $db = null) /** * retrieve a field * - * @param int $i field id - * @param null fields + * @param int $i field id + * @param null|mixed $fields * @return mixed reference to the {@link Get} object */ public function get($i = null, $fields = null) @@ -71,7 +68,9 @@ public function getInsertId() public function getCountImages($albId = 0, $start = 0, $limit = 0, $sort = 'img_id ASC, img_name', $order = 'ASC') { $crCountImages = new \CriteriaCompo(); + $crCountImages = $this->getImagesCriteria($crCountImages, $albId, $start, $limit, $sort, $order); + return parent::getCount($crCountImages); } @@ -86,7 +85,9 @@ public function getCountImages($albId = 0, $start = 0, $limit = 0, $sort = 'img_ public function getAllImages($start = 0, $limit = 0, $sort = 'img_id ASC, img_name', $order = 'ASC') { $crAllImages = new \CriteriaCompo(); + $crAllImages = $this->getImagesCriteria($crAllImages, 0, $start, $limit, $sort, $order); + return parent::getAll($crAllImages); } @@ -102,13 +103,18 @@ public function getAllImages($start = 0, $limit = 0, $sort = 'img_id ASC, img_na */ private function getImagesCriteria($crImages, $albId, $start, $limit, $sort, $order) { - if (0 < $albId) { + if ($albId > 0) { $crImages->add(new \Criteria('img_albid', $albId)); } + $crImages->setStart($start); + $crImages->setLimit($limit); + $crImages->setSort($sort); + $crImages->setOrder($order); + return $crImages; } @@ -120,14 +126,19 @@ private function getImagesCriteria($crImages, $albId, $start, $limit, $sort, $or public function unlinkImages($imageName) { \unlink(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/large/' . $imageName); + if (\file_exists(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/large/' . $imageName)) { return false; } + \unlink(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/medium/' . $imageName); + if (\file_exists(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/medium/' . $imageName)) { return false; } + \unlink(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/thumbs/' . $imageName); + if (\file_exists(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/thumbs/' . $imageName)) { return false; } diff --git a/class/Common/Migrate.php b/class/Common/Migrate.php index c11fff8..309c1b6 100644 --- a/class/Common/Migrate.php +++ b/class/Common/Migrate.php @@ -1,4 +1,4 @@ -renameTables = $configurator->renameTables; $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + parent::__construct($moduleDirName); } @@ -65,12 +69,16 @@ private function convertIPAddresses($tableName, $columnName) { if ($this->tableHandler->useTable($tableName)) { $attributes = $this->tableHandler->getColumnAttributes($tableName, $columnName); + if (false !== \mb_strpos($attributes, ' int(')) { if (false === \mb_strpos($attributes, 'unsigned')) { $this->tableHandler->alterColumn($tableName, $columnName, " bigint(16) NOT NULL DEFAULT '0' "); + $this->tableHandler->update($tableName, [$columnName => "4294967296 + $columnName"], "WHERE $columnName < 0", false); } + $this->tableHandler->alterColumn($tableName, $columnName, " varchar(45) NOT NULL DEFAULT '' "); + $this->tableHandler->update($tableName, [$columnName => "INET_NTOA($columnName)"], '', false); } } @@ -81,16 +89,23 @@ private function convertIPAddresses($tableName, $columnName) */ private function moveDoColumns() { - $tableName = 'newbb_posts_text'; + $tableName = 'newbb_posts_text'; + $srcTableName = 'newbb_posts'; + if ($this->tableHandler->useTable($tableName) && $this->tableHandler->useTable($srcTableName)) { $attributes = $this->tableHandler->getColumnAttributes($tableName, 'dohtml'); + if (false === $attributes) { $this->synchronizeTable($tableName); + $updateTable = $GLOBALS['xoopsDB']->prefix($tableName); - $joinTable = $GLOBALS['xoopsDB']->prefix($srcTableName); - $sql = "UPDATE `$updateTable` t1 INNER JOIN `$joinTable` t2 ON t1.post_id = t2.post_id \n" . "SET t1.dohtml = t2.dohtml, t1.dosmiley = t2.dosmiley, t1.doxcode = t2.doxcode\n" . ' , t1.doimage = t2.doimage, t1.dobr = t2.dobr'; + + $joinTable = $GLOBALS['xoopsDB']->prefix($srcTableName); + + $sql = "UPDATE `$updateTable` t1 INNER JOIN `$joinTable` t2 ON t1.post_id = t2.post_id \n" . "SET t1.dohtml = t2.dohtml, t1.dosmiley = t2.dosmiley, t1.doxcode = t2.doxcode\n" . ' , t1.doimage = t2.doimage, t1.dobr = t2.dobr'; + $this->tableHandler->addToQueue($sql); } } diff --git a/class/Common/ServerStats.php b/class/Common/ServerStats.php index 6ca20d7..f82737b 100644 --- a/class/Common/ServerStats.php +++ b/class/Common/ServerStats.php @@ -1,4 +1,4 @@ -prefix('wfdownloads_meta'); + // $sql .= " WHERE metakey='version' LIMIT 1"; + // $query = $GLOBALS['xoopsDB']->query($sql); + // list($meta) = $GLOBALS['xoopsDB']->fetchRow($query); + $html .= "
      " . \constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "\n"; + $html .= "
      \n"; + // $html .= '
      ' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "
      \n"; + // $html .= "
      \n"; + // $html .= "
      \n"; + $html .= '
      ' . \constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "
      \n"; + $html .= "
        \n"; $gdlib = \function_exists('gd_info') ? '' . \constant('CO_' . $moduleDirNameUpper . '_GDON') . '' : '' . \constant('CO_' . $moduleDirNameUpper . '_GDOFF') . ''; - $html .= '
      • ' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; + + $html .= '
      • ' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; + if (\function_exists('gd_info')) { if (true === $gdlib = gd_info()) { $html .= '
      • ' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '' . $gdlib['GD Version'] . ''; } } - // + // $safemode = ini_get('safe_mode') ? constant('CO_' . $moduleDirNameUpper . '_ON') . constant('CO_' . $moduleDirNameUpper . '_SAFEMODEPROBLEMS : constant('CO_' . $moduleDirNameUpper . '_OFF'); + // $html .= '
      • ' . constant('CO_' . $moduleDirNameUpper . '_SAFEMODESTATUS . $safemode; - // + // $registerglobals = (!ini_get('register_globals')) ? "" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '' : "" . constant('CO_' . $moduleDirNameUpper . '_ON') . ''; + // $html .= '
      • ' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals; - // + $downloads = \ini_get('file_uploads') ? '' . \constant('CO_' . $moduleDirNameUpper . '_ON') . '' : '' . \constant('CO_' . $moduleDirNameUpper . '_OFF') . ''; - $html .= '
      • ' . \constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; + + $html .= '
      • ' . \constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; $html .= '
      • ' . \constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' ' . \ini_get('upload_max_filesize') . "\n"; + $html .= '
      • ' . \constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' ' . \ini_get('post_max_size') . "\n"; + $html .= '
      • ' . \constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' ' . \ini_get('memory_limit') . "\n"; + $html .= "
      \n"; + $html .= "
        \n"; + $html .= '
      • ' . \constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' ' . XOOPS_ROOT_PATH . "\n"; + $html .= "
      \n"; + $html .= "
      \n"; + $html .= \constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n"; + $html .= '
      '; + $html .= '

      '; return $html; diff --git a/class/Common/SysUtility.php b/class/Common/SysUtility.php index 8fa794e..997a767 100644 --- a/class/Common/SysUtility.php +++ b/class/Common/SysUtility.php @@ -1,4 +1,4 @@ - * @author Mamba */ -use MyTextSanitizer; -use XoopsFormDhtmlTextArea; -use XoopsFormTextArea; -use XoopsModules\Tdmdownloads; use XoopsModules\Tdmdownloads\Helper; /** @@ -65,62 +60,92 @@ public static function truncateHtml($text, $length = 100, $ending = '...', $exac { if ($considerHtml) { // if the plain text is shorter than the maximum length, return the whole text + if (\mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) { return $text; } + // splits all html-tags to scanable lines + \preg_match_all('/(<.+?' . '>)?([^<>]*)/s', $text, $lines, \PREG_SET_ORDER); + $total_length = \mb_strlen($ending); - $open_tags = []; - $truncate = ''; + + $open_tags = []; + + $truncate = ''; + foreach ($lines as $line_matchings) { // if there is any html-tag in this line, handle it and add it (uncounted) to the output + if (!empty($line_matchings[1])) { // if it's an "empty element" with or without xhtml-conform closing slash + if (\preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) { // do nothing // if tag is a closing tag } elseif (\preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) { // delete tag from $open_tags list + $pos = \array_search($tag_matchings[1], $open_tags, true); + if (false !== $pos) { unset($open_tags[$pos]); } // if tag is an opening tag } elseif (\preg_match('/^<\s*([^\s>!]+).*?' . '>$/s', $line_matchings[1], $tag_matchings)) { // add tag to the beginning of $open_tags list + \array_unshift($open_tags, \mb_strtolower($tag_matchings[1])); } + // add html-tag to $truncate'd text + $truncate .= $line_matchings[1]; } + // calculate the length of the plain text part of the line; handle entities as one character + $content_length = \mb_strlen(\preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2])); + if ($total_length + $content_length > $length) { // the number of characters which are left - $left = $length - $total_length; + + $left = $length - $total_length; + $entities_length = 0; + // search for html entities + if (\preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, \PREG_OFFSET_CAPTURE)) { // calculate the real length of all entities in the legal range + foreach ($entities[0] as $entity) { if ($left >= $entity[1] + 1 - $entities_length) { $left--; + $entities_length += \mb_strlen($entity[0]); } else { // no more characters left + break; } } } + $truncate .= \mb_substr($line_matchings[2], 0, $left + $entities_length); + // maximum lenght is reached, so get off the loop + break; } - $truncate .= $line_matchings[2]; + + $truncate .= $line_matchings[2]; + $total_length += $content_length; // if the maximum length is reached, get off the loop + if ($total_length >= $length) { break; } @@ -129,21 +154,31 @@ public static function truncateHtml($text, $length = 100, $ending = '...', $exac if (\mb_strlen($text) <= $length) { return $text; } + $truncate = \mb_substr($text, 0, $length - \mb_strlen($ending)); } + // if the words shouldn't be cut in the middle... + if (!$exact) { // ...search the last occurance of a space... + $spacepos = \mb_strrpos($truncate, ' '); + if (isset($spacepos)) { // ...and cut the text in this position + $truncate = \mb_substr($truncate, 0, $spacepos); } } + // add the defined ending to the text + $truncate .= $ending; + if ($considerHtml) { // close all unclosed html-tags + foreach ($open_tags as $tag) { $truncate .= ''; } @@ -160,13 +195,20 @@ public static function truncateHtml($text, $length = 100, $ending = '...', $exac public static function getEditor($helper = null, $options = null) { /** @var Helper $helper */ + if (null === $options) { - $options = []; - $options['name'] = 'Editor'; - $options['value'] = 'Editor'; - $options['rows'] = 10; - $options['cols'] = '100%'; - $options['width'] = '100%'; + $options = []; + + $options['name'] = 'Editor'; + + $options['value'] = 'Editor'; + + $options['rows'] = 10; + + $options['cols'] = '100%'; + + $options['width'] = '100%'; + $options['height'] = '400px'; } @@ -200,8 +242,9 @@ public static function getEditor($helper = null, $options = null) public function fieldExists($fieldname, $table) { global $xoopsDB; + $result = $xoopsDB->queryF("SHOW COLUMNS FROM $table LIKE '$fieldname'"); - return ($xoopsDB->getRowsNum($result) > 0); + return $xoopsDB->getRowsNum($result) > 0; } } diff --git a/class/Common/VersionChecks.php b/class/Common/VersionChecks.php index 6a889a3..c5f4ffa 100644 --- a/class/Common/VersionChecks.php +++ b/class/Common/VersionChecks.php @@ -1,4 +1,4 @@ -getInfo('min_xoops'); //making sure it's a string } + $success = true; if (\version_compare($currentVer, $requiredVer, '<')) { $success = false; + $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer)); } @@ -53,32 +57,38 @@ public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = } /** - * * Verifies PHP version meets minimum requirements for this module * @static - * @param \XoopsModule|null $module * + * @param \XoopsModule|null $module * @return bool true if meets requirements, false if not */ - public static function checkVerPhp(\XoopsModule $module = null) + public static function checkVerPhp(?\XoopsModule $module = null) { - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); + if (null === $module) { $module = \XoopsModule::getByDirname($moduleDirName); } + \xoops_loadLanguage('admin', $moduleDirName); + \xoops_loadLanguage('common', $moduleDirName); // check for minimum PHP version + $success = true; $verNum = \PHP_VERSION; + $reqVer = &$module->getInfo('min_php'); if (false !== $reqVer && '' !== $reqVer) { if (\version_compare($verNum, $reqVer, '<')) { $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum)); + $success = false; } } @@ -87,7 +97,6 @@ public static function checkVerPhp(\XoopsModule $module = null) } /** - * * compares current module version with latest GitHub release * @static * @param \Xmf\Module\Helper $helper @@ -96,55 +105,84 @@ public static function checkVerPhp(\XoopsModule $module = null) * * @return string|array info about the latest module version, if newer */ - public static function checkVerModule($helper, $source = 'github', $default = 'master') { - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); - $update = ''; - $repository = 'XoopsModules25x/' . $moduleDirName; + + $update = ''; + + $repository = 'XoopsModules25x/' . $moduleDirName; + // $repository = 'XoopsModules25x/publisher'; //for testing only - $ret = ''; + + $ret = ''; + $infoReleasesUrl = "https://api.github.com/repos/$repository/releases"; + if ('github' === $source) { if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init())) { \curl_setopt($curlHandle, \CURLOPT_URL, $infoReleasesUrl); + \curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); + \curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized' + \curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]); + $curlReturn = \curl_exec($curlHandle); + if (false === $curlReturn) { \trigger_error(\curl_error($curlHandle)); - } elseif (false !== \strpos($curlReturn, 'Not Found')) { + } elseif (false !== \mb_strpos($curlReturn, 'Not Found')) { \trigger_error('Repository Not Found: ' . $infoReleasesUrl); } else { - $file = \json_decode($curlReturn, false); + $file = \json_decode($curlReturn, false); + $latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default); - $latestVersion = $file[0]->tag_name; - $prerelease = $file[0]->prerelease; + + $latestVersion = $file[0]->tag_name; + + $prerelease = $file[0]->prerelease; + if ('master' !== $latestVersionLink) { $update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion; } + //"PHP-standardized" version + $latestVersion = \mb_strtolower($latestVersion); + if (false !== \mb_strpos($latestVersion, 'final')) { $latestVersion = \str_replace('_', '', \mb_strtolower($latestVersion)); + $latestVersion = \str_replace('final', '', \mb_strtolower($latestVersion)); } - $moduleVersion = ($helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status')); + + $moduleVersion = $helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status'); + //"PHP-standardized" version + $moduleVersion = \str_replace(' ', '', \mb_strtolower($moduleVersion)); + // $moduleVersion = '1.0'; //for testing only + // $moduleDirName = 'publisher'; //for testing only + if (!$prerelease && \version_compare($moduleVersion, $latestVersion, '<')) { - $ret = []; + $ret = []; + $ret[] = $update; + $ret[] = $latestVersionLink; } } + \curl_close($curlHandle); } } + return $ret; } } diff --git a/class/Constants.php b/class/Constants.php index 4973d6c..315a502 100644 --- a/class/Constants.php +++ b/class/Constants.php @@ -1,4 +1,4 @@ -initVar('downlimit_id', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('downlimit_lid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('downlimit_uid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('downlimit_hostname', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('downlimit_date', \XOBJ_DTYPE_INT, null, false, 10); } } diff --git a/class/DownlimitHandler.php b/class/DownlimitHandler.php index cb7f477..017590e 100644 --- a/class/DownlimitHandler.php +++ b/class/DownlimitHandler.php @@ -1,4 +1,4 @@ -initVar('lid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('cid', \XOBJ_DTYPE_INT, null, false, 5); + $this->initVar('title', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('url', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('homepage', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('version', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('size', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('platform', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('description', \XOBJ_DTYPE_TXTAREA, null, false); + // Pour autoriser le html + $this->initVar('dohtml', \XOBJ_DTYPE_INT, 1, false); + $this->initVar('logourl', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('submitter', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('status', \XOBJ_DTYPE_INT, null, false, 2); + $this->initVar('date', \XOBJ_DTYPE_INT, null, false, 10); + $this->initVar('hits', \XOBJ_DTYPE_INT, null, false, 10); + $this->initVar('rating', \XOBJ_DTYPE_OTHER, null, false, 10); + $this->initVar('votes', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('comments', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('top', \XOBJ_DTYPE_INT, null, false, 2); + $this->initVar('paypal', \XOBJ_DTYPE_TXTBOX, null, false); //pour les jointures: + $this->initVar('cat_title', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('cat_imgurl', \XOBJ_DTYPE_TXTBOX, null, false); } @@ -61,7 +85,9 @@ public function __construct() public function getNewEnreg($db = null) { $newEnreg = 0; + /** @var \XoopsMySQLDatabase $db */ + if (null !== $db) { $newEnreg = $db->getInsertId(); } @@ -78,51 +104,83 @@ public function getNewEnreg($db = null) public function getForm($donnee = [], $erreur = false, $action = false) { global $xoopsModule, $xoopsUser; + /** @var \XoopsModules\Tdmdownloads\Helper $helper */ + $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); + /** @var \XoopsModules\Tdmdownloads\Utility $utility */ - $utility = new \XoopsModules\Tdmdownloads\Utility(); + + $utility = new \XoopsModules\Tdmdownloads\Utility(); + $moduleDirName = \basename(\dirname(__DIR__)); - if (false === $action) { + + if (!$action) { $action = $_SERVER['REQUEST_URI']; } + //permission pour uploader + /** @var \XoopsGroupPermHandler $grouppermHandler */ + $grouppermHandler = \xoops_getHandler('groupperm'); - $groups = \is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; + + $groups = \is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; + if ($xoopsUser) { $perm_upload = true; + if (!$xoopsUser->isAdmin($xoopsModule->mid())) { $perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')); } } else { $perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')); } + //nom du formulaire selon l'action (editer ou ajouter): + $title = $this->isNew() ? \sprintf(_AM_TDMDOWNLOADS_FORMADD) : \sprintf(_AM_TDMDOWNLOADS_FORMEDIT); //création du formulaire + $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); + $form->setExtra('enctype="multipart/form-data"'); + //titre + $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_FORMTITLE, 'title', 50, 255, $this->getVar('title')), true); + // fichier + $fichier = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMFILE, '

      '); - $url = $this->isNew() ? 'http://' : $this->getVar('url'); + + $url = $this->isNew() ? 'http://' : $this->getVar('url'); + $formurl = new \XoopsFormText(_AM_TDMDOWNLOADS_FORMURL, 'url', 75, 255, $url); + $fichier->addElement($formurl, false); - if (true === $perm_upload) { + + if ($perm_upload) { $fichier->addElement(new \XoopsFormFile(_AM_TDMDOWNLOADS_FORMUPLOAD, 'attachedfile', $helper->getConfig('maxuploadsize')), false); } + $form->addElement($fichier); //catégorie + /** @var \XoopsModules\Tdmdownloads\CategoryHandler $categoryHandler */ + $categoryHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Category'); - $categories = $utility->getItemIds('tdmdownloads_submit', $moduleDirName); - $criteria = new \CriteriaCompo(); + + $categories = $utility->getItemIds('tdmdownloads_submit', $moduleDirName); + + $criteria = new \CriteriaCompo(); + $criteria->setSort('cat_weight ASC, cat_title'); + $criteria->setOrder('ASC'); + if ($xoopsUser) { if (!$xoopsUser->isAdmin($xoopsModule->mid())) { $criteria->add(new \Criteria('cat_cid', '(' . \implode(',', $categories) . ')', 'IN')); @@ -130,50 +188,73 @@ public function getForm($donnee = [], $erreur = false, $action = false) } else { $criteria->add(new \Criteria('cat_cid', '(' . \implode(',', $categories) . ')', 'IN')); } + $downloadscatArray = $categoryHandler->getAll($criteria); + if (empty($downloadscatArray)) { \redirect_header('index.php', 2, \_NOPERM); } + $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); + $form->addElement($mytree->makeSelectElement('cid', 'cat_title', '--', $this->getVar('cid'), true, 0, '', _AM_TDMDOWNLOADS_FORMINCAT), true); //affichage des champs + /** @var \XoopsModules\Tdmdownloads\FieldHandler $fieldHandler */ + $fieldHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Field'); - $criteria = new \CriteriaCompo(); + + $criteria = new \CriteriaCompo(); + $criteria->setSort('weight ASC, title'); + $criteria->setOrder('ASC'); + /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloads_field */ + $downloads_field = $fieldHandler->getAll($criteria); + foreach (\array_keys($downloads_field) as $i) { /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ + if (1 == $downloads_field[$i]->getVar('status_def')) { if (1 == $downloads_field[$i]->getVar('fid')) { //page d'accueil + if (1 == $downloads_field[$i]->getVar('status')) { $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_FORMHOMEPAGE, 'homepage', 50, 255, $this->getVar('homepage'))); } else { $form->addElement(new \XoopsFormHidden('homepage', '')); } } + if (2 == $downloads_field[$i]->getVar('fid')) { //version + if (1 == $downloads_field[$i]->getVar('status')) { $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_FORMVERSION, 'version', 10, 255, $this->getVar('version'))); } else { $form->addElement(new \XoopsFormHidden('version', '')); } } + if (3 == $downloads_field[$i]->getVar('fid')) { //taille du fichier + if (1 == $downloads_field[$i]->getVar('status')) { $size_value_arr = \explode(' ', $this->getVar('size')); - $aff_size = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMSIZE, ''); + + $aff_size = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMSIZE, ''); + $aff_size->addElement(new \XoopsFormText('', 'sizeValue', 13, 13, $size_value_arr[0])); - if (false === \array_key_exists(1, $size_value_arr)) { + + if (!\array_key_exists(1, $size_value_arr)) { $size_value_arr[1] = 'K'; } - $type = new \XoopsFormSelect('', 'sizeType', $size_value_arr[1]); + + $type = new \XoopsFormSelect('', 'sizeType', $size_value_arr[1]); + $typeArray = [ 'B' => _AM_TDMDOWNLOADS_BYTES, 'K' => _AM_TDMDOWNLOADS_KBYTES, @@ -181,52 +262,75 @@ public function getForm($donnee = [], $erreur = false, $action = false) 'G' => _AM_TDMDOWNLOADS_GBYTES, 'T' => _AM_TDMDOWNLOADS_TBYTES, ]; + $type->addOptionArray($typeArray); + $aff_size->addElement($type); + $form->addElement($aff_size); } else { $form->addElement(new \XoopsFormHidden('size', '')); + $form->addElement(new \XoopsFormHidden('type_size', '')); } } + if (4 == $downloads_field[$i]->getVar('fid')) { //plateforme + if (1 == $downloads_field[$i]->getVar('status')) { $platformselect = new \XoopsFormSelect(_AM_TDMDOWNLOADS_FORMPLATFORM, 'platform', \explode('|', $this->getVar('platform')), 5, true); - $platformArray = \explode('|', $helper->getConfig('platform')); + + $platformArray = \explode('|', $helper->getConfig('platform')); + foreach ($platformArray as $platform) { $platformselect->addOption((string)$platform, $platform); } + $form->addElement($platformselect, false); } else { $form->addElement(new \XoopsFormHidden('platform', '')); } } } else { - $contenu = ''; + $contenu = ''; + $contenu_iddata = ''; - $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); + + $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); + /** @var \XoopsModules\Tdmdownloads\FielddataHandler $fielddataHandler */ + $fielddataHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Fielddata'); - $criteria = new \CriteriaCompo(); + + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('lid', $this->getVar('lid'))); + $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid'))); + $downloadsfielddata = $fielddataHandler->getAll($criteria); + foreach (\array_keys($downloadsfielddata) as $j) { /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloadsfielddata */ - if (true === $erreur) { + + if ($erreur) { $contenu = $donnee[$fieldName]; } else { if (!$this->isNew()) { $contenu = $downloadsfielddata[$j]->getVar('data'); } } + $contenu_iddata = $downloadsfielddata[$j]->getVar('iddata'); } + $iddata = 'iddata' . $downloads_field[$i]->getVar('fid'); + if (!$this->isNew()) { $form->addElement(new \XoopsFormHidden($iddata, $contenu_iddata)); } + if (1 == $downloads_field[$i]->getVar('status')) { $form->addElement(new \XoopsFormText($downloads_field[$i]->getVar('title'), $fieldName, 50, 255, $contenu)); } else { @@ -234,125 +338,196 @@ public function getForm($donnee = [], $erreur = false, $action = false) } } } + //description - $editorConfigs = []; - $editorConfigs['name'] = 'description'; - $editorConfigs['value'] = $this->getVar('description', 'e'); - $editorConfigs['rows'] = 20; - $editorConfigs['cols'] = 100; - $editorConfigs['width'] = '100%'; + + $editorConfigs = []; + + $editorConfigs['name'] = 'description'; + + $editorConfigs['value'] = $this->getVar('description', 'e'); + + $editorConfigs['rows'] = 20; + + $editorConfigs['cols'] = 100; + + $editorConfigs['width'] = '100%'; + $editorConfigs['height'] = '400px'; + $editorConfigs['editor'] = $helper->getConfig('editor'); + $form->addElement(new \XoopsFormEditor(_AM_TDMDOWNLOADS_FORMTEXTDOWNLOADS, 'description', $editorConfigs), true); + //tag - if ((1 == $helper->getConfig('usetag')) && \class_exists(FormTag::class)) { + if (1 == $helper->getConfig('usetag') && \class_exists(FormTag::class)) { $tagId = $this->isNew() ? 0 : $this->getVar('lid'); - if (true === $erreur) { + + if ($erreur) { $tagId = $donnee['TAG']; } + $form->addElement(new \XoopsModules\Tag\FormTag('tag', 60, 255, $tagId, 0)); } //image + if ($helper->getConfig('useshots')) { - $uploaddir = XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/shots/' . $this->getVar('logourl'); + $uploaddir = XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/shots/' . $this->getVar('logourl'); + $categoryImage = $this->getVar('logourl') ?: 'blank.gif'; + if (!\is_file($uploaddir)) { $categoryImage = 'blank.gif'; } + $uploadirectory = '/uploads/' . $moduleDirName . '/images/shots'; - $imgtray = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMIMG, '
      '); - $imgpath = \sprintf(_AM_TDMDOWNLOADS_FORMPATH, $uploadirectory); - $imageselect = new \XoopsFormSelect($imgpath, 'logo_img', $categoryImage); - $topics_array = \XoopsLists:: getImgListAsArray(XOOPS_ROOT_PATH . $uploadirectory); + + $imgtray = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMIMG, '
      '); + + $imgpath = \sprintf(_AM_TDMDOWNLOADS_FORMPATH, $uploadirectory); + + $imageselect = new \XoopsFormSelect($imgpath, 'logo_img', $categoryImage); + + $topics_array = \XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . $uploadirectory); + foreach ($topics_array as $image) { $imageselect->addOption($image, $image); } + $imageselect->setExtra("onchange='showImgSelected(\"image3\", \"logo_img\", \"" . $uploadirectory . '", "", "' . XOOPS_URL . "\")'"); + $imgtray->addElement($imageselect, false); + $imgtray->addElement(new \XoopsFormLabel('', "
      ")); + $fileseltray = new \XoopsFormElementTray('', '
      '); - if (true === $perm_upload) { + + if ($perm_upload) { $fileseltray->addElement(new \XoopsFormFile(_AM_TDMDOWNLOADS_FORMUPLOAD, 'attachedimage', $helper->getConfig('maxuploadsize')), false); } + $imgtray->addElement($fileseltray); + $form->addElement($imgtray); } + // pour changer de poster et pour ne pas mettre à jour la date: if ($xoopsUser) { if ($xoopsUser->isAdmin($xoopsModule->mid())) { // auteur + if ($this->isNew()) { - $submitter = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0; + $submitter = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0; + $donnee['date_update'] = 0; } else { $submitter = $this->getVar('submitter'); - $v_date = $this->getVar('date'); + + $v_date = $this->getVar('date'); } - if (true === $erreur) { + + if ($erreur) { $date_update = $donnee['date_update']; - $v_status = $donnee['status']; - $submitter = $donnee['submitter']; + + $v_status = $donnee['status']; + + $submitter = $donnee['submitter']; } else { $date_update = 'N'; - $v_status = 1; + + $v_status = 1; } + $form->addElement(new \XoopsFormSelectUser(_AM_TDMDOWNLOADS_FORMSUBMITTER, 'submitter', true, $submitter, 1, false), true); // date + if (!$this->isNew()) { $selection_date = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMDATEUPDATE); - $date = new \XoopsFormRadio('', 'date_update', $date_update); - $options = [ + + $date = new \XoopsFormRadio('', 'date_update', $date_update); + + $options = [ 'N' => _AM_TDMDOWNLOADS_FORMDATEUPDATE_NO . ' (' . \formatTimestamp($v_date, 's') . ')', 'Y' => _AM_TDMDOWNLOADS_FORMDATEUPDATE_YES, ]; + $date->addOptionArray($options); + $selection_date->addElement($date); + $selection_date->addElement(new \XoopsFormTextDateSelect('', 'date', '', \time())); + $form->addElement($selection_date); } + $status = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_FORMSTATUS, 'status', $v_status); + $status->addOption(1, _AM_TDMDOWNLOADS_FORMSTATUS_OK); + $form->addElement($status); + //permissions pour télécharger + if (2 == $helper->getConfig('permission_download')) { /** @var \XoopsMemberHandler $memberHandler */ - $memberHandler = \xoops_getHandler('member'); - $group_list = $memberHandler->getGroupList(); + + $memberHandler = \xoops_getHandler('member'); + + $group_list = $memberHandler->getGroupList(); + $grouppermHandler = \xoops_getHandler('groupperm'); - $full_list = \array_keys($group_list); + + $full_list = \array_keys($group_list); + global $xoopsModule; + if (!$this->isNew()) { - $item_ids_download = $grouppermHandler->getGroupIds('tdmdownloads_download_item', $this->getVar('lid'), $xoopsModule->getVar('mid')); - $item_ids_downloa = \array_values($item_ids_download); + $item_ids_download = $grouppermHandler->getGroupIds('tdmdownloads_download_item', $this->getVar('lid'), $xoopsModule->getVar('mid')); + + $item_ids_downloa = \array_values($item_ids_download); + $item_news_can_download_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_FORMPERMDOWNLOAD, 'item_download[]', $item_ids_download); } else { $item_news_can_download_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_FORMPERMDOWNLOAD, 'item_download[]', $full_list); } + $item_news_can_download_checkbox->addOptionArray($group_list); + $form->addElement($item_news_can_download_checkbox); } } } + //paypal + if (true === $helper->getConfig('use_paypal')) { $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_FORMPAYPAL, 'paypal', 50, 255, $this->getVar('paypal')), false); } else { $form->addElement(new \XoopsFormHidden('paypal', '')); } + // captcha + $form->addElement(new \XoopsFormCaptcha(), true); + // pour passer "lid" si on modifie la catégorie + if (!$this->isNew()) { $form->addElement(new \XoopsFormHidden('lid', $this->getVar('lid'))); + $form->addElement(new \XoopsFormHidden('downloads_modified', true)); } + //pour enregistrer le formulaire + $form->addElement(new \XoopsFormHidden('op', 'save_downloads')); + //bouton d'envoi du formulaire + $form->addElement(new \XoopsFormButtonTray('', \_SUBMIT, 'submit', 'submit', false)); return $form; diff --git a/class/DownloadsHandler.php b/class/DownloadsHandler.php index 2509ab7..f0db020 100644 --- a/class/DownloadsHandler.php +++ b/class/DownloadsHandler.php @@ -1,4 +1,4 @@ -initVar('fid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('title', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('img', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('weight', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('status', \XOBJ_DTYPE_INT, null, false, 5); + $this->initVar('search', \XOBJ_DTYPE_INT, null, false, 5); + $this->initVar('status_def', \XOBJ_DTYPE_INT, null, false, 5); //pour les jointures + $this->initVar('data', \XOBJ_DTYPE_TXTAREA, null, false); } @@ -44,7 +53,9 @@ public function __construct() public function getNewEnreg($db = null) { $newEnreg = 0; + /** @var \XoopsMySQLDatabase $db */ + if (null !== $db) { $newEnreg = $db->getInsertId(); } @@ -60,63 +71,103 @@ public function getNewEnreg($db = null) public function getForm($action = false) { /** @var \XoopsModules\Tdmdownloads\Helper $helper */ + $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); $moduleDirName = \basename(\dirname(__DIR__)); - if (false === $action) { + + if (!$action) { $action = $_SERVER['REQUEST_URI']; } + require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; //nom du formulaire selon l'action (editer ou ajouter): + $title = $this->isNew() ? \sprintf(_AM_TDMDOWNLOADS_FORMADD) : \sprintf(_AM_TDMDOWNLOADS_FORMEDIT); //création du formulaire + $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); + $form->setExtra('enctype="multipart/form-data"'); + //titre + if (1 == $this->getVar('status_def')) { $form->addElement(new \XoopsFormLabel(_AM_TDMDOWNLOADS_FORMTITLE, $this->getVar('title'))); + $form->addElement(new \XoopsFormHidden('title', $this->getVar('title'))); } else { $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_FORMTITLE, 'title', 50, 255, $this->getVar('title')), true); } + //image + $downloadsfield_img = $this->getVar('img') ?: 'blank.gif'; - $uploadirectory = '/uploads/' . $moduleDirName . '/images/field'; - $imgtray = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMIMAGE, '
      '); - $imgpath = \sprintf(_AM_TDMDOWNLOADS_FORMPATH, $uploadirectory); - $imageselect = new \XoopsFormSelect($imgpath, 'downloadsfield_img', $downloadsfield_img); - $topics_array = \XoopsLists:: getImgListAsArray(XOOPS_ROOT_PATH . $uploadirectory); + + $uploadirectory = '/uploads/' . $moduleDirName . '/images/field'; + + $imgtray = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMIMAGE, '
      '); + + $imgpath = \sprintf(_AM_TDMDOWNLOADS_FORMPATH, $uploadirectory); + + $imageselect = new \XoopsFormSelect($imgpath, 'downloadsfield_img', $downloadsfield_img); + + $topics_array = \XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . $uploadirectory); + foreach ($topics_array as $image) { $imageselect->addOption($image, $image); } + $imageselect->setExtra("onchange='showImgSelected(\"image3\", \"downloadsfield_img\", \"" . $uploadirectory . '", "", "' . XOOPS_URL . "\")'"); + $imgtray->addElement($imageselect, false); + $imgtray->addElement(new \XoopsFormLabel('', "

      ")); + $fileseltray = new \XoopsFormElementTray('', '
      '); + $fileseltray->addElement(new \XoopsFormFile(_AM_TDMDOWNLOADS_FORMUPLOAD, 'attachedfile', $helper->getConfig('maxuploadsize')), false); + $fileseltray->addElement(new \XoopsFormLabel(''), false); + $imgtray->addElement($fileseltray); + $form->addElement($imgtray); + //poids du champ + $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_FORMWEIGHT, 'weight', 5, 5, $this->getVar('weight', 'e')), false); + // affiché? + $status = $this->getVar('status') ?: 0; + $form->addElement(new \XoopsFormRadioYN(_AM_TDMDOWNLOADS_FORMAFFICHE, 'status', $status)); + // affiché dans le champ de recherche? + $search = $this->getVar('search') ?: 0; + $form->addElement(new \XoopsFormRadioYN(_AM_TDMDOWNLOADS_FORMAFFICHESEARCH, 'search', $search)); + // pour passer "fid" si on modifie le champ + if (!$this->isNew()) { $form->addElement(new \XoopsFormHidden('fid', $this->getVar('fid'))); + $form->addElement(new \XoopsFormHidden('status_def', $this->getVar('status_def'))); } else { $form->addElement(new \XoopsFormHidden('status_def', 0)); } + //pour enregistrer le formulaire + $form->addElement(new \XoopsFormHidden('op', 'save_field')); + //boutton d'envoi du formulaire + $form->addElement(new \XoopsFormButtonTray('', \_SUBMIT, 'submit', 'submit', false)); return $form; diff --git a/class/FieldHandler.php b/class/FieldHandler.php index 19a40a2..605302a 100644 --- a/class/FieldHandler.php +++ b/class/FieldHandler.php @@ -1,4 +1,4 @@ -initVar('iddata', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('fid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('lid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('data', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('dohtml', \XOBJ_DTYPE_INT, 1, false); } } diff --git a/class/FielddataHandler.php b/class/FielddataHandler.php index b5c119c..65b1116 100644 --- a/class/FielddataHandler.php +++ b/class/FielddataHandler.php @@ -1,4 +1,4 @@ -helper */ - $this->helper = $target->helper; + + /** @var \XoopsModules\Tdmdownloads\Helper $this->helper */ + + $this->helper = $target->helper; + $this->targetObject = $target; $title = $this->targetObject->isNew() ? \sprintf(\constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_ADD')) : \sprintf(\constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_EDIT')); + parent::__construct('', 'form', \xoops_getenv('SCRIPT_NAME'), 'post', true); + $this->setExtra('enctype="multipart/form-data"'); //include ID field, it's needed so the module knows if it is a new form or an edited form $hidden = new \XoopsFormHidden('fid', $this->targetObject->getVar('cat_cid')); + $this->addElement($hidden); + unset($hidden); - $categoryHandler = new \XoopsModules\Tdmdownloads\CategoryHandler(); - $start = Request::getInt('start', 0); + $categoryHandler = new \XoopsModules\Tdmdownloads\CategoryHandler(); + + $start = Request::getInt('start', 0); + $catPaginationLimit = $this->helper->getConfig('userpager') ?: 10; $criteria = new \CriteriaCompo(); + $criteria->setOrder('DESC'); + $criteria->setLimit($catPaginationLimit); + $criteria->setStart($start); $catCount = $categoryHandler->getCount($criteria); + $catArray = $categoryHandler->getAll($criteria); // Form Select Category + $categoryIdSelect = new \XoopsFormSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'SELECT'), 'cat_title', $this->targetObject->getVar('cat_cid')); + $categoryIdSelect->setExtra('onchange="submit()"'); + // $categoryIdSelect->addOption(0, ' '); foreach (\array_keys($catArray) as $i) { $catName = $catArray[$i]->getVar('cat_title'); - $catPid = $catArray[$i]->getVar('cat_pid'); - if (0 < $catPid) { + + $catPid = $catArray[$i]->getVar('cat_pid'); + + if ($catPid > 0) { $categoryObj = $categoryHandler->get($catPid); + if (\is_object($categoryObj)) { $catName .= ' (' . $categoryObj->getVar('cat_title') . ')'; } else { $catName .= ' (' . \constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR_CATPID') . ')'; } } + $categoryIdSelect->addOption($catArray[$i]->getVar('cat_cid'), $catName); } $this->addElement($categoryIdSelect); + unset($categoryCriteria); $this->addElement(new \XoopsFormHidden('start', 0)); + $this->addElement(new \XoopsFormHidden('limit', 0)); } } diff --git a/class/Helper.php b/class/Helper.php index 82d9e97..0e9a8b4 100644 --- a/class/Helper.php +++ b/class/Helper.php @@ -1,4 +1,4 @@ -debug = $debug; + $this->debug = $debug; + $moduleDirName = \basename(\dirname(__DIR__)); + parent::__construct($moduleDirName); } @@ -47,6 +49,7 @@ public function __construct($debug = false) public static function getInstance($debug = false) { static $instance; + if (null === $instance) { $instance = new static($debug); } @@ -74,14 +77,21 @@ public function getHandler($name) $ret = false; $class = __NAMESPACE__ . '\\' . \ucfirst($name) . 'Handler'; + if (!\class_exists($class)) { throw new \RuntimeException("Class '$class' not found"); } + /** @var \XoopsMySQLDatabase $db */ - $db = \XoopsDatabaseFactory::getDatabaseConnection(); + + $db = \XoopsDatabaseFactory::getDatabaseConnection(); + $helper = self::getInstance(); - $ret = new $class($db, $helper); + + $ret = new $class($db, $helper); + $this->addLog("Getting handler '{$name}'"); + return $ret; } } diff --git a/class/Modified.php b/class/Modified.php index 041301a..851bbfa 100644 --- a/class/Modified.php +++ b/class/Modified.php @@ -1,4 +1,4 @@ -initVar('requestid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('lid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('cid', \XOBJ_DTYPE_INT, null, false, 5); + $this->initVar('title', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('url', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('homepage', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('version', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('size', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('platform', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('logourl', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('description', \XOBJ_DTYPE_TXTAREA, null, false); + // Pour autoriser le html + $this->initVar('dohtml', \XOBJ_DTYPE_INT, 1, false); + $this->initVar('modifysubmitter', \XOBJ_DTYPE_INT, null, false, 11); } @@ -51,7 +65,9 @@ public function __construct() public function getNewEnreg($db = null) { $newEnreg = 0; + /** @var \XoopsMySQLDatabase $db */ + if (null !== $db) { $newEnreg = $db->getInsertId(); } @@ -69,69 +85,113 @@ public function getNewEnreg($db = null) public function getForm($lid, $erreur, $donnee = [], $action = false) { global $xoopsDB, $xoopsModule, $xoopsUser; + /** @var \XoopsModules\Tdmdownloads\Helper $helper */ + $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); $moduleDirName = \basename(\dirname(__DIR__)); - if (false === $action) { + + if (!$action) { $action = $_SERVER['REQUEST_URI']; } + $groups = \is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; + /** @var \XoopsGroupPermHandler $grouppermHandler */ + $grouppermHandler = \xoops_getHandler('groupperm'); - $perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')); + + $perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')); + //appel des class + /** @var \XoopsModules\Tdmdownloads\DownloadsHandler $downloadsHandler */ + $downloadsHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Downloads'); + // $categoryHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Category'); $viewDownloads = $downloadsHandler->get($lid); + require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; // affectation des variables + if (true === $erreur) { - $d_title = $donnee['title']; - $d_cid = $donnee['cid']; - $d_homepage = $donnee['homepage']; - $d_version = $donnee['version']; - $d_platform = $donnee['platform']; + $d_title = $donnee['title']; + + $d_cid = $donnee['cid']; + + $d_homepage = $donnee['homepage']; + + $d_version = $donnee['version']; + + $d_platform = $donnee['platform']; + $d_description = $donnee['description']; } else { - $d_title = $viewDownloads->getVar('title'); - $d_cid = $viewDownloads->getVar('cid'); - $d_homepage = $viewDownloads->getVar('homepage'); - $d_version = $viewDownloads->getVar('version'); - $d_platform = $viewDownloads->getVar('platform'); + $d_title = $viewDownloads->getVar('title'); + + $d_cid = $viewDownloads->getVar('cid'); + + $d_homepage = $viewDownloads->getVar('homepage'); + + $d_version = $viewDownloads->getVar('version'); + + $d_platform = $viewDownloads->getVar('platform'); + $d_description = $viewDownloads->getVar('description', 'e'); } //nom du formulaire + $title = \sprintf(_AM_TDMDOWNLOADS_FORMEDIT); //création du formulaire + $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); + $form->setExtra('enctype="multipart/form-data"'); + //titre + $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_FORMTITLE, 'title', 50, 255, $d_title), true); + // fichier + $fichier = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMFILE, '

      '); - $url = $viewDownloads->getVar('url'); + + $url = $viewDownloads->getVar('url'); + $formurl = new \XoopsFormText(_AM_TDMDOWNLOADS_FORMURL, 'url', 75, 255, $url); + $fichier->addElement($formurl, false); - if (true === $perm_upload) { + + if ($perm_upload) { $fichier->addElement(new \XoopsFormFile(_AM_TDMDOWNLOADS_FORMUPLOAD, 'attachedfile', $helper->getConfig('maxuploadsize')), false); } + $form->addElement($fichier); //catégorie + /** @var \XoopsModules\Tdmdownloads\CategoryHandler $categoryHandler */ + $categoryHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Category'); + /** @var \XoopsModules\Tdmdownloads\Utility $utility */ - $utility = new \XoopsModules\Tdmdownloads\Utility(); + + $utility = new \XoopsModules\Tdmdownloads\Utility(); + $categories = $utility->getItemIds('tdmdownloads_submit', $moduleDirName); - $criteria = new \CriteriaCompo(); + + $criteria = new \CriteriaCompo(); + $criteria->setSort('cat_weight ASC, cat_title'); + $criteria->setOrder('ASC'); + if ($xoopsUser) { if (!$xoopsUser->isAdmin($xoopsModule->mid())) { $criteria->add(new \Criteria('cat_cid', '(' . \implode(',', $categories) . ')', 'IN')); @@ -139,48 +199,69 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) } else { $criteria->add(new \Criteria('cat_cid', '(' . \implode(',', $categories) . ')', 'IN')); } + $downloadscatArray = $categoryHandler->getAll($criteria); + if (empty($downloadscatArray)) { \redirect_header('index.php', 2, \_NOPERM); } + $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); + $form->addElement($mytree->makeSelectElement('cid', 'cat_title', '--', $d_cid, true, 0, '', _AM_TDMDOWNLOADS_FORMINCAT), true); //affichage des champs + $fieldHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Field'); - $criteria = new \CriteriaCompo(); + + $criteria = new \CriteriaCompo(); + $criteria->setSort('weight ASC, title'); + $criteria->setOrder('ASC'); + $downloads_field = $fieldHandler->getAll($criteria); + foreach (\array_keys($downloads_field) as $i) { /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ + if (1 == $downloads_field[$i]->getVar('status_def')) { if (1 == $downloads_field[$i]->getVar('fid')) { //page d'accueil + if (1 == $downloads_field[$i]->getVar('status')) { $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_FORMHOMEPAGE, 'homepage', 50, 255, $d_homepage)); } else { $form->addElement(new \XoopsFormHidden('homepage', '')); } } + if (2 == $downloads_field[$i]->getVar('fid')) { //version + if (1 == $downloads_field[$i]->getVar('status')) { $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_FORMVERSION, 'version', 10, 255, $d_version)); } else { $form->addElement(new \XoopsFormHidden('version', '')); } } + if (3 == $downloads_field[$i]->getVar('fid')) { //taille du fichier + if (1 == $downloads_field[$i]->getVar('status')) { $size_value_arr = \explode(' ', $viewDownloads->getVar('size')); - $aff_size = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMSIZE, ''); + + $aff_size = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMSIZE, ''); + $aff_size->addElement(new \XoopsFormText('', 'sizeValue', 13, 13, $size_value_arr[0])); - if (false === \array_key_exists(1, $size_value_arr)) { + + if (!\array_key_exists(1, $size_value_arr)) { $size_value_arr[1] = 'K'; } - $type = new \XoopsFormSelect('', 'sizeType', $size_value_arr[1]); + + $type = new \XoopsFormSelect('', 'sizeType', $size_value_arr[1]); + $typeArray = [ 'B' => _AM_TDMDOWNLOADS_BYTES, 'K' => _AM_TDMDOWNLOADS_KBYTES, @@ -188,22 +269,31 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) 'G' => _AM_TDMDOWNLOADS_GBYTES, 'T' => _AM_TDMDOWNLOADS_TBYTES, ]; + $type->addOptionArray($typeArray); + $aff_size->addElement($type); + $form->addElement($aff_size); } else { $form->addElement(new \XoopsFormHidden('size', '')); + $form->addElement(new \XoopsFormHidden('type_size', '')); } } + if (4 == $downloads_field[$i]->getVar('fid')) { //plateforme + if (1 == $downloads_field[$i]->getVar('status')) { $platformselect = new \XoopsFormSelect(_AM_TDMDOWNLOADS_FORMPLATFORM, 'platform', \explode('|', $d_platform), 5, true); - $platformArray = \explode('|', $helper->getConfig('platform')); + + $platformArray = \explode('|', $helper->getConfig('platform')); + foreach ($platformArray as $platform) { $platformselect->addOption((string)$platform, $platform); } + $form->addElement($platformselect, false); //$form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_FORMPLATFORM, 'platform', 50, 255, $d_platform)); } else { @@ -211,21 +301,30 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) } } } else { - $contenu = ''; - $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); + $contenu = ''; + + $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); + $fielddataHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Fielddata'); - $criteria = new \CriteriaCompo(); + + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('lid', $viewDownloads->getVar('lid'))); + $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid'))); + $downloadsfielddata = $fielddataHandler->getAll($criteria); + foreach (\array_keys($downloadsfielddata) as $j) { /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloadsfielddata */ + if (true === $erreur) { $contenu = $donnee[$fieldName]; } else { $contenu = $downloadsfielddata[$j]->getVar('data'); } } + if (1 == $downloads_field[$i]->getVar('status')) { $form->addElement(new \XoopsFormText($downloads_field[$i]->getVar('title'), $fieldName, 50, 255, $contenu)); } else { @@ -233,46 +332,79 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) } } } + //description - $editorConfigs = []; - $editorConfigs['name'] = 'description'; - $editorConfigs['value'] = $d_description; - $editorConfigs['rows'] = 20; - $editorConfigs['cols'] = 60; - $editorConfigs['width'] = '100%'; + + $editorConfigs = []; + + $editorConfigs['name'] = 'description'; + + $editorConfigs['value'] = $d_description; + + $editorConfigs['rows'] = 20; + + $editorConfigs['cols'] = 60; + + $editorConfigs['width'] = '100%'; + $editorConfigs['height'] = '400px'; + $editorConfigs['editor'] = $helper->getConfig('editor'); + $form->addElement(new \XoopsFormEditor(_AM_TDMDOWNLOADS_FORMTEXTDOWNLOADS, 'description', $editorConfigs), true); + //image + if ($helper->getConfig('useshots')) { - $uploaddir = XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/shots/' . $viewDownloads->getVar('logourl'); - $categoryImage = $viewDownloads->getVar('logourl') ?: 'blank.gif'; + $uploaddir = XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/shots/' . $viewDownloads->getVar('logourl'); + + $categoryImage = $viewDownloads->getVar('logourl') ?: 'blank.gif'; + $uploadirectory = '/uploads/' . $moduleDirName . '/images/shots'; + if (!\is_file($uploaddir)) { $categoryImage = 'blank.gif'; } - $imgtray = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMIMG, '
      '); - $imgpath = \sprintf(_AM_TDMDOWNLOADS_FORMPATH, $uploadirectory); - $imageselect = new \XoopsFormSelect($imgpath, 'logo_img', $categoryImage); - $topics_array = \XoopsLists:: getImgListAsArray(XOOPS_ROOT_PATH . $uploadirectory); + + $imgtray = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMIMG, '
      '); + + $imgpath = \sprintf(_AM_TDMDOWNLOADS_FORMPATH, $uploadirectory); + + $imageselect = new \XoopsFormSelect($imgpath, 'logo_img', $categoryImage); + + $topics_array = \XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . $uploadirectory); + foreach ($topics_array as $image) { $imageselect->addOption($image, $image); } + $imageselect->setExtra("onchange='showImgSelected(\"image3\", \"logo_img\", \"" . $uploadirectory . '", "", "' . XOOPS_URL . "\")'"); + $imgtray->addElement($imageselect, false); + $imgtray->addElement(new \XoopsFormLabel('', "
      ")); + $fileseltray = new \XoopsFormElementTray('', '
      '); - if (true === $perm_upload) { + + if ($perm_upload) { $fileseltray->addElement(new \XoopsFormFile(_AM_TDMDOWNLOADS_FORMUPLOAD, 'attachedimage', $helper->getConfig('maxuploadsize')), false); } + $imgtray->addElement($fileseltray); + $form->addElement($imgtray); } + $form->addElement(new \XoopsFormCaptcha(), true); + $form->addElement(new \XoopsFormHidden('lid', $lid)); + //pour enregistrer le formulaire + $form->addElement(new \XoopsFormHidden('op', 'save')); + //bouton d'envoi du formulaire + $form->addElement(new \XoopsFormButtonTray('', \_SUBMIT, 'submit', 'submit', false)); return $form; diff --git a/class/ModifiedHandler.php b/class/ModifiedHandler.php index 628f2f5..23b736d 100644 --- a/class/ModifiedHandler.php +++ b/class/ModifiedHandler.php @@ -1,4 +1,4 @@ -initVar('modiddata', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('fid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('lid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('moddata', \XOBJ_DTYPE_TXTAREA, null, false); + $this->initVar('dohtml', \XOBJ_DTYPE_INT, 1, false); } } diff --git a/class/ModifiedfielddataHandler.php b/class/ModifiedfielddataHandler.php index aff96b1..18accf2 100644 --- a/class/ModifiedfielddataHandler.php +++ b/class/ModifiedfielddataHandler.php @@ -1,4 +1,4 @@ -initVar('ratingid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('lid', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('ratinguser', \XOBJ_DTYPE_INT, null, false, 11); + $this->initVar('rating', \XOBJ_DTYPE_OTHER, null, false, 3); + $this->initVar('ratinghostname', \XOBJ_DTYPE_TXTBOX, null, false); + $this->initVar('ratingtimestamp', \XOBJ_DTYPE_INT, null, false, 10); } @@ -42,17 +49,23 @@ public function __construct() public function getForm($lid, $action = false) { // global $xoopsDB, $xoopsModule, $xoopsModuleConfig; - if (false === $action) { + + if (!$action) { $action = $_SERVER['REQUEST_URI']; } + if (!$this->isNew()) { $rating = 11; } else { $rating = $this->getVar('rating'); } + $form = new \XoopsThemeForm(_MD_TDMDOWNLOADS_SINGLEFILE_RATHFILE, 'rateform', 'ratefile.php', 'post'); + $form->setExtra('enctype="multipart/form-data"'); - $rating = new \XoopsFormSelect(_MD_TDMDOWNLOADS_RATEFILE_VOTE, 'rating', $rating); + + $rating = new \XoopsFormSelect(_MD_TDMDOWNLOADS_RATEFILE_VOTE, 'rating', $rating); + $options = [ '11' => '--', '10' => '10', @@ -67,14 +80,23 @@ public function getForm($lid, $action = false) '1' => '1', '0' => '0', ]; + $rating->addOptionArray($options); + $form->addElement($rating, true); + $form->addElement(new \XoopsFormCaptcha(), true); + $form->addElement(new \XoopsFormHidden('op', 'save')); + $form->addElement(new \XoopsFormHidden('lid', $lid)); + // Submit button + $buttonTray = new \XoopsFormElementTray('', ''); + $buttonTray->addElement(new \XoopsFormButton('', 'post', _MD_TDMDOWNLOADS_RATEFILE_RATE, 'submit')); + $form->addElement($buttonTray); return $form; diff --git a/class/RatingHandler.php b/class/RatingHandler.php index a2e0f5a..8f8049b 100644 --- a/class/RatingHandler.php +++ b/class/RatingHandler.php @@ -1,4 +1,4 @@ - 0) { - $value = $this->tree[$key]['obj']->getVar($this->myId); + $value = $this->tree[$key]['obj']->getVar($this->myId); + $ret[$value] = $prefix_curr . $this->tree[$key]['obj']->getVar($fieldName); + $prefix_curr .= $prefix_orig; } + if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { foreach ($this->tree[$key]['child'] as $childKey) { $this->makeArrayTreeOptions($fieldName, $childKey, $ret, $prefix_orig, $prefix_curr); @@ -69,6 +72,7 @@ protected function makeArrayTreeOptions($fieldName, $key, &$ret, $prefix_orig, $ public function makeArrayTree($fieldName, $prefix = '-', $key = 0) { $ret = []; + $this->makeArrayTreeOptions($fieldName, $key, $ret, $prefix); return $ret; diff --git a/class/Utilities.php b/class/Utilities.php index ff79824..da761e4 100644 --- a/class/Utilities.php +++ b/class/Utilities.php @@ -1,4 +1,4 @@ -db = $db; + // $this->helper = $helper; + // } /** @@ -40,17 +42,22 @@ class Utilities public static function getItemIds($permtype, $dirname) { global $xoopsUser; + $permissions = []; + if (\is_array($permissions) && \array_key_exists($permtype, $permissions)) { return $permissions[$permtype]; } - $moduleHandler = \xoops_getHandler('module'); - $tdmModule = $moduleHandler->getByDirname($dirname); - $groups = \is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; + + $moduleHandler = \xoops_getHandler('module'); + + $tdmModule = $moduleHandler->getByDirname($dirname); + + $groups = \is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; + $grouppermHandler = \xoops_getHandler('groupperm'); - $categories = $grouppermHandler->getItemIds($permtype, $groups, $tdmModule->getVar('mid')); - return $categories; + return $grouppermHandler->getItemIds($permtype, $groups, $tdmModule->getVar('mid')); } /** @@ -65,14 +72,18 @@ public static function getItemIds($permtype, $dirname) */ public static function getNumbersOfEntries($mytree, $categories, $entries, $cid) { - $count = 0; + $count = 0; + $child_arr = []; + if (\in_array($cid, $categories)) { $child = $mytree->getAllChild($cid); + foreach (\array_keys($entries) as $i) { if ($entries[$i]->getVar('cid') === $cid) { ++$count; } + foreach (\array_keys($child) as $j) { if ($entries[$i]->getVar('cid') === $j) { ++$count; @@ -93,20 +104,29 @@ public static function getNumbersOfEntries($mytree, $categories, $entries, $cid) public static function getStatusImage($time, $status) { $moduleDirName = \basename(\dirname(__DIR__)); + /** @var Tdmdownloads\Helper $helper */ + $helper = Tdmdownloads\Helper::getInstance(); - $count = 7; - $new = ''; - $startdate = (\time() - (86400 * $count)); + $count = 7; + + $new = ''; + + $startdate = \time() - (86400 * $count); + if (1 == $helper->getConfig('showupdated')) { if ($startdate < $time) { $language = $GLOBALS['xoopsConfig']['language']; + if (!\is_dir(XOOPS_ROOT_PATH . "/modules/$moduleDirName/language/" . $language . '/')) { $language = 'english'; } + $img_path = XOOPS_ROOT_PATH . "/modules/$moduleDirName/language/" . $language . '/'; - $img_url = XOOPS_URL . "/modules/$moduleDirName/language/" . $language . '/'; + + $img_url = XOOPS_URL . "/modules/$moduleDirName/language/" . $language . '/'; + if (1 == $status) { if (\is_readable($img_path . 'new.png')) { $new = ' ' . _MD_TDMDOWNLOADS_INDEX_NEWTHISWEEK . ''; @@ -134,17 +154,24 @@ public static function getStatusImage($time, $status) public static function getPopularImage($hits) { /** @var Tdmdownloads\Helper $helper */ + $helper = Tdmdownloads\Helper::getInstance(); $moduleDirName = \basename(\dirname(__DIR__)); - $pop = ''; + + $pop = ''; + if ($hits >= $helper->getConfig('popular')) { $language = $GLOBALS['xoopsConfig']['language']; + if (!\is_dir(XOOPS_ROOT_PATH . "/modules/$moduleDirName/language/" . $language . '/')) { $language = 'english'; } + $img_path = XOOPS_ROOT_PATH . "/modules/$moduleDirName/language/" . $language . '/'; - $img_url = XOOPS_URL . "/modules/$moduleDirName/language/" . $language . '/'; + + $img_url = XOOPS_URL . "/modules/$moduleDirName/language/" . $language . '/'; + if (\is_readable($img_path . 'popular.png')) { $pop = ' ' . _MD_TDMDOWNLOADS_INDEX_POPULAR . ''; } else { @@ -156,7 +183,6 @@ public static function getPopularImage($hits) } /** - * @param $size * @param mixed $global * @param mixed $key * @param mixed $default @@ -164,22 +190,37 @@ public static function getPopularImage($hits) * * @return string */ + // public static function convertFileSize($size) + // { + // if ($size > 0) { + // $mb = 1024 * 1024; + // if ($size > $mb) { + // $mysize = sprintf("%01.2f", $size / $mb) . " MB"; + // } elseif ($size >= 1024) { + // $mysize = sprintf("%01.2f", $size / 1024) . " KB"; + // } else { + // $mysize = sprintf(_AM_TDMDOWNLOADS_NUMBYTES, $size); + // } - // + // return $mysize; + // } else { + // return ''; + // } + // } /** @@ -205,6 +246,7 @@ public static function cleanVars($global, $key, $default = '', $type = 'int') $ret = isset($global[$key]) ? \filter_var($global[$key], \FILTER_SANITIZE_NUMBER_INT) : $default; break; } + if (false === $ret) { return $default; } @@ -224,15 +266,21 @@ public static function cleanVars($global, $key, $default = '', $type = 'int') public static function getPathTree($mytree, $key, $category_array, $title, $prefix = '') { $category_parent = $mytree->getAllParent($key); + $category_parent = \array_reverse($category_parent); - $Path = ''; + + $Path = ''; + foreach (\array_keys($category_parent) as $j) { $Path .= $category_parent[$j]->getVar($title) . $prefix; } + $first_category = ''; + if (\array_key_exists($key, $category_array)) { $first_category = $category_array[$key]->getVar($title); } + $Path .= $first_category; return $Path; @@ -261,31 +309,38 @@ public static function getPathTreeUrl( $lasturl = false ) { global $xoopsModule; + $category_parent = $mytree->getAllParent($key); + if ('ASC' === $order) { $category_parent = \array_reverse($category_parent); - if (true === $link) { + + if ($link) { $Path = '' . $xoopsModule->name() . '' . $prefix; } else { $Path = $xoopsModule->name() . $prefix; } } else { $first_category = ''; + if (\array_key_exists($key, $category_array)) { $first_category = $category_array[$key]->getVar($title); } + $Path = $first_category . $prefix; } + foreach (\array_keys($category_parent) as $j) { - if (true === $link) { + if ($link) { $Path .= '' . $category_parent[$j]->getVar($title) . '' . $prefix; } else { $Path .= $category_parent[$j]->getVar($title) . $prefix; } } + if ('ASC' === $order) { if (\array_key_exists($key, $category_array)) { - if (true === $lasturl) { + if ($lasturl) { $first_category = '' . $category_array[$key]->getVar($title) . ''; } else { $first_category = $category_array[$key]->getVar($title); @@ -293,9 +348,10 @@ public static function getPathTreeUrl( } else { $first_category = ''; } + $Path .= $first_category; } else { - if (true === $link) { + if ($link) { $Path .= '' . $xoopsModule->name() . ''; } else { $Path .= $xoopsModule->name(); @@ -319,6 +375,7 @@ public static function createFolder($path, $mode, $fileSource, $fileTarget = nul } file_put_contents($path . '/index.html', ''); + if (!empty($fileSource) && !empty($fileTarget)) { @\copy($fileSource, $fileTarget); } @@ -335,17 +392,22 @@ public static function cloneFolder($pathSource, $pathTarget) { if (\is_dir($pathSource)) { // Create new dir + if (!\mkdir($pathTarget) && !\is_dir($pathTarget)) { throw new \RuntimeException(\sprintf('Unable to create the %s directory', $pathTarget)); } + // check all files in dir, and process it + $handle = \opendir($pathSource); + if ($handle) { while ($file = \readdir($handle)) { if ('.' !== $file && '..' !== $file) { self::cloneFolder("$pathSource/$file", "$pathTarget/$file"); } } + \closedir($handle); } } else { @@ -365,6 +427,7 @@ public static function prepareFolder($folder) if (!@\mkdir($folder) && !\is_dir($folder)) { throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder)); } + file_put_contents($folder . '/index.html', ''); } } diff --git a/class/Utility.php b/class/Utility.php index 09a6b6e..32b89c2 100644 --- a/class/Utility.php +++ b/class/Utility.php @@ -1,4 +1,4 @@ -getByDirname($dirname); - $groups = \is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; + + $tdmModule = $moduleHandler->getByDirname($dirname); + + $groups = \is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; /** @var \XoopsGroupPermHandler $grouppermHandler */ + $grouppermHandler = \xoops_getHandler('groupperm'); - $categories = $grouppermHandler->getItemIds($permtype, $groups, $tdmModule->getVar('mid')); - return $categories; + return $grouppermHandler->getItemIds($permtype, $groups, $tdmModule->getVar('mid')); } /** @@ -60,15 +61,20 @@ public function getItemIds($permtype, $dirname) */ public function getNumbersOfEntries($mytree, $categories, $entries, $cid) { - $count = 0; + $count = 0; + $child_arr = []; + if (\in_array($cid, $categories)) { $child = $mytree->getAllChild($cid); + foreach (\array_keys($entries) as $i) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $entries */ + if ($entries[$i]->getVar('cid') == $cid) { $count++; } + foreach (\array_keys($child) as $j) { if ($entries[$i]->getVar('cid') == $j) { $count++; @@ -89,17 +95,25 @@ public function getNumbersOfEntries($mytree, $categories, $entries, $cid) public function getStatusImage($time, $status) { global $xoopsModuleConfig; - $count = 7; - $new = ''; - $startdate = (\time() - (86400 * $count)); + + $count = 7; + + $new = ''; + + $startdate = \time() - (86400 * $count); + if (1 == $xoopsModuleConfig['showupdated']) { if ($startdate < $time) { $language = $GLOBALS['xoopsConfig']['language']; + if (!\is_dir(XOOPS_ROOT_PATH . '/modules/tdmdownloads/language/' . $language . '/')) { $language = 'english'; } + $img_path = XOOPS_ROOT_PATH . '/modules/tdmdownloads/language/' . $language . '/'; - $img_url = XOOPS_URL . '/modules/tdmdownloads/language/' . $language . '/'; + + $img_url = XOOPS_URL . '/modules/tdmdownloads/language/' . $language . '/'; + if (1 == $status) { if (\is_readable($img_path . 'new.png')) { $new = ' ' . _MD_TDMDOWNLOADS_INDEX_NEWTHISWEEK . ''; @@ -127,14 +141,20 @@ public function getStatusImage($time, $status) public function getPopularImage($hits) { global $xoopsModuleConfig; + $pop = ''; + if ($hits >= $xoopsModuleConfig['popular']) { $language = $GLOBALS['xoopsConfig']['language']; + if (!\is_dir(XOOPS_ROOT_PATH . '/modules/tdmdownloads/language/' . $language . '/')) { $language = 'english'; } + $img_path = XOOPS_ROOT_PATH . '/modules/tdmdownloads/language/' . $language . '/'; - $img_url = XOOPS_URL . '/modules/tdmdownloads/language/' . $language . '/'; + + $img_url = XOOPS_URL . '/modules/tdmdownloads/language/' . $language . '/'; + if (\is_readable($img_path . 'popular.png')) { $pop = ' ' . _MD_TDMDOWNLOADS_INDEX_POPULAR . ''; } else { @@ -153,6 +173,7 @@ public static function prettifyBytes($size) { if ($size > 0) { $mb = 1024 * 1024; + if ($size > $mb) { $mysize = \sprintf('%01.2f', $size / $mb) . ' MB'; } elseif ($size >= 1024) { @@ -185,6 +206,7 @@ public static function cleanVars($global, $key, $default = '', $type = 'int') $ret = isset($global[$key]) ? \filter_var($global[$key], \FILTER_SANITIZE_NUMBER_INT) : $default; break; } + if (false === $ret) { return $default; } @@ -203,19 +225,27 @@ public static function cleanVars($global, $key, $default = '', $type = 'int') public static function getPathTree($mytree, $key, $category_array, $title, $prefix = '') { /** @var \XoopsObjectTree $mytree */ + $categoryParent = $mytree->getAllParent($key); + $categoryParent = \array_reverse($categoryParent); - $path = ''; + + $path = ''; + foreach (\array_keys($categoryParent) as $j) { /** @var \XoopsModules\Tdmdownloads\Category[] $categoryParent */ + $path .= $categoryParent[$j]->getVar($title) . $prefix; } + if (\array_key_exists($key, $category_array)) { /** @var \XoopsModules\Tdmdownloads\Category[] $category_array */ + $firstCategory = $category_array[$key]->getVar($title); } else { $firstCategory = ''; } + $path .= $firstCategory; return $path; @@ -235,10 +265,13 @@ public static function getPathTree($mytree, $key, $category_array, $title, $pref public static function getPathTreeUrl($mytree, $key, $category_array, $title, $prefix = '', $link = false, $order = 'ASC', $lasturl = false) { global $xoopsModule; + $categoryParent = $mytree->getAllParent($key); + if ('ASC' === $order) { $categoryParent = \array_reverse($categoryParent); - if (true === $link) { + + if ($link) { $path = '' . $xoopsModule->name() . '' . $prefix; } else { $path = $xoopsModule->name() . $prefix; @@ -246,23 +279,28 @@ public static function getPathTreeUrl($mytree, $key, $category_array, $title, $p } else { if (\array_key_exists($key, $category_array)) { /** @var \XoopsModules\Tdmdownloads\Category[] $category_array */ + $firstCategory = $category_array[$key]->getVar($title); } else { $firstCategory = ''; } + $path = $firstCategory . $prefix; } + foreach (\array_keys($categoryParent) as $j) { /** @var \XoopsModules\Tdmdownloads\Category[] $categoryParent */ - if (true === $link) { + + if ($link) { $path .= '' . $categoryParent[$j]->getVar($title) . '' . $prefix; } else { $path .= $categoryParent[$j]->getVar($title) . $prefix; } } + if ('ASC' === $order) { if (\array_key_exists($key, $category_array)) { - if (true === $lasturl) { + if ($lasturl) { $firstCategory = '' . $category_array[$key]->getVar($title) . ''; } else { $firstCategory = $category_array[$key]->getVar($title); @@ -270,9 +308,10 @@ public static function getPathTreeUrl($mytree, $key, $category_array, $title, $p } else { $firstCategory = ''; } + $path .= $firstCategory; } else { - if (true === $link) { + if ($link) { $path .= '' . $xoopsModule->name() . ''; } else { $path .= $xoopsModule->name(); @@ -291,9 +330,12 @@ public static function getPathTreeUrl($mytree, $key, $category_array, $title, $p public static function convertStringToSize($stringSize) { if ('' != $stringSize) { - $kb = 1024; - $mb = 1024 * 1024; - $gb = 1024 * 1024 * 1024; + $kb = 1024; + + $mb = 1024 * 1024; + + $gb = 1024 * 1024 * 1024; + $size_value_arr = \explode(' ', $stringSize); if ('B' == $size_value_arr[1]) { @@ -305,6 +347,7 @@ public static function convertStringToSize($stringSize) } else { $mysize = $size_value_arr[0] * $gb; } + return $mysize; } @@ -320,36 +363,37 @@ public static function convertStringToSize($stringSize) public static function convertSizeToString($sizeString) { $mysizeString = ''; + if ('' != $sizeString) { $size_value_arr = \explode(' ', $sizeString); - if (true === \array_key_exists(0, $size_value_arr) && true === \array_key_exists(1, $size_value_arr)) { + + if (\array_key_exists(0, $size_value_arr) && \array_key_exists(1, $size_value_arr)) { if ('' != $size_value_arr[0]) { $mysizeString = ''; + switch ($size_value_arr[1]) { case 'B': $mysizeString = $size_value_arr[0] . ' ' . _AM_TDMDOWNLOADS_BYTES; break; - case 'K': $mysizeString = $size_value_arr[0] . ' ' . _AM_TDMDOWNLOADS_KBYTES; break; - case 'M': $mysizeString = $size_value_arr[0] . ' ' . _AM_TDMDOWNLOADS_MBYTES; break; - case 'G': $mysizeString = $size_value_arr[0] . ' ' . _AM_TDMDOWNLOADS_GBYTES; break; - case 'T': $mysizeString = $size_value_arr[0] . ' ' . _AM_TDMDOWNLOADS_TBYTES; break; } + return $mysizeString; } } } + return $mysizeString; } @@ -363,17 +407,25 @@ public static function getFileSize($url) { if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init($url))) { \curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); + \curl_setopt($curlHandle, \CURLOPT_HEADER, true); + \curl_setopt($curlHandle, \CURLOPT_NOBODY, true); + \curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized' + $curlReturn = \curl_exec($curlHandle); + if (false === $curlReturn) { \trigger_error(\curl_error($curlHandle)); + $size = 0; } else { $size = \curl_getinfo($curlHandle, \CURLINFO_CONTENT_LENGTH_DOWNLOAD); } + \curl_close($curlHandle); + if ($size <= 0) { return 0; } @@ -394,16 +446,19 @@ public static function convertFileSize($size) { if ($size > 0) { $kb = 1024; + $mb = 1024 * 1024; + $gb = 1024 * 1024 * 1024; + if ($size >= $gb) { - $mysize = \sprintf("%01.2f", $size / $gb) . " " . 'G'; + $mysize = \sprintf('%01.2f', $size / $gb) . ' ' . 'G'; } elseif ($size >= $mb) { - $mysize = \sprintf("%01.2f", $size / $mb) . " " . 'M'; + $mysize = \sprintf('%01.2f', $size / $mb) . ' ' . 'M'; } elseif ($size >= $kb) { - $mysize = \sprintf("%01.2f", $size / $kb) . " " . 'K'; + $mysize = \sprintf('%01.2f', $size / $kb) . ' ' . 'K'; } else { - $mysize = \sprintf("%01.2f", $size) . " " . 'B'; + $mysize = \sprintf('%01.2f', $size) . ' ' . 'B'; } return $mysize; diff --git a/comment_delete.php b/comment_delete.php index b9dded1..f45747a 100644 --- a/comment_delete.php +++ b/comment_delete.php @@ -1,4 +1,5 @@ - 0) { // Get file title - $sql = 'SELECT title, cid FROM ' . $xoopsDB->prefix('tdmdownloads_downloads') . ' WHERE lid=' . $com_itemid; + + $sql = 'SELECT title, cid FROM ' . $xoopsDB->prefix('tdmdownloads_downloads') . ' WHERE lid=' . $com_itemid; + $result = $xoopsDB->query($sql); + if ($result) { $categories = $utility->getItemIds('tdmdownloads_view', $moduleDirName); - $row = $xoopsDB->fetchArray($result); + + $row = $xoopsDB->fetchArray($result); + if (!in_array($row['cid'], $categories)) { redirect_header(XOOPS_URL, 2, _NOPERM); } + $com_replytitle = $row['title']; + require XOOPS_ROOT_PATH . '/include/comment_new.php'; } } diff --git a/comment_post.php b/comment_post.php index c9fe3f1..6dcf5dc 100644 --- a/comment_post.php +++ b/comment_post.php @@ -1,4 +1,5 @@ - " XOOPS Project", ]; - diff --git a/config/icons.php b/config/icons.php index 58c688b..1b1bb0a 100644 --- a/config/icons.php +++ b/config/icons.php @@ -1,4 +1,4 @@ - 'text', 'default' => 'uploads/' . $modversion['dirname'] . '/images', ]; - diff --git a/config/paths.php b/config/paths.php index fd7548a..eef88b7 100644 --- a/config/paths.php +++ b/config/paths.php @@ -1,8 +1,6 @@ -prefix('tdmdownloads_cat'), 'cid', 'pid', 'title', 'viewcat.php?cid=', 'title'); - return $block; + return sitemap_get_categories_map($xoopsDB->prefix('tdmdownloads_cat'), 'cid', 'pid', 'title', 'viewcat.php?cid=', 'title'); } diff --git a/extra/plugins/tag/tdmdownloads.php b/extra/plugins/tag/tdmdownloads.php index 0c30170..abeab42 100644 --- a/extra/plugins/tag/tdmdownloads.php +++ b/extra/plugins/tag/tdmdownloads.php @@ -1,4 +1,5 @@ -getHandler('Downloads'); + /** @var \XoopsModules\Tdmdownloads\Downloads $item_obj */ + $items_obj = $itemHandler->getObjects(new \Criteria('lid', '(' . implode(', ', $items_id) . ')', 'IN'), true); foreach (array_keys($items) as $cat_id) { foreach (array_keys($items[$cat_id]) as $item_id) { if (isset($items_obj[$item_id])) { - $item_obj = $items_obj[$item_id]; + $item_obj = $items_obj[$item_id]; + $items[$cat_id][$item_id] = [ 'title' => $item_obj->getVar('title'), 'uid' => $item_obj->getVar('submitter'), @@ -54,6 +60,7 @@ function tdmdownloads_tag_iteminfo(&$items) } } } + unset($items_obj); return null; @@ -65,12 +72,16 @@ function tdmdownloads_tag_iteminfo(&$items) function tdmdownloads_tag_synchronization($mid) { /** @var \XoopsModules\Tdmdownloads\DownloadsHandler $itemHandler */ + $itemHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Downloads'); + /** @var \XoopsModules\Tag\LinkHandler $linkHandler */ + $linkHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Link'); /* clear tag-item links */ - if (version_compare($GLOBALS['xoopsDB']->getServerVersion(), '4.1.0', 'ge')): + + if (version_compare($GLOBALS['xoopsDB']->getServerVersion(), '4.1.0', 'ge')) : $sql = " DELETE FROM {$linkHandler->table}" . ' WHERE ' . " tag_modid = {$mid}" @@ -81,7 +92,7 @@ function tdmdownloads_tag_synchronization($mid) . " WHERE {$itemHandler->table}.status > 0" . ' ) ' . ' )'; - else: + else : $sql = " DELETE {$linkHandler->table} FROM {$linkHandler->table}" . " LEFT JOIN {$itemHandler->table} AS aa ON {$linkHandler->table}.tag_itemid = aa.{$itemHandler->keyName} " . ' WHERE ' @@ -91,6 +102,7 @@ function tdmdownloads_tag_synchronization($mid) . ' OR aa.status < 1' . ' )'; endif; + if (!$result = $linkHandler->db->queryF($sql)) { //xoops_error($linkHandler->db->error()); } diff --git a/extra/plugins/waiting/tdmdownloads.php b/extra/plugins/waiting/tdmdownloads.php index 63ded54..3057db8 100644 --- a/extra/plugins/waiting/tdmdownloads.php +++ b/extra/plugins/waiting/tdmdownloads.php @@ -1,4 +1,5 @@ -query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('tdmdownloads_downloads') . ' WHERE status=0'); + if ($result) { $block['adminlink'] = XOOPS_URL . "/modules/$moduleDirName/admin/downloads.php?op=liste&statut_display=0"; + [$block['pendingnum']] = $xoopsDB->fetchRow($result); + $block['lang_linkname'] = _PI_WAITING_WAITINGS; } + $ret[] = $block; // TDMDownloads broken - $block = []; + + $block = []; + $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('tdmdownloads_broken')); + if ($result) { $block['adminlink'] = XOOPS_URL . "/modules/$moduleDirName/admin/broken.php"; + [$block['pendingnum']] = $xoopsDB->fetchRow($result); + $block['lang_linkname'] = _PI_WAITING_BROKENS; } + $ret[] = $block; // TDMDownloads modreq - $block = []; + + $block = []; + $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('tdmdownloads_mod')); + if ($result) { $block['adminlink'] = XOOPS_URL . "/modules/$moduleDirName/admin/modified.php"; + [$block['pendingnum']] = $xoopsDB->fetchRow($result); + $block['lang_linkname'] = _PI_WAITING_MODREQS; } + $ret[] = $block; return $ret; diff --git a/extra/plugins/whatsnew/tdmdownloads/data.inc.php b/extra/plugins/whatsnew/tdmdownloads/data.inc.php index cfcb95f..8802460 100644 --- a/extra/plugins/whatsnew/tdmdownloads/data.inc.php +++ b/extra/plugins/whatsnew/tdmdownloads/data.inc.php @@ -1,4 +1,5 @@ -prefix('tdmdownloads_downloads') . ' WHERE status>0 ORDER BY date'; + + $sql = 'SELECT lid, title, date, cid, submitter, hits, description FROM ' . $xoopsDB->prefix('tdmdownloads_downloads') . ' WHERE status>0 ORDER BY date'; $result = $xoopsDB->query($sql, $limit, $offset); - $i = 0; + $i = 0; + $ret = []; while (false !== ($row = $xoopsDB->fetchArray($result))) { - $lid = $row['lid']; - $ret[$i]['link'] = $URL_MOD . '/singlefile.php?lid=' . $lid; + $lid = $row['lid']; + + $ret[$i]['link'] = $URL_MOD . '/singlefile.php?lid=' . $lid; + $ret[$i]['cat_link'] = $URL_MOD . '/viewcat.php?cid=' . $row['cid']; $ret[$i]['title'] = $row['title']; - $ret[$i]['time'] = $row['date']; + + $ret[$i]['time'] = $row['date']; // atom feed - $ret[$i]['id'] = $lid; + + $ret[$i]['id'] = $lid; + $ret[$i]['description'] = $myts->displayTarea($row['description'], 0); //no html // category + //$ret[$i]['cat_name'] = $row['ctitle']; // counter + $ret[$i]['hits'] = $row['hits']; // this module dont show user name + $ret[$i]['uid'] = $row['submitter']; ++$i; @@ -68,9 +78,12 @@ function tdmdownloads_num() { global $xoopsDB; - $sql = 'SELECT count(*) FROM ' . $xoopsDB->prefix('tdmdownloads_downloads') . ' WHERE status>0 ORDER BY lid'; + $sql = 'SELECT count(*) FROM ' . $xoopsDB->prefix('tdmdownloads_downloads') . ' WHERE status>0 ORDER BY lid'; + $array = $xoopsDB->fetchRow($xoopsDB->query($sql)); - $num = $array[0]; + + $num = $array[0]; + if (empty($num)) { $num = 0; } @@ -87,20 +100,28 @@ function tdmdownloads_num() function tdmdownloads_data($limit = 0, $offset = 0) { global $xoopsDB; + $moduleDirName = basename(dirname(dirname(__DIR__))); - $sql = 'SELECT lid, title, date FROM ' . $xoopsDB->prefix('tdmdownloads_downloads') . ' WHERE status>0 ORDER BY lid'; + $sql = 'SELECT lid, title, date FROM ' . $xoopsDB->prefix('tdmdownloads_downloads') . ' WHERE status>0 ORDER BY lid'; + $result = $xoopsDB->query($sql, $limit, $offset); - $i = 0; + $i = 0; + $ret = []; while (false !== ($myrow = $xoopsDB->fetchArray($result))) { - $id = $myrow['lid']; - $ret[$i]['id'] = $id; - $ret[$i]['link'] = XOOPS_URL . "/modules/$moduleDirName/singlefile.php?lid=" . $id . ''; + $id = $myrow['lid']; + + $ret[$i]['id'] = $id; + + $ret[$i]['link'] = XOOPS_URL . "/modules/$moduleDirName/singlefile.php?lid=" . $id . ''; + $ret[$i]['title'] = $myrow['title']; - $ret[$i]['time'] = $myrow['date']; + + $ret[$i]['time'] = $myrow['date']; + ++$i; } diff --git a/header.php b/header.php index 810926e..9334510 100644 --- a/header.php +++ b/header.php @@ -1,4 +1,5 @@ -path('class/template.php'); + $xoopsTpl = new XoopsTpl(); } diff --git a/include/comment_functions.php b/include/comment_functions.php index 14d1924..bee6b94 100644 --- a/include/comment_functions.php +++ b/include/comment_functions.php @@ -1,4 +1,5 @@ -prefix('tdmdownloads_downloads') . ' SET comments = ' . $totalNumber . ' WHERE lid = ' . $downloadId; + $db->query($sql); } diff --git a/include/common.php b/include/common.php index c193bce..b9e3bf3 100644 --- a/include/common.php +++ b/include/common.php @@ -1,4 +1,5 @@ -path('class/template.php'); + $GLOBALS['xoopsTpl'] = new \XoopsTpl(); } @@ -95,8 +108,10 @@ // Local icons path if (is_object($helper->getModule())) { $pathModIcon16 = $helper->getModule()->getInfo('modicons16'); + $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16); + $GLOBALS['xoopsTpl']->assign('pathModIcon32', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon32); } diff --git a/include/notification.inc.php b/include/notification.inc.php index 9705332..a112aad 100644 --- a/include/notification.inc.php +++ b/include/notification.inc.php @@ -1,4 +1,5 @@ -getVar('dirname') !== $moduleDirName) { /** @var \XoopsModuleHandler $moduleHandler */ + $moduleHandler = xoops_getHandler('module'); - $module = $moduleHandler->getByDirname($moduleDirName); + + $module = $moduleHandler->getByDirname($moduleDirName); + /** @var \XoopsConfigHandler $configHandler */ + $configHandler = xoops_getHandler('config'); - $config = $configHandler->getConfigsByCat(0, $module->getVar('mid')); + + $config = $configHandler->getConfigsByCat(0, $module->getVar('mid')); } else { $module = $xoopsModule; + $config = $xoopsModuleConfig; } if ('global' === $category) { $item['name'] = ''; - $item['url'] = ''; + + $item['url'] = ''; return $item; } global $xoopsDB; + if ('category' === $category) { // Assume we have a valid category id - $sql = 'SELECT title FROM ' . $xoopsDB->prefix('tdmdownloads_cat') . ' WHERE cid = ' . $item_id; - $result = $xoopsDB->query($sql); // TODO: error check + + $sql = 'SELECT title FROM ' . $xoopsDB->prefix('tdmdownloads_cat') . ' WHERE cid = ' . $item_id; + + $result = $xoopsDB->query($sql); // TODO: error check + $result_array = $xoopsDB->fetchArray($result); + $item['name'] = $result_array['title']; - $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/viewcat.php?cid=' . $item_id; + + $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/viewcat.php?cid=' . $item_id; return $item; } if ('file' === $category) { // Assume we have a valid file id - $sql = 'SELECT cid,title FROM ' . $xoopsDB->prefix('tdmdownloads_downloads') . ' WHERE lid = ' . $item_id; - $result = $xoopsDB->query($sql); // TODO: error check + + $sql = 'SELECT cid,title FROM ' . $xoopsDB->prefix('tdmdownloads_downloads') . ' WHERE lid = ' . $item_id; + + $result = $xoopsDB->query($sql); // TODO: error check + $result_array = $xoopsDB->fetchArray($result); + $item['name'] = $result_array['title']; - $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/singlefile.php?cid=' . $result_array['cid'] . '&lid=' . $item_id; + + $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/singlefile.php?cid=' . $result_array['cid'] . '&lid=' . $item_id; return $item; } diff --git a/include/oninstall.php b/include/oninstall.php index 67ee43b..3c44d41 100644 --- a/include/oninstall.php +++ b/include/oninstall.php @@ -1,4 +1,4 @@ -getInfo('tables'); + foreach ($mod_tables as $table) { $GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';'); } @@ -47,127 +49,196 @@ function xoops_module_pre_install_tdmdownloads(\XoopsModule $module) return $xoopsSuccess && $phpSuccess; } + /** * @return bool */ function xoops_module_install_tdmdownloads() { global $xoopsModule, $xoopsConfig, $xoopsDB; + $moduleDirName = basename(dirname(__DIR__)); $namemodule = $moduleDirName; + if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $namemodule . '/language/' . $xoopsConfig['language'] . '/admin.php')) { require_once XOOPS_ROOT_PATH . '/modules/' . $namemodule . '/language/' . $xoopsConfig['language'] . '/admin.php'; } else { require_once XOOPS_ROOT_PATH . '/modules/' . $namemodule . '/language/english/admin.php'; } + $fieldHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Field'); - $obj = $fieldHandler->create(); + + $obj = $fieldHandler->create(); + $obj->setVar('title', _AM_TDMDOWNLOADS_FORMHOMEPAGE); + $obj->setVar('img', 'homepage.png'); + $obj->setVar('weight', 1); + $obj->setVar('search', 0); + $obj->setVar('status', 1); + $obj->setVar('status_def', 1); + $fieldHandler->insert($obj); + $obj = $fieldHandler->create(); + $obj->setVar('title', _AM_TDMDOWNLOADS_FORMVERSION); + $obj->setVar('img', 'version.png'); + $obj->setVar('weight', 2); + $obj->setVar('search', 0); + $obj->setVar('status', 1); + $obj->setVar('status_def', 1); + $fieldHandler->insert($obj); + $obj = $fieldHandler->create(); + $obj->setVar('title', _AM_TDMDOWNLOADS_FORMSIZE); + $obj->setVar('img', 'size.png'); + $obj->setVar('weight', 3); + $obj->setVar('search', 0); + $obj->setVar('status', 1); + $obj->setVar('status_def', 1); + $fieldHandler->insert($obj); + $obj = $fieldHandler->create(); + $obj->setVar('title', _AM_TDMDOWNLOADS_FORMPLATFORM); + $obj->setVar('img', 'platform.png'); + $obj->setVar('weight', 4); + $obj->setVar('search', 0); + $obj->setVar('status', 1); + $obj->setVar('status_def', 1); + $fieldHandler->insert($obj); //File creation ".$namemodule."/ + $dir = XOOPS_ROOT_PATH . '/uploads/' . $namemodule . ''; + if (!is_dir($dir)) { if (!mkdir($dir, 0777) && !is_dir($dir)) { throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir)); } } + chmod($dir, 0777); //File creation ".$namemodule."/images/ + $dir = XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images'; + if (!is_dir($dir)) { if (!mkdir($dir, 0777) && !is_dir($dir)) { throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir)); } } + chmod($dir, 0777); //File creation ".$namemodule."/images/cat + $dir = XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/cats'; + if (!is_dir($dir)) { if (!mkdir($dir, 0777) && !is_dir($dir)) { throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir)); } } + chmod($dir, 0777); //File creation ".$namemodule."/images/shots + $dir = XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/shots'; + if (!is_dir($dir)) { if (!mkdir($dir, 0777) && !is_dir($dir)) { throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir)); } } + chmod($dir, 0777); //File creation ".$namemodule."/images/field + $dir = XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/field'; + if (!is_dir($dir)) { if (!mkdir($dir, 0777) && !is_dir($dir)) { throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir)); } } + chmod($dir, 0777); //File creation ".$namemodule."/downloads + $dir = XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/downloads'; + if (!is_dir($dir)) { if (!mkdir($dir, 0777) && !is_dir($dir)) { throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir)); } } + chmod($dir, 0777); //Copy index.html + $indexFile = XOOPS_ROOT_PATH . '/modules/' . $namemodule . '/include/index.html'; + copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/index.html'); + copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/index.html'); + copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/cats/index.html'); + copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/shots/index.html'); + copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/field/index.html'); + copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/downloads/index.html'); //Copy blank.gif + $blankFile = XOOPS_ROOT_PATH . '/modules/' . $namemodule . '/assets/images/blank.gif'; + copy($blankFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/cats/blank.gif'); + copy($blankFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/shots/blank.gif'); + copy($blankFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/field/blank.gif'); //Copy images for fields + copy(XOOPS_ROOT_PATH . '/modules/' . $namemodule . '/assets/images/icons/16/homepage.png', XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/field/homepage.png'); + copy(XOOPS_ROOT_PATH . '/modules/' . $namemodule . '/assets/images/icons/16/version.png', XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/field/version.png'); + copy(XOOPS_ROOT_PATH . '/modules/' . $namemodule . '/assets/images/icons/16/size.png', XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/field/size.png'); + copy(XOOPS_ROOT_PATH . '/modules/' . $namemodule . '/assets/images/icons/16/platform.png', XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/field/platform.png'); return true; diff --git a/include/onupdate.php b/include/onupdate.php index 6d3a091..5c28977 100644 --- a/include/onupdate.php +++ b/include/onupdate.php @@ -1,4 +1,4 @@ -getErrors(); + if (!empty($errors)) { // print_r($errors); } @@ -39,44 +44,46 @@ function xoops_module_update_tdmdownloads(&$module, $prev_version = null) /** * @param $module - * * @return bool */ function update_tdmdownloads_v200(&$module) { // Update size - $db = \XoopsDatabaseFactory::getDatabaseConnection(); - $sql = 'SELECT lid, size FROM ' . $db->prefix('tdmdownloads_downloads'); + + $db = \XoopsDatabaseFactory::getDatabaseConnection(); + + $sql = 'SELECT lid, size FROM ' . $db->prefix('tdmdownloads_downloads'); + $result = $db->query($sql); + $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); + $helper->loadLanguage('admin'); + while (false !== ($myrow = $db->fetchArray($result))) { $size_value_arr = explode(' ', $myrow['size']); + switch ($size_value_arr[1]) { case _AM_TDMDOWNLOADS_BYTES: case 'Bytes': $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' B\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; $db->query($sql); break; - case _AM_TDMDOWNLOADS_KBYTES: case 'kB': $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' K\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; $db->query($sql); break; - case _AM_TDMDOWNLOADS_MBYTES: case 'MB': $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' M\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; $db->query($sql); break; - case _AM_TDMDOWNLOADS_GBYTES: case 'GB': $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' G\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; $db->query($sql); break; - case _AM_TDMDOWNLOADS_TBYTES: case 'TB': $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' T\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; @@ -84,52 +91,78 @@ function update_tdmdownloads_v200(&$module) break; } } + // Update folder + rename(XOOPS_ROOT_PATH . '/uploads/TDMDownloads', XOOPS_ROOT_PATH . '/uploads/tdmdownloads'); + // Change TDMDownloads with tdmdownloads - $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `url` = REPLACE(`url`, \'TDMDownloads\', \'tdmdownloads\') WHERE `url` LIKE \'%TDMDownloads%\''; + + $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `url` = REPLACE(`url`, \'TDMDownloads\', \'tdmdownloads\') WHERE `url` LIKE \'%TDMDownloads%\''; + $result = $db->query($sql); + return true; } /** * @param $module - * * @return bool */ function update_tdmdownloads_v167(&$module) { // rename module dir from upper case to lower case + rename(XOOPS_ROOT_PATH . '/modules/TDMDownloads', XOOPS_ROOT_PATH . '/modules/tdmdownloads'); + // rename upload dir from upper case to lower case + rename(XOOPS_ROOT_PATH . '/uploads/TDMDownloads', XOOPS_ROOT_PATH . '/uploads/tdmdownloads'); // files have been moved to assets-folder + $src = XOOPS_ROOT_PATH . '/modules/tdmdownloads/css/'; rrmdir($src); + $src = XOOPS_ROOT_PATH . '/modules/tdmdownloads/images/'; rrmdir($src); // delete unneeded/replacfiles + // unlink( XOOPS_ROOT_PATH.'/modules/tdmdownloads/admin/admin_header.php' ); // clean template directory + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_brokenfile.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_download.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_index.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_modfile.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_ratefile.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_singlefile.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_submit.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_viewcat.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_liste.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_rss.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/blocks/tdmdownloads_block_new.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/blocks/tdmdownloads_block_random.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/blocks/tdmdownloads_block_rating.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/blocks/tdmdownloads_block_search.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/blocks/tdmdownloads_block_top.html'); return true; @@ -142,9 +175,11 @@ function rrmdir($src) { if (is_dir($src)) { $dir = opendir($src); + while (false !== ($file = readdir($dir))) { if (('.' !== $file) && ('..' !== $file)) { $full = $src . '/' . $file; + if (is_dir($full)) { rrmdir($full); } else { @@ -152,7 +187,9 @@ function rrmdir($src) } } } + closedir($dir); + rmdir($src); } } @@ -163,28 +200,49 @@ function rrmdir($src) function update_tdmdownloads_v163() { /** @var \XoopsMySQLDatabase $db */ - $db = \XoopsDatabaseFactory::getDatabaseConnection(); + + $db = \XoopsDatabaseFactory::getDatabaseConnection(); + $sql = 'ALTER TABLE `' . $db->prefix('tdmdownloads_cat') . '` CHANGE `cid` `cat_cid` INT( 5 ) UNSIGNED NOT NULL AUTO_INCREMENT ;'; + $db->query($sql); + $sql = 'ALTER TABLE `' . $db->prefix('tdmdownloads_cat') . "` CHANGE `pid` `cat_pid` INT( 5 ) UNSIGNED NOT NULL DEFAULT '0' ;"; + $db->query($sql); + $sql = 'ALTER TABLE `' . $db->prefix('tdmdownloads_cat') . '` CHANGE `title` `cat_title` VARCHAR( 255 ) NOT NULL ;'; + $db->query($sql); + $sql = 'ALTER TABLE `' . $db->prefix('tdmdownloads_cat') . '` CHANGE `imgurl` `cat_imgurl` VARCHAR( 255 ) NOT NULL ;'; + $db->query($sql); + $sql = 'ALTER TABLE `' . $db->prefix('tdmdownloads_cat') . '` CHANGE `description_main` `cat_description_main` TEXT NOT NULL ;'; + $db->query($sql); + $sql = 'ALTER TABLE `' . $db->prefix('tdmdownloads_cat') . "` CHANGE `weight` `cat_weight` INT( 11 ) NOT NULL DEFAULT '0' ;"; + $db->query($sql); + $sql = 'ALTER TABLE `' . $db->prefix('tdmdownloads_downloads') . '` ADD `paypal` VARCHAR( 255 ) NOT NULL;'; + $db->query($sql); + $sql = 'ALTER TABLE `' . $db->prefix('tdmdownloads_downloads') . "` CHANGE `size` `size` VARCHAR( 15 ) NOT NULL DEFAULT '';"; + $db->query($sql); + $sql = 'ALTER TABLE `' . $db->prefix('tdmdownloads_mod') . "` CHANGE `size` `size` VARCHAR( 15 ) NOT NULL DEFAULT '';"; + $db->query($sql); + $sql = 'CREATE TABLE `' . $db->prefix('tdmdownloads_downlimit') . "` (downlimit_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, downlimit_lid INT(11) UNSIGNED NOT NULL DEFAULT '0', downlimit_uid INT(11) NOT NULL DEFAULT '0', downlimit_hostname VARCHAR(60) NOT NULL DEFAULT '', downlimit_date INT(10) NOT NULL DEFAULT '0', PRIMARY KEY (downlimit_id) ) ENGINE=MyISAM"; + $db->query($sql); return true; diff --git a/include/search.inc.php b/include/search.inc.php index a9702c1..7981a6d 100644 --- a/include/search.inc.php +++ b/include/search.inc.php @@ -1,4 +1,5 @@ -prefix('tdmdownloads_downloads') . ' WHERE status != 0'; @@ -33,9 +35,12 @@ function tdmdownloads_search($queryarray, $andor, $limit, $offset, $userid) $sql .= ' AND submitter=' . (int)$userid . ' '; } - $utility = new \XoopsModules\Tdmdownloads\Utility(); + $utility = new \XoopsModules\Tdmdownloads\Utility(); + $categories = $utility->getItemIds('tdmdownloads_view', $moduleDirName); + // if (is_array($categories) && count($categories) > 0) { + if ($categories && is_array($categories)) { $sql .= ' AND cid IN (' . implode(',', $categories) . ') '; } else { @@ -47,21 +52,32 @@ function tdmdownloads_search($queryarray, $andor, $limit, $offset, $userid) for ($i = 1; $i < $count; ++$i) { $sql .= " $andor "; + $sql .= "(title LIKE '%$queryarray[$i]%' OR description LIKE '%$queryarray[$i]%')"; } + $sql .= ')'; } - $sql .= ' ORDER BY date DESC'; + $sql .= ' ORDER BY date DESC'; + $result = $xoopsDB->query($sql, $limit, $offset); - $ret = []; - $i = 0; + + $ret = []; + + $i = 0; + while (false !== ($myrow = $xoopsDB->fetchArray($result))) { $ret[$i]['image'] = 'assets/images/deco/tdmdownloads_search.png'; - $ret[$i]['link'] = 'singlefile.php?cid=' . $myrow['cid'] . '&lid=' . $myrow['lid'] . ''; + + $ret[$i]['link'] = 'singlefile.php?cid=' . $myrow['cid'] . '&lid=' . $myrow['lid'] . ''; + $ret[$i]['title'] = $myrow['title']; - $ret[$i]['time'] = $myrow['date']; - $ret[$i]['uid'] = $myrow['submitter']; + + $ret[$i]['time'] = $myrow['date']; + + $ret[$i]['uid'] = $myrow['submitter']; + ++$i; } diff --git a/index.php b/index.php index c057779..5b6deed 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,4 @@ -getVar('cat_pid')) { - $totaldownloads = $utility->getNumbersOfEntries($mytree, $categories, $downloadsArray, $downloadscatArray[$i]->getVar('cat_cid')); + $totaldownloads = $utility->getNumbersOfEntries($mytree, $categories, $downloadsArray, $downloadscatArray[$i]->getVar('cat_cid')); + $subcategories_arr = $mytree->getFirstChild($downloadscatArray[$i]->getVar('cat_cid')); - $chcount = 0; - $subcategories = ''; + + $chcount = 0; + + $subcategories = ''; + //pour les mots clef + $keywords .= $downloadscatArray[$i]->getVar('cat_title') . ','; + foreach (array_keys($subcategories_arr) as $j) { /** @var \XoopsModules\Tdmdownloads\Category[] $subcategories_arr */ + if ($chcount >= $helper->getConfig('nbsouscat')) { $subcategories .= '
    • [+]
    • '; + break; } + $subcategories .= '
    • ' . $subcategories_arr[$j]->getVar('cat_title') . '
    • '; - $keywords .= $downloadscatArray[$i]->getVar('cat_title') . ','; + + $keywords .= $downloadscatArray[$i]->getVar('cat_title') . ','; + ++$chcount; } + $xoopsTpl->append( 'categories', [ @@ -79,6 +92,7 @@ 'count' => $count, ] ); + ++$count; } } @@ -88,19 +102,30 @@ //téléchargements récents if (1 == $helper->getConfig('bldate')) { $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('status', 0, '!=')); + $criteria->add(new \Criteria('cid', '(' . implode(',', $categories) . ')', 'IN')); + $criteria->setSort('date'); + $criteria->setOrder('DESC'); + $criteria->setLimit($helper->getConfig('nbbl')); + $downloads_arr_date = $downloadsHandler->getAll($criteria); + foreach (array_keys($downloads_arr_date) as $i) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloads_arr_date */ + $title = $downloads_arr_date[$i]->getVar('title'); + if (mb_strlen($title) >= $helper->getConfig('longbl')) { $title = mb_substr($title, 0, $helper->getConfig('longbl')) . '...'; } + $date = formatTimestamp($downloads_arr_date[$i]->getVar('date'), 's'); + $xoopsTpl->append( 'bl_date', [ @@ -115,18 +140,28 @@ //plus téléchargés if (1 == $helper->getConfig('blpop')) { $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('status', 0, '!=')); + $criteria->add(new \Criteria('cid', '(' . implode(',', $categories) . ')', 'IN')); + $criteria->setSort('hits'); + $criteria->setOrder('DESC'); + $criteria->setLimit($helper->getConfig('nbbl')); + $downloads_arr_hits = $downloadsHandler->getAll($criteria); + foreach (array_keys($downloads_arr_hits) as $i) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloads_arr_hits */ + $title = $downloads_arr_hits[$i]->getVar('title'); + if (mb_strlen($title) >= $helper->getConfig('longbl')) { $title = mb_substr($title, 0, $helper->getConfig('longbl')) . '...'; } + $xoopsTpl->append( 'bl_pop', [ @@ -141,19 +176,30 @@ //mieux notés if (1 == $helper->getConfig('blrating')) { $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('status', 0, '!=')); + $criteria->add(new \Criteria('cid', '(' . implode(',', $categories) . ')', 'IN')); + $criteria->setSort('rating'); + $criteria->setOrder('DESC'); + $criteria->setLimit($helper->getConfig('nbbl')); + $downloads_arr_rating = $downloadsHandler->getAll($criteria); + foreach (array_keys($downloads_arr_rating) as $i) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloads_arr_rating */ + $title = $downloads_arr_rating[$i]->getVar('title'); + if (mb_strlen($title) >= $helper->getConfig('longbl')) { $title = mb_substr($title, 0, $helper->getConfig('longbl')) . '...'; } + $rating = number_format($downloads_arr_rating[$i]->getVar('rating'), 1); + $xoopsTpl->append( 'bl_rating', [ @@ -177,65 +223,112 @@ // affichage des téléchargements if ($helper->getConfig('newdownloads') > 0) { $xoopsTpl->assign('nb_dowcol', $helper->getConfig('nb_dowcol')); + //Utilisation d'une copie d'écran avec la largeur selon les préférences + if (1 == $helper->getConfig('useshots')) { $xoopsTpl->assign('shotwidth', $helper->getConfig('shotwidth')); + $xoopsTpl->assign('show_screenshot', true); + $xoopsTpl->assign('img_float', $helper->getConfig('img_float')); } + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('status', 0, '!=')); + $criteria->add(new \Criteria('cid', '(' . implode(',', $categories) . ')', 'IN')); + $criteria->setLimit($helper->getConfig('newdownloads')); - $tblsort = []; - $tblsort[1] = 'date'; - $tblsort[2] = 'date'; - $tblsort[3] = 'hits'; - $tblsort[4] = 'hits'; - $tblsort[5] = 'rating'; - $tblsort[6] = 'rating'; - $tblsort[7] = 'title'; - $tblsort[8] = 'title'; - $tblorder = []; + + $tblsort = []; + + $tblsort[1] = 'date'; + + $tblsort[2] = 'date'; + + $tblsort[3] = 'hits'; + + $tblsort[4] = 'hits'; + + $tblsort[5] = 'rating'; + + $tblsort[6] = 'rating'; + + $tblsort[7] = 'title'; + + $tblsort[8] = 'title'; + + $tblorder = []; + $tblorder[1] = 'DESC'; + $tblorder[2] = 'ASC'; + $tblorder[3] = 'DESC'; + $tblorder[4] = 'ASC'; + $tblorder[5] = 'DESC'; + $tblorder[6] = 'ASC'; + $tblorder[7] = 'DESC'; + $tblorder[8] = 'ASC'; - $sort = $helper->getConfig('toporder') ?? 1; - $order = $helper->getConfig('toporder') ?? 1; + + $sort = $helper->getConfig('toporder') ?? 1; + + $order = $helper->getConfig('toporder') ?? 1; + $criteria->setSort($tblsort[$sort]); + $criteria->setOrder($tblorder[$order]); + $downloadsArray = $downloadsHandler->getAll($criteria); - $categories = $utility->getItemIds('tdmdownloads_download', $moduleDirName); - $item = $utility->getItemIds('tdmdownloads_download_item', $moduleDirName); - $count = 1; + + $categories = $utility->getItemIds('tdmdownloads_download', $moduleDirName); + + $item = $utility->getItemIds('tdmdownloads_download_item', $moduleDirName); + + $count = 1; + foreach (array_keys($downloadsArray) as $i) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloadsArray */ + if ('blank.gif' === $downloadsArray[$i]->getVar('logourl')) { $logourl = ''; } else { $logourl = $downloadsArray[$i]->getVar('logourl'); + $logourl = $uploadurl_shots . $logourl; } - $datetime = formatTimestamp($downloadsArray[$i]->getVar('date'), 's'); - $submitter = \XoopsUser::getUnameFromId($downloadsArray[$i]->getVar('submitter')); + + $datetime = formatTimestamp($downloadsArray[$i]->getVar('date'), 's'); + + $submitter = \XoopsUser::getUnameFromId($downloadsArray[$i]->getVar('submitter')); + $description = $downloadsArray[$i]->getVar('description'); + //permet d'afficher uniquement la description courte + if (false === mb_strpos($description, '[pagebreak]')) { $descriptionShort = $description; } else { $descriptionShort = mb_substr($description, 0, mb_strpos($description, '[pagebreak]')); } + // pour les vignettes "new" et "mis à jour" + $new = $utility->getStatusImage($downloadsArray[$i]->getVar('date'), $downloadsArray[$i]->getVar('status')); + $pop = $utility->getPopularImage($downloadsArray[$i]->getVar('hits')); // Défini si la personne est un admin + $adminlink = ''; + if (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid())) { $adminlink = ''; } + //permission de télécharger $downloadPermission = true; + if (1 === $helper->getConfig('permission_download')) { if (!in_array($downloadsArray[$i]->getVar('cid'), $categories)) { $downloadPermission = false; @@ -265,6 +360,7 @@ $downloadPermission = false; } } + $xoopsTpl->append( 'file', [ @@ -284,8 +380,11 @@ 'count' => $count, ] ); + //pour les mots clef + $keywords .= $downloadsArray[$i]->getVar('title') . ','; + ++$count; } } diff --git a/language/english/admin.php b/language/english/admin.php index de8e87b..8d2b123 100644 --- a/language/english/admin.php +++ b/language/english/admin.php @@ -1,4 +1,5 @@ ---- --- '); //define('_MI_TDMDOWNLOADS_ADMENU5', 'Blocks Admin'); - diff --git a/language/french/admin.php b/language/french/admin.php index e2c893a..985d063 100644 --- a/language/french/admin.php +++ b/language/french/admin.php @@ -1,4 +1,5 @@ -get($lid); + /** @var \XoopsThemeForm $form */ + $form = $obj->getForm($donnee = [], false, 'submit.php'); } else { /** @var \XoopsModules\Tdmdownloads\Modified $obj */ - $obj = $modifiedHandler->create(); + + $obj = $modifiedHandler->create(); + $form = $obj->getForm($lid, false, $donnee = []); } $xoopsTpl->assign('themeForm', $form->render()); @@ -119,18 +124,23 @@ // erreur si la catégorie est vide if (\Xmf\Request::hasVar('cid')) { if (0 == \Xmf\Request::getInt('cid', 0, 'POST')) { - $erreur = true; + $erreur = true; + $errorMessage .= _MD_TDMDOWNLOADS_ERREUR_NOCAT . '
      '; } } // get captcha (members are skipped in class/download.php getForm if (!$xoopsUser) { // erreur si le captcha est faux + xoops_load('xoopscaptcha'); + $xoopsCaptcha = \XoopsCaptcha::getInstance(); + if (!$xoopsCaptcha->verify()) { $errorMessage .= $xoopsCaptcha->getMessage() . '
      '; - $erreur = true; + + $erreur = true; } } // pour enregistrer temporairement les valeur des champs sup @@ -140,8 +150,10 @@ $downloads_field = $fieldHandler->getAll($criteria); foreach (array_keys($downloads_field) as $i) { /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ + if (0 == $downloads_field[$i]->getVar('status_def')) { - $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); + $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); + $donnee[$fieldName] = \Xmf\Request::getString($fieldName, '', 'POST'); } } @@ -149,52 +161,72 @@ $xoopsTpl->assign('message_erreur', $errorMessage); } else { // Pour le fichier + $mediaSize = 0; + if (isset($_POST['xoops_upload_file'][0])) { $uploader = new \XoopsMediaUploader($uploaddir_downloads, $helper->getConfig('mimetypes'), $helper->getConfig('maxuploadsize'), null, null); + if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { if ($helper->getConfig('newnamedownload')) { $uploader->setPrefix($helper->getConfig('prefixdownloads')); } + $uploader->fetchMedia($_POST['xoops_upload_file'][0]); + if (!$uploader->upload()) { $errors = $uploader->getErrors(); + redirect_header('javascript:history.go(-1)', 3, $errors); } else { $mediaSize = $uploader->getMediaSize(); + $obj->setVar('url', $uploadurl_downloads . $uploader->getSavedFileName()); } } else { if ($_FILES['attachedfile']['name'] > '') { // file name was given, but fetchMedia failed - show error when e.g. file size exceed maxuploadsize + $errorMessage .= $uploader->getErrors() . '
      '; + $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); + /** @var \XoopsThemeForm $form */ + $form = $obj->getForm($donnee, true); + $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); + break; } + $obj->setVar('url', \Xmf\Request::getString('url', '', 'REQUEST')); } } else { $obj->setVar('url', \Xmf\Request::getString('url', '', 'REQUEST')); } + // Pour l'image + if (isset($_POST['xoops_upload_file'][1])) { $uploader_2 = new \XoopsMediaUploader( $uploaddir_shots, [ - 'image/gif', - 'image/jpeg', - 'image/pjpeg', - 'image/x-png', - 'image/png', - ], $helper->getConfig('maxuploadsize'), null, null + 'image/gif', + 'image/jpeg', + 'image/pjpeg', + 'image/x-png', + 'image/png', + ], $helper->getConfig('maxuploadsize'), null, null ); + if ($uploader_2->fetchMedia($_POST['xoops_upload_file'][1])) { $uploader_2->setPrefix('downloads_'); + $uploader_2->fetchMedia($_POST['xoops_upload_file'][1]); + if (!$uploader_2->upload()) { $errors = $uploader_2->getErrors(); + redirect_header('javascript:history.go(-1)', 3, $errors); } else { $obj->setVar('logourl', $uploader_2->getSavedFileName()); @@ -202,18 +234,26 @@ } else { if ($_FILES['attachedimage']['name'] > '') { // file name was given, but fetchMedia failed - show error when e.g. file size exceed maxuploadsize + $errorMessage .= $uploader_2->getErrors() . '
      '; + $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); + $form = $obj->getForm($donnee, true); + $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); + break; } + $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'REQUEST')); } } else { $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'REQUEST')); } + //Automatic file size + if ('' == Xmf\Request::getString('sizeValue', '')) { if (0 == $mediaSize) { $obj->setVar('size', $utility::getFileSize(Xmf\Request::getUrl('url', ''))); @@ -223,39 +263,65 @@ } else { $obj->setVar('size', Xmf\Request::getFloat('sizeValue', 0) . ' ' . Xmf\Request::getString('sizeType', '')); } + $timeToRedirect = 2; + if (0 == $obj->getVar('size')) { $obj->setVar('size', ''); - $error_message = _AM_TDMDOWNLOADS_ERREUR_SIZE; + + $error_message = _AM_TDMDOWNLOADS_ERREUR_SIZE; + $timeToRedirect = 10; } + if ($modifiedHandler->insert($obj)) { $lidDownloads = $obj->getNewEnreg($db); + // Récupération des champs supplémentaires: + $criteria = new \CriteriaCompo(); + $criteria->setSort('weight ASC, title'); + $criteria->setOrder('ASC'); + $downloads_field = $fieldHandler->getAll($criteria); + foreach (array_keys($downloads_field) as $i) { /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ + if (0 == $downloads_field[$i]->getVar('status_def')) { //$objdata = $modifiedfielddataHandler->create(); - $objdata = $modifieddataHandler->create(); + + $objdata = $modifieddataHandler->create(); + $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); + $objdata->setVar('moddata', \Xmf\Request::getString($fieldName, '', 'POST')); + $objdata->setVar('lid', $lidDownloads); + $objdata->setVar('fid', $downloads_field[$i]->getVar('fid')); + //$modifiedfielddataHandler->insert($objdata) || $objdata->getHtmlErrors(); + $modifieddataHandler->insert($objdata) || $objdata->getHtmlErrors(); } } - $tags = []; + + $tags = []; + $tags['MODIFYREPORTS_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/admin/modified.php'; + /** @var \XoopsNotificationHandler $notificationHandler */ + $notificationHandler = xoops_getHandler('notification'); + $notificationHandler->triggerEvent('global', 0, 'file_modify', $tags); + redirect_header('singlefile.php?lid=' . \Xmf\Request::getInt('lid', 0, 'REQUEST'), timeToRedirect, _MD_TDMDOWNLOADS_MODFILE_THANKSFORINFO . '

      ' . $error_message); } + echo $obj->getHtmlErrors(); } //Affichage du formulaire de notation des téléchargements diff --git a/notification_update.php b/notification_update.php index d33fa15..91a523b 100644 --- a/notification_update.php +++ b/notification_update.php @@ -1,4 +1,5 @@ - */ + /** * Class TdmdownloadsCorePreload */ class TdmdownloadsCorePreload extends \XoopsPreloadItem { // to add PSR-4 autoloader - /** * @param $args */ diff --git a/ratefile.php b/ratefile.php index c968098..c8a50f3 100644 --- a/ratefile.php +++ b/ratefile.php @@ -1,4 +1,4 @@ -add(new \Criteria('lid', $lid)); + $downloadsArray = $downloadsHandler->getAll($criteria); + foreach (array_keys($downloadsArray) as $i) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloadsArray */ + if ($downloadsArray[$i]->getVar('submitter') == $ratinguser) { redirect_header('singlefile.php?lid=' . \Xmf\Request::getInt('lid', 0), 2, _MD_TDMDOWNLOADS_RATEFILE_CANTVOTEOWN); } } + // si c'est un membre on vérifie qu'il ne vote pas 2 fois + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('lid', $lid)); + $votesArray = $ratingHandler->getAll($criteria); + foreach (array_keys($votesArray) as $i) { /** @var \XoopsModules\Wfdownloads\Rating[] $votesArray */ + if ($votesArray[$i]->getVar('ratinguser') === $ratinguser) { redirect_header('singlefile.php?lid=' . \Xmf\Request::getInt('lid', 0), 2, _MD_TDMDOWNLOADS_RATEFILE_VOTEONCE); } } } else { // si c'est un utilisateur anonyme on vérifie qu'il ne vote pas 2 fois par jour - $yesterday = (time() - 86400); - $criteria = new \CriteriaCompo(); + + $yesterday = time() - 86400; + + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('lid', $lid)); + $criteria->add(new \Criteria('ratinguser', 0)); + $criteria->add(new \Criteria('ratinghostname', getenv('REMOTE_ADDR'))); + $criteria->add(new \Criteria('ratingtimestamp', $yesterday, '>')); + if ($ratingHandler->getCount($criteria) >= 1) { redirect_header('singlefile.php?lid=' . \Xmf\Request::getInt('lid', 0), 2, _MD_TDMDOWNLOADS_RATEFILE_VOTEONCE); } @@ -122,13 +139,15 @@ $rating = \Xmf\Request::getInt('rating', 0, 'POST'); if ($rating < 0 || $rating > 10) { $errorMessage .= _MD_TDMDOWNLOADS_RATEFILE_NORATING . '
      '; - $erreur = true; + + $erreur = true; } xoops_load('captcha'); $xoopsCaptcha = \XoopsCaptcha::getInstance(); if (!$xoopsCaptcha->verify()) { $errorMessage .= $xoopsCaptcha->getMessage() . '
      '; - $erreur = true; + + $erreur = true; } $obj->setVar('lid', $lid); $obj->setVar('ratinguser', $ratinguser); @@ -140,22 +159,34 @@ } else { if ($ratingHandler->insert($obj)) { $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('lid', $lid)); - $votesArray = $ratingHandler->getAll($criteria); - $votesTotal = $ratingHandler->getCount($criteria); + + $votesArray = $ratingHandler->getAll($criteria); + + $votesTotal = $ratingHandler->getCount($criteria); + $ratingTotal = 0; + foreach (array_keys($votesArray) as $i) { $ratingTotal += $votesArray[$i]->getVar('rating'); } - $rating = $ratingTotal / $votesTotal; + + $rating = $ratingTotal / $votesTotal; + $objdownloads = $downloadsHandler->get($lid); + $objdownloads->setVar('rating', number_format($rating, 1)); + $objdownloads->setVar('votes', $votesTotal); + if ($downloadsHandler->insert($objdownloads)) { redirect_header('singlefile.php?lid=' . $lid, 2, _MD_TDMDOWNLOADS_RATEFILE_VOTEOK); } + echo $objdownloads->getHtmlErrors(); } + echo $obj->getHtmlErrors(); } //Affichage du formulaire de notation des téléchargements diff --git a/rss.php b/rss.php index deaef86..e327473 100644 --- a/rss.php +++ b/rss.php @@ -1,4 +1,4 @@ -add(new \Criteria('cid', '(' . implode(',', $categories) . ')', 'IN')); if (0 !== $cid) { $criteria->add(new \Criteria('cid', $cid)); - $cat = $categoryHandler->get($cid); + + $cat = $categoryHandler->get($cid); + $title = $xoopsConfig['sitename'] . ' - ' . $xoopsModule->getVar('name') . ' - ' . $cat->getVar('cat_title'); } else { $title = $xoopsConfig['sitename'] . ' - ' . $xoopsModule->getVar('name'); @@ -53,14 +55,23 @@ if (!$xoopsTpl->is_cached('db:tdmdownloads_rss.tpl', $cid)) { $xoopsTpl->assign('channel_title', htmlspecialchars($title, ENT_QUOTES)); + $xoopsTpl->assign('channel_link', XOOPS_URL . '/'); + $xoopsTpl->assign('channel_desc', htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES)); + $xoopsTpl->assign('channel_lastbuild', formatTimestamp(time(), 'rss')); + $xoopsTpl->assign('channel_webmaster', $xoopsConfig['adminmail']); + $xoopsTpl->assign('channel_editor', $xoopsConfig['adminmail']); + $xoopsTpl->assign('channel_category', 'Event'); + $xoopsTpl->assign('channel_generator', 'XOOPS - ' . htmlspecialchars($xoopsModule->getVar('name'), ENT_QUOTES)); + $xoopsTpl->assign('channel_language', _LANGCODE); + if (_LANGCODE === 'fr') { $xoopsTpl->assign('docs', 'http://www.scriptol.fr/rss/RSS-2.0.html'); } else { @@ -68,28 +79,38 @@ } $xoopsTpl->assign('image_url', XOOPS_URL . $helper->getConfig('logorss')); + $dimention = getimagesize(XOOPS_ROOT_PATH . $helper->getConfig('logorss')); + if (empty($dimention[0])) { $width = 88; } else { - $width = ($dimention[0] > 144) ? 144 : $dimention[0]; + $width = $dimention[0] > 144 ? 144 : $dimention[0]; } + if (empty($dimention[1])) { $height = 31; } else { - $height = ($dimention[1] > 400) ? 400 : $dimention[1]; + $height = $dimention[1] > 400 ? 400 : $dimention[1]; } + $xoopsTpl->assign('image_width', $width); + $xoopsTpl->assign('image_height', $height); + foreach (array_keys($downloadsArray) as $i) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloadsArray */ + $description = $downloadsArray[$i]->getVar('description'); + //permet d'afficher uniquement la description courte + if (false === mb_strpos($description, '[pagebreak]')) { $descriptionShort = $description; } else { $descriptionShort = mb_substr($description, 0, mb_strpos($description, '[pagebreak]')); } + $xoopsTpl->append( 'items', [ diff --git a/search.php b/search.php index 6f6139a..5ca489b 100644 --- a/search.php +++ b/search.php @@ -1,4 +1,5 @@ -getVar('fid'); - $criteria = new \CriteriaCompo(); + + $lid_arr = []; + + $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); + + $criteria = new \CriteriaCompo(); + if (\Xmf\Request::hasVar($fieldName, 'REQUEST')) { 999 !== \Xmf\Request::getInt($fieldName, 0, 'REQUEST') ? $fieldContent[$downloads_field[$i]->getVar('fid')] = \Xmf\Request::getInt($fieldName, 0, 'REQUEST') : $fieldContent[$downloads_field[$i]->getVar('fid')] = 999; + $arguments .= $fieldName . '=' . \Xmf\Request::getInt($fieldName, 0, 'REQUEST') . '&'; } else { $fieldContent[$downloads_field[$i]->getVar('fid')] = 999; - $arguments .= $fieldName . '=&'; + + $arguments .= $fieldName . '=&'; } + if (1 == $downloads_field[$i]->getVar('status_def')) { $criteria->add(new \Criteria('status', 0, '!=')); + if (1 == $downloads_field[$i]->getVar('fid')) { //page d'accueil + $title_sup = _AM_TDMDOWNLOADS_FORMHOMEPAGE; + $criteria->setSort('homepage'); + $fieldNameBase = 'homepage'; } + if (2 == $downloads_field[$i]->getVar('fid')) { //version + $title_sup = _AM_TDMDOWNLOADS_FORMVERSION; + $criteria->setSort('version'); + $fieldNameBase = 'version'; } + if (3 == $downloads_field[$i]->getVar('fid')) { //taille du fichier + $title_sup = _AM_TDMDOWNLOADS_FORMSIZE; + $criteria->setSort('size'); + $fieldNameBase = 'size'; } + if (4 == $downloads_field[$i]->getVar('fid')) { //platform - $title_sup = _AM_TDMDOWNLOADS_FORMPLATFORM; + + $title_sup = _AM_TDMDOWNLOADS_FORMPLATFORM; + $platformArray = explode('|', $helper->getConfig('plateform')); + foreach ($platformArray as $platform) { $contentArray[$platform] = $platform; } + if (999 !== $fieldContent[$downloads_field[$i]->getVar('fid')]) { $criteria_2->add(new \Criteria('platform', '%' . $fieldContent[$downloads_field[$i]->getVar('fid')] . '%', 'LIKE')); } } else { $criteria->setOrder('ASC'); + $tdmdownloadsArray = $downloadsHandler->getAll($criteria); + foreach (array_keys($tdmdownloadsArray) as $j) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $tdmdownloadsArray */ - $contentArray[$tdmdownloadsArray[$j]->getVar($fieldNameBase)] = $tdmdownloadsArray[$j]->getVar($fieldNameBase); + $temp = $tdmdownloadsArray[$j]->getVar($fieldNameBase); + $contentArray[$temp] = $temp; } + if (999 !== $fieldContent[$downloads_field[$i]->getVar('fid')]) { $criteria_2->add(new \Criteria($fieldNameBase, $fieldContent[$downloads_field[$i]->getVar('fid')])); } } } else { $title_sup = $downloads_field[$i]->getVar('title'); + $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid'))); + $criteria->setSort('data'); + $criteria->setOrder('ASC'); + $tdmdownloadsArray = $fielddataHandler->getAll($criteria); + foreach (array_keys($tdmdownloadsArray) as $j) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $tdmdownloadsArray */ + $contentArray[$tdmdownloadsArray[$j]->getVar('data', 'n')] = $tdmdownloadsArray[$j]->getVar('data'); } + if ('' !== $fieldContent[$downloads_field[$i]->getVar('fid')]) { $criteria_1 = new \CriteriaCompo(); + $criteria_1->add(new \Criteria('data', $fieldContent[$downloads_field[$i]->getVar('fid')])); + $dataArray = $fielddataHandler->getAll($criteria_1); + foreach (array_keys($dataArray) as $k) { /** @var \XoopsModules\Tdmdownloads\Fielddata[] $dataArray */ + $lid_arr[] = $dataArray[$k]->getVar('lid'); } } } + if (count($lid_arr) > 0) { $criteria_2->add(new \Criteria('lid', '(' . implode(',', $lid_arr) . ')', 'IN')); } + $select_sup = new \XoopsFormSelect($title_sup, $fieldName, $fieldContent[$downloads_field[$i]->getVar('fid')]); + $select_sup->addOption(999, _MD_TDMDOWNLOADS_SEARCH_ALL1); + $select_sup->addOptionArray($contentArray); + $form->addElement($select_sup); + unset($select_sup); + $xoopsTpl->append('field', $downloads_field[$i]->getVar('title')); } @@ -165,10 +214,12 @@ if ('' !== $title) { $criteria_2->add(new \Criteria('title', '%' . $title . '%', 'LIKE')); + $arguments .= 'title=' . $title . '&'; } if (0 !== $cat) { $criteria_2->add(new \Criteria('cid', $cat)); + $arguments .= 'cat=' . $cat . '&'; } $tblsort = []; @@ -196,16 +247,20 @@ $numrows = $downloadsHandler->getCount($criteria_2); if (\Xmf\Request::hasVar('limit', 'REQUEST')) { $criteria_2->setLimit(\Xmf\Request::getInt('limit', 0, 'REQUEST')); + $limit = \Xmf\Request::getInt('limit', 0, 'REQUEST'); } else { $criteria_2->setLimit($helper->getConfig('perpageliste')); + $limit = $helper->getConfig('perpageliste'); } if (\Xmf\Request::hasVar('start', 'REQUEST')) { $criteria_2->setStart(\Xmf\Request::getInt('start', 0, 'REQUEST')); + $start = \Xmf\Request::getInt('start', 0, 'REQUEST'); } else { $criteria_2->setStart(0); + $start = 0; } //pour faire une jointure de table @@ -215,7 +270,9 @@ $tdmdownloadsArray = $downloadsHandler->getByLink($criteria_2); if ($numrows > $limit) { require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; + $pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', $arguments); + $pagenav = $pagenav->renderNav(4); } else { $pagenav = ''; @@ -224,42 +281,64 @@ $xoopsTpl->assign('pagenav', $pagenav); $keywords = ''; foreach (array_keys($tdmdownloadsArray) as $i) { - $tdmdownloadsTab['lid'] = $tdmdownloadsArray[$i]->getVar('lid'); - $tdmdownloadsTab['cid'] = $tdmdownloadsArray[$i]->getVar('cid'); - $tdmdownloadsTab['title'] = $tdmdownloadsArray[$i]->getVar('title'); - $tdmdownloadsTab['cat'] = $tdmdownloadsArray[$i]->getVar('cat_title'); + $tdmdownloadsTab['lid'] = $tdmdownloadsArray[$i]->getVar('lid'); + + $tdmdownloadsTab['cid'] = $tdmdownloadsArray[$i]->getVar('cid'); + + $tdmdownloadsTab['title'] = $tdmdownloadsArray[$i]->getVar('title'); + + $tdmdownloadsTab['cat'] = $tdmdownloadsArray[$i]->getVar('cat_title'); + $tdmdownloadsTab['imgurl'] = $uploadurl . $tdmdownloadsArray[$i]->getVar('cat_imgurl'); - $tdmdownloadsTab['date'] = formatTimestamp($tdmdownloadsArray[$i]->getVar('date'), 'd/m/Y'); + + $tdmdownloadsTab['date'] = formatTimestamp($tdmdownloadsArray[$i]->getVar('date'), 'd/m/Y'); + $tdmdownloadsTab['rating'] = number_format($tdmdownloadsArray[$i]->getVar('rating'), 0); - $tdmdownloadsTab['hits'] = $tdmdownloadsArray[$i]->getVar('hits'); - $contenu = ''; + + $tdmdownloadsTab['hits'] = $tdmdownloadsArray[$i]->getVar('hits'); + + $contenu = ''; + foreach (array_keys($downloads_field) as $j) { if (1 == $downloads_field[$j]->getVar('status_def')) { if (1 == $downloads_field[$j]->getVar('fid')) { //page d'accueil + $contenu = $tdmdownloadsArray[$i]->getVar('homepage'); } + if (2 == $downloads_field[$j]->getVar('fid')) { //version + $contenu = $tdmdownloadsArray[$i]->getVar('version'); } + if (3 == $downloads_field[$j]->getVar('fid')) { //taille du fichier + //mb $contenu = $utilities->convertFileSize($tdmdownloads_arr[$i]->getVar('size')); + $contenu = $tdmdownloadsArray[$i]->getVar('size'); } + if (4 == $downloads_field[$j]->getVar('fid')) { //plateforme + $contenu = $tdmdownloadsArray[$i]->getVar('platform'); } } else { $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('lid', $tdmdownloadsArray[$i]->getVar('lid'))); + $criteria->add(new \Criteria('fid', $downloads_field[$j]->getVar('fid'))); + $downloadsfielddata = $fielddataHandler->getAll($criteria); + if (count($downloadsfielddata) > 0) { foreach (array_keys($downloadsfielddata) as $k) { /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloadsfielddata */ + $contenu = $downloadsfielddata[$k]->getVar('data', 'n'); } } else { @@ -268,8 +347,10 @@ } $tdmdownloadsTab['fielddata'][$j] = $contenu; + unset($contenu); } + $xoopsTpl->append('search_list', $tdmdownloadsTab); $keywords .= $tdmdownloadsArray[$i]->getVar('title') . ','; diff --git a/singlefile.php b/singlefile.php index c8abcf9..aec2583 100644 --- a/singlefile.php +++ b/singlefile.php @@ -1,4 +1,4 @@ -getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' arrow ', true, 'ASC', true); -$navigation = $navigation . ' arrow ' . $viewDownloads->getVar('title'); +$navigation .= ' arrow ' . $viewDownloads->getVar('title'); $xoopsTpl->assign('navigation', $navigation); // sortie des informations //Utilisation d'une copie d'écran avec la largeur selon les préférences if (1 == $helper->getConfig('useshots')) { $xoopsTpl->assign('shotwidth', $helper->getConfig('shotwidth')); + $xoopsTpl->assign('show_screenshot', true); + $xoopsTpl->assign('img_float', $helper->getConfig('img_float')); } if ('ltr' === $helper->getConfig('download_float')) { $xoopsTpl->assign('textfloat', 'floatleft'); + $xoopsTpl->assign('infofloat', 'floatright'); } else { $xoopsTpl->assign('textfloat', 'floatright'); + $xoopsTpl->assign('infofloat', 'floatleft'); } @@ -79,6 +83,7 @@ $logourl = ''; } else { $logourl = $viewDownloads->getVar('logourl'); + $logourl = $uploadurl_shots . $logourl; } // Défini si la personne est un admin @@ -139,12 +144,15 @@ * @param $k * @return string */ -function xfield_key( $k ) { - return strtolower( str_replace( - ["Ü", "ü", "Ş", "ş", "I", "ı", "Ç", "ç", "Ğ", "ğ", "Ö", "ö"], - ["u", "u", "s", "s", "i", "i", "c", "c", "g", "g", "o", "o"], - $k - ) ); +function getXfieldKey($k) +{ + return mb_strtolower( + str_replace( + ['Ü', 'ü', 'Ş', 'ş', 'I', 'ı', 'Ç', 'ç', 'Ğ', 'ğ', 'Ö', 'ö'], + ['u', 'u', 's', 's', 'i', 'i', 'c', 'c', 'g', 'g', 'o', 'o'], + $k + ) + ); } // pour les champs supplémentaires @@ -157,42 +165,55 @@ function xfield_key( $k ) { $nb_champ = count($downloads_field); $champ_sup = ''; $champ_sup_vide = 0; -$xfields = []; +$xfields = []; foreach (array_keys($downloads_field) as $i) { /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ + if (1 == $downloads_field[$i]->getVar('status_def')) { if (1 == $downloads_field[$i]->getVar('fid')) { //page d'accueil + if ('' != $viewDownloads->getVar('homepage')) { $champ_sup = ' ' . _AM_TDMDOWNLOADS_FORMHOMEPAGE . ': ' . _MD_TDMDOWNLOADS_SINGLEFILE_ICI . ''; + ++$champ_sup_vide; $xfields['homepage'] = $champ_sup; } } + if (2 == $downloads_field[$i]->getVar('fid')) { //version + if ('' != $viewDownloads->getVar('version')) { $champ_sup = ' ' . _AM_TDMDOWNLOADS_FORMVERSION . ': ' . $viewDownloads->getVar('version'); + ++$champ_sup_vide; $xfields['version'] = $champ_sup; } } + if (3 == $downloads_field[$i]->getVar('fid')) { //taille du fichier + $size_value_arr = explode(' ', $viewDownloads->getVar('size')); + if ('' != $size_value_arr[0]) { $champ_sup = ' ' . _AM_TDMDOWNLOADS_FORMSIZE . ': ' . $utility::convertSizeToString($viewDownloads->getVar('size')); + ++$champ_sup_vide; $xfields['size'] = $champ_sup; } } + if (4 == $downloads_field[$i]->getVar('fid')) { //plateforme + if ('' != $viewDownloads->getVar('platform')) { $champ_sup = ' ' . _AM_TDMDOWNLOADS_FORMPLATFORM . $viewDownloads->getVar('platform'); + ++$champ_sup_vide; $xfields['platform'] = $champ_sup; @@ -200,23 +221,34 @@ function xfield_key( $k ) { } } else { $view_data = $fielddataHandler->get(); - $criteria = new \CriteriaCompo(); + + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('lid', \Xmf\Request::getInt('lid', 0, 'REQUEST'))); + $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid'))); + $downloadsfielddata = $fielddataHandler->getAll($criteria); - $contenu = ''; + + $contenu = ''; + foreach (array_keys($downloadsfielddata) as $j) { /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloadsfielddata */ + $contenu = $downloadsfielddata[$j]->getVar('data', 'n'); } + if ('' != $contenu) { $champ_sup = ' ' . $downloads_field[$i]->getVar('title') . ': ' . $contenu; + ++$champ_sup_vide; - $xfield_key = xfield_key( $downloads_field[$i]->getVar('title') ); - $xfields[ $xfield_key ] = $contenu; + $xfieldKey = getXfieldKey($downloads_field[$i]->getVar('title')); + + $xfields[$xfieldKey] = $contenu; } } + if ('' != $champ_sup) { $xoopsTpl->append( 'champ_sup', @@ -226,6 +258,7 @@ function xfield_key( $k ) { ] ); } + $champ_sup = ''; } @@ -255,20 +288,25 @@ function xfield_key( $k ) { } // pour utiliser tellafriend. -if ((1 == $helper->getConfig('usetellafriend')) && is_dir('../tellafriend')) { - $string = sprintf(_MD_TDMDOWNLOADS_SINGLEFILE_INTFILEFOUND, $xoopsConfig['sitename'] . ': ' . XOOPS_URL . '/modules/' . $moduleDirName . '/singlefile.php?lid=' . \Xmf\Request::getInt('lid', 0, 'REQUEST')); +if (1 == $helper->getConfig('usetellafriend') && is_dir('../tellafriend')) { + $string = sprintf(_MD_TDMDOWNLOADS_SINGLEFILE_INTFILEFOUND, $xoopsConfig['sitename'] . ': ' . XOOPS_URL . '/modules/' . $moduleDirName . '/singlefile.php?lid=' . \Xmf\Request::getInt('lid', 0, 'REQUEST')); + $subject = sprintf(_MD_TDMDOWNLOADS_SINGLEFILE_INTFILEFOUND, $xoopsConfig['sitename']); + if (false !== mb_strpos($subject, '%')) { $subject = rawurldecode($subject); } + if (false !== mb_stripos($string, '%3F')) { $string = rawurldecode($string); } + if (preg_match('/(' . preg_quote(XOOPS_URL, '/') . '.*)$/i', $string, $matches)) { $targetUri = str_replace('&', '&', $matches[1]); } else { $targetUri = XOOPS_URL . $_SERVER['REQUEST_URI']; } + $tellafriendText = '' . _MD_TDMDOWNLOADS_SINGLEFILE_TELLAFRIEND . ''; } else { $tellafriendText = 'TDMDownloads <{$smarty.const._AM_TDMDOWNLOADS_MAINTAINEDBY}> Xoops Support Team <{if $latestModRelease}> -


      +
      +
      +
      <{$latestModRelease}> <{/if}> diff --git a/templates/blocks/tdmdownloads_block_stylesimple.tpl b/templates/blocks/tdmdownloads_block_stylesimple.tpl index 00e58ec..5af8488 100644 --- a/templates/blocks/tdmdownloads_block_stylesimple.tpl +++ b/templates/blocks/tdmdownloads_block_stylesimple.tpl @@ -1,39 +1,40 @@ <{if $tdmblockstyle == 'simple4'}> -
      -<{elseif $tdmblockstyle == 'simple3'}> +
      + <{elseif $tdmblockstyle == 'simple3'}>
      -<{elseif $tdmblockstyle == 'simple2'}> -
      -<{else}> -
      -<{/if}> -
      -
      - <{if $downloads.logourl}> - + <{elseif $tdmblockstyle == 'simple2'}> +
      + <{else}> +
      <{/if}> -

      <{$downloads.title}>

      - <{if $downloads.description}> -

      <{$downloads.description}>

      - <{/if}> - <{if $downloads.inforation}> -

      - <{$smarty.const._MB_TDMDOWNLOADS_SUBMITDATE}><{$downloads.date}>
      - <{$smarty.const._MB_TDMDOWNLOADS_SUBMITTER}><{$downloads.submitter}>
      - <{$smarty.const._MB_TDMDOWNLOADS_REATING}><{$downloads.rating}>
      - <{$smarty.const._MB_TDMDOWNLOADS_HITS}><{$downloads.hits}> -

      - <{/if}> -
      -
      -

      - - <{if $perm_submit}> - - <{/if}> -

      +
      +
      + <{if $downloads.logourl}> + + <{/if}> +

      <{$downloads.title}>

      + <{if $downloads.description}> +

      <{$downloads.description}>

      + <{/if}> + <{if $downloads.inforation}> +

      + <{$smarty.const._MB_TDMDOWNLOADS_SUBMITDATE}><{$downloads.date}>
      + <{$smarty.const._MB_TDMDOWNLOADS_SUBMITTER}><{$downloads.submitter}>
      + <{$smarty.const._MB_TDMDOWNLOADS_REATING}><{$downloads.rating}>
      + <{$smarty.const._MB_TDMDOWNLOADS_HITS}><{$downloads.hits}> +

      + <{/if}> +
      +
      +

      + + <{if $perm_submit}> + + <{/if}> +

      +
      +
      -
      -
      diff --git a/templates/tdmdownloads_footer.tpl b/templates/tdmdownloads_footer.tpl index b1c1ac9..7a23084 100644 --- a/templates/tdmdownloads_footer.tpl +++ b/templates/tdmdownloads_footer.tpl @@ -3,7 +3,8 @@ <{/if}>
      <{if $xoops_isadmin}> -
      + +
      <{/if}>
      <{if $comment_mode == "flat"}> @@ -19,5 +20,5 @@ <{include file='db:system_notification_select.tpl'}>
      <{if $copyright}> -
      <{$copyright}>
      +
      <{$copyright}>
      <{/if}> diff --git a/testdata/index.php b/testdata/index.php index 65c6ee7..d27f520 100644 --- a/testdata/index.php +++ b/testdata/index.php @@ -1,4 +1,5 @@ -check()) { redirect_header('../admin/index.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); } - loadSampleData(); + + loadSampleData(); } else { xoops_cp_header(); + xoops_confirm( [ 'ok' => 1, @@ -51,6 +54,7 @@ ), true ); + xoops_cp_footer(); } break; @@ -64,36 +68,50 @@ function loadSampleData() { global $xoopsConfig; - $moduleDirName = basename(dirname(__DIR__)); + + $moduleDirName = basename(dirname(__DIR__)); + $moduleDirNameUpper = mb_strtoupper($moduleDirName); - $utility = new Tdmdownloads\Utility(); - $configurator = new Common\Configurator(); - $tables = Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); - $language = 'english/'; + + $utility = new Tdmdownloads\Utility(); + + $configurator = new Common\Configurator(); + + $tables = Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); + + $language = 'english/'; + if (is_dir(__DIR__ . '/' . $xoopsConfig['language'])) { $language = $xoopsConfig['language'] . '/'; } + foreach ($tables as $table) { $tabledata = Yaml::readWrapped($language . $table . '.yml'); + if (is_array($tabledata)) { TableLoad::truncateTable($table); + TableLoad::loadTableFromArray($table, $tabledata); } } // --- COPY test folder files --------------- + if (is_array($configurator->copyTestFolders) && count( $configurator->copyTestFolders ) > 0) { // $file = dirname(__DIR__) . '/testdata/images/'; + foreach ( array_keys( $configurator->copyTestFolders ) as $i ) { - $src = $configurator->copyTestFolders[$i][0]; + $src = $configurator->copyTestFolders[$i][0]; + $dest = $configurator->copyTestFolders[$i][1]; + $utility::rcopy($src, $dest); } } @@ -104,19 +122,29 @@ function loadSampleData() function saveSampleData() { global $xoopsConfig; - $moduleDirName = basename(dirname(__DIR__)); + + $moduleDirName = basename(dirname(__DIR__)); + $moduleDirNameUpper = mb_strtoupper($moduleDirName); - $tables = Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); - $language = 'english/'; + + $tables = Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); + + $language = 'english/'; + if (is_dir(__DIR__ . '/' . $xoopsConfig['language'])) { $language = $xoopsConfig['language'] . '/'; } + $languageFolder = __DIR__ . '/' . $language; + if (!file_exists($languageFolder . '/')) { Utility::createFolder($languageFolder . '/'); } + $exportFolder = $languageFolder . '/Exports-' . date('Y-m-d-H-i-s') . '/'; + Utility::createFolder($exportFolder); + foreach ($tables as $table) { TableLoad::saveTableToYamlFile($table, $exportFolder . $table . '.yml'); } @@ -126,8 +154,10 @@ function saveSampleData() function exportSchema() { - $moduleDirName = basename(dirname(__DIR__)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $moduleDirName = basename(dirname(__DIR__)); + + $moduleDirNameUpper = mb_strtoupper($moduleDirName); + try { // TODO set exportSchema // $migrate = new Tdmdownloads\Migrate($moduleDirName); diff --git a/upload.php b/upload.php index 3ce758f..229d49f 100644 --- a/upload.php +++ b/upload.php @@ -1,4 +1,5 @@ -checkPermissionRedirect('tdmdownloads_submit', $catId, 'index.php', 3, 'You are not allowed to submit a file', false); $permissionUpload = $permHelper->checkPermission('tdmdownloads_submit', $catId, false); if ($permissionUpload) { - if (0 < $catId) { + if ($catId > 0) { $GLOBALS['xoopsTpl']->assign('catId', $catId); $categoryObj = $categoryHandler->get($catId); + // get config for file type/extenstion + $fileextions = $helper->getConfig('mimetypes'); - $mimetypes = []; + + $mimetypes = []; + foreach ($fileextions as $fe) { switch ($fe) { case 'jpg': @@ -81,45 +85,65 @@ case 'tif': $mimetypes['image/tiff'] = 'image/tiff'; break; - case 'zip': $mimetypes['application/zip'] = 'application/zip'; break; - case 'else': default: - break; } } $allowedfileext = implode("', '", $fileextions); + if ('' !== $allowedfileext) { $allowedfileext = "'" . $allowedfileext . "'"; } + $allowedmimetypes = implode("', '", $mimetypes); + if ('' !== $allowedmimetypes) { $allowedmimetypes = "'" . $allowedmimetypes . "'"; } + // Define Stylesheet + /** @var xos_opal_Theme $xoTheme */ + $xoTheme->addStylesheet(XOOPS_URL . '/media/fine-uploader/fine-uploader-new.css'); + $xoTheme->addStylesheet(XOOPS_URL . '/media/fine-uploader/ManuallyTriggerUploads.css'); + $xoTheme->addStylesheet(XOOPS_URL . '/media/font-awesome/css/font-awesome.min.css'); + $xoTheme->addStylesheet(XOOPS_URL . '/modules/system/css/admin.css'); + // Define scripts + $xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js'); + $xoTheme->addScript('modules/system/js/admin.js'); + $xoTheme->addScript('media/fine-uploader/fine-uploader.js'); + // Define Breadcrumb and tips + $xoopsTpl->assign('multiupload', true); + // echo $helper->getConfig('mimetypes'); + $xoopsTpl->assign('file_maxsize', $helper->getConfig('maxuploadsize')); + $xoopsTpl->assign('img_maxwidth', $helper->getConfig('imageWidth')); + $xoopsTpl->assign('img_maxheight', $helper->getConfig('imageHeight')); + $xoopsTpl->assign('categoryname', $categoryObj->getVar('cat_title')); + $xoopsTpl->assign('allowedfileext', $categoryObj->getVar('allowedfileext')); + $xoopsTpl->assign('allowedmimetypes', $categoryObj->getVar('allowedmimetypes')); + $payload = [ 'aud' => 'ajaxfineupload.php', 'cat' => $catId, @@ -127,14 +151,20 @@ 'handler' => '\XoopsModules\\' . ucfirst($moduleDirName) . '\Common\FineimpuploadHandler', 'moddir' => $moduleDirName, ]; - $jwt = \Xmf\Jwt\TokenFactory::build('fineuploader', $payload, 60 * 30); // token good for 30 minutes + + $jwt = \Xmf\Jwt\TokenFactory::build('fineuploader', $payload, 60 * 30); // token good for 30 minutes + $xoopsTpl->assign('jwt', $jwt); + setcookie('jwt', $jwt); + $fineup_debug = 'false'; + if (($xoopsUser instanceof \XoopsUser ? $xoopsUser->isAdmin() : false) && isset($_REQUEST['FINEUPLOADER_DEBUG'])) { $fineup_debug = 'true'; } + $xoopsTpl->assign('fineup_debug', $fineup_debug); } } @@ -143,4 +173,3 @@ $xoBreadcrumbs[] = ['title' => constant('CO_' . $moduleDirNameUpper . '_IMAGES_UPLOAD')]; //require __DIR__ . '/footer.php'; require_once XOOPS_ROOT_PATH . '/footer.php'; - diff --git a/view.tag.php b/view.tag.php index b10fa9a..239bf08 100644 --- a/view.tag.php +++ b/view.tag.php @@ -1,4 +1,5 @@ -getVar('cat_pid') == $cid) { - $totaldownloads = $utility->getNumbersOfEntries($mytree, $categories, $downloadsArray, $downloadscatArray[$i]->getVar('cat_cid')); + $totaldownloads = $utility->getNumbersOfEntries($mytree, $categories, $downloadsArray, $downloadscatArray[$i]->getVar('cat_cid')); + $subcategories_arr = $mytree->getFirstChild($downloadscatArray[$i]->getVar('cat_cid')); - $chcount = 0; - $subcategories = ''; + + $chcount = 0; + + $subcategories = ''; + //pour les mots clef + $keywords .= $downloadscatArray[$i]->getVar('cat_title') . ','; + foreach (array_keys($subcategories_arr) as $j) { /** @var \XoopsModules\Tdmdownloads\Category[] $subcategories_arr */ + if ($chcount >= $helper->getConfig('nbsouscat')) { $subcategories .= '
    • [+]
    • '; + break; } + $subcategories .= '
    • ' . $subcategories_arr[$j]->getVar('cat_title') . '
    • '; - $keywords .= $downloadscatArray[$i]->getVar('cat_title') . ','; + + $keywords .= $downloadscatArray[$i]->getVar('cat_title') . ','; + ++$chcount; } + $xoopsTpl->append( 'subcategories', [ @@ -112,6 +125,7 @@ 'count' => $count, ] ); + ++$count; } } @@ -121,20 +135,32 @@ //téléchargements récents if (1 == $helper->getConfig('bldate')) { $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('status', 0, '!=')); + $criteria->add(new \Criteria('cid', '(' . implode(',', $categories) . ')', 'IN')); + $criteria->add(new \Criteria('cid', \Xmf\Request::getInt('cid', 0, 'REQUEST'))); + $criteria->setSort('date'); + $criteria->setOrder('DESC'); + $criteria->setLimit($helper->getConfig('nbbl')); + $downloadsArray = $downloadsHandler->getAll($criteria); + foreach (array_keys($downloadsArray) as $i) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloadsArray */ + $title = $downloadsArray[$i]->getVar('title'); + if (mb_strlen($title) >= $helper->getConfig('longbl')) { $title = mb_substr($title, 0, $helper->getConfig('longbl')) . '...'; } + $date = formatTimestamp($downloadsArray[$i]->getVar('date'), 's'); + $xoopsTpl->append( 'bl_date', [ @@ -149,18 +175,28 @@ //plus téléchargés if (1 == $helper->getConfig('blpop')) { $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('status', 0, '!=')); + $criteria->add(new \Criteria('cid', '(' . implode(',', $categories) . ')', 'IN')); + $criteria->add(new \Criteria('cid', \Xmf\Request::getInt('cid', 0, 'REQUEST'))); + $criteria->setSort('hits'); + $criteria->setOrder('DESC'); + $criteria->setLimit($helper->getConfig('nbbl')); + $downloadsArray = $downloadsHandler->getAll($criteria); + foreach (array_keys($downloadsArray) as $i) { $title = $downloadsArray[$i]->getVar('title'); + if (mb_strlen($title) >= $helper->getConfig('longbl')) { $title = mb_substr($title, 0, $helper->getConfig('longbl')) . '...'; } + $xoopsTpl->append( 'bl_pop', [ @@ -175,19 +211,30 @@ //mieux notés if (1 == $helper->getConfig('blrating')) { $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('status', 0, '!=')); + $criteria->add(new \Criteria('cid', '(' . implode(',', $categories) . ')', 'IN')); + $criteria->add(new \Criteria('cid', \Xmf\Request::getInt('cid', 0, 'REQUEST'))); + $criteria->setSort('rating'); + $criteria->setOrder('DESC'); + $criteria->setLimit($helper->getConfig('nbbl')); + $downloadsArray = $downloadsHandler->getAll($criteria); + foreach (array_keys($downloadsArray) as $i) { $title = $downloadsArray[$i]->getVar('title'); + if (mb_strlen($title) >= $helper->getConfig('longbl')) { $title = mb_substr($title, 0, $helper->getConfig('longbl')) . '...'; } + $rating = number_format($downloadsArray[$i]->getVar('rating'), 1); + $xoopsTpl->append( 'bl_rating', [ @@ -209,84 +256,126 @@ // affichage des téléchargements if ($helper->getConfig('perpage') > 0) { $xoopsTpl->assign('nb_dowcol', $helper->getConfig('nb_dowcol')); + //Utilisation d'une copie d'écran avec la largeur selon les préférences + if (1 == $helper->getConfig('useshots')) { $xoopsTpl->assign('shotwidth', $helper->getConfig('shotwidth')); + $xoopsTpl->assign('show_screenshot', true); + $xoopsTpl->assign('img_float', $helper->getConfig('img_float')); } + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('status', 0, '!=')); + $criteria->add(new \Criteria('cid', '(' . implode(',', $categories) . ')', 'IN')); + $criteria->add(new \Criteria('cid', \Xmf\Request::getInt('cid', 0, 'REQUEST'))); + $numrows = $downloadsHandler->getCount($criteria); + $xoopsTpl->assign('lang_thereare', sprintf(_MD_TDMDOWNLOADS_CAT_THEREARE, $numrows)); // Pour un affichage sur plusieurs pages + if (\Xmf\Request::hasVar('limit', 'REQUEST')) { $criteria->setLimit(\Xmf\Request::getInt('limit', 0, 'REQUEST')); + $limit = \Xmf\Request::getInt('limit', 0, 'REQUEST'); } else { $criteria->setLimit($helper->getConfig('perpage')); + $limit = $helper->getConfig('perpage'); } + if (\Xmf\Request::hasVar('start', 'REQUEST')) { $criteria->setStart(\Xmf\Request::getInt('start', 0, 'REQUEST')); + $start = \Xmf\Request::getInt('start', 0, 'REQUEST'); } else { $criteria->setStart(0); + $start = 0; } + if (\Xmf\Request::hasVar('sort', 'REQUEST')) { $criteria->setSort(\Xmf\Request::getString('sort', '', 'REQUEST')); + $sort = \Xmf\Request::getString('sort', '', 'REQUEST'); } else { $criteria->setSort('date'); + $sort = 'date'; } + if (\Xmf\Request::hasVar('order', 'REQUEST')) { $criteria->setOrder(\Xmf\Request::getString('order', '', 'REQUEST')); + $order = \Xmf\Request::getString('order', '', 'REQUEST'); } else { $criteria->setOrder('DESC'); + $order = 'DESC'; } $downloadsArray = $downloadsHandler->getAll($criteria); + if ($numrows > $limit) { require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; + $pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', 'limit=' . $limit . '&cid=' . \Xmf\Request::getInt('cid', 0, 'REQUEST') . '&sort=' . $sort . '&order=' . $order); + $pagenav = $pagenav->renderNav(4); } else { $pagenav = ''; } + $xoopsTpl->assign('pagenav', $pagenav); - $summary = ''; - $cpt = 0; + + $summary = ''; + + $cpt = 0; + $categories = $utility->getItemIds('tdmdownloads_download', $moduleDirName); - $item = $utility->getItemIds('tdmdownloads_download_item', $moduleDirName); + + $item = $utility->getItemIds('tdmdownloads_download_item', $moduleDirName); + foreach (array_keys($downloadsArray) as $i) { if ('blank.gif' === $downloadsArray[$i]->getVar('logourl')) { $logourl = ''; } else { $logourl = $downloadsArray[$i]->getVar('logourl'); + $logourl = $uploadurl_shots . $logourl; } - $datetime = formatTimestamp($downloadsArray[$i]->getVar('date'), 's'); - $submitter = \XoopsUser::getUnameFromId($downloadsArray[$i]->getVar('submitter')); + + $datetime = formatTimestamp($downloadsArray[$i]->getVar('date'), 's'); + + $submitter = \XoopsUser::getUnameFromId($downloadsArray[$i]->getVar('submitter')); + $description = $downloadsArray[$i]->getVar('description'); + //permet d'afficher uniquement la description courte + if (false === mb_strpos($description, '[pagebreak]')) { $descriptionShort = $description; } else { $descriptionShort = mb_substr($description, 0, mb_strpos($description, '[pagebreak]')); } + // pour les vignettes "new" et "mis à jour" + $new = $utility->getStatusImage($downloadsArray[$i]->getVar('date'), $downloadsArray[$i]->getVar('status')); + $pop = $utility->getPopularImage($downloadsArray[$i]->getVar('hits')); // Défini si la personne est un admin + $adminlink = ''; + if (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid())) { $adminlink = ''; } + //permission de télécharger + $downloadPermission = true; + if (1 === $helper->getConfig('permission_download')) { if (!in_array($downloadsArray[$i]->getVar('cid'), $categories)) { $downloadPermission = false; @@ -315,9 +407,13 @@ $downloadPermission = false; } } + // utilisation du sommaire + ++$cpt; + $summary = $cpt . '- ' . $downloadsArray[$i]->getVar('title') . '
      '; + $xoopsTpl->append('summary', ['title' => $summary, 'count' => $cpt]); $xoopsTpl->append( @@ -339,16 +435,20 @@ 'count' => $cpt, ] ); + //pour les mots clef + $keywords .= $downloadsArray[$i]->getVar('title') . ','; } if (0 == $numrows) { $bl_affichage = 0; } + $xoopsTpl->assign('bl_affichage', $bl_affichage); // affichage du sommaire + if ($helper->getConfig('autosummary')) { if (0 == $numrows) { $xoopsTpl->assign('aff_summary', false); @@ -360,33 +460,44 @@ } // sort menu display + if ($numrows > 1) { $xoopsTpl->assign('navigation', true); + $sortorder = $sort . $order; + if ('hitsASC' === $sortorder) { $displaySort = _MD_TDMDOWNLOADS_CAT_POPULARITYLTOM; } + if ('hitsDESC' === $sortorder) { $displaySort = _MD_TDMDOWNLOADS_CAT_POPULARITYMTOL; } + if ('titleASC' === $sortorder) { $displaySort = _MD_TDMDOWNLOADS_CAT_TITLEATOZ; } + if ('titleDESC' === $sortorder) { $displaySort = _MD_TDMDOWNLOADS_CAT_TITLEZTOA; } + if ('dateASC' === $sortorder) { $displaySort = _MD_TDMDOWNLOADS_CAT_DATEOLD; } + if ('dateDESC' === $sortorder) { $displaySort = _MD_TDMDOWNLOADS_CAT_DATENEW; } + if ('ratingASC' === $sortorder) { $displaySort = _MD_TDMDOWNLOADS_CAT_RATINGLTOH; } + if ('ratingDESC' === $sortorder) { $displaySort = _MD_TDMDOWNLOADS_CAT_RATINGHTOL; } + $xoopsTpl->assign('affichage_tri', sprintf(_MD_TDMDOWNLOADS_CAT_CURSORTBY, $displaySort)); } } diff --git a/visit.php b/visit.php index 4babcb2..9b5c9e5 100644 --- a/visit.php +++ b/visit.php @@ -1,4 +1,4 @@ -getConfig('permission_download')) { $item = $utility->getItemIds('tdmdownloads_download_item', $moduleDirName); + if (!in_array($viewDownloads->getVar('lid'), $item)) { redirect_header('singlefile.php?lid=' . $viewDownloads->getVar('lid'), 2, _MD_TDMDOWNLOADS_SINGLEFILE_NOPERMDOWNLOAD); } } else { $categories = $utility->getItemIds('tdmdownloads_download', $moduleDirName); + if (!in_array($viewDownloads->getVar('cid'), $categories)) { redirect_header('singlefile.php?lid=' . $viewDownloads->getVar('lid'), 2, _MD_TDMDOWNLOADS_SINGLEFILE_NOPERMDOWNLOAD); } } //check download limit option if (1 == $helper->getConfig('downlimit')) { - $limitlid = $helper->getConfig('limitlid'); + $limitlid = $helper->getConfig('limitlid'); + $limitglobal = $helper->getConfig('limitglobal'); - $yesterday = strtotime(formatTimestamp(time() - 86400)); + + $yesterday = strtotime(formatTimestamp(time() - 86400)); + if ($limitlid > 0) { $criteria = new \CriteriaCompo(); + if ($xoopsUser) { $criteria->add(new \Criteria('downlimit_uid', $xoopsUser->getVar('uid'), '=')); } else { $criteria->add(new \Criteria('downlimit_hostname', getenv('REMOTE_ADDR'), '=')); } + $criteria->add(new \Criteria('downlimit_lid', $lid, '=')); + $criteria->add(new \Criteria('downlimit_date', $yesterday, '>')); + $numrows = $downlimitHandler->getCount($criteria); + if ($numrows >= $limitlid) { redirect_header('singlefile.php?lid=' . $viewDownloads->getVar('lid'), 5, sprintf(_MD_TDMDOWNLOADS_SINGLEFILE_LIMITLID, $numrows, $limitlid)); } } + if ($limitglobal > 0) { $criteria = new \CriteriaCompo(); + if ($xoopsUser) { $criteria->add(new \Criteria('downlimit_uid', $xoopsUser->getVar('uid'), '=')); } else { $criteria->add(new \Criteria('downlimit_hostname', getenv('REMOTE_ADDR'), '=')); } + $criteria->add(new \Criteria('downlimit_date', $yesterday, '>')); + $numrows = $downlimitHandler->getCount($criteria); + if ($numrows >= $limitglobal) { redirect_header('singlefile.php?lid=' . $viewDownloads->getVar('lid'), 5, sprintf(_MD_TDMDOWNLOADS_SINGLEFILE_LIMITGLOBAL, $numrows, $limitglobal)); } } /** @var \XoopsModules\Tdmdownloads\Downlimit $obj */ + $obj = $downlimitHandler->create(); + $obj->setVar('downlimit_lid', $lid); + $obj->setVar('downlimit_uid', !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0); + $obj->setVar('downlimit_hostname', getenv('REMOTE_ADDR')); + $obj->setVar('downlimit_date', strtotime(formatTimestamp(time()))); + $downlimitHandler->insert($obj) || $obj->getHtmlErrors(); + // purge + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('downlimit_date', time() - 172800, '<')); + $numrows = $downlimitHandler->getCount($criteria); + echo 'a détruire: ' . $numrows . '
      '; + $downlimitHandler->deleteAll($criteria); } @$xoopsLogger->activated = false; error_reporting(0); if ($helper->getConfig('check_host')) { - $goodhost = 0; - $referer = parse_url(xoops_getenv('HTTP_REFERER')); + $goodhost = 0; + + $referer = parse_url(xoops_getenv('HTTP_REFERER')); + $refererHost = $referer['host']; + foreach ($helper->getConfig('referers') as $ref) { if (!empty($ref) && preg_match('/' . $ref . '/i', $refererHost)) { $goodhost = '1'; + break; } } + if (!$goodhost) { redirect_header(XOOPS_URL . "/modules/$moduleDirName/singlefile.php?cid=$cid&lid=$lid", 30, _MD_TDMDOWNLOADS_NOPERMISETOLINK); } @@ -117,6 +149,7 @@ $contentLength = $utility::convertStringToSize($viewDownloads->getVar('size')); if (!preg_match("/^ed2k*:\/\//i", $url)) { header("Content-Length: $contentLength"); + header("Location: $url"); } echo ''; diff --git a/xoops_version.php b/xoops_version.php index d822dbe..c78a9e7 100644 --- a/xoops_version.php +++ b/xoops_version.php @@ -1,4 +1,4 @@ - 10000 * 1048576) { $increment = 500; @@ -578,7 +578,8 @@ $i = $increment; while ($i * 1048576 <= $maxSize) { $optionMaxsize[$i . ' ' . _MI_TDMDOWNLOADS_MAXUPLOAD_SIZE_MB] = $i * 1048576; - $i += $increment; + + $i += $increment; } $modversion['config'][] = [ 'name' => 'maxuploadsize', From 54747e09a91b2075feb512d58eccdc3396a95ee5 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 23:11:43 -0400 Subject: [PATCH 33/62] changelog --- docs/changelog.txt | 3 ++- xoops_version.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 8add152..9e5b081 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -1,4 +1,4 @@ -
      2.0 RC 2 [NOT RELEASED]
      +
      2.0 RC 2 [WORK IN PROGRESS - NOT RELEASED]
      Dev: XOOPS 2.5.11, PHP 7.4.6
      - added hits and ratings and for output of download in index.php (goffy) - added number of subcategories for output of category in index.php (goffy) @@ -10,6 +10,7 @@ - Fix xml (geekwright) - add extra fields visibility (heyula) - refactor Utility (mamba) +- PHP 7.1 (mamba)
      2.0 RC 1 [2019-01-29]
      diff --git a/xoops_version.php b/xoops_version.php index c78a9e7..6581326 100644 --- a/xoops_version.php +++ b/xoops_version.php @@ -27,8 +27,8 @@ $modversion = [ 'name' => _MI_TDMDOWNLOADS_NAME, 'version' => '2.0', - 'module_status' => 'RC 1', - 'release_date' => '2019/01/31', + 'module_status' => 'RC 2', + 'release_date' => '2020/05/17', 'description' => _MI_TDMDOWNLOADS_DESC, 'credits' => 'Mage, Mamba, Goffy', 'author' => 'Mage', From 42f725bd2dac1a2f911a58aefc2f569b4e91717a Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 23:34:26 -0400 Subject: [PATCH 34/62] float --- admin/downloads.php | 2 +- blocks/tdmdownloads_top.php | 3 +- class/Common/Images.php | 352 --------------------------------- class/Common/ImagesHandler.php | 148 -------------- 4 files changed, 3 insertions(+), 502 deletions(-) delete mode 100644 class/Common/Images.php delete mode 100644 class/Common/ImagesHandler.php diff --git a/admin/downloads.php b/admin/downloads.php index 29345a2..980e607 100644 --- a/admin/downloads.php +++ b/admin/downloads.php @@ -208,7 +208,7 @@ 'lid' => $i, 'title' => $downloadsArray[$i]->getVar('title'), 'hits' => $downloadsArray[$i]->getVar('hits'), - 'rating' => number_format($downloadsArray[$i]->getVar('rating'), 1), + 'rating' => number_format((float)$downloadsArray[$i]->getVar('rating'), 1), 'statut_display' => $statusDisplay, ]; diff --git a/blocks/tdmdownloads_top.php b/blocks/tdmdownloads_top.php index f0d9507..951d078 100644 --- a/blocks/tdmdownloads_top.php +++ b/blocks/tdmdownloads_top.php @@ -195,7 +195,7 @@ function b_tdmdownloads_top_show($options) $block[$i]['hits'] = $downloadsArray[$i]->getVar('hits'); - $block[$i]['rating'] = number_format($downloadsArray[$i]->getVar('rating'), 1); + $block[$i]['rating'] = number_format((float)$downloadsArray[$i]->getVar('rating'), 1); $block[$i]['date'] = formatTimestamp($downloadsArray[$i]->getVar('date'), 's'); @@ -208,6 +208,7 @@ function b_tdmdownloads_top_show($options) $GLOBALS['xoopsTpl']->assign('tdmblockstyle', $blockstyle); + /** @var \XoopsGroupPermHandler $grouppermHandler */ $grouppermHandler = xoops_getHandler('groupperm'); $groups = XOOPS_GROUP_ANONYMOUS; diff --git a/class/Common/Images.php b/class/Common/Images.php deleted file mode 100644 index e2cae74..0000000 --- a/class/Common/Images.php +++ /dev/null @@ -1,352 +0,0 @@ - - Website: - */ - -use XoopsModules\Tdmdownloads; - -/** - * Class Object Images - */ -class Images extends \XoopsObject -{ - /** - * Constructor - * - * @param null - */ - public function __construct() - { - $this->initVar('img_id', \XOBJ_DTYPE_INT); - - $this->initVar('img_title', \XOBJ_DTYPE_TXTBOX); - - $this->initVar('img_desc', \XOBJ_DTYPE_TXTAREA); - - $this->initVar('img_name', \XOBJ_DTYPE_TXTBOX); - - $this->initVar('img_namelarge', \XOBJ_DTYPE_TXTBOX); - - $this->initVar('img_nameorig', \XOBJ_DTYPE_TXTBOX); - - $this->initVar('img_mimetype', \XOBJ_DTYPE_TXTBOX); - - $this->initVar('img_size', \XOBJ_DTYPE_INT); - - $this->initVar('img_resx', \XOBJ_DTYPE_INT); - - $this->initVar('img_resy', \XOBJ_DTYPE_INT); - - $this->initVar('img_downloads', \XOBJ_DTYPE_INT); - - $this->initVar('img_ratinglikes', \XOBJ_DTYPE_INT); - - $this->initVar('img_votes', \XOBJ_DTYPE_INT); - - $this->initVar('img_weight', \XOBJ_DTYPE_INT); - - $this->initVar('img_albid', \XOBJ_DTYPE_INT); - - $this->initVar('img_state', \XOBJ_DTYPE_INT); - - $this->initVar('img_date', \XOBJ_DTYPE_INT); - - $this->initVar('img_submitter', \XOBJ_DTYPE_INT); - - $this->initVar('img_ip', \XOBJ_DTYPE_TXTAREA); - - $this->initVar('dohtml', \XOBJ_DTYPE_INT, 1, false); - } - - /** - * @static function &getInstance - * - * @param null - */ - public static function getInstance() - { - static $instance = false; - - if (!$instance) { - $instance = new self(); - } - } - - /** - * @return int - */ - public function getNewInsertedIdImages() - { - return $GLOBALS['xoopsDB']->getInsertId(); - } - - /** - * @public function getForm - * @param bool $action - * @return \XoopsThemeForm - */ - public function getFormImages($action = false) - { - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); - - $moduleDirNameUpper = \mb_strtoupper($moduleDirName); - - $helper = Tdmdownloads\Helper::getInstance(); - - if (!$action) { - $action = $_SERVER['REQUEST_URI']; - } - - // Title - - $title = $this->isNew() ? \sprintf(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_ADD')) : \sprintf(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_EDIT')); - - // Get Theme Form - - \xoops_load('XoopsFormLoader'); - - $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); - - $form->setExtra('enctype="multipart/form-data"'); - - // Form Text ImgTitle - - $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_TITLE'), 'img_title', 50, 255, $this->getVar('img_title'))); - - // Form editor ImgDesc - - $editorConfigs = []; - - $editorConfigs['name'] = 'img_desc'; - - $editorConfigs['value'] = $this->getVar('img_desc', 'e'); - - $editorConfigs['rows'] = 5; - - $editorConfigs['cols'] = 40; - - $editorConfigs['width'] = '100%'; - - $editorConfigs['height'] = '400px'; - - $editorConfigs['editor'] = $helper->getConfig('editor'); - - $form->addElement(new \XoopsFormEditor(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_DESC'), 'img_desc', $editorConfigs)); - - // Form Text ImgName - - $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_NAME'), 'img_name', 50, 255, $this->getVar('img_name')), true); - - // Form Text ImgNameLarge - - $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_NAMELARGE'), 'img_namelarge', 50, 255, $this->getVar('img_namelarge')), true); - - // Form Text ImgOrigname - - $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_NAMEORIG'), 'img_nameorig', 50, 255, $this->getVar('img_nameorig')), true); - - // Form Text ImgMimetype - - $imgMimetype = $this->isNew() ? '0' : $this->getVar('img_mimetype'); - - $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_MIMETYPE'), 'img_mimetype', 20, 150, $imgMimetype)); - - // Form Text ImgSize - - $imgSize = $this->isNew() ? '0' : $this->getVar('img_size'); - - $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_SIZE'), 'img_size', 20, 150, $imgSize)); - - // Form Text ImgResx - - $imgResx = $this->isNew() ? '0' : $this->getVar('img_resx'); - - $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_RESX'), 'img_resx', 20, 150, $imgResx)); - - // Form Text ImgResy - - $imgResy = $this->isNew() ? '0' : $this->getVar('img_resy'); - - $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_RESY'), 'img_resy', 20, 150, $imgResy)); - - // Form Text ImgDownloads - - $imgDownloads = $this->isNew() ? '0' : $this->getVar('img_downloads'); - - $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_DOWNLOADS'), 'img_downloads', 20, 150, $imgDownloads)); - - // Form Text ImgRatinglikes - - $imgRatinglikes = $this->isNew() ? '0' : $this->getVar('img_ratinglikes'); - - $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_RATINGLIKES'), 'img_ratinglikes', 20, 150, $imgRatinglikes)); - - // Form Text ImgVotes - - $imgVotes = $this->isNew() ? '0' : $this->getVar('img_votes'); - - $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_VOTES'), 'img_votes', 20, 150, $imgVotes)); - - // Form Text ImgWeight - - $imgWeight = $this->isNew() ? '0' : $this->getVar('img_weight'); - - $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WEIGHT'), 'img_weight', 20, 150, $imgWeight)); - - // Form Table albums - - $albumsHandler = $helper->getHandler('Albums'); - - $imgAlbidSelect = new \XoopsFormSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_ALBID'), 'img_albid', $this->getVar('img_albid')); - - $imgAlbidSelect->addOptionArray($albumsHandler->getList()); - - $form->addElement($imgAlbidSelect, true); - - // Images handler - - $imagesHandler = $helper->getHandler('Images'); - - // Form Select Images - - $imgStateSelect = new \XoopsFormSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_STATE'), 'img_state', $this->getVar('img_state')); - - $imgStateSelect->addOption('Empty'); - - $imgStateSelect->addOptionArray($imagesHandler->getList()); - - $form->addElement($imgStateSelect, true); - - // Form Text Date Select ImgDate - - $imgDate = $this->isNew() ? 0 : $this->getVar('img_date'); - - $form->addElement(new \XoopsFormTextDateSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'DATE'), 'img_date', '', $imgDate)); - - // Form Select User ImgSubmitter - - $form->addElement(new \XoopsFormSelectUser(\constant('CO_' . $moduleDirNameUpper . '_' . 'SUBMITTER'), 'img_submitter', false, $this->getVar('img_submitter'))); - - // Form Text ImgIp - - $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_IP'), 'img_ip', 50, 255, $this->getVar('img_ip'))); - - // To Save - - $form->addElement(new \XoopsFormHidden('op', 'save')); - - $form->addElement(new \XoopsFormButtonTray('', \_SUBMIT, 'submit', '', false)); - - return $form; - } - - /** - * Get Values - * @param null $keys - * @param null $format - * @param null $maxDepth - * @return array - */ - public function getValuesImages($keys = null, $format = null, $maxDepth = null) - { - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); - - $moduleDirNameUpper = \mb_strtoupper($moduleDirName); - - $helper = Tdmdownloads\Helper::getInstance(); - - $ret = $this->getValues($keys, $format, $maxDepth); - - $ret['id'] = $this->getVar('img_id'); - - $ret['title'] = $this->getVar('img_title'); - - $ret['desc'] = $this->getVar('img_desc', 'n'); - - $ret['name'] = $this->getVar('img_name'); - - $ret['namelarge'] = $this->getVar('img_namelarge'); - - $ret['nameorig'] = $this->getVar('img_nameorig'); - - $ret['mimetype'] = $this->getVar('img_mimetype'); - - $ret['size'] = $this->getVar('img_size'); - - $ret['resx'] = $this->getVar('img_resx'); - - $ret['resy'] = $this->getVar('img_resy'); - - $ret['downloads'] = $this->getVar('img_downloads'); - - $ret['ratinglikes'] = $this->getVar('img_ratinglikes'); - - $ret['votes'] = $this->getVar('img_votes'); - - $ret['weight'] = $this->getVar('img_weight'); - - $ret['albid'] = $this->getVar('img_albid'); - - //$albums = $helper->getHandler('Albums'); - - //$albumsObj = $albums->get($this->getVar('img_albid')); - - //if (isset($albumsObj) && is_object($albumsObj)) { - - //$ret['alb_name'] = $albumsObj->getVar('alb_name'); - - //} - - $ret['state'] = $this->getVar('img_state'); - - $ret['state_text'] = $helper->getStateText($this->getVar('img_state')); - - $ret['date'] = \formatTimestamp($this->getVar('img_date'), 's'); - - $ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('img_submitter')); - - $ret['ip'] = $this->getVar('img_ip'); - - $ret['large'] = \constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_URL') . '/large/' . $this->getVar('img_namelarge'); - - $ret['medium'] = \constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_URL') . '/medium/' . $this->getVar('img_name'); - - $ret['thumb'] = \constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_URL') . '/thumbs/' . $this->getVar('img_name'); - - return $ret; - } - - /** - * Returns an array representation of the object - * - * @return array - */ - public function toArrayImages() - { - $ret = []; - - $vars = $this->getVars(); - - foreach (\array_keys($vars) as $var) { - $ret[$var] = $this->getVar('"{$var}"'); - } - - return $ret; - } -} diff --git a/class/Common/ImagesHandler.php b/class/Common/ImagesHandler.php deleted file mode 100644 index bef5812..0000000 --- a/class/Common/ImagesHandler.php +++ /dev/null @@ -1,148 +0,0 @@ - - Website: - */ - -/** - * Class Object Handler Images - */ -class ImagesHandler extends \XoopsPersistableObjectHandler -{ - /** - * Constructor - * @param \XoopsDatabase|null $db - */ - public function __construct(?\XoopsDatabase $db = null) - { - parent::__construct($db, 'tdmdownloads_images', Images::class, 'img_id', 'img_name'); - } - - /** - * retrieve a field - * - * @param int $i field id - * @param null|mixed $fields - * @return mixed reference to the {@link Get} object - */ - public function get($i = null, $fields = null) - { - return parent::get($i, $fields); - } - - /** - * get inserted id - * - * @param null - * @return int reference to the {@link Get} object - */ - public function getInsertId() - { - return $this->db->getInsertId(); - } - - /** - * Get Count Images in the database - * @param int $albId - * @param int $start - * @param int $limit - * @param string $sort - * @param string $order - * @return int - */ - public function getCountImages($albId = 0, $start = 0, $limit = 0, $sort = 'img_id ASC, img_name', $order = 'ASC') - { - $crCountImages = new \CriteriaCompo(); - - $crCountImages = $this->getImagesCriteria($crCountImages, $albId, $start, $limit, $sort, $order); - - return parent::getCount($crCountImages); - } - - /** - * Get All Images in the database - * @param int $start - * @param int $limit - * @param string $sort - * @param string $order - * @return array - */ - public function getAllImages($start = 0, $limit = 0, $sort = 'img_id ASC, img_name', $order = 'ASC') - { - $crAllImages = new \CriteriaCompo(); - - $crAllImages = $this->getImagesCriteria($crAllImages, 0, $start, $limit, $sort, $order); - - return parent::getAll($crAllImages); - } - - /** - * Get Criteria Images - * @param $crImages - * @param $albId - * @param int $start - * @param int $limit - * @param string $sort - * @param string $order - * @return int - */ - private function getImagesCriteria($crImages, $albId, $start, $limit, $sort, $order) - { - if ($albId > 0) { - $crImages->add(new \Criteria('img_albid', $albId)); - } - - $crImages->setStart($start); - - $crImages->setLimit($limit); - - $crImages->setSort($sort); - - $crImages->setOrder($order); - - return $crImages; - } - - /** - * delete all copies of a specific image - * @param $imageName - * @return bool - */ - public function unlinkImages($imageName) - { - \unlink(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/large/' . $imageName); - - if (\file_exists(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/large/' . $imageName)) { - return false; - } - - \unlink(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/medium/' . $imageName); - - if (\file_exists(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/medium/' . $imageName)) { - return false; - } - - \unlink(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/thumbs/' . $imageName); - - if (\file_exists(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/thumbs/' . $imageName)) { - return false; - } - - return true; - } -} From 13a5aa3b46602534e02ad1ecf43335838386624b Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 23:35:33 -0400 Subject: [PATCH 35/62] add return string --- class/Common/ImageResizer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/Common/ImageResizer.php b/class/Common/ImageResizer.php index 529a454..c50fb93 100644 --- a/class/Common/ImageResizer.php +++ b/class/Common/ImageResizer.php @@ -123,7 +123,7 @@ public function resizeImage($sourcefile, $endfile, $max_width, $max_height, $ima * @param $dest_w * @param $dest_h * @param int $quality - * @return bool + * @return bool|string */ public function resizeAndCrop($src_url, $src_mimetype, $dest_url, $dest_w, $dest_h, $quality = 90) { From 7ef249fdad0ab753eace410ee6ad4c8bff527096 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 23:35:53 -0400 Subject: [PATCH 36/62] PhpDoc --- admin/category.php | 1 + 1 file changed, 1 insertion(+) diff --git a/admin/category.php b/admin/category.php index 6c30551..ba09331 100644 --- a/admin/category.php +++ b/admin/category.php @@ -517,6 +517,7 @@ $perm_id = \Xmf\Request::getInt('cat_cid', $newcat_cid, 'POST'); + /** @var \XoopsGroupPermHandler $grouppermHandler */ $grouppermHandler = xoops_getHandler('groupperm'); $criteria = new \CriteriaCompo(); From 643345174dfa242d71fcca15fe45b0ea0997ffd0 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 17 May 2020 23:59:56 -0400 Subject: [PATCH 37/62] float --- admin/downloads.php | 4 ++-- index.php | 4 ++-- ratefile.php | 2 +- search.php | 2 +- singlefile.php | 2 +- viewcat.php | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/admin/downloads.php b/admin/downloads.php index 980e607..e87e9f6 100644 --- a/admin/downloads.php +++ b/admin/downloads.php @@ -523,7 +523,7 @@ $download['date'] = formatTimestamp($viewDownloads->getVar('date')); $download['submitter'] = XoopsUser::getUnameFromId($viewDownloads->getVar('submitter')); $download['hits'] = $viewDownloads->getVar('hits'); - $download['rating'] = number_format($viewDownloads->getVar('rating'), 1); + $download['rating'] = number_format((float)$viewDownloads->getVar('rating'), 1); $download['votes'] = $viewDownloads->getVar('votes'); if (true === $helper->getConfig('use_paypal') && '' !== $viewDownloads->getVar('paypal')) { @@ -608,7 +608,7 @@ $rating = $ratingTotal / $votesTotal; - $obj->setVar('rating', number_format($rating, 1)); + $obj->setVar('rating', number_format((float)$rating, 1)); $obj->setVar('votes', $votesTotal); diff --git a/index.php b/index.php index 5b6deed..f11b54d 100644 --- a/index.php +++ b/index.php @@ -198,7 +198,7 @@ $title = mb_substr($title, 0, $helper->getConfig('longbl')) . '...'; } - $rating = number_format($downloads_arr_rating[$i]->getVar('rating'), 1); + $rating = number_format((float)$downloads_arr_rating[$i]->getVar('rating'), 1); $xoopsTpl->append( 'bl_rating', @@ -212,7 +212,7 @@ } } $bl_affichage = 1; -if (0 == $helper->getConfig('bldate') && 0 == $helper->getConfig('blpop') && 0 == $helper->getConfig('blrating')) { +if (0 === $helper->getConfig('bldate') && 0 === $helper->getConfig('blpop') && 0 === $helper->getConfig('blrating')) { $bl_affichage = 0; } $xoopsTpl->assign('bl_affichage', $bl_affichage); diff --git a/ratefile.php b/ratefile.php index c8a50f3..0ad9ce2 100644 --- a/ratefile.php +++ b/ratefile.php @@ -176,7 +176,7 @@ $objdownloads = $downloadsHandler->get($lid); - $objdownloads->setVar('rating', number_format($rating, 1)); + $objdownloads->setVar('rating', number_format((float)$rating, 1)); $objdownloads->setVar('votes', $votesTotal); diff --git a/search.php b/search.php index 5ca489b..004d1ca 100644 --- a/search.php +++ b/search.php @@ -293,7 +293,7 @@ $tdmdownloadsTab['date'] = formatTimestamp($tdmdownloadsArray[$i]->getVar('date'), 'd/m/Y'); - $tdmdownloadsTab['rating'] = number_format($tdmdownloadsArray[$i]->getVar('rating'), 0); + $tdmdownloadsTab['rating'] = number_format((float)$tdmdownloadsArray[$i]->getVar('rating'), 0); $tdmdownloadsTab['hits'] = $tdmdownloadsArray[$i]->getVar('hits'); diff --git a/singlefile.php b/singlefile.php index aec2583..b434667 100644 --- a/singlefile.php +++ b/singlefile.php @@ -121,7 +121,7 @@ $xoopsTpl->assign('date', formatTimestamp($viewDownloads->getVar('date'), 's')); $xoopsTpl->assign('author', \XoopsUser::getUnameFromId($viewDownloads->getVar('submitter'))); $xoopsTpl->assign('hits', sprintf(_MD_TDMDOWNLOADS_SINGLEFILE_NBTELECH, $viewDownloads->getVar('hits'))); -$xoopsTpl->assign('rating', number_format($viewDownloads->getVar('rating'), 1)); +$xoopsTpl->assign('rating', number_format((float)$viewDownloads->getVar('rating'), 1)); $xoopsTpl->assign('votes', sprintf(_MD_TDMDOWNLOADS_SINGLEFILE_VOTES, $viewDownloads->getVar('votes'))); $xoopsTpl->assign('nb_comments', sprintf(_MD_TDMDOWNLOADS_SINGLEFILE_COMMENTS, $viewDownloads->getVar('comments'))); $xoopsTpl->assign('show_bookmark', $helper->getConfig('show_bookmark')); diff --git a/viewcat.php b/viewcat.php index 9253909..21c3b0f 100644 --- a/viewcat.php +++ b/viewcat.php @@ -233,7 +233,7 @@ $title = mb_substr($title, 0, $helper->getConfig('longbl')) . '...'; } - $rating = number_format($downloadsArray[$i]->getVar('rating'), 1); + $rating = number_format((float)$downloadsArray[$i]->getVar('rating'), 1); $xoopsTpl->append( 'bl_rating', @@ -422,7 +422,7 @@ 'id' => $downloadsArray[$i]->getVar('lid'), 'cid' => $downloadsArray[$i]->getVar('cid'), 'title' => $downloadsArray[$i]->getVar('title'), - 'rating' => number_format($downloadsArray[$i]->getVar('rating'), 1), + 'rating' => number_format((float)$downloadsArray[$i]->getVar('rating'), 1), 'hits' => $downloadsArray[$i]->getVar('hits'), 'new' => $new, 'pop' => $pop, From 6210bd9fb49efa09f34ae8b4fb5ae1fa5f2a380e Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 18 May 2020 00:00:28 -0400 Subject: [PATCH 38/62] PhpDoc --- class/Downloads.php | 3 +-- class/Utilities.php | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/class/Downloads.php b/class/Downloads.php index 869c2ee..90fc698 100644 --- a/class/Downloads.php +++ b/class/Downloads.php @@ -474,11 +474,10 @@ public function getForm($donnee = [], $erreur = false, $action = false) if (2 == $helper->getConfig('permission_download')) { /** @var \XoopsMemberHandler $memberHandler */ - $memberHandler = \xoops_getHandler('member'); - $group_list = $memberHandler->getGroupList(); + /** @var \XoopsGroupPermHandler $grouppermHandler */ $grouppermHandler = \xoops_getHandler('groupperm'); $full_list = \array_keys($group_list); diff --git a/class/Utilities.php b/class/Utilities.php index da761e4..788b2d1 100644 --- a/class/Utilities.php +++ b/class/Utilities.php @@ -49,12 +49,14 @@ public static function getItemIds($permtype, $dirname) return $permissions[$permtype]; } + /** @var \XoopsModuleHandler $moduleHandler */ $moduleHandler = \xoops_getHandler('module'); $tdmModule = $moduleHandler->getByDirname($dirname); $groups = \is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; + /** @var \XoopsGroupPermHandler $grouppermHandler */ $grouppermHandler = \xoops_getHandler('groupperm'); return $grouppermHandler->getItemIds($permtype, $groups, $tdmModule->getVar('mid')); From d679994ba167ffc317c8c56ada52b6827f4f863a Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 18 May 2020 00:00:44 -0400 Subject: [PATCH 39/62] missing $ --- modfile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modfile.php b/modfile.php index 0e0e407..45d2120 100644 --- a/modfile.php +++ b/modfile.php @@ -319,7 +319,7 @@ $notificationHandler->triggerEvent('global', 0, 'file_modify', $tags); - redirect_header('singlefile.php?lid=' . \Xmf\Request::getInt('lid', 0, 'REQUEST'), timeToRedirect, _MD_TDMDOWNLOADS_MODFILE_THANKSFORINFO . '

      ' . $error_message); + redirect_header('singlefile.php?lid=' . \Xmf\Request::getInt('lid', 0, 'REQUEST'), $timeToRedirect, _MD_TDMDOWNLOADS_MODFILE_THANKSFORINFO . '

      ' . $error_message); } echo $obj->getHtmlErrors(); From b66cc5aebb9a7bd8a79e6067a650cc5f47f16553 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 18 May 2020 00:00:58 -0400 Subject: [PATCH 40/62] array check --- blocks/tdmdownloads_top.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blocks/tdmdownloads_top.php b/blocks/tdmdownloads_top.php index 951d078..b1839a0 100644 --- a/blocks/tdmdownloads_top.php +++ b/blocks/tdmdownloads_top.php @@ -109,7 +109,7 @@ function b_tdmdownloads_top_show($options) $criteria->add(new \Criteria('cid', '(' . implode(',', $categories) . ')', 'IN')); - if (!0 == $options[0] && 1 === count($options)) { + if (is_array($options) && !empty($options) && !0 == $options[0] && 1 === count($options)) { $criteria->add(new \Criteria('cid', '(' . implode(',', $options) . ')', 'IN')); } From fe553895332edf4b475e795bfb9d0389b3a1c41e Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 18 May 2020 00:03:03 -0400 Subject: [PATCH 41/62] undefined $select_sup un --- blocks/tdmdownloads_search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blocks/tdmdownloads_search.php b/blocks/tdmdownloads_search.php index b4d5f35..875598c 100644 --- a/blocks/tdmdownloads_search.php +++ b/blocks/tdmdownloads_search.php @@ -212,7 +212,7 @@ function b_tdmdownloads_search_show() } } - $form->addElement($select_sup); +// $form->addElement($select_sup); } $select_sup = new \XoopsFormSelect($title_sup, $fieldName, $fieldContent[$downloads_field[$i]->getVar('fid')]); From 2636352cf7d360c90c3233a17945aea77980c6c9 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 18 May 2020 00:12:46 -0400 Subject: [PATCH 42/62] sample data --- testdata/english/index.html | 1 + testdata/english/tdmdownloads_broken.yml | 5 ++ testdata/english/tdmdownloads_cat.yml | 21 +++++++ testdata/english/tdmdownloads_downlimit.yml | 1 + testdata/english/tdmdownloads_downloads.yml | 40 +++++++++++++ testdata/english/tdmdownloads_field.yml | 40 +++++++++++++ testdata/english/tdmdownloads_fielddata.yml | 60 +++++++++++++++++++ testdata/english/tdmdownloads_mod.yml | 1 + .../english/tdmdownloads_modfielddata.yml | 1 + testdata/english/tdmdownloads_votedata.yml | 1 + 10 files changed, 171 insertions(+) create mode 100644 testdata/english/index.html create mode 100644 testdata/english/tdmdownloads_broken.yml create mode 100644 testdata/english/tdmdownloads_cat.yml create mode 100644 testdata/english/tdmdownloads_downlimit.yml create mode 100644 testdata/english/tdmdownloads_downloads.yml create mode 100644 testdata/english/tdmdownloads_field.yml create mode 100644 testdata/english/tdmdownloads_fielddata.yml create mode 100644 testdata/english/tdmdownloads_mod.yml create mode 100644 testdata/english/tdmdownloads_modfielddata.yml create mode 100644 testdata/english/tdmdownloads_votedata.yml diff --git a/testdata/english/index.html b/testdata/english/index.html new file mode 100644 index 0000000..74b6f45 --- /dev/null +++ b/testdata/english/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/testdata/english/tdmdownloads_broken.yml b/testdata/english/tdmdownloads_broken.yml new file mode 100644 index 0000000..a1593ca --- /dev/null +++ b/testdata/english/tdmdownloads_broken.yml @@ -0,0 +1,5 @@ +- + reportid: '1' + lid: '1' + sender: '1' + ip: '::1' diff --git a/testdata/english/tdmdownloads_cat.yml b/testdata/english/tdmdownloads_cat.yml new file mode 100644 index 0000000..8eb316d --- /dev/null +++ b/testdata/english/tdmdownloads_cat.yml @@ -0,0 +1,21 @@ +- + cat_cid: '1' + cat_pid: '0' + cat_title: Books + cat_imgurl: blank.png + cat_description_main: 'Books to download in PDF format' + cat_weight: '1' +- + cat_cid: '2' + cat_pid: '0' + cat_title: MP3 + cat_imgurl: blank.gif + cat_description_main: 'Audio files to download in MP3 format' + cat_weight: '2' +- + cat_cid: '3' + cat_pid: '2' + cat_title: 'Free Music' + cat_imgurl: blank.gif + cat_description_main: '' + cat_weight: '3' diff --git a/testdata/english/tdmdownloads_downlimit.yml b/testdata/english/tdmdownloads_downlimit.yml new file mode 100644 index 0000000..f7bcb87 --- /dev/null +++ b/testdata/english/tdmdownloads_downlimit.yml @@ -0,0 +1 @@ +{ } \ No newline at end of file diff --git a/testdata/english/tdmdownloads_downloads.yml b/testdata/english/tdmdownloads_downloads.yml new file mode 100644 index 0000000..11a49d4 --- /dev/null +++ b/testdata/english/tdmdownloads_downloads.yml @@ -0,0 +1,40 @@ +- + lid: '1' + cid: '1' + title: 'Sample Document' + url: 'http://gahp.net/wp-content/uploads/2017/09/sample.pdf' + homepage: '' + version: '' + size: '53.55 K' + platform: '' + description: 'How to compile a .tex file to a .pdf fileTesting' + logourl: blank.png + submitter: '1' + status: '1' + date: '1589774839' + hits: '0' + rating: '0.0000' + votes: '0' + comments: '0' + top: '0' + paypal: '' +- + lid: '2' + cid: '2' + title: 'Free Music File' + url: 'https://sample-videos.com/audio/mp3/crowd-cheering.mp3' + homepage: '' + version: '' + size: '' + platform: '' + description: 'Free MP3 file sample' + logourl: blank.png + submitter: '1' + status: '1' + date: '1589774646' + hits: '2' + rating: '0.0000' + votes: '0' + comments: '0' + top: '0' + paypal: '' diff --git a/testdata/english/tdmdownloads_field.yml b/testdata/english/tdmdownloads_field.yml new file mode 100644 index 0000000..6e24d39 --- /dev/null +++ b/testdata/english/tdmdownloads_field.yml @@ -0,0 +1,40 @@ +- + fid: '1' + title: Platform + img: platform.png + weight: '5' + status: '1' + search: '1' + status_def: '0' +- + fid: '3' + title: Size + img: size.png + weight: '1' + status: '1' + search: '1' + status_def: '0' +- + fid: '4' + title: picture + img: size.png + weight: '0' + status: '0' + search: '0' + status_def: '0' +- + fid: '5' + title: text + img: blank.gif + weight: '0' + status: '1' + search: '0' + status_def: '0' +- + fid: '6' + title: icon + img: platform.png + weight: '0' + status: '1' + search: '0' + status_def: '0' diff --git a/testdata/english/tdmdownloads_fielddata.yml b/testdata/english/tdmdownloads_fielddata.yml new file mode 100644 index 0000000..81bdd8a --- /dev/null +++ b/testdata/english/tdmdownloads_fielddata.yml @@ -0,0 +1,60 @@ +- + iddata: '1' + fid: '1' + lid: '2' + data: Any +- + iddata: '2' + fid: '1' + lid: '1' + data: PDF +- + iddata: '4' + fid: '3' + lid: '1' + data: '5' +- + iddata: '5' + fid: '3' + lid: '2' + data: '32' +- + iddata: '6' + fid: '4' + lid: '1' + data: '' +- + iddata: '7' + fid: '6' + lid: '1' + data: 'https://indir.top/uploads/images/img5d12568b43d9e.jpg' +- + iddata: '8' + fid: '5' + lid: '1' + data: 'This is just a text RESIM' +- + iddata: '9' + fid: '6' + lid: '2' + data: '' +- + iddata: '10' + fid: '4' + lid: '2' + data: '' +- + iddata: '11' + fid: '5' + lid: '2' + data: 'This is just a text RESIM' +- + iddata: '12' + fid: '3' + lid: '2' + data: '32' +- + iddata: '13' + fid: '1' + lid: '2' + data: Any diff --git a/testdata/english/tdmdownloads_mod.yml b/testdata/english/tdmdownloads_mod.yml new file mode 100644 index 0000000..f7bcb87 --- /dev/null +++ b/testdata/english/tdmdownloads_mod.yml @@ -0,0 +1 @@ +{ } \ No newline at end of file diff --git a/testdata/english/tdmdownloads_modfielddata.yml b/testdata/english/tdmdownloads_modfielddata.yml new file mode 100644 index 0000000..f7bcb87 --- /dev/null +++ b/testdata/english/tdmdownloads_modfielddata.yml @@ -0,0 +1 @@ +{ } \ No newline at end of file diff --git a/testdata/english/tdmdownloads_votedata.yml b/testdata/english/tdmdownloads_votedata.yml new file mode 100644 index 0000000..f7bcb87 --- /dev/null +++ b/testdata/english/tdmdownloads_votedata.yml @@ -0,0 +1 @@ +{ } \ No newline at end of file From 11158beaee51e78895528d319f64df961f0a946c Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 18 May 2020 22:15:13 -0400 Subject: [PATCH 43/62] 2.01 Alpha 1 --- admin/blocksadmin.php | 1 - admin/category.php | 3 +- admin/permissions.php | 4 +- class/Category.php | 1 - class/Common/FineimpuploadHandler.php | 6 +- class/Common/Images.php | 352 ++++++++++++++++++++++++++ class/Common/ImagesHandler.php | 148 +++++++++++ class/Downloads.php | 1 - class/Modified.php | 1 - class/Tree.php | 2 +- class/Utility.php | 1 - docs/changelog.txt | 2 +- header.php | 2 +- submit.php | 1 - xoops_version.php | 8 +- 15 files changed, 514 insertions(+), 19 deletions(-) create mode 100644 class/Common/Images.php create mode 100644 class/Common/ImagesHandler.php diff --git a/admin/blocksadmin.php b/admin/blocksadmin.php index 1844a88..632134d 100644 --- a/admin/blocksadmin.php +++ b/admin/blocksadmin.php @@ -82,7 +82,6 @@ function listBlocks() $memberHandler = xoops_getHandler('member'); /** @var \XoopsGroupPermHandler $grouppermHandler */ - $grouppermHandler = xoops_getHandler('groupperm'); $groups = $memberHandler->getGroups(); diff --git a/admin/category.php b/admin/category.php index ba09331..bc51a19 100644 --- a/admin/category.php +++ b/admin/category.php @@ -494,7 +494,6 @@ $perm_id = \Xmf\Request::hasVar('cat_cid', 'POST') ? $cat_cid : $newcat_cid; /** @var \XoopsGroupPermHandler $grouppermHandler */ - $grouppermHandler = xoops_getHandler('groupperm'); $criteria = new \CriteriaCompo(); @@ -540,7 +539,7 @@ if (1 == $helper->getConfig('permission_download')) { $perm_id = \Xmf\Request::getInt('cat_cid', $newcat_cid, 'POST'); - + /** @var \XoopsGroupPermHandler $grouppermHandler */ $grouppermHandler = xoops_getHandler('groupperm'); $criteria = new \CriteriaCompo(); diff --git a/admin/permissions.php b/admin/permissions.php index 1df424c..f48296c 100644 --- a/admin/permissions.php +++ b/admin/permissions.php @@ -36,8 +36,8 @@ ]; xoops_load('XoopsFormLoader'); -$permTableForm = new XoopsSimpleForm('', 'fselperm', 'permissions.php', 'post'); -$formSelect = new XoopsFormSelect('', 'permission', $permission); +$permTableForm = new \XoopsSimpleForm('', 'fselperm', 'permissions.php', 'post'); +$formSelect = new \XoopsFormSelect('', 'permission', $permission); $formSelect->setExtra('onchange="document.fselperm.submit()"'); foreach (array_keys($tab_perm) as $i) { $formSelect->addOption($i, $tab_perm[$i]); diff --git a/class/Category.php b/class/Category.php index 081ef51..89c0f46 100644 --- a/class/Category.php +++ b/class/Category.php @@ -195,7 +195,6 @@ public function getForm($action = false) $group_list = $memberHandler->getGroupList(); /** @var \XoopsGroupPermHandler $grouppermHandler */ - $grouppermHandler = \xoops_getHandler('groupperm'); $full_list = \array_keys($group_list); diff --git a/class/Common/FineimpuploadHandler.php b/class/Common/FineimpuploadHandler.php index 3be2404..b75ee35 100644 --- a/class/Common/FineimpuploadHandler.php +++ b/class/Common/FineimpuploadHandler.php @@ -37,8 +37,10 @@ * SOFTWARE. */ + //class FineImpUploadHandler extends \SystemFineUploadHandler + /** * Class FineimpuploadHandler * @package XoopsModules\Tdmdownloads\Common @@ -275,9 +277,9 @@ private function handleImageDB() $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); - // $imagesHandler = $helper->getHandler('Images'); + $imagesHandler = $helper->getHandler('Images'); - $imagesHandler = new \XoopsModules\Tdmdownloads\Common\ImagesHandler(); +// $imagesHandler = new \XoopsModules\Tdmdownloads\Common\ImagesHandler(); $imagesObj = $imagesHandler->create(); diff --git a/class/Common/Images.php b/class/Common/Images.php new file mode 100644 index 0000000..e2cae74 --- /dev/null +++ b/class/Common/Images.php @@ -0,0 +1,352 @@ + - Website: + */ + +use XoopsModules\Tdmdownloads; + +/** + * Class Object Images + */ +class Images extends \XoopsObject +{ + /** + * Constructor + * + * @param null + */ + public function __construct() + { + $this->initVar('img_id', \XOBJ_DTYPE_INT); + + $this->initVar('img_title', \XOBJ_DTYPE_TXTBOX); + + $this->initVar('img_desc', \XOBJ_DTYPE_TXTAREA); + + $this->initVar('img_name', \XOBJ_DTYPE_TXTBOX); + + $this->initVar('img_namelarge', \XOBJ_DTYPE_TXTBOX); + + $this->initVar('img_nameorig', \XOBJ_DTYPE_TXTBOX); + + $this->initVar('img_mimetype', \XOBJ_DTYPE_TXTBOX); + + $this->initVar('img_size', \XOBJ_DTYPE_INT); + + $this->initVar('img_resx', \XOBJ_DTYPE_INT); + + $this->initVar('img_resy', \XOBJ_DTYPE_INT); + + $this->initVar('img_downloads', \XOBJ_DTYPE_INT); + + $this->initVar('img_ratinglikes', \XOBJ_DTYPE_INT); + + $this->initVar('img_votes', \XOBJ_DTYPE_INT); + + $this->initVar('img_weight', \XOBJ_DTYPE_INT); + + $this->initVar('img_albid', \XOBJ_DTYPE_INT); + + $this->initVar('img_state', \XOBJ_DTYPE_INT); + + $this->initVar('img_date', \XOBJ_DTYPE_INT); + + $this->initVar('img_submitter', \XOBJ_DTYPE_INT); + + $this->initVar('img_ip', \XOBJ_DTYPE_TXTAREA); + + $this->initVar('dohtml', \XOBJ_DTYPE_INT, 1, false); + } + + /** + * @static function &getInstance + * + * @param null + */ + public static function getInstance() + { + static $instance = false; + + if (!$instance) { + $instance = new self(); + } + } + + /** + * @return int + */ + public function getNewInsertedIdImages() + { + return $GLOBALS['xoopsDB']->getInsertId(); + } + + /** + * @public function getForm + * @param bool $action + * @return \XoopsThemeForm + */ + public function getFormImages($action = false) + { + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); + + $helper = Tdmdownloads\Helper::getInstance(); + + if (!$action) { + $action = $_SERVER['REQUEST_URI']; + } + + // Title + + $title = $this->isNew() ? \sprintf(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_ADD')) : \sprintf(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_EDIT')); + + // Get Theme Form + + \xoops_load('XoopsFormLoader'); + + $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); + + $form->setExtra('enctype="multipart/form-data"'); + + // Form Text ImgTitle + + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_TITLE'), 'img_title', 50, 255, $this->getVar('img_title'))); + + // Form editor ImgDesc + + $editorConfigs = []; + + $editorConfigs['name'] = 'img_desc'; + + $editorConfigs['value'] = $this->getVar('img_desc', 'e'); + + $editorConfigs['rows'] = 5; + + $editorConfigs['cols'] = 40; + + $editorConfigs['width'] = '100%'; + + $editorConfigs['height'] = '400px'; + + $editorConfigs['editor'] = $helper->getConfig('editor'); + + $form->addElement(new \XoopsFormEditor(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_DESC'), 'img_desc', $editorConfigs)); + + // Form Text ImgName + + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_NAME'), 'img_name', 50, 255, $this->getVar('img_name')), true); + + // Form Text ImgNameLarge + + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_NAMELARGE'), 'img_namelarge', 50, 255, $this->getVar('img_namelarge')), true); + + // Form Text ImgOrigname + + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_NAMEORIG'), 'img_nameorig', 50, 255, $this->getVar('img_nameorig')), true); + + // Form Text ImgMimetype + + $imgMimetype = $this->isNew() ? '0' : $this->getVar('img_mimetype'); + + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_MIMETYPE'), 'img_mimetype', 20, 150, $imgMimetype)); + + // Form Text ImgSize + + $imgSize = $this->isNew() ? '0' : $this->getVar('img_size'); + + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_SIZE'), 'img_size', 20, 150, $imgSize)); + + // Form Text ImgResx + + $imgResx = $this->isNew() ? '0' : $this->getVar('img_resx'); + + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_RESX'), 'img_resx', 20, 150, $imgResx)); + + // Form Text ImgResy + + $imgResy = $this->isNew() ? '0' : $this->getVar('img_resy'); + + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_RESY'), 'img_resy', 20, 150, $imgResy)); + + // Form Text ImgDownloads + + $imgDownloads = $this->isNew() ? '0' : $this->getVar('img_downloads'); + + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_DOWNLOADS'), 'img_downloads', 20, 150, $imgDownloads)); + + // Form Text ImgRatinglikes + + $imgRatinglikes = $this->isNew() ? '0' : $this->getVar('img_ratinglikes'); + + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_RATINGLIKES'), 'img_ratinglikes', 20, 150, $imgRatinglikes)); + + // Form Text ImgVotes + + $imgVotes = $this->isNew() ? '0' : $this->getVar('img_votes'); + + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_VOTES'), 'img_votes', 20, 150, $imgVotes)); + + // Form Text ImgWeight + + $imgWeight = $this->isNew() ? '0' : $this->getVar('img_weight'); + + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WEIGHT'), 'img_weight', 20, 150, $imgWeight)); + + // Form Table albums + + $albumsHandler = $helper->getHandler('Albums'); + + $imgAlbidSelect = new \XoopsFormSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_ALBID'), 'img_albid', $this->getVar('img_albid')); + + $imgAlbidSelect->addOptionArray($albumsHandler->getList()); + + $form->addElement($imgAlbidSelect, true); + + // Images handler + + $imagesHandler = $helper->getHandler('Images'); + + // Form Select Images + + $imgStateSelect = new \XoopsFormSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_STATE'), 'img_state', $this->getVar('img_state')); + + $imgStateSelect->addOption('Empty'); + + $imgStateSelect->addOptionArray($imagesHandler->getList()); + + $form->addElement($imgStateSelect, true); + + // Form Text Date Select ImgDate + + $imgDate = $this->isNew() ? 0 : $this->getVar('img_date'); + + $form->addElement(new \XoopsFormTextDateSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'DATE'), 'img_date', '', $imgDate)); + + // Form Select User ImgSubmitter + + $form->addElement(new \XoopsFormSelectUser(\constant('CO_' . $moduleDirNameUpper . '_' . 'SUBMITTER'), 'img_submitter', false, $this->getVar('img_submitter'))); + + // Form Text ImgIp + + $form->addElement(new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_IP'), 'img_ip', 50, 255, $this->getVar('img_ip'))); + + // To Save + + $form->addElement(new \XoopsFormHidden('op', 'save')); + + $form->addElement(new \XoopsFormButtonTray('', \_SUBMIT, 'submit', '', false)); + + return $form; + } + + /** + * Get Values + * @param null $keys + * @param null $format + * @param null $maxDepth + * @return array + */ + public function getValuesImages($keys = null, $format = null, $maxDepth = null) + { + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); + + $helper = Tdmdownloads\Helper::getInstance(); + + $ret = $this->getValues($keys, $format, $maxDepth); + + $ret['id'] = $this->getVar('img_id'); + + $ret['title'] = $this->getVar('img_title'); + + $ret['desc'] = $this->getVar('img_desc', 'n'); + + $ret['name'] = $this->getVar('img_name'); + + $ret['namelarge'] = $this->getVar('img_namelarge'); + + $ret['nameorig'] = $this->getVar('img_nameorig'); + + $ret['mimetype'] = $this->getVar('img_mimetype'); + + $ret['size'] = $this->getVar('img_size'); + + $ret['resx'] = $this->getVar('img_resx'); + + $ret['resy'] = $this->getVar('img_resy'); + + $ret['downloads'] = $this->getVar('img_downloads'); + + $ret['ratinglikes'] = $this->getVar('img_ratinglikes'); + + $ret['votes'] = $this->getVar('img_votes'); + + $ret['weight'] = $this->getVar('img_weight'); + + $ret['albid'] = $this->getVar('img_albid'); + + //$albums = $helper->getHandler('Albums'); + + //$albumsObj = $albums->get($this->getVar('img_albid')); + + //if (isset($albumsObj) && is_object($albumsObj)) { + + //$ret['alb_name'] = $albumsObj->getVar('alb_name'); + + //} + + $ret['state'] = $this->getVar('img_state'); + + $ret['state_text'] = $helper->getStateText($this->getVar('img_state')); + + $ret['date'] = \formatTimestamp($this->getVar('img_date'), 's'); + + $ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('img_submitter')); + + $ret['ip'] = $this->getVar('img_ip'); + + $ret['large'] = \constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_URL') . '/large/' . $this->getVar('img_namelarge'); + + $ret['medium'] = \constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_URL') . '/medium/' . $this->getVar('img_name'); + + $ret['thumb'] = \constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_URL') . '/thumbs/' . $this->getVar('img_name'); + + return $ret; + } + + /** + * Returns an array representation of the object + * + * @return array + */ + public function toArrayImages() + { + $ret = []; + + $vars = $this->getVars(); + + foreach (\array_keys($vars) as $var) { + $ret[$var] = $this->getVar('"{$var}"'); + } + + return $ret; + } +} diff --git a/class/Common/ImagesHandler.php b/class/Common/ImagesHandler.php new file mode 100644 index 0000000..bef5812 --- /dev/null +++ b/class/Common/ImagesHandler.php @@ -0,0 +1,148 @@ + - Website: + */ + +/** + * Class Object Handler Images + */ +class ImagesHandler extends \XoopsPersistableObjectHandler +{ + /** + * Constructor + * @param \XoopsDatabase|null $db + */ + public function __construct(?\XoopsDatabase $db = null) + { + parent::__construct($db, 'tdmdownloads_images', Images::class, 'img_id', 'img_name'); + } + + /** + * retrieve a field + * + * @param int $i field id + * @param null|mixed $fields + * @return mixed reference to the {@link Get} object + */ + public function get($i = null, $fields = null) + { + return parent::get($i, $fields); + } + + /** + * get inserted id + * + * @param null + * @return int reference to the {@link Get} object + */ + public function getInsertId() + { + return $this->db->getInsertId(); + } + + /** + * Get Count Images in the database + * @param int $albId + * @param int $start + * @param int $limit + * @param string $sort + * @param string $order + * @return int + */ + public function getCountImages($albId = 0, $start = 0, $limit = 0, $sort = 'img_id ASC, img_name', $order = 'ASC') + { + $crCountImages = new \CriteriaCompo(); + + $crCountImages = $this->getImagesCriteria($crCountImages, $albId, $start, $limit, $sort, $order); + + return parent::getCount($crCountImages); + } + + /** + * Get All Images in the database + * @param int $start + * @param int $limit + * @param string $sort + * @param string $order + * @return array + */ + public function getAllImages($start = 0, $limit = 0, $sort = 'img_id ASC, img_name', $order = 'ASC') + { + $crAllImages = new \CriteriaCompo(); + + $crAllImages = $this->getImagesCriteria($crAllImages, 0, $start, $limit, $sort, $order); + + return parent::getAll($crAllImages); + } + + /** + * Get Criteria Images + * @param $crImages + * @param $albId + * @param int $start + * @param int $limit + * @param string $sort + * @param string $order + * @return int + */ + private function getImagesCriteria($crImages, $albId, $start, $limit, $sort, $order) + { + if ($albId > 0) { + $crImages->add(new \Criteria('img_albid', $albId)); + } + + $crImages->setStart($start); + + $crImages->setLimit($limit); + + $crImages->setSort($sort); + + $crImages->setOrder($order); + + return $crImages; + } + + /** + * delete all copies of a specific image + * @param $imageName + * @return bool + */ + public function unlinkImages($imageName) + { + \unlink(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/large/' . $imageName); + + if (\file_exists(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/large/' . $imageName)) { + return false; + } + + \unlink(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/medium/' . $imageName); + + if (\file_exists(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/medium/' . $imageName)) { + return false; + } + + \unlink(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/thumbs/' . $imageName); + + if (\file_exists(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/thumbs/' . $imageName)) { + return false; + } + + return true; + } +} diff --git a/class/Downloads.php b/class/Downloads.php index 90fc698..2d16d16 100644 --- a/class/Downloads.php +++ b/class/Downloads.php @@ -122,7 +122,6 @@ public function getForm($donnee = [], $erreur = false, $action = false) //permission pour uploader /** @var \XoopsGroupPermHandler $grouppermHandler */ - $grouppermHandler = \xoops_getHandler('groupperm'); $groups = \is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; diff --git a/class/Modified.php b/class/Modified.php index 851bbfa..9321e72 100644 --- a/class/Modified.php +++ b/class/Modified.php @@ -99,7 +99,6 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) $groups = \is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; /** @var \XoopsGroupPermHandler $grouppermHandler */ - $grouppermHandler = \xoops_getHandler('groupperm'); $perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')); diff --git a/class/Tree.php b/class/Tree.php index 447102d..cb7d6ad 100644 --- a/class/Tree.php +++ b/class/Tree.php @@ -79,7 +79,7 @@ public function makeArrayTree($fieldName, $prefix = '-', $key = 0) } } /* xoops 2.5.8 -class Tree extends XoopsObjectTree { +class Tree extends \XoopsObjectTree { protected function makeArrayTreeOptions($fieldName, $key, &$ret, $prefix_orig, $prefix_curr = '') { diff --git a/class/Utility.php b/class/Utility.php index 32b89c2..15cac0e 100644 --- a/class/Utility.php +++ b/class/Utility.php @@ -45,7 +45,6 @@ public function getItemIds($permtype, $dirname) $groups = \is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; /** @var \XoopsGroupPermHandler $grouppermHandler */ - $grouppermHandler = \xoops_getHandler('groupperm'); return $grouppermHandler->getItemIds($permtype, $groups, $tdmModule->getVar('mid')); diff --git a/docs/changelog.txt b/docs/changelog.txt index 9e5b081..7b8a8ef 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -1,4 +1,4 @@ -
      2.0 RC 2 [WORK IN PROGRESS - NOT RELEASED]
      Dev: XOOPS 2.5.11, PHP 7.4.6 +
      2.01 Alpha 1 [2020-05-018]
      Dev: XOOPS 2.5.11, PHP 7.4.6
      - added hits and ratings and for output of download in index.php (goffy) - added number of subcategories for output of category in index.php (goffy) diff --git a/header.php b/header.php index 9334510..8341235 100644 --- a/header.php +++ b/header.php @@ -50,7 +50,7 @@ if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) { require $GLOBALS['xoops']->path('class/template.php'); - $xoopsTpl = new XoopsTpl(); + $xoopsTpl = new \XoopsTpl(); } $perm_submit = $grouppermHandler->checkRight('tdmdownloads_ac', 4, $groups, $xoopsModule->getVar('mid')); diff --git a/submit.php b/submit.php index 096d7fd..065ff58 100644 --- a/submit.php +++ b/submit.php @@ -316,7 +316,6 @@ if (1 == $helper->getConfig('permission_download')) { /** @var \XoopsGroupPermHandler $grouppermHandler */ - $grouppermHandler = xoops_getHandler('groupperm'); $criteria = new \CriteriaCompo(); diff --git a/xoops_version.php b/xoops_version.php index 6581326..546ae7e 100644 --- a/xoops_version.php +++ b/xoops_version.php @@ -26,11 +26,11 @@ $modversion = [ 'name' => _MI_TDMDOWNLOADS_NAME, - 'version' => '2.0', - 'module_status' => 'RC 2', - 'release_date' => '2020/05/17', + 'version' => '2.01', + 'module_status' => 'Alpha 1', + 'release_date' => '2020/05/18', 'description' => _MI_TDMDOWNLOADS_DESC, - 'credits' => 'Mage, Mamba, Goffy', + 'credits' => 'Mage, Mamba, Goffy, Heyula', 'author' => 'Mage', 'nickname' => 'Mage', 'module_website_url' => 'www.xoops.org', From f29618992d3f5c05e4bc18e8aae8f53ec7b1b15a Mon Sep 17 00:00:00 2001 From: mambax7 Date: Tue, 19 May 2020 10:03:36 -0400 Subject: [PATCH 44/62] fix install bugs --- admin/menu.php | 25 ++++++++++++++++--------- include/oninstall.php | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/admin/menu.php b/admin/menu.php index 5e1ed99..dc99d4e 100644 --- a/admin/menu.php +++ b/admin/menu.php @@ -26,54 +26,61 @@ $pathIcon32 = \Xmf\Module\Admin::menuIconPath(''); if (is_object($helper->getModule())) { - $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); +// $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); + $pathModIcon32 = $helper->url($helper->getModule()->getInfo('modicons32')); } $adminmenu[] = [ 'title' => _MI_TDMDOWNLOADS_ADMENU1, 'link' => 'admin/index.php', - 'icon' => "{$pathModIcon32}/home.png", +// 'icon' => "{$pathModIcon32}/home.png", + 'icon' => 'assets/images/admin/home.png', ]; $adminmenu[] = [ 'title' => _MI_TDMDOWNLOADS_ADMENU2, 'link' => 'admin/category.php', - 'icon' => "{$pathModIcon32}/category.png", - //'menu' => "{$pathIcon32}/menu_category.png", +// 'icon' => "{$pathModIcon32}/category.png", + 'icon' => 'assets/images/admin/category.png', ]; $adminmenu[] = [ 'title' => _MI_TDMDOWNLOADS_ADMENU3, 'link' => 'admin/downloads.php', - 'icon' => "{$pathModIcon32}/downloads.png", +// 'icon' => "{$pathModIcon32}/downloads.png", + 'icon' => 'assets/images/admin/downloads.png', //'menu' => "{$pathIcon32}/menu_downloads.png", ]; $adminmenu[] = [ 'title' => _MI_TDMDOWNLOADS_ADMENU4, 'link' => 'admin/broken.php', - 'icon' => "{$pathModIcon32}/broken.png", +// 'icon' => "{$pathModIcon32}/broken.png", + 'icon' => 'assets/images/admin/broken.png', //'menu' => "{$pathIcon32}/menu_broken.png", ]; $adminmenu[] = [ 'title' => _MI_TDMDOWNLOADS_ADMENU5, 'link' => 'admin/modified.php', - 'icon' => "{$pathModIcon32}/modified.png", +// 'icon' => "{$pathModIcon32}/modified.png", + 'icon' => 'assets/images/admin/modified.png', //'menu' => "{$pathIcon32}/menu_modified.png", ]; $adminmenu[] = [ 'title' => _MI_TDMDOWNLOADS_ADMENU6, 'link' => 'admin/field.php', - 'icon' => "{$pathModIcon32}/field.png", +// 'icon' => "{$pathModIcon32}/field.png", + 'icon' => 'assets/images/admin/field.png', //'menu' => "{$pathIcon32}/menu_field.png", ]; $adminmenu[] = [ 'title' => _MI_TDMDOWNLOADS_ADMENU7, 'link' => 'admin/import.php', - 'icon' => "{$pathModIcon32}/import.png", +// 'icon' => "{$pathModIcon32}/import.png", + 'icon' => 'assets/images/admin/import.png', //'menu' => "{$pathIcon32}/menu_import.png", ]; diff --git a/include/oninstall.php b/include/oninstall.php index 3c44d41..990ac16 100644 --- a/include/oninstall.php +++ b/include/oninstall.php @@ -25,7 +25,7 @@ function xoops_module_pre_install_tdmdownloads(\XoopsModule $module) { require_once dirname(dirname(dirname(__DIR__))) . '/mainfile.php'; - require_once __DIR__ . '/common.php'; +// require_once __DIR__ . '/common.php'; /** @var \XoopsModules\Tdmdownloads\Utility $utility */ From 22ec8a7f5149ca19f6daf9b0ae87177da7afc019 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 8 Aug 2021 17:04:04 -0400 Subject: [PATCH 45/62] replace index.html with index.php --- admin/index.html | 1 - assets/css/index.html | 1 - assets/css/index.php | 2 ++ assets/images/admin/index.html | 1 - assets/images/admin/index.php | 2 ++ assets/images/bookmarks/index.html | 1 - assets/images/bookmarks/index.php | 2 ++ assets/images/deco/index.html | 1 - assets/images/deco/index.php | 2 ++ assets/images/icon/index.php | 3 +++ assets/images/icons/16/index.html | 1 - assets/images/icons/16/index.php | 2 ++ assets/images/icons/32/index.html | 1 - assets/images/icons/32/index.php | 2 ++ assets/images/icons/index.html | 1 - assets/images/icons/index.php | 2 ++ assets/images/index.html | 1 - assets/images/index.php | 2 ++ assets/index.html | 1 - assets/index.php | 3 +++ assets/js/index.html | 1 - assets/js/index.php | 3 +++ blocks/index.html | 1 - blocks/index.php | 2 ++ class/Common/index.html | 1 - class/Common/index.php | 3 +++ class/Form/index.html | 1 - class/Form/index.php | 3 +++ class/index.html | 1 - class/index.php | 2 ++ config/index.html | 1 - config/index.php | 2 ++ docs/index.html | 1 - docs/index.php | 2 ++ extra/index.html | 1 - extra/index.php | 2 ++ extra/plugins/index.html | 1 - extra/plugins/index.php | 2 ++ extra/plugins/sitemap/index.html | 1 - extra/plugins/sitemap/index.php | 2 ++ extra/plugins/tag/index.html | 1 - extra/plugins/tag/index.php | 3 +++ extra/plugins/waiting/index.html | 1 - extra/plugins/waiting/index.php | 3 +++ extra/plugins/whatsnew/index.html | 1 - extra/plugins/whatsnew/index.php | 2 ++ extra/plugins/whatsnew/tdmdownloads/index.html | 1 - extra/plugins/whatsnew/tdmdownloads/index.php | 2 ++ extra/uploads/index.html | 1 - extra/uploads/index.php | 3 +++ extra/uploads/tdmdownloads/downloads/index.html | 1 - extra/uploads/tdmdownloads/downloads/index.php | 2 ++ extra/uploads/tdmdownloads/images/cats/index.html | 1 - extra/uploads/tdmdownloads/images/cats/index.php | 2 ++ extra/uploads/tdmdownloads/images/field/index.html | 1 - extra/uploads/tdmdownloads/images/field/index.php | 2 ++ extra/uploads/tdmdownloads/images/index.html | 1 - extra/uploads/tdmdownloads/images/index.php | 2 ++ extra/uploads/tdmdownloads/images/shots/index.html | 1 - extra/uploads/tdmdownloads/images/shots/index.php | 2 ++ extra/uploads/tdmdownloads/index.html | 1 - extra/uploads/tdmdownloads/index.php | 2 ++ include/index.html | 1 - include/index.php | 2 ++ language/english/help/index.html | 1 - language/english/help/index.php | 2 ++ language/english/index.html | 1 - language/english/index.php | 2 ++ language/english/mail_template/index.html | 1 - language/english/mail_template/index.php | 2 ++ language/french/help/index.html | 1 - language/french/help/index.php | 2 ++ language/french/index.html | 1 - language/french/index.php | 2 ++ language/french/mail_template/index.html | 1 - language/french/mail_template/index.php | 2 ++ language/german/help/index.html | 1 - language/german/help/index.php | 2 ++ language/german/index.html | 1 - language/german/index.php | 2 ++ language/german/mail_template/index.html | 1 - language/german/mail_template/index.php | 2 ++ language/index.html | 1 - language/index.php | 2 ++ preloads/index.html | 1 - preloads/index.php | 3 +++ sql/index.html | 1 - sql/index.php | 2 ++ templates/admin/index.html | 1 - templates/admin/index.php | 2 ++ templates/blocks/index.html | 1 - templates/blocks/index.php | 2 ++ templates/index.html | 1 - templates/index.php | 2 ++ testdata/english/index.html | 1 - testdata/images/index.html | 1 - testdata/images/index.php | 3 +++ testdata/index.html | 1 - testdata/uploads/index.html | 1 - testdata/uploads/index.php | 3 +++ tests/index.html | 1 - tests/index.php | 3 +++ 102 files changed, 112 insertions(+), 52 deletions(-) delete mode 100644 admin/index.html delete mode 100644 assets/css/index.html create mode 100644 assets/css/index.php delete mode 100644 assets/images/admin/index.html create mode 100644 assets/images/admin/index.php delete mode 100644 assets/images/bookmarks/index.html create mode 100644 assets/images/bookmarks/index.php delete mode 100644 assets/images/deco/index.html create mode 100644 assets/images/deco/index.php create mode 100644 assets/images/icon/index.php delete mode 100644 assets/images/icons/16/index.html create mode 100644 assets/images/icons/16/index.php delete mode 100644 assets/images/icons/32/index.html create mode 100644 assets/images/icons/32/index.php delete mode 100644 assets/images/icons/index.html create mode 100644 assets/images/icons/index.php delete mode 100644 assets/images/index.html create mode 100644 assets/images/index.php delete mode 100644 assets/index.html create mode 100644 assets/index.php delete mode 100644 assets/js/index.html create mode 100644 assets/js/index.php delete mode 100644 blocks/index.html create mode 100644 blocks/index.php delete mode 100644 class/Common/index.html create mode 100644 class/Common/index.php delete mode 100644 class/Form/index.html create mode 100644 class/Form/index.php delete mode 100644 class/index.html create mode 100644 class/index.php delete mode 100644 config/index.html create mode 100644 config/index.php delete mode 100644 docs/index.html create mode 100644 docs/index.php delete mode 100644 extra/index.html create mode 100644 extra/index.php delete mode 100644 extra/plugins/index.html create mode 100644 extra/plugins/index.php delete mode 100644 extra/plugins/sitemap/index.html create mode 100644 extra/plugins/sitemap/index.php delete mode 100644 extra/plugins/tag/index.html create mode 100644 extra/plugins/tag/index.php delete mode 100644 extra/plugins/waiting/index.html create mode 100644 extra/plugins/waiting/index.php delete mode 100644 extra/plugins/whatsnew/index.html create mode 100644 extra/plugins/whatsnew/index.php delete mode 100644 extra/plugins/whatsnew/tdmdownloads/index.html create mode 100644 extra/plugins/whatsnew/tdmdownloads/index.php delete mode 100644 extra/uploads/index.html create mode 100644 extra/uploads/index.php delete mode 100644 extra/uploads/tdmdownloads/downloads/index.html create mode 100644 extra/uploads/tdmdownloads/downloads/index.php delete mode 100644 extra/uploads/tdmdownloads/images/cats/index.html create mode 100644 extra/uploads/tdmdownloads/images/cats/index.php delete mode 100644 extra/uploads/tdmdownloads/images/field/index.html create mode 100644 extra/uploads/tdmdownloads/images/field/index.php delete mode 100644 extra/uploads/tdmdownloads/images/index.html create mode 100644 extra/uploads/tdmdownloads/images/index.php delete mode 100644 extra/uploads/tdmdownloads/images/shots/index.html create mode 100644 extra/uploads/tdmdownloads/images/shots/index.php delete mode 100644 extra/uploads/tdmdownloads/index.html create mode 100644 extra/uploads/tdmdownloads/index.php delete mode 100644 include/index.html create mode 100644 include/index.php delete mode 100644 language/english/help/index.html create mode 100644 language/english/help/index.php delete mode 100644 language/english/index.html create mode 100644 language/english/index.php delete mode 100644 language/english/mail_template/index.html create mode 100644 language/english/mail_template/index.php delete mode 100644 language/french/help/index.html create mode 100644 language/french/help/index.php delete mode 100644 language/french/index.html create mode 100644 language/french/index.php delete mode 100644 language/french/mail_template/index.html create mode 100644 language/french/mail_template/index.php delete mode 100644 language/german/help/index.html create mode 100644 language/german/help/index.php delete mode 100644 language/german/index.html create mode 100644 language/german/index.php delete mode 100644 language/german/mail_template/index.html create mode 100644 language/german/mail_template/index.php delete mode 100644 language/index.html create mode 100644 language/index.php delete mode 100644 preloads/index.html create mode 100644 preloads/index.php delete mode 100644 sql/index.html create mode 100644 sql/index.php delete mode 100644 templates/admin/index.html create mode 100644 templates/admin/index.php delete mode 100644 templates/blocks/index.html create mode 100644 templates/blocks/index.php delete mode 100644 templates/index.html create mode 100644 templates/index.php delete mode 100644 testdata/english/index.html delete mode 100644 testdata/images/index.html create mode 100644 testdata/images/index.php delete mode 100644 testdata/index.html delete mode 100644 testdata/uploads/index.html create mode 100644 testdata/uploads/index.php delete mode 100644 tests/index.html create mode 100644 tests/index.php diff --git a/admin/index.html b/admin/index.html deleted file mode 100644 index 990cbd6..0000000 --- a/admin/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/css/index.html b/assets/css/index.html deleted file mode 100644 index 990cbd6..0000000 --- a/assets/css/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/css/index.php b/assets/css/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/assets/css/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/assets/images/admin/index.php b/assets/images/admin/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/assets/images/admin/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/assets/images/bookmarks/index.php b/assets/images/bookmarks/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/assets/images/bookmarks/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/assets/images/deco/index.php b/assets/images/deco/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/assets/images/deco/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/assets/images/icons/16/index.php b/assets/images/icons/16/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/assets/images/icons/16/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/assets/images/icons/32/index.php b/assets/images/icons/32/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/assets/images/icons/32/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/assets/images/icons/index.php b/assets/images/icons/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/assets/images/icons/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/assets/images/index.php b/assets/images/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/assets/images/index.php @@ -0,0 +1,2 @@ +history.go(-1); diff --git a/assets/index.php b/assets/index.php new file mode 100644 index 0000000..2ea9b7d --- /dev/null +++ b/assets/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/assets/js/index.php b/assets/js/index.php new file mode 100644 index 0000000..2ea9b7d --- /dev/null +++ b/assets/js/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/blocks/index.php b/blocks/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/blocks/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/class/Common/index.php b/class/Common/index.php new file mode 100644 index 0000000..2ea9b7d --- /dev/null +++ b/class/Common/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/class/Form/index.php b/class/Form/index.php new file mode 100644 index 0000000..2ea9b7d --- /dev/null +++ b/class/Form/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/class/index.php b/class/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/class/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/config/index.php b/config/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/config/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/docs/index.php b/docs/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/docs/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/extra/index.php b/extra/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/extra/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/extra/plugins/index.php b/extra/plugins/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/extra/plugins/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/extra/plugins/sitemap/index.php b/extra/plugins/sitemap/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/extra/plugins/sitemap/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/extra/plugins/tag/index.php b/extra/plugins/tag/index.php new file mode 100644 index 0000000..2ea9b7d --- /dev/null +++ b/extra/plugins/tag/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/extra/plugins/waiting/index.php b/extra/plugins/waiting/index.php new file mode 100644 index 0000000..2ea9b7d --- /dev/null +++ b/extra/plugins/waiting/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/extra/plugins/whatsnew/index.php b/extra/plugins/whatsnew/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/extra/plugins/whatsnew/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/extra/plugins/whatsnew/tdmdownloads/index.php b/extra/plugins/whatsnew/tdmdownloads/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/extra/plugins/whatsnew/tdmdownloads/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/extra/uploads/index.php b/extra/uploads/index.php new file mode 100644 index 0000000..2ea9b7d --- /dev/null +++ b/extra/uploads/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/extra/uploads/tdmdownloads/downloads/index.php b/extra/uploads/tdmdownloads/downloads/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/extra/uploads/tdmdownloads/downloads/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/extra/uploads/tdmdownloads/images/cats/index.php b/extra/uploads/tdmdownloads/images/cats/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/extra/uploads/tdmdownloads/images/cats/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/extra/uploads/tdmdownloads/images/field/index.php b/extra/uploads/tdmdownloads/images/field/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/extra/uploads/tdmdownloads/images/field/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/extra/uploads/tdmdownloads/images/index.php b/extra/uploads/tdmdownloads/images/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/extra/uploads/tdmdownloads/images/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/extra/uploads/tdmdownloads/images/shots/index.php b/extra/uploads/tdmdownloads/images/shots/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/extra/uploads/tdmdownloads/images/shots/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/extra/uploads/tdmdownloads/index.php b/extra/uploads/tdmdownloads/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/extra/uploads/tdmdownloads/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/include/index.php b/include/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/include/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/language/english/help/index.php b/language/english/help/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/language/english/help/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/language/english/index.php b/language/english/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/language/english/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/language/english/mail_template/index.php b/language/english/mail_template/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/language/english/mail_template/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/language/french/help/index.php b/language/french/help/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/language/french/help/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/language/french/index.php b/language/french/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/language/french/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/language/french/mail_template/index.php b/language/french/mail_template/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/language/french/mail_template/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/language/german/help/index.php b/language/german/help/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/language/german/help/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/language/german/index.php b/language/german/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/language/german/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/language/german/mail_template/index.php b/language/german/mail_template/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/language/german/mail_template/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/language/index.php b/language/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/language/index.php @@ -0,0 +1,2 @@ +history.go(-1); diff --git a/preloads/index.php b/preloads/index.php new file mode 100644 index 0000000..2ea9b7d --- /dev/null +++ b/preloads/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/sql/index.php b/sql/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/sql/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/templates/admin/index.php b/templates/admin/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/templates/admin/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/templates/blocks/index.php b/templates/blocks/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/templates/blocks/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/templates/index.php b/templates/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/templates/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/testdata/images/index.html b/testdata/images/index.html deleted file mode 100644 index 2c5cdd3..0000000 --- a/testdata/images/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/testdata/images/index.php b/testdata/images/index.php new file mode 100644 index 0000000..2ea9b7d --- /dev/null +++ b/testdata/images/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/testdata/uploads/index.html b/testdata/uploads/index.html deleted file mode 100644 index 74b6f45..0000000 --- a/testdata/uploads/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/testdata/uploads/index.php b/testdata/uploads/index.php new file mode 100644 index 0000000..2ea9b7d --- /dev/null +++ b/testdata/uploads/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/tests/index.php b/tests/index.php new file mode 100644 index 0000000..2ea9b7d --- /dev/null +++ b/tests/index.php @@ -0,0 +1,3 @@ + Date: Sun, 8 Aug 2021 20:39:01 -0400 Subject: [PATCH 46/62] Smarty defaults --- templates/admin/tdmdownloads_admin_broken.tpl | 6 +++--- templates/admin/tdmdownloads_admin_category.tpl | 8 ++++---- templates/admin/tdmdownloads_admin_downloads.tpl | 8 ++++---- templates/admin/tdmdownloads_admin_field.tpl | 6 +++--- templates/admin/tdmdownloads_admin_footer.tpl | 2 +- templates/admin/tdmdownloads_admin_header.tpl | 4 ++-- templates/admin/tdmdownloads_admin_import.tpl | 8 ++++---- templates/admin/tdmdownloads_admin_index.tpl | 2 +- templates/admin/tdmdownloads_admin_modified.tpl | 10 +++++----- templates/admin/tdmdownloads_admin_permissions.tpl | 2 +- templates/tdmdownloads_brokenfile.tpl | 2 +- templates/tdmdownloads_modfile.tpl | 2 +- templates/tdmdownloads_ratefile.tpl | 2 +- templates/tdmdownloads_submit.tpl | 2 +- 14 files changed, 32 insertions(+), 32 deletions(-) diff --git a/templates/admin/tdmdownloads_admin_broken.tpl b/templates/admin/tdmdownloads_admin_broken.tpl index f886c2d..c156039 100644 --- a/templates/admin/tdmdownloads_admin_broken.tpl +++ b/templates/admin/tdmdownloads_admin_broken.tpl @@ -1,6 +1,6 @@ <{include file='db:tdmdownloads_admin_header.tpl'}> -<{if $message_erreur}> +<{if $message_erreur|default:''}>
      <{$message_erreur}>
      <{/if}> <{if $broken_list}> @@ -31,13 +31,13 @@ <{/if}>
      " . constant('CO_' . $moduleDirNameUpper . '_' . 'TITLE') @@ -106,10 +136,13 @@ function listBlocks() . '
      '; echo " " . _EDIT . " " . _CLONE . " "; + if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) { echo " getVar('bid') . "'>" . _DELETE . " "; } + echo " @@ -271,8 +324,10 @@ function listBlocks()
      " . $GLOBALS['xoopsSecurity']->getTokenHTML() . " @@ -285,30 +340,46 @@ function listBlocks() /** * @param int $bid */ + function cloneBlock($bid) { require_once __DIR__ . '/admin_header.php'; + //require_once __DIR__ . '/admin_header.php'; + xoops_cp_header(); - $moduleDirName = basename(dirname(__DIR__)); + $moduleDirName = basename(dirname(__DIR__)); + $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName + xoops_loadLanguage('admin', 'system'); + xoops_loadLanguage('admin/blocksadmin', 'system'); + xoops_loadLanguage('admin/groups', 'system'); // mpu_adm_menu(); + $myblock = new \XoopsBlock($bid); + /** @var \XoopsMySQLDatabase $db */ - $db = \XoopsDatabaseFactory::getDatabaseConnection(); - $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid; - $result = $db->query($sql); + + $db = \XoopsDatabaseFactory::getDatabaseConnection(); + + $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid; + + $result = $db->query($sql); + $modules = []; + while (false !== ($row = $db->fetchArray($result))) { $modules[] = (int)$row['module_id']; } + $is_custom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type')); - $block = [ + + $block = [ 'title' => $myblock->getVar('title') . ' Clone', 'form_title' => constant('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK'), 'name' => $myblock->getVar('name'), @@ -326,87 +397,136 @@ function cloneBlock($bid) 'template' => $myblock->getVar('template'), 'options' => $myblock->getVar('options'), ]; + echo '' . _AM_BADMIN . ' »» ' . _AM_SYSTEM_BLOCKS_CLONEBLOCK . '

      '; + require_once __DIR__ . '/blockform.php'; + /** @var \XoopsThemeForm $form */ + $form->display(); + // xoops_cp_footer(); + require_once __DIR__ . '/admin_footer.php'; + exit(); } /** * @param int $bid - * @param $bside - * @param $bweight - * @param $bvisible - * @param $bcachetime - * @param $bmodule - * @param $options + * @param $bside + * @param $bweight + * @param $bvisible + * @param $bcachetime + * @param $bmodule + * @param $options */ + function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options) { xoops_loadLanguage('admin', 'system'); + xoops_loadLanguage('admin/blocksadmin', 'system'); + xoops_loadLanguage('admin/groups', 'system'); /** @var \XoopsBlock $block */ + $block = new \XoopsBlock($bid); + $clone = $block->xoopsClone(); + if (empty($bmodule)) { xoops_cp_header(); + xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN)); + xoops_cp_footer(); + exit(); } + $clone->setVar('side', $bside); + $clone->setVar('weight', $bweight); + $clone->setVar('visible', $bvisible); + //$clone->setVar('content', $_POST['bcontent']); + $clone->setVar('title', Request::getString('btitle', '', 'POST')); + $clone->setVar('bcachetime', $bcachetime); + if (isset($options) && (count($options) > 0)) { $options = implode('|', $options); + $clone->setVar('options', $options); } + $clone->setVar('bid', 0); + if ('C' === $block->getVar('block_type') || 'E' === $block->getVar('block_type')) { $clone->setVar('block_type', 'E'); } else { $clone->setVar('block_type', 'D'); } + $newid = $clone->store(); + if (!$newid) { xoops_cp_header(); + $clone->getHtmlErrors(); + xoops_cp_footer(); + exit(); } + if ('' !== $clone->getVar('template')) { /** @var \XoopsTplfileHandler $tplfileHandler */ + $tplfileHandler = xoops_getHandler('tplfile'); + /** @var \XoopsTplfile[] $btemplate */ + $btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid); + if (count($btemplate) > 0) { /** @var \XoopsObject $tplclone */ + $tplclone = $btemplate[0]->xoopsClone(); + $tplclone->setVar('tpl_id', 0); + $tplclone->setVar('tpl_refid', $newid); + $tplfileHandler->insert($tplclone); } } + /** @var \XoopsMySQLDatabase $db */ + $db = \XoopsDatabaseFactory::getDatabaseConnection(); + foreach ($bmodule as $bmid) { $sql = 'INSERT INTO ' . $db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')'; + $db->query($sql); } + $groups = &$GLOBALS['xoopsUser']->getGroups(); - $count = count($groups); + + $count = count($groups); + for ($i = 0; $i < $count; ++$i) { $sql = 'INSERT INTO ' . $db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $groups[$i] . ', ' . $newid . ", 1, 'block_read')"; + $db->query($sql); } + redirect_header('blocksadmin.php?op=listar', 1, _AM_DBUPDATED); } @@ -418,43 +538,67 @@ function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, * @param string $side * @param int $bcachetime */ + function setOrder($bid, $title, $weight, $visible, $side, $bcachetime) { $myblock = new \XoopsBlock($bid); + $myblock->setVar('title', $title); + $myblock->setVar('weight', $weight); + $myblock->setVar('visible', $visible); + $myblock->setVar('side', $side); + $myblock->setVar('bcachetime', $bcachetime); + $myblock->store(); } /** * @param int $bid */ + function editBlock($bid) { require_once __DIR__ . '/admin_header.php'; + //require_once __DIR__ . '/admin_header.php'; + xoops_cp_header(); - $moduleDirName = basename(dirname(__DIR__)); + $moduleDirName = basename(dirname(__DIR__)); + $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName + xoops_loadLanguage('admin', 'system'); + xoops_loadLanguage('admin/blocksadmin', 'system'); + xoops_loadLanguage('admin/groups', 'system'); + // mpu_adm_menu(); + $myblock = new \XoopsBlock($bid); + /** @var \XoopsMySQLDatabase $db */ - $db = \XoopsDatabaseFactory::getDatabaseConnection(); - $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid; - $result = $db->query($sql); + + $db = \XoopsDatabaseFactory::getDatabaseConnection(); + + $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid; + + $result = $db->query($sql); + $modules = []; + while (false !== ($row = $db->fetchArray($result))) { $modules[] = (int)$row['module_id']; } + $is_custom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type')); - $block = [ + + $block = [ 'title' => $myblock->getVar('title'), 'form_title' => constant('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_EDITBLOCK'), // 'name' => $myblock->getVar('name'), @@ -472,12 +616,19 @@ function editBlock($bid) 'template' => $myblock->getVar('template'), 'options' => $myblock->getVar('options'), ]; + echo '' . _AM_BADMIN . ' »» ' . _AM_SYSTEM_BLOCKS_EDITBLOCK . '

      '; + require_once __DIR__ . '/blockform.php'; + /** @var \XoopsThemeForm $form */ + $form->display(); + // xoops_cp_footer(); + require_once __DIR__ . '/admin_footer.php'; + exit(); } @@ -492,48 +643,69 @@ function editBlock($bid) * @param null|array|string $options * @param null|array $groups */ + function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups) { - $moduleDirName = basename(dirname(__DIR__)); + $moduleDirName = basename(dirname(__DIR__)); + $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName $myblock = new \XoopsBlock($bid); + $myblock->setVar('title', $btitle); + $myblock->setVar('weight', $bweight); + $myblock->setVar('visible', $bvisible); + $myblock->setVar('side', $bside); + $myblock->setVar('bcachetime', $bcachetime); + $myblock->store(); if (!empty($bmodule) && count($bmodule) > 0) { $sql = sprintf('DELETE FROM `%s` WHERE block_id = %u', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid); + $GLOBALS['xoopsDB']->query($sql); + if (in_array(0, $bmodule)) { $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid, 0); + $GLOBALS['xoopsDB']->query($sql); } else { foreach ($bmodule as $bmid) { $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid, (int)$bmid); + $GLOBALS['xoopsDB']->query($sql); } } } + $sql = sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $GLOBALS['xoopsDB']->prefix('group_permission'), $bid); + $GLOBALS['xoopsDB']->query($sql); + if (!empty($groups)) { foreach ($groups as $grp) { $sql = sprintf("INSERT INTO `%s` (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", $GLOBALS['xoopsDB']->prefix('group_permission'), $grp, $bid); + $GLOBALS['xoopsDB']->query($sql); } } + redirect_header($_SERVER['SCRIPT_NAME'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS')); } if ('list' === $op) { xoops_cp_header(); + // mpu_adm_menu(); + listBlocks(); + require_once __DIR__ . '/admin_footer.php'; + exit(); } @@ -541,36 +713,48 @@ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $b if (!$GLOBALS['xoopsSecurity']->check()) { redirect_header($_SERVER['SCRIPT_NAME'], 3, implode('
      ', $GLOBALS['xoopsSecurity']->getErrors())); } + foreach (array_keys($bid) as $i) { if ($oldtitle[$i] !== $title[$i] || $oldweight[$i] !== $weight[$i] || $oldvisible[$i] !== $visible[$i] || $oldside[$i] !== $side[$i] || $oldbcachetime[$i] !== $bcachetime[$i]) { setOrder($bid[$i], $title[$i], $weight[$i], $visible[$i], $side[$i], $bcachetime[$i], $bmodule[$i]); } + if (!empty($bmodule[$i]) && count($bmodule[$i]) > 0) { $sql = sprintf('DELETE FROM `%s` WHERE block_id = %u', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid[$i]); + $GLOBALS['xoopsDB']->query($sql); + if (in_array(0, $bmodule[$i])) { $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid[$i], 0); + $GLOBALS['xoopsDB']->query($sql); } else { foreach ($bmodule[$i] as $bmid) { $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid[$i], (int)$bmid); + $GLOBALS['xoopsDB']->query($sql); } } } + $sql = sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $GLOBALS['xoopsDB']->prefix('group_permission'), $bid[$i]); + $GLOBALS['xoopsDB']->query($sql); + if (!empty($groups[$i])) { foreach ($groups[$i] as $grp) { $sql = sprintf("INSERT INTO `%s` (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", $GLOBALS['xoopsDB']->prefix('group_permission'), $grp, $bid[$i]); + $GLOBALS['xoopsDB']->query($sql); } } } + redirect_header($_SERVER['SCRIPT_NAME'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS')); } + if ('clone' === $op) { cloneBlock($bid); } diff --git a/admin/broken.php b/admin/broken.php index 8eb12c0..d1f5aa1 100644 --- a/admin/broken.php +++ b/admin/broken.php @@ -1,4 +1,4 @@ -setLimit(\Xmf\Request::getInt('limit', 0, 'REQUEST')); + $limit = \Xmf\Request::getInt('limit', 0, 'REQUEST'); } else { $criteria->setLimit($helper->getConfig('perpageadmin')); + $limit = $helper->getConfig('perpageadmin'); } if (\Xmf\Request::hasVar('start', 'REQUEST')) { $criteria->setStart(\Xmf\Request::getInt('start', 0, 'REQUEST')); + $start = \Xmf\Request::getInt('start', 0, 'REQUEST'); } else { $criteria->setStart(0); + $start = 0; } $criteria->setSort('reportid'); @@ -60,14 +64,18 @@ $pagenav = ''; if ($numrows > $limit) { $pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', 'op=list&limit=' . $limit); + $pagenav = $pagenav->renderNav(4); } //Affichage du tableau des téléchargements brisés if ($numrows > 0) { $GLOBALS['xoopsTpl']->assign('broken_count', $numrows); + $broken = []; + foreach (array_keys($brokenArray) as $i) { /** @var \XoopsModules\Tdmdownloads\Broken[] $brokenArray */ + $broken = [ 'lid' => $brokenArray[$i]->getVar('lid'), 'reportid' => $brokenArray[$i]->getVar('reportid'), @@ -76,7 +84,9 @@ 'sender' => \XoopsUser::getUnameFromId($brokenArray[$i]->getVar('sender')), 'ip' => $brokenArray[$i]->getVar('ip'), ]; + $GLOBALS['xoopsTpl']->append('broken_list', $broken); + unset($broken); } } else { @@ -90,17 +100,25 @@ if (!$GLOBALS['xoopsSecurity']->check()) { redirect_header('downloads.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); } + if ($brokenHandler->delete($obj)) { redirect_header('broken.php', 1, _AM_TDMDOWNLOADS_REDIRECT_DELOK); } + $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); } else { //Affichage de la partie haute de l'administration de Xoops + xoops_cp_header(); + $adminObject = \Xmf\Module\Admin::getInstance(); + $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('broken.php')); + $adminObject->addItemButton(_MI_TDMDOWNLOADS_ADMENU4, 'broken.php?op=list', 'list'); + $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); + xoops_confirm(['ok' => 1, 'broken_id' => \Xmf\Request::getInt('broken_id', 0, 'REQUEST'), 'op' => 'del_brokendownloads'], $_SERVER['REQUEST_URI'], _AM_TDMDOWNLOADS_BROKEN_SURDEL . '
      '); } break; @@ -108,9 +126,11 @@ // Local icons path if (is_object($helper->getModule())) { $pathModIcon16 = $helper->getModule()->getInfo('modicons16'); + $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16); + $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32); } //Affichage de la partie basse de l'administration de Xoops diff --git a/admin/category.php b/admin/category.php index 81658d4..6c30551 100644 --- a/admin/category.php +++ b/admin/category.php @@ -1,4 +1,4 @@ - 0) { if (count($downloads_cat) > 0) { $GLOBALS['xoopsTpl']->assign('categories_count', count($downloads_cat)); - $mytree = new \XoopsModules\Tdmdownloads\Tree($downloads_cat, 'cat_cid', 'cat_pid'); + + $mytree = new \XoopsModules\Tdmdownloads\Tree($downloads_cat, 'cat_cid', 'cat_pid'); + $category_ArrayTree = $mytree->makeArrayTree('cat_title', ''); - $category = []; + + $category = []; + foreach (array_keys($category_ArrayTree) as $i) { /** @var \XoopsModules\Tdmdownloads\Category[] $downloads_cat */ + $category = [ 'cid' => $i, 'title' => $downloads_cat[$i]->getVar('cat_title'), @@ -61,7 +66,9 @@ 'cat_description_main' => $downloads_cat[$i]->getVar('cat_description_main'), 'cat_weight' => $downloads_cat[$i]->getVar('cat_weight'), ]; + $GLOBALS['xoopsTpl']->append('categories_list', $category); + unset($category); } } @@ -110,171 +117,281 @@ if (!$GLOBALS['xoopsSecurity']->check()) { redirect_header('category.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); } + // supression des téléchargements de la catégorie + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('cid', $categoryId)); + $downloadsArray = $downloadsHandler->getAll($criteria); + foreach (array_keys($downloadsArray) as $i) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloadsArray */ + // supression des votes + $criteria_1 = new \CriteriaCompo(); + $criteria_1->add(new \Criteria('lid', $downloadsArray[$i]->getVar('lid'))); + $votedata = $ratingHandler->getAll($criteria_1); + foreach (array_keys($votedata) as $j) { /** @var \XoopsModules\Tdmdownloads\Rating[] $votedata */ + $objvotedata = $ratingHandler->get($votedata[$j]->getVar('ratingid')); + $ratingHandler->delete($objvotedata) || $objvotedata->getHtmlErrors(); } + // supression des rapports de fichier brisé + $criteria_2 = new \CriteriaCompo(); + $criteria_2->add(new \Criteria('lid', $downloadsArray[$i]->getVar('lid'))); + $downloads_broken = $brokenHandler->getAll($criteria_2); + foreach (array_keys($downloads_broken) as $j) { /** @var \XoopsModules\Tdmdownloads\Broken[] $downloads_broken */ + $objbroken = $brokenHandler->get($downloads_broken[$j]->getVar('reportid')); + $brokenHandler->delete($objbroken) || $objbroken->getHtmlErrors(); } + // supression des data des champs sup. + $criteria_3 = new \CriteriaCompo(); + $criteria_3->add(new \Criteria('lid', $downloadsArray[$i]->getVar('lid'))); + $downloads_fielddata = $fielddataHandler->getAll($criteria_3); + if ($fielddataHandler->getCount($criteria_3) > 0) { foreach (array_keys($downloads_fielddata) as $j) { /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloads_fielddata */ + $objfielddata = $fielddataHandler->get($downloads_fielddata[$j]->getVar('iddata')); + $fielddataHandler->delete($objfielddata) || $objvfielddata->getHtmlErrors(); } } + // supression des commentaires + if ($downloadsArray[$i]->getVar('comments') > 0) { xoops_comment_delete($xoopsModule->getVar('mid'), $downloadsArray[$i]->getVar('lid')); } + //supression des tags - if ((1 == $helper->getConfig('usetag')) && class_exists(LinkHandler::class)) { + + if (1 == $helper->getConfig('usetag') && class_exists(LinkHandler::class)) { /** @var \XoopsModules\Tag\LinkHandler $linkHandler */ + $linkHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Link'); - $criteria = new \CriteriaCompo(); + + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('tag_itemid', $downloadsArray[$i]->getVar('lid'))); + $downloadsTags = $linkHandler->getAll($criteria); + if (count($downloadsTags) > 0) { foreach (array_keys($downloadsTags) as $j) { /** @var \XoopsModules\Tag\Link[] $downloadsTags */ + $objtags = $linkHandler->get($downloadsTags[$j]->getVar('tl_id')); + $linkHandler->delete($objtags) || $objtags->getHtmlErrors(); } } } + // supression du fichier + // pour extraire le nom du fichier + $urlfile = substr_replace($downloadsArray[$i]->getVar('url'), '', 0, mb_strlen($uploadurl_downloads)); + // chemin du fichier + $urlfile = $uploaddir_downloads . $urlfile; + if (is_file($urlfile)) { chmod($urlfile, 0777); + unlink($urlfile); } + // supression du téléchargment + $objdownloads = $downloadsHandler->get($downloadsArray[$i]->getVar('lid')); + $downloadsHandler->delete($objdownloads) || $objdownloads->getHtmlErrors(); } + // supression des sous catégories avec leurs téléchargements - $downloadscatArray = $categoryHandler->getAll(); - $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); + + $downloadscatArray = $categoryHandler->getAll(); + + $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); + $downloads_childcat = $mytree->getAllChild($categoryId); + foreach (array_keys($downloads_childcat) as $i) { /** @var \XoopsModules\Tdmdownloads\Category[] $downloads_childcat */ + // supression de la catégorie + $objchild = $categoryHandler->get($downloads_childcat[$i]->getVar('cat_cid')); + $categoryHandler->delete($objchild) || $objchild->getHtmlErrors(); + // supression des téléchargements associés + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('cid', $downloads_childcat[$i]->getVar('cat_cid'))); + $downloadsArray = $downloadsHandler->getAll($criteria); + foreach (array_keys($downloadsArray) as $j) { // supression des votes + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('lid', $downloadsArray[$j]->getVar('lid'))); + $votedata = $ratingHandler->getAll($criteria); + foreach (array_keys($votedata) as $k) { $objvotedata = $ratingHandler->get($votedata[$k]->getVar('ratingid')); + $ratingHandler->delete($objvotedata) || $objvotedata->getHtmlErrors(); } + // supression des rapports de fichier brisé + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('lid', $downloadsArray[$j]->getVar('lid'))); + $downloads_broken = $brokenHandler->getAll($criteria); + foreach (array_keys($downloads_broken) as $k) { $objbroken = $brokenHandler->get($downloads_broken[$k]->getVar('reportid')); + $brokenHandler->delete($objbroken) || $objbroken->getHtmlErrors(); } + // supression des data des champs sup. + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('lid', $downloadsArray[$j]->getVar('lid'))); + $downloads_fielddata = $fielddataHandler->getAll($criteria); + foreach (array_keys($downloads_fielddata) as $k) { $objfielddata = $fielddataHandler->get($downloads_fielddata[$k]->getVar('iddata')); + $fielddataHandler->delete($objfielddata) || $objvfielddata->getHtmlErrors(); } + // supression des commentaires + if ($downloadsArray[$j]->getVar('comments') > 0) { xoops_comment_delete($xoopsModule->getVar('mid'), $downloadsArray[$j]->getVar('lid')); } + //supression des tags - if ((1 == $helper->getConfig('usetag')) && class_exists(LinkHandler::class)) { + + if (1 == $helper->getConfig('usetag') && class_exists(LinkHandler::class)) { /** @var \XoopsModules\Tag\LinkHandler $linkHandler */ + $linkHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Link'); - $criteria = new \CriteriaCompo(); + + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('tag_itemid', $downloadsArray[$j]->getVar('lid'))); + $downloadsTags = $linkHandler->getAll($criteria); + if (count($downloadsTags) > 0) { foreach (array_keys($downloadsTags) as $k) { $objtags = $linkHandler->get($downloadsTags[$k]->getVar('tl_id')); + $linkHandler->delete($objtags) || $objtags->getHtmlErrors(); } } } + // supression du fichier $urlfile = substr_replace($downloadsArray[$j]->getVar('url'), '', 0, mb_strlen($uploadurl_downloads)); // pour extraire le nom du fichier $urlfile = $uploaddir_downloads . $urlfile; // chemin du fichier if (is_file($urlfile)) { chmod($urlfile, 0777); + unlink($urlfile); } + // supression du téléchargment + $objdownloads = $downloadsHandler->get($downloadsArray[$j]->getVar('lid')); + $downloadsHandler->delete($objdownloads) || $objdownloads->getHtmlErrors(); } } + if ($categoryHandler->delete($obj)) { redirect_header('category.php', 1, _AM_TDMDOWNLOADS_REDIRECT_DELOK); } else { $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); } } else { - $message = ''; + $message = ''; + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('cid', $categoryId)); + $downloadsArray = $downloadsHandler->getAll($criteria); + if (count($downloadsArray) > 0) { $message .= _AM_TDMDOWNLOADS_DELDOWNLOADS . '
      '; + foreach (array_keys($downloadsArray) as $i) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloadsArray */ + $message .= '' . $downloadsArray[$i]->getVar('title') . '
      '; } } - $downloadscatArray = $categoryHandler->getAll(); - $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); + + $downloadscatArray = $categoryHandler->getAll(); + + $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); + $downloads_childcat = $mytree->getAllChild($categoryId); + if (count($downloads_childcat) > 0) { $message .= _AM_TDMDOWNLOADS_DELSOUSCAT . '

      '; + foreach (array_keys($downloads_childcat) as $i) { /** @var \XoopsModules\Tdmdownloads\Category[] $downloads_childcat */ - $message .= '' . $downloads_childcat[$i]->getVar('cat_title') . '
      '; + + $message .= '' . $downloads_childcat[$i]->getVar('cat_title') . '
      '; + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('cid', $downloads_childcat[$i]->getVar('cat_cid'))); + $downloadsArray = $downloadsHandler->getAll($criteria); + if (count($downloadsArray) > 0) { $message .= _AM_TDMDOWNLOADS_DELDOWNLOADS . '
      '; + foreach (array_keys($downloadsArray) as $k) { $message .= '' . $downloadsArray[$k]->getVar('title') . '
      '; } @@ -283,13 +400,21 @@ } else { $message .= ''; } + //Affichage de la partie haute de l'administration de Xoops + xoops_cp_header(); + $adminObject = \Xmf\Module\Admin::getInstance(); + $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); + $adminObject->addItemButton(_AM_TDMDOWNLOADS_CAT_LIST, 'category.php?op=list', 'list'); + $adminObject->addItemButton(_AM_TDMDOWNLOADS_CAT_NEW, 'category.php?op=new_cat', 'add'); + $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); + xoops_confirm( [ 'ok' => 1, @@ -321,18 +446,21 @@ require_once XOOPS_ROOT_PATH . '/class/uploader.php'; $uploader = new \XoopsMediaUploader( $uploaddir, [ - 'image/gif', - 'image/jpeg', - 'image/pjpeg', - 'image/x-png', - 'image/png', - ], $helper->getConfig('maxuploadsize'), null, null + 'image/gif', + 'image/jpeg', + 'image/pjpeg', + 'image/x-png', + 'image/png', + ], $helper->getConfig('maxuploadsize'), null, null ); if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { $uploader->setPrefix('downloads_'); + $uploader->fetchMedia($_POST['xoops_upload_file'][0]); + if (!$uploader->upload()) { $errors = $uploader->getErrors(); + redirect_header('javascript:history.go(-1)', 3, $errors); } else { $obj->setVar('cat_imgurl', $uploader->getSavedFileName()); @@ -348,7 +476,8 @@ if (\Xmf\Request::hasVar('cat_cid', 'REQUEST')) { if ($cat_cid === \Xmf\Request::getInt('cat_pid', 0, 'POST')) { - $erreur = true; + $erreur = true; + $errorMessage .= _AM_TDMDOWNLOADS_ERREUR_CAT; } } @@ -357,60 +486,98 @@ } else { if ($categoryHandler->insert($obj)) { /** @var \XoopsModules\Tdmdownloads\Category $obj */ + $newcat_cid = $obj->getNewEnreg($db); + //permission pour voir + $perm_id = \Xmf\Request::hasVar('cat_cid', 'POST') ? $cat_cid : $newcat_cid; + /** @var \XoopsGroupPermHandler $grouppermHandler */ + $grouppermHandler = xoops_getHandler('groupperm'); - $criteria = new \CriteriaCompo(); + + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('gperm_itemid', $perm_id, '=')); + $criteria->add(new \Criteria('gperm_modid', $xoopsModule->getVar('mid'), '=')); + $criteria->add(new \Criteria('gperm_name', 'tdmdownloads_view', '=')); + $grouppermHandler->deleteAll($criteria); + if (\Xmf\Request::hasVar('groups_view', 'POST')) { foreach ($_POST['groups_view'] as $onegroup_id) { $grouppermHandler->addRight('tdmdownloads_view', $perm_id, $onegroup_id, $xoopsModule->getVar('mid')); } } + //permission pour editer - $perm_id = \Xmf\Request::getInt('cat_cid', $newcat_cid, 'POST'); + + $perm_id = \Xmf\Request::getInt('cat_cid', $newcat_cid, 'POST'); + $grouppermHandler = xoops_getHandler('groupperm'); - $criteria = new \CriteriaCompo(); + + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('gperm_itemid', $perm_id, '=')); + $criteria->add(new \Criteria('gperm_modid', $xoopsModule->getVar('mid'), '=')); + $criteria->add(new \Criteria('gperm_name', 'tdmdownloads_submit', '=')); + $grouppermHandler->deleteAll($criteria); + if (\Xmf\Request::hasVar('groups_submit', 'POST')) { foreach ($_POST['groups_submit'] as $onegroup_id) { $grouppermHandler->addRight('tdmdownloads_submit', $perm_id, $onegroup_id, $xoopsModule->getVar('mid')); } } + //permission pour télécharger + if (1 == $helper->getConfig('permission_download')) { - $perm_id = \Xmf\Request::getInt('cat_cid', $newcat_cid, 'POST'); + $perm_id = \Xmf\Request::getInt('cat_cid', $newcat_cid, 'POST'); + $grouppermHandler = xoops_getHandler('groupperm'); - $criteria = new \CriteriaCompo(); + + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('gperm_itemid', $perm_id, '=')); + $criteria->add(new \Criteria('gperm_modid', $xoopsModule->getVar('mid'), '=')); + $criteria->add(new \Criteria('gperm_name', 'tdmdownloads_download', '=')); + $grouppermHandler->deleteAll($criteria); + if (\Xmf\Request::hasVar('groups_download', 'POST')) { foreach ($_POST['groups_download'] as $onegroup_id) { $grouppermHandler->addRight('tdmdownloads_download', $perm_id, $onegroup_id, $xoopsModule->getVar('mid')); } } } + //notification + if (!\Xmf\Request::hasVar('categorie_modified', 'POST')) { - $tags = []; + $tags = []; + $tags['CATEGORY_NAME'] = \Xmf\Request::getString('cat_title', '', 'POST'); - $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/viewcat.php?cid=' . $newcat_cid; + + $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/viewcat.php?cid=' . $newcat_cid; + /** @var \XoopsNotificationHandler $notificationHandler */ + $notificationHandler = xoops_getHandler('notification'); + $notificationHandler->triggerEvent('global', 0, 'new_category', $tags); } + redirect_header('category.php?op=list', 1, _AM_TDMDOWNLOADS_REDIRECT_SAVE); } + $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); } $form = $obj->getForm(); @@ -421,9 +588,11 @@ // Local icons path if (is_object($helper->getModule())) { $pathModIcon16 = $helper->getModule()->getInfo('modicons16'); + $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16); + $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32); } diff --git a/admin/downloads.php b/admin/downloads.php index 5012a2e..29345a2 100644 --- a/admin/downloads.php +++ b/admin/downloads.php @@ -1,4 +1,4 @@ -addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_LISTE, 'downloads.php?op=list', 'list'); + $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_NEW, 'downloads.php?op=new_downloads', 'add'); } $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); @@ -75,13 +76,16 @@ if (\Xmf\Request::hasVar('statut_display', 'GET')) { if (0 === \Xmf\Request::getInt('statut_display', 0, 'GET')) { $criteria->add(new \Criteria('status', 0)); + $statusDisplay = 0; } else { $criteria->add(new \Criteria('status', 0, '!=')); + $statusDisplay = 1; } } else { $criteria->add(new \Criteria('status', 0, '!=')); + $statusDisplay = 1; } $documentSort = 1; @@ -89,22 +93,31 @@ if (\Xmf\Request::hasVar('document_tri')) { if (1 == \Xmf\Request::getInt('document_tri')) { $criteria->setSort('date'); + $documentSort = 1; } + if (2 == \Xmf\Request::getInt('document_tri')) { $criteria->setSort('title'); + $documentSort = 2; } + if (3 == \Xmf\Request::getInt('document_tri')) { $criteria->setSort('hits'); + $documentSort = 3; } + if (4 == \Xmf\Request::getInt('document_tri')) { $criteria->setSort('rating'); + $documentSort = 4; } + if (5 == \Xmf\Request::getInt('document_tri')) { $criteria->setSort('cid'); + $documentSort = 5; } } else { @@ -113,10 +126,13 @@ if (\Xmf\Request::hasVar('document_order')) { if (1 == \Xmf\Request::getInt('document_order')) { $criteria->setOrder('DESC'); + $documentOrder = 1; } + if (2 == \Xmf\Request::getInt('document_order')) { $criteria->setOrder('ASC'); + $documentOrder = 2; } } else { @@ -135,6 +151,7 @@ $pagenav = ''; if ($numrows > $limit) { $pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', 'op=list&document_tri=' . $documentSort . '&document_order=' . $documentOrder . '&statut_display=' . $statusDisplay); + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); } //Affichage du tableau des téléchargements @@ -146,29 +163,45 @@ . '/modules/' . $xoopsModule->dirname() . "/admin/downloads.php?statut_display=$statusDisplay&document_order=$documentOrder&document_tri='+this.options[this.selectedIndex].value\">"; + $selectDocument .= ''; + $selectDocument .= ''; + $selectDocument .= ''; + $selectDocument .= ''; + $selectDocument .= ''; + $selectDocument .= ' '; + $GLOBALS['xoopsTpl']->assign('selectDocument', $selectDocument); + $selectOrder = _AM_TDMDOWNLOADS_ORDER . " '; + $GLOBALS['xoopsTpl']->assign('selectOrder', $selectOrder); - $mytree = new \XoopsModules\Tdmdownloads\Tree($categoryArray, 'cat_cid', 'cat_pid'); - $class = 'odd'; + $mytree = new \XoopsModules\Tdmdownloads\Tree($categoryArray, 'cat_cid', 'cat_pid'); + + $class = 'odd'; + $downloads = []; + foreach (array_keys($downloadsArray) as $i) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloadsArray */ + $download = [ 'category' => $utility->getPathTree($mytree, $downloadsArray[$i]->getVar('cid'), $categoryArray, 'cat_title', $prefix = ' '), 'cid' => $downloadsArray[$i]->getVar('cid'), @@ -178,7 +211,9 @@ 'rating' => number_format($downloadsArray[$i]->getVar('rating'), 1), 'statut_display' => $statusDisplay, ]; + $GLOBALS['xoopsTpl']->append('downloads_list', $download); + unset($download); } } else { @@ -237,68 +272,113 @@ if (!$GLOBALS['xoopsSecurity']->check()) { redirect_header('downloads.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); } + // permet d'extraire le nom du fichier + $urlfile = substr_replace($obj->getVar('url'), '', 0, mb_strlen($uploadurl_downloads)); + if ($downloadsHandler->delete($obj)) { // permet de donner le chemin du fichier + $urlfile = $uploaddir_downloads . $urlfile; + // si le fichier est sur le serveur il es détruit + if (is_file($urlfile)) { chmod($urlfile, 0777); + unlink($urlfile); } + // supression des votes + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('lid', $downloads_lid)); + $votedata = $ratingHandler->getAll($criteria); + foreach (array_keys($votedata) as $i) { /** @var \XoopsModules\Tdmdownloads\Rating[] $votedata */ + $objvotedata = $ratingHandler->get($votedata[$i]->getVar('ratingid')); + $ratingHandler->delete($objvotedata) || $objvotedata->getHtmlErrors(); } + // supression des rapports de fichier brisé + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('lid', $downloads_lid)); + $downloads_broken = $brokenHandler->getAll($criteria); + foreach (array_keys($downloads_broken) as $i) { /** @var \XoopsModules\Tdmdownloads\Broken[] $downloads_broken */ + $objbroken = $brokenHandler->get($downloads_broken[$i]->getVar('reportid')); + $brokenHandler->delete($objbroken) || $objbroken->getHtmlErrors(); } + // supression des data des champs sup. + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('lid', $downloads_lid)); + $downloads_fielddata = $fielddataHandler->getAll($criteria); + foreach (array_keys($downloads_fielddata) as $i) { /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloads_fielddata */ + $objfielddata = $fielddataHandler->get($downloads_fielddata[$i]->getVar('iddata')); + $fielddataHandler->delete($objfielddata) || $objvfielddata->getHtmlErrors(); } + // supression des commentaires + xoops_comment_delete($xoopsModule->getVar('mid'), $downloads_lid); + //supression des tags - if ((1 == $helper->getConfig('usetag')) && class_exists(LinkHandler::class)) { + + if (1 == $helper->getConfig('usetag') && class_exists(LinkHandler::class)) { /** @var \XoopsModules\Tag\LinkHandler $linkHandler */ + $linkHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Link'); - $criteria = new \CriteriaCompo(); + + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('tag_itemid', $downloads_lid)); + $downloadsTags = $linkHandler->getAll($criteria); + foreach (array_keys($downloadsTags) as $i) { /** @var \XoopsModules\Tag\Link[] $downloadsTags */ + $objtags = $linkHandler->get($downloadsTags[$i]->getVar('tl_id')); + $linkHandler->delete($objtags) || $objtags->getHtmlErrors(); } } + redirect_header('downloads.php', 1, _AM_TDMDOWNLOADS_REDIRECT_DELOK); } else { $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); } } else { //Affichage de la partie haute de l'administration de Xoops + xoops_cp_header(); + $adminObject = \Xmf\Module\Admin::getInstance(); + $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); + $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_LISTE, 'downloads.php?op=list', 'list'); + $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_NEW, 'downloads.php?op=new_downloads', 'add'); if (0 == $downloads_waiting) { @@ -306,7 +386,9 @@ } else { $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_WAIT, 'downloads.php?op=list&statut_display=0', 'add', 'style="color : Red"'); } + $adminObject->displayButton('left'); + xoops_confirm( ['ok' => 1, 'downloads_lid' => $downloads_lid, 'op' => 'del_downloads'], $_SERVER['REQUEST_URI'], @@ -361,41 +443,56 @@ $fieldsList = []; foreach (array_keys($downloads_field) as $i) { /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ + if (1 == $downloads_field[$i]->getVar('status_def')) { if (1 == $downloads_field[$i]->getVar('fid')) { //page d'accueil + if ('' !== $viewDownloads->getVar('homepage')) { $fieldsList[] = ['name' => _AM_TDMDOWNLOADS_FORMHOMEPAGE, 'value' => '' . $viewDownloads->getVar('homepage') . '']; } } + if (2 == $downloads_field[$i]->getVar('fid')) { //version + if ('' !== $viewDownloads->getVar('version')) { $fieldsList[] = ['name' => _AM_TDMDOWNLOADS_FORMVERSION, 'value' => $viewDownloads->getVar('version')]; } } + if (3 == $downloads_field[$i]->getVar('fid')) { //taille du fichier + if ('' !== $viewDownloads->getVar('size')) { $fieldsList[] = ['name' => _AM_TDMDOWNLOADS_FORMSIZE, 'value' => $viewDownloads->getVar('size')]; } } + if (4 == $downloads_field[$i]->getVar('fid')) { //plateforme + if ('' !== $viewDownloads->getVar('platform')) { $fieldsList[] = ['name' => _AM_TDMDOWNLOADS_FORMPLATFORM, 'value' => $viewDownloads->getVar('platform')]; } } } else { - $contenu = ''; + $contenu = ''; + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('lid', $downloads_lid)); + $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid'))); + $downloadsfielddata = $fielddataHandler->getAll($criteria); + foreach (array_keys($downloadsfielddata) as $j) { /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloadsfielddata */ + $contenu = $downloadsfielddata[$j]->getVar('data'); } + if ('' !== $contenu) { $fieldsList[] = ['name' => $downloads_field[$i]->getVar('title'), 'value' => $contenu]; } @@ -403,14 +500,18 @@ } $download['fields_list'] = $fieldsList; // tags - if ((1 == $helper->getConfig('usetag')) && class_exists(Tag::class)) { + if (1 == $helper->getConfig('usetag') && class_exists(Tag::class)) { require_once XOOPS_ROOT_PATH . '/modules/tag/include/tagbar.php'; + $tags_array = tagBar($downloads_lid, 0); + if (!empty($tags_array)) { $tags = ''; + foreach (array_keys($tags_array['tags']) as $i) { $tags .= $tags_array['delimiter'] . ' ' . $tags_array['tags'][$i] . ' '; } + $download['tags'] = ['title' => $tags_array['title'], 'value' => $tags]; } } @@ -443,6 +544,7 @@ $userList = []; foreach (array_keys($votedataArray) as $i) { /** @var \XoopsModules\Tdmdownloads\Rating[] $votedataArray */ + $userList[] = [ 'ratinguser' => \XoopsUser::getUnameFromId($votedataArray[$i]->getVar('ratinguser')), 'ratinghostname' => $votedataArray[$i]->getVar('ratinghostname'), @@ -478,29 +580,43 @@ $objvotedata = $ratingHandler->get(\Xmf\Request::getInt('rid')); if ($ratingHandler->delete($objvotedata)) { $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('lid', \Xmf\Request::getInt('lid'))); + $votedataArray = $ratingHandler->getAll($criteria); - $votesTotal = $ratingHandler->getCount($criteria); - $obj = $downloadsHandler->get(\Xmf\Request::getInt('lid')); + + $votesTotal = $ratingHandler->getCount($criteria); + + $obj = $downloadsHandler->get(\Xmf\Request::getInt('lid')); + if (0 === $votesTotal) { $obj->setVar('rating', number_format(0, 1)); + $obj->setVar('votes', 0); + if ($downloadsHandler->insert($obj)) { redirect_header('downloads.php?op=view_downloads&downloads_lid=' . \Xmf\Request::getInt('lid'), 1, _AM_TDMDOWNLOADS_REDIRECT_DELOK); } } else { $ratingTotal = 0; + foreach (array_keys($votedataArray) as $i) { /** @var \XoopsModules\Tdmdownloads\Rating[] $votedataArray */ + $ratingTotal += $votedataArray[$i]->getVar('rating'); } + $rating = $ratingTotal / $votesTotal; + $obj->setVar('rating', number_format($rating, 1)); + $obj->setVar('votes', $votesTotal); + if ($downloadsHandler->insert($obj)) { redirect_header('downloads.php?op=view_downloads&downloads_lid=' . \Xmf\Request::getInt('lid'), 1, _AM_TDMDOWNLOADS_REDIRECT_DELOK); } } + $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); } $GLOBALS['xoopsTpl']->assign('message_erreur', $objvotedata->getHtmlErrors()); @@ -534,38 +650,49 @@ if (\Xmf\Request::hasVar('submitter', 'POST')) { $obj->setVar('submitter', \Xmf\Request::getInt('submitter', 0, 'POST')); + $donnee['submitter'] = \Xmf\Request::getInt('submitter', 0, 'POST'); } else { $obj->setVar('submitter', !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0); + $donnee['submitter'] = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0; } if (\Xmf\Request::hasVar('downloads_modified')) { $obj->setVar('date', time()); + if (\Xmf\Request::hasVar('status', 'POST')) { $obj->setVar('status', 1); + $donnee['status'] = 1; } else { $obj->setVar('status', 0); + $donnee['status'] = 0; } } else { if (\Xmf\Request::hasVar('date_update', 'POST') && 'Y' === $_POST['date_update']) { $obj->setVar('date', strtotime($_POST['date'])); + if (\Xmf\Request::hasVar('status', 'POST')) { $obj->setVar('status', 2); + $donnee['status'] = 1; } else { $obj->setVar('status', 0); + $donnee['status'] = 0; } } else { if (\Xmf\Request::hasVar('status', 'POST')) { $obj->setVar('status', 1); + $donnee['status'] = 1; } else { $obj->setVar('status', 0); + $donnee['status'] = 0; } + if (\Xmf\Request::hasVar('date', 'POST')) { $obj->setVar('date', strtotime($_POST['date'])); } else { @@ -577,14 +704,16 @@ // erreur si la description est vide if (\Xmf\Request::hasVar('description', 'POST')) { if ('' === \Xmf\Request::getString('description', '')) { - $erreur = true; + $erreur = true; + $errorMessage .= _AM_TDMDOWNLOADS_ERREUR_NODESCRIPTION . '
      '; } } // erreur si la catégorie est vide if (\Xmf\Request::hasVar('cid', 'POST')) { if (0 == \Xmf\Request::getInt('cid', 0, 'POST')) { - $erreur = true; + $erreur = true; + $errorMessage .= _AM_TDMDOWNLOADS_ERREUR_NOCAT . '
      '; } } @@ -595,13 +724,15 @@ $downloads_field = $fieldHandler->getAll($criteria); foreach (array_keys($downloads_field) as $i) { /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ + if (0 == $downloads_field[$i]->getVar('status_def')) { - $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); + $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); + $donnee[$fieldName] = \Xmf\Request::getString($fieldName, '', 'POST'); } } // enregistrement temporaire des tags - if ((1 == $helper->getConfig('usetag')) && class_exists(Tag::class)) { + if (1 == $helper->getConfig('usetag') && class_exists(Tag::class)) { $donnee['TAG'] = $_POST['tag']; } @@ -609,37 +740,55 @@ $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); /** @var \XoopsThemeForm $form */ + $form = $obj->getForm($donnee, true); + $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); + break; } // Pour le fichier $mediaSize = 0; if (isset($_POST['xoops_upload_file'][0])) { $uploader = new \XoopsMediaUploader($uploaddir_downloads, $helper->getConfig('mimetypes'), $helper->getConfig('maxuploadsize'), null, null); + if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { if ($helper->getConfig('newnamedownload')) { $uploader->setPrefix($helper->getConfig('prefixdownloads')); } + $uploader->fetchMedia($_POST['xoops_upload_file'][0]); + if (!$uploader->upload()) { $errorMessage .= $uploader->getErrors() . '
      '; + $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); + $form = $obj->getForm($donnee, true); + $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); + break; } + $mediaSize = $uploader->getMediaSize(); + $obj->setVar('url', $uploadurl_downloads . $uploader->getSavedFileName()); } else { if ($_FILES['attachedfile']['name'] > '') { // file name was given, but fetchMedia failed - show error when e.g. file size exceed maxuploadsize + $errorMessage .= $uploader->getErrors() . '
      '; + $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); + $form = $obj->getForm($donnee, true); + $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); + break; } + $obj->setVar('url', \Xmf\Request::getUrl('url', '', 'POST')); } } else { @@ -649,33 +798,47 @@ if (isset($_POST['xoops_upload_file'][1])) { $uploader_2 = new \XoopsMediaUploader( $uploaddir_shots, [ - 'image/gif', - 'image/jpeg', - 'image/pjpeg', - 'image/x-png', - 'image/png', - ], $helper->getConfig('maxuploadsize'), null, null + 'image/gif', + 'image/jpeg', + 'image/pjpeg', + 'image/x-png', + 'image/png', + ], $helper->getConfig('maxuploadsize'), null, null ); + if ($uploader_2->fetchMedia($_POST['xoops_upload_file'][1])) { $uploader_2->setPrefix('downloads_'); + $uploader_2->fetchMedia($_POST['xoops_upload_file'][1]); + if (!$uploader_2->upload()) { $errorMessage .= $uploader_2->getErrors() . '
      '; + $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); + $form = $obj->getForm($donnee, true); + $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); + break; } + $obj->setVar('logourl', $uploader_2->getSavedFileName()); } else { if ($_FILES['attachedimage']['name'] > '') { // file name was given, but fetchMedia failed - show error when e.g. file size exceed maxuploadsize + $errorMessage .= $uploader_2->getErrors() . '
      '; + $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); + $form = $obj->getForm($donnee, true); + $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); + break; } + $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'POST')); } } else { @@ -694,7 +857,9 @@ $timeToRedirect = 2; if (0 == $obj->getVar('size')) { $obj->setVar('size', ''); - $error_message = _AM_TDMDOWNLOADS_ERREUR_SIZE; + + $error_message = _AM_TDMDOWNLOADS_ERREUR_SIZE; + $timeToRedirect = 10; } // enregistrement @@ -704,20 +869,31 @@ } else { $lidDownloads = \Xmf\Request::getInt('lid'); } + //tags - if ((1 == $helper->getConfig('usetag')) && class_exists(TagHandler::class)) { + + if (1 == $helper->getConfig('usetag') && class_exists(TagHandler::class)) { /** @var \XoopsModules\Tag\TagHandler $tagHandler */ + $tagHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Tag'); + $tagHandler->updateByItem($_POST['tag'], $lidDownloads, $moduleDirName, 0); } + // Récupération des champs supplémentaires: + $criteria = new \CriteriaCompo(); + $criteria->setSort('weight ASC, title'); + $criteria->setOrder('ASC'); + $downloads_field = $fieldHandler->getAll($criteria); + foreach (array_keys($downloads_field) as $i) { if (0 == $downloads_field[$i]->getVar('status_def')) { $iddata = 'iddata' . $downloads_field[$i]->getVar('fid'); + if (\Xmf\Request::hasVar($iddata, 'POST')) { if ('' === \Xmf\Request::getString($iddata, '')) { $objdata = $fielddataHandler->create(); @@ -727,41 +903,67 @@ } else { $objdata = $fielddataHandler->create(); } + $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); + $objdata->setVar('data', \Xmf\Request::getString($fieldName, '', 'POST')); + $objdata->setVar('lid', $lidDownloads); + $objdata->setVar('fid', $downloads_field[$i]->getVar('fid')); + $fielddataHandler->insert($objdata) || $objdata->getHtmlErrors(); } } + //permission pour télécharger + if (2 == $helper->getConfig('permission_download')) { /** @var \XoopsGroupPermHandler $grouppermHandler */ + $grouppermHandler = xoops_getHandler('groupperm'); - $criteria = new \CriteriaCompo(); + + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('gperm_itemid', $lidDownloads, '=')); + $criteria->add(new \Criteria('gperm_modid', $xoopsModule->getVar('mid'), '=')); + $criteria->add(new \Criteria('gperm_name', 'tdmdownloads_download_item', '=')); + $grouppermHandler->deleteAll($criteria); + if (\Xmf\Request::hasVar('item_download', 'POST')) { foreach ($_POST['item_download'] as $onegroup_id) { $grouppermHandler->addRight('tdmdownloads_download_item', $lidDownloads, $onegroup_id, $xoopsModule->getVar('mid')); } } } + // pour les notifications uniquement lors d'un nouveau téléchargement + if (\Xmf\Request::hasVar('downloads_modified')) { - $tags = []; - $tags['FILE_NAME'] = \Xmf\Request::getString('title', '', 'POST'); - $tags['FILE_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/singlefile.php?cid=' . \Xmf\Request::getInt('cid', 0, 'POST') . '&lid=' . $lidDownloads; - $downloadscat_cat = $categoryHandler->get(\Xmf\Request::getInt('cid', 0, 'POST')); + $tags = []; + + $tags['FILE_NAME'] = \Xmf\Request::getString('title', '', 'POST'); + + $tags['FILE_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/singlefile.php?cid=' . \Xmf\Request::getInt('cid', 0, 'POST') . '&lid=' . $lidDownloads; + + $downloadscat_cat = $categoryHandler->get(\Xmf\Request::getInt('cid', 0, 'POST')); + $tags['CATEGORY_NAME'] = $downloadscat_cat->getVar('cat_title'); - $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/viewcat.php?cid=' . \Xmf\Request::getInt('cid', 0, 'POST'); + + $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/viewcat.php?cid=' . \Xmf\Request::getInt('cid', 0, 'POST'); + /** @var \XoopsNotificationHandler $notificationHandler */ + $notificationHandler = xoops_getHandler('notification'); + $notificationHandler->triggerEvent('global', 0, 'new_file', $tags); + $notificationHandler->triggerEvent('category', \Xmf\Request::getInt('cid', 0, 'POST'), 'new_file', $tags); } + redirect_header('downloads.php', $timeToRedirect, _AM_TDMDOWNLOADS_REDIRECT_SAVE . '

      ' . $error_message); } $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); @@ -792,9 +994,11 @@ // Local icons path if (is_object($helper->getModule())) { $pathModIcon16 = $helper->getModule()->getInfo('modicons16'); + $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16); + $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32); } diff --git a/admin/field.php b/admin/field.php index 5475189..8a92b66 100644 --- a/admin/field.php +++ b/admin/field.php @@ -1,4 +1,4 @@ - $downloads_field[$i]->getVar('title'), 'img' => $uploadurl_field . $downloads_field[$i]->getVar('img'), @@ -57,7 +58,9 @@ 'status_def' => $downloads_field[$i]->getVar('status_def'), 'search' => $downloads_field[$i]->getVar('search'), ]; + $GLOBALS['xoopsTpl']->append('fields_list', $field); + unset($field); } } @@ -121,16 +124,25 @@ if (!$GLOBALS['xoopsSecurity']->check()) { redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); } + // supression des entrée du champ + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('fid', \Xmf\Request::getInt('fid', 0))); + $downloadsArray = $fielddataHandler->getAll($criteria); + foreach (array_keys($downloadsArray) as $i) { /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloadsArray */ + // supression de l'entrée + $objdownloadsfielddata = $fielddataHandler->get($downloadsArray[$i]->getVar('iddata')); + $fielddataHandler->delete($objdownloadsfielddata) || $objdownloads->getHtmlErrors(); } + if ($fieldHandler->delete($obj)) { redirect_header('field.php', 1, _AM_TDMDOWNLOADS_REDIRECT_DELOK); } else { @@ -138,26 +150,41 @@ } } else { $downloadsfield = $fieldHandler->get(\Xmf\Request::getInt('fid', 0, 'GET')); + if (1 == $downloadsfield->getVar('status_def')) { redirect_header('field.php', 2, _AM_TDMDOWNLOADS_REDIRECT_NODELFIELD); } - $message = ''; + + $message = ''; + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('fid', \Xmf\Request::getInt('fid', 0, 'GET'))); + /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloadsArray */ + $downloadsArray = $fielddataHandler->getAll($criteria); + if (count($downloadsArray) > 0) { $message .= _AM_TDMDOWNLOADS_DELDATA . '
      '; + foreach (array_keys($downloadsArray) as $i) { $message .= '' . $downloadsArray[$i]->getVar('data') . '
      '; } } + //Affichage de la partie haute de l'administration de Xoops + xoops_cp_header(); + $adminObject = \Xmf\Module\Admin::getInstance(); + $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); + $adminObject->addItemButton(_AM_TDMDOWNLOADS_FIELD_NEW, 'field.php?op=new_field', 'add'); + $adminObject->addItemButton(_AM_TDMDOWNLOADS_FIELD_LIST, 'field.php?op=list', 'list'); + $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); xoops_confirm(['ok' => 1, 'fid' => \Xmf\Request::getInt('fid', 0, 'GET'), 'op' => 'del_field'], $_SERVER['REQUEST_URI'], sprintf(_AM_TDMDOWNLOADS_FORMSUREDEL, $obj->getVar('title')) . '

      ' . $message); @@ -182,18 +209,21 @@ require_once XOOPS_ROOT_PATH . '/class/uploader.php'; $uploader = new \XoopsMediaUploader( $uploaddir_field, [ - 'image/gif', - 'image/jpeg', - 'image/pjpeg', - 'image/x-png', - 'image/png', - ], $helper->getConfig('maxuploadsize'), 16, null + 'image/gif', + 'image/jpeg', + 'image/pjpeg', + 'image/x-png', + 'image/png', + ], $helper->getConfig('maxuploadsize'), 16, null ); if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { $uploader->setPrefix('downloads_'); + $uploader->fetchMedia($_POST['xoops_upload_file'][0]); + if (!$uploader->upload()) { $errors = $uploader->getErrors(); + redirect_header('javascript:history.go(-1)', 3, $errors); } else { $obj->setVar('img', $uploader->getSavedFileName()); @@ -210,12 +240,15 @@ if (true === $erreur) { xoops_cp_header(); + $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); } else { if ($fieldHandler->insert($obj)) { redirect_header('field.php', 1, _AM_TDMDOWNLOADS_REDIRECT_SAVE); } + xoops_cp_header(); + $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); } $form = $obj->getForm(); @@ -226,9 +259,11 @@ // Local icons path if (is_object($helper->getModule())) { $pathModIcon16 = $helper->getModule()->getInfo('modicons16'); + $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16); + $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32); } diff --git a/admin/import.php b/admin/import.php index 2c7b7c7..a31b92c 100644 --- a/admin/import.php +++ b/admin/import.php @@ -1,4 +1,4 @@ -useTable($myTable)) { // if this returns false, there is no table $table::truncateTable($myTable); @@ -52,30 +59,42 @@ function importMydownloads($path = '', $imgurl = '') } //Inserer les données des catégories + $query_topic = $xoopsDB->query('SELECT cid, pid, title, imgurl FROM ' . $xoopsDB->prefix('mydownloads_cat')); + while (false !== ($donnees = $xoopsDB->fetchArray($query_topic))) { if ('' === $donnees['imgurl']) { $img = 'blank.gif'; } else { $img = substr_replace($donnees['imgurl'], '', 0, mb_strlen($imgurl)); + @copy($path . $img, XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/cats/' . $img); } $title = $donnees['title']; + $insert = $xoopsDB->queryF('INSERT INTO ' . $xoopsDB->prefix('tdmdownloads_cat') . " (cat_cid, cat_pid, cat_title, cat_imgurl, cat_description_main, cat_weight ) VALUES ('" . $donnees['cid'] . "', '" . $donnees['pid'] . "', '" . $title . "', '" . $img . "', '', '0')"); + if (!$insert) { $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['title']]; } + $successes[] = sprintf(_AM_TDMDOWNLOADS_IMPORT_CAT_IMP, $donnees['title']); } + echo '
      '; //Inserer les données des téléchargemnts + $query_links = $xoopsDB->query('SELECT lid, cid, title, url, homepage, version, size, platform, logourl, submitter, status, date, hits, rating, votes, comments FROM ' . $xoopsDB->prefix('mydownloads_downloads')); + while (false !== ($donnees = $xoopsDB->fetchArray($query_links))) { //On recupere la description + $requete = $xoopsDB->queryF('SELECT description FROM ' . $xoopsDB->prefix('mydownloads_text') . " WHERE lid = '" . $donnees['lid'] . "'"); + [$description] = $xoopsDB->fetchRow($requete); + $insert = $xoopsDB->queryF( 'INSERT INTO ' . $xoopsDB->prefix('tdmdownloads_downloads') @@ -115,15 +134,22 @@ function importMydownloads($path = '', $imgurl = '') . $donnees['votes'] . "', '0', '0' )" ); + if (!$insert) { $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['title']]; } + $successes[] = sprintf(_AM_TDMDOWNLOADS_IMPORT_DOWNLOADS_IMP, $donnees['title']); + @copy($path . $donnees['logourl'], XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/shots/' . $donnees['logourl']); } + echo '
      '; + //Inserer les données des votes + $query_vote = $xoopsDB->query('SELECT ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp FROM ' . $xoopsDB->prefix('mydownloads_votedata')); + while (false !== ($donnees = $xoopsDB->fetchArray($query_vote))) { $insert = $xoopsDB->queryF( 'INSERT INTO ' @@ -142,14 +168,20 @@ function importMydownloads($path = '', $imgurl = '') . $donnees['ratingtimestamp'] . "')" ); + if (!$insert) { $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['ratingid']]; } + $successes[] = sprintf(_AM_TDMDOWNLOADS_IMPORT_VOTE_IMP, $donnees['ratingid']); } + echo '

      '; + echo "
      "; + echo _AM_TDMDOWNLOADS_IMPORT_OK; + echo '
      '; } else { xoops_confirm(['op' => 'importMydownloads', 'ok' => 1, 'path' => $path, 'imgurl' => $imgurl], 'import.php', _AM_TDMDOWNLOADS_IMPORT_CONF_MYDOWNLOADS . '
      '); @@ -164,13 +196,20 @@ function importMydownloads($path = '', $imgurl = '') function importWfdownloads($shots = '', $catimg = '') { $moduleDirName = basename(dirname(__DIR__)); - $ok = \Xmf\Request::getInt('ok', 0, 'POST'); + + $ok = \Xmf\Request::getInt('ok', 0, 'POST'); + global $xoopsDB; + if (1 === $ok) { //Vider les tables + $myTables = ['tdmdownloads_broken', 'tdmdownloads_cat', 'tdmdownloads_downloads', 'tdmdownloads_fielddata', 'tdmdownloads_modfielddata', 'tdmdownloads_votedata']; - $table = new \Xmf\Database\TableLoad(); - $tables = new \Xmf\Database\Tables(); + + $table = new \Xmf\Database\TableLoad(); + + $tables = new \Xmf\Database\Tables(); + foreach ($myTables as $myTable) { if ($tables->useTable($myTable)) { // if this returns false, there is no table $table::truncateTable($myTable); @@ -178,38 +217,48 @@ function importWfdownloads($shots = '', $catimg = '') } //Inserer les données des catégories + $query_topic = $xoopsDB->query('SELECT cid, pid, title, imgurl, description, total, summary, spotlighttop, spotlighthis, dohtml, dosmiley, doxcode, doimage, dobr, weight, formulize_fid FROM ' . $xoopsDB->prefix('wfdownloads_cat')); + while (false !== ($donnees = $xoopsDB->fetchArray($query_topic))) { if ('' === $donnees['imgurl']) { $img = 'blank.gif'; } else { $img = $donnees['imgurl']; + @copy($catimg . $img, XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/cats/' . $img); } + $insert = $xoopsDB->queryF( 'INSERT INTO ' . $xoopsDB->prefix('tdmdownloads_cat') . " (cat_cid, cat_pid, cat_title, cat_imgurl, cat_description_main, cat_weight ) VALUES ('" . $donnees['cid'] . "', '" . $donnees['pid'] . "', '" . addcslashes($donnees['title'], "'") . "', '" . $img . "', '" . addcslashes( $donnees['description'], "'" ) . "', '" . $donnees['weight'] . "')" ); + if (!$insert) { $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['title']]; } + $successes[] = sprintf(_AM_TDMDOWNLOADS_IMPORT_CAT_IMP, $donnees['title']); } + echo '
      '; //Inserer les données des téléchargemnts + $query_links = $xoopsDB->query( 'SELECT lid, cid, title, url, filename, filetype, homepage, version, size, platform, screenshot, screenshot2, screenshot3, screenshot4, submitter, publisher, status, date, hits, rating, votes, comments, license, mirror, price, paypalemail, features, requirements, homepagetitle, forumid, limitations, versiontypes, dhistory, published, expired, updated, offline, summary, description, ipaddress, notifypub, formulize_idreq FROM ' . $xoopsDB->prefix('wfdownloads_downloads') ); + while (false !== ($donnees = $xoopsDB->fetchArray($query_links))) { if ('' === $donnees['url']) { $newurl = XOOPS_URL . '/uploads/' . $donnees['filename']; } else { $newurl = $donnees['url']; } + $insert = $xoopsDB->queryF( 'INSERT INTO ' . $xoopsDB->prefix('tdmdownloads_downloads') . " ( lid, cid, title, url, homepage, version, size, platform, description, logourl, submitter, status, date, hits, rating, votes, comments, top) VALUES @@ -222,13 +271,18 @@ function importWfdownloads($shots = '', $catimg = '') if (!$insert) { $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['title']]; } + $successes[] = sprintf(_AM_TDMDOWNLOADS_IMPORT_DOWNLOADS_IMP, $donnees['title']); + @copy($shots . $donnees['screenshot'], XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/shots/' . $donnees['screenshot']); } + echo '
      '; //Inserer les données des votes + $query_vote = $xoopsDB->query('SELECT ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp FROM ' . $xoopsDB->prefix('wfdownloads_votedata')); + while (false !== ($donnees = $xoopsDB->fetchArray($query_vote))) { $insert = $xoopsDB->queryF( 'INSERT INTO ' @@ -247,13 +301,18 @@ function importWfdownloads($shots = '', $catimg = '') . $donnees['ratingtimestamp'] . "')" ); + if (!$insert) { echo '' . _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA . ': ' . $donnees['ratingid'] . '
      '; } + echo sprintf(_AM_TDMDOWNLOADS_IMPORT_VOTE_IMP . '
      ', $donnees['ratingid']); } + $successes[] = _AM_TDMDOWNLOADS_IMPORT_OK; + $GLOBALS['xoopsTpl']->assign('successes', $successes); + $GLOBALS['xoopsTpl']->assign('errors', $errors); } else { xoops_confirm(['op' => 'importWfdownloads', 'ok' => 1, 'shots' => $shots, 'catimg' => $catimg], 'import.php', _AM_TDMDOWNLOADS_IMPORT_CONF_WFDOWNLOADS . '
      '); @@ -292,6 +351,7 @@ function importWfdownloads($shots = '', $catimg = '') $check .= '
    • ' . _AM_TDMDOWNLOADS_IMPORT_DONT_DOWNLOADS . '
    • '; } else { $check .= '
    • ' . sprintf(_AM_TDMDOWNLOADS_IMPORT_NB_DOWNLOADS, $count_downloads) . '
    • '; + $counter++; } $sql = $xoopsDB->query('SELECT COUNT(cid) AS count FROM ' . $xoopsDB->prefix('mydownloads_cat')); @@ -301,6 +361,7 @@ function importWfdownloads($shots = '', $catimg = '') $check .= '
    • ' . _AM_TDMDOWNLOADS_IMPORT_DONT_TOPIC . '
    • '; } else { $check .= '
    • ' . sprintf('
      ' . _AM_TDMDOWNLOADS_IMPORT_NB_CAT, $count_topic) . '
    • '; + $counter++; } $check .= ''; @@ -312,9 +373,11 @@ function importWfdownloads($shots = '', $catimg = '') // To execute if ($counter > 0) { $form->addElement(new \XoopsFormHidden('op', 'import_mydownloads')); + $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); } else { $form->addElement(new \XoopsFormHidden('op', 'cancel')); + $form->addElement(new \XoopsFormButton('', 'submit', _CANCEL, 'submit')); } $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); @@ -344,6 +407,7 @@ function importWfdownloads($shots = '', $catimg = '') $check .= '
    • ' . _AM_TDMDOWNLOADS_IMPORT_DONT_DOWNLOADS . '
    • '; } else { $check .= '
    • ' . sprintf(_AM_TDMDOWNLOADS_IMPORT_NB_DOWNLOADS, $count_downloads) . '
    • '; + $counter++; } $sql = $xoopsDB->query('SELECT COUNT(cid) AS count FROM ' . $xoopsDB->prefix('wfdownloads_cat')); @@ -352,6 +416,7 @@ function importWfdownloads($shots = '', $catimg = '') $check .= '
    • ' . _AM_TDMDOWNLOADS_IMPORT_DONT_TOPIC . '
    • '; } else { $check .= '
    • ' . sprintf('
      ' . _AM_TDMDOWNLOADS_IMPORT_NB_CAT, $count_topic) . '
    • '; + $counter++; } $check .= ''; @@ -363,9 +428,11 @@ function importWfdownloads($shots = '', $catimg = '') // To execute if ($counter > 0) { $form->addElement(new \XoopsFormHidden('op', 'import_mydownloads')); + $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); } else { $form->addElement(new \XoopsFormHidden('op', 'cancel')); + $form->addElement(new \XoopsFormButton('', 'submit', _CANCEL, 'submit')); } $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); diff --git a/admin/index.php b/admin/index.php index b611817..128e3b2 100644 --- a/admin/index.php +++ b/admin/index.php @@ -1,4 +1,4 @@ -uploadFolders) as $i) { $utility::createFolder($configurator->uploadFolders[$i]); + $adminObject->addConfigBoxLine($configurator->uploadFolders[$i], 'folder'); } @@ -100,13 +101,13 @@ if ($helper->getConfig('displaySampleButton')) { xoops_loadLanguage('admin/modulesadmin', 'system'); + require dirname(__DIR__) . '/testdata/index.php'; $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=load', 'add'); $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=save', 'add'); // $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), '__DIR__ . /../../testdata/index.php?op=exportschema', 'add'); - } //------------- End Test Data ---------------------------- @@ -118,4 +119,3 @@ echo $utility::getServerStats(); //codeDump(__FILE__); require __DIR__ . '/admin_footer.php'; - diff --git a/admin/menu.php b/admin/menu.php index 9c0581b..5e1ed99 100644 --- a/admin/menu.php +++ b/admin/menu.php @@ -1,4 +1,4 @@ -getSynchronizeDDL(); if (!empty($queue)) { echo "
      \n";
      +
                   foreach ($queue as $line) {
                       echo $line . ";\n";
                   }
      +
                   echo "
      \n"; } break; @@ -90,6 +93,7 @@ case 'confirmwrite': if ($GLOBALS['xoopsSecurity']->check()) { $migrator->saveCurrentSchema(); + $message = 'Current schema file written'; } break; diff --git a/admin/modified.php b/admin/modified.php index 930726b..e63cd9f 100644 --- a/admin/modified.php +++ b/admin/modified.php @@ -1,4 +1,4 @@ -setLimit(\Xmf\Request::getInt('limit', 0, 'REQUEST')); + $limit = \Xmf\Request::getInt('limit', 0, 'REQUEST'); } else { $criteria->setLimit($helper->getConfig('perpageadmin')); + $limit = $helper->getConfig('perpageadmin'); } if (\Xmf\Request::hasVar('start', 'REQUEST')) { $criteria->setStart(\Xmf\Request::getInt('start', 0, 'REQUEST')); + $start = \Xmf\Request::getInt('start', 0, 'REQUEST'); } else { $criteria->setStart(0); + $start = 0; } $criteria->setSort('requestid'); @@ -55,6 +59,7 @@ $numrows = $modifiedHandler->getCount(); //Ggoffy if ($numrows > $limit) { $pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', 'op=liste&limit=' . $limit); + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); } else { $pagenav = ''; @@ -62,21 +67,30 @@ //Affichage du tableau des téléchargements modifiés if ($numrows > 0) { $GLOBALS['xoopsTpl']->assign('modified_count', $numrows); + foreach (array_keys($downloadsmod_arr) as $i) { /** @var \XoopsModules\Tdmdownloads\Modified[] $downloadsmod_arr */ + $downloads = $downloadsHandler->get($downloadsmod_arr[$i]->getVar('lid')); + // pour savoir si le fichier est nouveau - $downloads_url = $downloads->getVar('url'); + + $downloads_url = $downloads->getVar('url'); + $moddownloads_url = $downloadsmod_arr[$i]->getVar('url'); - $new_file = ($downloads_url != $moddownloads_url); - $modified = [ + + $new_file = ($downloads_url != $moddownloads_url); + + $modified = [ 'lid' => $downloadsmod_arr[$i]->getVar('lid'), 'requestid' => $downloadsmod_arr[$i]->getVar('requestid'), 'new_file' => $new_file, 'download_title' => $downloads->getVar('title'), 'modifysubmitter' => XoopsUser::getUnameFromId($downloadsmod_arr[$i]->getVar('modifysubmitter')), ]; + $GLOBALS['xoopsTpl']->append('modified_list', $modified); + unset($modified); } } else { @@ -131,46 +145,72 @@ $downloads_field = $fieldHandler->getAll($criteria); foreach (array_keys($downloads_field) as $i) { /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ + if (1 == $downloads_field[$i]->getVar('status_def')) { if (1 == $downloads_field[$i]->getVar('fid')) { //page d'accueil + $compare['cfields'][] = ['info' => _AM_TDMDOWNLOADS_FORMHOMEPAGE, 'current' => $downloads_homepage, 'modified' => $moddownloads_homepage]; } + if (2 == $downloads_field[$i]->getVar('fid')) { //version + $compare['cfields'][] = ['info' => _AM_TDMDOWNLOADS_FORMVERSION, 'current' => $downloads_version, 'modified' => $moddownloads_version]; } + if (3 == $downloads_field[$i]->getVar('fid')) { //taille du fichier + $compare['cfields'][] = ['info' => _AM_TDMDOWNLOADS_FORMSIZE, 'current' => $downloads_size, 'modified' => $moddownloads_size]; } + if (4 == $downloads_field[$i]->getVar('fid')) { //plateforme + $compare['cfields'][] = ['info' => _AM_TDMDOWNLOADS_FORMPLATFORM, 'current' => $downloads_platform, 'modified' => $moddownloads_platform]; } } else { //original - $contenu = ''; + + $contenu = ''; + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('lid', \Xmf\Request::getInt('downloads_lid', 0, 'REQUEST'))); + $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid'))); + $downloadsfielddata = $fielddataHandler->getAll($criteria); + foreach (array_keys($downloadsfielddata) as $j) { /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloadsfielddata */ + // $contenu = $downloadsfielddata[$j]->getVar('data'); + $contenu = $downloadsfielddata[$j]->getVar('data', 'e'); } + //proposé + $contentModified = ''; - $criteria = new \CriteriaCompo(); + + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('lid', \Xmf\Request::getInt('mod_id', 0, 'REQUEST'))); + $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid'))); + $downloadsfieldmoddata = $modifieddataHandler->getAll($criteria); + foreach (array_keys($downloadsfieldmoddata) as $j) { /** @var \XoopsModules\Tdmdownloads\Modified[] $downloadsfieldmoddata */ + $contentModified = $downloadsfieldmoddata[$j]->getVar('moddata', 'e'); } + // echo '
      ' . $downloads_field[$i]->getVar('title') . ': ' . $contentModified . '
       
      - <{if $pagenav}> + <{if $pagenav|default:''}>
      <{$pagenav}>
      <{/if}> <{/if}> -<{if $themeForm}> +<{if $themeForm|default:''}> <{$themeForm}> <{/if}>
      diff --git a/templates/admin/tdmdownloads_admin_category.tpl b/templates/admin/tdmdownloads_admin_category.tpl index cbb082d..8a2f44a 100644 --- a/templates/admin/tdmdownloads_admin_category.tpl +++ b/templates/admin/tdmdownloads_admin_category.tpl @@ -1,9 +1,9 @@ <{include file='db:tdmdownloads_admin_header.tpl'}> -<{if $message_erreur}> +<{if $message_erreur|default:''}>
      <{$message_erreur}>
      <{/if}> -<{if $categories_list}> +<{if $categories_list|default:''}> @@ -37,13 +37,13 @@ <{/if}>
       
      - <{if $pagenav}> + <{if $pagenav|default:''}>
      <{$pagenav}>
      <{/if}> <{/if}> -<{if $themeForm}> +<{if $themeForm|default:''}> <{$themeForm}> <{/if}> diff --git a/templates/admin/tdmdownloads_admin_downloads.tpl b/templates/admin/tdmdownloads_admin_downloads.tpl index 7ad50f6..b49a1f5 100644 --- a/templates/admin/tdmdownloads_admin_downloads.tpl +++ b/templates/admin/tdmdownloads_admin_downloads.tpl @@ -1,7 +1,7 @@ <{include file='db:tdmdownloads_admin_header.tpl'}> -<{if $message_erreur}> +<{if $message_erreur|default:''}>
      <{$message_erreur}>
      <{/if}> @@ -53,14 +53,14 @@ <{/if}>
     
    - <{if $pagenav}> + <{if $pagenav|default:''}>
    <{$pagenav}>
    <{/if}> <{/if}> -<{if $download_detail}> +<{if $download_detail|default:''}> @@ -184,7 +184,7 @@
    <{$download.title}>
    <{/if}> -<{if $themeForm}> +<{if $themeForm|default:''}> <{$themeForm}> <{/if}> diff --git a/templates/admin/tdmdownloads_admin_field.tpl b/templates/admin/tdmdownloads_admin_field.tpl index 2360421..a3ee1b7 100644 --- a/templates/admin/tdmdownloads_admin_field.tpl +++ b/templates/admin/tdmdownloads_admin_field.tpl @@ -1,6 +1,6 @@ <{include file='db:tdmdownloads_admin_header.tpl'}> -<{if $message_erreur}> +<{if $message_erreur|default:''}>
    <{$message_erreur}>
    <{/if}> <{if $fields_list}> @@ -42,13 +42,13 @@ <{/if}>
     
    - <{if $pagenav}> + <{if $pagenav|default:''}>
    <{$pagenav}>
    <{/if}> <{/if}> -<{if $themeForm}> +<{if $themeForm|default:''}> <{$themeForm}> <{/if}> diff --git a/templates/admin/tdmdownloads_admin_footer.tpl b/templates/admin/tdmdownloads_admin_footer.tpl index 97d4dfa..10caf94 100644 --- a/templates/admin/tdmdownloads_admin_footer.tpl +++ b/templates/admin/tdmdownloads_admin_footer.tpl @@ -1,7 +1,7 @@
    XOOPS
    TDMDownloads <{$smarty.const._AM_TDMDOWNLOADS_MAINTAINEDBY}> Xoops Support Team - <{if $latestModRelease}> + <{if $latestModRelease|default:''}>


    diff --git a/templates/admin/tdmdownloads_admin_header.tpl b/templates/admin/tdmdownloads_admin_header.tpl index d0ef53e..63bf592 100644 --- a/templates/admin/tdmdownloads_admin_header.tpl +++ b/templates/admin/tdmdownloads_admin_header.tpl @@ -1,8 +1,8 @@
    - <{if $navigation}> + <{if $navigation|default:''}> <{$navigation}>  <{/if}> - <{if $buttons}> + <{if $buttons|default:''}> <{$buttons}>  <{/if}>
    diff --git a/templates/admin/tdmdownloads_admin_import.tpl b/templates/admin/tdmdownloads_admin_import.tpl index 553e89c..f3f228a 100644 --- a/templates/admin/tdmdownloads_admin_import.tpl +++ b/templates/admin/tdmdownloads_admin_import.tpl @@ -16,16 +16,16 @@ } <{include file='db:tdmdownloads_admin_header.tpl'}> -<{if $message_erreur}> +<{if $message_erreur|default:''}>
    <{$message_erreur}>
    <{/if}> -<{if $successes}> +<{if $successes|default:''}> <{foreach item=success from=$successes}> <{/foreach}> <{/if}> -<{if $errors}> +<{if $errors|default:''}> <{foreach item=error from=$errors}> <{$error.title}>: <{$error.info}>
    @@ -37,7 +37,7 @@
    <{$smarty.const._AM_TDMDOWNLOADS_IMPORT_WARNING}>
    <{/if}> -<{if $themeForm}> +<{if $themeForm|default:''}> <{$themeForm}> <{/if}> diff --git a/templates/admin/tdmdownloads_admin_index.tpl b/templates/admin/tdmdownloads_admin_index.tpl index 989a724..9990a9c 100644 --- a/templates/admin/tdmdownloads_admin_index.tpl +++ b/templates/admin/tdmdownloads_admin_index.tpl @@ -1,6 +1,6 @@ <{include file='db:tdmdownloads_admin_header.tpl'}> -
    <{$index}>
    +
    <{$index|default:''}>
    <{include file='db:tdmdownloads_admin_footer.tpl'}> diff --git a/templates/admin/tdmdownloads_admin_modified.tpl b/templates/admin/tdmdownloads_admin_modified.tpl index 80cef86..3c92aef 100644 --- a/templates/admin/tdmdownloads_admin_modified.tpl +++ b/templates/admin/tdmdownloads_admin_modified.tpl @@ -7,10 +7,10 @@ font-weight: bold; } -<{if $message_erreur}> +<{if $message_erreur|default:''}>
    <{$message_erreur}>
    <{/if}> -<{if $modified_list}> +<{if $modified_list|default:''}> @@ -35,13 +35,13 @@ <{/if}>
     
    - <{if $pagenav}> + <{if $pagenav|default:''}>
    <{$pagenav}>
    <{/if}> <{/if}> -<{if $compare_list}> +<{if $compare_list|default:''}> @@ -89,7 +89,7 @@ <{/if}> -<{if $themeForm}> +<{if $themeForm|default:''}> <{$themeForm}> <{/if}> diff --git a/templates/admin/tdmdownloads_admin_permissions.tpl b/templates/admin/tdmdownloads_admin_permissions.tpl index 580c0a1..8542f4c 100644 --- a/templates/admin/tdmdownloads_admin_permissions.tpl +++ b/templates/admin/tdmdownloads_admin_permissions.tpl @@ -1,6 +1,6 @@ <{include file='db:tdmdownloads_admin_header.tpl'}> -<{if $message_erreur}> +<{if $message_erreur|default:''}>
    <{$message_erreur}>
    <{/if}> <{if $form_select}> diff --git a/templates/tdmdownloads_brokenfile.tpl b/templates/tdmdownloads_brokenfile.tpl index 0f8da96..3ec8db8 100644 --- a/templates/tdmdownloads_brokenfile.tpl +++ b/templates/tdmdownloads_brokenfile.tpl @@ -16,7 +16,7 @@ - <{if $message_erreur}> + <{if $message_erreur|default:''}>
    <{$message_erreur}>
    <{/if}> diff --git a/templates/tdmdownloads_modfile.tpl b/templates/tdmdownloads_modfile.tpl index d4bccad..e642240 100644 --- a/templates/tdmdownloads_modfile.tpl +++ b/templates/tdmdownloads_modfile.tpl @@ -8,7 +8,7 @@
    <{$navigation}>
    - <{if $message_erreur}> + <{if $message_erreur|default:''}>
    <{$message_erreur}>
    <{/if}> diff --git a/templates/tdmdownloads_ratefile.tpl b/templates/tdmdownloads_ratefile.tpl index 0e02755..2444676 100644 --- a/templates/tdmdownloads_ratefile.tpl +++ b/templates/tdmdownloads_ratefile.tpl @@ -18,7 +18,7 @@ - <{if $message_erreur}> + <{if $message_erreur|default:''}>
    <{$message_erreur}>
    <{/if}> diff --git a/templates/tdmdownloads_submit.tpl b/templates/tdmdownloads_submit.tpl index ec9a486..cefb1af 100644 --- a/templates/tdmdownloads_submit.tpl +++ b/templates/tdmdownloads_submit.tpl @@ -18,7 +18,7 @@ - <{if $message_erreur}> + <{if $message_erreur|default:''}>
    <{$message_erreur}>
    <{/if}> From 5668b800b7d00c56f726971ad0195dba4dfcf416 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 8 Aug 2021 20:39:27 -0400 Subject: [PATCH 47/62] PHP8 Unknown format specifier "{" --- admin/about.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/admin/about.php b/admin/about.php index 81db103..8323b59 100644 --- a/admin/about.php +++ b/admin/about.php @@ -14,17 +14,20 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + +use Xmf\Module\Admin; + require __DIR__ . '/admin_header.php'; $templateMain = 'tdmdownloads_admin_about.tpl'; xoops_cp_header(); // pour file protection $xoopsUrl = parse_url(XOOPS_URL); -$xoopsUrl = str_replace('www.', '', $xoopsUrl['host']); +$xoopsUrl = str_replace('www.', '', $xoopsUrl['host']??''); $fileProtection = _AM_TDMDOWNLOADS_ABOUT_FILEPROTECTION_INFO1 . '

    ' . XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/downloads/' . '

    ' . _AM_TDMDOWNLOADS_ABOUT_FILEPROTECTION_INFO2 . '

    '; -$fileProtection .= 'RewriteEngine on' . '
    ' . 'RewriteCond %{HTTP_REFERER} !' . $xoopsUrl . "/.*$ [NC]
    ReWriteRule \.*$ - [F]"; +$fileProtection .= 'RewriteEngine on' . '
    ' . 'RewriteCond %s{HTTP_REFERER} !' . $xoopsUrl . '/.*$ [NC]
    ReWriteRule \.*$ - [F]'; -$adminObject = \Xmf\Module\Admin::getInstance(); +$adminObject = Admin::getInstance(); $adminObject->addInfoBox(_AM_TDMDOWNLOADS_ABOUT_FILEPROTECTION); $adminObject->addInfoBoxLine(sprintf($fileProtection, '', '', 'information'), ''); From 680d996a4c002f102e28b21577aeb5b688a84c0f Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 8 Aug 2021 20:45:36 -0400 Subject: [PATCH 48/62] add TestdataButtons --- admin/index.php | 56 +++--- class/Common/TestdataButtons.php | 106 +++++++++++ language/english/common.php | 290 ++++++++++++++++--------------- 3 files changed, 290 insertions(+), 162 deletions(-) create mode 100644 class/Common/TestdataButtons.php diff --git a/admin/index.php b/admin/index.php index 128e3b2..b6d99c1 100644 --- a/admin/index.php +++ b/admin/index.php @@ -14,6 +14,21 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + +use Xmf\Module\Admin; +use Xmf\Request; +use XoopsModules\Tdmdownloads\{ + Common\Configurator, + Common\TestdataButtons, + Forms, + Helper, + Utility +}; +/** @var Admin $adminObject */ +/** @var Configurator $configurator */ +/** @var Utility $utility */ +/** @var Helper $helper */ + require __DIR__ . '/admin_header.php'; xoops_cp_header(); @@ -41,7 +56,7 @@ // compte le nombre de demande de modifications $nb_modified = $modifiedHandler->getCount(); -$adminObject = \Xmf\Module\Admin::getInstance(); +$adminObject = Admin::getInstance(); $adminObject->addInfoBox(_MI_TDMDOWNLOADS_ADMENU2); if (0 == $nb_categories) { $adminObject->addInfoBoxLine(sprintf(_AM_TDMDOWNLOADS_INDEX_CATEGORIES, '' . $nb_categories . ''), '', 'Red'); @@ -74,14 +89,12 @@ //--------------------------- $adminObject->addConfigBoxLine(''); -$helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); +$helper = Helper::getInstance(); $helper->loadLanguage('common'); -/** @var \XoopsModules\Tdmdownloads\Common\Configurator $configurator */ -$configurator = new \XoopsModules\Tdmdownloads\Common\Configurator(); +$configurator = new Configurator(); -/** @var \XoopsModules\Tdmdownloads\Utility $utility */ -$utility = new \XoopsModules\Tdmdownloads\Utility(); +$utility = new Utility(); foreach (array_keys($configurator->uploadFolders) as $i) { $utility::createFolder($configurator->uploadFolders[$i]); @@ -92,30 +105,29 @@ $adminObject->displayNavigation(basename(__FILE__)); //check for latest release -//$newRelease = $utility::checkVerModule($helper); +//$newRelease = $utility->checkVerModule($helper); //if (!empty($newRelease)) { // $adminObject->addItemButton($newRelease[0], $newRelease[1], 'download', 'style="color : Red"'); //} -//------------- Test Data ---------------------------- - +//------------- Test Data Buttons ---------------------------- if ($helper->getConfig('displaySampleButton')) { - xoops_loadLanguage('admin/modulesadmin', 'system'); - - require dirname(__DIR__) . '/testdata/index.php'; - - $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=load', 'add'); - - $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=save', 'add'); - // $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), '__DIR__ . /../../testdata/index.php?op=exportschema', 'add'); + TestdataButtons::loadButtonConfig($adminObject); + $adminObject->displayButton('left', ''); } - -//------------- End Test Data ---------------------------- - -$adminObject->displayButton('left', ''); +$op = Request::getString('op', 0, 'GET'); +switch ($op) { + case 'hide_buttons': + TestdataButtons::hideButtons(); + break; + case 'show_buttons': + TestdataButtons::showButtons(); + break; +} +//------------- End Test Data Buttons ---------------------------- $adminObject->displayIndex(); - echo $utility::getServerStats(); + //codeDump(__FILE__); require __DIR__ . '/admin_footer.php'; diff --git a/class/Common/TestdataButtons.php b/class/Common/TestdataButtons.php new file mode 100644 index 0000000..56b7202 --- /dev/null +++ b/class/Common/TestdataButtons.php @@ -0,0 +1,106 @@ + + * @copyright {@link https://xoops.org/ XOOPS Project} + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) + */ + +use Xmf\{ + Module\Admin, + Request, + Yaml +}; +use XoopsModules\Tdmdownloads\{ + Constants, + Helper +}; + +/** @var Helper $helper */ + +/** + * Class TestdataButtons + * + * Contains methods to create the Test buttons and change their visibility + */ +class TestdataButtons +{ + /** Button status constants */ + private const SHOW_BUTTONS = 1; + private const HIDE_BUTTONS = 0; + + /** + * Load the test button configuration + * + * @param \Xmf\Module\Admin $adminObject + * + * @return void + */ + public static function loadButtonConfig(Admin $adminObject): void + { + $moduleDirName = \basename(\dirname(__DIR__, 2)); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); + $helper = Helper::getInstance(); + $yamlFile = $helper->path('/config/admin.yml'); + $config = Yaml::readWrapped($yamlFile); // work with phpmyadmin YAML dumps + $displaySampleButton = $config['displaySampleButton']; + + if (self::SHOW_BUTTONS == $displaySampleButton) { + \xoops_loadLanguage('admin/modulesadmin', 'system'); + $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA'), $helper->url('testdata/index.php?op=load'), 'add'); + $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), $helper->url('testdata/index.php?op=save'), 'add'); + $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA'), $helper->url('testdata/index.php?op=clear'), 'alert'); + // $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), $helper->url( 'testdata/index.php?op=exportschema'), 'add'); + $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete'); + } else { + $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add'); + // $displaySampleButton = $config['displaySampleButton']; + } + } + + /** + * Hide the test buttons + * + * @return void + */ + public static function hideButtons(): void + { + $helper = Helper::getInstance(); + $yamlFile = $helper->path('config/admin.yml'); + $app = []; + $app['displaySampleButton'] = self::HIDE_BUTTONS; + Yaml::save($app, $yamlFile); + $helper->redirect('admin/index.php', Constants::REDIRECT_DELAY_NONE, ''); + } + + /** + * Show the test buttons + * + * @return void + */ + public static function showButtons(): void + { + $helper = Helper::getInstance(); + $yamlFile = $helper->path('config/admin.yml'); + $app = []; + $app['displaySampleButton'] = self::SHOW_BUTTONS; + Yaml::save($app, $yamlFile); + $helper->redirect('admin/index.php', Constants::REDIRECT_DELAY_NONE, ''); + } +} diff --git a/language/english/common.php b/language/english/common.php index b2ba212..69b6b5b 100644 --- a/language/english/common.php +++ b/language/english/common.php @@ -19,168 +19,178 @@ * @since 3.23 * @author Xoops Development Team */ -$moduleDirName = basename(dirname(dirname(__DIR__))); +$moduleDirName = basename(dirname(__DIR__, 2)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); -define('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS', 'GD library support: '); -define('CO_' . $moduleDirNameUpper . '_GDLIBVERSION', 'GD Library version: '); -define('CO_' . $moduleDirNameUpper . '_GDOFF', "Disabled (No thumbnails available)"); -define('CO_' . $moduleDirNameUpper . '_GDON', "Enabled (Thumbsnails available)"); -define('CO_' . $moduleDirNameUpper . '_IMAGEINFO', 'Server status'); -define('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE', 'Max post size permitted (post_max_size directive in php.ini): '); -define('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE', 'Max upload size permitted (upload_max_filesize directive in php.ini): '); -define('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT', 'Memory limit (memory_limit directive in php.ini): '); -define('CO_' . $moduleDirNameUpper . '_METAVERSION', "Downloads meta version: "); -define('CO_' . $moduleDirNameUpper . '_OFF', "OFF"); -define('CO_' . $moduleDirNameUpper . '_ON', "ON"); -define('CO_' . $moduleDirNameUpper . '_SERVERPATH', 'Server path to XOOPS root: '); -define('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS', 'Server uploads status: '); -define('CO_' . $moduleDirNameUpper . '_SPHPINI', "Information taken from PHP ini file:"); -define('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC', 'Note. Upload path *MUST* contain the full server path of your upload folder.'); - -define('CO_' . $moduleDirNameUpper . '_PRINT', "Print"); -define('CO_' . $moduleDirNameUpper . '_PDF', "Create PDF"); - -define('CO_' . $moduleDirNameUpper . '_UPGRADEFAILED0', "Update failed - couldn't rename field '%s'"); -define('CO_' . $moduleDirNameUpper . '_UPGRADEFAILED1', "Update failed - couldn't add new fields"); -define('CO_' . $moduleDirNameUpper . '_UPGRADEFAILED2', "Update failed - couldn't rename table '%s'"); -define('CO_' . $moduleDirNameUpper . '_ERROR_COLUMN', 'Could not create column in database : %s'); -define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS', 'This module requires XOOPS %s+ (%s installed)'); -define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP', 'This module requires PHP version %s+ (%s installed)'); -define('CO_' . $moduleDirNameUpper . '_ERROR_TAG_REMOVAL', 'Could not remove tags from Tag Module'); - -define('CO_' . $moduleDirNameUpper . '_FOLDERS_DELETED_OK', 'Upload Folders have been deleted'); +\define('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS', 'GD library support: '); +\define('CO_' . $moduleDirNameUpper . '_GDLIBVERSION', 'GD Library version: '); +\define('CO_' . $moduleDirNameUpper . '_GDOFF', "Disabled (No thumbnails available)"); +\define('CO_' . $moduleDirNameUpper . '_GDON', "Enabled (Thumbsnails available)"); +\define('CO_' . $moduleDirNameUpper . '_IMAGEINFO', 'Server status'); +\define('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE', 'Max post size permitted (post_max_size directive in php.ini): '); +\define('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE', 'Max upload size permitted (upload_max_filesize directive in php.ini): '); +\define('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT', 'Memory limit (memory_limit directive in php.ini): '); +\define('CO_' . $moduleDirNameUpper . '_METAVERSION', "Downloads meta version: "); +\define('CO_' . $moduleDirNameUpper . '_OFF', "OFF"); +\define('CO_' . $moduleDirNameUpper . '_ON', "ON"); +\define('CO_' . $moduleDirNameUpper . '_SERVERPATH', 'Server path to XOOPS root: '); +\define('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS', 'Server uploads status: '); +\define('CO_' . $moduleDirNameUpper . '_SPHPINI', "Information taken from PHP ini file:"); +\define('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC', 'Note. Upload path *MUST* contain the full server path of your upload folder.'); + +\define('CO_' . $moduleDirNameUpper . '_PRINT', "Print"); +\define('CO_' . $moduleDirNameUpper . '_PDF', "Create PDF"); + +\define('CO_' . $moduleDirNameUpper . '_UPGRADEFAILED0', "Update failed - couldn't rename field '%s'"); +\define('CO_' . $moduleDirNameUpper . '_UPGRADEFAILED1', "Update failed - couldn't add new fields"); +\define('CO_' . $moduleDirNameUpper . '_UPGRADEFAILED2', "Update failed - couldn't rename table '%s'"); +\define('CO_' . $moduleDirNameUpper . '_ERROR_COLUMN', 'Could not create column in database : %s'); +\define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS', 'This module requires XOOPS %s+ (%s installed)'); +\define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP', 'This module requires PHP version %s+ (%s installed)'); +\define('CO_' . $moduleDirNameUpper . '_ERROR_TAG_REMOVAL', 'Could not remove tags from Tag Module'); + +\define('CO_' . $moduleDirNameUpper . '_FOLDERS_DELETED_OK', 'Upload Folders have been deleted'); // Error Msgs -define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH', 'Could not delete %s directory'); -define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_REMOVE', 'Could not delete %s'); -define('CO_' . $moduleDirNameUpper . '_ERROR_NO_PLUGIN', 'Could not load plugin'); +\define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH', 'Could not delete %s directory'); +\define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_REMOVE', 'Could not delete %s'); +\define('CO_' . $moduleDirNameUpper . '_ERROR_NO_PLUGIN', 'Could not load plugin'); //Help -define('CO_' . $moduleDirNameUpper . '_DIRNAME', basename(dirname(dirname(__DIR__)))); -define('CO_' . $moduleDirNameUpper . '_HELP_HEADER', __DIR__ . '/help/helpheader.tpl'); -define('CO_' . $moduleDirNameUpper . '_BACK_2_ADMIN', 'Back to Administration of '); -define('CO_' . $moduleDirNameUpper . '_OVERVIEW', 'Overview'); +\define('CO_' . $moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__, 2))); +\define('CO_' . $moduleDirNameUpper . '_HELP_HEADER', __DIR__ . '/help/helpheader.tpl'); +\define('CO_' . $moduleDirNameUpper . '_BACK_2_ADMIN', 'Back to Administration of '); +\define('CO_' . $moduleDirNameUpper . '_OVERVIEW', 'Overview'); -//define('CO_' . $moduleDirNameUpper . '_HELP_DIR', __DIR__); +//\define('CO_' . $moduleDirNameUpper . '_HELP_DIR', __DIR__); //help multi-page -define('CO_' . $moduleDirNameUpper . '_DISCLAIMER', 'Disclaimer'); -define('CO_' . $moduleDirNameUpper . '_LICENSE', 'License'); -define('CO_' . $moduleDirNameUpper . '_SUPPORT', 'Support'); +\define('CO_' . $moduleDirNameUpper . '_DISCLAIMER', 'Disclaimer'); +\define('CO_' . $moduleDirNameUpper . '_LICENSE', 'License'); +\define('CO_' . $moduleDirNameUpper . '_SUPPORT', 'Support'); //Sample Data -define('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA', 'Import Sample Data (will delete ALL current data)'); -define('CO_' . $moduleDirNameUpper . '_' . 'SAMPLEDATA_SUCCESS', 'Sample Date uploaded successfully'); -define('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA', 'Export Tables to YAML'); -define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON', 'Show Sample Button?'); -define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON_DESC', 'If yes, the "Add Sample Data" button will be visible to the Admin. It is Yes as a default for first installation.'); -define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA', 'Export DB Schema to YAML'); -define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS', 'Export DB Schema to YAML was a success'); -define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR', 'ERROR: Export of DB Schema to YAML failed'); -define('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA_OK', 'Are you sure to Import Sample Data? (It will delete ALL current data)'); -define('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS', 'Hide the Import buttons)'); -define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS', 'Show the Import buttons)'); -define('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM', 'Confirm'); +\define('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA', 'Import Sample Data (will delete ALL current data)'); +\define('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_CONFIRM', 'Are you sure to Import Sample Data? (It will delete ALL current data)'); +\define('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_SUCCESS', 'Sample Date saved successfully'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA', 'Export Tables to YAML'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA_SUCCESS', 'Export Tables to YAML successfully'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA', 'Clear the Sample Data'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA_OK', 'The Sample Data has been cleared'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA_CONFIRM', 'Are you sure to Clear Sample Data? (It will delete ALL current data)'); +\define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA', 'Export DB Schema to YAML'); +\define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS', 'Export DB Schema to YAML was a success'); +\define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR', 'ERROR: Export of DB Schema to YAML failed'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON', 'Show Sample Button?'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON_DESC', 'If yes, the "Add Sample Data" button will be visible to the Admin. It is Yes as a default for first installation.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS', 'Hide the Import buttons)'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS', 'Show the Import buttons)'); + +\define('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM', 'Confirm'); //letter choice -define('CO_' . $moduleDirNameUpper . '_' . 'BROWSETOTOPIC', "Browse items alphabetically"); -define('CO_' . $moduleDirNameUpper . '_' . 'OTHER', 'Other'); -define('CO_' . $moduleDirNameUpper . '_' . 'ALL', 'All'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BROWSETOTOPIC', "Browse items alphabetically"); +\define('CO_' . $moduleDirNameUpper . '_' . 'OTHER', 'Other'); +\define('CO_' . $moduleDirNameUpper . '_' . 'ALL', 'All'); // block defines -define('CO_' . $moduleDirNameUpper . '_' . 'ACCESSRIGHTS', 'Access Rights'); -define('CO_' . $moduleDirNameUpper . '_' . 'ACTION', 'Action'); -define('CO_' . $moduleDirNameUpper . '_' . 'ACTIVERIGHTS', 'Active Rights'); -define('CO_' . $moduleDirNameUpper . '_' . 'BADMIN', 'Block Administration'); -define('CO_' . $moduleDirNameUpper . '_' . 'BLKDESC', 'Description'); -define('CO_' . $moduleDirNameUpper . '_' . 'CBCENTER', 'Center Middle'); -define('CO_' . $moduleDirNameUpper . '_' . 'CBLEFT', 'Center Left'); -define('CO_' . $moduleDirNameUpper . '_' . 'CBRIGHT', 'Center Right'); -define('CO_' . $moduleDirNameUpper . '_' . 'SBLEFT', 'Left'); -define('CO_' . $moduleDirNameUpper . '_' . 'SBRIGHT', 'Right'); -define('CO_' . $moduleDirNameUpper . '_' . 'SIDE', 'Alignment'); -define('CO_' . $moduleDirNameUpper . '_' . 'TITLE', 'Title'); -define('CO_' . $moduleDirNameUpper . '_' . 'VISIBLE', 'Visible'); -define('CO_' . $moduleDirNameUpper . '_' . 'VISIBLEIN', 'Visible In'); -define('CO_' . $moduleDirNameUpper . '_' . 'WEIGHT', 'Weight'); - -define('CO_' . $moduleDirNameUpper . '_' . 'PERMISSIONS', 'Permissions'); -define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS', 'Blocks Admin'); -define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_DESC', 'Blocks/Group Admin'); - -define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_MANAGMENT', 'Manage'); -define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_ADDBLOCK', 'Add a new block'); -define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_EDITBLOCK', 'Edit a block'); -define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK', 'Clone a block'); +\define('CO_' . $moduleDirNameUpper . '_' . 'ACCESSRIGHTS', 'Access Rights'); +\define('CO_' . $moduleDirNameUpper . '_' . 'ACTION', 'Action'); +\define('CO_' . $moduleDirNameUpper . '_' . 'ACTIVERIGHTS', 'Active Rights'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BADMIN', 'Block Administration'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BLKDESC', 'Description'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CBCENTER', 'Center Middle'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CBLEFT', 'Center Left'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CBRIGHT', 'Center Right'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SBLEFT', 'Left'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SBRIGHT', 'Right'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SIDE', 'Alignment'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TITLE', 'Title'); +\define('CO_' . $moduleDirNameUpper . '_' . 'VISIBLE', 'Visible'); +\define('CO_' . $moduleDirNameUpper . '_' . 'VISIBLEIN', 'Visible In'); +\define('CO_' . $moduleDirNameUpper . '_' . 'WEIGHT', 'Weight'); + +\define('CO_' . $moduleDirNameUpper . '_' . 'PERMISSIONS', 'Permissions'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS', 'Blocks Admin'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_DESC', 'Blocks/Group Admin'); + +\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_MANAGMENT', 'Manage'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_ADDBLOCK', 'Add a new block'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_EDITBLOCK', 'Edit a block'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK', 'Clone a block'); //myblocksadmin -define('CO_' . $moduleDirNameUpper . '_' . 'AGDS', 'Admin Groups'); -define('CO_' . $moduleDirNameUpper . '_' . 'BCACHETIME', 'Cache Time'); -define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_ADMIN', 'Blocks Admin'); +\define('CO_' . $moduleDirNameUpper . '_' . 'AGDS', 'Admin Groups'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BCACHETIME', 'Cache Time'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_ADMIN', 'Blocks Admin'); +\define('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS', 'Update successful'); //Template Admin -define('CO_' . $moduleDirNameUpper . '_' . 'TPLSETS', 'Template Management'); -define('CO_' . $moduleDirNameUpper . '_' . 'GENERATE', 'Generate'); -define('CO_' . $moduleDirNameUpper . '_' . 'FILENAME', 'File Name'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TPLSETS', 'Template Management'); +\define('CO_' . $moduleDirNameUpper . '_' . 'GENERATE', 'Generate'); +\define('CO_' . $moduleDirNameUpper . '_' . 'FILENAME', 'File Name'); //Menu -define('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_MIGRATE', 'Migrate'); -define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_YES', 'Folder "%s" exist'); -define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_NO', 'Folder "%s" does not exist. Create the specified folder with CHMOD 777.'); -define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS', 'Show Development Tools Button?'); -define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS_DESC', 'If yes, the "Migrate" Tab and other Development tools will be visible to the Admin.'); -define('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_FEEDBACK', 'Feedback'); +\define('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_MIGRATE', 'Migrate'); +\define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_YES', 'Folder "%s" exist'); +\define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_NO', 'Folder "%s" does not exist. Create the specified folder with CHMOD 777.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS', 'Show Development Tools Button?'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS_DESC', 'If yes, the "Migrate" Tab and other Development tools will be visible to the Admin.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_FEEDBACK', 'Feedback'); +\define('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_OK', 'Database migrated to current schema.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_WARNING', 'Warning! This is intended for developers only. Confirm write schema file from current database.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_SCHEMA_OK', 'Current schema file written'); //Latest Version Check -define('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION', 'New Version: '); - -//define('CO_' . $moduleDirNameUpper . '_FOLDER_YES', 'Folder "%s" exist'); -//define('CO_' . $moduleDirNameUpper . '_FOLDER_NO', 'Folder "%s" does not exist. Create the specified folder with CHMOD 777.'); - -//Uploader -define('CO_' . $moduleDirNameUpper . '_' . 'IMAGES_UPLOAD', 'Upload Files'); - -// ---------------- Errors ---------------- -define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEIMG_THUMBS', 'Error when creating thumb image: %s'); -define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEIMG_MEDIUM', 'Error when creating medium image: %s'); -define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEWM_MEDIUM', 'Error when adding watermark to medium image: %s (reason: %g)'); -define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEWM_LARGE', 'Error when adding watermark to large image: %s (reason: %g)'); - -// Album buttons -define('CO_' . $moduleDirNameUpper . '_' . 'ALBUM_ADD', 'Add Category'); -define('CO_' . $moduleDirNameUpper . '_' . 'ALBUM_EDIT', 'Edit Category'); - -//Uploader -define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_ADD', 'Add Field'); -define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_EDIT', 'Edit Field'); -define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_TITLE', 'Title'); -define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_FID', 'ID'); -define('CO_' . $moduleDirNameUpper . '_' . 'FORMIMAGE_PATH', 'File Path'); -define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_IMG', 'File Field'); - -define('CO_' . $moduleDirNameUpper . '_' . 'FORMUPLOAD', 'Upload'); -define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_WEIGHT', 'Weight'); -define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_STATUS', 'Status'); -define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_SEARCH', 'Search'); -define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_STATUS_DEF', 'Status Defi'); - -// fine uploader -define('CO_' . $moduleDirNameUpper . '_' . 'FU_SUBMIT', 'Submitting file: '); -define('CO_' . $moduleDirNameUpper . '_' . 'FU_SUBMITTED', 'File successfully checked, please upload'); -define('CO_' . $moduleDirNameUpper . '_' . 'FU_UPLOAD', 'Upload file: '); -define('CO_' . $moduleDirNameUpper . '_' . 'FU_FAILED', 'Errors occurred during uploading the file'); -define('CO_' . $moduleDirNameUpper . '_' . 'FU_SUCCEEDED', 'Successfully uploaded all files'); - -define('CO_' . $moduleDirNameUpper . '_' . 'SELECT', 'Select Category'); -define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_CATPID', 'Error: parent category not found'); +\define('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION', 'New Version: '); + +//DirectoryChecker +\define('CO_' . $moduleDirNameUpper . '_' . 'AVAILABLE', "Available"); +\define('CO_' . $moduleDirNameUpper . '_' . 'NOTAVAILABLE', "Not available"); +\define('CO_' . $moduleDirNameUpper . '_' . 'NOTWRITABLE', "Should have permission ( %d ), but it has ( %d )"); +\define('CO_' . $moduleDirNameUpper . '_' . 'CREATETHEDIR', 'Create it'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SETMPERM', 'Set the permission'); +\define('CO_' . $moduleDirNameUpper . '_' . 'DIRCREATED', 'The directory has been created'); +\define('CO_' . $moduleDirNameUpper . '_' . 'DIRNOTCREATED', 'The directory cannot be created'); +\define('CO_' . $moduleDirNameUpper . '_' . 'PERMSET', 'The permission has been set'); +\define('CO_' . $moduleDirNameUpper . '_' . 'PERMNOTSET', 'The permission cannot be set'); + +//FileChecker +//\define('CO_' . $moduleDirNameUpper . '_' . 'AVAILABLE', "Available"); +//\define('CO_' . $moduleDirNameUpper . '_' . 'NOTAVAILABLE', "Not available"); +//\define('CO_' . $moduleDirNameUpper . '_' . 'NOTWRITABLE', "Should have permission ( %d ), but it has ( %d )"); +//\define('CO_' . $moduleDirNameUpper . '_' . 'COPYTHEFILE', 'Copy it'); +//\define('CO_' . $moduleDirNameUpper . '_' . 'CREATETHEFILE', 'Create it'); +//\define('CO_' . $moduleDirNameUpper . '_' . 'SETMPERM', 'Set the permission'); + +\define('CO_' . $moduleDirNameUpper . '_' . 'FILECOPIED', 'The file has been copied'); +\define('CO_' . $moduleDirNameUpper . '_' . 'FILENOTCOPIED', 'The file cannot be copied'); + +//\define('CO_' . $moduleDirNameUpper . '_' . 'PERMSET', 'The permission has been set'); +//\define('CO_' . $moduleDirNameUpper . '_' . 'PERMNOTSET', 'The permission cannot be set'); //image config -define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH', 'Image Display Width'); -define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH_DSC', 'Display width for image'); -define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_HEIGHT', 'Image Display Height'); -define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_HEIGHT_DSC', 'Display height for image'); -define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG', '--- EXTERNAL Image configuration --- '); -define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG_DSC', ''); -define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH', 'Image Upload path'); -define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH_DSC', 'Path for uploading images'); +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH', 'Image Display Width'); +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH_DSC', 'Display width for image'); +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_HEIGHT', 'Image Display Height'); +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_HEIGHT_DSC', 'Display height for image'); +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG', '--- EXTERNAL Image configuration --- '); +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG_DSC', ''); +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH', 'Image Upload path'); +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH_DSC', 'Path for uploading images'); + +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_FILE_SIZE', 'Image File Size (in Bytes)'); +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_FILE_SIZE_DSC','The maximum file size of the image file (in Bytes)'); + +//Preferences +\define('CO_' . $moduleDirNameUpper . '_' . 'TRUNCATE_LENGTH', 'Number of Characters to truncate to the long text field'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TRUNCATE_LENGTH_DESC', 'Set the maximum number of characters to truncate the long text fields'); + +//Module Stats +\define('CO_' . $moduleDirNameUpper . '_' . 'STATS_SUMMARY', 'Module Statistics'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_CATEGORIES', 'Categories:'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_ITEMS', 'Items'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_OFFLINE', 'Offline'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_PUBLISHED', 'Published'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_REJECTED', 'Rejected'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_SUBMITTED', 'Submitted'); From 0dfb2a8b6d45d82a77d3d3e106f1de131b455afa Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 8 Aug 2021 21:02:56 -0400 Subject: [PATCH 49/62] Testdata --- class/Common/Configurator.php | 46 ++-- config/config.php | 8 +- testdata/english/index.php | 2 + testdata/english/tdmdownloads_cat.yml | 11 +- testdata/english/tdmdownloads_downloads.yml | 12 +- testdata/english/tdmdownloads_field.yml | 28 +-- testdata/english/tdmdownloads_fielddata.yml | 44 +--- testdata/index.php | 209 +++++++++++------- testdata/uploads/blank.png | Bin 0 -> 155 bytes testdata/uploads/category/blank.png | Bin 0 -> 155 bytes testdata/uploads/category/index.php | 2 + testdata/uploads/downloads/index.php | 2 + testdata/uploads/images/cats/blank.png | Bin 0 -> 155 bytes testdata/uploads/images/cats/calculator.png | Bin 0 -> 1593 bytes testdata/uploads/images/cats/cart_add.png | Bin 0 -> 1851 bytes testdata/uploads/images/cats/cash_stack.png | Bin 0 -> 1522 bytes testdata/uploads/images/cats/category.png | Bin 0 -> 2237 bytes testdata/uploads/images/cats/database_go.png | Bin 0 -> 1714 bytes testdata/uploads/images/cats/index.php | 2 + testdata/uploads/images/field/about.png | Bin 0 -> 2864 bytes testdata/uploads/images/field/add.png | Bin 0 -> 942 bytes testdata/uploads/images/field/bg_button.gif | Bin 0 -> 211 bytes testdata/uploads/images/field/blank.png | Bin 0 -> 155 bytes testdata/uploads/images/field/broken.png | Bin 0 -> 2630 bytes testdata/uploads/images/field/category.png | Bin 0 -> 2322 bytes testdata/uploads/images/field/downloads.png | Bin 0 -> 1850 bytes testdata/uploads/images/field/field.png | Bin 0 -> 2388 bytes testdata/uploads/images/field/import.png | Bin 0 -> 1165 bytes testdata/uploads/images/field/index.php | 2 + testdata/uploads/images/field/list.png | Bin 0 -> 2206 bytes testdata/uploads/images/field/modified.png | Bin 0 -> 3064 bytes testdata/uploads/images/field/permissions.png | Bin 0 -> 1679 bytes testdata/uploads/images/index.php | 2 + testdata/uploads/images/shots/blank.png | Bin 0 -> 155 bytes testdata/uploads/images/shots/index.php | 2 + testdata/uploads/screenshots/blank.png | Bin 0 -> 155 bytes testdata/uploads/screenshots/index.php | 2 + 37 files changed, 185 insertions(+), 189 deletions(-) create mode 100644 testdata/english/index.php create mode 100644 testdata/uploads/blank.png create mode 100644 testdata/uploads/category/blank.png create mode 100644 testdata/uploads/category/index.php create mode 100644 testdata/uploads/downloads/index.php create mode 100644 testdata/uploads/images/cats/blank.png create mode 100644 testdata/uploads/images/cats/calculator.png create mode 100644 testdata/uploads/images/cats/cart_add.png create mode 100644 testdata/uploads/images/cats/cash_stack.png create mode 100644 testdata/uploads/images/cats/category.png create mode 100644 testdata/uploads/images/cats/database_go.png create mode 100644 testdata/uploads/images/cats/index.php create mode 100644 testdata/uploads/images/field/about.png create mode 100644 testdata/uploads/images/field/add.png create mode 100644 testdata/uploads/images/field/bg_button.gif create mode 100644 testdata/uploads/images/field/blank.png create mode 100644 testdata/uploads/images/field/broken.png create mode 100644 testdata/uploads/images/field/category.png create mode 100644 testdata/uploads/images/field/downloads.png create mode 100644 testdata/uploads/images/field/field.png create mode 100644 testdata/uploads/images/field/import.png create mode 100644 testdata/uploads/images/field/index.php create mode 100644 testdata/uploads/images/field/list.png create mode 100644 testdata/uploads/images/field/modified.png create mode 100644 testdata/uploads/images/field/permissions.png create mode 100644 testdata/uploads/images/index.php create mode 100644 testdata/uploads/images/shots/blank.png create mode 100644 testdata/uploads/images/shots/index.php create mode 100644 testdata/uploads/screenshots/blank.png create mode 100644 testdata/uploads/screenshots/index.php diff --git a/class/Common/Configurator.php b/class/Common/Configurator.php index 4dbecb8..c615d82 100644 --- a/class/Common/Configurator.php +++ b/class/Common/Configurator.php @@ -27,14 +27,16 @@ class Configurator { public $name; - public $paths = []; - public $uploadFolders = []; - public $copyBlankFiles = []; + public $paths = []; + public $uploadFolders = []; + public $copyBlankFiles = []; public $copyTestFolders = []; public $templateFolders = []; - public $oldFiles = []; - public $oldFolders = []; - public $renameTables = []; + public $oldFiles = []; + public $oldFolders = []; + public $renameTables = []; + public $renameColumns = []; + public $moduleStats = []; public $modCopyright; public $icons; @@ -43,30 +45,24 @@ class Configurator */ public function __construct() { - $config = include \dirname(\dirname(__DIR__)) . '/config/config.php'; - $this->name = $config->name; - - $this->paths = $config->paths; - - $this->uploadFolders = $config->uploadFolders; - - $this->copyBlankFiles = $config->copyBlankFiles; + $config = require \dirname(__DIR__, 2) . '/config/config.php'; + $this->name = $config->name; + $this->paths = $config->paths; + $this->uploadFolders = $config->uploadFolders; + $this->copyBlankFiles = $config->copyBlankFiles; $this->copyTestFolders = $config->copyTestFolders; - $this->templateFolders = $config->templateFolders; + $this->oldFiles = $config->oldFiles; + $this->oldFolders = $config->oldFolders; + $this->renameTables = $config->renameTables; + $this->renameColumns = $config->renameColumns; + $this->moduleStats = $config->moduleStats; + $this->modCopyright = $config->modCopyright; - $this->oldFiles = $config->oldFiles; - - $this->oldFolders = $config->oldFolders; - - $this->renameTables = $config->renameTables; - - $this->modCopyright = $config->modCopyright; - - $this->icons = include \dirname(\dirname(__DIR__)) . '/config/icons.php'; + $this->icons = include \dirname(__DIR__, 2) . '/config/icons.php'; + $this->paths = include \dirname(__DIR__, 2) . '/config/paths.php'; - $this->paths = include \dirname(\dirname(__DIR__)) . '/config/paths.php'; } } diff --git a/config/config.php b/config/config.php index 65daaec..edf7544 100644 --- a/config/config.php +++ b/config/config.php @@ -17,7 +17,9 @@ * @since * @author XOOPS Development Team */ -$moduleDirName = basename(dirname(__DIR__)); +use Xmf\Module\Admin; + +$moduleDirName = \basename(\dirname(__DIR__)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); return (object)[ @@ -78,11 +80,13 @@ 'renameTables' => [// 'XX_archive' => 'ZZZZ_archive', ], + 'renameColumns' => [// 'extcal_event' => ['from' => 'event_etablissement', 'to' => 'event_location'], + ], 'moduleStats' => [ // 'totalcategories' => $helper->getHandler('Category')->getCategoriesCount(-1), // 'totalitems' => $helper->getHandler('Item')->getItemsCount(), // 'totalsubmitted' => $helper->getHandler('Item')->getItemsCount(-1, [Constants::PUBLISHER_STATUS_SUBMITTED]), ], 'modCopyright' => " - XOOPS Project", + XOOPS Project", ]; diff --git a/testdata/english/index.php b/testdata/english/index.php new file mode 100644 index 0000000..4ae18fd --- /dev/null +++ b/testdata/english/index.php @@ -0,0 +1,2 @@ +loadLanguage('common'); + switch ($op) { case 'load': - if (Request::hasVar('ok', 'REQUEST') && 1 === Request::getInt('ok', 0, 'REQUEST')) { + if (Request::hasVar('ok', 'REQUEST') && 1 === Request::getInt('ok', 0)) { if (!$GLOBALS['xoopsSecurity']->check()) { - redirect_header('../admin/index.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); + \redirect_header($helper->url('admin/index.php'), 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); } - loadSampleData(); } else { xoops_cp_header(); - - xoops_confirm( - [ - 'ok' => 1, - 'op' => 'load', - ], - 'index.php', - sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA_OK')), - constant( - 'CO_' . $moduleDirNameUpper . '_' . 'CONFIRM' - ), - true - ); - + xoops_confirm(['ok' => 1, 'op' => 'load'], 'index.php', \sprintf(\constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_CONFIRM')), \constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true); xoops_cp_footer(); } break; case 'save': saveSampleData(); break; + case 'clear': + clearSampleData(); + break; } // XMF TableLoad for SAMPLE data @@ -68,103 +65,157 @@ function loadSampleData() { global $xoopsConfig; + $moduleDirName = \basename(\dirname(__DIR__)); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); - $moduleDirName = basename(dirname(__DIR__)); - - $moduleDirNameUpper = mb_strtoupper($moduleDirName); - - $utility = new Tdmdownloads\Utility(); + $utility = new Utility(); + $configurator = new Configurator(); - $configurator = new Common\Configurator(); - - $tables = Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); + $tables = \Xmf\Module\Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); $language = 'english/'; - - if (is_dir(__DIR__ . '/' . $xoopsConfig['language'])) { + if (\is_dir(__DIR__ . '/' . $xoopsConfig['language'])) { $language = $xoopsConfig['language'] . '/'; } + // load module tables foreach ($tables as $table) { $tabledata = Yaml::readWrapped($language . $table . '.yml'); - - if (is_array($tabledata)) { - TableLoad::truncateTable($table); - - TableLoad::loadTableFromArray($table, $tabledata); - } + TableLoad::truncateTable($table); + TableLoad::loadTableFromArray($table, $tabledata); } - // --- COPY test folder files --------------- + // load permissions + $table = 'group_permission'; + $tabledata = Yaml::readWrapped($language . $table . '.yml'); + $mid = \Xmf\Module\Helper::getHelper($moduleDirName)->getModule()->getVar('mid'); + loadTableFromArrayWithReplace($table, $tabledata, 'gperm_modid', $mid); - if (is_array($configurator->copyTestFolders) - && count( - $configurator->copyTestFolders - ) > 0) { + // --- COPY test folder files --------------- + if (\is_array($configurator->copyTestFolders) && \count($configurator->copyTestFolders) > 0) { // $file = dirname(__DIR__) . '/testdata/images/'; - - foreach ( - array_keys( - $configurator->copyTestFolders - ) as $i - ) { - $src = $configurator->copyTestFolders[$i][0]; - + foreach (\array_keys($configurator->copyTestFolders) as $i) { + $src = $configurator->copyTestFolders[$i][0]; $dest = $configurator->copyTestFolders[$i][1]; - $utility::rcopy($src, $dest); } } - - redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'SAMPLEDATA_SUCCESS')); + \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_SUCCESS')); } function saveSampleData() { global $xoopsConfig; - - $moduleDirName = basename(dirname(__DIR__)); - + $moduleDirName = \basename(\dirname(__DIR__)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $helper = Helper::getInstance(); + $tables = $helper->getModule()->getInfo('tables'); - $tables = Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); - - $language = 'english/'; - - if (is_dir(__DIR__ . '/' . $xoopsConfig['language'])) { - $language = $xoopsConfig['language'] . '/'; - } - - $languageFolder = __DIR__ . '/' . $language; - - if (!file_exists($languageFolder . '/')) { + $languageFolder = __DIR__ . '/' . $xoopsConfig['language']; + if (!\file_exists($languageFolder . '/')) { Utility::createFolder($languageFolder . '/'); } - $exportFolder = $languageFolder . '/Exports-' . date('Y-m-d-H-i-s') . '/'; - Utility::createFolder($exportFolder); + // save module tables foreach ($tables as $table) { TableLoad::saveTableToYamlFile($table, $exportFolder . $table . '.yml'); } - redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'SAMPLEDATA_SUCCESS')); + // save permissions + $criteria = new \CriteriaCompo(); + $criteria->add(new \Criteria('gperm_modid', $helper->getModule()->getVar('mid'))); + $skipColumns[] = 'gperm_id'; + TableLoad::saveTableToYamlFile('group_permission', $exportFolder . 'group_permission.yml', $criteria, $skipColumns); + unset($criteria); + + \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA_SUCCESS')); } function exportSchema() { - $moduleDirName = basename(dirname(__DIR__)); - + $moduleDirName = \basename(\dirname(__DIR__)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); try { // TODO set exportSchema - // $migrate = new Tdmdownloads\Migrate($moduleDirName); + // $migrate = new Migrate($moduleDirName); // $migrate->saveCurrentSchema(); // // redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS')); - } catch (Throwable $e) { + } catch (\Throwable $e) { exit(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR')); } } + +/** + * loadTableFromArrayWithReplace + * + * @param string $table value with should be used insead of original value of $search + * + * @param array $data array of rows to insert + * Each element of the outer array represents a single table row. + * Each row is an associative array in 'column' => 'value' format. + * @param string $search name of column for which the value should be replaced + * @param $replace + * @return int number of rows inserted + */ +function loadTableFromArrayWithReplace($table, $data, $search, $replace) +{ + /** @var \XoopsMySQLDatabase $db */ + $db = \XoopsDatabaseFactory::getDatabaseConnection(); + + $prefixedTable = $db->prefix($table); + $count = 0; + + $sql = 'DELETE FROM ' . $prefixedTable . ' WHERE `' . $search . '`=' . $db->quote($replace); + + $result = $db->queryF($sql); + + if ($result) { + foreach ($data as $row) { + $insertInto = 'INSERT INTO ' . $prefixedTable . ' ('; + $valueClause = ' VALUES ('; + $first = true; + foreach ($row as $column => $value) { + if ($first) { + $first = false; + } else { + $insertInto .= ', '; + $valueClause .= ', '; + } + + $insertInto .= $column; + if ($search === $column) { + $valueClause .= $db->quote($replace); + } else { + $valueClause .= $db->quote($value); + } + } + + $sql = $insertInto . ') ' . $valueClause . ')'; + + $result = $db->queryF($sql); + if (false !== $result) { + ++$count; + } + } + } + return $count; +} + +function clearSampleData() +{ + $moduleDirName = \basename(\dirname(__DIR__)); + $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $helper = Helper::getInstance(); + // Load language files + $helper->loadLanguage('common'); + $tables = $helper->getModule()->getInfo('tables'); + // truncate module tables + foreach ($tables as $table) { + \Xmf\Database\TableLoad::truncateTable($table); + } + redirect_header($helper->url('admin/index.php'), 1, constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA_OK')); +} diff --git a/testdata/uploads/blank.png b/testdata/uploads/blank.png new file mode 100644 index 0000000000000000000000000000000000000000..e1ee728af27616842d865ef5f55162dcb93a9b16 GIT binary patch literal 155 zcmeAS@N?(olHy`uVBq!ia0vp^oFL4|3?y&GPYDK6>?NMQuI!gN<;1upcxOv22FVwA zL>4nJa0`Jj5jgR3=A9lx&I`x0{LtKJ|V9E|NjRvLl0f915%77L4Lsu p4$p3+0Xf{BE{-7;w~`YM0Bw|JV2qq$`wA$`;OXk;vd$@?2>{=>C42w? literal 0 HcmV?d00001 diff --git a/testdata/uploads/category/blank.png b/testdata/uploads/category/blank.png new file mode 100644 index 0000000000000000000000000000000000000000..e1ee728af27616842d865ef5f55162dcb93a9b16 GIT binary patch literal 155 zcmeAS@N?(olHy`uVBq!ia0vp^oFL4|3?y&GPYDK6>?NMQuI!gN<;1upcxOv22FVwA zL>4nJa0`Jj5jgR3=A9lx&I`x0{LtKJ|V9E|NjRvLl0f915%77L4Lsu p4$p3+0Xf{BE{-7;w~`YM0Bw|JV2qq$`wA$`;OXk;vd$@?2>{=>C42w? literal 0 HcmV?d00001 diff --git a/testdata/uploads/category/index.php b/testdata/uploads/category/index.php new file mode 100644 index 0000000..4ae18fd --- /dev/null +++ b/testdata/uploads/category/index.php @@ -0,0 +1,2 @@ +?NMQuI!gN<;1upcxOv22FVwA zL>4nJa0`Jj5jgR3=A9lx&I`x0{LtKJ|V9E|NjRvLl0f915%77L4Lsu p4$p3+0Xf{BE{-7;w~`YM0Bw|JV2qq$`wA$`;OXk;vd$@?2>{=>C42w? literal 0 HcmV?d00001 diff --git a/testdata/uploads/images/cats/calculator.png b/testdata/uploads/images/cats/calculator.png new file mode 100644 index 0000000000000000000000000000000000000000..ebb2cb8860abcebef5dd11be1e2554d14c8b1d28 GIT binary patch literal 1593 zcmZ{keK-?(6vux{qp;Q@77F1ep^b%k$=f#blDCX0q2}cxN?YY6@>Y$Q5~U2?R2ElA zQq8b5?j>|%AD?ZoOniQh%0RWN=07%OOU`Zw-guH2NCiMiWla!pi-`mPYU7G?^dq%)=ZttsavO%GBS*{!%arRVBe27peJ#T-kk5qF-(6LxB820K9c8+A zj6yD39OFaLbog!u2dA*i4h2y2>tc1(q4NpcX5 zxm*urz|TG~E7wqGl~2X?K09dcbEVKNI`{RggqzUIJkoL_DkQgD&lxBQZ0foqS4WIZ z_8v675!s*Cc)h>`J*53LY}u+cc?o(kQ@3gdbUinUp`&|f;p2Wi3AS8fuMqm|Opbla zH+8prS^BOKa-q47IPcoRZYs!{Rm&I^$!5FZ>tG2u;oH_0`3u+jn94@Rtdflm z15essjM^53FImgGz0 zRnS|q3^V9Qk9j$n`1o;?;f9H2=9czn`y3m9H>u0@#R=`!wlVffLhano)xNQEOW01w zw1bsi@hgi>P}Vj`!a{S>k{P_F2CcOTL8*KDo=L%IOmKF&Zc#;U*Ag=KOh?I9YOHxR z5?jmpY29Bnb5)fb<3kes=r2b=NC}I>v4Yf<`n$$%-1Zwm$ zgmJxcLsbs?;-Od=#RGBAyT%{gu|5^g;z!eq$-3>&O^lN~5Pt_U&=+ewMX%khXHWr{ z2rj#=UWfKBmPv&)@9T^qTvH8Vr`ieFj~jV5gAaL$?9xXK4eiMB4#MTJG0sx~IYf#F zE>0MNqN#HZg;~vCW?zOX{y_=qVHAVYO~Nk;swlDr7Iw^Qt|7Pp`VB0cB_(O<$8 z5-g>i{U9bOxgN*^63=h^*5K()RS1*v<}u66s#BeSZD*g@x0(Xxqi13UW;1 z@~28-LDurpGKcj`;Vd(AcVMwox}IynP-=zJbB@*cJMmXR@_G9KO$Tz2E!VQCm5a>0 z_z0^B{Xmrt1-rYut4waI;){PfW#_pxw6AIZs%lQ$0|BLSAmh!%w>|3$)zs8H%WTdv zxS}5r)MU+ijtn$?&`%>hRr8IEy77lZvq} zrDU8w#6R6Yh&j3LpRFjk{)8rdZkLz*M;;Q`Z>@lj`tURLN(9E`BD_YYbB?lGeZ7K~ z(2s97Wh0e)ocxjIs~H(1`>h5vJed}DlooDHITbDgFhilSCMdKC8taF`Sesc`o15)H mp{!9T{^HE${}^IVghfRp{=eaFHR*Sm0l4BlaSxqBGyVmFso+Zh literal 0 HcmV?d00001 diff --git a/testdata/uploads/images/cats/cart_add.png b/testdata/uploads/images/cats/cart_add.png new file mode 100644 index 0000000000000000000000000000000000000000..de36c1efac4d91f0ccd41c55ede72a6c1311c980 GIT binary patch literal 1851 zcmV-B2gLY^P)LiNFjQ!Cxm6~Ofxo6Ix88c})R;W3q<2dG|Hdd2lF1ZVc8?LM( z$&MkLvLtVRoqNCUy}mJ@MWyd?xZL&p&N;t(&PBkJ`)CfV7`0X_V2Q(KgUM>mnEu(d z_r)g&z@QgwOU6y>kMS=Xp%a{o*w~W-p!?*I~|VyRlC#aL`-xvDyynsGFvbsb?OKju2%q`b?u|D}O8A231`ObBSNo+mZa{PyL&9`C?89$?gOoFb8jVCE zl4u}G@&(aqwX#KB?Xxq;5UbhDl{-A}O93D+kR-C4Ar}Q0W1{(j;^Jc7cDZki;qAqX zd2s3Q2!L^*^L{7%{r$m0$y_EXF;$v>)o16h(2@)2$Fm2VfdK*86;;)VefoxD#PcK3 zX)>X>sE9K;#uzJGR#3p(f7~xDzLCHg@Jf6ocaRj)|`NWwo{m7WnD9i5n%m;f8q zZaZbj0wu;qqfxe8)n{ZYDlCCc^oA7NjLiIxakes#A1;#`i1LocwW~!5*S|q78>s*W4PtT*SZkBJ$S@W{&J(}a^9>G&XZEzZ?^iH7!Cn2A{%C(E9m ze?Wj2aWL373~}KLv0?uz)K_$j&iWiVk1BgE5WSVw)8j=NwiGMhNqsfWBwj{sTM2jW zeJijbSq8A+pg@F_{T=2v5I)XP*mH7w?$I=i^K_`Nc`|fA5!0<-%U<8T zYiBmgtg5xX-T{aU?dgxK$`aUUt(|5qsuk>S4HF_{O?xrMMkGOy5XYVZY5>xAKkWNS zulJgC@7_I>P);8jI|xBRJ@{l(Q?uS`G40*CYY$J^cDfw`IZ3bSjy3u5xYL=(xv_4- zUlYz(Q~n%Veq7*d71!(301RzyZIhBG&A^(~YY`O{g?eIs?)h_kvR`CBK2}z#aZ$nfD{V>X)=%a$&BiH5AM&?Tl} zbxR9|1^1LKWE>Dx-tZ=+jD&1XB5F6#bJThtSJ)+117J0wngOwxELOYCuJ!ZvMdFw- z$}>?wI{~nmElhERlD>K9?p(#D@?h-f-HQ~HB61GAR0n&}m{yXN3*?krw7c#y)-zq| zOvrd^;V1fdH(AY=iM=T61qKE}uh(Uh!;(7gvG?AiS{+{S9QkzaP0>PcL4boNkF$xN@Cd$yGR* zwGL^n=egjaLVA;gko1zD?d}jYC>!rTkPDb0tlWi0jYoX=NX*swVUWAzkQPfD@~bak zOW84;VK$PqJ}MP65MGLM7f);o2=fEV)gXLG0!e~Mx~YmCdy01`VQW!BXMY_3nz8e= p3UHn3e5b;%PUZHvGt(ae3;+zn(*@m=Ycc=;002ovPDHLkV1mq?eANH| literal 0 HcmV?d00001 diff --git a/testdata/uploads/images/cats/cash_stack.png b/testdata/uploads/images/cats/cash_stack.png new file mode 100644 index 0000000000000000000000000000000000000000..ee8e307904773d689d7448a6131f1b731bd63026 GIT binary patch literal 1522 zcmVJPPFomojLg6doqt`&*l!*RGUn_WV^GoSwrtEP^H0C|U!jzCQH!$PNzC0CvZ{ zX7_l>+0^ zUudmy{+FKzaljop^v>~}9A+s6%$o;`!>b>Eve??Xj06DUe2g%R5QPEqQ4D1aqNV~K zId=w~g%VuXG9P4O3fFGO_-*|LlxJ_l*%b5T63UeXl}Z_DS96AMYQj zk*F$Q_73eB?%VKe@zI`DNYa#oQ1;Gc3h-&=ES08Fn4N-ttOG9g%T;F!3V+^^xxl5+ z1XjrBpyIqJz$H+mLO=<0cXSl>kQx4P-%%mK5rTam?HpOTqHADs`WkN18B^8)WgVJ; zvJWYs5fvN-t5Bf!q=cla2{yI91cexF=^Ws0Q|Idk-l|Cxs*Vy#c+Uyah-FnyZiplK6SLkIJO%VkMuOMPK&{ zgiMpya@KWTSKbg3$7q9hKYMFHu<1|U-)OP_&@MzlB;X6g+?QbS;PC=43$6;0nS3sfE*qgoV|EK?zwXv$KseAn=u%RF>Bk9 zU7k{dG8Bv}$Y$d`A8-H~vlqB2@wJJY*P%Ik2F|)3U)MxxVv^^m)~Obis%zQY-qK1i z7>hA$1Ps;Ck}SMWg}s9~^~85$xJAvQjT+OymVP3pC5)lPj_dBSo@cxfWscRM@i(Uz z*KT{EUr2Cl#$YVQtPxIkq)Q~Cr{OQWd2E0$Mdd1p6uw;9B7JN@?Mh@u?r#Y6y=&Pu@9 z)0!xkBWNSUmUnj1+S|0YgVqLOI#!M`7|Uo~?*Xp8MUJ*$6y<5FR7A3k&usR6i9O(~ zc($kOA*k^y-h4F=Xt}Savj_fBO)H{=PAauBLwOfNOs0Gz$>u}>x)$e}=vk0>64g0c5>V#OR?wb#g0Xac z30SIxj8TY*0B7TJIQi`{k-feXGJyp$(MB>=LT0Q!`MDEnx_0vPF>1xO)_kg+kh5)V zZWc008VXi}33+Sq?Dm)5s7+K~LeTIm@B}dWIaFl4`9uLFjcM@3*O7CL1W@;K;^X=U zm0)HB-0alC4<}B2(f4ovBk;DL=dKpfPC4_tv|MB@8Ve4ir@o{oo0FHBe|!%l0*sl3 zL<>Knxm_>uigvdSelNUE=M@Gl@qo^Wzj;Z$8wYDN&)7l6W+prT``7aO{~P}A3H&9% Y03yyqEG@#Cng9R*07*qoM6N<$f>f^90ssI2 literal 0 HcmV?d00001 diff --git a/testdata/uploads/images/cats/category.png b/testdata/uploads/images/cats/category.png new file mode 100644 index 0000000000000000000000000000000000000000..42852b53d6ffc0ebe14ef247d3710107c49c39fd GIT binary patch literal 2237 zcmZ{lXE@u77sr2A%oH_>Dydl%snHrmiP>v&?bQ;a#HtwA9yKaPHC3%qvu?%SN{A7o z8tJ_%MiHtgsZx71TweZP{GaoD&*wbPIp25ZdA@1prUqaZ0TuuNz($6;mgj_AhzWGw zAOH2&?m6hav`w@DpdmBr#NzqI(%sO~1OWaL2Y|Rl06023=NbSYp#ZS%1^{Y#0B|KB z#}%)CehYf|hk-6|c2ULH$_qDhprQR^0AS_15DoCUfDZr|dyI6ot?l};FCzn;;QWKJ zmox^Pg-HIBqX0dr%lWjV|->E03W+xj`aC)6XjV*C$0h(F1 z#2~@Lfwr(LC$SBS6(`_;l8S5{HEg-E(c@`?3-PBa`QT`18a>$B3fUg(YEqBf?;`GK zZtfIOc{K;U4;@5eM%uXE`fu1Bbj*ut$!!g0ybB+9!kpx=%0#B?bu_N5yEmAja9vjw zH%!2dkumP&2hX%dqNk${;Y;haSx@en5sSRfb!cUV< zj0@cT{iYVR)lQ+sdwzTP>F)Z+tMf%qSScil=Mnk_m0^z%MWEw=_L4pGaYU%^l-F_h z%ulUWDkr8bkHHDTt|>Xrx1B+%IO`~066Fd%Uc+u=WK2ZY)PMn%%!eLg_`~qrlEoi5 zsyrbJudaLCElD+do3rqZhOs`L4Lwpe$@Fj73iGs@ZxybkMvXE9v3~XL6J11$IdZfFgOHz(YL-s#Ub%);Wn*%{@B4vN%iiJU$)k_T zHTUPPChF#x@Z^0+`P;t=a|5#?z=!33<@77O&HiL^$XyvzN3||kKb382T{v1L`v!QY z?knG!%pT?OYIr@?Z;}PFYvWsA_13S1JWKEZS@I7r_ab{0E(@waRS2I-pgQyxEPl3+ zH$CxTlP4VF18-aJs6;`U){>axWi*6!iU@>i^^TuB>r-zisTE~gXHR5Sa6K3D$? zh`2j2Y0KmwZ!TB}RZ-jt>z$aFmIhlIHYYbQr=bF<-!0bMQ|B-;C&lRdXd@ zN=Zahsjz<<6=H2+FdiEQ3>^iqZtv^aN(9Bb%><09Xy>hD-O}Nij7_Mf&8%)|bjt2gwOkKbgm2fv z)m2+b;C!GdMlTME-_F|eMT-VHnFZTMHWG*BlW=nFi- z`eY>rL?-x4{?ko|t3-E)Y|cN+xW9&3r^xV5kn~gaVRpF#LEJnMDHQ~{PM4PUsQAhR zN(|u75eIpL9KLe1@4?7eq;r)BsN(J@>msK;7nwLJFCLcd-Q(ps&@EHvCjfxrX7FLC zT{2dp<%U3BX;q(@l7l`1k+e}5V>4e^hIjzb-EdYY16>zm_#zHx)ww>>AEsjc1Y7%L ziw({;dp6GL@;!f6yEJ-yL}-W5!X5_B#Q_ZJfBgf(u0FL9*TPY zj_&R2A_2ahLT*4E_JtS488)IA|0WpXGvkzMaC5H3GYwVaygp>8J(C>LJBk9s3lXoW$O`C!5lW{Sdd3AOvh6MAOd%yH6)ita|o*AFp z_QFa@=ve`{Gt30q(>P3*FB9aPh!$$!IvGXI7d9OWE*Mas;pAL47=Jt><` zJB5;{ch0TkyIY^~UKPpZ@wi3|K`YOMPRSPguQYzGlQbB=1Za4E)oL=?ZEPcmPySH+ z+&x8*s@6~?HHF)1iV8ANs2UVHvA@CbKL$jAhmU8(|2LFl{;WPX07iPIy0toP G3I72M&oqPp literal 0 HcmV?d00001 diff --git a/testdata/uploads/images/cats/database_go.png b/testdata/uploads/images/cats/database_go.png new file mode 100644 index 0000000000000000000000000000000000000000..c10b2fb3f058979ac67f623b3c3cb63ca448522e GIT binary patch literal 1714 zcmV;j22J^iP)%3o2Sb5g|xTiZKQf6?ySNFd-&J2`@&12oFA}55@#}5ktJhNYEgH+5iDW zp(()%7-&mxd+FY{JG(nG{^!i>b_?6xB|6zZXJ^iw^MB|6zwbY17-nAV!%q(_S5);m zS(3X=pn)-VKWey4(;Q|%R5$da`E2(4ov&@Zz#mr|$Lv=A`13FKN{alJx894!#zr(X zH9}Dov@|#K$tzF77=ob?^7%X_CnJbNB1j|?Fm!$Y_E$IWqF3}v0F;jo9{$$n_jfac29Z6JKk^B2!|b01`h*#Nk7T}Ol8gORa`=@s!w?$NPng{!!L`Ey&r=jJ{t0bqP& zTk9MV`jOEIXxS{7WCN%HNYOEG3=>XO#r%1#VoufJDCJsN0HXWC#mjiOvmJ9=TQHT; z5Q)a1WwJ=5l0+`OA^=5^;jQ<;=~B_y;76UyiDWt@=FH}DmB-pK$5c9lbHD!ypT|R! zG{Eoo!Rv8j(V}?}5jFYGyo13E_7BNa8aYzIcp!i%flnloc0a2QfRP7Dve=uURR@A0 zgu+oMvJ6>P#0t42`MshzXikZul0#n4Q;ze<<#f^JDc^>{pBXex7NA)bLMsKC6^K^= zBFi(4KjUUG9M*fLL}PhBcOuyll57bx5w>cIlE{p3ICMN14j1La7^|^6yg1YTBs~p*P!M4vVJsHM&~QYMN$`RUe3g^}og!wHY(wovWiX}%C<>D^WGKsy5*adEhFpF*QK$+s zdA;?t&u8LWWoW8o2Lr#;C&!|XD>X^8l z#PH29EvpV|RxJnLjW<2=4jy|DZEN1c5q|nABSVv9I7l*FIjanBafc-`B%VQGE*u-$ zj)7R8%_9^yCoY)x|A2VUp!e1;-9jCQd$0#zo!pHV3db}d!@^1EUS!B~?55EN-tEIT zJ3c`)cZ?h>ck#oZ97tvp`o|7q-LkFZ@lX#V5I@@>W~ks^WXKO54#_X@q;iuubNvUf zGV~O1*-@&Zz?HxutY5Ybl5(&|-iz;!??R7Mx*L|O>$Ay_*^(7SOdqxARmK>V0mfTe zs!7?u7XAXu+dKLFMt)W-o``s;=v$x$3C@%u|CcsLAv9XMN4bjqm+_*hpM&|*l%KbFS3e|LZIqMo=)2Pb3r|yPfd)Ep1azA`OJwE zUk~uP*YCrRFTX^&zYd%_M$QiuokzF|il1io*_{Fhw;dJUI_*BG3MmX**BYmU{SCnP zVgIuSF!1;jz^^9}{%JSX(X+vV^U{5q-=yrp{F!Q7Eza)*k+qGVf((8(J>82qIp<$U zw@aN@-&Owm)kwC;UepL#kQ1-=ZSB8bs+~&M5x(myPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipS? z7BDpZaS`GG01B{4L_t(o!{?Wy_X@bLPxh z90b9ATI+k2Qj3(<+F3gWbe7BIpY-(fbai%iUV7n$7bXGTdFLG-ee_ZO-`3vVezX7P zn{PhW)z$Uc0C?-Iw|=FLeDTAU zEnC>QaUf$s^oRcEQM z%~4ZbOS zy58Y2xgHu4qp%Jv4r9SOi!lyk9EmX)li-uk(vWv|En6VPVu|zJ-Irc}{q?WE@x~ix ze(eq%K75$Hd-r+|Km724O`A4tYHVn5{Z}UB;*}zJ0oDoDI*hfm4UDzKiN#t+Y%I=! zagOrzG}19#vvHzFvemWGalO+&m&{Gy}pXyUfD<(#T@$2^Asb8odq+M5*xnM zz+KB0aIt?Ny6?XGzFaI8Kl`OSuzB<5oqP7Q|HGWRI`?VMRT+&uoRgpPHZjbO9f@%S zTG+8+6+b2jyldC4)=xh9sfhgLym|AGg$oxlI5^0QFTVKKJ9qB<^Wt=c56)c0 zs({4&ucwKfy>!eR!SzzY#cO3Q4qoMNHrBIh*<#Liea?=5`jla}0JH<=00Y)QrNRR( z2?t-=%E0AotX;dd9w^*6f^(_q+_>Kqg%rnny^|YdAcvK3ZBXBXXad=uW zFcI?O&TEW^7UczawN)hI^WEQ?Vs(?pA3nUEusqG{Kj~-pzh6gd!8toCoPdcTiNQqZ zbU;T>55|e)^ZB~xo_lVt2gs5oOBOrl=o~08ZG^CrU=cbmP4IE=7&@K8tI8sN3UrE` zuldJQBW%+3JX9_+dVQKl*VgfO9iv?K>TyXt17H$d5_;;Z4dCKK^h4%NRY+^X$rOX^2k@xj7^qd_KjFt zUE-2nLSSbAoQaXRf{Q$;Xv9P$=?sZ;WV2ba+3a!;@U_;SD3R$(OfiCU{bLMFOyj3B z5Cljnjij=ubQV$>B$Z`RD(22P!AvYbh?9hIl_99fqHN5}FO%S+02g_RF~QHI5Z{AzfJ&txlSVQbR3=MNW%-jkr|^{!J3)IM z!-Z>HOwYs5r@(kPYjMUPiH8jZ@f@zA36v#J9?m)9IG$2~DV0jb^L_5Qb0L>54x@Yz zJO#do3Vb9Tpt31cE)CfWb?=h7Hs7#|*f_pair+v_d?E@-*5Pwk^_(O(#rEO))k$$`3y}K}TIHe#%4n8s%wJpi#a; zX2*CMZ={D^4}KX@ibA0f_V@SqD}WC_{P3qIPo5-65}tVIE7Vjb5bYte(MkkF1QAHt z2!G-Vg|RWFr>7x_d1o?@Zfr&ghyqc9%uGTFpdcwt@$I%6?r2_&h;rTC-K9dIa7_X9 z_V&JW`0!z@wJf}?n!oyb8{yy}SO-Z0aRO0-LC>mL>DgE?n$2dv*3!~)$KvK@ z)~#wLRUYT)sbNx8H8=yx3Rs1)9*q;9vwp=QQrR3=jnB2o3U^*PM-L02Vvve~=>)tw6?aoT&_y~;GX6D{*pW& z{O}{L7GeUw3Kd(dOVcqqpTpgjf9+3mO06d4RUxGaH*H8Jio`$rm<{$MFK$>uO-(gQ zd-V17xgZGa!Gi}koj!f~qEhM?lG3`}yLWfi)YLRQ_Sj>txw%S;Qvjq(pjpm{pk(Hm=FBe97&^PSM!VKomt(S66f3z=3~mZ*PC< z7gDlxI!zdcEMB~L)%NY%kB4DcwRGuHw|)C|vDT8r5!2Jt^bKC+zq&4Q;@lt;<(ahH z$Iwutxob&14Yetn%K5&n_Iqoxpph zPn1$P1kpaCeVk~lXyU|Rt)sKEla7uKu3Wj|8XFsBXlQ8Swbx$T_3Epyeiv|)laser zm^}I9le%0kuRMSL{H~=-mu_CWcI}+n+FIf`#`k@f%jG1O%i;Sz)>@o%u2d??sZ*!O zWHM;2&GF;MdoN$U{MxEjtKJ(QAMZPI7T}N-2d*o@5Z-O8~)!K z@!-LOH|m9)*1E~}{T0^Q*2&4qmU6i~H;&_sb52C0;`{zYO-;>URaI5DF{UeyDFr3PgkV8XDkyjn1f?kSB!~#T2!iRY9z^iuzaWC3c<`cB zp%hXu2a6Q#p@*V05ULfiU?oinX|mZbXI_0_(`GkGv+1|lYbDpy1Hs=ns#7S6ou>h`ubKl9KPfPK&S*R ziLUE_AfQkvKt7-EUsza}2?m4bn^FcY3c3!e)hbAm1jEC_M>Cns`%ox!?$7`T5Tt&; zAL8+NWPW~r)(M2`08~}wt{@2n0+385Bk6S77KCd6h;~vsJ%JEHAVx<=BXe_ev$);| zf>~1nQ_zgXVjZ2nR4T#J(h^T;k=i64kB6TB86O|NjB&CezTwr^%vR)k-*t^NC>Ub!XupQ%FXP}YshAt4*3g>~^ zgNYY6pkx;Lx|fCE?VXvnj8i`l1;{DGY#BH%g<<6M1u&QaKUcoD#R|;^t){ds0M&26 zu}Bm&Q-_>ytt9|ttl7SnvVi`P1_~4^e?d1jsG4QRlQavowi)34oS|XZ1{}2LPOZng zRS)U_cppmdJlG}ff4m2M%e|l!RS5O#c=By9kO4SSf!lAeiS-~0{Fm5Z@bcQL&O0dm zIdx*>`o!6*U?A-h2A%A~mAV6pPA<@4DBcGQ>$+0WLD4WiFvc=pKi36YXAEFDlBE*J zOa)2C?uC@^umYGerILov0^q|R=G8H+5Fn%dx+^Z>0G5Abx$cz*H!mX5Iy`y(q4^6& z3$ucK7CZ*_zYy_}Y;$uH2A&Rp9LOUZyI#?{c|Zfgw0K{rpSq z{^aE3TBD&tti{Wwb!|;kVK|q|eX@Noz&$~{40Ore1fYug3vJfkT>c3#0J>cc5t-9n Q0{{R307*qoM6N<$f-zO3@&Et; literal 0 HcmV?d00001 diff --git a/testdata/uploads/images/field/bg_button.gif b/testdata/uploads/images/field/bg_button.gif new file mode 100644 index 0000000000000000000000000000000000000000..e2191c910c9d776ec65e1c97372183be4899ab2d GIT binary patch literal 211 zcmZ?wbhEHbecI)FJJ!n`Sai3f6t#kfBW{`pWh(x?Ai0bfB*gb`SZn# zm+#)bd;RM5moHyFe*F0D+qWlAp8o&;pMf}__>%>!PzOYU>||gKSfJ9Ek~uG9)w-P5 z^E_qvn{CwH=SjEilkZ9hP!Qk~ov@^6XNkr9fEUSLYr`ZXau!awY9y6lz#t%IE|yWE aFdk3Dtg-?uX`SOWmN(^-fB literal 0 HcmV?d00001 diff --git a/testdata/uploads/images/field/blank.png b/testdata/uploads/images/field/blank.png new file mode 100644 index 0000000000000000000000000000000000000000..e1ee728af27616842d865ef5f55162dcb93a9b16 GIT binary patch literal 155 zcmeAS@N?(olHy`uVBq!ia0vp^oFL4|3?y&GPYDK6>?NMQuI!gN<;1upcxOv22FVwA zL>4nJa0`Jj5jgR3=A9lx&I`x0{LtKJ|V9E|NjRvLl0f915%77L4Lsu p4$p3+0Xf{BE{-7;w~`YM0Bw|JV2qq$`wA$`;OXk;vd$@?2>{=>C42w? literal 0 HcmV?d00001 diff --git a/testdata/uploads/images/field/broken.png b/testdata/uploads/images/field/broken.png new file mode 100644 index 0000000000000000000000000000000000000000..44987c06fafd7ff0c62ba2c3626efdcc89f664e8 GIT binary patch literal 2630 zcmV-M3c2-(P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipS_ z4Ja)tR8i&3)XXr7k5WX-u@#1LKoAkjSOhf!O-N!MgoJbgNhh6t zBQr_%oOKQwMsp@QG=7Fh}>IGWTSBHl`F^xsFZ}*({)NT!+%hLGrFQ=~+B? zB0=xH1zrO9X9Zu8zd(V9((u_5e7&9}iwk_ewK025+r|%)x$asqdwLYU2SEq|7z$!> zm>8GBp1o@Pxvd=A_v)$96ra1h%+qgSU9tk-O2d66cr?a07A4Z3TYk^IQg`K*O7i)d zKqP-4seZo~rBHQsR3|26;Gu7;L;Z(#{U*!0n>|Xml`cVnuczSiJ*dYH@Y>buZd}p* z(L0cdDU?L#omSLL2UP8&0BZJ~2*gmRTm$+2`{m{De#bu?=dyn(ar}=e@YOVYp#+b> z!2ACGquq0tE`^x_NQ4MACF~epQ;vxsU^)y5qlk=Y(SRZo1W+g2=6EdltE zM3E@Nv{ET+{_@LtU(aG$6HhC~Cm;$zDa5v^*4N8V9{Ogm&5E)eLgim)ufsf_{A+Rk zY0YITu4>6OLH}V0t6&&Z=QQ#3*%5hl&u-=W{u?vZ@R4H3%aJe!RI6aeiq4XlyKm!A z^Zbu3yZh6z%ny2zH;+OPqO`_JrPPMoZZoHT`qLNg^SSaZP6Oaeb#O(JbeEVfZdkV- z_U(i5b4aO3wLZh+#}9F+|8QZf?0vSkB6lAM*#1Vy=p4=TuLBCpEb`C#9Q&2+=T@d; zx0~a6jQt0oQh~`yn3+N4r%A?>Dj;0YoEjzBjb~dXdg{iBfS1Q?^J~ ztNeU*xBOd*!3`D*0dBT09!_WK*))0eGVyMIe$lOK= zZoVmc&}RH?9st-FQ@>c3ZesfI5yrv**AF?la*^yh&_DevpEcV8P67;s7a?zCv%PG| z51e@oQhf7u<*0zNs^WFEG5Qbxh~M`D-ei$-#UWjCRIxspYzxZ2d$^7P^NV$m5I(%D z`&~@z-NzdmBA|WQVqQIRK)n|6sh0wV-zi~@HL}_4S=d|9z63`Os7OKC5MuKe$ZwOj z8tZ#8SZbL@w`nLZ49Sm;vACyQ`a(YW?kTqF|1LsRj9V52ksJ}>I4~N)lr1vi1pQCA zJavH;!BK>i z<10~Y_CHU3CH&1(JqAmseD0LLLG5O>iOk-X=De8?(KqLtmVUywbDD$g&db zNX=1wZyf#gmI5FAyF$sDs5)O7O{XaVA<$8BsJHCI4fxF(Ab^gT(i8wsAeBsTx;VqZ zDqHW!TuA<06Pvt-`rdIZQk>4KNQ3||tQfD<<#_4D$yfRuK5#=l;p5;YqG;r7%)(Qe zvVwD-N7jn5P_x(sII5LVmRe8;3d}GhA4P2U8N~mCvfRjK$!2=ps49M`qO<~05VLG{ zCNuO6pWb`0!iGW>|Am>FjE-ceY*}pyrSJsGVTh$|Ovu)5SA-x47*#N=pe(}bFa)T+ zEm6%;o6U5x*9<*zJx>|48PzgP_S;EzoEqPK&|&RJmA9205tLXqE-CMxaTU|^>m!Io(4?R{mE@f7b3A0k1V~2Vp0RYIvju1Z ztT14z8kftv=YQh9Vm>ha>Z3iTAqJ7s2o?~x3}T|#SMqmnb6I=zBIE$iCiv8%%PxmK zuanX+F9My2wBAgLg3n$l{-7%I4ZKdNy3F8AV=|8E60r+I4CHEZJL z_TQYCL_?PHLF_Y@%Zqtax`C_ig0%M=T*aFRq`w1#1BmsuDyLhGe*8ZRo5C` z+k=KBD;c})CiWg5%rA0^rH6`~F4ZCtAhs#aHFqSr|Jsy(`idLZbuT?vzF~UkY<(OK_?Uldv1>)PVf8(BjMHb%a8}i_qb*?DHgvV( z#!ZS*m0+fX_8el$AlcqZBHcjB3#Hh%Lj?v@1yTxHk}38#O1y? z*TtB-5caRkG_>5C%P>7~lDq*W1xcV$pk9O7kRxhoMp-d%J=DkuPQJv90r}acIioal zb6K`omOMFjRz^(j+~)G*r6wE+{>WT#W1P-*c&<~~OFq-xE)6G!mGAp#%fPZNbT$KZ zbzsLpYX}0wby39vQL#kehX@MQ(Z*xrlk6-Oydi^4+gu)BX~ApNOPGvSm}Hh&{7-|! zM>Z_%VC}pHlI1cIMyN~%vRTMvY6uk<$|a;!Mnxec;_MuokY|scP-o&C8xrp7^VqrE zgx7;h9L?@Y!owA~HNmYp_>Y{+^7pj0vV38uv@U2-*{)8QKMzbBrY0$#9O3M#Q*vx@ zNbMLH;G7Pp&JulhhsOis5#{sUe#yh>Y8&>|%CT`vg7tCO+$3sER$Fu9ftXeVS}6hz z<*F}5gTjPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipS? z7BLCD0&KDX00@#vL_t(o!@ZYzaMjfn$3OS?`@Q#)mpyrqK(GWOA%sP7K@p2U00rw( zm9bW++G-W8ooemW7VB1*amE?7PDjVFGcHxih)e-d5Qa@Hj4}Z=hOmY$30Yp=%Ugfj zy|;g4F^ocmA_Hb}Dm>@5AsJ zHz&xsB3dwFnD}(jyzqmLt)B)coqLS`kKAgDx;qowUR>`TpjJOxG_NC8GW&4VsZ16B zjoqp{vN)~^*pA%z@Qpb&e|ROZESo^$`r(qm@pEEZ#!UaO9ay>YvvCClIXjfnD|&mg ze{&q~$l}FQ+XudnU6Ouo=?$Tu-}0FG0;Ue)A;=0pM91`?k@$6Td(E!zRDPtCgal9mgsJ2i5^I&ofY@2AAjL*uMN&yw#9m5&jD>qM+jWNMvJsl zm>WDgG1E{pJ!euQ_7@XRAA#k|8|F-&T)CmPcDPnb3n2tTpaJpXdnpLzvU_i`dwX-> zlcQ~c_GHpZsf^)}MUX}ZXq#%ietG<40t=2;(2zY9Z zqAjkOTxIHmZCb>WlJ2PQcXvCft`mN1`-$8yV|&AUu`vV1`>r&Me0kkP7mZ#~R+e|t&)W}bR_xTwJ;z{Ii>5arNTfAcN1!EIIZ7luv-Ea4 ze#bGRY0ut3gJCw0l1I*;drCa8U_l)K#l<=QC@l?t&E1!`!OTg5L!F?dKxxoQpcQC| z5Ev8|<>^tCC00d5P0-oA4&@FvM8$`%pE41xUfuYY2@^(GT5F_~g9?&>p>TbTQVJ>i zRVkEGDBbteN(;~NIdsI@hJm5w89THrot7b8MI{$HN1X(Gs&bgqPjYAOG!zt zb{zkt5LpI{D1_dOz?a}FP!gm9r9fyvfq@_vwbO0KX~ED2nh>IHGkV7|@;6N*Hgn(C z5ZJhJAD3NLOIca?p)q4h3mnH6N@<3wl$zFP|Jd(SUuu-pXx;Z-0KO+V)RGRmwpWGn z@)1Iz41Y|`MJsQ+DcJ6&Bh5*QiQPd+xb?(TcHZq-qHjsY-x_E?4wFPv6aSAMqZ zO6_?PDf=LoN^{R!0ZNNaCRQtADe$F0N`bEgQVEn6fWQz2@m`yrUK7I#;AzN6EtWrP zao55CzOV6pC6+86rdR%b;tYyH3kP$curOzJNlBPg${CEkK=aNnlj##I=A0|BUHw(& zONAP!0I3i{;CYJn4wsA!lJ*6*)ZDjNGyg)3=k=j9Kx!X<90jSA1+Z>i^Apw8kf|%Ogta{yhL;VjT%n^ z^jQvALjUpc7V*sUty^&Q+s4L?dn+m{i+)*F7S^681u$6m8Aox&IEQz4LdX#KzD5l| z?+biS;7QO3Tu&2AXrwgpeZj)HieFu?aJ+twP#Vh=dc~S<@zgU%KO#A67H+*XfbUB5C*pGlgt|U(qR5{ z%_|T1{pBgpT3{IH)gSbTMRznGAuSi2RE8Ti?5md2TcQGaw~ifCR9YU%B`3!s5HN9F zpCcVEx4mre;Eg6NCp2Agh{mBO0f~%(>sz$8W;os%VDgzJZ$Ic`nL`N766`-@bIJVA z+QVU^s&n6T_ZttRit9dKu&};j?awaOxUNrr5X#EJRE{d<)y+P+Ax+#i>554@dNi>F z*nW_B+~vSAO>w@(hR1yZR^QS>fMGyaRO+eocBi7pvQx0@4^pxPVl%&D!m+NpNw8&u9pF9Mr zzl8f@pGr&Wuls`N3411X{Xt;R_(=$ydB1w}`9(Z5f3nb>Nkr0t-i#ua)6&1yx z`iopjO(oJay=MP2##YzXQyy97UV78hnZr-Ml@UP` zOanCi#AKLUaBe;;Hm0a6_epvo?!6Mq3kL`ae5t7@59+&@9%b#S&f9S2JTdh6J>@%L z@wL%KLDbUQuMXEv7#G3{nL3(6q#Wo;YL>rxoR=ObVf;vq9CBsL%M0kgzSb!oxqt8L zFz@DXg8f?^sJtmg>zgGME;y0vJMw}NMdGzdwSlVZe;lDb0m&@1w!3_|>NvZXRnpes z0GdcyhY z-r4AgYc6m2C=?0IawPtL+WBco@r;%}LOHuRSBz_%Q9iAy<&s;E>WAOe`tpa9`rIGw z(FYD^bYR4X&8G4GY4w}my)_&8$)Z3&KXA=Yt7;k=dIJY{bnHc_^Ds#hz4U+Eiw4hX s=o^&&D@ftiDFxNr@1k&9$#+@n-#7!Eo*J=!kpKVy07*qoM6N<$f~#X;;s5{u literal 0 HcmV?d00001 diff --git a/testdata/uploads/images/field/downloads.png b/testdata/uploads/images/field/downloads.png new file mode 100644 index 0000000000000000000000000000000000000000..88f0373c76a79d7ef6b2eff3144ab17692683169 GIT binary patch literal 1850 zcmV-A2gUe_P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01|Wn01|Wo-ewH0>L_nMFkQpD$1_iP$49cs0auNiASQ4%4$+YX`YT9B~9Y@yyrg8 zIX{a#Nydqj86)~{=IWe#&;On8|Nh4iy0ve@9i1F~J?G{20^sdlF~(r&?$XKlgZN^% z$68$j2+{xYk(b{-cJSC9ZS-T?1VT9|GHJ&#%9+xwK;j`oiMG-0ZRU zM+b+CEHo4%s$}muO;chLOw=Z|Gz`QcHSy({qu-i3^1>^L)=&!enNQ~5TgT>`0FoU6 zXhfxK(qHxlpFQjfX~3k2q6P<|OhSMKf%twH3}6UkERCs=DLLf!TS_sn`1h!hS;@hJ zK(M_Z`6K{An8;Oo>7~lRwNWJ#RCx_-MPy_MBLXs32qQyi5kOH0g%Ab`kqPNW{SwcY z{y}FxITbAasr0U1#JMLGuWfUd`JdpsxU=>Szj^WG-M=g~&gurOA{1prRvFs%A*6zo z00{#voABiZR?T%>4o~sb_%xPp-CAAvP5f4L8Xo{K?|uK!wil&G7hanJKD-W``qiu7 zc;?XI@2=F6;d9QXN6(CYoQ>Rwd#!#d$lb__JcO{Jb&MugQBGD-O4bl*h1rcm{I&JD zrG5E<3pR(9EA#VjzxuP&3teg8!|Q+zWQ60r_1Q+_mGb5?#!*D`-X!1r$_kO|Au9?f z$RcdYK$C*Q9tZ-Cw9$Vf%gyYt}K@(CMORf*Eet*z=^Ik@arGU9-f++{>8N$ zi@dqMN%cmJ-HIUZro(;H<5b8EqR$$^ZhHthQGg^1p5>u48@I*>h(IRts2pJF-5_|H4P!_r^R!2+O_MjR!Gq6Bf2 zut{Q!PE1fw&PJB~lNT2^O=6y+fn!GxAIap4`);2<%au}%0?iO@b(a8W!}#qFe~Ry& z_&MhP{%2hM*GDMkGpN`7tyB_-;t+Q}Tj81Mv9FIG*gxbaSMEGjguTW5SCgQbA0C~= zT;B+57Ubo!kd_S)fgk`uU;=8_F5|faGkEa}v#pkBz|0WDFe(OtVGBmS&;w@fn>n=q zMF4+zDu8mSKK$(9E=-N@2J>zL0aA#qiOXp#B+7wJT3=L9PaD*O_G}?h29716O-%Jt zRj#hpiXGE14w}u%!UaS@07L0%wk5%)RWzu*f>6o|rFu@6Qg94HlxVn8Kx+**m(#{% znjHZUA<`tEoE%CUW%$iHgp?0^f17^-fkgUjcxzQ-W-tT$4~!#;17vMmCrRRW1du2d z+qMNKV ze&DEG5EgCU%$ONO1QL>kWfKdb>W!c?14iqJq{~8DRPZdY>p{qefoEeo_E7 z8R@vvb7KhC1xdMud`23U`(qIs28nc?*|g5lU;_xtA`${g6q}|W#vK7@r6VF?NJ_+- zpp^khdhB`x2FSEcrL-kS*cgBa4oL{xhV~=X4C2lJ!XOMmWTb7w%jE#!fk@(iF=hi{ zS&+y;CuQHLBqjwO^{Bx3G&zP@3$I1(>>!0RtpZX+}^{6xiGa13HOfOA_0b z;7~J32;@BbLDd5QE0Y5oon}G{jI(9T8xnJRGiGqxf5bHJw=!jzK|(;sk#*tITj$R$`l{nh2*3d_ o3c!2PB)dbq?_(Lj`lFlw1wR^Q%A#-4IsgCw07*qoM6N<$f{UPAI{*Lx literal 0 HcmV?d00001 diff --git a/testdata/uploads/images/field/field.png b/testdata/uploads/images/field/field.png new file mode 100644 index 0000000000000000000000000000000000000000..b0b2f8445d183dc9583cb71fb07210fcb6a15560 GIT binary patch literal 2388 zcmZ{mdpOe#AI5)0%^@ZRBIfM%I zGVdh-NLdqbmagZUs{X#|?CPf6;zZk%C>v1SS+}y|Zl?}!u9*;}8tofv;|g)mb5yMM z5%eBa9Z7*3VDzs_<=Ud*iExLClASUydLyISIGm3GFde!en-h(ua3Q?U1HlxZ; zJq4jlGfx)9BK``yRxBuUuXI^K9(&D{#@yB&T5M|WgYL_zFWw`!w3L2u`Evmd_b%;-7L2pxFI*MtqfF3=FG;157u?+oMMDjV zZw5B|_fOk?NPo0$1?BeX#)-^n`bjH32N@eAg`rxuZ_OE*cc-B@Dh6Fo*GMNQ)203Y5ADX*@^w~ z#l_vvZwQ^b3$%N>`+PCHt$nTom2U>ct-UNy-f=SJ58&iRPth|T&xYuu)dAW|_L}w_ zqx$AP%RX6WX1?{sL`GgEyit+gU5p!Oad7oGQ=tIlWof&*sx=p9py_;`oNi_&(cJ|$ zr>7sa=KVGWYW#_~wW28#6l8+FJ59Fr>pSyVsAf)D5Z@Rk5Tp~*G2uJOl;g0&Xr;gZ zRu%{a*|p`@yG}2KltyH4C5=xjbZyZqeXSqhxnGiI3iZb($9+cQR63q;@qc#Mk{ZL+ zd9?14$aW(!_i6vLc!isfr&}0?gMsrH$Zb99q!MLi`9X)Q#|zr&ao-JRcb6#jg?`q< zjM%RJ>JNfmW@@Kygz>EzSMlMyy{z!t>u6~ubkdcPN}B@eN|&F>c+AI;wKfs~ zI>hWgH_m}uI29Ha;~dWkcf%Alx``1#;SH)W5s^cFW!WfX$(crST9>Zi{gVUB+`KTP z^3bBkd$Z;wKFj2uiD7figrE4jv4U>EX| zJ_w3P2^l?QUo4oKP1I;=qWjFaviHhbXEa*8SaON0SEheXu!UV@tlT)HZ)_EZC#;E7 zzfY*e4~NR0sHmVjmb98XIkmsSDoTDE96npWf;+@|_d`TECuCrp1`ZL2dFdiEc@wp; z94tl!B;NeDWIsC4zz8z#>6t==u$p_xFb=N8lV~b9Nj>0m0`XkrH@qM8$BzN24WbUF zyUhF6l*^Tkuv~BI9;|^u4T>gj(7{e|*e;zA^}e?A!w2#ByMun3?{L= zxI6_gYh!HFJ&XJFzmy=;ASl*I^K4Auc4 zdIj`nU$5!7+&tBLj$r;AG8o^ocUkXkY8LgBHj9UNEA!^poxy=TY8Nr5XC&@*C1Hyx*=#C-@=}@GetdbMIxM;Sg8Q-Tv!wmBDZd1 z)O2Q;nO#NGUddQeDckZWCGm`R<_T$KZ}#IGE>Ml+49slTq>mxf5~!sFC5VX)4l&d>lsmYP`U z>+ubh{JiSilC5Wgfb)HK4Q}N^LL4>Pn0B_fa)XPtZK2EG*D{By{N470+o?x0?1Sbr zj~BXTDydkTQa&c+Skr?dzC^qW_#QguZ-m4Bq2wy>ILO}251!SyGAB|B;}$Jf_`PPu z(z|GeEn6+v^v(7H1+nN-GS2Q@@3>Wzjjxu=cKgd%9YrDPCC3r4y1 zeQqv*$+RnQ?K76K7xhJtHPofJKth>GhEO8pB6d=>CEbM5k!mQMlop9&B0Qrs|AT57 z5KTJECh_mP6jY9qxGn_{{fGZNVN!pA<{GR&Qfgbcj9grd;>k25=N* zh((|b5r$Y-6x#UMabu%nhfyeF6v}a+o%BD2fNRt%mu~+5g2iq6*X;s8uyMpaxAKnq EFZ%IkrvLx| literal 0 HcmV?d00001 diff --git a/testdata/uploads/images/field/import.png b/testdata/uploads/images/field/import.png new file mode 100644 index 0000000000000000000000000000000000000000..bbcbaa42afd7980270aa7ed562269c133d0a0612 GIT binary patch literal 1165 zcmV;81akX{P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipS_ z4KE9!;Ev(|00a$5L_t(o!@XC*YaC@1|GjT!G8;D=8gdYFN=rpaFZOC1OROQ699u*~ zXby!!JVdDe4WeGmvDTJ7dGJ&rATg;(bJ9aSSV9hhNJ6x07CJj|cW35%?|GP+&1_N$ zoka(RZ)TY9z2EzNzxTfP5lUXSKm4f1%t}OXT{rsd(@&Bzc1&3SK@j{#L{H*4+HN+R z@0PXWmYq0u=FGTd9a7~O6c*4kfO&->v1y?fse%)s*U^5e0w zv5VDe6{-pmfvO^R4gjip^emz*jP~Dc3R>Yickh1jb!iP;zjp1$omNPL0q8T`=f3}o9&wO+v`K<6>S$>INs?q_AFXrF1Rcjj zCsi$~NMbI}fVFIMFPf5jENxB(rv)BV1&-sC6XE{;K3vyv(wHbSn67V6hIA4LWuFxa zA_K=U$FSr?nVc2K|0lc9hP+o8-uLBMY8GzC# zv>*jlCF3|w6h+wC**Po?!1w*FD2|&%X2=`z$aP()s+uffg+e8(jv^|mMp$5N0%1`o zegwdS0C?|}^XJEhe7~1m3WcgdMIiZDxS1Iu3K0u|zCATHHL|_EeOL;Bh)5JgY3fl< zZwe!Iu23xiU;zt*S)eMgiG_%0X$F`%tp%EW>P4>O6gB79=)-O%m8FdLn|V!dg36PbeZt zHINpS9DsT87!%O-ci3x7+n*v-!DS@j)OuEt(=LB7#o0{pi;?iA(Q>;f>3!Flb$P`sdSU z2L}fT!%(~3E|P5Ri>VjKF*==&20?&Eqk%@F@$G{L-&}cX=E`7A>D8;Vc=&JwGcz-@ z%zRx$rd9Q|=lt3+#{6uI`Ofpa`sU{5@ALEXSX)~g3_yO(&dy?EW25(edHT&KDtaMn zPQTjPdbIGL9?go*0bsONqgrhgqJqQlu=EkH^wBJ_?B;y{3p@Y&;q=_Ovp0jFRrNd{ flarHwl(q8@B>0#92u$w;00000NkvXXu0mjfB&!Te literal 0 HcmV?d00001 diff --git a/testdata/uploads/images/field/index.php b/testdata/uploads/images/field/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/testdata/uploads/images/field/index.php @@ -0,0 +1,2 @@ +W8At9uygh-qrP!NflV0?-XYn!#bJ9|FO&Z!qW zyErB!QAhgp?aq9f-}C<7cjkLX;0}+mu`~KZ4;?%>Iy!p)$Vh6RrpW`LP)KjJ+K%J6 zMZ+kp&Cf5*;&w_EVoV?Tf3#EB!nJbn7)j}9H0m`En$sH%b}iZ`rt zU6*RL!SZsZaOu+LAHDO=$A5eE)!EnKJ^TLxIDY)eFINk>FMJa&Yka)ay+Og$kRSIaXIU zxOQ!x;o%`BC-?smrqtU4q|>8M$g+ZM+lXQ(a!HbqB(dj$BuV~n5kU}eT@TB$G0isZ zwuNomIF8$^mu9oY*w|h7E6VDDZw0*je;^Qyd7g_XDo9dCyi;5fiXtP+QV*zWd-qm5 z3(|GnUJ#z=A&MfJrbaEReoFu~6bcEZ*(MYUB1s~$ETbqgilU$>iVqpgWVRCYxn9XjXsvQRuMe<#ceHXfp$jGw11Mo(dx}d76 zP%4$tG)+jSNA%m(Kzm>ymJ5Y~tgNh|X<9D@-&imC!cq^Qd+o+`BC4ulnr)VrRyln5 zK)Y6}*KP-3z4_+FwMQO#m`0Nh<4~*B&~=?qD2Oa8$g)Bppc9RT359~>as?I^mauJ?c)X8f zGAYz*rCS1Uzjmoq4rt3;y_9LFV*h>=Pq)z#JOw*)X%m5uT7v3v9R0!NP?#xROhDm7f! zBNz-K%QE3`kVK-7a(R$IKqrxi6Ap*bG!@ITXtyl_0i8X2MrgM!=I5{T;Dbk+xm>Qe zOYd6%-o=aWInO`;2i|}G6ROo3lau@KJdbL%PQBiw-EQMJF3{PKJkRsrbOMT^5De-> zB4JcjA)ha@xtZhi=?7U@xb7`4uRFH`&@!3Lu`5?*IC}J6R#w*e`s;1d=@b(aV`!R+ z<8(G1=xoKE)X;nU9LJ$tuClSQMXgq6YH9+{gDY2Nf|{l#Ow+n0fSO1og-<^Df@ZVD zo;|~qN);9tSIK0)CXtAdO!g6pgwS;jRaJXEK)v3iT&_|qmZ?@7$g)H{9-~&PbNTX@ zn5KoMX@Y6qd@m3IN!Ru0)YOC|%L+3y3*_?#LqjP%&m)`7F+00Rw?}BTT9~GZEXzcr zQG&q$fk1$8I7}=SMv`s-A$!@|N6+uJ#s%~o%Ns#Iz$EoI1Nw;3Kz z;dw4oQwInH)F{vg==jZ$>_cck7|`bDXICD7{He*e-~NE{@w@Rnk5Z{ZyKNB;htM>Q zM52$8ks%t528yB(i$w_p0w{`%>$*siL@L!!BobzQJF9WP>_+45e5eb=0KYwL$aqcT1VFFf*|S5W=koTD?%Wk6OYFoRh7&} zqf%X4Th7hR&8!*5_Bycbi?0AV-}Va704%`U`DG;f^$_$^67_2$?T-OJO?`qOhDA}* zK@dd|&v9JKb?t_K^CDmXo4~q17lEoDwdp?r9(?=LtXmVRKLS2XH#G?#BJ4ZXZD=e% zsH@A@_rcECt<-WQ5Lx^R*Y-~p}=VfjLqFJ}AKy5puocX9~dG4DLQ goBZ}}vhIfCe~R_O2g#G^$p8QV07*qoM6N<$g7DHn+W-In literal 0 HcmV?d00001 diff --git a/testdata/uploads/images/field/modified.png b/testdata/uploads/images/field/modified.png new file mode 100644 index 0000000000000000000000000000000000000000..2c4bdec1236144c43d07b5a85f14ffac84d61642 GIT binary patch literal 3064 zcmV004R>004l5008;`004mK004C`008P>0026e000+ooVrmw00006 zVoOIv0RI600RN!9r;`8x010qNS#tmY3ljhU3ljkVnw%H_000McNliru+XEC0D-N~h zzi9vf3g<~gK~z}7m6v&pRo8vTKj)r%?|b*Y{mt@bGt3OD#{;;=U}94ngF_Nw)p%<$ zj@2q{KZoR&AonwVc*zqNG7h>Zps7xHz_(*k-exU~Hh6fngh%ff-Bz=SWvNy3#r4bAG???{|Jb!N(cvehlw!zA|6^@9U#U>z+i!oM-AX zq?A&nsyj8EtDdY)6?bv?b7%P#hWJK0fcD9k@!#G=^fzAlR(n(AnI#=D)zuyoElG=b zSjRFYn!Ezwx;}-nOD69yJXutS2eabfsp(uUSKYv#CqMWo0C~f|>t7`n4_TGw2M6Z0 z#y)dbR~?^O*&^ENEdqu{z?A5^h7tKx6mPwIh@GcgqOmBJDKQO6#L}7DXfZHaLdJc0S9qRJ z#kryh$MHynO)~kaI@q5TpMGFz`*(Mb4`=>y>5WDB7dvZp-`=`?x-|~{|MC!*Mn~Dc z=Lp9O9ayG@p=)Rwq~bvg{fhDOC5J-A!|{9^S7DoiWW=OYb_rWLi`v2@BPLtlIIH## zmiL_Ax@PT7UGUoW!_T=jhv|~WmVbDkRAU{#^Y|w*oEc_HF4>~PY{{cg@mR4S&fSX> zbj^vcdj^~rk zJ1lMuv!iE{qvvKgGn!{&x)E}x zhd=&w1F2wzu3N%{EuGPHm2|Ggh0A3!1(#yYr|kF?Djrighvf?ryw{iEV!FccRGEt7 zV+C|(XG@R#-%INNPd~00yF9$wb6tX_K`dmDiU$!=kSlu}$StDz#7VxizMH>(^%6xb z%FuY3SV$)vlnh_4pb03tKINLnJqwfc49$?QTnSZ#z%+H-s)OsebFS0CKfNNTR%-L5 zCRD(Xv?VPbTiwFu`&!xhg>Kf}p5i;bP3+v$!`B~eqQNY2`cjDx2XhQfR%nO?P(lL) zYi_G!XsSf1>Z9udP19I^MSy%_c$;>+t- z@cq3x^l*~p^CCR3G|302XDHSby1Wvy;eg`wXo*s}h9(q3Kr|dcLwMH#glzMYVHhlK zwdozq5|37~Y#pgf3`3$D8Xg*eTIM+Bx33K3i9O| zm70$(1^5b~KuSU9ElCp5!00s^_{v)|)Wz(h3)<_rFjc1J`V=b;HAkUoSE54KB?>{% zG^mS*I9R)#o$noD?P8Psi4(Bn=d9fNB&t%t2XraXG{E=4_fZO3>O;iiVg78jn7Ibv z?>59~Yl-ei*2ho+1Onglaa|APE2I>dhQ!b{<~7-bY=daT#+ZLU!~fOCLgkX(wvB`D zpXSdqKLXQ269PPSbq}9_sgbG=t7yb}`-YkDPd*_E4Rz68J7g)TYX||Jr*Iq>&-DQa z2X%s`#)f4H)^#V)2F|hU=Wmk!#Wv`r^w| zXHWKz&MW7OLe~U_DG6H!x?wQCB}B+J$dnYJpn)FY|2iOl`cWMj_#!^nLV|O zOlh25-H&o;#nZTz3axF8$Z-7k{{G?kOE-NBwmjcUyeYcd3fo^SR~#i!!qhdC5G-g3 zktup)iY}glnx{~XL-DSS^vvzX+5ZL%pG3y$nY;Eev`fQGzWWwSMt9*XU#s-i`MobZ z6#v3URz!zR>tgTE_K5ji9jdLPWwq$=2JjkNvl z77D+39r}AQBT1UpJwknYgn_;@bR2t4aOCxE+s7t$!q-2dCak|NKrqnJx35>WwKvOO zyS-ykrRJz&xgvt5M$ps=1PydUl1c>VZnJ4`2vV#m`bG*k_dksP+IPtgohDw_M9YRv zG)|r4)X*q#zp`pm=eHZTO%}G_9H4HMiLbR`%2a<(-(=PCrkAhkUJ?wN!jL|xkjtlT z4X|on2-^-aFj-+dn@5+Dh;0(EE%M1m;)ixK)_;s-Lo2C=o+LGPmNP>m=t8b|x+_up zw@djCZVV8+M#G^qr(&V6Fq&$?_9nhdF#Tqdds%CT=FzL?U5Tzv_N5ynh$1`LsHJ^g~hK&_-(GXKB22hJm3GOx;}frDgSp|M|k~nd<@M zTtzUZ5XuG-kWvc6)cwJMk@FXaCk7JraiXzEQ1gmbHJ`z+6>%zMN`)Mk$1i##LuWFF z_U=EmbIkum=S<&{7E@>F@BvYmY$EmG6Qm{vIoW?fCBoL`XI3`7^ryF`a@RK|^PV;E zX+Y4a8+vOj5l%KV#v}C&iBNq*ER;xu%~;g5LY7K;wW2*SG87yc91xc$#{E*Eph|^; zS1J}=V|Lp3nw@>1qo!1;Tos@Atg{^cbY^B3tD;tSg>2SnOTXtYtlg4BqTzB5}^uei%gW25W5vNi}SH0?N zsp41j?-fg@S~V86X__(Ge+=6U(YpQ-7PdDsRjd4sew_=>z3{)Sf_~fA98j}LsXQ<) zgfI{oAPi7aDJ20VrS3I%E^#~3Ie&8GRNSrR<|)tV0@^AdpD$Ma5bi zS@hU^UVI|z2?SA>8gTH*y(!}h416Rq@83E_2YybcN zC3HntbYx+4WjbSWWnpw>05UK!IV~_TEipM%Ff%$eHaavlD=;uRFfdNs$y@*c03~!q zSaf7zbY(hiZ)9m^c>ppnF*z+TF)cAUR4_9-H8wglH7hVMIxsLlfpOpf0000Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipS_ z4KOMo(~u$n00s|9L_t(o!?l)OY*fb;$A5D_cD=hc;Dl5NJE)}&rB!JpPzqFSnwIjR zK-ETSt19g?>H{KG`W7M7R|G^;(GCVvi*RNlfo}M1L@~+1V){p8c?R_Uzd| zlw-e|%}<;-0YH0u`*~xG3=R(3-rimr9UZj~A3l_ci3ypSnz91}19I-%Ios6KB&SZD z>I67>^5mlHt4ct$w6uJ%d-v|&c6WDEU0p4GeSK5LZeEQj^_W1GRclPYrvuY-0 z`}XYsbaZqi4<9+)H8wUTeSLj$@ZdpdY;63^l2g#t)phmJqer%_t<5$!H%|fT?LWQ! zMBMqmod=+)scAThB75e{8GGo^q2Z;bz`1|_zDcLk3=9m=+t>T%?c29Mc>lfk=TB8@ z3saL*KWb=b_+;(cwH!Hmgu2yrFYMpHfBczFzi;2Z?^ z&yMfjy^~Q2qA(&GWGe;`hM`qTk~K6$(^oZWM)#jg8ZP>lU@OwJ7C$DQIsoI<+wc@BvkE4;{sD#ASRuh3k}bVns+LLVVv~ML-M>9{2=7mO?R)QsB9H z5>$8JHRjHZWzP>%fU)~)D4a8yBo_dCE$7Yv!^H<~i`M?y|lK&TP)N!*v zjxiSB_t^5v1i$?G1aJKA$^GW#==+;8L{X`dS!?;|LN)k+07cmLYA`D}YYnX*FNb*9 zUx1&y8eoh?#G;Mi^R60Vv8T|$mW?^WNR`B;AfI>W`z(fNkO+SI!yI8)@++nI&xps! zEw|*?@Z&8x!pH%oP{4H7<%@e>yUUbzV0`|CSFWK+rMTs4VAf@Cs*>&4l;Awnq+*L6ux z_>4_Bh=7#)!}ngwqqRjF%bok0!8c2BkI6ugYNDae^QqlgX0HRu))GaULa~VN`S`wH zZdev8f>=SsVys||K^sFhlOdB0$dtQiw)`x(eEBk4w{D#ufa|(kxpHOMz^%buVW>A& zClbqD*GXY*DhvxrV|2oCoVepS9^fJ%Y(=Y;ZRMB5eQw002ovPDHLkV1guIEe`+y literal 0 HcmV?d00001 diff --git a/testdata/uploads/images/index.php b/testdata/uploads/images/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/testdata/uploads/images/index.php @@ -0,0 +1,2 @@ +?NMQuI!gN<;1upcxOv22FVwA zL>4nJa0`Jj5jgR3=A9lx&I`x0{LtKJ|V9E|NjRvLl0f915%77L4Lsu p4$p3+0Xf{BE{-7;w~`YM0Bw|JV2qq$`wA$`;OXk;vd$@?2>{=>C42w? literal 0 HcmV?d00001 diff --git a/testdata/uploads/images/shots/index.php b/testdata/uploads/images/shots/index.php new file mode 100644 index 0000000..6a50543 --- /dev/null +++ b/testdata/uploads/images/shots/index.php @@ -0,0 +1,2 @@ +?NMQuI!gN<;1upcxOv22FVwA zL>4nJa0`Jj5jgR3=A9lx&I`x0{LtKJ|V9E|NjRvLl0f915%77L4Lsu p4$p3+0Xf{BE{-7;w~`YM0Bw|JV2qq$`wA$`;OXk;vd$@?2>{=>C42w? literal 0 HcmV?d00001 diff --git a/testdata/uploads/screenshots/index.php b/testdata/uploads/screenshots/index.php new file mode 100644 index 0000000..4ae18fd --- /dev/null +++ b/testdata/uploads/screenshots/index.php @@ -0,0 +1,2 @@ + Date: Sun, 8 Aug 2021 22:13:12 -0400 Subject: [PATCH 50/62] PHP8 Smarty defaults --- templates/tdmdownloads_footer.tpl | 12 +-- templates/tdmdownloads_header.tpl | 4 +- templates/tdmdownloads_index.tpl | 4 +- templates/tdmdownloads_upload.tpl | 2 +- testdata/english/group_permission.yml | 115 ++++++++++++++++++++++++++ 5 files changed, 126 insertions(+), 11 deletions(-) create mode 100644 testdata/english/group_permission.yml diff --git a/templates/tdmdownloads_footer.tpl b/templates/tdmdownloads_footer.tpl index 7a23084..6971e04 100644 --- a/templates/tdmdownloads_footer.tpl +++ b/templates/tdmdownloads_footer.tpl @@ -1,17 +1,17 @@ -<{if $error}> +<{if $error|default:''}>
    <{$error}>
    <{/if}>
    <{if $xoops_isadmin}> - +
    <{/if}>
    - <{if $comment_mode == "flat"}> + <{if $comment_mode|default:'' == "flat"}> <{include file="db:system_comments_flat.tpl"}> - <{elseif $comment_mode == "thread"}> + <{elseif $comment_mode|default:'' == "thread"}> <{include file="db:system_comments_thread.tpl"}> - <{elseif $comment_mode == "nest"}> + <{elseif $comment_mode|default:'' == "nest"}> <{include file="db:system_comments_nest.tpl"}> <{/if}>
    @@ -19,6 +19,6 @@
    <{include file='db:system_notification_select.tpl'}>
    -<{if $copyright}> +<{if $copyright|default:''}>
    <{$copyright}>
    <{/if}> diff --git a/templates/tdmdownloads_header.tpl b/templates/tdmdownloads_header.tpl index 96d937c..75a2fe0 100644 --- a/templates/tdmdownloads_header.tpl +++ b/templates/tdmdownloads_header.tpl @@ -1,8 +1,8 @@ -<{if $show_breadcrumbs}> +<{if $show_breadcrumbs|default:''}> <{include file='db:tdmdownloads_breadcrumbs.tpl'}> <{/if}> -<{if $ads != ''}> +<{if $ads|default:'' != ''}>
    <{$ads}>
    <{/if}> diff --git a/templates/tdmdownloads_index.tpl b/templates/tdmdownloads_index.tpl index 1bacef1..fb23f35 100644 --- a/templates/tdmdownloads_index.tpl +++ b/templates/tdmdownloads_index.tpl @@ -5,7 +5,7 @@ <{$smarty.const._MD_TDMDOWNLOADS_DOWNLOAD}> - <{if count($categories) gt 0}> + <{if is_array($categories|default:'') && count($categories) gt 0}>
    @@ -115,7 +115,7 @@ <{if $show_latest_files}> - <{if $file != ""}> + <{if $file|default:'' != ""}>
    <{$smarty.const._MD_TDMDOWNLOADS_INDEX_LATESTLIST}>
    diff --git a/templates/tdmdownloads_upload.tpl b/templates/tdmdownloads_upload.tpl index 5419e61..017b28d 100644 --- a/templates/tdmdownloads_upload.tpl +++ b/templates/tdmdownloads_upload.tpl @@ -41,7 +41,7 @@ maxHeightImageError: "<{$smarty.const._MAXHEIGHTIMAGEERROR}>", maxWidthImageError: "<{$smarty.const._MAXWIDTHIMAGEERROR}>", minHeightImageError: "<{$smarty.const._MINHEIGHTIMAGEERROR}>", - minWidthImageError: "<{$smarty.const.__MINWIDTHIMAGEERROR}>", + minWidthImageError: "<{$smarty.const._MINWIDTHIMAGEERROR}>", retryFailTooManyItems: "<{$smarty.const._RETRYFAILTOOMANYITEMS}>", onLeave: "<{$smarty.const._ONLEAVE}>", unsupportedBrowserIos8Safari: "<{$smarty.const._UNSUPPORTEDBROWSERIOS8SAFARI}>" diff --git a/testdata/english/group_permission.yml b/testdata/english/group_permission.yml new file mode 100644 index 0000000..b7924c6 --- /dev/null +++ b/testdata/english/group_permission.yml @@ -0,0 +1,115 @@ +- + gperm_groupid: '2' + gperm_itemid: '32' + gperm_modid: '1831' + gperm_name: tdmdownloads_ac +- + gperm_groupid: '2' + gperm_itemid: '16' + gperm_modid: '1831' + gperm_name: tdmdownloads_ac +- + gperm_groupid: '2' + gperm_itemid: '8' + gperm_modid: '1831' + gperm_name: tdmdownloads_ac +- + gperm_groupid: '2' + gperm_itemid: '4' + gperm_modid: '1831' + gperm_name: tdmdownloads_ac +- + gperm_groupid: '1' + gperm_itemid: '64' + gperm_modid: '1831' + gperm_name: tdmdownloads_ac +- + gperm_groupid: '1' + gperm_itemid: '32' + gperm_modid: '1831' + gperm_name: tdmdownloads_ac +- + gperm_groupid: '1' + gperm_itemid: '16' + gperm_modid: '1831' + gperm_name: tdmdownloads_ac +- + gperm_groupid: '1' + gperm_itemid: '8' + gperm_modid: '1831' + gperm_name: tdmdownloads_ac +- + gperm_groupid: '1' + gperm_itemid: '4' + gperm_modid: '1831' + gperm_name: tdmdownloads_ac +- + gperm_groupid: '2' + gperm_itemid: '2' + gperm_modid: '1831' + gperm_name: tdmdownloads_download +- + gperm_groupid: '2' + gperm_itemid: '1' + gperm_modid: '1831' + gperm_name: tdmdownloads_download +- + gperm_groupid: '1' + gperm_itemid: '2' + gperm_modid: '1831' + gperm_name: tdmdownloads_download +- + gperm_groupid: '1' + gperm_itemid: '1' + gperm_modid: '1831' + gperm_name: tdmdownloads_download +- + gperm_groupid: '2' + gperm_itemid: '2' + gperm_modid: '1831' + gperm_name: tdmdownloads_submit +- + gperm_groupid: '2' + gperm_itemid: '1' + gperm_modid: '1831' + gperm_name: tdmdownloads_submit +- + gperm_groupid: '1' + gperm_itemid: '2' + gperm_modid: '1831' + gperm_name: tdmdownloads_submit +- + gperm_groupid: '1' + gperm_itemid: '1' + gperm_modid: '1831' + gperm_name: tdmdownloads_submit +- + gperm_groupid: '3' + gperm_itemid: '2' + gperm_modid: '1831' + gperm_name: tdmdownloads_view +- + gperm_groupid: '3' + gperm_itemid: '1' + gperm_modid: '1831' + gperm_name: tdmdownloads_view +- + gperm_groupid: '2' + gperm_itemid: '2' + gperm_modid: '1831' + gperm_name: tdmdownloads_view +- + gperm_groupid: '2' + gperm_itemid: '1' + gperm_modid: '1831' + gperm_name: tdmdownloads_view +- + gperm_groupid: '1' + gperm_itemid: '2' + gperm_modid: '1831' + gperm_name: tdmdownloads_view +- + gperm_groupid: '1' + gperm_itemid: '1' + gperm_modid: '1831' + gperm_name: tdmdownloads_view From d8ca99d9dc0ebb8aef61ee05c41bacc6a5b7b6e9 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 8 Aug 2021 22:13:45 -0400 Subject: [PATCH 51/62] Language translations adjustments --- language/english/common.php | 48 ++++++++++++++++++----- language/french/common.php | 63 ++++++++++++++++++++++++++++-- language/german/common.php | 77 +++++++++++++++++++++++++++++++++---- 3 files changed, 168 insertions(+), 20 deletions(-) diff --git a/language/english/common.php b/language/english/common.php index 69b6b5b..ccabadf 100644 --- a/language/english/common.php +++ b/language/english/common.php @@ -156,18 +156,48 @@ \define('CO_' . $moduleDirNameUpper . '_' . 'PERMNOTSET', 'The permission cannot be set'); //FileChecker -//\define('CO_' . $moduleDirNameUpper . '_' . 'AVAILABLE', "Available"); -//\define('CO_' . $moduleDirNameUpper . '_' . 'NOTAVAILABLE', "Not available"); -//\define('CO_' . $moduleDirNameUpper . '_' . 'NOTWRITABLE', "Should have permission ( %d ), but it has ( %d )"); -//\define('CO_' . $moduleDirNameUpper . '_' . 'COPYTHEFILE', 'Copy it'); -//\define('CO_' . $moduleDirNameUpper . '_' . 'CREATETHEFILE', 'Create it'); -//\define('CO_' . $moduleDirNameUpper . '_' . 'SETMPERM', 'Set the permission'); - +\define('CO_' . $moduleDirNameUpper . '_' . 'COPYTHEFILE', 'Copy it'); \define('CO_' . $moduleDirNameUpper . '_' . 'FILECOPIED', 'The file has been copied'); \define('CO_' . $moduleDirNameUpper . '_' . 'FILENOTCOPIED', 'The file cannot be copied'); -//\define('CO_' . $moduleDirNameUpper . '_' . 'PERMSET', 'The permission has been set'); -//\define('CO_' . $moduleDirNameUpper . '_' . 'PERMNOTSET', 'The permission cannot be set'); +//Uploader +define('CO_' . $moduleDirNameUpper . '_' . 'IMAGES_UPLOAD', 'Upload Files'); + +// ---------------- Errors ---------------- +define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEIMG_THUMBS', 'Error when creating thumb image: %s'); +define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEIMG_MEDIUM', 'Error when creating medium image: %s'); +define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEWM_MEDIUM', 'Error when adding watermark to medium image: %s (reason: %g)'); +define('CO_' . $moduleDirNameUpper . '_' . 'FAILSAVEWM_LARGE', 'Error when adding watermark to large image: %s (reason: %g)'); + +// Album buttons +define('CO_' . $moduleDirNameUpper . '_' . 'ALBUM_ADD', 'Add Category'); +define('CO_' . $moduleDirNameUpper . '_' . 'ALBUM_EDIT', 'Edit Category'); + +//Uploader +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_ADD', 'Add Field'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_EDIT', 'Edit Field'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_TITLE', 'Title'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_FID', 'ID'); +define('CO_' . $moduleDirNameUpper . '_' . 'FORMIMAGE_PATH', 'File Path'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_IMG', 'File Field'); + +define('CO_' . $moduleDirNameUpper . '_' . 'FORMUPLOAD', 'Upload'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_WEIGHT', 'Weight'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_STATUS', 'Status'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_SEARCH', 'Search'); +define('CO_' . $moduleDirNameUpper . '_' . 'FIELD_STATUS_DEF', 'Status Defi'); + +// fine uploader +define('CO_' . $moduleDirNameUpper . '_' . 'FU_SUBMIT', 'Submitting file: '); +define('CO_' . $moduleDirNameUpper . '_' . 'FU_SUBMITTED', 'File successfully checked, please upload'); +define('CO_' . $moduleDirNameUpper . '_' . 'FU_UPLOAD', 'Upload file: '); +define('CO_' . $moduleDirNameUpper . '_' . 'FU_FAILED', 'Errors occurred during uploading the file'); +define('CO_' . $moduleDirNameUpper . '_' . 'FU_SUCCEEDED', 'Successfully uploaded all files'); + +define('CO_' . $moduleDirNameUpper . '_' . 'SELECT', 'Select Category'); +define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_CATPID', 'Error: parent category not found'); + + //image config \define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH', 'Image Display Width'); diff --git a/language/french/common.php b/language/french/common.php index 6af077c..b30f35c 100644 --- a/language/french/common.php +++ b/language/french/common.php @@ -19,7 +19,7 @@ * @since 3.23 * @author Xoops Development Team */ -$moduleDirName = basename(dirname(dirname(__DIR__))); +$moduleDirName = basename(dirname(__DIR__, 2)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); define('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS', 'GD library support: '); @@ -47,9 +47,9 @@ define('CO_' . $moduleDirNameUpper . '_ERROR_COLUMN', 'Could not create column in database : %s'); define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS', 'This module requires XOOPS %s+ (%s installed)'); define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP', 'This module requires PHP version %s+ (%s installed)'); -define('CO_' . $moduleDirNameUpper . '_ERROR_TAG_REMOVAL', 'Could not remove tags from Tag Module'); +\define('CO_' . $moduleDirNameUpper . '_ERROR_TAG_REMOVAL', 'Could not remove tags from Tag Module'); -define('CO_' . $moduleDirNameUpper . '_FOLDERS_DELETED_OK', 'Upload Folders have been deleted'); +\define('CO_' . $moduleDirNameUpper . '_FOLDERS_DELETED_OK', 'Upload Folders have been deleted'); // Error Msgs define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH', 'Could not delete %s directory'); @@ -62,7 +62,7 @@ define('CO_' . $moduleDirNameUpper . '_BACK_2_ADMIN', 'Back to Administration of '); define('CO_' . $moduleDirNameUpper . '_OVERVIEW', 'Overview'); -//define('CO_' . $moduleDirNameUpper . '_HELP_DIR', __DIR__); +//\define('CO_' . $moduleDirNameUpper . '_HELP_DIR', __DIR__); //help multi-page define('CO_' . $moduleDirNameUpper . '_DISCLAIMER', 'Disclaimer'); @@ -78,6 +78,15 @@ define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA', 'Export DB Schema to YAML'); define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS', 'Export DB Schema to YAML was a success'); define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR', 'ERROR: Export of DB Schema to YAML failed'); +\define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA', 'Export DB Schema to YAML'); +\define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS', 'Export DB Schema to YAML was a success'); +\define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR', 'ERROR: Export of DB Schema to YAML failed'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON', 'Show Sample Button?'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON_DESC', 'If yes, the "Add Sample Data" button will be visible to the Admin. It is Yes as a default for first installation.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS', 'Hide the Import buttons)'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS', 'Show the Import buttons)'); + +\define('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM', 'Confirm'); //letter choice define('CO_' . $moduleDirNameUpper . '_' . 'BROWSETOTOPIC', "Browse items alphabetically"); @@ -113,6 +122,8 @@ //myblocksadmin define('CO_' . $moduleDirNameUpper . '_' . 'AGDS', 'Admin Groups'); define('CO_' . $moduleDirNameUpper . '_' . 'BCACHETIME', 'Cache Time'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_ADMIN', 'Blocks Admin'); +\define('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS', 'Update successful'); //Template Admin define('CO_' . $moduleDirNameUpper . '_' . 'TPLSETS', 'Template Management'); @@ -123,10 +134,32 @@ define('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_MIGRATE', 'Migrate'); define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_YES', 'Folder "%s" exist'); define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_NO', 'Folder "%s" does not exist. Create the specified folder with CHMOD 777.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS', 'Show Development Tools Button?'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS_DESC', 'If yes, the "Migrate" Tab and other Development tools will be visible to the Admin.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_FEEDBACK', 'Feedback'); +\define('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_OK', 'Database migrated to current schema.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_WARNING', 'Warning! This is intended for developers only. Confirm write schema file from current database.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_SCHEMA_OK', 'Current schema file written'); //Latest Version Check define('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION', 'New Version: '); +//DirectoryChecker +\define('CO_' . $moduleDirNameUpper . '_' . 'AVAILABLE', "Available"); +\define('CO_' . $moduleDirNameUpper . '_' . 'NOTAVAILABLE', "Not available"); +\define('CO_' . $moduleDirNameUpper . '_' . 'NOTWRITABLE', "Should have permission ( %d ), but it has ( %d )"); +\define('CO_' . $moduleDirNameUpper . '_' . 'CREATETHEDIR', 'Create it'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SETMPERM', 'Set the permission'); +\define('CO_' . $moduleDirNameUpper . '_' . 'DIRCREATED', 'The directory has been created'); +\define('CO_' . $moduleDirNameUpper . '_' . 'DIRNOTCREATED', 'The directory cannot be created'); +\define('CO_' . $moduleDirNameUpper . '_' . 'PERMSET', 'The permission has been set'); +\define('CO_' . $moduleDirNameUpper . '_' . 'PERMNOTSET', 'The permission cannot be set'); + +//FileChecker +\define('CO_' . $moduleDirNameUpper . '_' . 'COPYTHEFILE', 'Copy it'); +\define('CO_' . $moduleDirNameUpper . '_' . 'FILECOPIED', 'The file has been copied'); +\define('CO_' . $moduleDirNameUpper . '_' . 'FILENOTCOPIED', 'The file cannot be copied'); + //Uploader define('CO_' . $moduleDirNameUpper . '_' . 'IMAGES_UPLOAD', 'Upload Files'); @@ -161,6 +194,12 @@ define('CO_' . $moduleDirNameUpper . '_' . 'FU_FAILED', 'Errors occurred during uploading the file'); define('CO_' . $moduleDirNameUpper . '_' . 'FU_SUCCEEDED', 'Successfully uploaded all files'); + +define('CO_' . $moduleDirNameUpper . '_' . 'SELECT', 'Select Category'); +define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_CATPID', 'Error: parent category not found'); + + + //image config define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH', 'Image Display Width'); define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH_DSC', 'Display width for image'); @@ -170,3 +209,19 @@ define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG_DSC', ''); define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH', 'Image Upload path'); define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH_DSC', 'Path for uploading images'); + +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_FILE_SIZE', 'Image File Size (in Bytes)'); +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_FILE_SIZE_DSC','The maximum file size of the image file (in Bytes)'); + +//Preferences +\define('CO_' . $moduleDirNameUpper . '_' . 'TRUNCATE_LENGTH', 'Number of Characters to truncate to the long text field'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TRUNCATE_LENGTH_DESC', 'Set the maximum number of characters to truncate the long text fields'); + +//Module Stats +\define('CO_' . $moduleDirNameUpper . '_' . 'STATS_SUMMARY', 'Module Statistics'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_CATEGORIES', 'Categories:'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_ITEMS', 'Items'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_OFFLINE', 'Offline'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_PUBLISHED', 'Published'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_REJECTED', 'Rejected'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_SUBMITTED', 'Submitted'); diff --git a/language/german/common.php b/language/german/common.php index 3f0bf58..70e43da 100644 --- a/language/german/common.php +++ b/language/german/common.php @@ -19,7 +19,7 @@ * @since 3.23 * @author Xoops Development Team */ -$moduleDirName = basename(dirname(dirname(__DIR__))); +$moduleDirName = basename(dirname(__DIR__, 2)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); define('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS', 'GD library support: '); @@ -47,6 +47,10 @@ define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP', 'Dieses Modul benötigt PHP Version %s+ (%s installiert)'); define('CO_' . $moduleDirNameUpper . '_ERROR_TAG_REMOVAL', 'Konnte Tags vom Tag-Modul nicht entfernen'); define('CO_' . $moduleDirNameUpper . '_FOLDERS_DELETED_OK', 'Upload-Verzeichnisse wurden gelöscht'); +\define('CO_' . $moduleDirNameUpper . '_ERROR_TAG_REMOVAL', 'Could not remove tags from Tag Module'); + +\define('CO_' . $moduleDirNameUpper . '_FOLDERS_DELETED_OK', 'Upload Folders have been deleted'); + // Error Msgs define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH', 'Konnte Verzeichnis %s nicht löschen'); define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_REMOVE', 'Konnte %s nicht löschen'); @@ -56,6 +60,8 @@ define('CO_' . $moduleDirNameUpper . '_HELP_HEADER', __DIR__ . '/help/helpheader.tpl'); define('CO_' . $moduleDirNameUpper . '_BACK_2_ADMIN', 'Zurück zur Administration von '); define('CO_' . $moduleDirNameUpper . '_OVERVIEW', 'Übersicht'); + +//\define('CO_' . $moduleDirNameUpper . '_HELP_DIR', __DIR__); //help multi-page define('CO_' . $moduleDirNameUpper . '_DISCLAIMER', 'Disclaimer'); define('CO_' . $moduleDirNameUpper . '_LICENSE', 'Lizenz'); @@ -69,10 +75,21 @@ define('CO_' . $moduleDirNameUpper . '_EXPORT_SCHEMA', 'Export DB Schema für YAML'); define('CO_' . $moduleDirNameUpper . '_EXPORT_SCHEMA_SUCCESS', 'Export DB Schema zu YAML erfolgreich'); define('CO_' . $moduleDirNameUpper . '_EXPORT_SCHEMA_ERROR', 'ERROR: Export des DB Schema zu YAML fehlgeschlagen'); +\define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA', 'Export DB Schema to YAML'); +\define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS', 'Export DB Schema to YAML was a success'); +\define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR', 'ERROR: Export of DB Schema to YAML failed'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON', 'Show Sample Button?'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON_DESC', 'If yes, the "Add Sample Data" button will be visible to the Admin. It is Yes as a default for first installation.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS', 'Hide the Import buttons)'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS', 'Show the Import buttons)'); + +\define('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM', 'Confirm'); + //letter choice define('CO_' . $moduleDirNameUpper . '_BROWSETOTOPIC', "Einträge alphabetisch anzeigen"); define('CO_' . $moduleDirNameUpper . '_OTHER', 'Andere'); define('CO_' . $moduleDirNameUpper . '_ALL', 'Alle'); + // block defines define('CO_' . $moduleDirNameUpper . '_ACCESSRIGHTS', 'Zugriffsberechtigungen'); define('CO_' . $moduleDirNameUpper . '_ACTION', 'Aktion'); @@ -96,10 +113,14 @@ define('CO_' . $moduleDirNameUpper . '_BLOCKS_ADDBLOCK', 'Add a new block'); define('CO_' . $moduleDirNameUpper . '_BLOCKS_EDITBLOCK', 'Edit a block'); define('CO_' . $moduleDirNameUpper . '_BLOCKS_CLONEBLOCK', 'Clone a block'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_EDITBLOCK', 'Edit a block'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK', 'Clone a block'); + //myblocksadmin define('CO_' . $moduleDirNameUpper . '_' . 'AGDS', 'Admin Groups'); define('CO_' . $moduleDirNameUpper . '_' . 'BCACHETIME', 'Cache Time'); -define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_ADMIN', 'Blocks Admin'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_ADMIN', 'Blocks Admin'); +\define('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS', 'Update successful'); //Template Admin define('CO_' . $moduleDirNameUpper . '_' . 'TPLSETS', 'Template Management'); @@ -107,15 +128,35 @@ define('CO_' . $moduleDirNameUpper . '_' . 'FILENAME', 'File Name'); //Menu -define('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_MIGRATE', 'Migrate'); -define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_YES', 'Folder "%s" exist'); -define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_NO', 'Folder "%s" does not exist. Create the specified folder with CHMOD 777.'); -define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS', 'Show Development Tools Button?'); -define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS_DESC', 'If yes, the "Migrate" Tab and other Development tools will be visible to the Admin.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_MIGRATE', 'Migrate'); +\define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_YES', 'Folder "%s" exist'); +\define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_NO', 'Folder "%s" does not exist. Create the specified folder with CHMOD 777.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS', 'Show Development Tools Button?'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS_DESC', 'If yes, the "Migrate" Tab and other Development tools will be visible to the Admin.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_FEEDBACK', 'Feedback'); +\define('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_OK', 'Database migrated to current schema.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_WARNING', 'Warning! This is intended for developers only. Confirm write schema file from current database.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_SCHEMA_OK', 'Current schema file written'); //Latest Version Check define('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION', 'New Version: '); +//DirectoryChecker +\define('CO_' . $moduleDirNameUpper . '_' . 'AVAILABLE', "Available"); +\define('CO_' . $moduleDirNameUpper . '_' . 'NOTAVAILABLE', "Not available"); +\define('CO_' . $moduleDirNameUpper . '_' . 'NOTWRITABLE', "Should have permission ( %d ), but it has ( %d )"); +\define('CO_' . $moduleDirNameUpper . '_' . 'CREATETHEDIR', 'Create it'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SETMPERM', 'Set the permission'); +\define('CO_' . $moduleDirNameUpper . '_' . 'DIRCREATED', 'The directory has been created'); +\define('CO_' . $moduleDirNameUpper . '_' . 'DIRNOTCREATED', 'The directory cannot be created'); +\define('CO_' . $moduleDirNameUpper . '_' . 'PERMSET', 'The permission has been set'); +\define('CO_' . $moduleDirNameUpper . '_' . 'PERMNOTSET', 'The permission cannot be set'); + +//FileChecker +\define('CO_' . $moduleDirNameUpper . '_' . 'COPYTHEFILE', 'Copy it'); +\define('CO_' . $moduleDirNameUpper . '_' . 'FILECOPIED', 'The file has been copied'); +\define('CO_' . $moduleDirNameUpper . '_' . 'FILENOTCOPIED', 'The file cannot be copied'); + //Uploader define('CO_' . $moduleDirNameUpper . '_' . 'IMAGES_UPLOAD', 'Upload Files'); @@ -150,6 +191,12 @@ define('CO_' . $moduleDirNameUpper . '_' . 'FU_FAILED', 'Errors occurred during uploading the file'); define('CO_' . $moduleDirNameUpper . '_' . 'FU_SUCCEEDED', 'Successfully uploaded all files'); + +define('CO_' . $moduleDirNameUpper . '_' . 'SELECT', 'Select Category'); +define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_CATPID', 'Error: parent category not found'); + + + //image config define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH', 'Image Display Width'); define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH_DSC', 'Display width for image'); @@ -159,3 +206,19 @@ define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG_DSC', ''); define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH', 'Image Upload path'); define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH_DSC', 'Path for uploading images'); + +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_FILE_SIZE', 'Image File Size (in Bytes)'); +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_FILE_SIZE_DSC','The maximum file size of the image file (in Bytes)'); + +//Preferences +\define('CO_' . $moduleDirNameUpper . '_' . 'TRUNCATE_LENGTH', 'Number of Characters to truncate to the long text field'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TRUNCATE_LENGTH_DESC', 'Set the maximum number of characters to truncate the long text fields'); + +//Module Stats +\define('CO_' . $moduleDirNameUpper . '_' . 'STATS_SUMMARY', 'Module Statistics'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_CATEGORIES', 'Categories:'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_ITEMS', 'Items'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_OFFLINE', 'Offline'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_PUBLISHED', 'Published'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_REJECTED', 'Rejected'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_SUBMITTED', 'Submitted'); From 8a8f7e11594d94a763e5c074e132705f3970e12b Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 8 Aug 2021 22:14:04 -0400 Subject: [PATCH 52/62] namespaces --- header.php | 12 ++++++++++-- search.php | 15 +++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/header.php b/header.php index 8341235..85144b9 100644 --- a/header.php +++ b/header.php @@ -14,6 +14,15 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + +use XoopsModules\Tdmdownloads\{ + Helper, + Utility +}; +/** @var Helper $helper */ +/** @var Utility $utility */ + + require dirname(dirname(__DIR__)) . '/mainfile.php'; $moduleDirName = basename(__DIR__); @@ -24,8 +33,7 @@ //require_once XOOPS_ROOT_PATH . '/class/tree.php'; //require_once XOOPS_ROOT_PATH.'/class/xoopsform/grouppermform.php'; -/** @var \XoopsModules\Tdmdownloads\Helper $helper */ -$helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); +$helper = Helper::getInstance(); $permHelper = new \Xmf\Module\Helper\Permission(); diff --git a/search.php b/search.php index 004d1ca..6e3b2c8 100644 --- a/search.php +++ b/search.php @@ -15,13 +15,20 @@ * @author Gregory Mage (Aka Mage) */ -use XoopsModules\Tdmdownloads; +use XoopsModules\Tdmdownloads\{ + DownloadsHandler, + Helper, + Utility +}; +/** @var Helper $helper */ +/** @var Utility $utility */ require_once __DIR__ . '/header.php'; -/** @var \XoopsModules\Tdmdownloads\Helper $helper */ -$helper = Tdmdownloads\Helper::getInstance(); $moduleDirName = basename(__DIR__); +$helper = Helper::getInstance(); +$utility = new Utility(); +$downloadsHandler = $helper->getHandler('Downloads'); // template d'affichage $GLOBALS['xoopsOption']['template_main'] = 'tdmdownloads_liste.tpl'; @@ -64,7 +71,7 @@ $form->addElement($mytree->makeSelectElement('cat', 'cat_title', '--', $cat, true, 0, '', _AM_TDMDOWNLOADS_FORMINCAT), true); //recherche champ sup. -//$fieldHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Field'); +//$fieldHandler = Helper::getInstance()->getHandler('Field'); $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('search', 1)); $criteria->add(new \Criteria('status', 1)); From c8eadf0319cb1cd7de721a81ea7af5467464b603 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 8 Aug 2021 22:14:55 -0400 Subject: [PATCH 53/62] 2.01 Beta 1 --- docs/changelog.txt | 12 +++++++++++- xoops_version.php | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 7b8a8ef..e739e43 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -1,3 +1,14 @@ +
    2.01 Beta 1 [2021-08-08]
    Dev: XOOPS 2.5.11, PHP 7.4.22, PHP 8.08 +
    +- PHP 7.1 & PHP 8 (mamba) +- various updates/cosmetics (mamba) +- replace index.html with index.php (mamba) +- PHP 8 Smarty defaults (mamba) +- fix PHP8 Unknown format specifier "{" (mamba) +- add TestdataButtons and testdata (mamba) +- Language translations adjustments (mamba) + +
    2.01 Alpha 1 [2020-05-018]
    Dev: XOOPS 2.5.11, PHP 7.4.6
    - added hits and ratings and for output of download in index.php (goffy) @@ -10,7 +21,6 @@ - Fix xml (geekwright) - add extra fields visibility (heyula) - refactor Utility (mamba) -- PHP 7.1 (mamba)
    2.0 RC 1 [2019-01-29]
    diff --git a/xoops_version.php b/xoops_version.php index 546ae7e..ee38dff 100644 --- a/xoops_version.php +++ b/xoops_version.php @@ -27,8 +27,8 @@ $modversion = [ 'name' => _MI_TDMDOWNLOADS_NAME, 'version' => '2.01', - 'module_status' => 'Alpha 1', - 'release_date' => '2020/05/18', + 'module_status' => 'Beta 1', + 'release_date' => '2021/08/08', 'description' => _MI_TDMDOWNLOADS_DESC, 'credits' => 'Mage, Mamba, Goffy, Heyula', 'author' => 'Mage', From a706ac2eab06fc4cc6fb079d6d5226b8eb997809 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 8 Aug 2021 22:59:39 -0400 Subject: [PATCH 54/62] Fully qualified name replaced with import --- admin/admin_header.php | 9 ++++++--- admin/broken.php | 10 ++++++--- admin/category.php | 29 +++++++++++++++++---------- admin/downloads.php | 21 ++++++++++--------- admin/field.php | 14 ++++++++----- admin/import.php | 15 +++++++++----- admin/index.php | 1 - admin/menu.php | 8 ++++++-- admin/migrate.php | 5 +++-- admin/modified.php | 5 ++++- admin/permissions.php | 8 ++++++-- blocks/tdmdownloads_search.php | 16 +++++++++------ blocks/tdmdownloads_top.php | 6 ++++-- brokenfile.php | 5 ++++- class/Category.php | 3 ++- class/Common/FineimpuploadHandler.php | 11 +++++++--- config/icons.php | 4 +++- config/imageconfig.php | 4 +++- extra/plugins/tag/tdmdownloads.php | 4 +++- header.php | 4 +++- include/common.php | 28 ++++++++++++++------------ include/oninstall.php | 4 +++- include/onupdate.php | 4 +++- index.php | 9 +++++++-- modfile.php | 9 +++++++-- ratefile.php | 5 ++++- rss.php | 5 ++++- search.php | 6 +++--- singlefile.php | 10 ++++++--- submit.php | 9 ++++++--- upload.php | 14 +++++++++---- viewcat.php | 10 +++++++-- visit.php | 5 ++++- 33 files changed, 202 insertions(+), 98 deletions(-) diff --git a/admin/admin_header.php b/admin/admin_header.php index 26192b9..015b0b3 100644 --- a/admin/admin_header.php +++ b/admin/admin_header.php @@ -15,7 +15,10 @@ * @author Gregory Mage (Aka Mage) */ -use XoopsModules\Tdmdownloads\Tree; +use Xmf\Module\Admin; +use XoopsModules\Tdmdownloads\{ + Helper, + Tree}; // Include xoops admin header require_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php'; @@ -32,10 +35,10 @@ $moduleDirName = basename(dirname(__DIR__)); /** @var \XoopsModules\Tdmdownloads\Helper $helper */ -$helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); +$helper = Helper::getInstance(); /** @var \Xmf\Module\Admin $adminObject */ -$adminObject = \Xmf\Module\Admin::getInstance(); +$adminObject = Admin::getInstance(); $myts = \MyTextSanitizer::getInstance(); diff --git a/admin/broken.php b/admin/broken.php index d1f5aa1..05e7be9 100644 --- a/admin/broken.php +++ b/admin/broken.php @@ -14,13 +14,17 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + +use Xmf\Module\Admin; +use XoopsModules\Tdmdownloads\Helper; + require __DIR__ . '/admin_header.php'; // Template $templateMain = 'tdmdownloads_admin_broken.tpl'; /** @var \XoopsModules\Tdmdownloads\Helper $helper */ -$helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); +$helper = Helper::getInstance(); //On recupere la valeur de l'argument op dans l'URL$ $op = \Xmf\Request::getCmd('op', 'list'); @@ -31,7 +35,7 @@ case 'list': //Affichage de la partie haute de l'administration de Xoops xoops_cp_header(); - $adminObject = \Xmf\Module\Admin::getInstance(); + $adminObject = Admin::getInstance(); $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); $criteria = new \CriteriaCompo(); @@ -111,7 +115,7 @@ xoops_cp_header(); - $adminObject = \Xmf\Module\Admin::getInstance(); + $adminObject = Admin::getInstance(); $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('broken.php')); diff --git a/admin/category.php b/admin/category.php index bc51a19..dd0bbd1 100644 --- a/admin/category.php +++ b/admin/category.php @@ -1,6 +1,13 @@ assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); $adminObject->addItemButton(_AM_TDMDOWNLOADS_CAT_NEW, 'category.php?op=new_cat', 'add'); $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); @@ -49,7 +56,7 @@ if (count($downloads_cat) > 0) { $GLOBALS['xoopsTpl']->assign('categories_count', count($downloads_cat)); - $mytree = new \XoopsModules\Tdmdownloads\Tree($downloads_cat, 'cat_cid', 'cat_pid'); + $mytree = new Tree($downloads_cat, 'cat_cid', 'cat_pid'); $category_ArrayTree = $mytree->makeArrayTree('cat_title', ''); @@ -78,7 +85,7 @@ case 'new_cat': //Affichage de la partie haute de l'administration de Xoops xoops_cp_header(); - $adminObject = \Xmf\Module\Admin::getInstance(); + $adminObject = Admin::getInstance(); $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); $adminObject->addItemButton(_AM_TDMDOWNLOADS_CAT_LIST, 'category.php?op=list', 'list'); $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); @@ -94,7 +101,7 @@ case 'edit_cat': //Affichage de la partie haute de l'administration de Xoops xoops_cp_header(); - $adminObject = \Xmf\Module\Admin::getInstance(); + $adminObject = Admin::getInstance(); $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); $adminObject->addItemButton(_AM_TDMDOWNLOADS_CAT_LIST, 'category.php?op=list', 'list'); $adminObject->addItemButton(_AM_TDMDOWNLOADS_CAT_NEW, 'category.php?op=new_cat', 'add'); @@ -190,7 +197,7 @@ if (1 == $helper->getConfig('usetag') && class_exists(LinkHandler::class)) { /** @var \XoopsModules\Tag\LinkHandler $linkHandler */ - $linkHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Link'); + $linkHandler = TagHelper::getInstance()->getHandler('Link'); $criteria = new \CriteriaCompo(); @@ -236,7 +243,7 @@ $downloadscatArray = $categoryHandler->getAll(); - $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); + $mytree = new Tree($downloadscatArray, 'cat_cid', 'cat_pid'); $downloads_childcat = $mytree->getAllChild($categoryId); @@ -311,7 +318,7 @@ if (1 == $helper->getConfig('usetag') && class_exists(LinkHandler::class)) { /** @var \XoopsModules\Tag\LinkHandler $linkHandler */ - $linkHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Link'); + $linkHandler = TagHelper::getInstance()->getHandler('Link'); $criteria = new \CriteriaCompo(); @@ -371,7 +378,7 @@ $downloadscatArray = $categoryHandler->getAll(); - $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); + $mytree = new Tree($downloadscatArray, 'cat_cid', 'cat_pid'); $downloads_childcat = $mytree->getAllChild($categoryId); @@ -405,7 +412,7 @@ xoops_cp_header(); - $adminObject = \Xmf\Module\Admin::getInstance(); + $adminObject = Admin::getInstance(); $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); diff --git a/admin/downloads.php b/admin/downloads.php index e87e9f6..8e75922 100644 --- a/admin/downloads.php +++ b/admin/downloads.php @@ -1,8 +1,11 @@ assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); if (1 == $statusMenu) { $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_NEW, 'downloads.php?op=new_downloads', 'add'); @@ -193,7 +196,7 @@ $GLOBALS['xoopsTpl']->assign('selectOrder', $selectOrder); - $mytree = new \XoopsModules\Tdmdownloads\Tree($categoryArray, 'cat_cid', 'cat_pid'); + $mytree = new Tree($categoryArray, 'cat_cid', 'cat_pid'); $class = 'odd'; @@ -224,7 +227,7 @@ case 'new_downloads': //Affichage de la partie haute de l'administration de Xoops xoops_cp_header(); - $adminObject = \Xmf\Module\Admin::getInstance(); + $adminObject = Admin::getInstance(); $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_LISTE, 'downloads.php?op=list', 'list'); $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_NEW, 'downloads.php?op=new_downloads', 'add'); @@ -245,7 +248,7 @@ case 'edit_downloads': //Affichage de la partie haute de l'administration de Xoops xoops_cp_header(); - $adminObject = \Xmf\Module\Admin::getInstance(); + $adminObject = Admin::getInstance(); $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_LISTE, 'downloads.php?op=list', 'list'); $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_NEW, 'downloads.php?op=new_downloads', 'add'); @@ -347,7 +350,7 @@ if (1 == $helper->getConfig('usetag') && class_exists(LinkHandler::class)) { /** @var \XoopsModules\Tag\LinkHandler $linkHandler */ - $linkHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Link'); + $linkHandler = Helper::getInstance()->getHandler('Link'); $criteria = new \CriteriaCompo(); @@ -373,7 +376,7 @@ xoops_cp_header(); - $adminObject = \Xmf\Module\Admin::getInstance(); + $adminObject = Admin::getInstance(); $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); @@ -400,7 +403,7 @@ case 'view_downloads': //Affichage de la partie haute de l'administration de Xoops xoops_cp_header(); - $adminObject = \Xmf\Module\Admin::getInstance(); + $adminObject = Admin::getInstance(); $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_LISTE, 'downloads.php?op=list', 'list'); $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_NEW, 'downloads.php?op=new_downloads', 'add'); @@ -418,7 +421,7 @@ //catégorie //$view_category = $categoryHandler->get($viewDownloads->getVar('cid')); $categoryArray = $categoryHandler->getAll(); - $mytree = new \XoopsModules\Tdmdownloads\Tree($categoryArray, 'cat_cid', 'cat_pid'); + $mytree = new Tree($categoryArray, 'cat_cid', 'cat_pid'); // sortie des informations $downloads_title = $viewDownloads->getVar('title'); $downloads_description = $viewDownloads->getVar('description'); @@ -875,7 +878,7 @@ if (1 == $helper->getConfig('usetag') && class_exists(TagHandler::class)) { /** @var \XoopsModules\Tag\TagHandler $tagHandler */ - $tagHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Tag'); + $tagHandler = Helper::getInstance()->getHandler('Tag'); $tagHandler->updateByItem($_POST['tag'], $lidDownloads, $moduleDirName, 0); } diff --git a/admin/field.php b/admin/field.php index 8a92b66..4881e2e 100644 --- a/admin/field.php +++ b/admin/field.php @@ -14,13 +14,17 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + +use Xmf\Module\Admin; +use XoopsModules\Tdmdownloads\Helper; + require __DIR__ . '/admin_header.php'; require dirname(__DIR__) . '/include/common.php'; // Template $templateMain = 'tdmdownloads_admin_field.tpl'; /** @var \XoopsModules\Tdmdownloads\Helper $helper */ -$helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); +$helper = Helper::getInstance(); //On recupere la valeur de l'argument op dans l'URL$ $op = \Xmf\Request::getCmd('op', 'list'); @@ -31,7 +35,7 @@ case 'list': //Affichage de la partie haute de l'administration de Xoops xoops_cp_header(); - $adminObject = \Xmf\Module\Admin::getInstance(); + $adminObject = Admin::getInstance(); $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); $adminObject->addItemButton(_AM_TDMDOWNLOADS_FIELD_NEW, 'field.php?op=new_field', 'add'); $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); @@ -87,7 +91,7 @@ case 'new_field': //Affichage de la partie haute de l'administration de Xoops xoops_cp_header(); - $adminObject = \Xmf\Module\Admin::getInstance(); + $adminObject = Admin::getInstance(); $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); $adminObject->addItemButton(_AM_TDMDOWNLOADS_FIELD_LIST, 'field.php?op=list', 'list'); $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); @@ -103,7 +107,7 @@ case 'edit_field': //Affichage de la partie haute de l'administration de Xoops xoops_cp_header(); - $adminObject = \Xmf\Module\Admin::getInstance(); + $adminObject = Admin::getInstance(); $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); $adminObject->addItemButton(_AM_TDMDOWNLOADS_FIELD_NEW, 'field.php?op=new_field', 'add'); $adminObject->addItemButton(_AM_TDMDOWNLOADS_FIELD_LIST, 'field.php?op=list', 'list'); @@ -177,7 +181,7 @@ xoops_cp_header(); - $adminObject = \Xmf\Module\Admin::getInstance(); + $adminObject = Admin::getInstance(); $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); diff --git a/admin/import.php b/admin/import.php index a31b92c..38affc4 100644 --- a/admin/import.php +++ b/admin/import.php @@ -14,13 +14,18 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + +use Xmf\Database\TableLoad; +use Xmf\Database\Tables; +use Xmf\Module\Admin; + require __DIR__ . '/admin_header.php'; xoops_cp_header(); // Template $templateMain = 'tdmdownloads_admin_import.tpl'; -$adminObject = \Xmf\Module\Admin::getInstance(); +$adminObject = Admin::getInstance(); //Action dans switch $op = 'index'; @@ -48,9 +53,9 @@ function importMydownloads($path = '', $imgurl = '') $myTables = ['tdmdownloads_broken', 'tdmdownloads_cat', 'tdmdownloads_downloads', 'tdmdownloads_fielddata', 'tdmdownloads_modfielddata', 'tdmdownloads_votedata']; - $table = new \Xmf\Database\TableLoad(); + $table = new TableLoad(); - $tables = new \Xmf\Database\Tables(); + $tables = new Tables(); foreach ($myTables as $myTable) { if ($tables->useTable($myTable)) { // if this returns false, there is no table @@ -206,9 +211,9 @@ function importWfdownloads($shots = '', $catimg = '') $myTables = ['tdmdownloads_broken', 'tdmdownloads_cat', 'tdmdownloads_downloads', 'tdmdownloads_fielddata', 'tdmdownloads_modfielddata', 'tdmdownloads_votedata']; - $table = new \Xmf\Database\TableLoad(); + $table = new TableLoad(); - $tables = new \Xmf\Database\Tables(); + $tables = new Tables(); foreach ($myTables as $myTable) { if ($tables->useTable($myTable)) { // if this returns false, there is no table diff --git a/admin/index.php b/admin/index.php index b6d99c1..5fb5da4 100644 --- a/admin/index.php +++ b/admin/index.php @@ -20,7 +20,6 @@ use XoopsModules\Tdmdownloads\{ Common\Configurator, Common\TestdataButtons, - Forms, Helper, Utility }; diff --git a/admin/menu.php b/admin/menu.php index dc99d4e..6dff328 100644 --- a/admin/menu.php +++ b/admin/menu.php @@ -14,17 +14,21 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + +use Xmf\Module\Admin; +use XoopsModules\Tdmdownloads\Helper; + require dirname(__DIR__) . '/preloads/autoloader.php'; $moduleDirName = basename(dirname(__DIR__)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); /** @var \XoopsModules\Tdmdownloads\Helper $helper */ -$helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); +$helper = Helper::getInstance(); $helper->loadLanguage('common'); $helper->loadLanguage('feedback'); -$pathIcon32 = \Xmf\Module\Admin::menuIconPath(''); +$pathIcon32 = Admin::menuIconPath(''); if (is_object($helper->getModule())) { // $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); $pathModIcon32 = $helper->url($helper->getModule()->getInfo('modicons32')); diff --git a/admin/migrate.php b/admin/migrate.php index de2a542..4019a45 100644 --- a/admin/migrate.php +++ b/admin/migrate.php @@ -31,7 +31,8 @@ // ------------------------------------------------------------------------- // use Xmf\Request; -use XoopsModules\Tdmdownloads; +use XoopsModules\Tdmdownloads\{ + Common\Migrate}; require_once __DIR__ . '/admin_header.php'; xoops_cp_header(); @@ -58,7 +59,7 @@ $configurator = new Tdmdownloads\Common\Configurator(); /** @var \XoopsModules\Tdmdownloads\Common\Migrate $migrator */ -$migrator = new \XoopsModules\Tdmdownloads\Common\Migrate($configurator); +$migrator = new Migrate($configurator); $op = Request::getCmd('op', 'default'); $opShow = Request::getCmd('show', null, 'POST'); diff --git a/admin/modified.php b/admin/modified.php index e63cd9f..8e66d55 100644 --- a/admin/modified.php +++ b/admin/modified.php @@ -14,13 +14,16 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + +use XoopsModules\Tdmdownloads\Helper; + require __DIR__ . '/admin_header.php'; // Template $templateMain = 'tdmdownloads_admin_modified.tpl'; /** @var \XoopsModules\Tdmdownloads\Helper $helper */ -$helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); +$helper = Helper::getInstance(); //On recupere la valeur de l'argument op dans l'URL$ $op = \Xmf\Request::getCmd('op', 'list'); diff --git a/admin/permissions.php b/admin/permissions.php index f48296c..d48b99a 100644 --- a/admin/permissions.php +++ b/admin/permissions.php @@ -14,15 +14,19 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + +use Xmf\Module\Admin; +use XoopsModules\Tdmdownloads\Helper; + require __DIR__ . '/admin_header.php'; xoops_cp_header(); require_once $GLOBALS['xoops']->path('www/class/xoopsform/grouppermform.php'); /** @var \XoopsModules\Tdmdownloads\Helper $helper */ -$helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); +$helper = Helper::getInstance(); -$adminObject = \Xmf\Module\Admin::getInstance(); +$adminObject = Admin::getInstance(); $templateMain = 'tdmdownloads_admin_permissions.tpl'; $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); diff --git a/blocks/tdmdownloads_search.php b/blocks/tdmdownloads_search.php index 875598c..bc68803 100644 --- a/blocks/tdmdownloads_search.php +++ b/blocks/tdmdownloads_search.php @@ -15,6 +15,10 @@ * @author Gregory Mage (Aka Mage) */ +use XoopsModules\Tdmdownloads\{ + Helper, + Tree}; + /** * @return array */ @@ -32,7 +36,7 @@ function b_tdmdownloads_search_show() /** @var \XoopsModules\Tdmdownloads\Helper $helper */ - $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); + $helper = Helper::getInstance(); //appel des class @@ -52,7 +56,7 @@ function b_tdmdownloads_search_show() /** @var \XoopsModules\Tdmdownloads\CategoryHandler $categoryHandler */ - $categoryHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Category'); + $categoryHandler = Helper::getInstance()->getHandler('Category'); $block = []; @@ -78,7 +82,7 @@ function b_tdmdownloads_search_show() $downloadscatArray = $categoryHandler->getAll($criteria); - $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); + $mytree = new Tree($downloadscatArray, 'cat_cid', 'cat_pid'); $form->addElement($mytree->makeSelectElement('cat', 'cat_title', '--', '', true, 0, '', _AM_TDMDOWNLOADS_FORMINCAT), true); @@ -86,7 +90,7 @@ function b_tdmdownloads_search_show() /** @var \XoopsModules\Tdmdownloads\FieldHandler $fieldHandler */ - $fieldHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Field'); + $fieldHandler = Helper::getInstance()->getHandler('Field'); $criteria = new \CriteriaCompo(); @@ -165,7 +169,7 @@ function b_tdmdownloads_search_show() /** @var \XoopsModules\Tdmdownloads\DownloadsHandler $downloadsHandler */ - $downloadsHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Downloads'); + $downloadsHandler = Helper::getInstance()->getHandler('Downloads'); $tdmdownloadsArray = $downloadsHandler->getAll($criteria); @@ -186,7 +190,7 @@ function b_tdmdownloads_search_show() /** @var \XoopsModules\Tdmdownloads\FielddataHandler $fielddataHandler */ - $fielddataHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Fielddata'); + $fielddataHandler = Helper::getInstance()->getHandler('Fielddata'); $tdmdownloadsArray = $fielddataHandler->getAll($criteria); diff --git a/blocks/tdmdownloads_top.php b/blocks/tdmdownloads_top.php index b1839a0..2da2e16 100644 --- a/blocks/tdmdownloads_top.php +++ b/blocks/tdmdownloads_top.php @@ -17,6 +17,8 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) */ +use XoopsModules\Tdmdownloads\Helper; + /** * @param $options * @return array @@ -41,7 +43,7 @@ function b_tdmdownloads_top_show($options) /** @var \XoopsModules\Tdmdownloads\DownloadsHandler $downloadsHandler */ - $downloadsHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Downloads'); + $downloadsHandler = Helper::getInstance()->getHandler('Downloads'); $block = []; @@ -239,7 +241,7 @@ function b_tdmdownloads_top_edit($options) $moduleDirName = basename(dirname(__DIR__)); - $categoryHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Category'); + $categoryHandler = Helper::getInstance()->getHandler('Category'); $criteria = new \CriteriaCompo(); diff --git a/brokenfile.php b/brokenfile.php index 113a7ba..71e2a36 100644 --- a/brokenfile.php +++ b/brokenfile.php @@ -14,6 +14,9 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + +use XoopsModules\Tdmdownloads\Tree; + require_once __DIR__ . '/header.php'; // template d'affichage $moduleDirName = basename(__DIR__); @@ -53,7 +56,7 @@ $criteria->setOrder('ASC'); $criteria->add(new \Criteria('cat_cid', '(' . implode(',', $categories) . ')', 'IN')); $downloadscatArray = $categoryHandler->getAll($criteria); - $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); + $mytree = new Tree($downloadscatArray, 'cat_cid', 'cat_pid'); //navigation $navigation = $utility->getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' arrow ', true, 'ASC', true); $navigation .= ' arrow ' . $viewDownloads->getVar('title') . ''; diff --git a/class/Category.php b/class/Category.php index 89c0f46..6104a8e 100644 --- a/class/Category.php +++ b/class/Category.php @@ -17,6 +17,7 @@ * @author Gregory Mage (Aka Mage) */ +use Xmf\Module\Helper\Permission; use XoopsModules\Tdmdownloads; /** @@ -41,7 +42,7 @@ public function __construct() $this->helper = Tdmdownloads\Helper::getInstance(); - $this->permHelper = new \Xmf\Module\Helper\Permission(); + $this->permHelper = new Permission(); $this->initVar('cat_cid', \XOBJ_DTYPE_INT, null, false, 5); diff --git a/class/Common/FineimpuploadHandler.php b/class/Common/FineimpuploadHandler.php index b75ee35..95994f8 100644 --- a/class/Common/FineimpuploadHandler.php +++ b/class/Common/FineimpuploadHandler.php @@ -2,6 +2,11 @@ namespace XoopsModules\Tdmdownloads\Common; +use XoopsModules\Tdmdownloads\{ + Helper, + Utility +}; + /** * SystemFineImUploadHandler class to work with ajaxfineupload.php endpoint * to facilitate uploads for the system image manager @@ -137,11 +142,11 @@ protected function storeUploadedFile($target, $mimeType, $uid) $this->pathUpload = \constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH'); - $utility = new \XoopsModules\Tdmdownloads\Utility(); + $utility = new Utility(); /** @var \XoopsModules\Tdmdownloads\Helper $helper */ - $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); + $helper = Helper::getInstance(); // if ( WGGALLERY_PERM_SUBMITAPPR === $permissionsHandler->permGlobalSubmit()) { @@ -275,7 +280,7 @@ private function handleImageDB() $this->getImageDim(); - $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); + $helper = Helper::getInstance(); $imagesHandler = $helper->getHandler('Images'); diff --git a/config/icons.php b/config/icons.php index 1b1bb0a..eaa9f00 100644 --- a/config/icons.php +++ b/config/icons.php @@ -1,6 +1,8 @@ loadLanguage('common'); // extra module configs diff --git a/extra/plugins/tag/tdmdownloads.php b/extra/plugins/tag/tdmdownloads.php index abeab42..7b7d97c 100644 --- a/extra/plugins/tag/tdmdownloads.php +++ b/extra/plugins/tag/tdmdownloads.php @@ -18,6 +18,8 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) */ +use XoopsModules\Tag\Helper; + /** * @param $items * @return bool|null @@ -77,7 +79,7 @@ function tdmdownloads_tag_synchronization($mid) /** @var \XoopsModules\Tag\LinkHandler $linkHandler */ - $linkHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Link'); + $linkHandler = Helper::getInstance()->getHandler('Link'); /* clear tag-item links */ diff --git a/header.php b/header.php index 85144b9..a796b2f 100644 --- a/header.php +++ b/header.php @@ -19,6 +19,8 @@ Helper, Utility }; +use Xmf\Module\Helper\Permission; + /** @var Helper $helper */ /** @var Utility $utility */ @@ -35,7 +37,7 @@ $helper = Helper::getInstance(); -$permHelper = new \Xmf\Module\Helper\Permission(); +$permHelper = new Permission(); $modulePath = XOOPS_ROOT_PATH . '/modules/' . $moduleDirName; require __DIR__ . '/include/common.php'; diff --git a/include/common.php b/include/common.php index b9e3bf3..26ac2e8 100644 --- a/include/common.php +++ b/include/common.php @@ -18,7 +18,9 @@ * @author XOOPS Development Team */ +use Xmf\Module\Admin; use XoopsModules\Tdmdownloads; +use XoopsModules\Tdmdownloads\Helper; require dirname(__DIR__) . '/preloads/autoloader.php'; @@ -30,7 +32,7 @@ /** @var \XoopsModules\Tdmdownloads\Utility $utility */ $db = \XoopsDatabaseFactory::getDatabaseConnection(); $debug = false; -$helper = \XoopsModules\Tdmdownloads\Helper::getInstance($debug); +$helper = Helper::getInstance($debug); $utility = new \XoopsModules\Tdmdownloads\Utility(); //$configurator = new Tdmdownloads\Common\Configurator(); @@ -38,18 +40,18 @@ //handlers //appel des class -$categoryHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Category'); -$downloadsHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Downloads'); -$downlimitHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Downlimit'); -$ratingHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Rating'); -$fieldHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Field'); -$fielddataHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Fielddata'); -$brokenHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Broken'); -$modifiedHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Modified'); -$modifieddataHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Modifiedfielddata'); - -$pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16); -$pathIcon32 = \Xmf\Module\Admin::iconUrl('', 32); +$categoryHandler = Helper::getInstance()->getHandler('Category'); +$downloadsHandler = Helper::getInstance()->getHandler('Downloads'); +$downlimitHandler = Helper::getInstance()->getHandler('Downlimit'); +$ratingHandler = Helper::getInstance()->getHandler('Rating'); +$fieldHandler = Helper::getInstance()->getHandler('Field'); +$fielddataHandler = Helper::getInstance()->getHandler('Fielddata'); +$brokenHandler = Helper::getInstance()->getHandler('Broken'); +$modifiedHandler = Helper::getInstance()->getHandler('Modified'); +$modifieddataHandler = Helper::getInstance()->getHandler('Modifiedfielddata'); + +$pathIcon16 = Admin::iconUrl('', 16); +$pathIcon32 = Admin::iconUrl('', 32); if (!defined($moduleDirNameUpper . '_CONSTANTS_DEFINED')) { define($moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__))); diff --git a/include/oninstall.php b/include/oninstall.php index 990ac16..e3fc9fc 100644 --- a/include/oninstall.php +++ b/include/oninstall.php @@ -15,6 +15,8 @@ * @author Gregory Mage (Aka Mage) */ +use XoopsModules\Tdmdownloads\Helper; + /** * Prepares system prior to attempting to install module * @param \XoopsModule $module {@link XoopsModule} @@ -67,7 +69,7 @@ function xoops_module_install_tdmdownloads() require_once XOOPS_ROOT_PATH . '/modules/' . $namemodule . '/language/english/admin.php'; } - $fieldHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Field'); + $fieldHandler = Helper::getInstance()->getHandler('Field'); $obj = $fieldHandler->create(); diff --git a/include/onupdate.php b/include/onupdate.php index 5c28977..c41494b 100644 --- a/include/onupdate.php +++ b/include/onupdate.php @@ -1,5 +1,7 @@ query($sql); - $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); + $helper = Helper::getInstance(); $helper->loadLanguage('admin'); diff --git a/index.php b/index.php index f11b54d..67e9c67 100644 --- a/index.php +++ b/index.php @@ -14,10 +14,15 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + +use XoopsModules\Tdmdownloads\{ + Helper, + Tree}; + require_once __DIR__ . '/header.php'; /** @var \XoopsModules\Tdmdownloads\Helper $helper */ -$helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); +$helper = Helper::getInstance(); // template d'affichage $moduleDirName = basename(__DIR__); @@ -41,7 +46,7 @@ $criteria->setOrder('ASC'); $criteria->add(new \Criteria('cat_cid', '(' . implode(',', $categories) . ')', 'IN')); $downloadscatArray = $categoryHandler->getAll($criteria); -$mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); +$mytree = new Tree($downloadscatArray, 'cat_cid', 'cat_pid'); //affichage des catégories $xoopsTpl->assign('nb_catcol', $helper->getConfig('nb_catcol')); diff --git a/modfile.php b/modfile.php index 45d2120..f357ee6 100644 --- a/modfile.php +++ b/modfile.php @@ -14,10 +14,15 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + +use XoopsModules\Tdmdownloads\{ + Helper, + Tree}; + require_once __DIR__ . '/header.php'; /** @var \XoopsModules\Tdmdownloads\Helper $helper */ -$helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); +$helper = Helper::getInstance(); // template d'affichage $GLOBALS['xoopsOption']['template_main'] = 'tdmdownloads_modfile.tpl'; @@ -61,7 +66,7 @@ $criteria->setOrder('ASC'); $criteria->add(new \Criteria('cat_cid', '(' . implode(',', $categories) . ')', 'IN')); $downloadscatArray = $categoryHandler->getAll($criteria); - $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); + $mytree = new Tree($downloadscatArray, 'cat_cid', 'cat_pid'); //navigation $navigation = $utility->getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' arrow ', true, 'ASC', true); $navigation .= ' arrow ' . $viewDownloads->getVar('title') . ''; diff --git a/ratefile.php b/ratefile.php index 0ad9ce2..6d4d240 100644 --- a/ratefile.php +++ b/ratefile.php @@ -14,6 +14,9 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + +use XoopsModules\Tdmdownloads\Tree; + require_once __DIR__ . '/header.php'; $moduleDirName = basename(__DIR__); @@ -54,7 +57,7 @@ $criteria->setOrder('ASC'); $criteria->add(new \Criteria('cat_cid', '(' . implode(',', $categories) . ')', 'IN')); $downloadscatArray = $categoryHandler->getAll($criteria); - $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); + $mytree = new Tree($downloadscatArray, 'cat_cid', 'cat_pid'); //navigation $navigation = $utility->getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' arrow ', true, 'ASC', true); $navigation .= ' arrow ' . $viewDownloads->getVar('title') . ''; diff --git a/rss.php b/rss.php index e327473..f40ced8 100644 --- a/rss.php +++ b/rss.php @@ -14,13 +14,16 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + +use XoopsModules\Tdmdownloads\Helper; + require_once __DIR__ . '/header.php'; $xoopsLogger->activated = false; require_once XOOPS_ROOT_PATH . '/class/template.php'; global $xoopsModuleConfig; /** @var \XoopsModules\Tdmdownloads\Helper $helper */ -$helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); +$helper = Helper::getInstance(); $itemsCount = $helper->getConfig('perpagerss'); $cid = \Xmf\Request::getInt('cid', 0, 'GET'); diff --git a/search.php b/search.php index 6e3b2c8..9d3a437 100644 --- a/search.php +++ b/search.php @@ -18,8 +18,8 @@ use XoopsModules\Tdmdownloads\{ DownloadsHandler, Helper, - Utility -}; + Tree, + Utility}; /** @var Helper $helper */ /** @var Utility $utility */ @@ -67,7 +67,7 @@ $cat_select->addOptionArray($categoryHandler->getList($criteria )); $form->addElement($cat_select);*/ $downloadscatArray = $categoryHandler->getAll($criteria); -$mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); +$mytree = new Tree($downloadscatArray, 'cat_cid', 'cat_pid'); $form->addElement($mytree->makeSelectElement('cat', 'cat_title', '--', $cat, true, 0, '', _AM_TDMDOWNLOADS_FORMINCAT), true); //recherche champ sup. diff --git a/singlefile.php b/singlefile.php index b434667..eec1622 100644 --- a/singlefile.php +++ b/singlefile.php @@ -1,6 +1,10 @@ setOrder('ASC'); $criteria->add(new \Criteria('cat_cid', '(' . implode(',', $categories) . ')', 'IN')); $downloadscatArray = $categoryHandler->getAll($criteria); -$mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); +$mytree = new Tree($downloadscatArray, 'cat_cid', 'cat_pid'); //navigation $navigation = $utility->getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' arrow ', true, 'ASC', true); @@ -341,7 +345,7 @@ function getXfieldKey($k) } $xoTheme->addMeta('meta', 'description', strip_tags($descriptionShort)); //keywords -$keywords = \Xmf\Metagen::generateKeywords($viewDownloads->getVar('description'), 10); +$keywords = Metagen::generateKeywords($viewDownloads->getVar('description'), 10); $xoTheme->addMeta('meta', 'keywords', implode(', ', $keywords)); /*$keywords = substr($keywords,0,-1); $xoTheme->addMeta( 'meta', 'keywords', $keywords);*/ diff --git a/submit.php b/submit.php index 065ff58..87680d3 100644 --- a/submit.php +++ b/submit.php @@ -1,7 +1,10 @@ getConfig('usetag') && class_exists(TagHandler::class)) { /** @var \XoopsModules\Tag\TagHandler $tagHandler */ - $tagHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Tag'); + $tagHandler = Helper::getInstance()->getHandler('Tag'); $tagHandler->updateByItem($_POST['tag'], $lidDownloads, $moduleDirName, 0); } diff --git a/upload.php b/upload.php index 229d49f..4eb98f7 100644 --- a/upload.php +++ b/upload.php @@ -18,7 +18,13 @@ * @author Wedega - Email: - Website: */ +use Xmf\Jwt\TokenFactory; +use Xmf\Module\Admin; use Xmf\Request; +use XoopsModules\Tdmdownloads\{ + CategoryHandler, + Form\UploadForm +}; require_once __DIR__ . '/header.php'; @@ -32,10 +38,10 @@ $GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_upload.tpl'; require_once XOOPS_ROOT_PATH . '/header.php'; -$pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16); +$pathIcon16 = Admin::iconUrl('', 16); $GLOBALS['xoopsTpl']->assign('pathIcon16', $pathIcon16); -$categoryHandler = new \XoopsModules\Tdmdownloads\CategoryHandler(); +$categoryHandler = new CategoryHandler(); // Form Create if (isset($catId)) { @@ -47,7 +53,7 @@ $catId = 1; //for testing, comment out later $xoopsTpl->assign('multiupload', true); -$form = new \XoopsModules\Tdmdownloads\Form\UploadForm($categoryObj); +$form = new UploadForm($categoryObj); $form->setExtra('enctype="multipart/form-data"'); $GLOBALS['xoopsTpl']->assign('form', $form->render()); @@ -152,7 +158,7 @@ 'moddir' => $moduleDirName, ]; - $jwt = \Xmf\Jwt\TokenFactory::build('fineuploader', $payload, 60 * 30); // token good for 30 minutes + $jwt = TokenFactory::build('fineuploader', $payload, 60 * 30); // token good for 30 minutes $xoopsTpl->assign('jwt', $jwt); diff --git a/viewcat.php b/viewcat.php index 21c3b0f..3d60ca0 100644 --- a/viewcat.php +++ b/viewcat.php @@ -14,11 +14,17 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + +use XoopsModules\Tdmdownloads\{ + Helper, + Tree +}; + require_once __DIR__ . '/header.php'; $moduleDirName = basename(__DIR__); /** @var \XoopsModules\Tdmdownloads\Helper $helper */ -$helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); +$helper = Helper::getInstance(); // template d'affichage $GLOBALS['xoopsOption']['template_main'] = 'tdmdownloads_viewcat.tpl'; @@ -47,7 +53,7 @@ $criteria->setOrder('ASC'); $criteria->add(new \Criteria('cat_cid', '(' . implode(',', $categories) . ')', 'IN')); $downloadscatArray = $categoryHandler->getAll($criteria); -$mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); +$mytree = new Tree($downloadscatArray, 'cat_cid', 'cat_pid'); //tableau des téléchargements $criteria = new \CriteriaCompo(); diff --git a/visit.php b/visit.php index 9b5c9e5..1bfcd55 100644 --- a/visit.php +++ b/visit.php @@ -14,11 +14,14 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + +use XoopsModules\Tdmdownloads\Helper; + error_reporting(0); require __DIR__ . '/header.php'; /** @var \XoopsModules\Tdmdownloads\Helper $helper */ -$helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); +$helper = Helper::getInstance(); $lid = \Xmf\Request::getInt('lid', 0, 'REQUEST'); $cid = \Xmf\Request::getInt('cid', 0, 'REQUEST'); From 98a70157e3e91120b9ab37e1e8e558e4941c14a0 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 8 Aug 2021 23:07:03 -0400 Subject: [PATCH 55/62] Static methods invocation via '->' --- admin/downloads.php | 26 ++++++++++++++++---------- brokenfile.php | 4 ++-- modfile.php | 4 ++-- ratefile.php | 4 ++-- singlefile.php | 4 ++-- viewcat.php | 4 ++-- 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/admin/downloads.php b/admin/downloads.php index 8e75922..c91ab5f 100644 --- a/admin/downloads.php +++ b/admin/downloads.php @@ -1,11 +1,17 @@ $utility->getPathTree($mytree, $downloadsArray[$i]->getVar('cid'), $categoryArray, 'cat_title', $prefix = ' '), + 'category' => $utility::getPathTree($mytree, $downloadsArray[$i]->getVar('cid'), $categoryArray, 'cat_title', $prefix = ' '), 'cid' => $downloadsArray[$i]->getVar('cid'), 'lid' => $i, 'title' => $downloadsArray[$i]->getVar('title'), @@ -350,7 +356,7 @@ if (1 == $helper->getConfig('usetag') && class_exists(LinkHandler::class)) { /** @var \XoopsModules\Tag\LinkHandler $linkHandler */ - $linkHandler = Helper::getInstance()->getHandler('Link'); + $linkHandler = TagHelper::getInstance()->getHandler('Link'); $criteria = new \CriteriaCompo(); @@ -428,7 +434,7 @@ //permet d'enlever [pagebreak] du texte $downloads_description = str_replace('[pagebreak]', '', $downloads_description); - $category = $utility->getPathTree($mytree, $viewDownloads->getVar('cid'), $categoryArray, 'cat_title', $prefix = ' '); + $category = $utility::getPathTree($mytree, $viewDownloads->getVar('cid'), $categoryArray, 'cat_title', $prefix = ' '); // affichages des informations du téléchargement $download = [ 'title' => $downloads_title, @@ -878,7 +884,7 @@ if (1 == $helper->getConfig('usetag') && class_exists(TagHandler::class)) { /** @var \XoopsModules\Tag\TagHandler $tagHandler */ - $tagHandler = Helper::getInstance()->getHandler('Tag'); + $tagHandler = TagHelper::getInstance()->getHandler('Tag'); $tagHandler->updateByItem($_POST['tag'], $lidDownloads, $moduleDirName, 0); } diff --git a/brokenfile.php b/brokenfile.php index 71e2a36..ca22188 100644 --- a/brokenfile.php +++ b/brokenfile.php @@ -58,14 +58,14 @@ $downloadscatArray = $categoryHandler->getAll($criteria); $mytree = new Tree($downloadscatArray, 'cat_cid', 'cat_pid'); //navigation - $navigation = $utility->getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' arrow ', true, 'ASC', true); + $navigation = $utility::getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' arrow ', true, 'ASC', true); $navigation .= ' arrow ' . $viewDownloads->getVar('title') . ''; $navigation .= ' arrow ' . _MD_TDMDOWNLOADS_SINGLEFILE_REPORTBROKEN; $xoopsTpl->assign('navigation', $navigation); // référencement // titre de la page $pagetitle = _MD_TDMDOWNLOADS_SINGLEFILE_REPORTBROKEN . ' - ' . $viewDownloads->getVar('title') . ' - '; - $pagetitle .= $utility->getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' - ', false, 'DESC', true); + $pagetitle .= $utility::getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' - ', false, 'DESC', true); $xoopsTpl->assign('xoops_pagetitle', $pagetitle); //description $xoTheme->addMeta('meta', 'description', strip_tags(_MD_TDMDOWNLOADS_SINGLEFILE_REPORTBROKEN . ' (' . $viewDownloads->getVar('title') . ')')); diff --git a/modfile.php b/modfile.php index f357ee6..dcb08c1 100644 --- a/modfile.php +++ b/modfile.php @@ -68,14 +68,14 @@ $downloadscatArray = $categoryHandler->getAll($criteria); $mytree = new Tree($downloadscatArray, 'cat_cid', 'cat_pid'); //navigation - $navigation = $utility->getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' arrow ', true, 'ASC', true); + $navigation = $utility::getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' arrow ', true, 'ASC', true); $navigation .= ' arrow ' . $viewDownloads->getVar('title') . ''; $navigation .= ' arrow ' . _MD_TDMDOWNLOADS_SINGLEFILE_MODIFY; $xoopsTpl->assign('navigation', $navigation); // référencement // titre de la page $pagetitle = _MD_TDMDOWNLOADS_SINGLEFILE_MODIFY . ' - ' . $viewDownloads->getVar('title') . ' - '; - $pagetitle .= $utility->getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' - ', false, 'DESC', true); + $pagetitle .= $utility::getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' - ', false, 'DESC', true); $xoopsTpl->assign('xoops_pagetitle', $pagetitle); //description $xoTheme->addMeta('meta', 'description', strip_tags(_MD_TDMDOWNLOADS_SINGLEFILE_MODIFY . ' (' . $viewDownloads->getVar('title') . ')')); diff --git a/ratefile.php b/ratefile.php index 6d4d240..99799a9 100644 --- a/ratefile.php +++ b/ratefile.php @@ -59,14 +59,14 @@ $downloadscatArray = $categoryHandler->getAll($criteria); $mytree = new Tree($downloadscatArray, 'cat_cid', 'cat_pid'); //navigation - $navigation = $utility->getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' arrow ', true, 'ASC', true); + $navigation = $utility::getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' arrow ', true, 'ASC', true); $navigation .= ' arrow ' . $viewDownloads->getVar('title') . ''; $navigation .= ' arrow ' . _MD_TDMDOWNLOADS_SINGLEFILE_RATHFILE; $xoopsTpl->assign('navigation', $navigation); // référencement // titre de la page $pagetitle = _MD_TDMDOWNLOADS_SINGLEFILE_RATHFILE . ' - ' . $viewDownloads->getVar('title') . ' - '; - $pagetitle .= $utility->getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' - ', false, 'DESC', true); + $pagetitle .= $utility::getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' - ', false, 'DESC', true); $xoopsTpl->assign('xoops_pagetitle', $pagetitle); //description $xoTheme->addMeta('meta', 'description', strip_tags(_MD_TDMDOWNLOADS_SINGLEFILE_RATHFILE . ' (' . $viewDownloads->getVar('title') . ')')); diff --git a/singlefile.php b/singlefile.php index eec1622..6089795 100644 --- a/singlefile.php +++ b/singlefile.php @@ -58,7 +58,7 @@ $mytree = new Tree($downloadscatArray, 'cat_cid', 'cat_pid'); //navigation -$navigation = $utility->getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' arrow ', true, 'ASC', true); +$navigation = $utility::getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' arrow ', true, 'ASC', true); $navigation .= ' arrow ' . $viewDownloads->getVar('title'); $xoopsTpl->assign('navigation', $navigation); @@ -333,7 +333,7 @@ function getXfieldKey($k) // titre de la page $pagetitle = $viewDownloads->getVar('title') . ' - '; -$pagetitle .= $utility->getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' - ', false, 'DESC', true); +$pagetitle .= $utility::getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' - ', false, 'DESC', true); $xoopsTpl->assign('xoops_pagetitle', $pagetitle); //version for title $xoopsTpl->assign('version', $viewDownloads->getVar('version')); diff --git a/viewcat.php b/viewcat.php index 3d60ca0..6506373 100644 --- a/viewcat.php +++ b/viewcat.php @@ -63,7 +63,7 @@ $xoopsTpl->assign('lang_thereare', sprintf(_MD_TDMDOWNLOADS_INDEX_THEREARE, count($downloadsArray))); //navigation -$navCategory = $utility->getPathTreeUrl($mytree, $cid, $downloadscatArray, 'cat_title', $prefix = ' arrow ', true, 'ASC'); +$navCategory = $utility::getPathTreeUrl($mytree, $cid, $downloadscatArray, 'cat_title', $prefix = ' arrow ', true, 'ASC'); $xoopsTpl->assign('category_path', $navCategory); // info catégorie @@ -510,7 +510,7 @@ // référencement // titre de la page -$pagetitle = $utility->getPathTreeUrl($mytree, $cid, $downloadscatArray, 'cat_title', $prefix = ' - ', false, 'DESC'); +$pagetitle = $utility::getPathTreeUrl($mytree, $cid, $downloadscatArray, 'cat_title', $prefix = ' - ', false, 'DESC'); $xoopsTpl->assign('xoops_pagetitle', $pagetitle); //description $xoTheme->addMeta('meta', 'description', strip_tags($downloadscatArray[$cid]->getVar('cat_description_main'))); From c29d457cc3a07e11ae3c26feef332acf985102fc Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 8 Aug 2021 23:07:50 -0400 Subject: [PATCH 56/62] Cascading dirname(...) calls --- admin/admin_header.php | 2 +- class/Common/Breadcrumb.php | 2 +- class/Common/FineimpuploadHandler.php | 4 ++-- class/Common/Images.php | 4 ++-- class/Common/Migrate.php | 2 +- class/Common/ServerStats.php | 2 +- class/Common/VersionChecks.php | 6 +++--- class/Form/UploadForm.php | 4 ++-- comment_delete.php | 2 +- comment_edit.php | 2 +- comment_post.php | 2 +- comment_reply.php | 2 +- extra/plugins/waiting/tdmdownloads.php | 2 +- extra/plugins/whatsnew/tdmdownloads/data.inc.php | 4 ++-- header.php | 2 +- include/oninstall.php | 2 +- language/english/modinfo.php | 2 +- language/french/common.php | 2 +- language/french/modinfo.php | 2 +- language/german/common.php | 2 +- language/german/modinfo.php | 2 +- notification_update.php | 2 +- 22 files changed, 28 insertions(+), 28 deletions(-) diff --git a/admin/admin_header.php b/admin/admin_header.php index 015b0b3..4e052d6 100644 --- a/admin/admin_header.php +++ b/admin/admin_header.php @@ -21,7 +21,7 @@ Tree}; // Include xoops admin header -require_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php'; +require_once dirname(__DIR__, 3) . '/include/cp_header.php'; require_once XOOPS_ROOT_PATH . '/kernel/module.php'; require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; diff --git a/class/Common/Breadcrumb.php b/class/Common/Breadcrumb.php index 4d72f07..8500f8c 100644 --- a/class/Common/Breadcrumb.php +++ b/class/Common/Breadcrumb.php @@ -39,7 +39,7 @@ class Breadcrumb public function __construct() { - $this->dirname = \basename(\dirname(\dirname(__DIR__))); + $this->dirname = \basename(dirname(__DIR__, 2)); } /** diff --git a/class/Common/FineimpuploadHandler.php b/class/Common/FineimpuploadHandler.php index 95994f8..4213d2d 100644 --- a/class/Common/FineimpuploadHandler.php +++ b/class/Common/FineimpuploadHandler.php @@ -134,7 +134,7 @@ public function __construct(\stdClass $claims) */ protected function storeUploadedFile($target, $mimeType, $uid) { - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirName = \basename(dirname(__DIR__, 2)); $moduleDirNameUpper = \mb_strtoupper($moduleDirName); @@ -272,7 +272,7 @@ protected function storeUploadedFile($target, $mimeType, $uid) */ private function handleImageDB() { - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirName = \basename(dirname(__DIR__, 2)); require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/header.php'; diff --git a/class/Common/Images.php b/class/Common/Images.php index e2cae74..7528728 100644 --- a/class/Common/Images.php +++ b/class/Common/Images.php @@ -103,7 +103,7 @@ public function getNewInsertedIdImages() */ public function getFormImages($action = false) { - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirName = \basename(dirname(__DIR__, 2)); $moduleDirNameUpper = \mb_strtoupper($moduleDirName); @@ -265,7 +265,7 @@ public function getFormImages($action = false) */ public function getValuesImages($keys = null, $format = null, $maxDepth = null) { - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirName = \basename(dirname(__DIR__, 2)); $moduleDirNameUpper = \mb_strtoupper($moduleDirName); diff --git a/class/Common/Migrate.php b/class/Common/Migrate.php index 309c1b6..3c5f3e5 100644 --- a/class/Common/Migrate.php +++ b/class/Common/Migrate.php @@ -42,7 +42,7 @@ public function __construct() $this->renameTables = $configurator->renameTables; - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirName = \basename(dirname(__DIR__, 2)); parent::__construct($moduleDirName); } diff --git a/class/Common/ServerStats.php b/class/Common/ServerStats.php index f82737b..3279fe2 100644 --- a/class/Common/ServerStats.php +++ b/class/Common/ServerStats.php @@ -28,7 +28,7 @@ public static function getServerStats() { //mb $wfdownloads = WfdownloadsWfdownloads::getInstance(); - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirName = \basename(dirname(__DIR__, 2)); $moduleDirNameUpper = \mb_strtoupper($moduleDirName); diff --git a/class/Common/VersionChecks.php b/class/Common/VersionChecks.php index c5f4ffa..0aa73b5 100644 --- a/class/Common/VersionChecks.php +++ b/class/Common/VersionChecks.php @@ -29,7 +29,7 @@ trait VersionChecks */ public static function checkVerXoops(?\XoopsModule $module = null, $requiredVer = null) { - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirName = \basename(dirname(__DIR__, 2)); $moduleDirNameUpper = \mb_strtoupper($moduleDirName); @@ -65,7 +65,7 @@ public static function checkVerXoops(?\XoopsModule $module = null, $requiredVer */ public static function checkVerPhp(?\XoopsModule $module = null) { - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirName = \basename(dirname(__DIR__, 2)); $moduleDirNameUpper = \mb_strtoupper($moduleDirName); @@ -107,7 +107,7 @@ public static function checkVerPhp(?\XoopsModule $module = null) */ public static function checkVerModule($helper, $source = 'github', $default = 'master') { - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirName = \basename(dirname(__DIR__, 2)); $moduleDirNameUpper = \mb_strtoupper($moduleDirName); diff --git a/class/Form/UploadForm.php b/class/Form/UploadForm.php index d67b17a..d31a11e 100644 --- a/class/Form/UploadForm.php +++ b/class/Form/UploadForm.php @@ -27,7 +27,7 @@ use Xmf\Request; use XoopsModules\Tdmdownloads; -require_once \dirname(\dirname(__DIR__)) . '/include/common.php'; +require_once dirname(__DIR__, 2) . '/include/common.php'; //$moduleDirName = basename(dirname(dirname(__DIR__))); //$helper = Tdmdownloads\Helper::getInstance(); @@ -50,7 +50,7 @@ class UploadForm extends \XoopsThemeForm */ public function __construct($target) { - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirName = \basename(dirname(__DIR__, 2)); $moduleDirNameUpper = \mb_strtoupper($moduleDirName); diff --git a/comment_delete.php b/comment_delete.php index f45747a..d256291 100644 --- a/comment_delete.php +++ b/comment_delete.php @@ -25,5 +25,5 @@ // along with this program; if not, write to the Free Software // // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ // -require dirname(dirname(__DIR__)) . '/mainfile.php'; +require dirname(__DIR__, 2) . '/mainfile.php'; require XOOPS_ROOT_PATH . '/include/comment_delete.php'; diff --git a/comment_edit.php b/comment_edit.php index 200db86..03c2bd2 100644 --- a/comment_edit.php +++ b/comment_edit.php @@ -25,5 +25,5 @@ // along with this program; if not, write to the Free Software // // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ // -require dirname(dirname(__DIR__)) . '/mainfile.php'; +require dirname(__DIR__, 2) . '/mainfile.php'; require XOOPS_ROOT_PATH . '/include/comment_edit.php'; diff --git a/comment_post.php b/comment_post.php index 6dcf5dc..2e3ca7d 100644 --- a/comment_post.php +++ b/comment_post.php @@ -25,5 +25,5 @@ // along with this program; if not, write to the Free Software // // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ // -require dirname(dirname(__DIR__)) . '/mainfile.php'; +require dirname(__DIR__, 2) . '/mainfile.php'; require XOOPS_ROOT_PATH . '/include/comment_post.php'; diff --git a/comment_reply.php b/comment_reply.php index 73cf4b7..dcee807 100644 --- a/comment_reply.php +++ b/comment_reply.php @@ -25,5 +25,5 @@ // along with this program; if not, write to the Free Software // // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ // -require dirname(dirname(__DIR__)) . '/mainfile.php'; +require dirname(__DIR__, 2) . '/mainfile.php'; require XOOPS_ROOT_PATH . '/include/comment_reply.php'; diff --git a/extra/plugins/waiting/tdmdownloads.php b/extra/plugins/waiting/tdmdownloads.php index 3057db8..f870c45 100644 --- a/extra/plugins/waiting/tdmdownloads.php +++ b/extra/plugins/waiting/tdmdownloads.php @@ -19,7 +19,7 @@ function b_waiting_tdmdownloads() $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection(); - $moduleDirName = basename(dirname(dirname(__DIR__))); + $moduleDirName = basename(dirname(__DIR__, 2)); $ret = []; diff --git a/extra/plugins/whatsnew/tdmdownloads/data.inc.php b/extra/plugins/whatsnew/tdmdownloads/data.inc.php index 8802460..b02da31 100644 --- a/extra/plugins/whatsnew/tdmdownloads/data.inc.php +++ b/extra/plugins/whatsnew/tdmdownloads/data.inc.php @@ -22,7 +22,7 @@ function tdmdownloads_new($limit = 0, $offset = 0) { global $xoopsDB; - $moduleDirName = basename(dirname(dirname(dirname(dirname(__DIR__))))); + $moduleDirName = basename(dirname(__DIR__, 4)); $myts = \MyTextSanitizer::getInstance(); @@ -101,7 +101,7 @@ function tdmdownloads_data($limit = 0, $offset = 0) { global $xoopsDB; - $moduleDirName = basename(dirname(dirname(__DIR__))); + $moduleDirName = basename(dirname(__DIR__, 2)); $sql = 'SELECT lid, title, date FROM ' . $xoopsDB->prefix('tdmdownloads_downloads') . ' WHERE status>0 ORDER BY lid'; diff --git a/header.php b/header.php index a796b2f..4770d14 100644 --- a/header.php +++ b/header.php @@ -25,7 +25,7 @@ /** @var Utility $utility */ -require dirname(dirname(__DIR__)) . '/mainfile.php'; +require dirname(__DIR__, 2) . '/mainfile.php'; $moduleDirName = basename(__DIR__); $moduleDirNameUpper = mb_strtoupper($moduleDirName); diff --git a/include/oninstall.php b/include/oninstall.php index e3fc9fc..ec1a204 100644 --- a/include/oninstall.php +++ b/include/oninstall.php @@ -25,7 +25,7 @@ */ function xoops_module_pre_install_tdmdownloads(\XoopsModule $module) { - require_once dirname(dirname(dirname(__DIR__))) . '/mainfile.php'; + require_once dirname(__DIR__, 3) . '/mainfile.php'; // require_once __DIR__ . '/common.php'; diff --git a/language/english/modinfo.php b/language/english/modinfo.php index 2ce7b62..acf2f2e 100644 --- a/language/english/modinfo.php +++ b/language/english/modinfo.php @@ -17,7 +17,7 @@ // Nom du module define('_MI_TDMDOWNLOADS_NAME', 'TDMDownloads'); -define('_MI_TDMDOWNLOADS_DIRNAME', basename(dirname(dirname(__DIR__)))); +define('_MI_TDMDOWNLOADS_DIRNAME', basename(dirname(__DIR__, 2))); define('_MI_TDMDOWNLOADS_HELP_HEADER', __DIR__ . '/help/helpheader.tpl'); // Description du module define('_MI_TDMDOWNLOADS_DESC', 'Creates a downloads section where users can download/submit/rate various files.'); diff --git a/language/french/common.php b/language/french/common.php index b30f35c..343408a 100644 --- a/language/french/common.php +++ b/language/french/common.php @@ -57,7 +57,7 @@ define('CO_' . $moduleDirNameUpper . '_ERROR_NO_PLUGIN', 'Could not load plugin'); //Help -define('CO_' . $moduleDirNameUpper . '_DIRNAME', basename(dirname(dirname(__DIR__)))); +define('CO_' . $moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__, 2))); define('CO_' . $moduleDirNameUpper . '_HELP_HEADER', __DIR__ . '/help/helpheader.tpl'); define('CO_' . $moduleDirNameUpper . '_BACK_2_ADMIN', 'Back to Administration of '); define('CO_' . $moduleDirNameUpper . '_OVERVIEW', 'Overview'); diff --git a/language/french/modinfo.php b/language/french/modinfo.php index 0878c2a..22b0612 100644 --- a/language/french/modinfo.php +++ b/language/french/modinfo.php @@ -17,7 +17,7 @@ // Nom du module define('_MI_TDMDOWNLOADS_NAME', 'TDMDownloads'); -define('_MI_TDMDOWNLOADS_DIRNAME', basename(dirname(dirname(__DIR__)))); +define('_MI_TDMDOWNLOADS_DIRNAME', basename(dirname(__DIR__, 2))); define('_MI_TDMDOWNLOADS_HELP_HEADER', __DIR__ . '/help/helpheader.tpl'); // Description du module define('_MI_TDMDOWNLOADS_DESC', 'Crée une section de téléchargements où les utilisateurs peuvent télécharger, soumettre et noter différents fichiers.'); diff --git a/language/german/common.php b/language/german/common.php index 70e43da..9460d22 100644 --- a/language/german/common.php +++ b/language/german/common.php @@ -56,7 +56,7 @@ define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_REMOVE', 'Konnte %s nicht löschen'); define('CO_' . $moduleDirNameUpper . '_ERROR_NO_PLUGIN', 'Konnte Plugin nicht laden'); //Help -define('CO_' . $moduleDirNameUpper . '_DIRNAME', basename(dirname(dirname(__DIR__)))); +define('CO_' . $moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__, 2))); define('CO_' . $moduleDirNameUpper . '_HELP_HEADER', __DIR__ . '/help/helpheader.tpl'); define('CO_' . $moduleDirNameUpper . '_BACK_2_ADMIN', 'Zurück zur Administration von '); define('CO_' . $moduleDirNameUpper . '_OVERVIEW', 'Übersicht'); diff --git a/language/german/modinfo.php b/language/german/modinfo.php index 8bca1ed..5b44276 100644 --- a/language/german/modinfo.php +++ b/language/german/modinfo.php @@ -17,7 +17,7 @@ // The name of this module define('_MI_TDMDOWNLOADS_NAME', 'TDMDownloads'); -define('_MI_TDMDOWNLOADS_DIRNAME', basename(dirname(dirname(__DIR__)))); +define('_MI_TDMDOWNLOADS_DIRNAME', basename(dirname(__DIR__, 2))); define('_MI_TDMDOWNLOADS_HELP_HEADER', __DIR__ . '/help/helpheader.tpl'); // A brief description of this module define('_MI_TDMDOWNLOADS_DESC', 'Erstellt einen Downloadbereich in dem User verschiedene Dateien downloaden, einschicken und bewerten können.'); diff --git a/notification_update.php b/notification_update.php index 91a523b..23589e2 100644 --- a/notification_update.php +++ b/notification_update.php @@ -14,5 +14,5 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ -require dirname(dirname(__DIR__)) . '/mainfile.php'; +require dirname(__DIR__, 2) . '/mainfile.php'; require XOOPS_ROOT_PATH . '/include/notification_update.php'; From 8f5b80b44b6f03dfa5d9e3b6e0cb2b4d2a632f80 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 8 Aug 2021 23:26:17 -0400 Subject: [PATCH 57/62] check for mysqli_result --- admin/blocksadmin.php | 24 +- admin/import.php | 316 +++++++++--------- admin/permissions.php | 4 +- comment_new.php | 2 +- .../whatsnew/tdmdownloads/data.inc.php | 53 +-- include/notification.inc.php | 11 +- include/onupdate.php | 62 ++-- include/search.inc.php | 18 +- 8 files changed, 249 insertions(+), 241 deletions(-) diff --git a/admin/blocksadmin.php b/admin/blocksadmin.php index 632134d..a3e6f9b 100644 --- a/admin/blocksadmin.php +++ b/admin/blocksadmin.php @@ -165,11 +165,11 @@ function listBlocks() $result = $db->query($sql); $modules = []; - - while (false !== ($row = $db->fetchArray($result))) { - $modules[] = (int)$row['module_id']; + if ($result instanceof \mysqli_result) { + while (false !== ($row = $db->fetchArray($result))) { + $modules[] = (int)$row['module_id']; + } } - $cachetime_options = ''; foreach ($cachetimes as $cachetime => $cachetime_name) { @@ -371,11 +371,11 @@ function cloneBlock($bid) $result = $db->query($sql); $modules = []; - - while (false !== ($row = $db->fetchArray($result))) { - $modules[] = (int)$row['module_id']; + if ($result instanceof \mysqli_result) { + while (false !== ($row = $db->fetchArray($result))) { + $modules[] = (int)$row['module_id']; + } } - $is_custom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type')); $block = [ @@ -590,11 +590,11 @@ function editBlock($bid) $result = $db->query($sql); $modules = []; - - while (false !== ($row = $db->fetchArray($result))) { - $modules[] = (int)$row['module_id']; + if ($result instanceof \mysqli_result) { + while (false !== ($row = $db->fetchArray($result))) { + $modules[] = (int)$row['module_id']; + } } - $is_custom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type')); $block = [ diff --git a/admin/import.php b/admin/import.php index 38affc4..47c5fe1 100644 --- a/admin/import.php +++ b/admin/import.php @@ -65,120 +65,123 @@ function importMydownloads($path = '', $imgurl = '') //Inserer les données des catégories - $query_topic = $xoopsDB->query('SELECT cid, pid, title, imgurl FROM ' . $xoopsDB->prefix('mydownloads_cat')); + $result = $xoopsDB->query('SELECT cid, pid, title, imgurl FROM ' . $xoopsDB->prefix('mydownloads_cat')); - while (false !== ($donnees = $xoopsDB->fetchArray($query_topic))) { - if ('' === $donnees['imgurl']) { - $img = 'blank.gif'; - } else { - $img = substr_replace($donnees['imgurl'], '', 0, mb_strlen($imgurl)); + if ($result instanceof \mysqli_result) { + while (false !== ($donnees = $xoopsDB->fetchArray($result))) { + if ('' === $donnees['imgurl']) { + $img = 'blank.gif'; + } else { + $img = substr_replace($donnees['imgurl'], '', 0, mb_strlen($imgurl)); - @copy($path . $img, XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/cats/' . $img); - } + @copy($path . $img, XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/cats/' . $img); + } - $title = $donnees['title']; + $title = $donnees['title']; - $insert = $xoopsDB->queryF('INSERT INTO ' . $xoopsDB->prefix('tdmdownloads_cat') . " (cat_cid, cat_pid, cat_title, cat_imgurl, cat_description_main, cat_weight ) VALUES ('" . $donnees['cid'] . "', '" . $donnees['pid'] . "', '" . $title . "', '" . $img . "', '', '0')"); + $insert = $xoopsDB->queryF('INSERT INTO ' . $xoopsDB->prefix('tdmdownloads_cat') . " (cat_cid, cat_pid, cat_title, cat_imgurl, cat_description_main, cat_weight ) VALUES ('" . $donnees['cid'] . "', '" . $donnees['pid'] . "', '" . $title . "', '" . $img . "', '', '0')"); - if (!$insert) { - $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['title']]; - } + if (!$insert) { + $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['title']]; + } - $successes[] = sprintf(_AM_TDMDOWNLOADS_IMPORT_CAT_IMP, $donnees['title']); + $successes[] = sprintf(_AM_TDMDOWNLOADS_IMPORT_CAT_IMP, $donnees['title']); + } } - echo '
    '; //Inserer les données des téléchargemnts - $query_links = $xoopsDB->query('SELECT lid, cid, title, url, homepage, version, size, platform, logourl, submitter, status, date, hits, rating, votes, comments FROM ' . $xoopsDB->prefix('mydownloads_downloads')); - - while (false !== ($donnees = $xoopsDB->fetchArray($query_links))) { - //On recupere la description + $result = $xoopsDB->query('SELECT lid, cid, title, url, homepage, version, size, platform, logourl, submitter, status, date, hits, rating, votes, comments FROM ' . $xoopsDB->prefix('mydownloads_downloads')); + if ($result instanceof \mysqli_result) { + while (false !== ($donnees = $xoopsDB->fetchArray($result))) { + //On recupere la description - $requete = $xoopsDB->queryF('SELECT description FROM ' . $xoopsDB->prefix('mydownloads_text') . " WHERE lid = '" . $donnees['lid'] . "'"); + $requete = $xoopsDB->queryF('SELECT description FROM ' . $xoopsDB->prefix('mydownloads_text') . " WHERE lid = '" . $donnees['lid'] . "'"); - [$description] = $xoopsDB->fetchRow($requete); + [$description] = $xoopsDB->fetchRow($requete); - $insert = $xoopsDB->queryF( - 'INSERT INTO ' - . $xoopsDB->prefix('tdmdownloads_downloads') - . " ( + $insert = $xoopsDB->queryF( + 'INSERT INTO ' + . $xoopsDB->prefix('tdmdownloads_downloads') + . " ( lid, cid, title, url, homepage, version, size, platform, description, logourl, submitter, status, date, hits, rating, votes, comments, top) VALUES ('" - . $donnees['lid'] - . "', '" - . $donnees['cid'] - . "', '" - . $donnees['title'] - . "', '" - . $donnees['url'] - . "', '" - . $donnees['homepage'] - . "', '" - . $donnees['version'] - . "', '" - . $donnees['size'] - . "', '" - . $donnees['platform'] - . "', '" - . $description - . "', '" - . $donnees['logourl'] - . "', '" - . $donnees['submitter'] - . "', '" - . $donnees['status'] - . "', '" - . $donnees['date'] - . "', '" - . $donnees['hits'] - . "', '" - . $donnees['rating'] - . "', '" - . $donnees['votes'] - . "', '0', '0' )" - ); - - if (!$insert) { - $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['title']]; + . $donnees['lid'] + . "', '" + . $donnees['cid'] + . "', '" + . $donnees['title'] + . "', '" + . $donnees['url'] + . "', '" + . $donnees['homepage'] + . "', '" + . $donnees['version'] + . "', '" + . $donnees['size'] + . "', '" + . $donnees['platform'] + . "', '" + . $description + . "', '" + . $donnees['logourl'] + . "', '" + . $donnees['submitter'] + . "', '" + . $donnees['status'] + . "', '" + . $donnees['date'] + . "', '" + . $donnees['hits'] + . "', '" + . $donnees['rating'] + . "', '" + . $donnees['votes'] + . "', '0', '0' )" + ); + + if (!$insert) { + $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['title']]; + } + + $successes[] = sprintf(_AM_TDMDOWNLOADS_IMPORT_DOWNLOADS_IMP, $donnees['title']); + + @copy($path . $donnees['logourl'], XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/shots/' . $donnees['logourl']); } - - $successes[] = sprintf(_AM_TDMDOWNLOADS_IMPORT_DOWNLOADS_IMP, $donnees['title']); - - @copy($path . $donnees['logourl'], XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/shots/' . $donnees['logourl']); } echo '
    '; //Inserer les données des votes - $query_vote = $xoopsDB->query('SELECT ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp FROM ' . $xoopsDB->prefix('mydownloads_votedata')); - - while (false !== ($donnees = $xoopsDB->fetchArray($query_vote))) { - $insert = $xoopsDB->queryF( - 'INSERT INTO ' - . $xoopsDB->prefix('tdmdownloads_votedata') - . " (ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp ) VALUES ('" - . $donnees['ratingid'] - . "', '" - . $donnees['lid'] - . "', '" - . $donnees['ratinguser'] - . "', '" - . $donnees['rating'] - . "', '" - . $donnees['ratinghostname'] - . "', '" - . $donnees['ratingtimestamp'] - . "')" - ); - - if (!$insert) { - $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['ratingid']]; + $result = $xoopsDB->query('SELECT ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp FROM ' . $xoopsDB->prefix('mydownloads_votedata')); + if ($result instanceof \mysqli_result) { + while (false !== ($donnees = $xoopsDB->fetchArray($result))) { + $insert = $xoopsDB->queryF( + 'INSERT INTO ' + . $xoopsDB->prefix('tdmdownloads_votedata') + . " (ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp ) VALUES ('" + . $donnees['ratingid'] + . "', '" + . $donnees['lid'] + . "', '" + . $donnees['ratinguser'] + . "', '" + . $donnees['rating'] + . "', '" + . $donnees['ratinghostname'] + . "', '" + . $donnees['ratingtimestamp'] + . "')" + ); + + if (!$insert) { + $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['ratingid']]; + } + + $successes[] = sprintf(_AM_TDMDOWNLOADS_IMPORT_VOTE_IMP, $donnees['ratingid']); } - - $successes[] = sprintf(_AM_TDMDOWNLOADS_IMPORT_VOTE_IMP, $donnees['ratingid']); } echo '

    '; @@ -223,29 +226,30 @@ function importWfdownloads($shots = '', $catimg = '') //Inserer les données des catégories - $query_topic = $xoopsDB->query('SELECT cid, pid, title, imgurl, description, total, summary, spotlighttop, spotlighthis, dohtml, dosmiley, doxcode, doimage, dobr, weight, formulize_fid FROM ' . $xoopsDB->prefix('wfdownloads_cat')); - - while (false !== ($donnees = $xoopsDB->fetchArray($query_topic))) { - if ('' === $donnees['imgurl']) { - $img = 'blank.gif'; - } else { - $img = $donnees['imgurl']; - - @copy($catimg . $img, XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/cats/' . $img); + $result = $xoopsDB->query('SELECT cid, pid, title, imgurl, description, total, summary, spotlighttop, spotlighthis, dohtml, dosmiley, doxcode, doimage, dobr, weight, formulize_fid FROM ' . $xoopsDB->prefix('wfdownloads_cat')); + if ($result instanceof \mysqli_result) { + while (false !== ($donnees = $xoopsDB->fetchArray($result))) { + if ('' === $donnees['imgurl']) { + $img = 'blank.gif'; + } else { + $img = $donnees['imgurl']; + + @copy($catimg . $img, XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/cats/' . $img); + } + + $insert = $xoopsDB->queryF( + 'INSERT INTO ' . $xoopsDB->prefix('tdmdownloads_cat') . " (cat_cid, cat_pid, cat_title, cat_imgurl, cat_description_main, cat_weight ) VALUES ('" . $donnees['cid'] . "', '" . $donnees['pid'] . "', '" . addcslashes($donnees['title'], "'") . "', '" . $img . "', '" . addcslashes( + $donnees['description'], + "'" + ) . "', '" . $donnees['weight'] . "')" + ); + + if (!$insert) { + $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['title']]; + } + + $successes[] = sprintf(_AM_TDMDOWNLOADS_IMPORT_CAT_IMP, $donnees['title']); } - - $insert = $xoopsDB->queryF( - 'INSERT INTO ' . $xoopsDB->prefix('tdmdownloads_cat') . " (cat_cid, cat_pid, cat_title, cat_imgurl, cat_description_main, cat_weight ) VALUES ('" . $donnees['cid'] . "', '" . $donnees['pid'] . "', '" . addcslashes($donnees['title'], "'") . "', '" . $img . "', '" . addcslashes( - $donnees['description'], - "'" - ) . "', '" . $donnees['weight'] . "')" - ); - - if (!$insert) { - $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['title']]; - } - - $successes[] = sprintf(_AM_TDMDOWNLOADS_IMPORT_CAT_IMP, $donnees['title']); } echo '
    '; @@ -256,30 +260,31 @@ function importWfdownloads($shots = '', $catimg = '') 'SELECT lid, cid, title, url, filename, filetype, homepage, version, size, platform, screenshot, screenshot2, screenshot3, screenshot4, submitter, publisher, status, date, hits, rating, votes, comments, license, mirror, price, paypalemail, features, requirements, homepagetitle, forumid, limitations, versiontypes, dhistory, published, expired, updated, offline, summary, description, ipaddress, notifypub, formulize_idreq FROM ' . $xoopsDB->prefix('wfdownloads_downloads') ); - - while (false !== ($donnees = $xoopsDB->fetchArray($query_links))) { - if ('' === $donnees['url']) { - $newurl = XOOPS_URL . '/uploads/' . $donnees['filename']; - } else { - $newurl = $donnees['url']; - } - - $insert = $xoopsDB->queryF( - 'INSERT INTO ' . $xoopsDB->prefix('tdmdownloads_downloads') . " ( + if ($query_links instanceof \mysqli_result) { + while (false !== ($donnees = $xoopsDB->fetchArray($query_links))) { + if ('' === $donnees['url']) { + $newurl = XOOPS_URL . '/uploads/' . $donnees['filename']; + } else { + $newurl = $donnees['url']; + } + + $insert = $xoopsDB->queryF( + 'INSERT INTO ' . $xoopsDB->prefix('tdmdownloads_downloads') . " ( lid, cid, title, url, homepage, version, size, platform, description, logourl, submitter, status, date, hits, rating, votes, comments, top) VALUES ('" . $donnees['lid'] . "', '" . $donnees['cid'] . "', '" . addcslashes($donnees['title'], "'") . "', '" . $newurl . "', '" . $donnees['homepage'] . "', '" . $donnees['version'] . "', '" . $donnees['size'] . "', '" . $donnees['platform'] . "', '" . addcslashes( - $donnees['description'], - "'" - ) . "', '" . $donnees['screenshot'] . "', '" . $donnees['submitter'] . "', '" . $donnees['status'] . "', '" . $donnees['date'] . "', '" . $donnees['hits'] . "', '" . $donnees['rating'] . "', '" . $donnees['votes'] . "', '0', '0' )" - ); + $donnees['description'], + "'" + ) . "', '" . $donnees['screenshot'] . "', '" . $donnees['submitter'] . "', '" . $donnees['status'] . "', '" . $donnees['date'] . "', '" . $donnees['hits'] . "', '" . $donnees['rating'] . "', '" . $donnees['votes'] . "', '0', '0' )" + ); - if (!$insert) { - $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['title']]; - } + if (!$insert) { + $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['title']]; + } - $successes[] = sprintf(_AM_TDMDOWNLOADS_IMPORT_DOWNLOADS_IMP, $donnees['title']); + $successes[] = sprintf(_AM_TDMDOWNLOADS_IMPORT_DOWNLOADS_IMP, $donnees['title']); - @copy($shots . $donnees['screenshot'], XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/shots/' . $donnees['screenshot']); + @copy($shots . $donnees['screenshot'], XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/shots/' . $donnees['screenshot']); + } } echo '
    '; @@ -287,31 +292,32 @@ function importWfdownloads($shots = '', $catimg = '') //Inserer les données des votes $query_vote = $xoopsDB->query('SELECT ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp FROM ' . $xoopsDB->prefix('wfdownloads_votedata')); - - while (false !== ($donnees = $xoopsDB->fetchArray($query_vote))) { - $insert = $xoopsDB->queryF( - 'INSERT INTO ' - . $xoopsDB->prefix('tdmdownloads_votedata') - . " (ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp ) VALUES ('" - . $donnees['ratingid'] - . "', '" - . $donnees['lid'] - . "', '" - . $donnees['ratinguser'] - . "', '" - . $donnees['rating'] - . "', '" - . $donnees['ratinghostname'] - . "', '" - . $donnees['ratingtimestamp'] - . "')" - ); - - if (!$insert) { - echo '' . _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA . ': ' . $donnees['ratingid'] . '
    '; + if ($query_vote instanceof \mysqli_result) { + while (false !== ($donnees = $xoopsDB->fetchArray($query_vote))) { + $insert = $xoopsDB->queryF( + 'INSERT INTO ' + . $xoopsDB->prefix('tdmdownloads_votedata') + . " (ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp ) VALUES ('" + . $donnees['ratingid'] + . "', '" + . $donnees['lid'] + . "', '" + . $donnees['ratinguser'] + . "', '" + . $donnees['rating'] + . "', '" + . $donnees['ratinghostname'] + . "', '" + . $donnees['ratingtimestamp'] + . "')" + ); + + if (!$insert) { + echo '' . _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA . ': ' . $donnees['ratingid'] . '
    '; + } + + echo sprintf(_AM_TDMDOWNLOADS_IMPORT_VOTE_IMP . '
    ', $donnees['ratingid']); } - - echo sprintf(_AM_TDMDOWNLOADS_IMPORT_VOTE_IMP . '
    ', $donnees['ratingid']); } $successes[] = _AM_TDMDOWNLOADS_IMPORT_OK; diff --git a/admin/permissions.php b/admin/permissions.php index d48b99a..fe54715 100644 --- a/admin/permissions.php +++ b/admin/permissions.php @@ -99,7 +99,7 @@ $result = $xoopsDB->query($sql); - if ($result) { + if ($result instanceof \mysqli_result) { while (false !== ($row = $xoopsDB->fetchArray($result))) { $permissionsForm->addItem($row['lid'], $row['title']); } @@ -109,7 +109,7 @@ $result = $xoopsDB->query($sql); - if ($result) { + if ($result instanceof \mysqli_result) { while (false !== ($row = $xoopsDB->fetchArray($result))) { $permissionsForm->addItem($row['cat_cid'], $row['cat_title'], $row['cat_pid']); } diff --git a/comment_new.php b/comment_new.php index 1c69973..80b4e1c 100644 --- a/comment_new.php +++ b/comment_new.php @@ -35,7 +35,7 @@ $result = $xoopsDB->query($sql); - if ($result) { + if ($result instanceof \mysqli_result) { $categories = $utility->getItemIds('tdmdownloads_view', $moduleDirName); $row = $xoopsDB->fetchArray($result); diff --git a/extra/plugins/whatsnew/tdmdownloads/data.inc.php b/extra/plugins/whatsnew/tdmdownloads/data.inc.php index b02da31..1835dc7 100644 --- a/extra/plugins/whatsnew/tdmdownloads/data.inc.php +++ b/extra/plugins/whatsnew/tdmdownloads/data.inc.php @@ -35,37 +35,38 @@ function tdmdownloads_new($limit = 0, $offset = 0) $i = 0; $ret = []; + if ($result instanceof \mysqli_result) { + while (false !== ($row = $xoopsDB->fetchArray($result))) { + $lid = $row['lid']; - while (false !== ($row = $xoopsDB->fetchArray($result))) { - $lid = $row['lid']; + $ret[$i]['link'] = $URL_MOD . '/singlefile.php?lid=' . $lid; - $ret[$i]['link'] = $URL_MOD . '/singlefile.php?lid=' . $lid; + $ret[$i]['cat_link'] = $URL_MOD . '/viewcat.php?cid=' . $row['cid']; - $ret[$i]['cat_link'] = $URL_MOD . '/viewcat.php?cid=' . $row['cid']; + $ret[$i]['title'] = $row['title']; - $ret[$i]['title'] = $row['title']; + $ret[$i]['time'] = $row['date']; - $ret[$i]['time'] = $row['date']; + // atom feed - // atom feed + $ret[$i]['id'] = $lid; - $ret[$i]['id'] = $lid; + $ret[$i]['description'] = $myts->displayTarea($row['description'], 0); //no html - $ret[$i]['description'] = $myts->displayTarea($row['description'], 0); //no html + // category - // category + //$ret[$i]['cat_name'] = $row['ctitle']; - //$ret[$i]['cat_name'] = $row['ctitle']; + // counter - // counter + $ret[$i]['hits'] = $row['hits']; - $ret[$i]['hits'] = $row['hits']; + // this module dont show user name - // this module dont show user name + $ret[$i]['uid'] = $row['submitter']; - $ret[$i]['uid'] = $row['submitter']; - - ++$i; + ++$i; + } } return $ret; @@ -110,20 +111,20 @@ function tdmdownloads_data($limit = 0, $offset = 0) $i = 0; $ret = []; + if ($result instanceof \mysqli_result) { + while (false !== ($myrow = $xoopsDB->fetchArray($result))) { + $id = $myrow['lid']; - while (false !== ($myrow = $xoopsDB->fetchArray($result))) { - $id = $myrow['lid']; - - $ret[$i]['id'] = $id; + $ret[$i]['id'] = $id; - $ret[$i]['link'] = XOOPS_URL . "/modules/$moduleDirName/singlefile.php?lid=" . $id . ''; + $ret[$i]['link'] = XOOPS_URL . "/modules/$moduleDirName/singlefile.php?lid=" . $id . ''; - $ret[$i]['title'] = $myrow['title']; + $ret[$i]['title'] = $myrow['title']; - $ret[$i]['time'] = $myrow['date']; + $ret[$i]['time'] = $myrow['date']; - ++$i; + ++$i; + } } - return $ret; } diff --git a/include/notification.inc.php b/include/notification.inc.php index a112aad..8e346a0 100644 --- a/include/notification.inc.php +++ b/include/notification.inc.php @@ -73,8 +73,9 @@ function tdmdownloads_notify_iteminfo($category, $item_id) $sql = 'SELECT title FROM ' . $xoopsDB->prefix('tdmdownloads_cat') . ' WHERE cid = ' . $item_id; $result = $xoopsDB->query($sql); // TODO: error check - - $result_array = $xoopsDB->fetchArray($result); + if ($result instanceof \mysqli_result) { + $result_array = $xoopsDB->fetchArray($result); + } $item['name'] = $result_array['title']; @@ -89,9 +90,9 @@ function tdmdownloads_notify_iteminfo($category, $item_id) $sql = 'SELECT cid,title FROM ' . $xoopsDB->prefix('tdmdownloads_downloads') . ' WHERE lid = ' . $item_id; $result = $xoopsDB->query($sql); // TODO: error check - - $result_array = $xoopsDB->fetchArray($result); - + if ($result instanceof \mysqli_result) { + $result_array = $xoopsDB->fetchArray($result); + } $item['name'] = $result_array['title']; $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/singlefile.php?cid=' . $result_array['cid'] . '&lid=' . $item_id; diff --git a/include/onupdate.php b/include/onupdate.php index c41494b..0f9e202 100644 --- a/include/onupdate.php +++ b/include/onupdate.php @@ -61,39 +61,39 @@ function update_tdmdownloads_v200(&$module) $helper = Helper::getInstance(); $helper->loadLanguage('admin'); - - while (false !== ($myrow = $db->fetchArray($result))) { - $size_value_arr = explode(' ', $myrow['size']); - - switch ($size_value_arr[1]) { - case _AM_TDMDOWNLOADS_BYTES: - case 'Bytes': - $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' B\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; - $db->query($sql); - break; - case _AM_TDMDOWNLOADS_KBYTES: - case 'kB': - $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' K\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; - $db->query($sql); - break; - case _AM_TDMDOWNLOADS_MBYTES: - case 'MB': - $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' M\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; - $db->query($sql); - break; - case _AM_TDMDOWNLOADS_GBYTES: - case 'GB': - $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' G\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; - $db->query($sql); - break; - case _AM_TDMDOWNLOADS_TBYTES: - case 'TB': - $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' T\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; - $db->query($sql); - break; + if ($result instanceof \mysqli_result) { + while (false !== ($myrow = $db->fetchArray($result))) { + $size_value_arr = explode(' ', $myrow['size']); + + switch ($size_value_arr[1]) { + case _AM_TDMDOWNLOADS_BYTES: + case 'Bytes': + $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' B\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; + $db->query($sql); + break; + case _AM_TDMDOWNLOADS_KBYTES: + case 'kB': + $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' K\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; + $db->query($sql); + break; + case _AM_TDMDOWNLOADS_MBYTES: + case 'MB': + $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' M\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; + $db->query($sql); + break; + case _AM_TDMDOWNLOADS_GBYTES: + case 'GB': + $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' G\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; + $db->query($sql); + break; + case _AM_TDMDOWNLOADS_TBYTES: + case 'TB': + $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `size` = \'' . $size_value_arr[0] . ' T\'' . ' WHERE `lid` = ' . $myrow['lid'] . ';'; + $db->query($sql); + break; + } } } - // Update folder rename(XOOPS_ROOT_PATH . '/uploads/TDMDownloads', XOOPS_ROOT_PATH . '/uploads/tdmdownloads'); diff --git a/include/search.inc.php b/include/search.inc.php index 7981a6d..12c652d 100644 --- a/include/search.inc.php +++ b/include/search.inc.php @@ -66,20 +66,20 @@ function tdmdownloads_search($queryarray, $andor, $limit, $offset, $userid) $ret = []; $i = 0; + if ($result instanceof \mysqli_result) { + while (false !== ($myrow = $xoopsDB->fetchArray($result))) { + $ret[$i]['image'] = 'assets/images/deco/tdmdownloads_search.png'; - while (false !== ($myrow = $xoopsDB->fetchArray($result))) { - $ret[$i]['image'] = 'assets/images/deco/tdmdownloads_search.png'; + $ret[$i]['link'] = 'singlefile.php?cid=' . $myrow['cid'] . '&lid=' . $myrow['lid'] . ''; - $ret[$i]['link'] = 'singlefile.php?cid=' . $myrow['cid'] . '&lid=' . $myrow['lid'] . ''; + $ret[$i]['title'] = $myrow['title']; - $ret[$i]['title'] = $myrow['title']; + $ret[$i]['time'] = $myrow['date']; - $ret[$i]['time'] = $myrow['date']; + $ret[$i]['uid'] = $myrow['submitter']; - $ret[$i]['uid'] = $myrow['submitter']; - - ++$i; + ++$i; + } } - return $ret; } From 0733ca7dba115fb9eb4bcd8ac13dd551c1d34497 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Wed, 18 Aug 2021 08:45:08 -0400 Subject: [PATCH 58/62] PHP 8 Smarty defaults $icons as arrays fix XoopsBlock --- admin/migrate.php | 38 +- class/Category.php | 17 +- class/Common/Configurator.php | 4 +- class/Common/Images.php | 8 +- class/Common/Migrate.php | 76 ++-- class/Common/SysUtility.php | 346 +++++++++++++----- class/Downloads.php | 9 +- class/Field.php | 2 +- class/Modified.php | 12 +- class/Utilities.php | 4 +- class/Utility.php | 22 +- config/paths.php | 16 +- extra/plugins/tag/tdmdownloads.php | 10 +- include/common.php | 5 +- include/oninstall.php | 14 +- include/onupdate.php | 223 +++++++++-- language/english/help/help.html | 42 --- language/french/help/help.html | 2 +- modfile.php | 3 +- search.php | 7 + submit.php | 12 +- templates/blocks/tdmdownloads_block_new.tpl | 2 +- .../tdmdownloads_block_styledefault.tpl | 8 +- .../blocks/tdmdownloads_block_stylesimple.tpl | 4 +- templates/tdmdownloads_brokenfile.tpl | 2 +- templates/tdmdownloads_download.tpl | 10 +- templates/tdmdownloads_index.tpl | 34 +- templates/tdmdownloads_liste.tpl | 16 +- templates/tdmdownloads_modfile.tpl | 2 +- templates/tdmdownloads_ratefile.tpl | 2 +- templates/tdmdownloads_rss.tpl | 2 +- templates/tdmdownloads_singlefile.tpl | 108 +++--- templates/tdmdownloads_submit.tpl | 2 +- templates/tdmdownloads_viewcat.tpl | 70 ++-- visit.php | 2 +- xoops_version.php | 2 +- 36 files changed, 706 insertions(+), 432 deletions(-) delete mode 100644 language/english/help/help.html diff --git a/admin/migrate.php b/admin/migrate.php index 4019a45..73936de 100644 --- a/admin/migrate.php +++ b/admin/migrate.php @@ -30,11 +30,20 @@ // Project: XOOPS Project // // ------------------------------------------------------------------------- // + use Xmf\Request; +use Xmf\Module\Admin; use XoopsModules\Tdmdownloads\{ - Common\Migrate}; + Common\Configurator, + Common\Migrate, + Helper +}; + +/** @var Admin $adminObject */ +/** @var Configurator $configurator */ +/** @var Migrate $migrator */ -require_once __DIR__ . '/admin_header.php'; +require __DIR__ . '/admin_header.php'; xoops_cp_header(); $adminObject->displayNavigation(basename(__FILE__)); @@ -55,47 +64,44 @@ //XoopsLoad::load('migrate', 'newbb'); -/** @var Tdmdownloads\Common\Configurator $configurator */ -$configurator = new Tdmdownloads\Common\Configurator(); +$configurator = new Configurator(); -/** @var \XoopsModules\Tdmdownloads\Common\Migrate $migrator */ $migrator = new Migrate($configurator); -$op = Request::getCmd('op', 'default'); -$opShow = Request::getCmd('show', null, 'POST'); +$op = Request::getCmd('op', 'show'); +$opShow = Request::getCmd('show', null, 'POST'); $opMigrate = Request::getCmd('migrate', null, 'POST'); -$opSchema = Request::getCmd('schema', null, 'POST'); -$op = !empty($opShow) ? 'show' : $op; -$op = !empty($opMigrate) ? 'migrate' : $op; -$op = !empty($opSchema) ? 'schema' : $op; +$opSchema = Request::getCmd('schema', null, 'POST'); +$op = !empty($opShow) ? 'show' : $op; +$op = !empty($opMigrate) ? 'migrate' : $op; +$op = !empty($opSchema) ? 'schema' : $op; $message = ''; switch ($op) { case 'show': + default: $queue = $migrator->getSynchronizeDDL(); if (!empty($queue)) { echo "
    \n";
    -
                 foreach ($queue as $line) {
                     echo $line . ";\n";
                 }
    -
                 echo "
    \n"; } break; case 'migrate': $migrator->synchronizeSchema(); - $message = 'Database migrated to current schema.'; + $message = constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_OK'); break; case 'schema': - xoops_confirm(['op' => 'confirmwrite'], 'migrate.php', 'Warning! This is intended for developers only. Confirm write schema file from current database.', 'Confirm'); + xoops_confirm(['op' => 'confirmwrite'], 'migrate.php', constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_WARNING'), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM')); break; case 'confirmwrite': if ($GLOBALS['xoopsSecurity']->check()) { $migrator->saveCurrentSchema(); - $message = 'Current schema file written'; + $message = constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_SCHEMA_OK'); } break; } diff --git a/class/Category.php b/class/Category.php index 6104a8e..037c9e0 100644 --- a/class/Category.php +++ b/class/Category.php @@ -18,7 +18,10 @@ */ use Xmf\Module\Helper\Permission; -use XoopsModules\Tdmdownloads; +use XoopsModules\Tdmdownloads\{ + Helper +}; +/** @var Helper $helper */ /** * Class Category @@ -38,9 +41,7 @@ public function __construct() { parent::__construct(); - /** @var Tdmdownloads\Helper $helper */ - - $this->helper = Tdmdownloads\Helper::getInstance(); + $this->helper = Helper::getInstance(); $this->permHelper = new Permission(); @@ -85,9 +86,7 @@ public function getNewEnreg($db = null) */ public function getForm($action = false) { - /** @var \XoopsModules\Tdmdownloads\Helper $helper */ - - $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); + $helper = Helper::getInstance(); if (!$action) { $action = $_SERVER['REQUEST_URI']; @@ -167,9 +166,7 @@ public function getForm($action = false) // Pour faire une sous-catégorie - /** @var \XoopsModules\Tdmdownloads\CategoryHandler $categoryHandler */ - - $categoryHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Category'); + $categoryHandler = Helper::getInstance()->getHandler('Category'); $criteria = new \CriteriaCompo(); diff --git a/class/Common/Configurator.php b/class/Common/Configurator.php index c615d82..bd7a766 100644 --- a/class/Common/Configurator.php +++ b/class/Common/Configurator.php @@ -61,8 +61,8 @@ public function __construct() $this->moduleStats = $config->moduleStats; $this->modCopyright = $config->modCopyright; - $this->icons = include \dirname(__DIR__, 2) . '/config/icons.php'; - $this->paths = include \dirname(__DIR__, 2) . '/config/paths.php'; + $this->icons = require \dirname(__DIR__, 2) . '/config/icons.php'; + $this->paths = require \dirname(__DIR__, 2) . '/config/paths.php'; } } diff --git a/class/Common/Images.php b/class/Common/Images.php index 7528728..a8e9fe9 100644 --- a/class/Common/Images.php +++ b/class/Common/Images.php @@ -19,7 +19,9 @@ * @author Wedega - Email: - Website: */ -use XoopsModules\Tdmdownloads; +use XoopsModules\Tdmdownloads\{ + Helper +}; /** * Class Object Images @@ -107,7 +109,7 @@ public function getFormImages($action = false) $moduleDirNameUpper = \mb_strtoupper($moduleDirName); - $helper = Tdmdownloads\Helper::getInstance(); + $helper = Helper::getInstance(); if (!$action) { $action = $_SERVER['REQUEST_URI']; @@ -269,7 +271,7 @@ public function getValuesImages($keys = null, $format = null, $maxDepth = null) $moduleDirNameUpper = \mb_strtoupper($moduleDirName); - $helper = Tdmdownloads\Helper::getInstance(); + $helper = Helper::getInstance(); $ret = $this->getValues($keys, $format, $maxDepth); diff --git a/class/Common/Migrate.php b/class/Common/Migrate.php index 3c5f3e5..a68effa 100644 --- a/class/Common/Migrate.php +++ b/class/Common/Migrate.php @@ -24,6 +24,7 @@ class Migrate extends \Xmf\Database\Migrate { private $renameTables; + private $renameColumns; /** * Migrate constructor. @@ -47,10 +48,11 @@ public function __construct() parent::__construct($moduleDirName); } + /** - * change table prefix if needed + * rename table if needed */ - private function changePrefix() + private function renameTable() { foreach ($this->renameTables as $oldName => $newName) { if ($this->tableHandler->useTable($oldName) && !$this->tableHandler->useTable($newName)) { @@ -60,53 +62,18 @@ private function changePrefix() } /** - * Change integer IPv4 column to varchar IPv6 capable - * - * @param string $tableName table to convert - * @param string $columnName column with IP address + * rename columns if needed */ - private function convertIPAddresses($tableName, $columnName) + private function renameColumns() { - if ($this->tableHandler->useTable($tableName)) { - $attributes = $this->tableHandler->getColumnAttributes($tableName, $columnName); - - if (false !== \mb_strpos($attributes, ' int(')) { - if (false === \mb_strpos($attributes, 'unsigned')) { - $this->tableHandler->alterColumn($tableName, $columnName, " bigint(16) NOT NULL DEFAULT '0' "); - - $this->tableHandler->update($tableName, [$columnName => "4294967296 + $columnName"], "WHERE $columnName < 0", false); + foreach ($this->renameColumns as $tableName) { + if ($this->tableHandler->useTable($tableName)) { + $oldName = $tableName['from']; + $newName = $tableName['to']; + $attributes = $this->tableHandler->getColumnAttributes($tableName, $oldName); + if (false !== \strpos($attributes, ' int(')) { + $this->tableHandler->alterColumn($tableName, $oldName, $attributes, $newName); } - - $this->tableHandler->alterColumn($tableName, $columnName, " varchar(45) NOT NULL DEFAULT '' "); - - $this->tableHandler->update($tableName, [$columnName => "INET_NTOA($columnName)"], '', false); - } - } - } - - /** - * Move do* columns from newbb_posts to newbb_posts_text table - */ - private function moveDoColumns() - { - $tableName = 'newbb_posts_text'; - - $srcTableName = 'newbb_posts'; - - if ($this->tableHandler->useTable($tableName) - && $this->tableHandler->useTable($srcTableName)) { - $attributes = $this->tableHandler->getColumnAttributes($tableName, 'dohtml'); - - if (false === $attributes) { - $this->synchronizeTable($tableName); - - $updateTable = $GLOBALS['xoopsDB']->prefix($tableName); - - $joinTable = $GLOBALS['xoopsDB']->prefix($srcTableName); - - $sql = "UPDATE `$updateTable` t1 INNER JOIN `$joinTable` t2 ON t1.post_id = t2.post_id \n" . "SET t1.dohtml = t2.dohtml, t1.dosmiley = t2.dosmiley, t1.doxcode = t2.doxcode\n" . ' , t1.doimage = t2.doimage, t1.dobr = t2.dobr'; - - $this->tableHandler->addToQueue($sql); } } } @@ -120,14 +87,13 @@ private function moveDoColumns() */ protected function preSyncActions() { - /* - // change 'bb' table prefix to 'newbb' - $this->changePrefix(); - // columns dohtml, dosmiley, doxcode, doimage and dobr moved between tables as some point - $this->moveDoColumns(); - // Convert IP address columns from int to readable varchar(45) for IPv6 - $this->convertIPAddresses('newbb_posts', 'poster_ip'); - $this->convertIPAddresses('newbb_report', 'reporter_ip'); - */ + // rename table + if ($this->renameTables && \is_array($this->renameTables)) { + $this->renameTable(); + } + // rename column + if ($this->renameColumns && \is_array($this->renameColumns)) { + $this->renameColumns(); + } } } diff --git a/class/Common/SysUtility.php b/class/Common/SysUtility.php index 997a767..8a67423 100644 --- a/class/Common/SysUtility.php +++ b/class/Common/SysUtility.php @@ -22,32 +22,192 @@ * @author Mamba */ -use XoopsModules\Tdmdownloads\Helper; +use Xmf\Request; +use XoopsFormEditor; +use XoopsModules\Tdmdownloads\{ + Helper +}; + /** * Class SysUtility */ class SysUtility { - use VersionChecks; + use VersionChecks; //checkVerXoops, checkVerPhp Traits + use ServerStats; // getServerStats Trait + use FilesManagement; // Files Management Trait + + //--------------- Common module methods ----------------------------- + + /** + * Access the only instance of this class + * + * @return SysUtility + * + */ + public static function getInstance(): SysUtility + { + static $instance; + if (null === $instance) { + $instance = new static(); + } + + return $instance; + } + + /** + * @param $text + * @param $form_sort + * @return string + */ + public static function selectSorting($text, $form_sort): string + { + global $start, $order, $sort; + + $select_view = ''; + $moduleDirName = \basename(\dirname(__DIR__)); + $helper = Helper::getInstance(); + + //$pathModIcon16 = XOOPS_URL . '/modules/' . $moduleDirName . '/' . $helper->getConfig('modicons16'); + $pathModIcon16 = $helper->url($helper->getModule()->getInfo('modicons16')); - //checkVerXoops, checkVerPhp Traits + $select_view = '' . $text . ''; + //$sorts = $sort == 'asc' ? 'desc' : 'asc'; + if ($form_sort == $sort) { + $sel1 = 'asc' === $order ? 'selasc.png' : 'asc.png'; + $sel2 = 'desc' === $order ? 'seldesc.png' : 'desc.png'; + } else { + $sel1 = 'asc.png'; + $sel2 = 'desc.png'; + } + $select_view .= ' ASC'; + $select_view .= 'DESC'; + $select_view .= ''; + + return $select_view; + } + + /***************Blocks***************/ + /** + * @param array $cats + * @return string + */ + public static function blockAddCatSelect(array $cats): string + { + $cat_sql = ''; + if (\is_array($cats) && !empty($cats)) { + $cat_sql = '(' . \current($cats); + \array_shift($cats); + foreach ($cats as $cat) { + $cat_sql .= ',' . $cat; + } + $cat_sql .= ')'; + } + + return $cat_sql; + } + + /** + * @param $content + */ + public static function metaKeywords($content): void + { + global $xoopsTpl, $xoTheme; + $myts = \MyTextSanitizer::getInstance(); + $content = $myts->undoHtmlSpecialChars($myts->displayTarea($content)); + if (\is_object($xoTheme)) { + $xoTheme->addMeta('meta', 'keywords', \strip_tags($content)); + } else { // Compatibility for old Xoops versions + $xoopsTpl->assign('xoops_metaKeywords', \strip_tags($content)); + } + } - use ServerStats; + /** + * @param $content + */ + public static function metaDescription($content): void + { + global $xoopsTpl, $xoTheme; + $myts = \MyTextSanitizer::getInstance(); + $content = $myts->undoHtmlSpecialChars($myts->displayTarea($content)); + if (\is_object($xoTheme)) { + $xoTheme->addMeta('meta', 'description', \strip_tags($content)); + } else { // Compatibility for old Xoops versions + $xoopsTpl->assign('xoops_metaDescription', \strip_tags($content)); + } + } - // getServerStats Trait + /** + * @param string $tableName + * @param string $columnName + * + * @return array|false + */ + public static function enumerate(string $tableName, string $columnName) + { + $table = $GLOBALS['xoopsDB']->prefix($tableName); + + // $result = $GLOBALS['xoopsDB']->query("SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS + // WHERE TABLE_NAME = '" . $table . "' AND COLUMN_NAME = '" . $columnName . "'") + // || exit ($GLOBALS['xoopsDB']->error()); + + $sql = 'SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = "' . $table . '" AND COLUMN_NAME = "' . $columnName . '"'; + $result = $GLOBALS['xoopsDB']->query($sql); + if (!$result) { + // exit($GLOBALS['xoopsDB']->error()); + $logger = \XoopsLogger::getInstance(); + $logger->handleError(\E_USER_WARNING, $sql, __FILE__, __LINE__); + return false; + } - use FilesManagement; + $row = $GLOBALS['xoopsDB']->fetchBoth($result); + $enumList = \explode(',', \str_replace("'", '', \mb_substr($row['COLUMN_TYPE'], 5, - 6))); + return $enumList; + } - // Files Management Trait - use ImageResizer; + /** + * Clone a record in a dB + * + * @TODO need to exit more gracefully on error. Should throw/trigger error and then return false + * + * @param string $tableName name of dB table (without prefix) + * @param string $idField name of field (column) in dB table + * @param int $id item id to clone + * + * @return mixed + */ + public static function cloneRecord(string $tableName, string $idField, int $id) + { + $newId = false; + $table = $GLOBALS['xoopsDB']->prefix($tableName); + // copy content of the record you wish to clone + $sql = "SELECT * FROM $table WHERE $idField='" . (int)$id . "' "; + $tempTable = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql), \MYSQLI_ASSOC); + if (!$tempTable) { + exit($GLOBALS['xoopsDB']->error()); + } + // set the auto-incremented id's value to blank. + unset($tempTable[$idField]); + // insert cloned copy of the original record + $sql = "INSERT INTO $table (" . \implode(', ', \array_keys($tempTable)) . ") VALUES ('" . \implode("', '", \array_values($tempTable)) . "')"; + $result = $GLOBALS['xoopsDB']->queryF($sql); + if (!$result) { + exit($GLOBALS['xoopsDB']->error()); + } + // Return the new id + return $GLOBALS['xoopsDB']->getInsertId(); + } /** * truncateHtml can truncate a string up to a number of characters while preserving whole words and HTML tags * www.gsdesign.ro/blog/cut-html-string-without-breaking-the-tags * www.cakephp.org * + * @TODO: Refactor to consider HTML5 & void (self-closing) elements + * @TODO: Consider using https://github.com/jlgrall/truncateHTML/blob/master/truncateHTML.php + * * @param string $text String to truncate. * @param int $length Length of returned string, including ellipsis. * @param string $ending Ending to be appended to the trimmed string. @@ -56,96 +216,72 @@ class SysUtility * * @return string Trimmed string. */ - public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true) - { + public static function truncateHtml( + string $text, + ?int $length = 100, + ?string $ending = '...', + ?bool $exact = false, + ?bool $considerHtml = true + ): string { + $openTags = []; if ($considerHtml) { // if the plain text is shorter than the maximum length, return the whole text - if (\mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) { return $text; } - // splits all html-tags to scanable lines - \preg_match_all('/(<.+?' . '>)?([^<>]*)/s', $text, $lines, \PREG_SET_ORDER); - $total_length = \mb_strlen($ending); - - $open_tags = []; - + //$openTags = []; $truncate = ''; - foreach ($lines as $line_matchings) { // if there is any html-tag in this line, handle it and add it (uncounted) to the output - if (!empty($line_matchings[1])) { // if it's an "empty element" with or without xhtml-conform closing slash - if (\preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) { // do nothing // if tag is a closing tag - } elseif (\preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) { - // delete tag from $open_tags list - - $pos = \array_search($tag_matchings[1], $open_tags, true); - + } elseif (\preg_match('/^<\s*\/(\S+?)\s*>$/s', $line_matchings[1], $tag_matchings)) { + // delete tag from $openTags list + $pos = \array_search($tag_matchings[1], $openTags, true); if (false !== $pos) { - unset($open_tags[$pos]); + unset($openTags[$pos]); } // if tag is an opening tag } elseif (\preg_match('/^<\s*([^\s>!]+).*?' . '>$/s', $line_matchings[1], $tag_matchings)) { - // add tag to the beginning of $open_tags list - - \array_unshift($open_tags, \mb_strtolower($tag_matchings[1])); + // add tag to the beginning of $openTags list + \array_unshift($openTags, \mb_strtolower($tag_matchings[1])); } - // add html-tag to $truncate'd text - $truncate .= $line_matchings[1]; } - // calculate the length of the plain text part of the line; handle entities as one character - - $content_length = \mb_strlen(\preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2])); - + $content_length = \mb_strlen(\preg_replace('/&[0-9a-z]{2,8};|&#\d{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2])); if ($total_length + $content_length > $length) { // the number of characters which are left - - $left = $length - $total_length; - + $left = $length - $total_length; $entities_length = 0; - // search for html entities - - if (\preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, \PREG_OFFSET_CAPTURE)) { + if (\preg_match_all('/&[0-9a-z]{2,8};|&#\d{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, \PREG_OFFSET_CAPTURE)) { // calculate the real length of all entities in the legal range - foreach ($entities[0] as $entity) { if ($left >= $entity[1] + 1 - $entities_length) { $left--; - $entities_length += \mb_strlen($entity[0]); } else { // no more characters left - break; } } } - $truncate .= \mb_substr($line_matchings[2], 0, $left + $entities_length); - - // maximum lenght is reached, so get off the loop - + // maximum length is reached, so get off the loop break; } - - $truncate .= $line_matchings[2]; - + $truncate .= $line_matchings[2]; $total_length += $content_length; // if the maximum length is reached, get off the loop - if ($total_length >= $length) { break; } @@ -154,32 +290,22 @@ public static function truncateHtml($text, $length = 100, $ending = '...', $exac if (\mb_strlen($text) <= $length) { return $text; } - $truncate = \mb_substr($text, 0, $length - \mb_strlen($ending)); } - // if the words shouldn't be cut in the middle... - if (!$exact) { // ...search the last occurance of a space... - $spacepos = \mb_strrpos($truncate, ' '); - if (isset($spacepos)) { // ...and cut the text in this position - $truncate = \mb_substr($truncate, 0, $spacepos); } } - // add the defined ending to the text - $truncate .= $ending; - if ($considerHtml) { // close all unclosed html-tags - - foreach ($open_tags as $tag) { + foreach ($openTags as $tag) { $truncate .= ''; } } @@ -188,27 +314,23 @@ public static function truncateHtml($text, $length = 100, $ending = '...', $exac } /** + * Get correct text editor based on user rights + * * @param \Xmf\Module\Helper $helper * @param array|null $options + * * @return \XoopsFormDhtmlTextArea|\XoopsFormEditor */ - public static function getEditor($helper = null, $options = null) + public static function getEditor(?\Xmf\Module\Helper $helper = null, ?array $options = null) { /** @var Helper $helper */ - if (null === $options) { - $options = []; - - $options['name'] = 'Editor'; - - $options['value'] = 'Editor'; - - $options['rows'] = 10; - - $options['cols'] = '100%'; - - $options['width'] = '100%'; - + $options = []; + $options['name'] = 'Editor'; + $options['value'] = 'Editor'; + $options['rows'] = 10; + $options['cols'] = '100%'; + $options['width'] = '100%'; $options['height'] = '400px'; } @@ -220,9 +342,9 @@ public static function getEditor($helper = null, $options = null) if (\class_exists('XoopsFormEditor')) { if ($isAdmin) { - $descEditor = new \XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorAdmin'), $options, $nohtml = false, $onfailure = 'textarea'); + $descEditor = new XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorAdmin'), $options, $nohtml = false, $onfailure = 'textarea'); } else { - $descEditor = new \XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorUser'), $options, $nohtml = false, $onfailure = 'textarea'); + $descEditor = new XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorUser'), $options, $nohtml = false, $onfailure = 'textarea'); } } else { $descEditor = new \XoopsFormDhtmlTextArea(\ucfirst($options['name']), $options['name'], $options['value'], '100%', '100%'); @@ -234,17 +356,69 @@ public static function getEditor($helper = null, $options = null) } /** - * @param $fieldname - * @param $table + * Check if column in dB table exists * - * @return bool + * @param string $fieldname name of dB table field + * @param string $table name of dB table (including prefix) + * + * @return bool true if table exists + * @deprecated */ - public function fieldExists($fieldname, $table) + public static function fieldExists(string $fieldname, string $table): bool { - global $xoopsDB; + $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1); + \trigger_error(__METHOD__ . " is deprecated, use Xmf\Database\Tables instead - instantiated from {$trace[0]['file']} line {$trace[0]['line']},"); + + $result = $GLOBALS['xoopsDB']->queryF("SHOW COLUMNS FROM $table LIKE '$fieldname'"); + return ($GLOBALS['xoopsDB']->getRowsNum($result) > 0); + } + + + /** + * Function responsible for checking if a directory exists, we can also write in and create an index.html file + * + * @param string $folder The full path of the directory to check + */ + public static function prepareFolder(string $folder): void + { + try { + if (!@\mkdir($folder) && !\is_dir($folder)) { + throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder)); + } + file_put_contents($folder . '/index.html', ''); + } catch (\Exception $e) { + echo 'Caught exception: ', $e->getMessage(), "\n", '
    '; + } + } - $result = $xoopsDB->queryF("SHOW COLUMNS FROM $table LIKE '$fieldname'"); + /** + * Check if dB table table exists + * + * @param string $tablename dB tablename with prefix + * @return bool true if table exists + */ + public static function tableExists(string $tablename): bool + { + $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1); + \trigger_error(__FUNCTION__ . " is deprecated, called from {$trace[0]['file']} line {$trace[0]['line']}"); + $GLOBALS['xoopsLogger']->addDeprecated( + \basename(\dirname(__DIR__, 2)) . ' Module: ' . __FUNCTION__ . ' function is deprecated, please use Xmf\Database\Tables method(s) instead.' . " Called from {$trace[0]['file']}line {$trace[0]['line']}" + ); + $result = $GLOBALS['xoopsDB']->queryF("SHOW TABLES LIKE '$tablename'"); + + return $GLOBALS['xoopsDB']->getRowsNum($result) > 0 ; + } - return $xoopsDB->getRowsNum($result) > 0; + /** + * Add a field to a mysql table + * + * @param $field + * @param $table + * @return bool|\mysqli_result + */ + public static function addField($field, $table) + { + global $xoopsDB; + return $xoopsDB->queryF('ALTER TABLE ' . $table . " ADD $field;"); } } diff --git a/class/Downloads.php b/class/Downloads.php index 2d16d16..1976e59 100644 --- a/class/Downloads.php +++ b/class/Downloads.php @@ -4,6 +4,7 @@ use XoopsModules\Tag\FormTag; + /** * TDMDownload * @@ -107,7 +108,7 @@ public function getForm($donnee = [], $erreur = false, $action = false) /** @var \XoopsModules\Tdmdownloads\Helper $helper */ - $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); + $helper = Helper::getInstance(); /** @var \XoopsModules\Tdmdownloads\Utility $utility */ @@ -170,7 +171,7 @@ public function getForm($donnee = [], $erreur = false, $action = false) /** @var \XoopsModules\Tdmdownloads\CategoryHandler $categoryHandler */ - $categoryHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Category'); + $categoryHandler = Helper::getInstance()->getHandler('Category'); $categories = $utility->getItemIds('tdmdownloads_submit', $moduleDirName); @@ -202,7 +203,7 @@ public function getForm($donnee = [], $erreur = false, $action = false) /** @var \XoopsModules\Tdmdownloads\FieldHandler $fieldHandler */ - $fieldHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Field'); + $fieldHandler = Helper::getInstance()->getHandler('Field'); $criteria = new \CriteriaCompo(); @@ -300,7 +301,7 @@ public function getForm($donnee = [], $erreur = false, $action = false) /** @var \XoopsModules\Tdmdownloads\FielddataHandler $fielddataHandler */ - $fielddataHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Fielddata'); + $fielddataHandler = Helper::getInstance()->getHandler('Fielddata'); $criteria = new \CriteriaCompo(); diff --git a/class/Field.php b/class/Field.php index 1c8d999..eddd329 100644 --- a/class/Field.php +++ b/class/Field.php @@ -72,7 +72,7 @@ public function getForm($action = false) { /** @var \XoopsModules\Tdmdownloads\Helper $helper */ - $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); + $helper = Helper::getInstance(); $moduleDirName = \basename(\dirname(__DIR__)); diff --git a/class/Modified.php b/class/Modified.php index 9321e72..6541d50 100644 --- a/class/Modified.php +++ b/class/Modified.php @@ -88,7 +88,7 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) /** @var \XoopsModules\Tdmdownloads\Helper $helper */ - $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); + $helper = Helper::getInstance(); $moduleDirName = \basename(\dirname(__DIR__)); @@ -107,9 +107,9 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) /** @var \XoopsModules\Tdmdownloads\DownloadsHandler $downloadsHandler */ - $downloadsHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Downloads'); + $downloadsHandler = Helper::getInstance()->getHandler('Downloads'); - // $categoryHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Category'); + // $categoryHandler = Helper::getInstance()->getHandler('Category'); $viewDownloads = $downloadsHandler->get($lid); @@ -177,7 +177,7 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) /** @var \XoopsModules\Tdmdownloads\CategoryHandler $categoryHandler */ - $categoryHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Category'); + $categoryHandler = Helper::getInstance()->getHandler('Category'); /** @var \XoopsModules\Tdmdownloads\Utility $utility */ @@ -211,7 +211,7 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) //affichage des champs - $fieldHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Field'); + $fieldHandler = Helper::getInstance()->getHandler('Field'); $criteria = new \CriteriaCompo(); @@ -304,7 +304,7 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); - $fielddataHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Fielddata'); + $fielddataHandler = Helper::getInstance()->getHandler('Fielddata'); $criteria = new \CriteriaCompo(); diff --git a/class/Utilities.php b/class/Utilities.php index 788b2d1..abf1dde 100644 --- a/class/Utilities.php +++ b/class/Utilities.php @@ -109,7 +109,7 @@ public static function getStatusImage($time, $status) /** @var Tdmdownloads\Helper $helper */ - $helper = Tdmdownloads\Helper::getInstance(); + $helper = Helper::getInstance(); $count = 7; @@ -157,7 +157,7 @@ public static function getPopularImage($hits) { /** @var Tdmdownloads\Helper $helper */ - $helper = Tdmdownloads\Helper::getInstance(); + $helper = Helper::getInstance(); $moduleDirName = \basename(\dirname(__DIR__)); diff --git a/class/Utility.php b/class/Utility.php index 15cac0e..7b70392 100644 --- a/class/Utility.php +++ b/class/Utility.php @@ -95,6 +95,9 @@ public function getStatusImage($time, $status) { global $xoopsModuleConfig; + $moduleDirName = basename(dirname(__DIR__)); + $helper = Helper::getInstance(); + $count = 7; $new = ''; @@ -105,25 +108,25 @@ public function getStatusImage($time, $status) if ($startdate < $time) { $language = $GLOBALS['xoopsConfig']['language']; - if (!\is_dir(XOOPS_ROOT_PATH . '/modules/tdmdownloads/language/' . $language . '/')) { + if (!\is_dir(XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/language/' . $language . '/')) { $language = 'english'; } - $img_path = XOOPS_ROOT_PATH . '/modules/tdmdownloads/language/' . $language . '/'; + $img_path = XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/language/' . $language . '/'; - $img_url = XOOPS_URL . '/modules/tdmdownloads/language/' . $language . '/'; + $img_url = XOOPS_URL . '/modules/' . $moduleDirName . '/language/' . $language . '/'; if (1 == $status) { if (\is_readable($img_path . 'new.png')) { $new = ' ' . _MD_TDMDOWNLOADS_INDEX_NEWTHISWEEK . ''; } else { - $new = ' ' . _MD_TDMDOWNLOADS_INDEX_NEWTHISWEEK . ''; + $new = ' ' . _MD_TDMDOWNLOADS_INDEX_NEWTHISWEEK . ''; } } elseif (2 == $status) { if (\is_readable($img_path . 'updated.png')) { $new = ' ' . _MD_TDMDOWNLOADS_INDEX_UPTHISWEEK . ''; } else { - $new = ' ' . _MD_TDMDOWNLOADS_INDEX_UPTHISWEEK . ''; + $new = ' ' . _MD_TDMDOWNLOADS_INDEX_UPTHISWEEK . ''; } } } @@ -140,24 +143,25 @@ public function getStatusImage($time, $status) public function getPopularImage($hits) { global $xoopsModuleConfig; + $moduleDirName = basename(dirname(__DIR__)); $pop = ''; if ($hits >= $xoopsModuleConfig['popular']) { $language = $GLOBALS['xoopsConfig']['language']; - if (!\is_dir(XOOPS_ROOT_PATH . '/modules/tdmdownloads/language/' . $language . '/')) { + if (!\is_dir(XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/language/' . $language . '/')) { $language = 'english'; } - $img_path = XOOPS_ROOT_PATH . '/modules/tdmdownloads/language/' . $language . '/'; + $img_path = XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/language/' . $language . '/'; - $img_url = XOOPS_URL . '/modules/tdmdownloads/language/' . $language . '/'; + $img_url = XOOPS_URL . '/modules/' . $moduleDirName . '/language/' . $language . '/'; if (\is_readable($img_path . 'popular.png')) { $pop = ' ' . _MD_TDMDOWNLOADS_INDEX_POPULAR . ''; } else { - $pop = ' ' . _MD_TDMDOWNLOADS_INDEX_POPULAR . ''; + $pop = ' ' . _MD_TDMDOWNLOADS_INDEX_POPULAR . ''; } } diff --git a/config/paths.php b/config/paths.php index eef88b7..8c9fb4e 100644 --- a/config/paths.php +++ b/config/paths.php @@ -4,16 +4,14 @@ $moduleDirName = basename(dirname(__DIR__)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); -return (object)[ +return [ 'name' => mb_strtoupper($moduleDirName) . ' PathConfigurator', - 'paths' => [ - 'dirname' => $moduleDirName, - 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin', - 'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName, - 'modUrl' => XOOPS_URL . '/modules/' . $moduleDirName, - 'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName, - 'uploadUrl' => XOOPS_UPLOAD_URL . '/' . $moduleDirName, - ], + 'dirname' => $moduleDirName, + 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin', + 'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName, + 'modUrl' => XOOPS_URL . '/modules/' . $moduleDirName, + 'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName, + 'uploadUrl' => XOOPS_UPLOAD_URL . '/' . $moduleDirName, 'uploadFolders' => [ XOOPS_UPLOAD_PATH . '/' . $moduleDirName, XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/category', diff --git a/extra/plugins/tag/tdmdownloads.php b/extra/plugins/tag/tdmdownloads.php index 7b7d97c..7a731d3 100644 --- a/extra/plugins/tag/tdmdownloads.php +++ b/extra/plugins/tag/tdmdownloads.php @@ -18,7 +18,11 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) */ -use XoopsModules\Tag\Helper; +use XoopsModules\Tag\Helper as TagHelper; +use XoopsModules\Tdmdownloads\{ + Helper +}; + /** * @param $items @@ -40,7 +44,7 @@ function tdmdownloads_tag_iteminfo(&$items) /** @var \XoopsModules\Tdmdownloads\DownloadsHandler $itemHandler */ - $itemHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Downloads'); + $itemHandler = Helper::getInstance()->getHandler('Downloads'); /** @var \XoopsModules\Tdmdownloads\Downloads $item_obj */ @@ -75,7 +79,7 @@ function tdmdownloads_tag_synchronization($mid) { /** @var \XoopsModules\Tdmdownloads\DownloadsHandler $itemHandler */ - $itemHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Downloads'); + $itemHandler = Helper::getInstance()->getHandler('Downloads'); /** @var \XoopsModules\Tag\LinkHandler $linkHandler */ diff --git a/include/common.php b/include/common.php index 26ac2e8..bfe04ea 100644 --- a/include/common.php +++ b/include/common.php @@ -19,8 +19,9 @@ */ use Xmf\Module\Admin; -use XoopsModules\Tdmdownloads; -use XoopsModules\Tdmdownloads\Helper; +use XoopsModules\Tdmdownloads\{ + Helper +}; require dirname(__DIR__) . '/preloads/autoloader.php'; diff --git a/include/oninstall.php b/include/oninstall.php index ec1a204..7b2b5f1 100644 --- a/include/oninstall.php +++ b/include/oninstall.php @@ -209,19 +209,19 @@ function xoops_module_install_tdmdownloads() //Copy index.html - $indexFile = XOOPS_ROOT_PATH . '/modules/' . $namemodule . '/include/index.html'; + $indexFile = XOOPS_ROOT_PATH . '/modules/' . $namemodule . '/include/index.php'; - copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/index.html'); + copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/index.php'); - copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/index.html'); + copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/index.php'); - copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/cats/index.html'); + copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/cats/index.php'); - copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/shots/index.html'); + copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/shots/index.php'); - copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/field/index.html'); + copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/images/field/index.php'); - copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/downloads/index.html'); + copy($indexFile, XOOPS_ROOT_PATH . '/uploads/' . $namemodule . '/downloads/index.php'); //Copy blank.gif diff --git a/include/onupdate.php b/include/onupdate.php index 0f9e202..d2263e0 100644 --- a/include/onupdate.php +++ b/include/onupdate.php @@ -1,6 +1,22 @@ IsAdmin()) { + exit('Restricted access' . PHP_EOL); +} /** * TDMDownload @@ -19,10 +35,51 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Gregory Mage (Aka Mage) */ + +/** + * Prepares system prior to attempting to install module + * @param \XoopsModule $module {@link XoopsModule} + * @return bool true if ready to install, false if not + */ +function xoops_module_pre_update_tdmdownloads(\XoopsModule $module) +{ + $moduleDirName = \basename(\dirname(__DIR__)); + $helper = Helper::getInstance(); + $utility = new Utility(); + + $xoopsSuccess = $utility::checkVerXoops($module); + $phpSuccess = $utility::checkVerPhp($module); + + /** @var Configurator $configurator */ + $configurator = new Configurator(); + + //create upload folders + $uploadFolders = $configurator->uploadFolders; + foreach ($uploadFolders as $value) { + $utility::prepareFolder($value); + } + + $migrator = new Migrate(); + $migrator->synchronizeSchema(); + + return $xoopsSuccess && $phpSuccess; +} + + + function xoops_module_update_tdmdownloads(&$module, $prev_version = null) { $ret = null; + $moduleDirName = \basename(\dirname(__DIR__)); + $moduleDirNameUpper = mb_strtoupper($moduleDirName); + + $helper = Helper::getInstance(); + $utility = new Utility(); + $configurator = new Configurator(); + + $helper->loadLanguage('common'); + if ($prev_version < 163) { $ret = update_tdmdownloads_v163($module); } @@ -35,6 +92,10 @@ function xoops_module_update_tdmdownloads(&$module, $prev_version = null) $ret = update_tdmdownloads_v200($module); } + if ($prev_version < 201) { + $ret = update_tdmdownloads_v201($module); + } + $errors = $module->getErrors(); if (!empty($errors)) { @@ -44,6 +105,105 @@ function xoops_module_update_tdmdownloads(&$module, $prev_version = null) return $ret; } + +/** + * @param $module + * @return bool + */ +function update_tdmdownloads_v201(&$module) +{ + $moduleDirName = \basename(\dirname(__DIR__)); + $moduleDirNameUpper = mb_strtoupper($moduleDirName); + + $helper = Helper::getInstance(); + $utility = new Utility(); + $configurator = new Configurator(); + + $helper->loadLanguage('common'); + + //delete old HTML templates + if (count($configurator->templateFolders) > 0) { + foreach ($configurator->templateFolders as $folder) { + $templateFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $folder); + if (is_dir($templateFolder)) { + $templateList = array_diff(scandir($templateFolder, SCANDIR_SORT_NONE), ['..', '.']); + foreach ($templateList as $k => $v) { + $fileInfo = new SplFileInfo($templateFolder . $v); + if ('html' === $fileInfo->getExtension() && 'index.html' !== $fileInfo->getFilename()) { + if (file_exists($templateFolder . $v)) { + unlink($templateFolder . $v); + } + } + } + } + } + } + + // --- DELETE OLD FILES --------------- + if (count($configurator->oldFiles) > 0) { + // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { + foreach (array_keys($configurator->oldFiles) as $i) { + $tempFile = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFiles[$i]); + if (is_file($tempFile)) { + unlink($tempFile); + } + } + } + + // --- DELETE OLD FOLDERS --------------- + xoops_load('XoopsFile'); + if (count($configurator->oldFolders) > 0) { + // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { + foreach (array_keys($configurator->oldFolders) as $i) { + $tempFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFolders[$i]); + /** @var XoopsObjectHandler $folderHandler */ + $folderHandler = \XoopsFile::getHandler('folder', $tempFolder); + $folderHandler->delete($tempFolder); + } + } + + // --- CREATE UPLOAD FOLDERS --------------- + if (count($configurator->uploadFolders) > 0) { + // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { + foreach (array_keys($configurator->uploadFolders) as $i) { + $utility::createFolder($configurator->uploadFolders[$i]); + } + } + + // --- COPY blank.png FILES --------------- + if (count($configurator->copyBlankFiles) > 0) { + $file = dirname(__DIR__) . '/assets/images/blank.png'; + foreach (array_keys($configurator->copyBlankFiles) as $i) { + $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; + $utility::copyFile($file, $dest); + } + } + + //delete .html entries from the tpl table + $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; + $GLOBALS['xoopsDB']->queryF($sql); + + //delete .tpl entries from the tpl table + $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.tpl%'"; + $GLOBALS['xoopsDB']->queryF($sql); + + //delete tdmdownloads entries from the tpl_source table + $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplsource') . " WHERE `tpl_source` LIKE '%tdmdownloads%'"; + $GLOBALS['xoopsDB']->queryF($sql); + + $sql = 'CREATE TABLE `' . $GLOBALS['xoopsDB']->prefix('tdmdownloads_downlimit') . "` (downlimit_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, downlimit_lid INT(11) UNSIGNED NOT NULL DEFAULT '0', + downlimit_uid INT(11) NOT NULL DEFAULT '0', downlimit_hostname VARCHAR(60) NOT NULL DEFAULT '', downlimit_date INT(10) NOT NULL DEFAULT '0', PRIMARY KEY (downlimit_id) + ) ENGINE=MyISAM"; + + $GLOBALS['xoopsDB']->query($sql); + + /** @var XoopsGroupPermHandler $gpermHandler */ + $gpermHandler = xoops_getHandler('groupperm'); + + return $gpermHandler->deleteByModule($module->getVar('mid'), 'item_read'); + +} + /** * @param $module * @return bool @@ -52,6 +212,7 @@ function update_tdmdownloads_v200(&$module) { // Update size + $moduleDirName = basename(dirname(__DIR__)); $db = \XoopsDatabaseFactory::getDatabaseConnection(); $sql = 'SELECT lid, size FROM ' . $db->prefix('tdmdownloads_downloads'); @@ -61,6 +222,7 @@ function update_tdmdownloads_v200(&$module) $helper = Helper::getInstance(); $helper->loadLanguage('admin'); + if ($result instanceof \mysqli_result) { while (false !== ($myrow = $db->fetchArray($result))) { $size_value_arr = explode(' ', $myrow['size']); @@ -96,11 +258,11 @@ function update_tdmdownloads_v200(&$module) } // Update folder - rename(XOOPS_ROOT_PATH . '/uploads/TDMDownloads', XOOPS_ROOT_PATH . '/uploads/tdmdownloads'); + rename(XOOPS_ROOT_PATH . '/uploads/TDMDownloads', XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName ); // Change TDMDownloads with tdmdownloads - $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `url` = REPLACE(`url`, \'TDMDownloads\', \'tdmdownloads\') WHERE `url` LIKE \'%TDMDownloads%\''; + $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `url` = REPLACE(`url`, \'TDMDownloads\', \''. $moduleDirName.'\') WHERE `url` LIKE \'%TDMDownloads%\''; $result = $db->query($sql); @@ -113,59 +275,46 @@ function update_tdmdownloads_v200(&$module) */ function update_tdmdownloads_v167(&$module) { + $moduleDirName = basename(dirname(__DIR__)); // rename module dir from upper case to lower case - rename(XOOPS_ROOT_PATH . '/modules/TDMDownloads', XOOPS_ROOT_PATH . '/modules/tdmdownloads'); + rename(XOOPS_ROOT_PATH . '/modules/TDMDownloads', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName); // rename upload dir from upper case to lower case - rename(XOOPS_ROOT_PATH . '/uploads/TDMDownloads', XOOPS_ROOT_PATH . '/uploads/tdmdownloads'); + rename(XOOPS_ROOT_PATH . '/uploads/TDMDownloads', XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName); // files have been moved to assets-folder - $src = XOOPS_ROOT_PATH . '/modules/tdmdownloads/css/'; + $src = XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/css/'; rrmdir($src); - $src = XOOPS_ROOT_PATH . '/modules/tdmdownloads/images/'; + $src = XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/images/'; rrmdir($src); // delete unneeded/replacfiles - // unlink( XOOPS_ROOT_PATH.'/modules/tdmdownloads/admin/admin_header.php' ); + // unlink( XOOPS_ROOT_PATH.'/modules/' . $moduleDirName . '/admin/admin_header.php' ); // clean template directory - @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_brokenfile.html'); - - @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_download.html'); - - @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_index.html'); - - @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_modfile.html'); - - @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_ratefile.html'); - - @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_singlefile.html'); - - @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_submit.html'); - - @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_viewcat.html'); - - @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_liste.html'); - - @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_rss.html'); - - @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/blocks/tdmdownloads_block_new.html'); - - @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/blocks/tdmdownloads_block_random.html'); - - @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/blocks/tdmdownloads_block_rating.html'); - - @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/blocks/tdmdownloads_block_search.html'); - - @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/blocks/tdmdownloads_block_top.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/templates/tdmdownloads_brokenfile.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/templates/tdmdownloads_download.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/templates/tdmdownloads_index.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/templates/tdmdownloads_modfile.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/templates/tdmdownloads_ratefile.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/templates/tdmdownloads_singlefile.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/templates/tdmdownloads_submit.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/templates/tdmdownloads_viewcat.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/templates/tdmdownloads_liste.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/templates/tdmdownloads_rss.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/templates/blocks/tdmdownloads_block_new.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/templates/blocks/tdmdownloads_block_random.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/templates/blocks/tdmdownloads_block_rating.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/templates/blocks/tdmdownloads_block_search.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/templates/blocks/tdmdownloads_block_top.html'); return true; } diff --git a/language/english/help/help.html b/language/english/help/help.html deleted file mode 100644 index 7a56dd7..0000000 --- a/language/english/help/help.html +++ /dev/null @@ -1,42 +0,0 @@ -
    -

    Help: - TDMDownloads Back to the Administration of TDMDownloads - -

    - -

    Description

    -

    - Creates a downloads section where users can download/submit/rate various files. - It uses XOOPS permission and group management, thus allowing a great flexibility in use. -

    -

    Install/uninstall

    - No special measures necessary, follow the standard installation process - extract the /tdmdownloads folder into the ../modules directory. Install the module through Admin -> System Module -> Modules. -

    - Detailed instructions on installing modules are available in the - XOOPS Operations Manual -

    -

    Operating instructions

    - To set up this module you need to: -

    - i) Configure your preferences for the module (see "Preferences") and - optionally the Partners block if you intend to use it (see - Blocks) -

    - ii) Check that you have given your user groups the necessary module and - block access rights to use this module. Group permissions are set through - the Administration Menu -> System -> Groups. -

    - Detailed instructions on configuring the access rights for user groups are available in the - XOOPS Operations Manual -

    -

    Tutorial

    -

    - Not available at the moment. -

    - -
    diff --git a/language/french/help/help.html b/language/french/help/help.html index 4c87319..ff183fd 100644 --- a/language/french/help/help.html +++ b/language/french/help/help.html @@ -1,7 +1,7 @@

    Aide : TDMDownloads Retour à l'administration de TDMDownloads diff --git a/modfile.php b/modfile.php index dcb08c1..8ea2478 100644 --- a/modfile.php +++ b/modfile.php @@ -17,7 +17,8 @@ use XoopsModules\Tdmdownloads\{ Helper, - Tree}; + Tree +}; require_once __DIR__ . '/header.php'; diff --git a/search.php b/search.php index 9d3a437..e9f05fd 100644 --- a/search.php +++ b/search.php @@ -16,12 +16,16 @@ */ use XoopsModules\Tdmdownloads\{ + CategoryHandler, + Downloads, DownloadsHandler, Helper, Tree, Utility}; /** @var Helper $helper */ /** @var Utility $utility */ +/** @var CategoryHandler $categoryHandler */ +/** @var FieldHandler $fieldHandler */ require_once __DIR__ . '/header.php'; @@ -29,6 +33,7 @@ $helper = Helper::getInstance(); $utility = new Utility(); $downloadsHandler = $helper->getHandler('Downloads'); +require __DIR__ . '/include/common.php'; // template d'affichage $GLOBALS['xoopsOption']['template_main'] = 'tdmdownloads_liste.tpl'; @@ -153,6 +158,7 @@ } else { $criteria->setOrder('ASC'); + /** @var Downloads $tdmdownloadsArray */ $tdmdownloadsArray = $downloadsHandler->getAll($criteria); foreach (array_keys($tdmdownloadsArray) as $j) { @@ -376,5 +382,6 @@ //keywords $keywords = mb_substr($keywords, 0, -1); $xoTheme->addMeta('meta', 'keywords', strip_tags($keywords)); +$GLOBALS['xoopsTpl']->assign('mod_url', XOOPS_URL . '/modules/' . $moduleDirName); require XOOPS_ROOT_PATH . '/footer.php'; diff --git a/submit.php b/submit.php index 87680d3..4630d21 100644 --- a/submit.php +++ b/submit.php @@ -1,10 +1,13 @@ getConfig('usetag') && class_exists(TagHandler::class)) { /** @var \XoopsModules\Tag\TagHandler $tagHandler */ - $tagHandler = Helper::getInstance()->getHandler('Tag'); + $tagHandler = TagHelper::getInstance()->getHandler('Tag'); $tagHandler->updateByItem($_POST['tag'], $lidDownloads, $moduleDirName, 0); } @@ -382,4 +385,7 @@ $xoopsTpl->assign('themeForm', $form->render()); break; } + +$GLOBALS['xoopsTpl']->assign('mod_url', XOOPS_URL . '/modules/' . $moduleDirName); + require XOOPS_ROOT_PATH . '/footer.php'; diff --git a/templates/blocks/tdmdownloads_block_new.tpl b/templates/blocks/tdmdownloads_block_new.tpl index cef8332..9b3d1f7 100644 --- a/templates/blocks/tdmdownloads_block_new.tpl +++ b/templates/blocks/tdmdownloads_block_new.tpl @@ -10,7 +10,7 @@ <{/if}> diff --git a/templates/blocks/tdmdownloads_block_styledefault.tpl b/templates/blocks/tdmdownloads_block_styledefault.tpl index d4eb17e..ff0268e 100644 --- a/templates/blocks/tdmdownloads_block_styledefault.tpl +++ b/templates/blocks/tdmdownloads_block_styledefault.tpl @@ -1,7 +1,7 @@
    <{if $downloads.inforation}> @@ -15,13 +15,13 @@ <{if $downloads.logourl || $downloads.description}>
    - <{if $downloads.logourl != ""}> + <{if $downloads.logourl|default:'' != ''}> <{$downloads.title}> <{/if}> - <{if $downloads.description != ""}> + <{if $downloads.description|default:'' != ''}> <{$downloads.description}> - --> + --> <{/if}>
    diff --git a/templates/blocks/tdmdownloads_block_stylesimple.tpl b/templates/blocks/tdmdownloads_block_stylesimple.tpl index 5af8488..e48d5b4 100644 --- a/templates/blocks/tdmdownloads_block_stylesimple.tpl +++ b/templates/blocks/tdmdownloads_block_stylesimple.tpl @@ -29,10 +29,10 @@

    - <{if $perm_submit}> - + <{/if}>

    diff --git a/templates/tdmdownloads_brokenfile.tpl b/templates/tdmdownloads_brokenfile.tpl index 3ec8db8..2c08699 100644 --- a/templates/tdmdownloads_brokenfile.tpl +++ b/templates/tdmdownloads_brokenfile.tpl @@ -2,7 +2,7 @@ diff --git a/templates/tdmdownloads_download.tpl b/templates/tdmdownloads_download.tpl index 4e9c4cd..ed0818c 100644 --- a/templates/tdmdownloads_download.tpl +++ b/templates/tdmdownloads_download.tpl @@ -1,7 +1,7 @@
    @@ -15,8 +15,8 @@ <{if $down.pop}> <{$down.pop}> <{/if}> - <{if $down.perm_download != ""}> - + <{$smarty.const._MD_TDMDOWNLOADS_INDEX_DLNOW}> <{/if}> <{$smarty.const._MD_TDMDOWNLOADS_INDEX_SUBMITDATE}><{$down.updated}> @@ -24,7 +24,7 @@ <{$down.description_short}>
    <{if $show_screenshot === true}> - <{if $down.logourl != ''}> + <{if $down.logourl|default:'' != ''}> <{$down.title}> <{/if}> <{/if}> @@ -33,7 +33,7 @@
    diff --git a/templates/tdmdownloads_index.tpl b/templates/tdmdownloads_index.tpl index fb23f35..8c09dda 100644 --- a/templates/tdmdownloads_index.tpl +++ b/templates/tdmdownloads_index.tpl @@ -2,7 +2,7 @@ <{if is_array($categories|default:'') && count($categories) gt 0}> @@ -15,21 +15,21 @@
    - <{if $category.image != ""}> - <{$category.title}> + <{if $category.image|default:'' != ''}> + <{$category.title}> <{/if}> <{$category.description_main}>
    - <{if $category.subcategories != ""}> + <{if $category.subcategories|default:'' != ''}>
    <{$smarty.const._MD_TDMDOWNLOADS_INDEX_SCAT}>
      <{$category.subcategories}>
    @@ -48,23 +48,23 @@
    - <{$smarty.const._MD_TDMDOWNLOADS_RSS}> + <{$smarty.const._MD_TDMDOWNLOADS_RSS}>
    <{if $bl_affichage==1}>
    <{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLNAME}>

    - <{if $bl_date != ""}> + <{if $bl_date|default:'' != ''}> <{/if}> - <{if $bl_pop != ""}> + <{if $bl_pop|default:'' != ''}> <{/if}> - <{if $bl_rating != ""}> + <{if $bl_rating|default:'' != ''}>
    - <{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLDATE}><{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLDATE}> + <{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLDATE}><{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLDATE}>
    - <{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLPOP}><{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLPOP}> + <{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLPOP}><{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLPOP}>
    - <{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLRATING}><{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLRATING}> + <{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLRATING}><{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLRATING}>
      <{foreach item=bl_rating from=$bl_rating}>
    • - <{$bl_rating.title}> + <{$bl_rating.title}> (<{$bl_rating.rating}>)
    • <{/foreach}> @@ -115,7 +115,7 @@ <{if $show_latest_files}> - <{if $file|default:'' != ""}> + <{if $file|default:'' != ''}>
      <{$smarty.const._MD_TDMDOWNLOADS_INDEX_LATESTLIST}>
      diff --git a/templates/tdmdownloads_liste.tpl b/templates/tdmdownloads_liste.tpl index 4d09807..a960e1f 100644 --- a/templates/tdmdownloads_liste.tpl +++ b/templates/tdmdownloads_liste.tpl @@ -1,7 +1,7 @@
      @@ -23,13 +23,13 @@ <{foreach item=download from=$search_list}>
      <{foreach item=fielddata from=$download.fielddata}> @@ -38,14 +38,14 @@
      - <{$download.title}> + <{$download.title}> <{$download.cat}> - <{$download.cat}> + <{$download.cat}> <{$fielddata}><{$download.rating}> <{$download.hits}> - + <{$smarty.const._MD_TDMDOWNLOADS_SEARCH_DOWNLOAD}><{$download.title}> - + <{$smarty.const._PREVIEW}><{$download.title}> <{if $perm_submit}> - + <{$smarty.const._EDIT}><{$download.title}> <{/if}> @@ -54,9 +54,9 @@ <{/foreach}>
      - <{if $pagenav != ''}> + <{if $pagenav|default:'' != ''}>
      <{$pagenav}>
      <{/if}> -
    \ No newline at end of file + diff --git a/templates/tdmdownloads_modfile.tpl b/templates/tdmdownloads_modfile.tpl index e642240..c0dda07 100644 --- a/templates/tdmdownloads_modfile.tpl +++ b/templates/tdmdownloads_modfile.tpl @@ -2,7 +2,7 @@ diff --git a/templates/tdmdownloads_ratefile.tpl b/templates/tdmdownloads_ratefile.tpl index 2444676..292bce3 100644 --- a/templates/tdmdownloads_ratefile.tpl +++ b/templates/tdmdownloads_ratefile.tpl @@ -2,7 +2,7 @@ diff --git a/templates/tdmdownloads_rss.tpl b/templates/tdmdownloads_rss.tpl index b60ba1c..b5a8beb 100644 --- a/templates/tdmdownloads_rss.tpl +++ b/templates/tdmdownloads_rss.tpl @@ -12,7 +12,7 @@ <{$channel_webmaster}> <{$channel_language}> - <{if $image_url != ""}> + <{if $image_url|default:'' != ''}> <{$channel_title}> <{$image_url}> diff --git a/templates/tdmdownloads_singlefile.tpl b/templates/tdmdownloads_singlefile.tpl index e6be16a..cd1f8f3 100644 --- a/templates/tdmdownloads_singlefile.tpl +++ b/templates/tdmdownloads_singlefile.tpl @@ -2,7 +2,7 @@ @@ -22,7 +22,7 @@
    <{if $show_screenshot === true}> - <{if $logourl != ''}> + <{if $logourl|default:'' != ''}> <{$title}> <{/if}> <{/if}> @@ -34,7 +34,7 @@
    <{$smarty.const._MD_TDMDOWNLOADS_SINGLEFILE_AUTHOR}><{$author}>
    <{$hits}>
    <{$smarty.const._MD_TDMDOWNLOADS_SINGLEFILE_RATING}><{$rating}><{$votes}>
    - <{if $commentsnav != ''}> + <{if $commentsnav|default:'' != ''}>
    <{$nb_comments}>
    <{/if}>
    @@ -46,22 +46,22 @@
    <{/if}> - <{if $perm_download != ""}> + <{if $perm_download|default:'' != ''}>
    <{$smarty.const._MD_TDMDOWNLOADS_INDEX_DLNOW}> @@ -100,13 +100,13 @@
  • @@ -124,45 +124,45 @@
    <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_ME}>
    - <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_BLINKLIST}> - <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_DELICIOUS}> - <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_DIGG}> + <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_BLINKLIST}> + <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_DELICIOUS}> + <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_DIGG}> <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_FARK}> - <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_FURL}> - <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_NEWSVINE}> - <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_REDDIT}> - <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_YAHOO}> - <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_BALATARIN}> - <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_FACEBOOK}> - <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_TWITTER}> - <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_SCRIPSTYLE}> - <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_STUMBLE}> - <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_TECHNORATI}> - <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_MIXX}> - <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_MYSPACE}> - <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_DESIGNFLOAT}> - <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_GOOGLEPLUS}> - <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_GOOGLEBOOKMARKS}> + href="http://cgi.fark.com/cgi/fark/edit.pl?new_url=<{$mod_url}>/singlefile.php?lid=<{$lid}>&new_comment=<{$downloads.title}>&new_link_other=<{$downloads.title}>&linktype=Misc"><{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_FARK}> + <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_FURL}> + <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_NEWSVINE}> + <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_REDDIT}> + <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_YAHOO}> + <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_BALATARIN}> + <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_FACEBOOK}> + <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_TWITTER}> + <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_SCRIPSTYLE}> + <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_STUMBLE}> + <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_TECHNORATI}> + <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_MIXX}> + <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_MYSPACE}> + <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_DESIGNFLOAT}> + <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_GOOGLEPLUS}> + <{$smarty.const._MD_TDMDOWNLOADS_BOOKMARK_TO_GOOGLEBOOKMARKS}>
    <{/if}> @@ -172,11 +172,11 @@ <{$lang_notice}>
  • - <{if $comment_mode == "flat"}> - <{include file="db:system_comments_flat.tpl"}> - <{elseif $comment_mode == "thread"}> - <{include file="db:system_comments_thread.tpl"}> - <{elseif $comment_mode == "nest"}> + <{if $comment_mode|default:'' == "flat"}> + <{include file="db:system_comments_flat.tpl"}> + <{elseif $comment_mode|default:'' == "thread"}> + <{include file="db:system_comments_thread.tpl"}> + <{elseif $comment_mode|default:'' == "nest"}> <{include file="db:system_comments_nest.tpl"}> <{/if}>
    diff --git a/templates/tdmdownloads_submit.tpl b/templates/tdmdownloads_submit.tpl index cefb1af..9d64e41 100644 --- a/templates/tdmdownloads_submit.tpl +++ b/templates/tdmdownloads_submit.tpl @@ -2,7 +2,7 @@ diff --git a/templates/tdmdownloads_viewcat.tpl b/templates/tdmdownloads_viewcat.tpl index a8fbc35..c8b9e4e 100644 --- a/templates/tdmdownloads_viewcat.tpl +++ b/templates/tdmdownloads_viewcat.tpl @@ -2,13 +2,13 @@
    <{$category_path}>
    - <{if $cat_description != ""}> + <{if $cat_description|default:'' != ''}>
    <{$cat_description}>
    <{/if}> @@ -21,18 +21,18 @@
    - <{if $category.image != ""}> - <{$category.title}> + <{if $category.image|default:'' != ''}> + <{$category.title}> <{/if}> <{$category.description_main}>
    - <{if $category.subcategories != ""}> + <{if $category.subcategories|default:'' != ''}>
    <{$smarty.const._MD_TDMDOWNLOADS_INDEX_SCAT}>
      <{$category.subcategories}>
    @@ -51,7 +51,7 @@
    - <{$smarty.const._MD_TDMDOWNLOADS_RSS}> + <{$smarty.const._MD_TDMDOWNLOADS_RSS}>
    <{if $bl_affichage==1}> @@ -59,43 +59,43 @@
    <{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLNAME}>
    - <{if $bl_date != ""}> + <{if $bl_date|default:'' != ''}> <{/if}> - <{if $bl_pop != ""}> + <{if $bl_pop|default:'' != ''}> <{/if}> - <{if $bl_rating != ""}> + <{if $bl_rating|default:'' != ''}>
    - <{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLDATE}><{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLDATE}> + <{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLDATE}><{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLDATE}>
    - <{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLPOP}><{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLPOP}> + <{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLPOP}><{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLPOP}>
    - <{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLRATING}><{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLRATING}> + <{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLRATING}><{$smarty.const._MD_TDMDOWNLOADS_INDEX_BLRATING}>
    @@ -134,38 +134,38 @@ <{$smarty.const._MD_TDMDOWNLOADS_CAT_SORTBY}> <{$smarty.const._MD_TDMDOWNLOADS_CAT_TITLE}> ( - - <{$smarty.const._MD_TDMDOWNLOADS_CAT_TITLEATOZ}> + + <{$smarty.const._MD_TDMDOWNLOADS_CAT_TITLEATOZ}> - - <{$smarty.const._MD_TDMDOWNLOADS_CAT_TITLEZTOA}> + + <{$smarty.const._MD_TDMDOWNLOADS_CAT_TITLEZTOA}> ) <{$smarty.const._MD_TDMDOWNLOADS_CAT_DATE}>( - - <{$smarty.const._MD_TDMDOWNLOADS_CAT_DATEOLD}> + + <{$smarty.const._MD_TDMDOWNLOADS_CAT_DATEOLD}> - - <{$smarty.const._MD_TDMDOWNLOADS_CAT_DATENEW}> + + <{$smarty.const._MD_TDMDOWNLOADS_CAT_DATENEW}> ) <{$smarty.const._MD_TDMDOWNLOADS_CAT_RATING}>( - - <{$smarty.const._MD_TDMDOWNLOADS_CAT_RATINGLTOH}> + + <{$smarty.const._MD_TDMDOWNLOADS_CAT_RATINGLTOH}> - - <{$smarty.const._MD_TDMDOWNLOADS_CAT_RATINGHTOL}> + + <{$smarty.const._MD_TDMDOWNLOADS_CAT_RATINGHTOL}> ) <{$smarty.const._MD_TDMDOWNLOADS_CAT_POPULARITY}>( - - <{$smarty.const._MD_TDMDOWNLOADS_CAT_POPULARITYLTOM}> + + <{$smarty.const._MD_TDMDOWNLOADS_CAT_POPULARITYLTOM}> - - <{$smarty.const._MD_TDMDOWNLOADS_CAT_POPULARITYMTOL}> + + <{$smarty.const._MD_TDMDOWNLOADS_CAT_POPULARITYMTOL}> ) @@ -174,7 +174,7 @@ <{/if}> - <{if $file != ""}> + <{if $file|default:'' != ''}>
    <{$smarty.const._MD_TDMDOWNLOADS_CAT_LIST}>
    @@ -192,7 +192,7 @@
    - <{if $pagenav != ''}> + <{if $pagenav|default:'' != ''}>
    <{$pagenav}>
    <{/if}> diff --git a/visit.php b/visit.php index 1bfcd55..09b4169 100644 --- a/visit.php +++ b/visit.php @@ -16,11 +16,11 @@ */ use XoopsModules\Tdmdownloads\Helper; +/** @var Helper $helper */ error_reporting(0); require __DIR__ . '/header.php'; -/** @var \XoopsModules\Tdmdownloads\Helper $helper */ $helper = Helper::getInstance(); $lid = \Xmf\Request::getInt('lid', 0, 'REQUEST'); diff --git a/xoops_version.php b/xoops_version.php index ee38dff..b8b3900 100644 --- a/xoops_version.php +++ b/xoops_version.php @@ -759,7 +759,7 @@ 'description' => '', 'formtype' => 'textbox', 'valuetype' => 'text', - 'default' => '/modules/tdmdownloads/assets/images/mydl_slogo.png', + 'default' => '/modules/' . $moduleDirName . '/assets/images/mydl_slogo.png', ]; $modversion['config'][] = [ From f9e092dcfb13b88dd9579197c85542c39a5596a6 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Wed, 27 Oct 2021 03:34:53 -0400 Subject: [PATCH 59/62] cosmetics --- .scrutinizer.yml | 2 ++ README.md | 1 - admin/blockform.php | 2 +- admin/blocksadmin.php | 10 +++++----- admin/index.php | 4 ++-- admin/menu.php | 2 +- class/Common/VersionChecks.php | 4 ++-- config/config.php | 2 +- config/icons.php | 4 ++-- config/imageconfig.php | 2 +- config/paths.php | 4 ++-- header.php | 5 ++--- include/common.php | 6 +++--- include/onupdate.php | 4 ++-- language/english/common.php | 2 +- language/english/help/disclaimer.tpl | 12 ++++++------ language/french/common.php | 2 +- language/french/help/disclaimer.tpl | 12 ++++++------ language/german/common.php | 2 +- singlefile.php | 2 +- templates/admin/tdmdownloads_admin_downloads.tpl | 4 ++-- testdata/index.php | 6 +++--- upload.php | 5 +++-- 23 files changed, 50 insertions(+), 49 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index d758d13..40b69d7 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,5 +1,7 @@ # language: php build: + environment: + php: 8.0.11 nodes: tests: true analysis: diff --git a/README.md b/README.md index 57f63f4..355093c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/XoopsModules25x/tdmdownloads.svg?style=flat)](https://scrutinizer-ci.com/g/XoopsModules25x/tdmdownloads/?branch=master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/95b12220e0ac4056b9af52af708379c9)](https://www.codacy.com/app/mambax7/tdmdownloads_2) [![Code Climate](https://img.shields.io/codeclimate/github/XoopsModules25x/tdmdownloads.svg?style=flat)](https://codeclimate.com/github/mambax7/tdmdownloads) -[![SensioLabsInsight](https://insight.sensiolabs.com/projects/68207475-07ff-4567-a282-6e2f119077d2/mini.png)](https://insight.sensiolabs.com/projects/68207475-07ff-4567-a282-6e2f119077d2) [![Latest Pre-Release](https://img.shields.io/github/tag/XoopsModules25x/tdmdownloads.svg?style=flat)](https://github.com/XoopsModules25x/tdmdownloads/tags/) [![Latest Version](https://img.shields.io/github/release/XoopsModules25x/tdmdownloads.svg?style=flat)](https://github.com/XoopsModules25x/tdmdownloads/releases/) diff --git a/admin/blockform.php b/admin/blockform.php index 408bda6..6d8015e 100644 --- a/admin/blockform.php +++ b/admin/blockform.php @@ -16,7 +16,7 @@ require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; $moduleDirName = basename(dirname(__DIR__)); -$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName +$moduleDirNameUpper = \mb_strtoupper($moduleDirName); //$capsDirName $form = new \XoopsThemeForm($block['form_title'], 'blockform', 'blocksadmin.php', 'post', true); if (isset($block['name'])) { diff --git a/admin/blocksadmin.php b/admin/blocksadmin.php index a3e6f9b..7b5717f 100644 --- a/admin/blocksadmin.php +++ b/admin/blocksadmin.php @@ -19,7 +19,7 @@ require __DIR__ . '/admin_header.php'; $moduleDirName = basename(dirname(__DIR__)); -$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName +$moduleDirNameUpper = \mb_strtoupper($moduleDirName); //$capsDirName if (!is_object($xoopsModule) || !is_object($GLOBALS['xoopsUser']) || !$GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) { @@ -61,7 +61,7 @@ function listBlocks() $moduleDirName = basename(dirname(__DIR__)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); //$capsDirName /** @var \XoopsMySQLDatabase $db */ @@ -350,7 +350,7 @@ function cloneBlock($bid) $moduleDirName = basename(dirname(__DIR__)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); //$capsDirName xoops_loadLanguage('admin', 'system'); @@ -569,7 +569,7 @@ function editBlock($bid) $moduleDirName = basename(dirname(__DIR__)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); //$capsDirName xoops_loadLanguage('admin', 'system'); @@ -647,7 +647,7 @@ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $b { $moduleDirName = basename(dirname(__DIR__)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); //$capsDirName $myblock = new \XoopsBlock($bid); diff --git a/admin/index.php b/admin/index.php index 5fb5da4..bb71725 100644 --- a/admin/index.php +++ b/admin/index.php @@ -32,7 +32,7 @@ xoops_cp_header(); $moduleDirName = basename(dirname(__DIR__)); -$moduleDirNameUpper = mb_strtoupper($moduleDirName); +$moduleDirNameUpper = \mb_strtoupper($moduleDirName); // Template Index $templateMain = 'tdmdownloads_admin_index.tpl'; @@ -105,7 +105,7 @@ //check for latest release //$newRelease = $utility->checkVerModule($helper); -//if (!empty($newRelease)) { +//if (null !== $newRelease) { // $adminObject->addItemButton($newRelease[0], $newRelease[1], 'download', 'style="color : Red"'); //} diff --git a/admin/menu.php b/admin/menu.php index 6dff328..e0ef1f9 100644 --- a/admin/menu.php +++ b/admin/menu.php @@ -21,7 +21,7 @@ require dirname(__DIR__) . '/preloads/autoloader.php'; $moduleDirName = basename(dirname(__DIR__)); -$moduleDirNameUpper = mb_strtoupper($moduleDirName); +$moduleDirNameUpper = \mb_strtoupper($moduleDirName); /** @var \XoopsModules\Tdmdownloads\Helper $helper */ $helper = Helper::getInstance(); diff --git a/class/Common/VersionChecks.php b/class/Common/VersionChecks.php index 0aa73b5..b333266 100644 --- a/class/Common/VersionChecks.php +++ b/class/Common/VersionChecks.php @@ -97,7 +97,7 @@ public static function checkVerPhp(?\XoopsModule $module = null) } /** - * compares current module version with latest GitHub release + * compares current module version with the latest GitHub release * @static * @param \Xmf\Module\Helper $helper * @param string|null $source @@ -105,7 +105,7 @@ public static function checkVerPhp(?\XoopsModule $module = null) * * @return string|array info about the latest module version, if newer */ - public static function checkVerModule($helper, $source = 'github', $default = 'master') + public static function checkVerModule(\Xmf\Module\Helper $helper, ?string $source = 'github', ?string $default = 'master'): ?array { $moduleDirName = \basename(dirname(__DIR__, 2)); diff --git a/config/config.php b/config/config.php index edf7544..5354180 100644 --- a/config/config.php +++ b/config/config.php @@ -20,7 +20,7 @@ use Xmf\Module\Admin; $moduleDirName = \basename(\dirname(__DIR__)); -$moduleDirNameUpper = mb_strtoupper($moduleDirName); +$moduleDirNameUpper = \mb_strtoupper($moduleDirName); return (object)[ 'name' => $moduleDirNameUpper . ' Module Configurator', diff --git a/config/icons.php b/config/icons.php index eaa9f00..18e3e31 100644 --- a/config/icons.php +++ b/config/icons.php @@ -2,11 +2,11 @@ use Xmf\Module\Admin; -$pathIcon16 = Admin::iconUrl('', 16); +$pathIcon16 = Admin::iconUrl('', '16'); $moduleDirName = basename(dirname(__DIR__)); return (object)[ - 'name' => mb_strtoupper($moduleDirName) . ' IconConfigurator', + 'name' => \mb_strtoupper($moduleDirName) . ' IconConfigurator', 'icons' => [ 'edit' => " . _EDIT . ", 'delete' => "" . _DELETE . "", diff --git a/config/imageconfig.php b/config/imageconfig.php index 21f22bd..be14c9b 100644 --- a/config/imageconfig.php +++ b/config/imageconfig.php @@ -3,7 +3,7 @@ use XoopsModules\Tdmdownloads\Helper; $moduleDirName = basename(dirname(__DIR__)); -$moduleDirNameUpper = mb_strtoupper($moduleDirName); +$moduleDirNameUpper = \mb_strtoupper($moduleDirName); /** @var \XoopsModules\Tdmdownloads\Helper $helper */ $helper = Helper::getInstance(); diff --git a/config/paths.php b/config/paths.php index 8c9fb4e..0e7656e 100644 --- a/config/paths.php +++ b/config/paths.php @@ -2,10 +2,10 @@ /** @return object */ $moduleDirName = basename(dirname(__DIR__)); -$moduleDirNameUpper = mb_strtoupper($moduleDirName); +$moduleDirNameUpper = \mb_strtoupper($moduleDirName); return [ - 'name' => mb_strtoupper($moduleDirName) . ' PathConfigurator', + 'name' => \mb_strtoupper($moduleDirName) . ' PathConfigurator', 'dirname' => $moduleDirName, 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin', 'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName, diff --git a/header.php b/header.php index 4770d14..aa1e4bc 100644 --- a/header.php +++ b/header.php @@ -20,15 +20,14 @@ Utility }; use Xmf\Module\Helper\Permission; - +/** @var \Xmf\Module\Helper\Permission $permHelper */ /** @var Helper $helper */ /** @var Utility $utility */ - require dirname(__DIR__, 2) . '/mainfile.php'; $moduleDirName = basename(__DIR__); -$moduleDirNameUpper = mb_strtoupper($moduleDirName); +$moduleDirNameUpper = \mb_strtoupper($moduleDirName); //require_once XOOPS_ROOT_PATH.'/class/pagenav.php'; //require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; diff --git a/include/common.php b/include/common.php index bfe04ea..fad9f6c 100644 --- a/include/common.php +++ b/include/common.php @@ -26,7 +26,7 @@ require dirname(__DIR__) . '/preloads/autoloader.php'; $moduleDirName = basename(dirname(__DIR__)); -$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName +$moduleDirNameUpper = \mb_strtoupper($moduleDirName); //$capsDirName /** @var \XoopsDatabase $db */ /** @var \XoopsModules\Tdmdownloads\Helper $helper */ @@ -51,8 +51,8 @@ $modifiedHandler = Helper::getInstance()->getHandler('Modified'); $modifieddataHandler = Helper::getInstance()->getHandler('Modifiedfielddata'); -$pathIcon16 = Admin::iconUrl('', 16); -$pathIcon32 = Admin::iconUrl('', 32); +$pathIcon16 = Admin::iconUrl('', '16'); +$pathIcon32 = Admin::iconUrl('', '32'); if (!defined($moduleDirNameUpper . '_CONSTANTS_DEFINED')) { define($moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__))); diff --git a/include/onupdate.php b/include/onupdate.php index d2263e0..89b30f7 100644 --- a/include/onupdate.php +++ b/include/onupdate.php @@ -72,7 +72,7 @@ function xoops_module_update_tdmdownloads(&$module, $prev_version = null) $ret = null; $moduleDirName = \basename(\dirname(__DIR__)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); $helper = Helper::getInstance(); $utility = new Utility(); @@ -113,7 +113,7 @@ function xoops_module_update_tdmdownloads(&$module, $prev_version = null) function update_tdmdownloads_v201(&$module) { $moduleDirName = \basename(\dirname(__DIR__)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); $helper = Helper::getInstance(); $utility = new Utility(); diff --git a/language/english/common.php b/language/english/common.php index ccabadf..f541fac 100644 --- a/language/english/common.php +++ b/language/english/common.php @@ -20,7 +20,7 @@ * @author Xoops Development Team */ $moduleDirName = basename(dirname(__DIR__, 2)); -$moduleDirNameUpper = mb_strtoupper($moduleDirName); +$moduleDirNameUpper = \mb_strtoupper($moduleDirName); \define('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS', 'GD library support: '); \define('CO_' . $moduleDirNameUpper . '_GDLIBVERSION', 'GD Library version: '); diff --git a/language/english/help/disclaimer.tpl b/language/english/help/disclaimer.tpl index 5df7a0c..d74e9ac 100644 --- a/language/english/help/disclaimer.tpl +++ b/language/english/help/disclaimer.tpl @@ -3,7 +3,7 @@

    DISCLAIMER


    -

    Software downloaded from the XOOPS web site is provided 'as is' without warranty +

    Software downloaded from the XOOPS website is provided 'as is' without warranty of any kind, either express or implied, including, but not limited to, the implied warranties of fitness for a purpose, or the warranty of non-infringement. Without limiting the foregoing, XOOPS Projects team makes no warranty that:

    @@ -15,21 +15,21 @@ accurate or reliable
  • the quality of the software will meet your expectations any errors in the - software obtained from XOOPS web site will be corrected. + software obtained from XOOPS website will be corrected.

  • -

    Software and its documentation made available on the XOOPS web site:

    +

    Software and its documentation made available on the XOOPS website:


    1. could include technical or other mistakes, inaccuracies or typographical errors. XOOPS may make changes to the software or documentation made available - on its web site. + on its website.
    2. may be out of date, and XOOPS makes no commitment to update such materials.
    3. XOOPS assumes no responsibility for errors or omissions in the software - or documentation available from its web site. + or documentation available from its website.


    In no event shall XOOPS team be liable to you or any third parties for @@ -43,6 +43,6 @@ and risk and with agreement that you will be solely responsible for any damage to your computer system or loss of data that results from such activities. No advice or information, whether oral or written, obtained by you from XOOPS or from XOOPS - web site shall create any warranty for the software

    + website shall create any warranty for the software

    diff --git a/language/french/common.php b/language/french/common.php index 343408a..c8f47c5 100644 --- a/language/french/common.php +++ b/language/french/common.php @@ -20,7 +20,7 @@ * @author Xoops Development Team */ $moduleDirName = basename(dirname(__DIR__, 2)); -$moduleDirNameUpper = mb_strtoupper($moduleDirName); +$moduleDirNameUpper = \mb_strtoupper($moduleDirName); define('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS', 'GD library support: '); define('CO_' . $moduleDirNameUpper . '_GDLIBVERSION', 'GD Library version: '); diff --git a/language/french/help/disclaimer.tpl b/language/french/help/disclaimer.tpl index 5df7a0c..d74e9ac 100644 --- a/language/french/help/disclaimer.tpl +++ b/language/french/help/disclaimer.tpl @@ -3,7 +3,7 @@

    DISCLAIMER


    -

    Software downloaded from the XOOPS web site is provided 'as is' without warranty +

    Software downloaded from the XOOPS website is provided 'as is' without warranty of any kind, either express or implied, including, but not limited to, the implied warranties of fitness for a purpose, or the warranty of non-infringement. Without limiting the foregoing, XOOPS Projects team makes no warranty that:

    @@ -15,21 +15,21 @@ accurate or reliable
  • the quality of the software will meet your expectations any errors in the - software obtained from XOOPS web site will be corrected. + software obtained from XOOPS website will be corrected.

  • -

    Software and its documentation made available on the XOOPS web site:

    +

    Software and its documentation made available on the XOOPS website:


    1. could include technical or other mistakes, inaccuracies or typographical errors. XOOPS may make changes to the software or documentation made available - on its web site. + on its website.
    2. may be out of date, and XOOPS makes no commitment to update such materials.
    3. XOOPS assumes no responsibility for errors or omissions in the software - or documentation available from its web site. + or documentation available from its website.


    In no event shall XOOPS team be liable to you or any third parties for @@ -43,6 +43,6 @@ and risk and with agreement that you will be solely responsible for any damage to your computer system or loss of data that results from such activities. No advice or information, whether oral or written, obtained by you from XOOPS or from XOOPS - web site shall create any warranty for the software

    + website shall create any warranty for the software

    diff --git a/language/german/common.php b/language/german/common.php index 9460d22..630f17b 100644 --- a/language/german/common.php +++ b/language/german/common.php @@ -20,7 +20,7 @@ * @author Xoops Development Team */ $moduleDirName = basename(dirname(__DIR__, 2)); -$moduleDirNameUpper = mb_strtoupper($moduleDirName); +$moduleDirNameUpper = \mb_strtoupper($moduleDirName); define('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS', 'GD library support: '); define('CO_' . $moduleDirNameUpper . '_GDLIBVERSION', 'GD Library version: '); diff --git a/singlefile.php b/singlefile.php index 6089795..590f533 100644 --- a/singlefile.php +++ b/singlefile.php @@ -150,7 +150,7 @@ */ function getXfieldKey($k) { - return mb_strtolower( + return \mb_strtolower( str_replace( ['Ü', 'ü', 'Ş', 'ş', 'I', 'ı', 'Ç', 'ç', 'Ğ', 'ğ', 'Ö', 'ö'], ['u', 'u', 's', 's', 'i', 'i', 'c', 'c', 'g', 'g', 'o', 'o'], diff --git a/templates/admin/tdmdownloads_admin_downloads.tpl b/templates/admin/tdmdownloads_admin_downloads.tpl index b49a1f5..5635d35 100644 --- a/templates/admin/tdmdownloads_admin_downloads.tpl +++ b/templates/admin/tdmdownloads_admin_downloads.tpl @@ -7,12 +7,12 @@
    - <{$selectDocument}> <{$selectOrder}> + <{$selectDocument|default:''}> <{$selectOrder|default:''}>
    -<{if $downloads_list}> +<{if $downloads_list|default:''}> diff --git a/testdata/index.php b/testdata/index.php index b0c5af4..4149986 100644 --- a/testdata/index.php +++ b/testdata/index.php @@ -107,7 +107,7 @@ function saveSampleData() { global $xoopsConfig; $moduleDirName = \basename(\dirname(__DIR__)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); $helper = Helper::getInstance(); $tables = $helper->getModule()->getInfo('tables'); @@ -136,7 +136,7 @@ function saveSampleData() function exportSchema() { $moduleDirName = \basename(\dirname(__DIR__)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); try { // TODO set exportSchema @@ -208,7 +208,7 @@ function loadTableFromArrayWithReplace($table, $data, $search, $replace) function clearSampleData() { $moduleDirName = \basename(\dirname(__DIR__)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); $helper = Helper::getInstance(); // Load language files $helper->loadLanguage('common'); diff --git a/upload.php b/upload.php index 4eb98f7..7a3bc9c 100644 --- a/upload.php +++ b/upload.php @@ -25,11 +25,12 @@ CategoryHandler, Form\UploadForm }; +/** @var \Xmf\Module\Helper\Permission $permHelper */ require_once __DIR__ . '/header.php'; $moduleDirName = basename(__DIR__); -$moduleDirNameUpper = mb_strtoupper($moduleDirName); +$moduleDirNameUpper = \mb_strtoupper($moduleDirName); // It recovered the value of argument op in URL$ $op = Request::getString('op', 'form'); @@ -38,7 +39,7 @@ $GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_upload.tpl'; require_once XOOPS_ROOT_PATH . '/header.php'; -$pathIcon16 = Admin::iconUrl('', 16); +$pathIcon16 = Admin::iconUrl('', '16'); $GLOBALS['xoopsTpl']->assign('pathIcon16', $pathIcon16); $categoryHandler = new CategoryHandler(); From 9385e11bfc0849c86485196364d1d4914bb20207 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Wed, 27 Oct 2021 03:35:33 -0400 Subject: [PATCH 60/62] trigger_error() --- class/Common/SysUtility.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/class/Common/SysUtility.php b/class/Common/SysUtility.php index 8a67423..9ca2ced 100644 --- a/class/Common/SysUtility.php +++ b/class/Common/SysUtility.php @@ -155,7 +155,7 @@ public static function enumerate(string $tableName, string $columnName) $sql = 'SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = "' . $table . '" AND COLUMN_NAME = "' . $columnName . '"'; $result = $GLOBALS['xoopsDB']->query($sql); if (!$result) { - // exit($GLOBALS['xoopsDB']->error()); + // trigger_error($GLOBALS['xoopsDB']->error()); $logger = \XoopsLogger::getInstance(); $logger->handleError(\E_USER_WARNING, $sql, __FILE__, __LINE__); return false; @@ -186,7 +186,7 @@ public static function cloneRecord(string $tableName, string $idField, int $id) $sql = "SELECT * FROM $table WHERE $idField='" . (int)$id . "' "; $tempTable = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql), \MYSQLI_ASSOC); if (!$tempTable) { - exit($GLOBALS['xoopsDB']->error()); + trigger_error($GLOBALS['xoopsDB']->error()); } // set the auto-incremented id's value to blank. unset($tempTable[$idField]); @@ -194,7 +194,7 @@ public static function cloneRecord(string $tableName, string $idField, int $id) $sql = "INSERT INTO $table (" . \implode(', ', \array_keys($tempTable)) . ") VALUES ('" . \implode("', '", \array_values($tempTable)) . "')"; $result = $GLOBALS['xoopsDB']->queryF($sql); if (!$result) { - exit($GLOBALS['xoopsDB']->error()); + trigger_error($GLOBALS['xoopsDB']->error()); } // Return the new id return $GLOBALS['xoopsDB']->getInsertId(); From 8033bfa1e19e6bc1cfdb8dd16093135fbdec88f9 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Wed, 27 Oct 2021 03:36:53 -0400 Subject: [PATCH 61/62] implode() requires an array --- admin/downloads.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/admin/downloads.php b/admin/downloads.php index c91ab5f..0a1c2c2 100644 --- a/admin/downloads.php +++ b/admin/downloads.php @@ -39,6 +39,7 @@ //On recupere la valeur de l'argument op dans l'URL$ $op = \Xmf\Request::getCmd('op', 'list'); +$catId = \Xmf\Request::getInt('cat_cid', 0); // compte le nombre de téléchargement non validé $criteria = new \CriteriaCompo(); @@ -653,7 +654,7 @@ $obj->setVar('version', \Xmf\Request::getString('version', '', 'POST')); $obj->setVar('paypal', \Xmf\Request::getString('paypal', '', 'POST')); if (\Xmf\Request::hasVar('platform', 'POST')) { - $obj->setVar('platform', implode('|', \Xmf\Request::getString('platform', '', 'POST'))); + $obj->setVar('platform', implode('|', \Xmf\Request::getArray('platform', [], 'POST'))); } $obj->setVar('description', \Xmf\Request::getString('description', '', 'POST')); From 5c5ecb7b39e5de37c0ac67f5deff4355153b699d Mon Sep 17 00:00:00 2001 From: mambax7 Date: Wed, 27 Oct 2021 04:05:50 -0400 Subject: [PATCH 62/62] fix for File Size admin message showing up for users --- admin/downloads.php | 2 +- admin/modified.php | 2 +- class/Downloads.php | 2 +- class/Modified.php | 2 +- language/english/admin.php | 3 ++- language/french/admin.php | 3 ++- language/german/admin.php | 4 ++-- 7 files changed, 10 insertions(+), 8 deletions(-) diff --git a/admin/downloads.php b/admin/downloads.php index 0a1c2c2..4f73344 100644 --- a/admin/downloads.php +++ b/admin/downloads.php @@ -475,7 +475,7 @@ //taille du fichier if ('' !== $viewDownloads->getVar('size')) { - $fieldsList[] = ['name' => _AM_TDMDOWNLOADS_FORMSIZE, 'value' => $viewDownloads->getVar('size')]; + $fieldsList[] = ['name' => _AM_TDMDOWNLOADS_FORMSIZE_WHEN_SUBMIT, 'value' => $viewDownloads->getVar('size')]; } } diff --git a/admin/modified.php b/admin/modified.php index 8e66d55..c0f8b38 100644 --- a/admin/modified.php +++ b/admin/modified.php @@ -165,7 +165,7 @@ if (3 == $downloads_field[$i]->getVar('fid')) { //taille du fichier - $compare['cfields'][] = ['info' => _AM_TDMDOWNLOADS_FORMSIZE, 'current' => $downloads_size, 'modified' => $moddownloads_size]; + $compare['cfields'][] = ['info' => _AM_TDMDOWNLOADS_FORMSIZE_WHEN_SUBMIT, 'current' => $downloads_size, 'modified' => $moddownloads_size]; } if (4 == $downloads_field[$i]->getVar('fid')) { diff --git a/class/Downloads.php b/class/Downloads.php index 1976e59..34c687a 100644 --- a/class/Downloads.php +++ b/class/Downloads.php @@ -245,7 +245,7 @@ public function getForm($donnee = [], $erreur = false, $action = false) if (1 == $downloads_field[$i]->getVar('status')) { $size_value_arr = \explode(' ', $this->getVar('size')); - $aff_size = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMSIZE, ''); + $aff_size = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMSIZE_WHEN_SUBMIT, ''); $aff_size->addElement(new \XoopsFormText('', 'sizeValue', 13, 13, $size_value_arr[0])); diff --git a/class/Modified.php b/class/Modified.php index 6541d50..7d637a2 100644 --- a/class/Modified.php +++ b/class/Modified.php @@ -251,7 +251,7 @@ public function getForm($lid, $erreur, $donnee = [], $action = false) if (1 == $downloads_field[$i]->getVar('status')) { $size_value_arr = \explode(' ', $viewDownloads->getVar('size')); - $aff_size = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMSIZE, ''); + $aff_size = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMSIZE_WHEN_SUBMIT, ''); $aff_size->addElement(new \XoopsFormText('', 'sizeValue', 13, 13, $size_value_arr[0])); diff --git a/language/english/admin.php b/language/english/admin.php index 8d2b123..c67db94 100644 --- a/language/english/admin.php +++ b/language/english/admin.php @@ -124,7 +124,8 @@ define('_AM_TDMDOWNLOADS_FORMPLATFORM', 'Platform: '); define('_AM_TDMDOWNLOADS_FORMPOSTER', 'Posted by '); define('_AM_TDMDOWNLOADS_FORMRATING', 'Note'); -define('_AM_TDMDOWNLOADS_FORMSIZE', "File Size
    To use the automatic system for calculating the file size, leave this field empty."); +define('_AM_TDMDOWNLOADS_FORMSIZE', "File Size"); +define('_AM_TDMDOWNLOADS_FORMSIZE_WHEN_SUBMIT', "File Size
    To use the automatic system for calculating the file size, leave this field empty."); define('_AM_TDMDOWNLOADS_FORMSTATUS', 'Download Status'); define('_AM_TDMDOWNLOADS_FORMSTATUS_OK', 'Approved'); define('_AM_TDMDOWNLOADS_FORMSUBMITTER', 'Posted by'); diff --git a/language/french/admin.php b/language/french/admin.php index 985d063..2efdcd6 100644 --- a/language/french/admin.php +++ b/language/french/admin.php @@ -124,7 +124,8 @@ define('_AM_TDMDOWNLOADS_FORMPLATFORM', 'Plateforme :'); define('_AM_TDMDOWNLOADS_FORMPOSTER', 'Posté par '); define('_AM_TDMDOWNLOADS_FORMRATING', 'Note'); -define('_AM_TDMDOWNLOADS_FORMSIZE', "Taille du fichier
    Pour utiliser le système automatique de calcul de la taille du fichier, laissez ce champ vide."); +define('_AM_TDMDOWNLOADS_FORMSIZE', "Taille du fichier"); +define('_AM_TDMDOWNLOADS_FORMSIZE_WHEN_SUBMIT', "Taille du fichier
    Pour utiliser le système automatique de calcul de la taille du fichier, laissez ce champ vide."); define('_AM_TDMDOWNLOADS_FORMSTATUS', 'État du téléchargement'); define('_AM_TDMDOWNLOADS_FORMSTATUS_OK', 'Approuvé'); define('_AM_TDMDOWNLOADS_FORMSUBMITTER', 'Posté par'); diff --git a/language/german/admin.php b/language/german/admin.php index 45b4949..96e3d5a 100644 --- a/language/german/admin.php +++ b/language/german/admin.php @@ -124,8 +124,8 @@ define('_AM_TDMDOWNLOADS_FORMPLATFORM', 'Plattform: '); define('_AM_TDMDOWNLOADS_FORMPOSTER', 'Eingesendet von '); define('_AM_TDMDOWNLOADS_FORMRATING', 'Bewertung'); -//define('_AM_TDMDOWNLOADS_FORMSIZE', 'Dateigröße'); -define('_AM_TDMDOWNLOADS_FORMSIZE', "Dateigröße
    Um das automatische System zur Berechnung der Dateigröße zu verwenden, lassen Sie dieses Feld leer."); +define('_AM_TDMDOWNLOADS_FORMSIZE', 'Dateigröße'); +define('_AM_TDMDOWNLOADS_FORMSIZE_WHEN_SUBMIT', "Dateigröße
    Um das automatische System zur Berechnung der Dateigröße zu verwenden, lassen Sie dieses Feld leer."); define('_AM_TDMDOWNLOADS_FORMSTATUS', 'Download Status'); define('_AM_TDMDOWNLOADS_FORMSTATUS_OK', 'Bestätigt'); define('_AM_TDMDOWNLOADS_FORMSUBMITTER', 'Eingesendet von');