]*)([^>]*)>(.+?)@ise";
$node->body = preg_replace($pattern, "''.stripslashes('\\4').' ['. print_friendly_urls(stripslashes('\\2')) .']'", $node->body);
$urls = print_friendly_urls();
if (count($urls)) {
$node->pfp_links = '';
$max = count($urls);
for ($i = 0; $i < $max; $i++) {
$node->pfp_links .= '['. ($i + 1) .'] '. $urls[$i] ."
\n";
}
}
}
init_theme();
$node->logo = !empty($print_settings['logo_url']) ? $print_settings['logo_url'] : theme_get_setting('logo');
/* Grab and format the src URL */
$node->source_url = url("node/$node->nid", NULL, NULL, TRUE);
$node->language = $GLOBALS['locale'];
$node->printcss = empty($print_settings['css']) ? 'misc/print.css' : $print_settings['css'];
$robots_meta = _print_robots_meta_generator();
include_once('print.node.tpl.php');
}
/**
* Renders a print friendly version of profile pages.
*/
function print_generate_profile() {
global $base_url;
$source_url = $base_url . substr($_GET['q'], 5);
$language = $GLOBALS['locale'];
$name = arg(2);
$value = arg(3);
$field = db_fetch_object(db_query("SELECT DISTINCT(fid), type, title, page, visibility FROM {profile_fields} WHERE name = '%s'", $name));
$robots_meta = _print_robots_meta_generator();
$print_settings = variable_get('print_settings', NULL);
$node->printcss = empty($print_settings['css']) ? 'misc/print.css' : $print_settings['css'];
if ($name && $field->fid) {
// Do not allow browsing of private fields by non-admins
if (!user_access('administer users') && $field->visibility == PROFILE_PRIVATE) {
drupal_access_denied();
return;
}
// Compile a list of fields to show
$fields = array();
$result = db_query('SELECT name, title, type FROM {profile_fields} WHERE fid != %d AND visibility = %d ORDER BY weight', $field->fid, PROFILE_PUBLIC_LISTINGS);
while ($record = db_fetch_object($result)) {
$fields[] = $record;
}
// Determine what query to use:
switch ($field->type) {
case 'checkbox':
$query = 'v.value = 1';
break;
case 'selection':
$query = "v.value = '". db_escape_string($value) ."'";
break;
case 'list':
$query = "v.value LIKE '%%". db_escape_string($value) ."%%'";
break;
default:
drupal_not_found();
return;
}
// Extract the affected users:
$result = db_query("SELECT u.uid FROM {users} u INNER JOIN {profile_values} v ON u.uid = v.uid WHERE v.fid = %d AND $query", $field->fid);
$output = '';
while ($account = db_fetch_object($result)) {
$user = user_load(array('uid' => $account->uid));
$sort[$user->profile_lastname] = $user;
}
ksort($sort);
foreach ($sort as $user) {
$output .= theme('profile_profile', $user, $fields);
}
if ($field->type == 'selection' || $field->type == 'list') {
$title = strtr($field->page, array('%value' => theme('placeholder', $value)));
}
else {
$title = $field->page;
}
$output .= '
';
include_once('print.profile.tpl.php');
}
else if ($name && !$field->id) {
drupal_not_found();
}
else {
// Compile a list of fields to show
$fields = array();
$result = db_query('SELECT name, title, type FROM {profile_fields} WHERE visibility = %d', PROFILE_PUBLIC_LISTINGS);
while ($record = db_fetch_object($result)) {
$fields[] = $record;
}
// Extract the affected users:
$result = pager_query("SELECT uid FROM {users} WHERE uid > 0 ORDER BY access DESC", 20, 0, NULL);
$output = '';
while ($account = db_fetch_object($result)) {
$output .= theme('profile_profile', user_load(array('uid' => $account->uid)), $fields);
}
$output .= '
';
$output .= theme('pager', NULL, 20);
$title = t('user list');
include_once('print.profile.tpl.php');
}
}
function print_friendly_urls($url = 0) {
global $base_url;
static $urls = array();
if ($url) {
if(strpos($url, '://') || preg_match("/^mailto:.*?@.*?\..*?$/iu", $url)) {
$urls[] = $url;
} else {
$base_url. '/'. url($url);
}
return count($urls);
}
return $urls;
}
/********************************************************************
* Module Functions :: Themeable Functions
********************************************************************/
function theme_print_link($node) {
return array('title' => t('Printer friendly version'),
'href' => "node/$node->nid/print",
'attributes' => array('title' => t('Display a printer friendly version of this page.')),
);
}