Campustream 1.0
A social network MQP for WPI
|
00001 <? 00002 00007 class Newseventcategory_Model /* extends ActiveRecord... or does it? */ { 00008 private static $categories = array( 00009 0 => array( 00010 'type' => 'imported', 00011 'name' => 'Imported News', 00012 'slug' => 'imported' 00013 ), 00014 00015 1 => array( 00016 'type' => 'news', 00017 'name' => 'General WPI News', 00018 'slug' => 'general' 00019 ), 00020 00021 2 => array( 00022 'type' => 'news', 00023 'name' => 'Greek Life', 00024 'slug' => 'greek' 00025 ), 00026 00027 3 => array( 00028 'type' => 'news', 00029 'name' => 'Academics', 00030 'slug' => 'academics' 00031 ), 00032 00033 4 => array( 00034 'type' => 'news', 00035 'name' => 'Sports', 00036 'slug' => 'sports' 00037 ), 00038 00039 5 => array( 00040 'type' => 'news', 00041 'name' => 'Club/Organization News', 00042 'slug' => 'club_organization' 00043 ), 00044 00045 6 => array( 00046 'type' => 'news', 00047 'name' => 'World News', 00048 'slug' => 'world' 00049 ), 00050 00051 7 => array( 00052 'type' => 'news', 00053 'name' => 'Miscellaneous', 00054 'slug' => 'misc' 00055 ), 00056 00057 8 => array( 00058 'type' => 'event', 00059 'name' => 'General WPI Events', 00060 'slug' => 'general' 00061 ), 00062 00063 9 => array( 00064 'type' => 'event', 00065 'name' => 'Greek Life', 00066 'slug' => 'greek' 00067 ), 00068 00069 10 => array( 00070 'type' => 'event', 00071 'name' => 'Academics', 00072 'slug' => 'academics' 00073 ), 00074 00075 11 => array( 00076 'type' => 'event', 00077 'name' => 'Sports', 00078 'slug' => 'sports' 00079 ), 00080 00081 12 => array( 00082 'type' => 'event', 00083 'name' => 'Club/Organization Events', 00084 'slug' => 'club_organization' 00085 ), 00086 00087 13 => array( 00088 'type' => 'event', 00089 'name' => 'Social Event', 00090 'slug' => 'social' 00091 ), 00092 00093 14 => array( 00094 'type' => 'event', 00095 'name' => 'Miscellaneous Events', 00096 'slug' => 'misc' 00097 ), 00098 ); 00099 00103 public function load($cat_id) { 00104 $this->id = $cat_id; 00105 00106 foreach (self::$categories[$cat_id] as $key=>$val) { 00107 $this->$key = $val; 00108 } 00109 } 00110 00114 public static function getByType($type) { 00115 $cats = array(); 00116 foreach (self::$categories as $cat_id => $cat) { 00117 if ($cat['type'] == $type) { 00118 $cats[] = array( 00119 'id' => $cat_id, 00120 'name' => $cat['name'], 00121 'slug' => $cat['slug'] 00122 ); 00123 } 00124 } 00125 00126 return $cats; 00127 } 00128 00132 public static function getBySlug($type, $slug) { 00133 foreach (self::$categories as $id => $cat) { 00134 if ($cat['type'] == $type && $cat['slug'] == $slug) { 00135 $model = new Newseventcategory_Model(); 00136 $model->load($id); 00137 00138 return $model; 00139 } 00140 } 00141 } 00142 }