| Current Path : /home/juvelize/www/libraries/tsgrabber/ |
| Current File : /home/juvelize/www/libraries/tsgrabber/feeds.php |
<?php
/*
* TsGrabber - Grabber RSS feeds/Грабер RSS-лент.
* Site/Сайт: http://tsiba.net
* E-mail/Э-почта: info@tsiba.net
* © 2012 tsiba.net
*/
?>
<?php
// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die();
class TSFeed extends JObject {
public $id;
public $title;
public $url;
public $public;
public $featured;
public $menu;
public $category;
public $link;
public $linktext;
public $user;
public $update;
public $minutes;
public $lastupdate;
public $block;
function __construct($identifier = 0)
{
if ($identifier) {
$this->load($identifier);
} else {
$this->id = 0;
$this->title = '';
$this->url = '';
$this->public = 0;
$this->featured = 0;
$this->menu = 0;
$this->category = 0;
$this->link = 0;
$this->linktext = '';
$this->user = 0;
$this->update = 0;
$this->minutes = '';
$this->lastupdate = '';
$this->block = 0;
}
}
public function load($id)
{
$db =& JFactory::getDBO();
$query = "SELECT * FROM #__tsgrabber_feeds WHERE id='".$id."'";
$db->setQuery($query);
list($rec) = $db->loadObjectList();
$this->id = $rec->id;
$this->title = $rec->title;
$this->url = $rec->url;
$this->public = $rec->public;
$this->featured = $rec->featured;
$this->menu = $rec->menu;
$this->category = $rec->category;
$this->link = $rec->link;
$this->linktext = $rec->linktext;
$this->user = $rec->user;
$this->update = $rec->update;
$this->minutes = $rec->minutes;
$this->lastupdate = $rec->lastupdate;
$this->block = $rec->block;
}
public function save()
{
$db =& JFactory::getDBO();
if ($this->id) {
$query = 'UPDATE';
} else {
$query = 'INSERT INTO';
}
$query .= ' `#__tsgrabber_feeds` SET'
. " `title` = '{$db->getEscaped($this->title)}', "
. " `url` = '{$db->getEscaped($this->url)}', "
. " `public` = '{$db->getEscaped($this->public)}', "
. " `featured` = '{$db->getEscaped($this->featured)}', "
. " `menu` = '{$db->getEscaped($this->menu)}', "
. " `category` = '{$db->getEscaped($this->category)}', "
. " `link` = '{$db->getEscaped($this->link)}', "
. " `linktext` = '{$db->getEscaped($this->linktext)}', "
. " `user` = '{$db->getEscaped($this->user)}', "
. " `update` = '{$db->getEscaped($this->update)}', "
. " `minutes` = '{$db->getEscaped($this->minutes)}', "
. " `lastupdate` = '{$db->getEscaped($this->lastupdate)}', "
. " `block` = '{$db->getEscaped($this->block)}'";
if ($this->id) {
$query .= " WHERE `id` = {$this->id}";
}
$db->setQuery($query);
if (!$db->query()) {
return false;
}
if($this->id==0)
$this->id = $db->insertid();
return $this->id;
}
public function bind($data)
{
$this->id = $data['id'];
$this->title = $data['title'];
$this->url = $data['url'];
$this->public = $data['public'];
$this->featured = ($data['featured']=='on') ? "1" : "0";
$this->menu = $data['menu'];
$this->category = $data['category'];
$this->link = ($data['link']=='on') ? "1" : "0";
$this->linktext = $data['linktext'];
$this->user = $data['user'];
$this->update = $data['update'];
$this->minutes = $data['minutes'];
if($data['lastupdate']==''){
$this->lastupdate = $this->lastupdate;
}else{
$this->lastupdate = $data['lastupdate'];
}
$this->block = ($data['block']=='on') ? "1" : "0";
}
function truncateText($string, $limit, $break = ".", $pad = "...")
{
if (strlen($string) <= $limit) return $string;
if (false !== ($breakpoint = mb_strpos($string, $break, $limit))) {
if ($breakpoint < strlen($string) - 1) {
$string = mb_substr($string, 0, $breakpoint) . $pad;
}
}
return $string;
}
}