<commit_before><?php
/**
 * Bookmark Helper
 * 
 * @author <NAME>
 * @version 1.1
 * returns social bookmarklets
 * Note: You will need to change the domain name to match your domain name
 * Thanks to http://kevin.vanzonneveld.net/ for the social bookmark list
 * Thanks to <NAME> for the original helper
 */
class BookmarkHelper extends Helper{
	var $helpers = array('Html');

         /**
	 * Folder where all the bookmark images are located.
	 */
	var $imgFolder = "plugins/bookmark/vendors/img/bookmarks/"; 
	
	/**
	 * change this defaults if you want to use a different set of bookmarklets
	 * The array elements should correspond to $bookmarks keys
	 */
	var $defaults = array('yahoo', 'google', 'windows', 'facebook', 'digg', 'ask', 'technorati', 'delicious', 'stumble', 'squidoo', 'netscape', 'slashdot', 'reddit', 'furl', 'blinklist', 'dzone', 'swik', 'shoutwire', 'blinkbits', 'spurl', 'diigo', 'tailrank', 'rawsugar');
	
	/**
	 * @param $pagetitle - (required) Title of the Page
	 * @param $url - (optional) URL of the page
	 * @param $sites - (optional)social bookmarks. If not provided the helper uses the defaults set above. The values should match to the keys of the "bookmarks" variable defined below
	 * returns a div with the specified social bookmarklets 
	 */
	function getBookMarks($pagetitle, $url = null, $sites = array()){
		if(empty($url)){
                        /* Note: As an alternative you can try Router::url("", true). This should return the absolute url of the current page, but wasn't working for me. So I used this hack. Hopefully someone can tell me a better way to find absolute path */
			$url = $this->Html->url(null, true);
		} 
		if(empty($sites)){
			$sites = $this->defaults;
		}
		
		$output = "";
		foreach($sites as $site){
			if(!array_key_exists($site, $this->bookmarks)) 
				continue;
				
			//build url
			$link = $this->bookmarks[$site]['link'];
			$link = str_replace('{url}', $url, $link);
			if(substr_count($link, '{title}') > 0)
				$link = str_replace('{title}',urlencode($pagetitle), $link );
			
			$name = $this->bookmarks[$site]['name'];
			$iconLoc = Router::url('/', true) . $this->imgFolder . $this->bookmarks[$site]['icon'];
			$image = $this->Html->image($iconLoc, array('title'=> "{$name}", 'alt'=>"{$name}", 'border'=> "0"));
			
			$output .= $this->Html->link($image, $link, array('escape'=> false)). ' ';
		}
		return '<div id="bookmarklets">' . $output . '</div>';
	}
	
	/**
	 * list of social bookmarks.
	 * if you want to use any other social bookmark, replace the actual URL with "{url}" and title with "{title}". 
	 * See below bookmarks for more details
	 */
	var $bookmarks = array(
		'yahoo' => 
			array(<commit_msg>- fixing bookmark link issue - setting a conservative number of bookmark links<commit_after><?php
/**
 * Bookmark Helper
 * 
 * @author <NAME>
 * @version 1.1
 * returns social bookmarklets
 * Note: You will need to change the domain name to match your domain name
 * Thanks to http://kevin.vanzonneveld.net/ for the social bookmark list
 * Thanks to <NAME> for the original helper
 */
class BookmarkHelper extends Helper{
	var $helpers = array('Html');

         /**
	 * Folder where all the bookmark images are located.
	 */
	var $imgFolder = "/bookmark/img/"; 
	
	/**
	 * change this defaults if you want to use a different set of bookmarklets
	 * The array elements should correspond to $bookmarks keys
	 */
	var $defaults = array('yahoo', 'google', 'windows', 'facebook', 'digg', 'technorati', 'delicious', 'stumble', 'slashdot');
	
	/**
	 * @param $pagetitle - (required) Title of the Page
	 * @param $url - (optional) URL of the page
	 * @param $sites - (optional)social bookmarks. If not provided the helper uses the defaults set above. The values should match to the keys of the "bookmarks" variable defined below
	 * returns a div with the specified social bookmarklets 
	 */
	function getBookMarks($pagetitle, $url = null, $sites = array()){
		if(empty($url)){
            /* Note: As an alternative you can try Router::url("", true). This should return the absolute url of the current page, but wasn't working for me. So I used this hack. Hopefully someone can tell me a better way to find absolute path */
			$url = $this->Html->url(null, true);
		} 
		if(empty($sites)){
			$sites = $this->defaults;
		}
		
		$output = "";
		foreach($sites as $site){
			if(!array_key_exists($site, $this->bookmarks)) 
				continue;
				
			//build url
			$link = $this->bookmarks[$site]['link'];
			$link = str_replace('{url}', $url, $link);
			if(substr_count($link, '{title}') > 0)
				$link = str_replace('{title}',urlencode($pagetitle), $link );
			
			$name = $this->bookmarks[$site]['name'];
			$image = $this->Html->image($this->imgFolder . $this->bookmarks[$site]['icon'], array('title'=> "{$name}", 'alt'=>"{$name}", 'border'=> "0"));
			$output .= $this->Html->link($image, $link, array('escape'=> false)). ' ';
		}
		return '<div id="bookmarklets">' . $output . '</div>';
	}
	
	/**
	 * list of social bookmarks.
	 * if you want to use any other social bookmark, replace the actual URL with "{url}" and title with "{title}". 
	 * See below bookmarks for more details
	 */
	var $bookmarks = array(
		'yahoo' => 
			array(
{'fraction_non_alphanumeric': 0.16127797972068109, 'fraction_numerical': 0.0015305146355462024, 'mean_word_length': 3.6678571428571427, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2198522', 'n_tokens_mistral': 1746, 'n_tokens_neox': 1579, 'n_words': 562}