Jump to content

Mouse

Members
  • Posts

    95
  • Joined

  • Last visited

    Never

About Mouse

  • Birthday 03/19/1970

Contact Methods

  • Website URL
    http://mouse.nodstrum.com

Profile Information

  • Gender
    Male
  • Location
    Too Close to LONDON

Mouse's Achievements

Member

Member (2/5)

0

Reputation

  1. <?php /** * $Id: buymeabeer.module,v 1.1 2007/05/27 15:34:58 yaph Exp $ * * @file * Author: Ramiro Gómez - http://www.ramiro.org * A Drupal module that allows donations via Paypal to buy beer. */ define('BMAB_ANCHOR_TEXT', t('If you liked this post, buy me a beer.')); define('BMAB_LINK_TITLE_TEXT', t('Donate a beer or two via Paypal.')); /** * Implementation of hook_menu(). */ function buymeabeer_menu($may_cache) { $items = array(); $items[] = array( 'path' => 'admin/settings/buymeabeer', 'title' => t('Buy Me a Beer'), 'description' => t('Enable the node types to display the buy me a beer link, set the paypal e-mail and the anchor text for the link.'), 'callback' => 'drupal_get_form', 'callback arguments' => array('buymeabeer_admin_settings'), 'access' => user_access('administer site configuration'), 'type' => MENU_NORMAL_ITEM ); return $items; } /** * admin settings for the buymeabeer module */ function buymeabeer_admin_settings() { $form = array(); $form['buymeabeer'] = array( '#type' => 'fieldset', '#title' => 'Buy Me a Beer ' . t('settings'), '#collapsible' => TRUE, '#collapsed' => FALSE ); $form['buymeabeer']['buymeabeer_paypal_mail'] = array( '#type' => 'textfield', '#title' => t('Paypal E-mail Addrees'), '#default_value' => variable_get('buymeabeer_paypal_mail', ''), '#size' => 60, '#maxlength' => 60, '#required' => TRUE, '#description' => t('Enter an e-mail address that is enabled to receive paypal payments.') ); $form['buymeabeer']['buymeabeer_anchor_text'] = array( '#type' => 'textfield', '#title' => t('Anchor Text'), '#default_value' => variable_get('buymeabeer_anchor_text', BMAB_ANCHOR_TEXT), '#size' => 60, '#maxlength' => 60, '#description' => t('Enter the anchor text for the link.') ); $form['buymeabeer']['buymeabeer_link_title_text'] = array( '#type' => 'textfield', '#title' => t('Link Title Text'), '#default_value' => variable_get('buymeabeer_link_title_text', BMAB_LINK_TITLE_TEXT), '#size' => 60, '#maxlength' => 60, '#description' => t('Enter the title text for the link. This is what is displayed as a tooltip when the cursor is moved over the link. This text is also used as the paypal donation identifier') ); $form['buymeabeer']['buymeabeer_teaser_full_view'] = array( '#type' => 'select', '#title' => t('Display in teaser and/or full view'), '#default_value' => variable_get('buymeabeer_teaser_full_view', 0), '#options' => array(0 => t('Full view'), 1 => t('Teaser'), 2 => t('Teasers and full view')), '#description' => t('When to display the link.'), ); $form['buymeabeer']['buymeabeer_node_types'] = array( '#type' => 'checkboxes', '#title' => t('Node Types'), '#default_value' => variable_get('buymeabeer_node_types', array()), '#options' => node_get_types('names'), '#description' => t('Enable the node types to display the link for.') ); $form['buymeabeer']['buymeabeer_weight'] = array( '#type' => 'select', '#title' => t('Weight'), '#default_value' => variable_get('buymeabeer_weight', 20), '#options' => drupal_map_assoc(range(-20,20)), '#description' => t('Specifies the position of the link. A low weight, e.g. <strong>-20</strong> will display the link above the content and a high weight, e.g. <strong>20</strong> below the content.') ); return system_settings_form($form); } /** * Implementation of hook_nodeapi(). */ function buymeabeer_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { if ($op == 'view') { //Check our node is one of the checked types if(in_array($node->type, variable_get('buymeabeer_node_types', array()), TRUE)) { $display_link = FALSE; switch (variable_get('buymeabeer_teaser_full_view', 0)) { // display in full view only case 0: if (!$a3) { $display_link = TRUE; } break; // display in teaser only case 1: if ($a3) { $display_link = TRUE; } break; // display in full view and teaser case 2: $display_link = TRUE; break; } if($display_link) { $node->content['buymeabeer_ad'] = array( '#value' => theme('buymeabeer_link'), '#weight' => variable_get('buymeabeer_weight', 20) ); } } } } function buymeabeer_paypal_link() { $paypal_mail = variable_get('buymeabeer_paypal_mail', ''); $anchor_text = variable_get('buymeabeer_anchor_text', BMAB_ANCHOR_TEXT); $title_text = variable_get('buymeabeer_link_title_text', BMAB_LINK_TITLE_TEXT); $href = "https://www.paypal.com/cgi-bin/webscr"; $query = "cmd=_xclick&business=$paypal_mail&item_name=$title_text"; return l("<span>".$anchor_text."</span>", $href, array('class' => 'buymeabeer-link', 'title' => $title_text), $query, NULL, TRUE, FALSE); } /** * theme function for link display */ function theme_buymeabeer_link() { $link = buymeabeer_paypal_link(); return '<div class="buymeabeer"><span>'. $link .'</span></div>'; } ?>
  2. Sorry no it just returns "<span>If you like this site please donate to support it.</span>" on the page but thanks!
  3. This code is for a Drupal module i am playing with. i need to get span tags around the <strong>$anchor_text</strong> I have tried every thing i can think of to do it but i have run out of ideas! could someone help me put here? return '<div class="buymeabeer"><span>'. $link .'</span></div>'; almost works but it puts the taggs arround everything and my CSS just wont play nice like that! <?php function buymeabeer_paypal_link() { $paypal_mail = variable_get('buymeabeer_paypal_mail', ''); $anchor_text = variable_get('buymeabeer_anchor_text', BMAB_ANCHOR_TEXT); $title_text = variable_get('buymeabeer_link_title_text', BMAB_LINK_TITLE_TEXT); $href = "https://www.paypal.com/cgi-bin/webscr"; $query = "cmd=_xclick&business=$paypal_mail&item_name=$title_text"; return l($anchor_text, $href, array('class' => 'buymeabeer-link', 'title' => $title_text), $query, NULL, TRUE, FALSE); } /** * theme function for link display */ function theme_buymeabeer_link() { $link = buymeabeer_paypal_link(); return '<div class="buymeabeer">'. $link .'</div>'; } ?>
  4. maybe somthing like...? <?php /* images named 1.jpg, 2.jpg etc. */ // total number of images in the folder $total = "11"; $file_type = ".jpg"; // location of the folder containing the images $image_folder = "images/random"; $start = "1"; $random = mt_rand($start, $total); switch ($url) { case 1: echo "http://flickr.com/photos/account_123"; break; case 2: echo "http://flickr.com/photos/account_246"; break; default: echo "http://flickr.com/"; } $image_name = $random . $file_type; echo "<a href=\"$url\"><img src=\"$image_folder/$image_name\" alt=\"$image_name\" /></a>"; ?>
  5. Thinking about this, would it be the time to use CASE? if so, how so?... sorry, still a noobie here. i got sidetracked from PHP by having children...
  6. For a while now I have been using the following “Random Image” code to display an image into the index page of my site http://afterthemouse.com but now I need to extend it’s scope a little. I need to add a link back to the photographers Flickr account to each photo. How do I structure the array? The thumbnails will be stored locally and serve as a link to the full size Flickr image Many thanks <?php /* images named 1.jpg, 2.jpg etc. */ // total number of images in the folder $total = "11"; $file_type = ".jpg"; // location of the folder containing the images $image_folder = "images/random"; $start = "1"; $random = mt_rand($start, $total); $image_name = $random . $file_type; echo "<img src=\"$image_folder/$image_name\" alt=\"$image_name\" />"; ?>
  7. Hi, I am using the GD Image library to make an image that I want to include in a page. But I cannot just include the GD script into the page as it just prints meaningless code… and I don’t really want to send my users to a page with only the raw image on it so can I redirect the browser back to the previous page but only when the image is created <?php // test vars $firstname = "testing"; $uid = "11"; ////////////////////////// $point = 20; // good for up to around 16 places $text = $firstname; $text = mb_convert_case($text, MB_CASE_UPPER, "UTF-8"); $size = imagettfbbox($point, 0, "nametag.ttf", $text); $xsize = abs($size[0]) + abs($size[2]); $ysize = abs($size[5]) + abs($size[1]); $image = imagecreatefrompng("sml_nm_tg.png"); $imagesize = getimagesize("sml_nm_tg.png"); $textleftpos = round(($imagesize[0] - $xsize) / 2); $texttoppos = round(($imagesize[1] + $ysize) / 2) + 10; $red = imagecolorclosest($image, 255, 51, 0); imagettftext($image, $point, 0, $textleftpos, $texttoppos, $red, "nametag.ttf", $text); header("content-type: image/png"); imagepng($image, "badge_" . $firstname . ".png"); imagedestroy($image); ;?>
  8. Hi, Can anyone tell me in a little detail how to add fonts to my GD Library to cure this error... Warning: imagettfbbox() [function.imagettfbbox]: Could not find/open font in /home/.../testing.php on line 6 Many Thanks
  9. how would i go about saving the new image in a selected file? whilst preserving the transparency???
  10. Many thanks sir but the Define didn't work it out... also isn't that counterproductive if the site user is a a mac or linux addict?
  11. Ken, using the function imagecolorclosest() instead of imagecolorallocat() has done the trick, many thanks. how can i rectify this, is there a way to find out which fonts are on the server (i assume) or can i put one in there? Many thanks Mouse
  12. Well I have had a little play with this and I am not clear on a couple of bits… <?php $point = 18; $text = "Bekky"; // to be users name here $size = imagettfbbox($point, 0, "ARIAL", $text); $xsize = abs($size[0]) + abs($size[2]); $ysize = abs($size[5]) + abs($size[1]); $image = imagecreatefrompng("images/badge/sml_nm_tg.png"); $imagesize = getimagesize("images/badge/sml_nm_tg.png"); $textleftpos = round(($imagesize[0] - $xsize) / 2); $texttoppos = round(($imagesize[1] + $ysize) / 2) + 10; $red = ImageColorAllocate($image, 255, 51, 0); $grey = ImageColorAllocate($image, 102, 153, 153); imagettftext($image, $point, 0, $textleftpos + 1, $texttoppos + 1, $grey, "ARIAL", $text); imagettftext($image, $point, 0, $textleftpos, $texttoppos, $red, "ARIAL", $text); header("content-type: image/png"); imagepng($image); imagedestroy($image); ?> as you can see there is meant to be red writing with a grey drop shadow but as you can see from this local test screen print… <img src="http://mouse.nodstrum.com/images/badge/demo.jpg" /> it just isn’t doing the colours thing… even worse <a href="http://mouse.nodstrum.com/nametag.php">when I try this online I get gibberish</a> any ideas? PLEASE????
  13. many thanks... i'm off to play with the options! Night All
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.