|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
/* |
|
3
|
|
|
You may not change or alter any portion of this comment or credits |
|
4
|
|
|
of supporting developers from this source code or any supporting source code |
|
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
6
|
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
|
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
14
|
|
|
* @license https://www.fsf.org/copyleft/gpl.html GNU public license |
|
15
|
|
|
* @since 1.0 |
|
16
|
|
|
* @author trabis <[email protected]> |
|
17
|
|
|
* @author The SmartFactory <www.smartfactory.ca> |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
use XoopsModules\Publisher\Helper; |
|
21
|
|
|
use XoopsModules\Publisher\Seo; |
|
22
|
|
|
|
|
23
|
|
|
//require_once __DIR__ . '/seo_functions.php'; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @param $category |
|
27
|
|
|
* @param $itemId |
|
28
|
|
|
* |
|
29
|
|
|
* @return mixed |
|
30
|
|
|
*/ |
|
31
|
|
|
function publisher_notify_iteminfo($category, $itemId) |
|
32
|
|
|
{ |
|
33
|
|
|
if ('global' === $category) { |
|
34
|
|
|
$item['name'] = ''; |
|
|
|
|
|
|
35
|
|
|
$item['url'] = ''; |
|
36
|
|
|
|
|
37
|
|
|
return $item; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
global $xoopsModule; |
|
41
|
|
|
$helper = Helper::getInstance(); |
|
42
|
|
|
|
|
43
|
|
|
if ('category' === $category) { |
|
44
|
|
|
// Assume we have a valid category id |
|
45
|
|
|
$sql = 'SELECT name, short_url FROM ' . $GLOBALS['xoopsDB']->prefix($helper->getDirname() . '_categories') . ' WHERE categoryid = ' . $itemId; |
|
46
|
|
|
$result = $GLOBALS['xoopsDB']->query($sql); // TODO: error check |
|
47
|
|
|
$resultArray = $GLOBALS['xoopsDB']->fetchArray($result); |
|
48
|
|
|
$item['name'] = $resultArray['name']; |
|
49
|
|
|
$item['url'] = Seo::generateUrl('category', $itemId, $resultArray['short_url']); |
|
50
|
|
|
|
|
51
|
|
|
return $item; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
if ('item' === $category) { |
|
55
|
|
|
// Assume we have a valid story id |
|
56
|
|
|
$sql = 'SELECT title, short_url FROM ' . $GLOBALS['xoopsDB']->prefix($helper->getDirname() . '_items') . ' WHERE itemid = ' . $itemId; |
|
57
|
|
|
$result = $GLOBALS['xoopsDB']->query($sql); // TODO: error check |
|
58
|
|
|
$resultArray = $GLOBALS['xoopsDB']->fetchArray($result); |
|
59
|
|
|
$item['name'] = $resultArray['title']; |
|
60
|
|
|
$item['url'] = Seo::generateUrl('item', $itemId, $resultArray['short_url']); |
|
61
|
|
|
|
|
62
|
|
|
return $item; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
return null; |
|
66
|
|
|
} |
|
67
|
|
|
|