Other
Writting a plug-in
<?php
if (!defined('RSSFIT_ROOT_PATH')) {
exit();
}
/**
* Class RssfitSample
*/
class RssfitSample
{
public $dirname = 'sample';
public $modname;
public $grab;
public $module; // optional, see line 71
/**
* @return bool
*/
public function loadModule()
{
$mod = $GLOBALS['module_handler']->getByDirname($this->dirname);
if (!$mod || !$mod->getVar('isactive')) {
return false;
}
$this->modname = $mod->getVar('name');
$this->module = $mod; // optional, remove this line if there is nothing
// to do with module info when grabbing entries
return $mod;
}
/**
* @param $obj
* @return bool
*/
public function &grabEntries(&$obj)
{
global $xoopsDB;
$myts = \MyTextSanitizer::getInstance();
$ret = false;
$i = 0;
// The following example code grabs the latest entries from the module MyLinks
$sql = 'SELECT l.lid, l.cid, l.title, l.date, t.description FROM ' . $xoopsDB->prefix('mylinks_links') . ' l, ' . $xoopsDB->prefix('mylinks_text') . ' t WHERE l.status > 0 AND l.lid = t.lid ORDER BY date DESC';
$result = $xoopsDB->query($sql, $this->grab, 0);
while ($row = $xoopsDB->fetchArray($result)) {
$link = XOOPS_URL . '/modules/' . $this->dirname . '/singlelink.php?cid=' . $row['cid'] . '&lid=' . $row['lid'];
/*
* Required elements of an RSS item
*/
// 1. Title of an item
$ret[$i]['title'] = $row['title'];
// 2. URL of an item
$ret[$i]['link'] = $link;
// 3. Item modification date, must be in Unix time format
$ret[$i]['timestamp'] = $row['date'];
// 4. The item synopsis, or description, whatever
$ret[$i]['description'] = $myts->displayTarea($row['description']);
/*
* Optional elements of an RSS item
*/
// 5. The item synopsis, or description, whatever
$ret[$i]['guid'] = $link;
// 6. A string + domain that identifies a categorization taxonomy
$ret[$i]['category'] = $this->modname;
$ret[$i]['domain'] = XOOPS_URL . '/modules/' . $this->dirname . '/';
// 7. extra tags examples
$ret[$i]['extras'] = [];
// 7a. without attribute
$ret[$i]['extras']['author'] = ['content' => 'aabbc@c.com'];
// 7b. with attributes
$ret[$i]['extras']['enclosure']['attributes'] = ['url' => 'url-to-any-file', 'length' => 1024000, 'type' => 'audio/mpeg'];
$i++;
}
return $ret;
}
}When RSSFit met Podcast
Externals
Last updated