Completed
Branch master (1bc8d1)
by Pierre-Henry
33:16
created

XmlDesignCore::softwareNews()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 13
nc 5
nop 1
dl 0
loc 21
rs 9.0534
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author         Pierre-Henry Soria <[email protected]>
4
 * @copyright      (c) 2012-2017, Pierre-Henry Soria. All Rights Reserved.
5
 * @license        GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
6
 * @package        PH7 / App / System / Core / Class / Design
7
 */
8
9
namespace PH7;
10
11
use PH7\Framework\Pattern\Statik;
12
use PH7\Framework\Layout\Html\Design;
13
use PH7\Framework\Error\CException\PH7Exception;
14
use PH7\Framework\Mvc\Router\Uri;
15
16
class XmlDesignCore
17
{
18
    /**
19
     * Import the trait to set the class static.
20
     * The trait sets constructor/clone private to prevent instantiation.
21
     */
22
    use Statik;
23
24
    public static function xslHeader()
25
    {
26
        echo '<?xml-stylesheet type="text/xsl" href="', Uri::get('xml','main','xsllayout'), '"?>
27
        <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
28
    }
29
30
    public static function rssHeader()
31
    {
32
        echo '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">';
33
    }
34
35
    public static function xslFooter()
36
    {
37
        echo '</urlset>';
38
    }
39
40
    public static function rssFooter()
41
    {
42
        echo '</rss>';
43
    }
44
45
    public static function sitemapHeaderLink()
46
    {
47
        echo '<link rel="alternate" type="application/xml" title="Sitemap" href="', Uri::get('xml','sitemap','xmlrouter'), '" />';
48
    }
49
50
    public static function rssHeaderLinks()
51
    {
52
        echo '<link rel="alternate" type="application/rss+xml" title="', t('Latest Blog Posts'), '" href="', Uri::get('xml','rss','xmlrouter','blog'), '" />
53
        <link rel="alternate" type="application/rss+xml" title="', t('Latest Notes'), '" href="', Uri::get('xml','rss','xmlrouter','note'), '" />
54
        <link rel="alternate" type="application/rss+xml" title="', t('Latest Forum Topics'), '" href="', Uri::get('xml','rss','xmlrouter','forum-topic'), '" />
55
        <link rel="alternate" type="application/rss+xml" title="', t('Latest Profile Comments'), '" href="', Uri::get('xml','rss','xmlrouter','comment-profile'), '" />
56
        <link rel="alternate" type="application/rss+xml" title="', t('Latest Blog Comments'), '" href="', Uri::get('xml','rss','xmlrouter','comment-blog'), '" />
57
        <link rel="alternate" type="application/rss+xml" title="', t('Latest Note Comments'), '" href="', Uri::get('xml','rss','xmlrouter','comment-note'), '" />
58
        <link rel="alternate" type="application/rss+xml" title="', t('Latest Picture Comments'), '" href="', Uri::get('xml','rss','xmlrouter','comment-picture'), '" />
59
        <link rel="alternate" type="application/rss+xml" title="', t('Latest Video Comments'), '" href="', Uri::get('xml','rss','xmlrouter','comment-video'), '" />
60
        <link rel="alternate" type="application/rss+xml" title="', t('Latest Game Comments'), '" href="', Uri::get('xml','rss','xmlrouter','comment-game'), '" />';
61
    }
62
63
    /**
64
     * Show the software news.
65
     *
66
     * @param integet $iNum Number of news to display.
67
     *
68
     * @return void HTML contents.
69
     */
70
    public static function softwareNews($iNum)
71
    {
72
        try {
73
            $aNews = (new NewsFeedCore)->getSoftware($iNum);
74
75
            if (sizeof($aNews) > 0) {
76
                foreach ($aNews as $aItems) {
77
                    echo '<h4><a href="', $aItems['link'], '" target="_blank">', escape($aItems['title'], true), '</a></h4>';
78
                    echo '<p>', escape($aItems['description'], true), '</p>';
79
                }
80
            } else {
81
                echo '<p>', t('No News Software.'), '</p>';
82
            }
83
        }
84
        catch (PH7Exception $oE) {
85
            (new Design)->setFlashMsg(
86
                t("It seems you don't have Internet connection or the remote URL is temporarily unavailable. Some features on the admin panel won't be available."),
87
                'error'
88
            );
89
        }
90
    }
91
}
92