Zend - The PHP Company




Email

Add Code


Icon Send-To-A-Friend  

Type: class
Added by: iconinteractive
Entered: 10/09/2004
Last modified: 09/12/2003
Rating: - (fewer than 3 votes)
Views: 6398
This class is designed to place a link on any page for a user to click on and recommend the site to a friend. The user can then fill in their name and email address as well as their friend's name and email address, and any comments they would like to include with it. The example URL leads to our freeware archive where the class and all related files can be downloaded in a zip archive.


*  Send to friend class
*  Author: Icon Interactive Group  - www.iconinteractive.com
*  Date: July 20th, 2004
*
*
* This class is designed to place a link on any page for a user to click on and
* recommend the site to a friend. The user can then fill in their name and email
* address as well as their friend's name and email address, and any comments they
* would like to include with it.
*
*    Public methods
*    ------------------
*    SendToFriend()
          This is the constructor for the SendToFriend class. When called, it places
          a small image and a customizable (in global.inc.php) message. When clicked,
          it opens up popup window (sendtofriend.html) and provides a form for the
          user to fill in the appropriate values required to send the email to the
          person's friend.
     
     getTitle()
          This method parses the current website and returns the information between the
          <title> and </title> tags. If no title has been provided, the method returns
          the string "untitled."
********************************************************************************************/
class SendToFriend
{
  function SendToFriend()
  {
    global $IMAGE_LOCATION;
    global $MESSAGE;
  ?>
    <script language='javascript'>
    function sendToFriend(pagetitle)
    {
      var urlName = "sendtofriend.html?pagetitle=" + pagetitle;
      window.open(urlName, '', 'status=no, width=450, height=425, scrollbars=yes');
    }
    </script>
    <a href="javascript:sendToFriend('<?print $this->getTitle();?>');"><img src="<?=$IMAGE_LOCATION?>sendtofriend.gif" border="0" /> <?=$MESSAGE;?></a>
  <?
  
}
  
  function 
getTitle()
  {
    global 
$PHP_SELF;
    
$filename basename($PHP_SELF); //get the core filename
    
    
if( file_exists($filename) ) //if the file can be successfully read
    
{
      
$handle fopen($filename"r");
      
$page fread($handlefilesize("$filename"));
      
fclose($handle);
      
      
//parse the site for the title information
      
list($junk,$title) = explode("<title>",$page);
      list(
$title,$junk) = explode("</title>",$title);
    }
    
    if(
$title//if a title was successfully found
      
return $title;
    else 
//no title was found, return default value
      
return "Untitled";
  }
}
//end class


Usage Example


See the example


Rate This Script





Search



This Category All Categories