[geeklog-cvs] geeklog-1.3/public_html/admin trackback.php,1.5,1.6

dhaun at iowaoutdoors.org dhaun at iowaoutdoors.org
Sun Jan 30 15:01:25 EST 2005


Update of /var/cvs/geeklog-1.3/public_html/admin
In directory www:/tmp/cvs-serv31474/public_html/admin

Modified Files:
	trackback.php 
Log Message:
Implemented Pinging weblog directory services (blo.gs, etc.). Needs a web interface to manage those sites ...


Index: trackback.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/admin/trackback.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** trackback.php	30 Jan 2005 13:51:10 -0000	1.5
--- trackback.php	30 Jan 2005 20:01:23 -0000	1.6
***************
*** 206,217 ****
  
  /**
! * Send a Pingback to all the links in $text, advertising our post at $url
  *
! * @param    string  $url    URL of a post on our site
! * @param    string  $text   text of a story etc., will be searched for links
  * @return   string          pingback results
  *
  */
! function sendPingbacks ($url, $text)
  {
      global $_CONF, $LANG_TRB;
--- 206,217 ----
  
  /**
! * Send a Pingback to all the links in our entry
  *
! * @param    string  $type   type of entry we're advertising ('article' = story)
! * @param    string  $id     ID of that entry
  * @return   string          pingback results
  *
  */
! function sendPingbacks ($type, $id)
  {
      global $_CONF, $LANG_TRB;
***************
*** 219,223 ****
      $retval = '';
  
!     $retval .= '<p>Pingback results:</p>';
  
      // extract all links from the text
--- 219,227 ----
      $retval = '';
  
!     if ($type == 'article') {
!         list ($url, $text) = STORY_getItemInfo ($id, 'url,description');
!     } else {
!         list ($url, $text) = PLG_getItemInfo ($type, $id, 'url,description');
!     }
  
      // extract all links from the text
***************
*** 239,243 ****
--- 243,249 ----
          $template->set_var ('layout_url', $_CONF['layout_url']);
          $template->set_var ('lang_resend', $LANG_TRB['resend']);
+         $template->set_var ('lang_results', $LANG_TRB['pingback_results']);
  
+         $counter = 1;
          foreach ($links as $key => $URLtoPing) {
              $result = PNB_sendPingback ($url, $URLtoPing);
***************
*** 256,260 ****
--- 262,269 ----
              $template->set_var ('pingback_result', $result);
              $template->set_var ('resend', $resend);
+             $template->set_var ('alternate_row',
+                     ($counter % 2) == 0 ? 'row-even' : 'row-odd');
              $template->parse ('pingback_results', 'item', true);
+             $counter++;
          }
          $template->parse ('output', 'list');
***************
*** 269,272 ****
--- 278,344 ----
  
  /**
+ * Ping weblog directory services
+ *
+ * @param    string  $type   type of entry we're advertising ('article' = story)
+ * @param    string  $id     ID of that entry
+ * @return   string          result of the pings
+ *
+ */
+ function sendPings ($type, $id)
+ {
+     global $_CONF, $LANG_TRB;
+ 
+     $retval = '';
+ 
+     if ($type == 'article') {
+         list ($itemurl,$feedurl) = STORY_getItemInfo ($id, 'url,feed');
+     } else {
+         list ($itemurl,$feedurl) = PLG_getItemInfo ($type, $id, 'url,feed');
+     }
+ 
+     $template = new Template ($_CONF['path_layout'] . 'admin/trackback');
+     $template->set_file (array ('list' => 'pinglist.thtml',
+                                 'item' => 'pingitem.thtml'));
+     $template->set_var ('site_url', $_CONF['site_url']);
+     $template->set_var ('site_admin_url', $_CONF['site_admin_url']);
+     $template->set_var ('layout_url', $_CONF['layout_url']);
+     $template->set_var ('lang_resend', $LANG_TRB['resend']);
+     $template->set_var ('lang_results', $LANG_TRB['ping_results']);
+ 
+     $counter = 1;
+     foreach ($_CONF['ping_sites'] as $site) {
+         $resend = '';
+         if ($site['method'] == 'weblogUpdates.ping') {
+             $result = PNB_sendPing ($site['ping_url'], $_CONF['site_name'],
+                                     $_CONF['site_url'], $itemurl);
+         } else if ($site['method'] == 'weblogUpdates.extendedPing') {
+             $result = PNB_sendExtendedPing ($site['ping_url'],
+                 $_CONF['site_name'], $_CONF['site_url'], $itemurl, $feedurl);
+         } else {
+             $result = $LANG_TRB['unknown_method'] . ': ' . $site['method'];
+         }
+         if (empty ($result)) {
+             $result = '<b>' . $LANG_TRB['ping_success'] . '</b>';
+         } else {
+             $result = '<span class="warningsmall">' . $result . '</span>';
+         }
+ 
+         $template->set_var ('service_name', $site['name']);
+         $template->set_var ('service_url', $site['site_url']);
+         $template->set_var ('service_ping_url', $site['ping_url']);
+         $template->set_var ('ping_result', $result);
+         $template->set_var ('resend', $resend);
+         $template->set_var ('alternate_row',
+                 ($counter % 2) == 0 ? 'row-even' : 'row-odd');
+         $template->parse ('ping_results', 'item', true);
+         $counter++;
+     }
+     $template->parse ('output', 'list');
+     $retval .= $template->finish ($template->get_var ('output'));
+ 
+     return $retval;
+ }
+ 
+ /**
  * Prepare a list of all links in a story/item so that we can ask the user
  * which one to send the trackback to.
***************
*** 316,319 ****
--- 388,393 ----
              $template->set_var ('link_text', $matches[2][$i]);
              $template->set_var ('link_url', $matches[1][$i]);
+             $template->set_var ('alternate_row',
+                     (($i + 1) % 2) == 0 ? 'row-even' : 'row-odd');
              $template->parse ('autodetect_items', 'item', true);
          }
***************
*** 421,433 ****
      $id = COM_applyFilter ($_REQUEST['id']);
      if (!empty ($id)) {
-         if ($type == 'article') {
-             list ($url, $fulltext) = STORY_getItemInfo ($id, 'url,description');
-         } else {
-             list ($url, $fulltext) = PLG_getItemInfo ($type, $id,
-                                                       'url,description');
-         }
          $display .= COM_siteHeader ('menu', $LANG_TRB['pingback'])
                    . COM_startBlock ($LANG_TRB['pingback_results'])
!                   . sendPingbacks ($url, $fulltext)
                    . COM_endBlock ()
                    . COM_siteFooter ();
--- 495,501 ----
      $id = COM_applyFilter ($_REQUEST['id']);
      if (!empty ($id)) {
          $display .= COM_siteHeader ('menu', $LANG_TRB['pingback'])
                    . COM_startBlock ($LANG_TRB['pingback_results'])
!                   . sendPingbacks ($type, $id)
                    . COM_endBlock ()
                    . COM_siteFooter ();
***************
*** 446,461 ****
      }
  
!     $pingback_sent = false;
!     $ping_sent = false;
!     $trackback_sent = false;
!     if (isset ($_REQUEST['pingback_sent'])) {
!         $pingback_sent = true;
!     }
!     if (isset ($_REQUEST['ping_sent'])) {
!         $ping_sent = true;
!     }
!     if (isset ($_REQUEST['trackback_sent'])) {
!         $trackback_sent = true;
!     }
  
      $pingresult = '';
--- 514,520 ----
      }
  
!     $pingback_sent  = isset ($_REQUEST['pingback_sent']);
!     $ping_sent      = isset ($_REQUEST['ping_sent']);
!     $trackback_sent = isset ($_REQUEST['trackback_sent']);
  
      $pingresult = '';
***************
*** 463,477 ****
          $what = $_POST['what'];
          if (isset ($what[0])) {         // Pingback
!             if ($type == 'article') {
!                 list ($url, $fulltext) = STORY_getItemInfo ($id,
!                                                             'url,description');
!             } else {
!                 list ($url, $fulltext) = PLG_getItemInfo ($type, $id,
!                                                           'url,description');
!             }
!             $pingresult = sendPingbacks ($url, $fulltext);
              $pingback_sent = true;
          } else if (isset ($what[1])) {  // Ping
!             // TBD
          } else if (isset ($what[2])) {  // Trackback
              $url = $_CONF['site_admin_url'] . '/trackback?mode=pretrackback&id='
--- 522,530 ----
          $what = $_POST['what'];
          if (isset ($what[0])) {         // Pingback
!             $pingresult = sendPingbacks ($type, $id);
              $pingback_sent = true;
          } else if (isset ($what[1])) {  // Ping
!             $pingresult = sendPings ($type, $id);
!             $ping_sent = true;
          } else if (isset ($what[2])) {  // Trackback
              $url = $_CONF['site_admin_url'] . '/trackback?mode=pretrackback&id='




More information about the geeklog-cvs mailing list