Skip to content

Commit

Permalink
Merge pull request #5 from zyspec/master
Browse files Browse the repository at this point in the history
Code cleanup
  • Loading branch information
mambax7 committed Oct 21, 2019
2 parents 1692982 + cd80e5a commit 1b648ee
Show file tree
Hide file tree
Showing 21 changed files with 290 additions and 406 deletions.
41 changes: 8 additions & 33 deletions add_breeder.php
Expand Up @@ -10,7 +10,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* Module: Xforms
* Module: Pedigree
*
* @package XoopsModules\Pedigree
* @author XOOPS Module Development Team
Expand Down Expand Up @@ -39,34 +39,9 @@
redirect_header('javascript:history.go(-1)', 3, _NOPERM . '<br>' . _MA_PEDIGREE_REGIST);
}

$f = Request::getString('f', '', 'GET');
$f = Request::getString('f', '', 'POST');
if ('check' === $f) {
//check for access
/*
$achternaam = Request::getString('achternaam', '', 'POST');
$voornaam = Request::getString('voornaam', '', 'POST');
$email = Request::getEmail('email', '', 'POST');
$website = Request::getUrl('website', '', 'POST');
$user = Request::getString('user', '', 'POST');
//insert into owner
//$query = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('pedigree_owner') . " VALUES ('','" . $voornaam . "','" . $achternaam . "','','','','','','" . $email . "','" . $website . "','" . $user . "')";
$query = 'INSERT INTO '
. $GLOBALS['xoopsDB']->prefix('pedigree_owner')
. " VALUES (0,'"
. $GLOBALS['xoopsDB']->escape($voornaam)
. "','"
. $GLOBALS['xoopsDB']->escape($achternaam)
. "','','','','','','"
. $GLOBALS['xoopsDB']->escape($email)
. "','"
. $GLOBALS['xoopsDB']->escape($website)
. "','"
. $GLOBALS['xoopsDB']->escape($user)
. "')";
$GLOBALS['xoopsDB']->query($query);
*/
$objVars = [
'firstname' => Request::getString('voornaam', '', 'POST'),
'lastname' => Request::getString('achternaam', '', 'POST'),
Expand All @@ -80,25 +55,25 @@
$oObj->setVars($objVars);
$ownerHandler->insert($oObj);

redirect_header($helper->url(), 3, _MA_PEDIGREE_ADDED_TO_DB);
$helper->redirect('', 3, _MA_PEDIGREE_ADDED_TO_DB);
}

//create form
include XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
$form = new \XoopsThemeForm(_MA_PEDIGREE_ADD_OWNER, 'breedername', 'add_breeder.php?f=check', 'post', true);
$form = new \XoopsThemeForm(_MA_PEDIGREE_ADD_OWNER, 'breedername', 'add_breeder.php?f=check', 'post');
$form->addElement(new \XoopsFormHiddenToken($name = 'XOOPS_TOKEN_REQUEST', $timeout = 360));
$form->addElement(new \XoopsFormHidden('user', $GLOBALS['xoopsUser']->getVar('uid')));
//lastname
$form->addElement(new \XoopsFormText('<b>' . _MA_PEDIGREE_FLD_OWN_LNAME . '</b>', 'achternaam', $size = 50, $maxsize = 255, $value = ''));
$form->addElement(new \XoopsFormText('<b>' . _MA_PEDIGREE_FLD_OWN_LNAME . '</b>', 'achternaam', $size = 30, $maxsize = 30, $value = ''));

//firstname
$form->addElement(new \XoopsFormText('<b>' . _MA_PEDIGREE_FLD_OWN_FNAME . '</b>', 'voornaam', $size = 50, $maxsize = 255, $value = ''));
$form->addElement(new \XoopsFormText('<b>' . _MA_PEDIGREE_FLD_OWN_FNAME . '</b>', 'voornaam', $size = 3050, $maxsize = 30, $value = ''));

//email
$form->addElement(new \XoopsFormText('<b>' . _MA_PEDIGREE_FLD_OWN_EMAIL . '</b>', 'email', $size = 50, $maxsize = 255, $value = ''));
$form->addElement(new \XoopsFormText('<b>' . _MA_PEDIGREE_FLD_OWN_EMAIL . '</b>', 'email', $size = 30, $maxsize = 40, $value = ''));

//website
$form->addElement(new \XoopsFormText('<b>' . _MA_PEDIGREE_FLD_OWN_WEB . '</b>', 'website', $size = 50, $maxsize = 255, $value = ''));
$form->addElement(new \XoopsFormText('<b>' . _MA_PEDIGREE_FLD_OWN_WEB . '</b>', 'website', $size = 30, $maxsize = 60, $value = ''));
$form->addElement(new \XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, _MA_PEDIGREE_FLD_OWN_WEB_EX));

//submit button
Expand Down
6 changes: 3 additions & 3 deletions admin/blocksadmin.php
Expand Up @@ -508,7 +508,7 @@ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $b
$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) {
Expand All @@ -521,7 +521,7 @@ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $b

if ('order' === $op) {
if (!$GLOBALS['xoopsSecurity']->check()) {
redirect_header($_SERVER['PHP_SELF'], 3, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
redirect_header($_SERVER['SCRIPT_NAME'], 3, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
}
foreach (array_keys($bid) as $i) {
if ($oldtitle[$i] != $title[$i] || $oldweight[$i] != $weight[$i] || $oldvisible[$i] != $visible[$i]
Expand Down Expand Up @@ -551,7 +551,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);
Expand Down
4 changes: 2 additions & 2 deletions admin/tools.php
Expand Up @@ -135,8 +135,8 @@ function colours()
{
global $xoopsTpl, $femaleTextColour;
$form = 'This will be the wizard to create and modify the website colourscheme.<hr>';
$form .= '<FORM NAME="myForm" action=\'savecolors.php\' method=\'POST\'>';
$form .= '<INPUT TYPE="text" id="ftxtcolor" name="ftxtcolor" value="#' . $femaleTextColour . '" size="11" maxlength="7">';
$form .= '<form name="myForm" action=\'savecolors.php\' method=\'POST\'>';
$form .= '<input type="text" id="ftxtcolor" name="ftxtcolor" value="#' . $femaleTextColour . '" size="11" maxlength="7">';
$form .= '<a href="javascript:TCP.popup(document.forms[\'myForm\'].elements[\'ftxtcolor\'])">';
$form .= '<img width="15" height="13" border="0" alt="Click Here to Pick up the color" src="img/sel.gif"></a>';
$form .= '</form>';
Expand Down
7 changes: 4 additions & 3 deletions advanced.php
Expand Up @@ -30,8 +30,9 @@
$configHandler = xoops_getHandler('config');
$moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid'));

//colour variables
$colors = explode(';', $moduleConfig['colourscheme']);
//get colour variables
list($actlink, $even, $odd, $text, $hovlink, $head, $body, $title) = Pedigree\Utility::getColourScheme();
/*
$actlink = $colors[0];
$even = $colors[1];
$odd = $colors[2];
Expand All @@ -40,7 +41,7 @@
$head = $colors[5];
$body = $colors[6];
$title = $colors[7];

*/
//@todo convert to use Object CRUD using \Criteria instead of SQL call
//query to count male dogs
$result = $GLOBALS['xoopsDB']->query('SELECT count(id) FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " WHERE roft='0'");
Expand Down
13 changes: 6 additions & 7 deletions assets/css/module.css
Expand Up @@ -8,14 +8,13 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* Wfdownloads module
* Module: Pedigree
*
* @copyright XOOPS Project (https://xoops.org)
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
* @package wfdownload
* @since 3.23
* @author WF-Sections, Xoops Development Team, luciorota
* @version svn:$Id$
* @package XoopsModules\Pedigree
* @copyright {@link https://xoops.org/ XOOPS Project}
* @license {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
* @since 3.23
* @author WF-Sections, XOOPS Module Dev Team, luciorota
*/
.pedigree_headertable {
padding: 0;
Expand Down
67 changes: 16 additions & 51 deletions blocks/menu_block.php
Expand Up @@ -8,11 +8,11 @@

// Include any constants used for internationalizing templates.
$moduleDirName = basename(dirname(__DIR__));
xoops_loadLanguage('main', $moduleDirName);
//xoops_loadLanguage('main', $moduleDirName);
// Include any common code for this module.
$helper = Pedigree\Helper::getInstance();
$helper->loadLanguage('main');

require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/include/common.php';
// Include any common code for this module.
require_once $helper->path('include/common.php');

/**
* @todo: move hard coded language strings to language file
Expand All @@ -21,17 +21,12 @@
*/
function menu_block()
{
global $xoopsTpl, $xoopsUser, $pedigree;
$moduleDirName = basename(dirname(__DIR__));
/*
//get module configuration
$moduleHandler = xoops_getHandler('module');
$module = $moduleHandler->getByDirname($moduleDirName);
$configHandler = xoops_getHandler('config');
$moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid'));
*/
$helper = Pedigree\Helper::getInstance();

//colour variables
$colors = explode(',', $helper->getConfig('colourscheme'));
list($actlink, $even, $odd, $text, $hovlink, $head, $body, $title) = Pedigree\Utility::getColourScheme();
/*
$actlink = $colors[0];
$even = $colors[1];
$odd = $colors[2];
Expand All @@ -40,7 +35,7 @@ function menu_block()
$head = $colors[5];
$body = $colors[6];
$title = $colors[7];

*/
/*
//inline-css
echo '<style>';
Expand All @@ -64,21 +59,13 @@ function menu_block()
echo '</style>';
*/

//iscurrent user a module admin ?
$xoopsModule = XoopsModule::getByDirname($moduleDirName);
if (!empty($xoopsUser) && ($GLOBALS['xoopsUser'] instanceof \XoopsUser)
&& $xoopsUser->isAdmin($xoopsModule->mid())) {
$modadmin = true;
} else {
$modadmin = false;
}
$counter = 1;
$menuwidth = 4;
$x = $_SERVER['SCRIPT_NAME'];
$lastpos = Pedigree\Utility::myStrRpos($x, '/');
$len = strlen($x);
$curpage = substr($x, $lastpos, $len);

$x = $_SERVER['PHP_SELF'];
$lastpos = my_strrpos($x, '/');
$len = strlen($x);
$curpage = substr($x, $lastpos, $len);
if (1 == $helper->getConfig('showwelcome')) {
if ('/welcome.php' === $curpage) {
$title = '<b>Welcome</b>';
Expand Down Expand Up @@ -177,7 +164,7 @@ function menu_block()
if ($counter == $menuwidth) {
$counter = 1;
}
if (true === $modadmin) {
if (true === $helper->isUserAdmin()) {
if ('/tools.php' === $curpage) {
$title = '<b>Webmaster tools</b>';
} else {
Expand Down Expand Up @@ -209,30 +196,8 @@ function menu_block()

//create path taken
//showpath();
$xoopsTpl->assign('menuarray', $menuarray);
$GLOBALS['xoopsTpl']->assign('menuarray', $menuarray);

//return the template contents
return $xoopsTpl;
}

/**
* @param $haystack
* @param $needle
* @param int $offset
*
* @return bool|int
*/
function my_strrpos($haystack, $needle, $offset = 0)
{
// same as strrpos, except $needle can be a string
$strrpos = false;
if (is_string($haystack) && is_string($needle) && is_numeric($offset)) {
$strlen = strlen($haystack);
$strpos = strpos(strrev(substr($haystack, $offset)), strrev($needle));
if (is_numeric($strpos)) {
$strrpos = $strlen - $strpos - strlen($needle);
}
}

return $strrpos;
return $GLOBALS['xoopsTpl'];
}
6 changes: 3 additions & 3 deletions class/Animal.php
Expand Up @@ -12,10 +12,9 @@
/**
* Pedigree module for XOOPS
*
* @package XoopsModules\Pedigree
* @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project}
* @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
* @package pedigree
* @subpackage class
* @since 1.3.1
* @author XOOPS Module Dev Team
* @author ZySpec <zyspec@yahoo.com>
Expand Down Expand Up @@ -79,7 +78,8 @@ public function getNumOfFields()
$this->fields = $fieldsHandler->getIds($criteria); //get all object IDs
$this->configValues = $fieldsHandler->getAll($criteria, null, false); //get objects as arrays
if (empty($this->configValues)) {
$this->configValues = '';
/** @internal changed from '' to [] in v1.32 Alpha 1; not sure this is really needed since getAll() above will return empty array */
$this->configValues = [];
}
/*
$SQL = "SELECT * FROM " . $GLOBALS['xoopsDB']->prefix("pedigree_fields") . " ORDER BY `order`";
Expand Down
4 changes: 2 additions & 2 deletions class/Field.php
Expand Up @@ -31,8 +31,8 @@ class Field
protected $id;

/**
* @param $fieldnumber
* @param $config
* @param int $fieldnumber
* @param array $config
*/
public function __construct($fieldnumber, $config)
{
Expand Down

0 comments on commit 1b648ee

Please sign in to comment.