Xaraya / Postnuke CVS Notices - Message

Note: this list is kept only as a demonstration for CVSNotice. For the latest CVS notices, see the Xaraya and Postnuke sites

View Statistics - Next Notice - Previous Notice

Directory filter : [ all ] / postnuke_official / html / modules / ns-addstory [ view in CVS ]

Date Directory [filter] File(s) [view] Author [filter]
06 Aug 2002 00:33:17postnuke_official/html/modules/ns-addstoryaddstory_functions.php,1.17.2.3,1.17.2.4judgej
 Bug 588086 - detect block-html and suppress nl2br if present. Provide means for admin to over-ride this.

Update of /home/cvsroot/postnuke_official/html/modules/ns-addstory
In directory ns7.hostnuke.net:/tmp/cvs-serv5995/html/modules/ns-addstory

Modified Files:
      Tag: PostNuke_71
	addstory_functions.php 
Log Message:
Bug 588086 - detect block-html and suppress nl2br if present. Provide means for admin to over-ride this.


Index: addstory_functions.php
===================================================================
RCS file: /home/cvsroot/postnuke_official/html/modules/ns-addstory/Attic/addstory_functions.php,v
retrieving revision 1.17.2.3
retrieving revision 1.17.2.4
diff -C2 -d -r1.17.2.3 -r1.17.2.4
*** addstory_functions.php	4 Aug 2002 22:07:22 -0000	1.17.2.3
--- addstory_functions.php	6 Aug 2002 00:33:15 -0000	1.17.2.4
***************
*** 60,64 ****
  
  // added by EB to reuse the code
! function storyPreview($subject, $hometext, $bodytext="", $notes="", $topic)
  {
      global $user,
--- 60,64 ----
  
  // added by EB to reuse the code
! function storyPreview($subject, $hometext, $bodytext="", $notes="", $topic, $format_type=0)
  {
      global $user,
***************
*** 70,73 ****
--- 70,82 ----
  	   $opPrefix;
  
+     if (empty($format_type))
+     {
+         $format_type = 0;
+     }
+ 
+     // Get the format types. 'home' string is bits 0-1, 'body' is bits 2-3.
+     $format_type_home = ($format_type%4);
+     $format_type_body = (($format_type/4)%4);
+ 
      list($dbconn) = pnDBGetConn();
      $pntable = pnDBGetTables();
***************
*** 93,99 ****
      OpenTable();
      echo "<img src=\"$tipath$topicimage\" border=\"0\" align=\"right\" alt=\"\">";
!     echo "<font class=\"pn-title\"><b>" . pnVarPrepForDisplay($subject) . "</b></font><br><br><font class=\"pn-normal\">" . pnVarPrepHTMLDisplay(nl2br($hometext)) . "</font>";
      if (!empty($bodytext)) {
!         echo "<br /><br /><font class=\"pn-normal\">" . pnVarPrepHTMLDisplay(nl2br($bodytext)) . "</font>";
      }
      if (!empty($notes)) {
--- 102,124 ----
      OpenTable();
      echo "<img src=\"$tipath$topicimage\" border=\"0\" align=\"right\" alt=\"\">";
!     echo "<font class=\"pn-title\"><b>" . pnVarPrepForDisplay($subject) . "</b></font><br><br><font class=\"pn-normal\">";
!     // Put br tags in only if format of hometext is 'text'.
!     if ($format_type_home == 0)
!     {
!         echo pnVarPrepHTMLDisplay(nl2br($hometext));
!     } else {
!         echo pnVarPrepHTMLDisplay($hometext);
!     }
!     echo "</font>";
      if (!empty($bodytext)) {
!         echo "<br /><br /><font class=\"pn-normal\">";
!         // Put br tags in only if format of bodytext is 'text'
!         if ($format_type_body == 0)
!         {
!             echo pnVarPrepHTMLDisplay(nl2br($bodytext));
!         } else {
!             echo pnVarPrepHTMLDisplay($bodytext);
!         }
!         echo "</font>";
      }
      if (!empty($notes)) {
***************
*** 104,108 ****
  
  // added by EugenioBaldi to reuse the code
! function storyEdit($subject, $hometext, $bodytext, $notes, $topic, $ihome, $catid, $alanguage, $comm, $aid, $informant)
  {
      global $tipath,
--- 129,133 ----
  
  // added by EugenioBaldi to reuse the code
! function storyEdit($subject, $hometext, $bodytext, $notes, $topic, $ihome, $catid, $alanguage, $comm, $aid, $informant, $format_type=0)
  {
      global $tipath,
***************
*** 112,115 ****
--- 137,149 ----
             $opPrefix;
  
+     if (empty($format_type))
+     {
+         $format_type = 0;
+     }
+ 
+     // Get the format types. 'home' string is bits 0-1, 'body' is bits 2-3.
+     $format_type_home = ($format_type%4);
+     $format_type_body = (($format_type/4)%4);
+ 
      list($dbconn) = pnDBGetConn();
      $pntable = pnDBGetTables();
***************
*** 125,132 ****
  	buildLanguageMenu(true,$alanguage);
      echo "<br><br><b>"._STORYTEXT."</b><br>"
!         ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"12\" name=\"hometext\">" . pnVarPrepForDisplay(unnltobr($hometext)) . "</textarea><br><br>"
!         ."<b>"._EXTENDEDTEXT."</b><br>"
!         ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"12\" name=\"bodytext\">" . pnVarPrepForDisplay(unnltobr($bodytext)) . "</textarea><br><br>";
! 	echo "<font class=\"pn-normal\">"._AREYOUSURE."</font><br><br>";
      if (pnSecAuthAction(0, 'Stories::', "$subject::", ACCESS_EDIT)) {
          echo "<b>"._NOTES."</b><br><textarea wrap=\"virtual\" cols=\"50\" rows=\"4\" name=\"notes\">" . pnVarPrepForDisplay(unnltobr($notes)) . "</textarea><br><br>";
--- 159,190 ----
  	buildLanguageMenu(true,$alanguage);
      echo "<br><br><b>"._STORYTEXT."</b><br>"
!         ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"12\" name=\"hometext\">";
!     // Remove br tags only if format of hometext is 'text'.
!     if ($format_type_home == 0)
!     {
!         echo pnVarPrepForDisplay(unnltobr($hometext));
!     } else {
!         echo pnVarPrepForDisplay($hometext);
!     }
!     echo "</textarea>";
! 
!     // Choose format type for hometext.
!     buildFormatTypeMenu("format_type_home", $format_type_home);
! 
!     echo "<br><br><b>"._EXTENDEDTEXT."</b><br>"
!         ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"12\" name=\"bodytext\">";
!     // Remove br tags only if format of bodytext is 'text'
!     // The bodytext flag is in bits 2 and 3.
!     if ($format_type_body == 0)
!     {
!         echo pnVarPrepForDisplay(unnltobr($bodytext));
!     } else {
!         echo pnVarPrepForDisplay($bodytext);
!     }
!     echo "</textarea>";
!     // Choose format type for hometext.
!     buildFormatTypeMenu("format_type_body", $format_type_body);
! 
! 	echo "<br><br><font class=\"pn-normal\">"._AREYOUSURE."</font><br><br>";
      if (pnSecAuthAction(0, 'Stories::', "$subject::", ACCESS_EDIT)) {
          echo "<b>"._NOTES."</b><br><textarea wrap=\"virtual\" cols=\"50\" rows=\"4\" name=\"notes\">" . pnVarPrepForDisplay(unnltobr($notes)) . "</textarea><br><br>";
***************
*** 136,139 ****
--- 194,241 ----
  }
  
+ // judgej: get best-guess of the format types of the a content string.
+ // Returns: 0=text; 1=html
+ function estimateFormatType($content)
+ {
+     // If the content string contains block-tags then is is likely to be HTML,
+     // otherwise assume text.
+     $block_elements = Array(
+         'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
+         'div', 'center', 'form', 'hr', 'table',
+         'p', 'pre', 'blockquote', 'address'
+     );
+     $pattern = '';
+     $sep = '';
+ 
+     // ereg pattern is <tag-name[ >]|<tag-name2[ >]|...
+     foreach ($block_elements as $block_element)
+     {
+         $pattern = $pattern . $sep . '<' . $block_element . '[ >]';
+         if ($sep == '') {$sep = '|';}
+     }
+ 
+     // If pattern matches then return 1 to indicate this probably contains HTML.
+     if (eregi($pattern, $content))
+     {
+         return 1;
+     } else {
+         return 0;
+     }
+ }
+ 
+ // judgej: get default format types of the story components.
+ function defaultFormatType($hometext, $bodytext)
+ {
+     $format_type_home = 0;
+     $format_type_body = 0;
+ 
+     $format_type_home = estimateFormatType($hometext);
+     $format_type_body = estimateFormatType($bodytext);
+ 
+     $format_type = ($format_type_body*4) + $format_type_home;
+ 
+     return ($format_type);
+ }
+ 
  // added by AV to reuse the code
  function buildLanguageMenu($inheritselection, $alanguage){
***************
*** 175,178 ****
--- 277,301 ----
  		lang_dropdown();
  	}
+ }
+ 
+ function buildFormatTypeMenu($field_name, $default_value)
+ {
+ 	echo "<br><b>". _FORMATTYPE ."</b>&nbsp;"
+ 	."<select name=\"$field_name\" class=\"pn-text\">";
+ 
+     $format_types[] = Array('value' => 0, 'label' => _PLAINTEXT);
+     $format_types[] = Array('value' => 1, 'label' => _HTMLFORMATED);
+ 
+     foreach ($format_types as $format_type)
+     {
+         if ($format_type['value'] == $default_value)
+         {
+             $sel = " selected";
+         } else {
+             $sel = "";
+         }
+ 		echo "<option value=\"" . $format_type['value'] . "\"$sel>" . pnVarPrepForDisplay($format_type['label']) . "</option>\n";
+     }
+ 	echo "</select>";
  }
  


Directory filter : [ all ] / postnuke_official / html / modules / ns-addstory [ view in CVS ]

View Statistics - Next Notice - Previous Notice


Visit Developer Site - Browse CVS Repository Syndicate via backend.rss
(max. once per hour please)
Powered by CVSNotice 0.1.3