Completed
Push — master ( 16a09f...2bada9 )
by Michael
01:30
created

class/headline.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 25 and the first side effect is on line 20.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
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      GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
15
 * @package
16
 * @since
17
 * @author       XOOPS Development Team, Kazumi Ono (AKA onokazu)
18
 */
19
20
defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
21
22
/**
23
 * Class XoopsheadlineHeadline
24
 */
25
class XoopsheadlineHeadline extends XoopsObject
26
{
27
28
    /**
29
     * XoopsheadlineHeadline constructor.
30
     */
31
    public function __construct()
32
    {
33
        parent::__construct();
34
        $this->initVar('headline_id', XOBJ_DTYPE_INT, null, false);
35
        $this->initVar('headline_name', XOBJ_DTYPE_TXTBOX, null, true, 255);
36
        $this->initVar('headline_url', XOBJ_DTYPE_TXTBOX, null, true, 255);
37
        $this->initVar('headline_rssurl', XOBJ_DTYPE_TXTBOX, null, true, 255);
38
        $this->initVar('headline_cachetime', XOBJ_DTYPE_INT, 600, false);
39
        $this->initVar('headline_asblock', XOBJ_DTYPE_INT, 0, false);
40
        $this->initVar('headline_display', XOBJ_DTYPE_INT, 0, false);
41
        $this->initVar('headline_encoding', XOBJ_DTYPE_OTHER, null, false);
42
        $this->initVar('headline_weight', XOBJ_DTYPE_INT, 0, false);
43
        $this->initVar('headline_mainimg', XOBJ_DTYPE_INT, 1, false);
44
        $this->initVar('headline_mainfull', XOBJ_DTYPE_INT, 1, false);
45
        $this->initVar('headline_mainmax', XOBJ_DTYPE_INT, 10, false);
46
        $this->initVar('headline_blockimg', XOBJ_DTYPE_INT, 0, false);
47
        $this->initVar('headline_blockmax', XOBJ_DTYPE_INT, 10, false);
48
        $this->initVar('headline_xml', XOBJ_DTYPE_SOURCE, null, false);
49
        $this->initVar('headline_updated', XOBJ_DTYPE_INT, 0, false);
50
    }
51
52
    /**
53
     * @return bool
54
     */
55
    public function cacheExpired()
56
    {
57
        if (time() - $this->getVar('headline_updated') > $this->getVar('headline_cachetime')) {
58
            return true;
59
        }
60
61
        return false;
62
    }
63
}
64
65
/**
66
 * Class xoopsheadlineHeadlineHandler
67
 */
68
class xoopsheadlineHeadlineHandler extends XoopsPersistableObjectHandler
69
{
70
71
    /**
72
     * xoopsheadlineHeadlineHandler constructor.
73
     * @param XoopsDatabase $db
74
     */
75
    public function __construct(XoopsDatabase $db)
76
    {
77
        parent::__construct($db, 'xoopsheadline', 'xoopsheadline' . 'Headline', 'headline_id');
78
    }
79
}
80