Advertisement
ProFishChris

ProFish Link Generator

Nov 9th, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.39 KB | None | 0 0
  1. <?php
  2.     // Code used to produce styled image links on www.pro-fish.co.uk
  3.     // Creating new content is a simple matter of adding a new MediaLink to the array
  4.  
  5.     // Create a struct for the links
  6.     class MediaLink
  7.     {
  8.         public $nameReadable;
  9.         public $nameInternal;
  10.         public $href;
  11.         public $imageSrc;
  12.         public $title;
  13.        
  14.         function __construct($humanName, $internalName, $linkURL, $imageURL, $linkTitle) {
  15.             $this->nameReadable=$humanName;
  16.             $this->nameInternal=$internalName;
  17.             $this->href=$linkURL;
  18.             $this->imageSrc=$imageURL;
  19.             $this->title=$linkTitle;
  20.         }
  21.     }
  22.    
  23.         // Example array of links to be created
  24.         $pageLinks = array(
  25.            
  26.             new MediaLink("Bitbucket", "bitbucket",
  27.                     "https://bitbucket.org/",
  28.                     "img/bitbucket-icon.png",
  29.                     "Bitbucket Repository"),
  30.            
  31.             new MediaLink("Pastebin", "pastebin",
  32.                     "http://pastebin.com/",
  33.                     "img/pastebin-icon.jpeg",
  34.                     "Pastebin Repository"),
  35.            
  36.             new MediaLink("Twitter", "twitter",
  37.                     "http://www.twitter.com/",
  38.                     "img/twitter-icon.png",
  39.                     "Twitter Feed"),
  40.            
  41.             new MediaLink("LinkedIn", "linkedin",
  42.                     "http://uk.linkedin.com/",
  43.                     "img/linkedin-icon.png",
  44.                     "LinkedIn Portfolio"),
  45.            
  46.             new MediaLink("Stack Overflow","stackoverflow",
  47.                     "http://stackoverflow.com/",
  48.                     "img/stackoverflow-icon.jpg",
  49.                     "StackOverflow Profile"),
  50.            
  51.             new MediaLink("SO Careers", "careersso",
  52.                     "http://careers.stackoverflow.com/",
  53.                     "img/socareers-icon.png",
  54.                     "StackOverflow Careers Profile")
  55.         );
  56.    
  57.  
  58.     // Output all links as images
  59.     function CreateImageLinks($pageLinks)
  60.     {
  61.         // Write HTML to page
  62.         foreach ($pageLinks as $link)
  63.         {
  64.             echo "<div class='imgLink'>";
  65.             echo "<a href='$link->href' target='_blank' title='$link->title'>\n";
  66.             echo "<img src='$link->imageSrc' alt='$link->nameReadable'/></a></div>\n";
  67.         }
  68.     }
  69. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement