Browse Source

2008/06/15. CVS version 1.5.6.3 imported.

Frederic G. MARAND 7 years ago
commit
4849721b17
13 changed files with 417 additions and 0 deletions
  1. 12 0
      CHANGELOG.TXT
  2. 7 0
      CVS/Entries
  3. 7 0
      CVS/Entries.Extra
  4. 7 0
      CVS/Entries.Extra.Old
  5. 7 0
      CVS/Entries.Old
  6. 1 0
      CVS/Repository
  7. 1 0
      CVS/Root
  8. 1 0
      CVS/Tag
  9. 0 0
      CVS/Template
  10. 44 0
      INSTALL.txt
  11. 6 0
      links_filter.info
  12. 75 0
      links_filter.install
  13. 249 0
      links_filter.module

+ 12 - 0
CHANGELOG.TXT

@@ -0,0 +1,12 @@
+Change log for Links_filter module for Drupal 5
+===========================================
+
+$Id: CHANGELOG.TXT,v 1.5.6.8 2008/06/15 21:19:36 fgm Exp $
+
+2008-07-27
+   FEAT     Initial version
+
+This documentation is copyright 2008 Ouest Systemes Informatiques. All rights reserved.
+
+This documentation is licensed for public use under the Creative Commons BY-NC-SA 2.0 license for France,
+found at http://creativecommons.org/licenses/by-nc-sa/2.0/fr/

+ 7 - 0
CVS/Entries

@@ -0,0 +1,7 @@
+D/po////
+/CHANGELOG.TXT/1.5.6.8/Sun Jun 15 21:19:36 2008//TDRUPAL-5
+/INSTALL.txt/1.5.6.3/Sun Jun 15 21:19:36 2008//TDRUPAL-5
+/taxonews.info/1.1.2.4/Sun Jun 15 21:19:36 2008//TDRUPAL-5
+/taxonews.install/1.2.2.3/Sun Jun 15 21:19:36 2008//TDRUPAL-5
+/taxonews.module/1.10.6.9/Sun Jun 15 21:19:36 2008//TDRUPAL-5
+/Taxonews.php/1.1.2.2/Sun Jun 15 21:37:05 2008//TDRUPAL-5

+ 7 - 0
CVS/Entries.Extra

@@ -0,0 +1,7 @@
+D/po///////
+/CHANGELOG.TXT////*///
+/INSTALL.txt////*///
+/taxonews.info////*///
+/taxonews.install////*///
+/taxonews.module////*///
+/Taxonews.php////*///

+ 7 - 0
CVS/Entries.Extra.Old

@@ -0,0 +1,7 @@
+D/po///////
+/CHANGELOG.TXT////*///
+/INSTALL.txt////*///
+/taxonews.info////*///
+/taxonews.install////*///
+/taxonews.module////*///
+/Taxonews.php////*///

+ 7 - 0
CVS/Entries.Old

@@ -0,0 +1,7 @@
+D/po////
+/CHANGELOG.TXT/1.5.6.8/Sun Jun 15 21:19:36 2008//TDRUPAL-5
+/INSTALL.txt/1.5.6.3/Sun Jun 15 21:19:36 2008//TDRUPAL-5
+/taxonews.info/1.1.2.4/Sun Jun 15 21:19:36 2008//TDRUPAL-5
+/taxonews.install/1.2.2.3/Sun Jun 15 21:19:36 2008//TDRUPAL-5
+/taxonews.module/1.10.6.9/Sun Jun 15 21:19:36 2008//TDRUPAL-5
+/Taxonews.php/1.1.2.1/Sun Jun 15 21:19:36 2008//TDRUPAL-5

+ 1 - 0
CVS/Repository

@@ -0,0 +1 @@
+contributions/modules/taxonews

+ 1 - 0
CVS/Root

@@ -0,0 +1 @@
+:pserver:fgm@cvs.drupal.org:/cvs/drupal-contrib

+ 1 - 0
CVS/Tag

@@ -0,0 +1 @@
+TDRUPAL-5

+ 0 - 0
CVS/Template


+ 44 - 0
INSTALL.txt

