Commit 634be6e00ceeb8cfe0ccddfd38d67e455fed331f
- Diff rendering mode:
- inline
- side by side
.gitignore
(1 / 1)
|   | |||
| 1 | db_settings.php | ||
| 1 | settings.php |
db_settings_sample.php
(0 / 5)
|   | |||
| 1 | <?php | ||
| 2 | $db_host = 'localhost'; | ||
| 3 | $db_name = ''; | ||
| 4 | $db_user = ''; | ||
| 5 | $db_passwd = ''; |
default_icon.png
(5 / 0)
Binary files differ
entry.class.php
(25 / 2)
|   | |||
| 6 | 6 | ||
| 7 | 7 | class Entry{ | |
| 8 | 8 | var $canHaveMultiples = FALSE; | |
| 9 | var $img = 'http://blaise.ca/images/icons/rss.png'; | ||
| 9 | |||
| 10 | public static $classpath = array(); | ||
| 11 | |||
| 12 | public static function add_classpath($class, $path) { | ||
| 13 | self::$classpath[$path][] = $class; | ||
| 14 | } | ||
| 15 | |||
| 16 | public static function get_classpath($class) { | ||
| 17 | foreach (self::$classpath as $path => $classes) { | ||
| 18 | if (in_array($class, $classes)) { | ||
| 19 | return $path; | ||
| 20 | } | ||
| 21 | } | ||
| 22 | } | ||
| 10 | 23 | ||
| 11 | 24 | function Entry($data) { | |
| 12 | 25 | foreach ($data as $key => $value) { | |
| … | … | ||
| 83 | 83 | } | |
| 84 | 84 | ||
| 85 | 85 | function getIcon(){ | |
| 86 | return '<img src="'.$this->img.'" alt="'.$this->feed_title.'" title="'.$this->feed_title.'"/>'; | ||
| 86 | if ($this->img) { | ||
| 87 | $img = $this->img; | ||
| 88 | } else { | ||
| 89 | $class_name = get_class($this); | ||
| 90 | $class_dir = dirname( Entry::get_classpath($class_name) ); | ||
| 91 | $module_icon_path = $class_dir . '/' . strtolower($class_name) . '.png'; | ||
| 92 | |||
| 93 | $img = WEBROOT . (file_exists($module_icon_path) ? str_replace(ABS_PATH, '', $module_icon_path) : DEFAULT_ENTRY_ICON); | ||
| 94 | } | ||
| 95 | |||
| 96 | return '<img src="'.$img.'" alt="'.$this->feed_title.'" title="'.$this->feed_title.'" class="feed-icon"/>'; | ||
| 87 | 97 | } | |
| 88 | 98 | ||
| 89 | 99 | function getSingleTitle(){ |
main.php
(9 / 6)
|   | |||
| 12 | 12 | //function __autoload($class_name){ | |
| 13 | 13 | // require_once 'modules/' . strtolower($class_name) . '.class.php'; | |
| 14 | 14 | //} | |
| 15 | require_once('entry.class.php'); | ||
| 16 | include('modules.php'); | ||
| 15 | require('entry.class.php'); | ||
| 16 | require('settings.php'); | ||
| 17 | require('modules.php'); | ||
| 18 | |||
| 19 | define('ABS_PATH', dirname(__FILE__)); | ||
| 20 | define('DEFAULT_ENTRY_ICON', '/default_icon.png'); | ||
| 21 | |||
| 17 | 22 | /** | |
| 18 | 23 | * Load db settings and connect. | |
| 19 | 24 | * @return database handling | |
| 20 | 25 | */ | |
| 21 | 26 | function db_connect() { | |
| 22 | require('db_settings.php'); | ||
| 23 | |||
| 24 | $dbh = @mysql_connect($db_host, $db_user, $db_passwd); | ||
| 27 | $dbh = @mysql_connect(DB_HOST, DB_USER, DB_PASS); | ||
| 25 | 28 | if(!$dbh) | |
| 26 | 29 | die('Could not connect: ' . mysql_error()); | |
| 27 | if(!mysql_select_db($db_name, $dbh)) | ||
| 30 | if(!mysql_select_db(DB_NAME, $dbh)) | ||
| 28 | 31 | die('Could not select database: ' . mysql_error()); | |
| 29 | 32 | ||
| 30 | 33 | return $dbh; |
modules.php
(16 / 5)
|   | |||
| 1 | 1 | <?php | |
| 2 | 2 | ||
| 3 | 3 | // Check the 'modules' directory... | |
| 4 | $modules_dir = $_SERVER['DOCUMENT_ROOT'].'/feeds/modules'; | ||
| 4 | $modules_dir = dirname(__FILE__).'/modules'; | ||
| 5 | 5 | ||
| 6 | |||
| 7 | 6 | $classes = array( | |
| 8 | 7 | 'main' => array(), | |
| 9 | 8 | 'sub' => array(), | |
| … | … | ||
| 37 | 37 | } | |
| 38 | 38 | } | |
| 39 | 39 | ||
| 40 | // Ok, now actually load them. | ||
| 40 | // Ok, now actually load them, and store the classpaths. | ||
| 41 | $declared_classes = get_declared_classes(); | ||
| 41 | 42 | foreach($classes as $type) { | |
| 42 | foreach($type as $class) { | ||
| 43 | include($class); | ||
| 43 | foreach($type as $path) { | ||
| 44 | // Load the file | ||
| 45 | include($path); | ||
| 46 | |||
| 47 | // Check for new declared classes... | ||
| 48 | $new_declared_classes = get_declared_classes(); | ||
| 49 | foreach($new_declared_classes as $new_class) { | ||
| 50 | if (!in_array($new_class, $declared_classes)) { | ||
| 51 | // ... and store them. | ||
| 52 | Entry::add_classpath($new_class, $path); | ||
| 53 | } | ||
| 54 | } | ||
| 55 | $declared_classes = $new_declared_classes; | ||
| 44 | 56 | } | |
| 45 | 57 | } |
settings_sample.php
(6 / 0)
|   | |||
| 1 | <?php | ||
| 2 | define('DB_HOST', 'localhost'); | ||
| 3 | define('DB_NAME', ''); | ||
| 4 | define('DB_USER', ''); | ||
| 5 | define('DB_PASS', ''); | ||
| 6 | define('WEBROOT', '/feeds'); |

