Changeset 639 for plugins/blogroll/trunk/blogroll.plugin.php
- Timestamp:
- 06/25/08 03:47:56 (5 months ago)
- Files:
-
- 1 modified
-
plugins/blogroll/trunk/blogroll.plugin.php (modified) (27 diffs)
Legend:
- Unmodified
- Added
- Removed
-
plugins/blogroll/trunk/blogroll.plugin.php
r521 r639 2 2 /* 3 3 * Blogroll Plugin 4 * Usage: <?php $theme->show_blogroll(); ?> 5 * A sample blogroll.php template is included with the plugin. This can be copied to your 4 * Usage: <?php $theme->show_blogroll(); ?> 5 * A sample blogroll.php template is included with the plugin. This can be copied to your 6 6 * active theme and modified to fit your preference. 7 7 * … … 20 20 const VERSION= '0.5-beta'; 21 21 const DB_VERSION= 003; 22 22 23 23 public function info() 24 24 { 25 25 return array( 26 'name' => 'Blogroll',27 'version' => self::VERSION,28 'url' => 'http://wiki.habariproject.org/en/plugins/blogroll',29 'author' => 'Habari Community',30 'authorurl' => 'http://habariproject.org/',31 'license' => 'Apache License 2.0',32 'description' => 'Displays a blogroll on your blog'26 'name' => 'Blogroll', 27 'version' => self::VERSION, 28 'url' => 'http://wiki.habariproject.org/en/plugins/blogroll', 29 'author' => 'Habari Community', 30 'authorurl' => 'http://habariproject.org/', 31 'license' => 'Apache License 2.0', 32 'description' => 'Displays a blogroll on your blog' 33 33 ); 34 34 } 35 35 36 36 public function action_plugin_activation( $file ) 37 37 { … … 40 40 DB::register_table( 'bloginfo' ); 41 41 DB::register_table( 'tag2blog' ); 42 42 43 43 if ( ! CronTab::get_cronjob( 'blogroll:update' ) ) { 44 44 CronTab::add_hourly_cron( 'blogroll:update', 'blogroll_update_cron', 'Updates the blog updated timestamp from weblogs.com' ); 45 45 } 46 46 47 47 Options::set( 'blogroll__db_version', self::DB_VERSION ); 48 48 Options::set( 'blogroll__use_updated', true ); … … 51 51 Options::set( 'blogroll__direction', 'ASC' ); 52 52 Options::set( 'blogroll__list_title', 'Blogroll' ); 53 53 54 54 if ( $this->install_db_tables() ) { 55 55 Session::notice( _t( 'Created the Blogroll database tables.', 'blogroll' ) ); … … 60 60 } 61 61 } 62 62 63 63 public function action_plugin_deactivation( $file ) 64 64 { … … 68 68 } 69 69 } 70 70 71 71 public function install_db_tables() 72 72 { … … 107 107 updated VARCHAR(12) NOT NULL, 108 108 rel VARCHAR(255) NOT NULL, 109 description TEXT ,109 description TEXT 110 110 ); 111 111 CREATE TABLE " . DB::table('bloginfo') . " ( … … 119 119 tag_id INTEGER UNSIGNED NOT NULL, 120 120 blog_id INTEGER UNSIGNED NOT NULL, 121 PRIMARY KEY (tag_id, post_id)121 PRIMARY KEY (tag_id, blog_id) 122 122 ); 123 123 CREATE INDEX IF NOT EXISTS tag2blog_blog_id ON " . DB::table('tag2blog') . "(blog_id);"; … … 126 126 return DB::dbdelta( $schema ); 127 127 } 128 128 129 129 public function action_update_check() 130 130 { 131 131 Update::add( 'blogroll', '0420cf10-db83-11dc-95ff-0800200c9a66', $this->info->version ); 132 132 } 133 133 134 134 public function action_init() 135 135 { … … 137 137 DB::register_table( 'bloginfo' ); 138 138 DB::register_table( 'tag2blog' ); 139 139 140 140 if ( Options::get( 'blogroll__db_version' ) && self::DB_VERSION > Options::get( 'blogroll__db_version' ) ) { 141 141 $this->install_db_tables(); … … 144 144 } 145 145 } 146 146 147 147 public function filter_plugin_config( $actions, $plugin_id ) 148 148 { 149 149 150 150 if ( $this->plugin_id() == $plugin_id ){ 151 151 $actions[]= _t( 'Configure', 'blogroll' ); … … 153 153 return $actions; 154 154 } 155 155 156 156 public function action_plugin_ui( $plugin_id, $action ) 157 157 { … … 160 160 case _t( 'Configure', 'blogroll' ): 161 161 $form= new FormUI( 'blogroll' ); 162 162 163 163 $title= $form->append( 'text', 'list_title', 'option:blogroll__list_title', _t( 'List title: ', 'blogroll' ) ); 164 164 165 165 $max= $form->append( 'text', 'max_links', 'option:blogroll__max_links', _t( 'Max. displayed links: ', 'blogroll') ); 166 167 $sort_bys= array_merge( 166 167 $sort_bys= array_merge( 168 168 array_combine( array_keys( Blog::default_fields() ), array_map( 'ucwords', array_keys( Blog::default_fields() ) ) ), 169 169 array( 'random' => _t('Randomly', 'blogroll') ) 170 170 ); 171 171 $sortby= $form->append( 'select', 'sort_by', 'option:blogroll__sort_by', _t( 'Sort By: ', 'blogroll'), $sort_bys ); 172 172 173 173 $orders= array( 'ASC' => _t('Ascending' ,'blogroll'), 'DESC' => _t('Descending' ,'blogroll') ); 174 174 $order= $form->append( 'select', 'direction', 'option:blogroll__direction', _t( 'Order: ', 'blogroll'), $orders ); 175 175 176 176 $update= $form->append( 'checkbox', 'use_update', 'option:blogroll__use_update', _t( 'Use Weblogs.com to get updates? ', 'blogroll') ); 177 177 178 178 $form->append( 'submit', 'save', 'Save' ); 179 179 $form->out(); … … 182 182 } 183 183 } 184 184 185 185 public function filter_adminhandler_post_loadplugins_main_menu( $menus ) 186 186 { … … 189 189 return $menus; 190 190 } 191 191 192 192 public function action_admin_theme_post_blogroll_manage( $handler, $theme ) 193 193 { 194 194 extract( $handler->handler_vars ); 195 195 196 196 if ( isset( $change ) && isset( $blog_ids ) ) { 197 197 $count= count( $blog_ids ); 198 198 $blog_ids= (array) $blog_ids; 199 199 200 200 switch ( $change ) { 201 201 case 'delete': … … 238 238 } 239 239 } 240 240 241 241 Utils::redirect( URL::get( 'admin', 'page=blogroll_manage' ) ); 242 242 exit; 243 243 } 244 244 245 245 public function action_admin_theme_post_blogroll_publish( $handler, $theme ) 246 246 { 247 247 $params= array_intersect_key( $handler->handler_vars, array_flip( array('name', 'url', 'feed', 'description', 'owner', 'tags') ) ); 248 248 extract( $handler->handler_vars ); 249 249 250 250 if ( !empty( $quick_link ) ) { 251 251 $link= $quick_link; … … 265 265 } 266 266 } 267 267 268 268 if ( ( empty( $params['name'] ) || empty( $params['url'] ) ) ) { 269 269 Session::error( _t('Blog Name and URL are required feilds.', 'blogroll') ); … … 292 292 } 293 293 } 294 294 295 295 if ( !empty( $quick_link ) && !empty( $redirect_to ) ) { 296 296 $msg= sprintf( _t('Successfully added blog %s. Now going back.', 'blogroll'), htmlspecialchars( $blog->name ) ); … … 300 300 exit; 301 301 } 302 302 303 303 Utils::redirect( URL::get( 'admin', 'page=blogroll_publish' ) ); 304 304 exit; 305 305 } 306 306 307 307 public function action_admin_theme_get_blogroll_manage( $handler, $theme ) 308 308 { 309 309 Stack::add( 'admin_stylesheet', array( $this->get_url() . '/templates/blogroll.css', 'screen' ) ); 310 310 $theme->feed_icon= $this->get_url() . '/templates/feed.png'; 311 311 312 312 $theme->display( 'blogroll_manage' ); 313 313 exit; 314 314 } 315 315 316 316 public function action_admin_theme_get_blogroll_publish( $handler, $theme ) 317 317 { 318 318 Stack::add( 'admin_stylesheet', array( $this->get_url() . '/templates/blogroll.css', 'screen' ) ); 319 319 extract( $handler->handler_vars ); 320 320 321 321 if ( !empty( $quick_link_bookmarklet ) ) { 322 322 Session::add_to_set( 'last_form_data', array('quick_link'=>$quick_link_bookmarklet, 'redirect_to'=>$quick_link_bookmarklet), 'post' ); … … 324 324 exit; 325 325 } 326 326 327 327 if ( !empty( $id ) ) { 328 328 $blog= Blog::get( $id ); … … 336 336 $theme->$key= $value; 337 337 } 338 338 339 339 $theme->relationships= Plugins::filter( 'blogroll_relationships', array('external'=>'External', 'nofollow'=>'Nofollow', 'bookmark'=>'Bookmark') ); 340 340 $controls= array( … … 346 346 exit; 347 347 } 348 348 349 349 public function filter_available_templates( $templates, $class ) { 350 350 $templates= array_merge( $templates, array('blogroll_manage','blogroll_publish','blogroll','blogroll_publish_extras') ); 351 351 return $templates; 352 352 } 353 353 354 354 public function filter_include_template_file( $template_path, $template_name, $class ) 355 355 { … … 368 368 return $template_path; 369 369 } 370 370 371 371 public function theme_show_blogroll( $theme, $user_params= array() ) 372 372 { 373 373 $theme->blogroll_title= Options::get( 'blogroll__list_title' ); 374 374 375 375 // Build the params array to pass it to the get() method 376 376 $order_by= Options::get( 'blogroll__sort_by' ); 377 377 $direction= Options::get( 'blogroll__direction'); 378 378 379 379 $params= array( 380 380 'limit' => Options::get( 'blogroll__max_links' ), 381 381 'order_by' => $order_by . ' ' . $direction, 382 );383 382 ); 383 384 384 $theme->blogs= Blogs::get( $params ); 385 385 386 386 return $theme->fetch( 'blogroll' ); 387 387 } 388 388 389 389 public function filter_blogroll_update_cron( $success ) 390 390 { … … 419 419 } 420 420 } 421 421 422 422 public function filter_habminbar( $menu ) 423 423 { … … 425 425 return $menu; 426 426 } 427 427 428 428 public function filter_rewrite_rules( $rules ) 429 429 { … … 441 441 return $rules; 442 442 } 443 443 444 444 private function import_opml( SimpleXMLElement $xml ) 445 445 { … … 459 459 return $count; 460 460 } 461 461 462 462 private function map_opml_atts( $atts ) 463 463 {
