ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilExternalFeedBlock Class Reference

Custom block for external feeds. More...

+ Inheritance diagram for ilExternalFeedBlock:
+ Collaboration diagram for ilExternalFeedBlock:

Public Member Functions

 __construct ($a_id=0)
 Constructor. More...
 
 setFeedUrl ($a_feed_url)
 Set FeedUrl. More...
 
 isFeedUrlLocal ($url)
 Check if feed url is local. More...
 
 getFeedUrl ()
 Get FeedUrl. More...
 
 create ()
 Create new item. More...
 
 read ()
 Read item from database. More...
 
 update ()
 Update item in database. More...
 
 delete ()
 Delete item from database. More...
 
- Public Member Functions inherited from ilCustomBlock
 __construct ($a_id=0)
 Constructor. More...
 
 setId ($a_id)
 Set Id. More...
 
 getId ()
 Get Id. More...
 
 setContextObjId ($a_context_obj_id)
 Set ContextObjId. More...
 
 getContextObjId ()
 Get ContextObjId. More...
 
 setContextObjType ($a_context_obj_type)
 Set ContextObjType. More...
 
 getContextObjType ()
 Get ContextObjType. More...
 
 setContextSubObjId ($a_context_sub_obj_id)
 Set ContextSubObjId. More...
 
 getContextSubObjId ()
 Get ContextSubObjId. More...
 
 setContextSubObjType ($a_context_sub_obj_type)
 Set ContextSubObjType. More...
 
 getContextSubObjType ()
 Get ContextSubObjType. More...
 
 setType ($a_type)
 Set Type. More...
 
 getType ()
 Get Type. More...
 
 setTitle ($a_title)
 Set Title. More...
 
 getTitle ()
 Get Title. More...
 
 create ()
 Create new item. More...
 
 read ()
 Read item from database. More...
 
 update ()
 Update item in database. More...
 
 delete ()
 Delete item from database. More...
 
 querygetBlocksForContext ()
 Query getBlocksForContext. More...
 
 queryBlocksForContext ($a_include_sub_obj=true)
 Query BlocksForContext. More...
 
 queryTitleForId ()
 Query TitleForId. More...
 
 queryCntBlockForContext ()
 Query CntBlockForContext. More...
 

Protected Attributes

 $db
 
 $log
 
 $feed_url
 
- Protected Attributes inherited from ilCustomBlock
 $db
 
 $id
 
 $context_obj_id
 
 $context_obj_type
 
 $context_sub_obj_id
 
 $context_sub_obj_type
 
 $type
 
 $title
 

Additional Inherited Members

- Static Public Member Functions inherited from ilCustomBlock
static multiBlockQuery ($a_context_obj_type, array $a_context_obj_ids)
 

Detailed Description

Custom block for external feeds.

Author
alex killing <alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilExternalFeedBlock.php.

Constructor & Destructor Documentation

◆ __construct()

ilExternalFeedBlock::__construct (   $a_id = 0)

Constructor.

Parameters
int$a_id

Definition at line 32 of file class.ilExternalFeedBlock.php.

References $DIC, read(), and ilCustomBlock\setId().

33  {
34  global $DIC;
35 
36  $this->db = $DIC->database();
37  $this->log = $DIC["ilLog"];
38  if ($a_id > 0) {
39  $this->setId($a_id);
40  $this->read();
41  }
42  }
global $DIC
Definition: saml.php:7
setId($a_id)
Set Id.
read()
Read item from database.
+ Here is the call graph for this function:

Member Function Documentation

◆ create()

ilExternalFeedBlock::create ( )

Create new item.

Definition at line 92 of file class.ilExternalFeedBlock.php.

References $db, $ilDB, $ilLog, $log, $query, getFeedUrl(), and ilCustomBlock\getId().

93  {
94  $ilDB = $this->db;
96 
97  parent::create();
98 
99  $query = "INSERT INTO il_external_feed_block (" .
100  " id" .
101  ", feed_url" .
102  " ) VALUES (" .
103  $ilDB->quote($this->getId(), "integer")
104  . "," . $ilDB->quote($this->getFeedUrl(), "text") . ")";
105  $ilDB->manipulate($query);
106  }
$query
global $ilDB
+ Here is the call graph for this function:

