Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RSS feed for GetSimple
#3
You can see it here http://www.manage-projects.ru

This is buildrss.php. I placed it in theme/yourthemename/plugins

Code:
<?php

//  Begin Function
function createRSSFile($post_title,$post_description,$post_link,$guid)
{
    $returnITEM = "<item>\n";
    $returnITEM .= "<guid>".$guid."</guid>\n";
    # this will return the Title of the Article.
    $returnITEM .= "<title>".$post_title."</title>\n";
    # this will return the Description of the Article.
    $returnITEM .= "<description>".$post_description."</description>\n";
    # this will return the URL to the post.
    $returnITEM .= "<link>".$post_link."</link>\n";
    $returnITEM .= "</item>\n";
    return $returnITEM;
}


// rss_categories - category to rss
// items number
// lenght of descrip)
function buildrssfile($rss_categories,$itemsnumber,$descl)
{
    if (empty($rss_categories)) { $rss_categories    ='news'; }
    if (empty($descl)) { $descl    =256; }
    if (empty($itemsnumber)) { $itemsnumber    =5; }
    
    $TITLE_OF_YOUR_RSS_FEED = "Управление проектами";
    $DESCRIPTION_OF_YOUR_FEED = "Все об управлении проектами в одном месте";
    
    $path     = tsl('data/pages/');
    $counter = '0';
    $table = '';

    //display all pages
    $filenames = getFiles($path);
    
    $count="0";
    $pagesArray = array();
    if (count($filenames) != 0) {
        foreach ($filenames as $file) {
            if (isFile($file, $path, 'xml')) {
                $data = getXML($path .$file);
                if ($data->parent == $rss_categories) {
                    $status = $data->menuStatus;
                    //$pagesArray[$count]['title'] = $data->title;
                    $pagesArray[$count]['title'] = html_entity_decode($data->title, ENT_QUOTES, 'UTF-8');
                    $pagesArray[$count]['parent'] = $data->parent;
                    $pagesArray[$count]['menuStatus'] = $data->menuStatus;
                    $pagesArray[$count]['private'] = $data->private;
                    $pagesArray[$count]['content'] = htmlspecialchars($data->content, ENT_QUOTES, 'UTF-8');
                    //$pagesArray[$count]['content'] = $data->content;
                    if ($data->parent != '') {
                        $parentdata = getXML($path . $data->parent .'.xml');
                        $parentTitle = $parentdata->title;
                        $pagesArray[$count]['sort'] = $parentTitle .' '. $data->title;
                    } else {
                        $pagesArray[$count]['sort'] = $data->title;
                    }
                    $pagesArray[$count]['url'] = $data->url;
                    $pagesArray[$count]['date'] = $data->pubDate;
                    $parentTitle = '';
                    $count++;
                }
            }
        }
    }
    


// Lets build the page
$filename = "feeds/index.xml";
$rootURL = "http://www.manage-projects.ru/feeds/";
$webroot = "http://www.manage-projects.ru/";
$latestBuild = date("r");
// Lets define the the type of doc we're creating.
$createXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$createXML .= "<rss version=\"0.92\">\n";
$createXML .= "<channel>
    <title>".$TITLE_OF_YOUR_RSS_FEED."</title>
    <link>".$rootURL."</link>
    <description>".$DESCRIPTION_OF_YOUR_FEED."</description>
    <lastBuildDate>".$latestBuild."</lastBuildDate>
    <docs></docs>
    <language>ru</language>
";


// Lets get the results
$ff=0;
while ($pagesArray[$ff]<>'') {
    $item = $pagesArray[$ff];
    if (empty($item['parent'])) {
        $page = $webroot.$item['url'];    
    } else {
        $page = $webroot.$item['parent']."/".$item['url'];
    }
    $pieces = explode(" ", $item['content']);
    $feedcontent = '';
    $rr=0;
    while (strlen($feedcontent)<$descl) {
        $feedcontent .= $pieces[$rr]." ";
        $rr++;
    }
    $description = $feedcontent;
    $title = $item['title'];
    $guid = $item['date'];
    $createXML .= createRSSFile($title,$description,$page,$guid);
    $ff++;
}

$createXML .= "</channel>\n </rss>";
// Finish it up
$filehandle = fopen($filename,"w") or die("Can't open the file");
fwrite($filehandle,$createXML);
fclose($filehandle);
echo "XML Sitemap updated!";

}
?>

I include it in function.php in theme.
Code:
<?php
require_once('plugins/buildrss.php');
?>

Than in template.php i put next code
Code:
$generatRSS = $_GET['rss'];

if ($generatRSS==1) {
    buildrssfile('news',5,256);    
}

where first parametr - name of parent page for news for example.
second - quantity of items add in rss (it is not work yet Big Grin )
third - qty of symbols in description.

I make cron task to generate rss file.
Reply


Messages In This Thread
RSS feed for GetSimple - by Alexey - 2009-10-24, 08:49:14
RSS feed for GetSimple - by ccagle8 - 2009-10-24, 10:56:34
RSS feed for GetSimple - by Alexey - 2009-10-24, 23:08:39
RSS feed for GetSimple - by Alexey - 2009-10-24, 23:21:36
RSS feed for GetSimple - by oobx - 2010-01-26, 02:20:51
RSS feed for GetSimple - by Alexey - 2010-01-26, 06:44:47
RSS feed for GetSimple - by madguy - 2010-02-18, 12:38:11
RSS feed for GetSimple - by Alexey - 2010-02-18, 12:58:11
RSS feed for GetSimple - by Zegnåt - 2010-02-18, 23:53:49
RSS feed for GetSimple - by madguy - 2010-02-19, 02:53:13
RSS feed for GetSimple - by madguy - 2010-02-19, 10:01:18
RSS feed for GetSimple - by Alexey - 2010-02-24, 04:09:04
RSS feed for GetSimple - by Hopes - 2010-04-09, 05:08:36
RSS feed for GetSimple - by webget - 2010-06-03, 09:03:11
RSS feed for GetSimple - by Zegnåt - 2010-06-03, 16:51:13
RSS feed for GetSimple - by Carlos - 2010-06-03, 17:42:51
RSS feed for GetSimple - by Ouisri - 2010-08-28, 14:29:32
RSS feed for GetSimple - by allimitedition - 2011-05-19, 22:53:53
RSS feed for GetSimple - by mvlcek - 2011-05-20, 06:39:41
RSS feed for GetSimple - by soawesomejohn - 2011-12-01, 08:13:56
RSS feed for GetSimple - by soawesomejohn - 2011-12-01, 08:23:25
RSS feed for GetSimple - by soawesomejohn - 2011-12-01, 08:28:55
RSS feed for GetSimple - by n00dles101 - 2011-12-01, 08:35:18
RSS feed for GetSimple - by mvlcek - 2011-12-01, 17:56:50
RSS feed for GetSimple - by Oleg06 - 2011-12-01, 18:32:45



Users browsing this thread: 1 Guest(s)