[Imc-tech] Various patches

Clint Popetz cpopetz at cpopetz.com
Sat Sep 7 16:02:03 CDT 2002


[For our archive, a copy of the message I sent to dada about patches I
have made.]

				-Clint


I have several patches, broken up into different files and attached,
which I have applied to the uc-imc's version of dada, which may or may
not be useful to folks.

--comment_features.diff

This allows comments to be successfully rated on features.  Without
this patch, the comment gets rated, but when ArticleOracle->get_unique
is called to display the parent, it fails, because the parent is a
feature.

--displayable_media.diff

This patch makes sure that the random image selected for the media
sidebar on the home page isn't from a hidden article.  We had some
pretty nasty racist things that were popping up :)

--editor_docs.diff

Without this, I couldn't see any of the Docs as an editor.

--link_hidden.diff

Our editors like to link hidden spam as a record of what they are
hiding, so I needed to be able to see hidden articles in the list of
articles to link together.

--make_clickable.diff

Active makes URLs clickable (wraps them in an <a href>), and I wanted
dada to do the same.

--vanishing_features.diff

We aren't using feature rating, and the code that does the
hiding/unhiding of articles as they become features wasn't working in
the case where a feature should become a feature immediately, i.e. not
after someone rates it above the threshold.


Anyway, I hope those are useful to someone.

				-Clint
				(a ucimc tech guy)
-------------- next part --------------
diff -c2p -r ./imc_Article.inc /var/www/php-include/imc_classes/imc_Article.inc
*** ./imc_Article.inc	Fri May 10 12:34:15 2002
--- /var/www/php-include/imc_classes/imc_Article.inc	Sat Sep  7 14:28:23 2002
*************** class Article extends Object {
*** 396,401 ****
  			$display_summary = $this->summary;
  		} else {
! 			$display_body = nl2br(htmlentities($this->body));
! 			$display_summary = nl2br(htmlentities($this->summary));
  		}
  		// look for associated media files (image, audio, video)
--- 396,401 ----
  			$display_summary = $this->summary;
  		} else {
! 			$display_body = $this->make_clickable(nl2br(htmlentities($this->body)));
! 			$display_summary = $this->make_clickable(nl2br(htmlentities($this->summary)));
  		}
  		// look for associated media files (image, audio, video)
*************** class Article extends Object {
*** 421,426 ****
  			$display_summary = $this->summary;
  		} else {
! 			$display_body = nl2br(htmlentities($this->body));
! 			$display_summary = nl2br(htmlentities($this->summary));
  		}
  		// look for associated media files (image, audio, video)
--- 421,426 ----
  			$display_summary = $this->summary;
  		} else {
! 			$display_body = $this->make_clickable(nl2br(htmlentities($this->body)));
! 			$display_summary = $this->make_clickable(nl2br(htmlentities($this->summary)));
  		}
  		// look for associated media files (image, audio, video)
*************** class Article extends Object {
*** 446,451 ****
  			$display_summary = $this->summary;
  		} else {
! 			$display_body = nl2br($this->body);
! 			$display_summary = nl2br(htmlentities($this->summary));
  		}
  		// look for associated media files (image, audio, video)
--- 446,451 ----
  			$display_summary = $this->summary;
  		} else {
! 			$display_body = $this->make_clickable(nl2br($this->body));
! 			$display_summary = $this->make_clickable(nl2br(htmlentities($this->summary)));
  		}
  		// look for associated media files (image, audio, video)
*************** class Article extends Object {
*** 464,467 ****
--- 464,474 ----
  	}
  
+ 	function make_clickable($item) {
+ 		$pattern = '#(http://|ftp://|mailto:|news:)([^\s<>()\]\[]+)([\s\n<>()\[\]]*)#';
+ 		$ret = preg_replace($pattern,"<a href=\"\\1\\2\"><u>\\1\\2</u></a>\\3",$item);
+ 		return($ret);
+ 
+ 	}
+ 
  	function preview() {
  		global $PageConfig,$PHP_SELF,$g_url,$authorized_object;
*************** class Article extends Object {
*** 471,476 ****
  			$display_summary = $this->summary;
  		} else {
! 			$display_body = nl2br(htmlentities($this->body));
! 			$display_summary = nl2br(htmlentities($this->summary));
  		}
  		// look for associated media files (image, audio, video)
--- 478,483 ----
  			$display_summary = $this->summary;
  		} else {
! 			$display_body = $this->make_clickable(nl2br(htmlentities($this->body)));
! 			$display_summary = $this->make_clickable(nl2br(htmlentities($this->summary)));
  		}
  		// look for associated media files (image, audio, video)

-------------- next part --------------
diff -c2p -r ./editor_includes/doc.inc /var/www/ucimc-dada/editor_includes/doc.inc
*** ./editor_includes/doc.inc	Fri May 10 12:34:15 2002
--- /var/www/ucimc-dada/editor_includes/doc.inc	Tue May 21 15:14:06 2002
*************** switch ($function) {
*** 58,62 ****
  				$all_the_docs = $oracle->response_array;
  			}
! 			$column_array[] = array(title=>'Title',field=>'title', width=>'500','link'=>$g_url.'editor/index.php?class=Doc&function=display&id=$row->objectid',strclass=>'formfield');
  			if ($showscore) {
  				$column_array[] = array(title=>'Score',field=>'score',func=>'display_score',width=>'40',align=>'center',strclass=>'smallstring');
--- 58,62 ----
  				$all_the_docs = $oracle->response_array;
  			}
! 			$column_array[] = array(title=>'Title',field=>'title', width=>'500','link'=>$g_url.'editor/index.php?class=Doc&function=display&id=$row[objectid]',strclass=>'formfield');
  			if ($showscore) {
  				$column_array[] = array(title=>'Score',field=>'score',func=>'display_score',width=>'40',align=>'center',strclass=>'smallstring');
-------------- next part --------------
diff -c2p -r ./editor_includes/article_options.inc /var/www/ucimc-dada/editor_includes/article_options.inc
*** ./editor_includes/article_options.inc	Fri May 10 12:34:15 2002
--- /var/www/ucimc-dada/editor_includes/article_options.inc	Sun Sep  1 22:10:47 2002
*************** if ($the_article->parentid == 0) {
*** 171,175 ****
  	$oracle->reset();
  	$oracle->set_selectfields('articles.objectid,articles.modified_timestamp,articles.heading,articles.media');
! 	$oracle->set_where_clause("articles.edit_datetime > '$recentsql' AND articles.parentid = 0 AND articles.displayable = 1");
  	$oracle->set_where_clause('categories.objectid = articles.categoryid');
  	$oracle->set_orderby('articles.edit_datetime DESC');
--- 171,175 ----
  	$oracle->reset();
  	$oracle->set_selectfields('articles.objectid,articles.modified_timestamp,articles.heading,articles.media');
! 	$oracle->set_where_clause("articles.edit_datetime > '$recentsql' AND articles.parentid = 0");
  	$oracle->set_where_clause('categories.objectid = articles.categoryid');
  	$oracle->set_orderby('articles.edit_datetime DESC');

-------------- next part --------------
diff -c2p -r ./imc_Feature.inc /var/www/php-include/imc_classes/imc_Feature.inc
*** ./imc_Feature.inc	Fri May 10 12:34:15 2002
--- /var/www/php-include/imc_classes/imc_Feature.inc	Mon Aug 19 22:44:53 2002
*************** class Feature extends Article {
*** 12,15 ****
--- 12,37 ----
  	}
  
+ 
+ 	function set_displayable($int) {
+ 
+ 		$this->db_args['displayable'] = $int;
+ 		$this->displayable = $int;
+ 
+ 			// if the Feature is now displayed, delete the associated newswire article
+ 			if ($this->displayable && $this->parentid != 0) {
+ 				$oracle = new ArticleOracle();
+ 				$newswire_version = $oracle->get_unique($this->parentid);
+ 				if ($newswire_version) {
+ 					echo ('<p class="alert">Attempting to delete the old version...</p>');
+ 					$newswire_version->purge();
+ 					// update comments attached to the old article to this feature
+ 					echo ('<p class="alert">Attempting to convert any comments from old version...</p>');
+ 					$qoracle = new ArticleOracle();
+ 					$qoracle->send_raw_sql("UPDATE articles SET parentid = $this->objectid WHERE parentid = $this->parentid"); 
+ 					$this->set_parentid(0);
+ 				}
+ 			}
+ 	}
+ 
  	function get_icons() {
  		include_once('imc_classes/imc_RatingTracker.inc');
*************** class Feature extends Article {
*** 555,572 ****
  				}
  			}
- 			// if the Feature is now displayed, delete the associated newswire article
- 			if ($this->displayable && $this->parentid != 0) {
- 				$oracle = new ArticleOracle();
- 				$newswire_version = $oracle->get_unique($this->parentid);
- 				if ($newswire_version) {
- 					echo ('<p class="alert">Attempting to delete the old version...</p>');
- 					$newswire_version->purge();
- 					// update comments attached to the old article to this feature
- 					echo ('<p class="alert">Attempting to convert any comments from old version...</p>');
- 					$qoracle = new ArticleOracle();
- 					$qoracle->send_raw_sql("UPDATE articles SET parentid = $this->objectid WHERE parentid = $this->parentid"); 
- 					$this->set_parentid(0);
- 				}
- 			}
  		}
  		$this->set_record();
--- 577,580 ----

-------------- next part --------------
diff -c2p -r ./components/media_column.inc /var/www/ucimc-dada/components/media_column.inc
*** ./components/media_column.inc	Fri May 10 12:34:15 2002
--- /var/www/ucimc-dada/components/media_column.inc	Wed Sep  4 16:08:39 2002
***************
*** 34,37 ****
--- 34,38 ----
  		$oracle->set_where_clause('created_datetime > "'.$d2->get_mysql_datetime().'"');
  		$oracle->set_where_clause("media.mime_class = 'image'");
+ 		$oracle->set_where_clause('displayable = 1');
  		$oracle->set_orderby('RAND()');
  		$oracle->set_limit_count(1);

-------------- next part --------------
diff -c2p -r ./imc_Article.inc /var/www/php-include/imc_classes/imc_Article.inc
*** ./imc_Article.inc	Fri May 10 12:34:15 2002
--- /var/www/php-include/imc_classes/imc_Article.inc	Sat Sep  7 14:28:23 2002
*************** class Article extends Object {
*** 1109,1113 ****
  		if ($this->parentid != 0) {
  			// otherwise try to get and display the parent
! 			$oracle = new ArticleOracle();
  			if ($parent = $oracle->get_unique($this->parentid)) {
  				$parent->uncache();
--- 1116,1120 ----
  		if ($this->parentid != 0) {
  			// otherwise try to get and display the parent
! 			$oracle = new ArticleFeatureOracle();
  			if ($parent = $oracle->get_unique($this->parentid)) {
  				$parent->uncache();
diff -c2p -r ./newswire.inc /var/www/ucimc-dada/newswire.inc
*** ./newswire.inc	Fri May 10 12:34:15 2002
--- /var/www/ucimc-dada/newswire.inc	Sat Sep  7 14:07:49 2002
*************** if ($id && $function == 'display_printab
*** 151,155 ****
  								$the_article->$function();
  								if ($the_article->parentid != 0) {
! 									$oracle = new ArticleOracle();
  									$the_article = $oracle->get_unique($the_article->parentid)
  										or die ($oracle->display_error());
--- 151,155 ----
  								$the_article->$function();
  								if ($the_article->parentid != 0) {
! 									$oracle = new ArticleFeatureOracle();
  									$the_article = $oracle->get_unique($the_article->parentid)
  										or die ($oracle->display_error());


More information about the Imc-tech mailing list