◆ delete()

ilExternalFeedBlock::delete ( )

Delete item from database.

Definition at line 147 of file class.ilExternalFeedBlock.php.

References $db, $ilDB, $query, and ilCustomBlock\getId().

148  {
149  $ilDB = $this->db;
150 
151  parent::delete();
152 
153  $query = "DELETE FROM il_external_feed_block" .
154  " WHERE id = " . $ilDB->quote($this->getId(), "integer");
155 
156  $ilDB->manipulate($query);
157  }
$query
global $ilDB
+ Here is the call graph for this function:

◆ getFeedUrl()

ilExternalFeedBlock::getFeedUrl ( )

Get FeedUrl.

Returns
string URL of the external news feed.

Definition at line 83 of file class.ilExternalFeedBlock.php.

References $feed_url.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ isFeedUrlLocal()

ilExternalFeedBlock::isFeedUrlLocal (   $url)

Check if feed url is local.

Parameters
string
Returns
bool

Definition at line 59 of file class.ilExternalFeedBlock.php.

References $res, and $url.

60  {
61  $host = strtolower(parse_url($url, PHP_URL_HOST));
62  if (is_int(strpos($url, ".localhost")) || trim($host) == "localhost") {
63  return true;
64  }
65  $ip = gethostbyname($host);
66 
67  $res = filter_var(
68  $ip,
69  FILTER_VALIDATE_IP,
70  FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE
71  );
72  if (in_array($res, [false, ""])) {
73  return true;
74  }
75  return false;
76  }
foreach($_POST as $key=> $value) $res
$url

◆ read()

ilExternalFeedBlock::read ( )

Read item from database.

Definition at line 112 of file class.ilExternalFeedBlock.php.

References $db, $ilDB, $query, ilCustomBlock\getId(), and setFeedUrl().

Referenced by __construct().

113  {
114  $ilDB = $this->db;
115 
116  parent::read();
117 
118  $query = "SELECT * FROM il_external_feed_block WHERE id = " .
119  $ilDB->quote($this->getId(), "integer");
120  $set = $ilDB->query($query);
121  $rec = $ilDB->fetchAssoc($set);
122 
123  $this->setFeedUrl($rec["feed_url"]);
124  }
setFeedUrl($a_feed_url)
Set FeedUrl.
$query
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setFeedUrl()

ilExternalFeedBlock::setFeedUrl (   $a_feed_url)

Set FeedUrl.

Parameters
string$a_feed_urlURL of the external news feed.

Definition at line 49 of file class.ilExternalFeedBlock.php.

Referenced by read().

50  {
51  $this->feed_url = $a_feed_url;
52  }
+ Here is the caller graph for this function:

◆ update()

ilExternalFeedBlock::update ( )

Update item in database.

Definition at line 130 of file class.ilExternalFeedBlock.php.

References $db, $ilDB, $query, getFeedUrl(), ilCustomBlock\getId(), and League\Flysystem\Adapter\Polyfill\update().

131  {
132  $ilDB = $this->db;
133 
134  parent::update();
135 
136  $query = "UPDATE il_external_feed_block SET " .
137  " feed_url = " . $ilDB->quote($this->getFeedUrl(), "text") .
138  " WHERE id = " . $ilDB->quote($this->getId(), "integer");
139 
140  $ilDB->manipulate($query);
141  }
$query
update($pash, $contents, Config $config)
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilExternalFeedBlock::$db
protected

Definition at line 17 of file class.ilExternalFeedBlock.php.

Referenced by create(), delete(), read(), and update().

◆ $feed_url

ilExternalFeedBlock::$feed_url
protected

Definition at line 25 of file class.ilExternalFeedBlock.php.

Referenced by getFeedUrl().

◆ $log

ilExternalFeedBlock::$log
protected

Definition at line 22 of file class.ilExternalFeedBlock.php.

Referenced by create().


The documentation for this class was generated from the following file: