[geeklog-cvs] geeklog-1.3/system lib-plugins.php,1.41,1.42

dhaun at iowaoutdoors.org dhaun at iowaoutdoors.org
Fri Sep 24 06:25:34 EDT 2004


Update of /var/cvs/geeklog-1.3/system
In directory www:/tmp/cvs-serv12054/system

Modified Files:
	lib-plugins.php 
Log Message:
Extended PLG_replaceTags() so that plugins can return more than one autotag.


Index: lib-plugins.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/system/lib-plugins.php,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -d -r1.41 -r1.42
*** lib-plugins.php	21 Sep 2004 10:58:17 -0000	1.41
--- lib-plugins.php	24 Sep 2004 10:25:32 -0000	1.42
***************
*** 874,878 ****
  * Get a list of all currently supported autolink tags.
  *
! * Returns an associative array where $A['plugin-name'] = 'tag-name'
  *
  * @return   array   All currently supported autolink tags
--- 874,878 ----
  * Get a list of all currently supported autolink tags.
  *
! * Returns an associative array where $A['tag-name'] = 'plugin-name'
  *
  * @return   array   All currently supported autolink tags
***************
*** 884,889 ****
  
      // Determine which Core Modules and Plugins support AutoLinks
!     $autolinkModules = array ('story'    => 'story',
!                               'calendar' => 'event'
                               );
  
--- 884,890 ----
  
      // Determine which Core Modules and Plugins support AutoLinks
!     //                        'tag'   => 'module'
!     $autolinkModules = array ('story' => 'geeklog',
!                               'event' => 'geeklog'
                               );
  
***************
*** 892,896 ****
          if (function_exists ($function)) {
              $autotag = $function ('tagname');
!             $autolinkModules[$pi_name]  = $autotag;
          }
      }
--- 893,903 ----
          if (function_exists ($function)) {
              $autotag = $function ('tagname');
!             if (is_array ($autotag)) {
!                 foreach ($autotag as $tag) {
!                     $autolinkModules[$tag] = $pi_name;
!                 }
!             } else {
!                 $autolinkModules[$autotag] = $pi_name;
!             }
          }
      }
***************
*** 915,936 ****
  
      // For each supported module - scan the content looking for any AutoLink tags
!     $tags = array();
!     foreach ($autolinkModules as $module => $moduletag) {
          $autotag_prefix = '['. $moduletag;
          $offset = $prev_offset = 0;
!         $strlen = strlen($content);
          while ($offset < $strlen) {
!             $start_pos = strpos( strtolower( $content ), $autotag_prefix, $offset );
!             if( $start_pos !== FALSE ) {
!                $end_pos = strpos( strtolower( $content ), ']', $start_pos );
!                $next_tag = strpos( strtolower( $content ), '[', $start_pos +1);
!                if( $end_pos > $start_pos AND (($end_pos < $next_tag OR $next_tag == FALSE)) ) {
                      $taglength = $end_pos - $start_pos + 1;
!                     $tag = substr($content,$start_pos,$taglength);
!                     $parms = explode(' ',$tag);
!                     $label = str_replace(']','',substr($tag,strlen($parms[0])+1));
!                     $parms = explode(':',$parms[0]);
                      $newtag = array (
                          'module'    => $module,
                          'tagstr'    => $tag,
                          'startpos'  => $start_pos,
--- 922,946 ----
  
      // For each supported module - scan the content looking for any AutoLink tags
!     $tags = array ();
!     foreach ($autolinkModules as $moduletag => $module) {
          $autotag_prefix = '['. $moduletag;
          $offset = $prev_offset = 0;
!         $strlen = strlen ($content);
          while ($offset < $strlen) {
!             $start_pos = strpos (strtolower ($content), $autotag_prefix,
!                                  $offset );
!             if ($start_pos !== FALSE) {
!                $end_pos = strpos (strtolower ($content), ']', $start_pos);
!                $next_tag = strpos (strtolower ($content), '[', $start_pos + 1);
!                if ($end_pos > $start_pos AND (($end_pos < $next_tag OR $next_tag == FALSE))) {
                      $taglength = $end_pos - $start_pos + 1;
!                     $tag = substr ($content, $start_pos, $taglength);
!                     $parms = explode (' ', $tag);
!                     $label = str_replace (']', '',
!                              substr ($tag, strlen ($parms[0]) + 1));
!                     $parms = explode (':', $parms[0]);
                      $newtag = array (
                          'module'    => $module,
+                         'tag'       => $moduletag,
                          'tagstr'    => $tag,
                          'startpos'  => $start_pos,
***************
*** 956,974 ****
  
      // If we have found 1 or more AutoLink tag
!     if (count($tags) > 0) {       // Found the [tag] - Now process them all
          foreach ($tags as $autotag) {
              $function = 'plugin_autotags_' . $autotag['module'];
!             if ($autotag['module'] == 'story') {
!                 $filelink = '<a href="' . COM_buildUrl ($_CONF['site_url']
!                           . '/article.php?story=' . $autotag['parm1']) . '">'
!                           . $autotag['parm2'] . '</a>';
!                 $content = str_replace($autotag['tagstr'], $filelink, $content);
!             } else if ($autotag['module'] == 'calendar') {
!                 $filelink = '<a href="' . $_CONF['site_url']
!                           . '/calendar_event.php?eid=' . $autotag['parm1']
!                           . '">' . $autotag['parm2'] . '</a>';
!                 $content = str_replace($autotag['tagstr'], $filelink, $content);
!             } elseif (function_exists($function)) {
!                 $content = $function('parse', $content, $autotag);
              }
          }
--- 966,989 ----
  
      // If we have found 1 or more AutoLink tag
!     if (count ($tags) > 0) {       // Found the [tag] - Now process them all
          foreach ($tags as $autotag) {
              $function = 'plugin_autotags_' . $autotag['module'];
!             if ($autotag['module'] == 'geeklog') {
!                 $url = '';
!                 if ($autotag['tag'] == 'story') {
!                     $url = COM_buildUrl ($_CONF['site_url']
!                          . '/article.php?story=' . $autotag['parm1']);
!                 } else if ($autotag['tag'] == 'event') {
!                     $url = $_CONF['site_url'] . '/calendar_event.php?eid='
!                          . $autotag['parm1'];
!                 }
!                 if (!empty ($url)) {
!                     $filelink = '<a href="' . $url . '">' . $autotag['parm2']
!                               . '</a>';
!                     $content = str_replace ($autotag['tagstr'], $filelink,
!                                             $content);
!                 }
!             } else if (function_exists ($function)) {
!                 $content = $function ('parse', $content, $autotag);
              }
          }
***************
*** 976,980 ****
  
      return $content;
- 
  }
  
--- 991,994 ----




More information about the geeklog-cvs mailing list