= 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('@@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('

Store a list of links present in filtered content.

') ; switch ($section) { case 'admin/help#links_filter': $ret = $help . t('

More help later.

'); 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' => '

Some markup

', ); $ret = $form; break; } return $ret; } error_reporting($_links_filterErrorReporting); unset($_links_filterErrorReporting);