|
1
|
|
|
<?php |
|
2
|
|
|
// ------------------------------------------------------------------------ // |
|
3
|
|
|
// BOOKSHOP - MODULE FOR XOOPS 2 // |
|
4
|
|
|
// Copyright (c) 2007, 2008 Instant Zero // |
|
5
|
|
|
// <http://www.instant-zero.com/> // |
|
6
|
|
|
// ------------------------------------------------------------------------- // |
|
7
|
|
|
// This program is free software; you can redistribute it and/or modify // |
|
8
|
|
|
// it under the terms of the GNU General Public License as published by // |
|
9
|
|
|
// the Free Software Foundation; either version 2 of the License, or // |
|
10
|
|
|
// (at your option) any later version. // |
|
11
|
|
|
// // |
|
12
|
|
|
// You may not change or alter any portion of this comment or credits // |
|
13
|
|
|
// of supporting developers from this source code or any supporting // |
|
14
|
|
|
// source code which is considered copyrighted (c) material of the // |
|
15
|
|
|
// original comment or credit authors. // |
|
16
|
|
|
// // |
|
17
|
|
|
// This program is distributed in the hope that it will be useful, // |
|
18
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
19
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
20
|
|
|
// GNU General Public License for more details. // |
|
21
|
|
|
// // |
|
22
|
|
|
// You should have received a copy of the GNU General Public License // |
|
23
|
|
|
// along with this program; if not, write to the Free Software // |
|
24
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
|
25
|
|
|
// ------------------------------------------------------------------------ // |
|
26
|
|
|
|
|
27
|
|
|
defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
|
28
|
|
|
|
|
29
|
|
|
include_once XOOPS_ROOT_PATH . '/kernel/object.php'; |
|
30
|
|
|
if (!class_exists('Bookshop_XoopsPersistableObjectHandler')) { |
|
31
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/bookshop/class/PersistableObjectHandler.php'; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Class bookshop_authors |
|
36
|
|
|
*/ |
|
37
|
|
|
class bookshop_authors extends Bookshop_Object |
|
38
|
|
|
{ |
|
39
|
|
|
public function __construct() |
|
40
|
|
|
{ |
|
41
|
|
|
$this->initVar('auth_id', XOBJ_DTYPE_INT, null, false); |
|
42
|
|
|
$this->initVar('auth_type', XOBJ_DTYPE_INT, null, false); |
|
43
|
|
|
$this->initVar('auth_name', XOBJ_DTYPE_TXTBOX, null, false); |
|
44
|
|
|
$this->initVar('auth_firstname', XOBJ_DTYPE_TXTBOX, null, false); |
|
45
|
|
|
$this->initVar('auth_email', XOBJ_DTYPE_TXTBOX, null, false); |
|
46
|
|
|
$this->initVar('auth_bio', XOBJ_DTYPE_TXTAREA, null, false); |
|
47
|
|
|
$this->initVar('auth_url', XOBJ_DTYPE_TXTBOX, null, false); |
|
48
|
|
|
$this->initVar('auth_photo1', XOBJ_DTYPE_TXTBOX, null, false); |
|
49
|
|
|
$this->initVar('auth_photo2', XOBJ_DTYPE_TXTBOX, null, false); |
|
50
|
|
|
$this->initVar('auth_photo3', XOBJ_DTYPE_TXTBOX, null, false); |
|
51
|
|
|
$this->initVar('auth_photo4', XOBJ_DTYPE_TXTBOX, null, false); |
|
52
|
|
|
$this->initVar('auth_photo5', XOBJ_DTYPE_TXTBOX, null, false); |
|
53
|
|
|
// Pour autoriser le html |
|
54
|
|
|
$this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Class BookshopBookshop_authorsHandler |
|
60
|
|
|
*/ |
|
61
|
|
|
class BookshopBookshop_authorsHandler extends Bookshop_XoopsPersistableObjectHandler |
|
62
|
|
|
{ |
|
63
|
|
|
/** |
|
64
|
|
|
* @param $db |
|
65
|
|
|
*/ |
|
66
|
|
|
public function __construct($db) |
|
67
|
|
|
{ // Table Classe Id |
|
68
|
|
|
parent::__construct($db, 'bookshop_authors', 'bookshop_authors', 'auth_id'); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Renvoie le lien à utiliser pour aller vers un auteur |
|
73
|
|
|
* |
|
74
|
|
|
* @param integer $auth_id L'identifiant de l'auteur |
|
75
|
|
|
* @param string $auth_name Le nom de l'auteur |
|
76
|
|
|
* @param string $auth_firstname Le prénom de l'auteur |
|
77
|
|
|
* @return string L'URL à utiliser en fonction du paramétrage du module |
|
78
|
|
|
*/ |
|
79
|
|
|
public function GetAuthorLink($auth_id, $auth_name, $auth_firstname) |
|
80
|
|
|
{ |
|
81
|
|
|
$url = ''; |
|
|
|
|
|
|
82
|
|
|
if (bookshop_getmoduleoption('urlrewriting') == 1) { // On utilise l'url rewriting |
|
83
|
|
|
$url = BOOKSHOP_URL . 'author-' . (int)$auth_id . bookshop_makeSEOurl($auth_firstname . ' ' . $auth_name) . '.html'; |
|
84
|
|
|
} else { // Pas d'utilisation de l'url rewriting |
|
85
|
|
|
$url = BOOKSHOP_URL . 'author.php?auth_id=' . (int)$auth_id; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
return $url; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Renvoie l'alphabet à partir de la première lettre du nom des auteurs et traducteurs |
|
93
|
|
|
* |
|
94
|
|
|
* @return array l'alphabet des lettres utilisées ! |
|
95
|
|
|
*/ |
|
96
|
|
|
public function getAlphabet() |
|
97
|
|
|
{ |
|
98
|
|
|
global $myts; |
|
99
|
|
|
$ret = array(); |
|
100
|
|
|
$sql = 'SELECT DISTINCT (UPPER(SUBSTRING(auth_name, 1, 1))) as oneletter FROM ' . $this->table; |
|
101
|
|
|
$result = $this->db->query($sql); |
|
102
|
|
|
if (!$result) { |
|
103
|
|
|
return $ret; |
|
104
|
|
|
} |
|
105
|
|
|
while ($myrow = $this->db->fetchArray($result)) { |
|
106
|
|
|
$ret[] = $myts->htmlSpecialChars($myrow['oneletter']); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
return $ret; |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.