Skip to content

Commit 756ad9d

Browse files
authored
Merge pull request #12 from mambax7/master
Remove pass-by-reference instances
2 parents 6c02fc6 + 94fc393 commit 756ad9d

7 files changed

Lines changed: 152 additions & 444 deletions

File tree

LICENSE

Lines changed: 0 additions & 339 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/0fdcfa1725a14753865921b99bb3611e)](https://www.codacy.com/app/mambax7/tag_2)
66
[![Code Climate](https://img.shields.io/codeclimate/github/XoopsModules25x/tag.svg?style=flat)](https://codeclimate.com/github/XoopsModules25x/tag)
77
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/0ffc2915-82a8-446a-978e-df50e2e58858/mini.png)](https://insight.sensiolabs.com/projects/0ffc2915-82a8-446a-978e-df50e2e58858)
8-
[![Latest Pre-Resease](https://img.shields.io/github/tag/XoopsModules25x/tag.svg?style=flat)](https://github.com/XoopsModules25x/tag/tags/)
8+
[![Latest Pre-Release](https://img.shields.io/github/tag/XoopsModules25x/tag.svg?style=flat)](https://github.com/XoopsModules25x/tag/tags/)
99
[![Latest Version](https://img.shields.io/github/release/XoopsModules25x/tag.svg?style=flat)](https://github.com/XoopsModules25x/tag/releases/)
1010

1111
Tag module for [XOOPS CMS](http://xoops.org) is designed for site-wide tag management, handling tag input, display and stats for each module that enables tag plugin.
@@ -18,5 +18,3 @@ To contribute to the Tutorial, [fork it on GitHub](https://github.com/XoopsDocs/
1818
Please visit us on http://xoops.org
1919

2020
The upcoming "next generation" version of XOOPS CMS is being crafted on GitHub at: https://github.com/XOOPS
21-
22-
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/0fdcfa1725a14753865921b99bb3611e)](https://www.codacy.com/app/mambax7/tag_2?utm_source=github.com&utm_medium=referral&utm_content=XoopsModules25x/tag&utm_campaign=Badge_Grade)

admin/about.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@
2727
$aboutAdmin = new ModuleAdmin();
2828

2929
echo $aboutAdmin->addNavigation(basename(__FILE__));
30-
echo $aboutAdmin->renderAbout('6KJ7RW5DR3VTJ', false);
30+
echo $aboutAdmin->renderAbout('xoopsfoundation@gmail.com', false);
3131

3232
include __DIR__ . '/admin_footer.php';

class/utilities.php

Lines changed: 0 additions & 97 deletions
This file was deleted.

class/utility.php

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
<?php
2+
3+
/**
4+
* Class MyalbumUtil
5+
*/
6+
class TagUtility extends XoopsObject
7+
{
8+
/**
9+
* Function responsible for checking if a directory exists, we can also write in and create an index.html file
10+
*
11+
* @param string $folder The full path of the directory to check
12+
*
13+
* @return void
14+
*/
15+
public static function createFolder($folder)
16+
{
17+
// try {
18+
// if (!mkdir($folder) && !is_dir($folder)) {
19+
// throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder));
20+
// } else {
21+
// file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>');
22+
// }
23+
// }
24+
// catch (Exception $e) {
25+
// echo 'Caught exception: ', $e->getMessage(), "\n", '<br/>';
26+
// }
27+
try {
28+
if (!file_exists($folder)) {
29+
if (!mkdir($folder) && !is_dir($folder)) {
30+
throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder));
31+
} else {
32+
file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>');
33+
}
34+
}
35+
} catch (Exception $e) {
36+
echo 'Caught exception: ', $e->getMessage(), "\n", '<br/>';
37+
}
38+
}
39+
40+
/**
41+
* @param $file
42+
* @param $folder
43+
* @return bool
44+
*/
45+
public static function copyFile($file, $folder)
46+
{
47+
return copy($file, $folder);
48+
// try {
49+
// if (!is_dir($folder)) {
50+
// throw new \RuntimeException(sprintf('Unable to copy file as: %s ', $folder));
51+
// } else {
52+
// return copy($file, $folder);
53+
// }
54+
// } catch (Exception $e) {
55+
// echo 'Caught exception: ', $e->getMessage(), "\n", "<br/>";
56+
// }
57+
// return false;
58+
}
59+
60+
/**
61+
* @param $src
62+
* @param $dst
63+
*/
64+
public static function recurseCopy($src, $dst)
65+
{
66+
$dir = opendir($src);
67+
// @mkdir($dst);
68+
while (false !== ($file = readdir($dir))) {
69+
if (($file !== '.') && ($file !== '..')) {
70+
if (is_dir($src . '/' . $file)) {
71+
self::recurseCopy($src . '/' . $file, $dst . '/' . $file);
72+
} else {
73+
copy($src . '/' . $file, $dst . '/' . $file);
74+
}
75+
}
76+
}
77+
closedir($dir);
78+
}
79+
80+
/**
81+
*
82+
* Verifies XOOPS version meets minimum requirements for this module
83+
* @static
84+
* @param XoopsModule $module
85+
*
86+
* @return bool true if meets requirements, false if not
87+
*/
88+
public static function checkVerXoops(XoopsModule $module)
89+
{
90+
xoops_loadLanguage('admin', $module->dirname());
91+
//check for minimum XOOPS version
92+
$currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string
93+
$currArray = explode('.', $currentVer);
94+
$requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string
95+
$reqArray = explode('.', $requiredVer);
96+
$success = true;
97+
foreach ($reqArray as $k => $v) {
98+
if (isset($currArray[$k])) {
99+
if ($currArray[$k] > $v) {
100+
break;
101+
} elseif ($currArray[$k] == $v) {
102+
continue;
103+
} else {
104+
$success = false;
105+
break;
106+
}
107+
} else {
108+
if ((int)$v > 0) { // handles things like x.x.x.0_RC2
109+
$success = false;
110+
break;
111+
}
112+
}
113+
}
114+
115+
if (!$success) {
116+
$module->setErrors(sprintf(_AM_XXXXX_ERROR_BAD_XOOPS, $requiredVer, $currentVer));
117+
}
118+
119+
return $success;
120+
}
121+
122+
/**
123+
*
124+
* Verifies PHP version meets minimum requirements for this module
125+
* @static
126+
* @param XoopsModule $module
127+
*
128+
* @return bool true if meets requirements, false if not
129+
*/
130+
public static function checkVerPhp(XoopsModule $module)
131+
{
132+
xoops_loadLanguage('admin', $module->dirname());
133+
// check for minimum PHP version
134+
$success = true;
135+
$verNum = phpversion();
136+
$reqVer =& $module->getInfo('min_php');
137+
if (false !== $reqVer && '' !== $reqVer) {
138+
if (version_compare($verNum, $reqVer, '<')) {
139+
$module->setErrors(sprintf(_AM_XXXXX_ERROR_BAD_PHP, $reqVer, $verNum));
140+
$success = false;
141+
}
142+
}
143+
144+
return $success;
145+
}
146+
}

sample.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656

5757
/* Step 2: add tag storage after item storage */
5858
// File: submit.item.php
59-
$tag_handler = xoops_getModuleHandler('tag', 'tag');
60-
$tag_handler->updateByItem($_POST['item_tag'], $itemid, $GLOBALS['xoopsModule']->getVar('dirname'), $catid = 0);
59+
$tagHandler = xoops_getModuleHandler('tag', 'tag');
60+
$tagHandler->updateByItem($_POST['item_tag'], $itemid, $GLOBALS['xoopsModule']->getVar('dirname'), $catid = 0);
6161

6262
/* Step 3: define functions to build info of tagged items */
6363
// File: /modules/tag/plugin/mymodule.php OR /modules/mymodule/include/plugin.tag.php
@@ -75,8 +75,8 @@ function mymodule_tag_iteminfo(&$items)
7575
$items_id[] = (int)$item_id;
7676
}
7777
}
78-
$item_handler = xoops_getModuleHandler('item', 'module');
79-
$items_obj = $item_handler->getObjects(new Criteria('itemid', '(' . implode(', ', $items_id) . ')', 'IN'), true);
78+
$itemHandler = xoops_getModuleHandler('item', 'module');
79+
$items_obj = $itemHandler->getObjects(new Criteria('itemid', '(' . implode(', ', $items_id) . ')', 'IN'), true);
8080

8181
foreach (array_keys($items) as $cat_id) {
8282
foreach (array_keys($items[$cat_id]) as $item_id) {

0 commit comments

Comments
 (0)