1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits of |
4
|
|
|
supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit |
6
|
|
|
authors. |
7
|
|
|
|
8
|
|
|
This program is distributed in the hope that it will be useful, but |
9
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of |
10
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Module: Pedigree |
15
|
|
|
* |
16
|
|
|
* @package XoopsModules\Pedigree |
17
|
|
|
* @author XOOPS Module Development Team |
18
|
|
|
* @copyright Copyright (c) 2001-2019 {@link https://xoops.org XOOPS Project} |
19
|
|
|
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU Public License |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
use Xmf\Request; |
|
|
|
|
23
|
|
|
use XoopsModules\Pedigree\{ |
24
|
|
|
Common\Breadcrumb, |
25
|
|
|
Animal, |
26
|
|
|
Field, |
27
|
|
|
Helper, |
28
|
|
|
Utility |
29
|
|
|
}; |
30
|
|
|
/** @var Helper $helper */ |
31
|
|
|
/** @var Animal $animal */ |
32
|
|
|
/** @var Field $userField */ |
33
|
|
|
|
34
|
|
|
require_once __DIR__ . '/header.php'; |
35
|
|
|
|
36
|
|
|
$helper->loadLanguage('main'); |
37
|
|
|
|
38
|
|
|
// Include any common code for this module. |
39
|
|
|
require_once $helper->path('include/common.php'); |
40
|
|
|
//require_once __DIR__ . '/welcome.php'; |
41
|
|
|
|
42
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'pedigree_index.tpl'; |
43
|
|
|
|
44
|
|
|
require $GLOBALS['xoops']->path('/header.php'); |
45
|
|
|
|
46
|
|
|
//load javascript |
47
|
|
|
$xoTheme->addScript(XOOPS_URL . '/browse.php?Frameworks/jquery/jquery.js'); |
48
|
|
|
//$xoTheme->addScript($helper->url('assets/js/jquery.ThickBox/thickbox-compressed.js')); |
49
|
|
|
|
50
|
|
|
$xoTheme->addScript($helper->url('assets/js/jquery.magnific-popup.min.js')); |
51
|
|
|
$xoTheme->addScript($helper->url('assets/js/colpick.js')); |
52
|
|
|
|
53
|
|
|
//load CSS style sheets |
54
|
|
|
$xoTheme->addStylesheet($helper->url('assets/css/colpick.css')); |
55
|
|
|
$xoTheme->addStylesheet($helper->url('assets/css/magnific-popup.css')); |
56
|
|
|
$xoTheme->addStylesheet($helper->url('assets/css/style.css')); |
57
|
|
|
|
58
|
|
|
//$xoTheme->addStylesheet($helper->url('assets/css/jquery.ThickBox/thickbox.css')); |
59
|
|
|
//$xoTheme->addStylesheet($helper->url('assets/css/module.css')); |
60
|
|
|
|
61
|
|
|
$GLOBALS['xoopsTpl']->assign('pedigree_url', $helper->url()); |
62
|
|
|
|
63
|
|
|
// Breadcrumb |
64
|
|
|
$breadcrumb = new Breadcrumb(); |
65
|
|
|
$breadcrumb->addLink($helper->getModule()->getVar('name'), $helper->url()); |
66
|
|
|
|
67
|
|
|
$GLOBALS['xoopsTpl']->assign('module_home', $helper->getDirname()); // this definition is not removed for backward compatibility issues |
68
|
|
|
$GLOBALS['xoopsTpl']->assign('pedigree_breadcrumb', $breadcrumb->render()); |
69
|
|
|
|
70
|
|
|
// Create an animal object |
71
|
|
|
$animal = new Animal(); |
72
|
|
|
$fields = $animal->getNumOfFields(); //find out how many user fields there are |
73
|
|
|
|
74
|
|
|
foreach ($fields as $i => $iValue) { |
75
|
|
|
$userField = new Field($fields[$i], $animal->getConfig()); |
76
|
|
|
if ($userField->isActive() && $userField->hasSearch()) { |
77
|
|
|
$fieldType = $userField->getSetting('fieldtype'); |
78
|
|
|
$fieldObject = new $fieldType($userField, $animal); |
79
|
|
|
$function = 'user' . $iValue . $fieldObject->getSearchString(); |
80
|
|
|
//echo $function."<br>"; |
81
|
|
|
$usersearch[] = [ |
82
|
|
|
'title' => $userField->getSetting('SearchName'), |
83
|
|
|
'searchid' => 'user' . $iValue, |
84
|
|
|
'function' => $function, |
85
|
|
|
'explanation' => $userField->getSetting('SearchExplanation'), |
86
|
|
|
'searchfield' => $fieldObject->searchfield(), |
87
|
|
|
]; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
//$catarray['letters'] = Pedigree\Utility::lettersChoice(); |
92
|
|
|
//$letter = ''; |
93
|
|
|
//$myObject = Helper::getInstance(); |
94
|
|
|
//$activeObject = 'Tree'; |
95
|
|
|
$name = 'pname'; |
96
|
|
|
$link = "result.php?f={$name}&l=1&o={$name}&w="; |
97
|
|
|
$link2 = '%25'; |
98
|
|
|
|
99
|
|
|
$criteria = $helper->getHandler('Tree')->getActiveCriteria(); |
100
|
|
|
$criteria->setGroupby('UPPER(LEFT(' . $name . ', 1))'); |
101
|
|
|
$catarray['letters'] = Utility::lettersChoice($helper, 'Tree', $criteria, $name, $link, $link2); |
102
|
|
|
//$catarray['toolbar'] = pedigree_toolbar(); |
103
|
|
|
|
104
|
|
|
$word = $myts->displayTarea(strtr($helper->getConfig('welcome'), ['[numanimals]' => $numdogs, '[animalType]' => $helper->getConfig('animalType'), '[animalTypes]' => $helper->getConfig('animalTypes')])); |
105
|
|
|
|
106
|
|
|
//add data to smarty template |
107
|
|
|
$GLOBALS['xoopsTpl']->assign([ |
108
|
|
|
'catarray' => $catarray, |
109
|
|
|
'pageTitle' => _MA_PEDIGREE_BROWSETOTOPIC, |
110
|
|
|
'sselect' => strtr(_MA_PEDIGREE_SELECT, ['[animalType]' => $helper->getConfig('animalType')]), |
111
|
|
|
'explain' => _MA_PEDIGREE_EXPLAIN, |
112
|
|
|
'sname' => _MA_PEDIGREE_SEARCHNAME, |
113
|
|
|
'snameex' => strtr(_MA_PEDIGREE_SEARCHNAME_EX, ['[animalTypes]' => $helper->getConfig('animalTypes')]), |
114
|
|
|
'usersearch' => isset($usersearch) ? $usersearch : '', |
115
|
|
|
'showwelcome' => $helper->getConfig('showwelcome'), |
116
|
|
|
'word' => $word, |
117
|
|
|
//'welcome' => $GLOBALS['myts']->displayTarea($helper->getConfig('welcome')) |
118
|
|
|
]); |
119
|
|
|
|
120
|
|
|
require $GLOBALS['xoops']->path('footer.php'); |
121
|
|
|
|
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/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 beforeOtherDir/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: