ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilFeedUrlInputGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2007 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
32{
36 protected $lng;
37
38 protected $value;
39 protected $maxlength = 200;
40 protected $size = 40;
41
48 public function __construct($a_title = "", $a_postvar = "")
49 {
50 global $DIC;
51
52 $this->lng = $DIC->language();
53 parent::__construct($a_title, $a_postvar);
54 $this->setType("feedurl");
55 }
56
62 public function checkInput()
63 {
65
66 $lng->loadLanguageModule("feed");
67
68 $_POST[$this->getPostVar()] =
70
71 // remove safari pseudo protocol
72 if (substr($_POST[$this->getPostVar()], 0, 5) == "feed:") {
73 $_POST[$this->getPostVar()] = "http:" .
74 substr($_POST[$this->getPostVar()], 5);
75 }
76
77 // add missing http://
78 if (!is_int(strpos($_POST[$this->getPostVar()], "://"))) {
79 $_POST[$this->getPostVar()] = "http://" . $_POST[$this->getPostVar()];
80 }
81
82 // check required
83 if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "") {
84 $this->setAlert($lng->txt("msg_input_is_required"));
85
86 return false;
87 }
88
89 // check feed url
90 $url = $_POST[$this->getPostVar()];
91 include_once("./Services/Feeds/classes/class.ilExternalFeed.php");
93
94 // try to determine a feed url, if we failed here
95 if ($check !== true) {
97 $check2 = ilExternalFeed::_checkUrl($url2);
98
99 if ($check2 === true) {
100 $_POST[$this->getPostVar()] = $url2;
101 $check = true;
102 }
103 }
104
105 // if check failed, output error message
106 if ($check !== true) {
107 $check = str_replace("MagpieRSS:", "", $check);
108 $this->setAlert($lng->txt("feed_no_valid_url") . "<br />" . $check);
109 return false;
110 }
111
112 return true;
113 }
114}
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
static _checkUrl($a_url)
Check Url.
static _determineFeedUrl($a_url)
Determine Feed Url.
This class represents a feed url property in a property form.
__construct($a_title="", $a_postvar="")
Constructor.
checkInput()
Check input, strip slashes etc.
setType($a_type)
Set Type.
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
This class represents a text property in a property form.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$url
global $DIC
Definition: saml.php:7