• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/Form/classes/class.ilFeedUrlInputGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2007 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00031 class ilFeedUrlInputGUI extends ilTextInputGUI
00032 {
00033         protected $value;
00034         protected $maxlength = 200;
00035         protected $size = 40;
00036         
00043         function __construct($a_title = "", $a_postvar = "")
00044         {
00045                 parent::__construct($a_title, $a_postvar);
00046                 $this->setType("feedurl");
00047         }
00048 
00054         function checkInput()
00055         {
00056                 global $lng;
00057                 
00058                 $lng->loadLanguageModule("feed");
00059                 
00060                 $_POST[$this->getPostVar()] = 
00061                         ilUtil::stripSlashes($_POST[$this->getPostVar()]);
00062                         
00063                 // remove safari pseudo protocol
00064                 if (substr($_POST[$this->getPostVar()], 0, 5) == "feed:")
00065                 {
00066                         $_POST[$this->getPostVar()] = "http:".
00067                                 substr($_POST[$this->getPostVar()], 5);
00068                 }
00069                 
00070                 // add missing http://
00071                 if (!is_int(strpos($_POST[$this->getPostVar()], "://")))
00072                 {
00073                         $_POST[$this->getPostVar()] = "http://".$_POST[$this->getPostVar()];
00074                 }
00075                         
00076                 // check required
00077                 if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
00078                 {
00079                         $this->setAlert($lng->txt("msg_input_is_required"));
00080 
00081                         return false;
00082                 }
00083                 
00084                 // check feed url
00085                 $url = $_POST[$this->getPostVar()];
00086                 include_once("./Services/Feeds/classes/class.ilExternalFeed.php");
00087                 $check = ilExternalFeed::_checkUrl($url);
00088 
00089                 // try to determine a feed url, if we failed here
00090                 if  ($check !== true)
00091                 {
00092                         $url2 = ilExternalFeed::_determineFeedUrl($url);
00093                         $check2 = ilExternalFeed::_checkUrl($url2);
00094                         
00095                         if ($check2 === true)
00096                         {
00097                                 $_POST[$this->getPostVar()] = $url2;
00098                                 $check = true;
00099                         }
00100                 }
00101 
00102                 // if check failed, output error message
00103                 if  ($check !== true)
00104                 {
00105                         $check = str_replace("MagpieRSS:", "", $check);
00106                         $this->setAlert($lng->txt("feed_no_valid_url")."<br />".$check);
00107                         return false;
00108                 }
00109                 
00110                 return true;
00111         }
00112 
00113 }

Generated on Fri Dec 13 2013 17:56:57 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1