? banner-megapatch.patch
? banner-settings-menu.patch
Index: banner.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/banner/banner.install,v
retrieving revision 1.9
diff -u -r1.9 banner.install
--- banner.install 10 Dec 2006 20:59:30 -0000 1.9
+++ banner.install 26 Dec 2006 22:40:07 -0000
@@ -15,7 +15,7 @@
target VARCHAR(8) NOT NULL DEFAULT '',
workflow TINYINT UNSIGNED NOT NULL DEFAULT '0',
mode TINYINT UNSIGNED NOT NULL DEFAULT '0',
- content TEXT,
+ banner_content TEXT,
cache TEXT,
-- notifications
@@ -60,7 +60,7 @@
target varchar(8) NOT NULL DEFAULT '',
workflow smallint NOT NULL DEFAULT '0',
mode smallint NOT NULL DEFAULT '0',
- content text NOT NULL DEFAULT '',
+ banner_content text NOT NULL DEFAULT '',
cache text NOT NULL DEFAULT '',
notify_day smallint NOT NULL DEFAULT '0',
@@ -139,3 +139,19 @@
variable_del('banner_renewal_message');
variable_del('banner_notify_failed');
}
+
+/* Rename content column, it conflicts with Drupal 5. */
+function banner_update_1() {
+ $ret = array();
+ switch ($GLOBALS['db_type']) {
+ case 'mysql':
+ case 'mysqli':
+ $ret[] = update_sql('ALTER TABLE {banner} CHANGE COLUMN content banner_content TEXT');
+ break;
+ case 'pgsql':
+ db_change_column($ret,'banner','content','banner_content','TEXT');
+ break;
+ }
+ return $ret;
+}
+
Index: banner.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/banner/banner.module,v
retrieving revision 1.72
diff -u -r1.72 banner.module
--- banner.module 10 Dec 2006 21:40:36 -0000 1.72
+++ banner.module 26 Dec 2006 22:40:07 -0000
@@ -19,7 +19,6 @@
// FIXME: add admin notification on new banner submission
// FIXME: check that 'administer banners' role can delete/edit all banners.
// FIXME: check: only show stats to admin or banner owner
-// FIXME: try to get size of remote banners / make width/height editable?
// FIXME: add banner type to admin overviews?
// FIXME: test availability of remote banner (do it when trying to get size)?
// FIXME: add help text on admin/banner and admin/help/banner
@@ -384,6 +383,16 @@
'weight' => 5,
);
+ // settings page
+ $items[] = array(
+ 'path' => 'admin/settings/banner',
+ 'title' => t('Banner'),
+ 'description' => t('Manage Banner settings.'),
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => 'banner_admin_settings',
+ 'access' => user_access('administer site configuration'),
+ );
+
// admin menu
$items[] = array(
'path' => 'admin/content/banner',
@@ -505,21 +514,43 @@
}
break;
case BANNER_TEXT:
- if (empty($node->content)) {
- form_set_error('content', t('You need to enter the banner text in the content field to use the selected mode.'));
+ if (empty($node->banner_content)) {
+ form_set_error('banner_content', t('You need to enter the banner text in the content field to use the selected mode.'));
}
break;
case BANNER_JAVASCRIPT:
- if (empty($node->content)) {
- form_set_error('content', t('You need to enter the script in the content field to use the selected mode.'));
+ if (empty($node->banner_content)) {
+ form_set_error('banner_content', t('You need to enter the script in the content field to use the selected mode.'));
}
break;
case BANNER_REMOTE:
- if (valid_url($node->content, TRUE)) {
- // FIXME: check that remote image exists!
- // FIXME: only do this if allow_url_fopen = On
- if (!(list($node->width, $node->height) = getimagesize($node->content))) {
- drupal_set_message(t('Could not determine size of remote image.'), 'error');
+ if (valid_url($node->banner_content, TRUE)) {
+ // Have Drupal fetch a copy of the remote file for us.
+ $result = drupal_http_request($node->banner_content, array(), 'GET');
+ if ($result->code == 200) { // Status: OK
+ // Acquire a temporary file.
+ $file = tempnam(file_directory_temp(), 'file');
+ $handle = fopen($file, 'wb');
+ if ($handle) {
+ // Copy our data into the temporary file
+ fwrite($handle, $result->data);
+ fclose($handle);
+ if ((list($node->width, $node->height) = getimagesize($file))) {
+ form_set_value($form['banner']['width'], $node->width);
+ form_set_value($form['banner']['height'], $node->height);
+ }
+ else {
+ drupal_set_message(t('Could not determine size of remote image.'), 'error');
+ }
+ // Delete our temporary file
+ file_delete($file);
+ }
+ else {
+ drupal_set_message(t('Could not create temporary file while attempting to determine size of remote image.'), 'error');
+ }
+ }
+ else {
+ drupal_set_message(t('Could not determine size of remote image: Unexpected response from remote webserver.'), 'error');
}
}
else {
@@ -564,7 +595,6 @@
global $user;
$node = node_prepare($node, $teaser);
-
$output = '';
switch ($node->mode) {
case BANNER_UPLOAD:
@@ -1065,7 +1095,7 @@
'target' => '',
'workflow' => 0,
'mode' => 0,
- 'content' => '',
+ 'banner_content' => '',
'cache' => '',
// notifications
@@ -1189,7 +1219,7 @@
$banners[$node->nid]->views_week_max = $node->views_week_max;
$banners[$node->nid]->views_max = $node->views_max;
if ($node->mode == BANNER_JAVASCRIPT) {
- $banners[$node->nid]->html = $node->content;
+ $banners[$node->nid]->html = $node->banner_content;
}
else {
$banners[$node->nid]->html = "document.write('".str_replace(array("'", "\n", "\r"), array("\"", " ", " "), _banner_view($node))."');";
@@ -1640,7 +1670,6 @@
'#default_value' => $node->url,
'#description' => t('Target URL for this banner. If your are linking to an internal page, you must provide the full URL (i.e. http://yoursite.com/node/42 instead of node/42).'),
);
-/* FIXME: currently this makes attachments die
$form['target'] = array(
'#type' => 'select',
'#title' => t('Target'),
@@ -1652,9 +1681,8 @@
'_parent' => '_parent',
'_top' => '_top',
),
- '#description' => t('Frame target for the banner URL. See W3C\'s documentation on frame target names for a description of the available options.', array('%url' => 'http://www.w3.org/TR/html4/types.html#h-6.16')),
+ '#description' => t('Frame target for the banner URL. See W3C\'s documentation on frame target names for a description of the available options.', array('@url' => 'http://www.w3.org/TR/html4/types.html#h-6.16')),
);
-*/
if (user_access('administer banners')) {
// FIXME: owner of banner must be able to disable banner
$form['workflow'] = array(
@@ -1680,10 +1708,10 @@
'#options' => _banner_get_mode_options(),
'#description' => t('Choose the desired mode for this banner. See the banner help for a description of the available modes.', array('%url' => url('admin/help/banner'))),
);
- $form['content'] = array(
+ $form['banner_content'] = array(
'#type' => 'textarea',
'#title' => t('Content'),
- '#default_value' => $node->content,
+ '#default_value' => $node->banner_content,
'#rows' => 8,
'#description' => t('Enter the ad content. This can either be text, javascript or the URL of a remote image. If you are adding a text ad, the following placeholders are available: %url and %target, which are replaced with the banner URL and the banner target respectively (these placeholders can also be used in uploaded text banners). If no %url placeholder is present, a link to the banner URL will be added after the banner text.'),
);
@@ -1938,21 +1966,19 @@
* Themed banner
*/
function theme_banner_view_remote($node) {
-/*
$img_attr = array(
'width' => $node->width,
'height' => $node->height,
'alt' => '',
);
-*/
+
// FIXME: used a couple of times in the code, move to separate function
$url_attr = array('title' => $node->url);
if ($node->target != '_none') {
$url_attr['target'] = $node->target;
}
- $output = l(theme('banner_image', $node->content, $img_attr), 'banner/'. $node->nid, $url_attr, NULL, NULL, FALSE, TRUE);
-
+ $output = l(theme('banner_image', $node->banner_content, $img_attr), 'banner/'. $node->nid, $url_attr, NULL, NULL, FALSE, TRUE);
return $output;
}
@@ -1967,20 +1993,20 @@
function theme_banner_view_text($node) {
$output = '';
- if (strpos($node->content, '%url')) {
+ if (strpos($node->banner_content, '%url')) {
// %url present in content, replace with banner link and target
$replace = array(
'%url' => check_url(url('banner/'. $node->nid)),
'%target' => $node->target != '_none' ? $node->target : '_self',
);
- $output .= strtr($node->content, $replace);
+ $output .= strtr($node->banner_content, $replace);
}
else {
// no %url in content, add link at the end
$attr = array(
'target' => $node->target != '_none' ? $node->target : '_self',
);
- $output .= $node->content .' ';
+ $output .= $node->banner_content .' ';
$output .= l(t('»'), 'banner/'. $node->nid, $attr, NULL, NULL, FALSE, TRUE);
}