Passed
Push — master ( b847d6...d6d54c )
by Michael
09:34 queued 05:00
created

index.php (4 issues)

1
<?php
2
// -------------------------------------------------------------------------
3
4
use XoopsModules\Pedigree;
0 ignored issues
show
This use statement conflicts with another class in this namespace, Pedigree. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
5
6
require_once __DIR__ . '/header.php';
7
8
$moduleDirName = basename(__DIR__);
9
xoops_loadLanguage('main', $moduleDirName);
10
11
// Include any common code for this module.
12
require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/include/common.php';
13
require_once __DIR__ . '/welcome.php';
14
15
$GLOBALS['xoopsOption']['template_main'] = 'pedigree_index.tpl';
16
17
include $GLOBALS['xoops']->path('/header.php');
18
19
//load javascript
20
$xoTheme->addScript(XOOPS_URL . '/browse.php?Frameworks/jquery/jquery.js');
21
//$xoTheme->addScript(PEDIGREE_URL . '/assets/js/jquery.ThickBox/thickbox-compressed.js');
22
23
$xoTheme->addScript(PEDIGREE_URL . '/assets/js/jquery.magnific-popup.min.js');
0 ignored issues
show
The constant PEDIGREE_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
24
$xoTheme->addScript(PEDIGREE_URL . '/assets/js/colpick.js');
25
26
//load CSS style sheets
27
$xoTheme->addStylesheet(PEDIGREE_URL . '/assets/css/colpick.css');
28
$xoTheme->addStylesheet(PEDIGREE_URL . '/assets/css/magnific-popup.css');
29
$xoTheme->addStylesheet(PEDIGREE_URL . '/assets/css/style.css');
30
31
//$xoTheme->addStylesheet(PEDIGREE_URL . '/assets/css/jquery.ThickBox/thickbox.css');
32
//$xoTheme->addStylesheet(PEDIGREE_URL . '/module.css');
33
34
$GLOBALS['xoopsTpl']->assign('pedigree_url', PEDIGREE_URL . '/');
35
36
// Breadcrumb
37
$breadcrumb = new Pedigree\Breadcrumb();
38
$breadcrumb->addLink($helper->getModule()->getVar('name'), PEDIGREE_URL);
39
40
$GLOBALS['xoopsTpl']->assign('module_home', Pedigree\Utility::getModuleName(false)); // this definition is not removed for backward compatibility issues
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Pedigree\Utility::getModuleName() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

40
$GLOBALS['xoopsTpl']->assign('module_home', /** @scrutinizer ignore-deprecated */ Pedigree\Utility::getModuleName(false)); // this definition is not removed for backward compatibility issues
Loading history...
41
$GLOBALS['xoopsTpl']->assign('pedigree_breadcrumb', $breadcrumb->render());
42
43
//get module configuration
44
/** @var XoopsModuleHandler $moduleHandler */
45
$moduleHandler = xoops_getHandler('module');
46
$module        = $moduleHandler->getByDirname($xoopsModule->dirname());
47
$configHandler = xoops_getHandler('config');
48
$moduleConfig  = $configHandler->getConfigsByCat(0, $module->getVar('mid'));
49
50
//create animal object
51
$animal = new Pedigree\Animal();
52
53
//test to find out how many user fields there are..
54
$fields = $animal->getNumOfFields();
55
56
foreach ($fields as $i => $iValue) {
57
    $userField = new Pedigree\Field($fields[$i], $animal->getConfig());
58
    if ($userField->isActive() && $userField->hasSearch()) {
59
        $fieldType   = $userField->getSetting('FieldType');
60
        $fieldObject = new $fieldType($userField, $animal);
61
        $function    = 'user' . $iValue . $fieldObject->getSearchString();
62
        //echo $function."<br>";
63
        $usersearch[] = [
64
            'title'       => $userField->getSetting('SearchName'),
65
            'searchid'    => 'user' . $iValue,
66
            'function'    => $function,
67
            'explanation' => $userField->getSetting('SearchExplanation'),
68
            'searchfield' => $fieldObject->searchfield()
69
        ];
70
    }
71
}
72
73
//$catarray['letters']          = Pedigree\Utility::lettersChoice();
74
$letter              = '';
75
$myObject     = Pedigree\Helper::getInstance();
76
$activeObject = 'Tree';
77
$name         = 'naam';
78
$link         = "result.php?f={$name}&amp;l=1&amp;o={$name}&amp;w=";
79
$link2        = '%25';
80
81
$criteria = $myObject->getHandler('Tree')->getActiveCriteria();
0 ignored issues
show
The method getActiveCriteria() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

81
$criteria = $myObject->getHandler('Tree')->/** @scrutinizer ignore-call */ getActiveCriteria();
Loading history...
82
$criteria->setGroupby('UPPER(LEFT(' . $name . ',1))');
83
$catarray['letters'] = Pedigree\Utility::lettersChoice($myObject, $activeObject, $criteria, $name, $link, $link2);
84
//$catarray['toolbar']          = pedigree_toolbar();
85
$xoopsTpl->assign('catarray', $catarray);
86
$xoopsTpl->assign('pageTitle', _MA_PEDIGREE_BROWSETOTOPIC);
87
88
//add data to smarty template
89
$GLOBALS['xoopsTpl']->assign([
90
                                 'sselect'    => strtr(_MA_PEDIGREE_SELECT, ['[animalType]' => $moduleConfig['animalType']]),
91
                                 'explain'     => _MA_PEDIGREE_EXPLAIN,
92
                                 'sname'       => _MA_PEDIGREE_SEARCHNAME,
93
                                 'snameex'    => strtr(_MA_PEDIGREE_SEARCHNAME_EX, ['[animalTypes]' => $moduleConfig['animalTypes']]),
94
                                 'usersearch' => isset($usersearch) ? $usersearch : ''
95
                             ]);
96
$GLOBALS['xoopsTpl']->assign('showwelcome', $moduleConfig['showwelcome']);
97
//$GLOBALS['xoopsTpl']->assign('welcome', $GLOBALS['myts']->displayTarea($moduleConfig['welcome']));
98
//$word = $myts->displayTarea(strtr($helper->getConfig('welcome'), array('[numanimals]' => $numdogs, '[animalType]' => $helper->getConfig('animalType'), '[animalTypes]' => $helper->getConfig('animalTypes'))));
99
$GLOBALS['xoopsTpl']->assign('word', $word);
100
include $GLOBALS['xoops']->path('footer.php');
101