@@ -0,0 +1,44 @@
+OSInet links_filter module for Drupal
+=====================================
+$Id: INSTALL.txt,v 1.5.6.3 2008/06/15 21:19:36 fgm Exp $
+
+
+PREREQUISITES
+=============
+
+  - Drupal 5.x, taxonomy module enabled
+  - PHP 5.1
+  - MySQL 5.x
+  - MySQL 4.x and PGSQL might work but are not supported
+  - other databases are not taken into account
+
+
+First time install
+==================
+
+1. Copy this directory to
+  <drupal>/modules/taxonews
+
+Upgrades
+========
+
+Since the module does not store any content and did not change its
+configuration variables for the DRUPAL-5 branch, you can just erase
+the files from the previous version and copy the files of the new version.
+No additional install or upgrade procedure is currently necessary.
+
+
+Legal notice
+============
+
+This documentation is copyright 2008 Ouest Systemes Informatiques. All rights reserved.
+
+This documentation is licensed for public use under the Creative Commons 
+BY-NC-SA 2.0 license for France, found at 
+  http://creativecommons.org/licenses/by-nc-sa/2.0/fr/
+
+The code in this directory is licensed under the CeCILL 2.0 by Ouest Systemes Informatiques.
+
+In addition, a GPL 2 or later license has been granted to drupal.org, allowing
+it as well as downstream distributors to distribute the module under these
+licenses.

+ 6 - 0
links_filter.info

@@ -0,0 +1,6 @@
+; $Id: taxonews.info,v 1.1.2.4 2008/06/15 21:19:36 fgm Exp $
+name = Links filter
+description = "Track links on a site"
+package = Content
+;dependencies =
+;project = "drupal"

+ 75 - 0
links_filter.install

@@ -0,0 +1,75 @@
+<?php
+/**
+ * Installer file for Taxonews module
+ *
+ * @author     Frederic G. MARAND
+ * @version    CVS: $Id: taxonews.install,v 1.2.2.3 2008/06/15 21:19:36 fgm Exp $
+ * @copyright  2005-2008 Ouest Syst�mes Informatiques (OSI)
+ * @license    http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
+ * @link       http://drupal.org/project/taxonews
+ * @since      Version 1.10.8.2 of taxonews.module
+ * @package    taxonews
+ */
+
+/**
+ * We just defined this update to have a reference schema version
+ *
+ * @return array
+ */
+function links_filter_update_5100()
+  {
+  $ret = array();
+  drupal_set_message(t('Links_filter schema version is now 5100.'));
+  return $ret;
+  }
+
+function links_filter_install()
+  {
+  $dbType = $GLOBALS['db_type'];
+  switch ($dbType)
+    {
+    case 'mysql':
+    case 'mysqli':
+      db_query
+        (
+        "CREATE TABLE {lf_links} 
+          (
+          `lfl_id` int(10) unsigned NOT NULL default '0',
+          `module` varchar(64) NOT NULL default 'node',
+          `key1` int(10) NOT NULL default 0,
+          `key2` int(10) NOT NULL default 0,
+          `url` varchar(255) NOT NULL default '',
+          PRIMARY KEY (`lfl_id`),
+          UNIQUE KEY `ux_url` (`url`,`module`,`key1`,`key2`)   
+          ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;"        
+        );
+      break;
+    default:
+      drupal_set_message("Unsupported DB type $dbType");
+      break;
+    }
+  }
+   
+/**
+ * Implement hook_uninstall:
+ * - remove configuration settings (persistent variables)
+ * - remove blocks
+ * 
+ * By convention, all persistent variables in the main class of a module 
+ * are named VAR_something, so we can find them all safely using reflection.
+ * 
+ * @return void
+ */
+function links_filter_uninstall()
+  { 
+  // 1. Obtain the class definition to enable Reflection
+  $pwd = dirname(drupal_get_filename('module', 'links_filter'));
+  
+  // 2. Remove the module settings
+  // Nothing yet
+    
+  // 3. Remove the module blocks
+  $sq = "DELETE FROM {blocks} WHERE module = 'links_filter'";
+  $ret = db_query($sq);
+  drupal_set_message(t('Removed links_filter blocks.'));
+  }

+ 249 - 0
links_filter.module

@@ -0,0 +1,249 @@
+<?php
+/**
+ * A module to display blocks selected by terms in a taxonomy vocabulary,
+ * as long as they are newer than a set limit
+ *
+ * The module defines one block for each term in the vocabulary.
+ *
+ * Settings allows the administrator to choose
+ *   - the vocabulary to be used to select nodes
+ *   - the number of days nodes are considered for display
+ *
+ * Blocks without matching nodes do not appear.
+ *
+ * This file contains the drupal "glue"
+ * 
+ * @author     Frederic G. MARAND
+ * @version    CVS: $Id: taxonews.module,v 1.10.6.9 2008/06/15 21:19:36 fgm Exp $
+ * @copyright  2005-2008 Ouest Systèmes Informatiques (OSI)
+ * @license    http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
+ * @link       http://drupal.org/project/taxonews
+ * @since      Version 1.1
+ * @package    taxonews
+ */
+
+class Links_Filter
+  {
+  const PATH_SETTINGS   = 'admin/settings/links_filter';
+  
+  static public function adminSettings()
+    {
+    $form =array();
+    
+    return $form;
+    }
+  }
+
+/**
+ * check requirements
+ * PHP 6 not yet tested either
+ */
+list($major, $minor, $patch) = explode('.', PHP_VERSION);
+if (($major != 5) || ($minor == 0))
+  {
+  die('Links_filter requires PHP &ge; 5.1. You are using PHP ' . PHP_VERSION);
+  }
+unset($major, $minor, $patch);
+
+$_links_filterErrorReporting = error_reporting(E_ALL | E_STRICT);
+
+/**
+ * Until a more generic way to use class methods as callbacks is available
+ * or included in core
+ *
+ * @param string $method The name of the method to be invoked
+ * @return mixed Returns the result of the invoked method
+ */
+function _links_filter_form_rerouter($method)
+  {
+  $args = func_get_args();
+  $ret = call_user_func_array(array('Links_filter', $method), $args);
+  return $ret;
+  }
+
+function _links_filter_process($text)
+  {
+  $arBacktrace = debug_backtrace();
+  $log = NULL;
+  watchdog('links_filter', var_export($arBacktrace, true), WATCHDOG_NOTICE);
+  if (count($arBacktrace) >= 7)
+    {
+    $bt5 = $arBacktrace[5];
+    $bt6 = $arBacktrace[6];
+    
+    if ($bt6['function'] = 'node_build_content') // viewing or indexing a node: log its nid/vid
+      {
+      //dsm("Viewing nid " . $bt6['args'][0]->nid . ' vid ' . $bt6['args'][0]->vid);
+      $log = array(0, 'node', $bt6['args'][0]->nid, $bt6['args'][0]->vid);
+      }
+    elseif ($bt5['function'] == 'block_block' && $bt5['args'][0] == 'view')
+      {
+      //dsm("Viewing custom block delta " . $bt5['args'][1]);
+      $log = array(0, 'block', $bt5['args'][1], 0);
+      }
+    }
+    
+  if (!empty($log))
+    {
+    $sqCount = 'SELECT count(lfl.lfl_id) '
+        . 'FROM {lf_links} lfl '
+        . "WHERE /* id %d */ lfl.module = '%s' AND lfl.key1 = %d AND lfl.key2 = %d "
+        . " AND lfl.url = '%s' ";
+    /*
+     * This is an admin-only module, so we do NO access control
+     */
+    $arMatches = array();
+    // @todo PREG can probably be improved
+    $matchCount = preg_match_all('@<a\s.*href="(.*)".*>@iU', $text, $arMatches);
+    if ($matchCount > 0)
+      {
+      foreach ($arMatches[1] as $match)
+        {
+        $log[4] = $match; 
+        $count = db_result(db_query($sqCount, $log));
+        if ($count == 0)
+          {
+          $newLid = db_next_id('link_filter_lfl_id');
+          $log[0] = $newLid;
+          $sqInsert = 'INSERT INTO {lf_links} '
+            . '(lfl_id, module, key1, key2, url) '
+            . " VALUES (%d, '%s', %d, %d, '%s') ";
+          db_query($sqInsert, $log); 
+          }
+        }
+      }
+    }
+  }
+
+/**
+ * -----------------------------------------------------------------------------
+ * Drupal hooks below
+ * -----------------------------------------------------------------------------
+ */
+
+/**
+ * Implement hook_help
+ *
+ * @param string $section
+ * @return string HTML
+ */
+function links_filter_help($section)
+  {
+  $ret = NULL;
+  $help = t('<p>Store a list of links present in filtered content.</p>') ;
+  switch ($section)
+    {
+    case 'admin/help#links_filter':
+      $ret = $help 
+      . t('<p>More help later.</p>');
+      break;
+    case 'admin/modules#description':
+      $ret = $help;
+      break;
+    }
+  return $ret;
+  }
+
+/**
+ * Implement hook_block
+ *
+ * @param string $op list|view|configure|save
+ * @param int $delta
+ * @param array $edit
+ * @return mixed either void or HTML for blocks/block list
+ * @see Taxonews::blockList
+ * @see Taxonews::blockView
+ */
+function links_filter_block($op = 'list', $delta = 0, $edit = array())
+  {
+  $ret = NULL;
+  switch ($op)
+    {
+    case 'list':      break;
+    case 'view':      break;
+    case 'configure': break;
+    case 'save':      break;
+    default:          break;
+    }
+  return $ret;
+  }
+
+/**
+ * Implement hook_menu
+ *
+ * @param boolean $may_cache
+ * @return array
+ */
+function links_filter_menu($may_cache)
+  {
+  if ($may_cache)
+    {
+    $items[] = array
+      (
+      'title'       => t('Links filter'),
+      'description' => t('Define the various parameters used by the links_filter module'),
+      'path'        => Links_filter::PATH_SETTINGS,
+      'callback'    => 'drupal_get_form',
+      'callback arguments' => array('_links_filter_form_rerouter', 'adminSettings'),
+      'access'      => user_access('administer site configuration'),
+      );
+    }
+
+  return $items;
+  }
+
+function links_filter_filter_tips($delta, $format, $long = FALSE)
+  {
+  dsm(array("links_filter_filter_tips", 'delta' => $delta, 'format' => $format, 'long' => ($long ? 'True' : 'False')));
+  $ret = 'Links in content are logged for later analytics. Does not modifiy content display';
+  return $ret;
+  }
+ 
+function links_filter_filter($op, $delta = 0, $format = -1, $text = '')
+  {
+  //dsm(array('lf_filter', 'op' => $op, 'delta' => $delta, 'format' => $format, 'text' => check_plain($text)));
+  switch ($op)
+    {
+    case 'list': // provide a list of available filters. Returns an associative array of filter names with numerical keys. These keys are used for subsequent operations and passed back through the $delta parameter.
+      $ret = array
+        (
+        'Links filter',
+        );
+      break; 
+      
+    case 'no cache': // Return true if caching should be disabled for this filter.
+      $ret = TRUE;
+      break;
+      
+    case 'description': // Return a short description of what this filter does.
+      $ret = 'Catch links in content for analysis';
+      break;
+      
+    case 'prepare': // Return the prepared version of the content in $text.
+      $ret = $text;
+      break;
+      
+    case 'process': // Return the processed version of the content in $text.
+      _links_filter_process($text);
+      return $text;
+      break;
+      
+    case 'settings': // Return HTML form controls for the filter's settings. 
+      // These settings are stored with variable_set() when the form is submitted. 
+      // Remember to use the $format identifier in the variable and control names 
+      // to store settings per input format (e.g. "mymodule_setting_$format").
+      $form = array();
+      $form['boo'] = array
+        (
+        '#type' => 'markup',
+        '#value' => '<p>Some markup</p>',
+        );
+      $ret = $form;
+      break;
+    }
+    
+  return $ret;
+  }
+
+error_reporting($_links_filterErrorReporting);
+unset($_links_filterErrorReporting);