Commit 634be6e00ceeb8cfe0ccddfd38d67e455fed331f

  • avatar
  • blaise.ca <balleyne @d…b.privatedns.com>
  • Fri Dec 04 06:02:14 CET 2009
Tracking class paths, adding support for using custom images
.gitignore
(1 / 1)
  
1db_settings.php
1settings.php
  
1<?php
2$db_host = 'localhost';
3$db_name = '';
4$db_user = '';
5$db_passwd = '';
Binary files differ
  
66
77class Entry{
88 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 }
1023
1124 function Entry($data) {
1225 foreach ($data as $key => $value) {
8383 }
8484
8585 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"/>';
8797 }
8898
8999 function getSingleTitle(){
main.php
(9 / 6)
  
1212//function __autoload($class_name){
1313// require_once 'modules/' . strtolower($class_name) . '.class.php';
1414//}
15require_once('entry.class.php');
16include('modules.php');
15require('entry.class.php');
16require('settings.php');
17require('modules.php');
18
19define('ABS_PATH', dirname(__FILE__));
20define('DEFAULT_ENTRY_ICON', '/default_icon.png');
21
1722/**
1823 * Load db settings and connect.
1924 * @return database handling
2025 */
2126function 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);
2528 if(!$dbh)
2629 die('Could not connect: ' . mysql_error());
27 if(!mysql_select_db($db_name, $dbh))
30 if(!mysql_select_db(DB_NAME, $dbh))
2831 die('Could not select database: ' . mysql_error());
2932
3033 return $dbh;
modules.php
(16 / 5)
  
11<?php
22
33// Check the 'modules' directory...
4$modules_dir = $_SERVER['DOCUMENT_ROOT'].'/feeds/modules';
4$modules_dir = dirname(__FILE__).'/modules';
55
6
76$classes = array(
87 'main' => array(),
98 'sub' => array(),
3737 }
3838}
3939
40// Ok, now actually load them.
40// Ok, now actually load them, and store the classpaths.
41$declared_classes = get_declared_classes();
4142foreach($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;
4456 }
4557}
  
1<?php
2define('DB_HOST', 'localhost');
3define('DB_NAME', '');
4define('DB_USER', '');
5define('DB_PASS', '');
6define('WEBROOT', '/feeds');