add('name', PLUGIN_DELICIOUS_N); $propbag->add('description', PLUGIN_DELICIOUS_D); $propbag->add('author', 'Riscky'); $propbag->add('version', '0.8.1'); $propbag->add('requirements', array( 'serendipity' => '0.8', 'smarty' => '2.6.7', 'php' => '4.1.0' )); $propbag->add('stackable', true); $propbag->add('configuration', array( 'sidebarTitle', 'deliciousID', 'displayNumber', 'cacheTime', 'moreLink', 'morelink_text' )); $propbag->add('groups', array('FRONTEND_EXTERNAL_SERVICES')); } function introspect_config_item($name, &$propbag) { switch($name) { case 'sidebarTitle': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_DELICIOUS_TITLE_N); $propbag->add('description', PLUGIN_DELICIOUS_TITLE_D); $propbag->add('default', 'My del.icio.us'); break; case 'deliciousID': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_DELICIOUS_USERNAME_N); $propbag->add('description', PLUGIN_DELICIOUS_USERNAME_D); $propbag->add('default', 'riscky'); break; case 'morelink_text': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_DELICIOUS_MORELINK_T); $propbag->add('description', ''); $propbag->add('default', PLUGIN_DELICIOUS_MORELINK); break; case 'displayNumber': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_DELICIOUS_DISPLAYNUMBER_N); $propbag->add('description', PLUGIN_DELICIOUS_DISPLAYNUMBER_D); $propbag->add('default', '30'); break; case 'cacheTime': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_DELICIOUS_CACHETIME_N); $propbag->add('description', PLUGIN_DELICIOUS_CACHETIME_D); $propbag->add('default', 1); break; case 'moreLink': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_DELICIOUS_MORELINK_N); $propbag->add('description', PLUGIN_DELICIOUS_MORELINK_D); $propbag->add('default', 'true'); break; default: return false; } return true; } function generate_content(&$title) { global $serendipity; $title = $this->get_config('sidebarTitle'); $deliciousID = $this->get_config('deliciousID'); $moreLink = $this->get_config('moreLink'); if (empty($deliciousID)) { return false; } if ($this->get_config('displayNumber') < 30 && $this->get_config('displayNumber') >= 1) { $displayNumber = $this->get_config('displayNumber'); } else { $displayNumber = 30; } if ($this->get_config('cacheTime') > 0) { $cacheTime = ($this->get_config('cacheTime') * 3600); } else { $cacheTime = 3600 + 1 ; } $gDeliciousURL = 'http://del.icio.us/'; $gDeliciousCacheLoc = $serendipity['serendipityPath'] . '/templates_c/delicious_'; // safe write location... need to have local abilit $parsedCache = $gDeliciousCacheLoc . md5($deliciousID) . '.cache'; if(!is_file($parsedCache) || ((mktime() - filectime($parsedCache)) > $cacheTime)) { if (!is_dir($gDeliciousCacheLoc) && !mkdir($gDeliciousCacheLoc, 0775)) { print 'Try to chmod go+rwx - permissions are wrong.'; } require_once 'Onyx/RSS.php'; $deliciousFeed = new Onyx_RSS(); //$deliciousFeed->setCachePath($gDeliciousCacheLoc); //$deliciousFeed->setExpiryTime($cacheTime); //$deliciousFeed->parse($gDeliciousURL .'rss/' . $deliciousID, md5($deliciousID) . '.dat'); $deliciousFeed->parse($gDeliciousURL . 'rss/' . $deliciousID); if( $deliciousFeed->numItems() >= 1 ) { $fileHandle = @fopen($parsedCache, 'w'); if ($fileHandle) { $deliciousContent = ''; fwrite($fileHandle, $deliciousContent); fclose($fileHandle); print $deliciousContent; } else { print '

A del.icio.us error occured!
' . 'Error Message: unable to make a delicious cache file: ' . $parsedCache . '!

'; } } elseif (is_file($parsedCache)) { print file_get_contents($parsedCache); } else { print '

A del.icio.us error occured!
' . 'Error Message: rss failed

'; } } else { print file_get_contents($parsedCache); } if (serendipity_db_bool($moreLink)) { print '

' . $this->get_config('morelink_text') . '

'; } } } function delicious_clean_htmlspecialchars($given, $quote_style = ENT_QUOTES) { return htmlspecialchars(html_entity_decode($given, $quote_style, LANG_CHARSET), $quote_style, LANG_CHARSET); } ?>