Subversion Repositories My Stuff

Rev

Rev 12 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php

///////////////////////////////////////////////////////////////////////////////////////
// Originally socialBookmarks v1.0 - 04-10-2006
// Currently SocialBookmarking v.1.01 01-30-2009
// GPL Licensing malarky. Use it, change it  whatever. As long as it's useful to you :)
// Originally created by Paul Hodgson, 01-10-2006 or 10-01-2006 if you're in the US :)
// Modified/Updated by Eduardo Martinez, 12-28-2009
///////////////////////////////////////////////////////////////////////////////////////

function smarty_cms_function_SocialBookmarking($params, &$smarty)
{

    $url_array = array(

                        "delicious" => array("url" => "http://del.icio.us/post?url=[thisurl]&amp;title=[title]",
                                        "alt" => "del.icio.us",
                                        "image" => "delicious.png",
                                        "title" => "Submit to del.icio.us"),
                               
                        "digg" => array("url" => "http://digg.com/submit?phase=2&amp;url=[thisurl]",
                                        "alt" => "digg",
                                        "image" => "digg.png",
                                        "title" => "Submit to digg"),
                       
                        //new Sites added by Eduardo
                        "stumbleupon" => array("url" => "http://www.stumbleupon.com/submit?url=[thisurl]",
                                        "alt" => "stumbleupon",
                                        "image" => "stumble.png",
                                        "title" => "Submit to StumbleUpon"),

                        "buzzup" => array("url" => "http://buzz.yahoo.com/submit/?submitUrl=[thisurl]",
                                        "alt" => "buzzup",
                                        "image" => "buzzup.png",
                                        "title" => "Submit to buzzup"),

                        "BlinkList" => array("url" => "http://blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=[thisurl]",
                                        "alt" => "BlinkList",
                                        "image" => "blinklist.png",
                                        "title" => "Submit to BlinkList"),

                        "mixx" => array("url" => "http://www.mixx.com/submit?page_url=[thisurl]",
                                        "alt" => "mixx",
                                        "image" => "mixx.png",
                                        "title" => "Submit to mixx"),

                        "myspace" => array("url" => "http://www.myspace.com/Modules/PostTo/Pages/?l=3&amp;u=[thisurl]",
                                        "alt" => "myspace",
                                        "image" => "myspace.png",
                                        "title" => "Post to myspace"),

                        "LinkedIn" => array("url" => "http://www.linkedin.com/shareArticle?mini=true&amp;url[thisurl]",
                                        "alt" => "linkedin",
                                        "image" => "linkedin.png",
                                        "title" => "Post to LinkedIn"),

                        "facebook" => array("url" => "http://www.facebook.com/share.php?u=[thisurl]",
                                        "alt" => "facebook",
                                        "image" => "facebook.png",
                                        "title" => "Post to facebook"),
                        // end of new Social Sites
                       
                        "reddit" => array("url" => "http://reddit.com/submit?url=[thisurl]&amp;title=[title]",
                                        "alt" => "reddit.com",
                                        "image" => "reddit.png",
                                        "title" => "Submit to reddit.com"),

                        "magnolia" => array("url" => "http://ma.gnolia.com/bookmarklet/add?url=[thisurl]&amp;title=[title]",
                                        "alt" => "ma.gnolia.com",
                                        "image" => "magnolia.png",
                                        "title" => "Submit to ma.gnolia.com"),

                        "newsvine" => array("url" => "http://www.newsvine.com/_tools/seed&amp;save?u=[thisurl]&amp;h=[title]",
                                        "alt" => "newsvine.com",
                                        "image" => "newsvine.png",
                                        "title" => "Submit to newsvine.com"),

                        "furl" => array("url" => "http://www.furl.net/storeIt.jsp?u=[thisurl]&amp;t=[title]",
                                        "alt" => "furl.net",
                                        "image" => "furl.png",
                                        "title" => "Submit to furl.net"),

                        "google" => array("url" => "http://www.google.com/bookmarks/mark?op=add&amp;bkmk=[thisurl]&amp;title=[title]",
                                        "alt" => "google",
                                        "image" => "google.png",
                                        "title" => "Submit to Google"),

                        "yahoo" => array("url" => "http://myweb2.search.yahoo.com/myresults/bookmarklet?u=[thisurl]&amp;t=[title]",
                                        "alt" => "yahoo",
                                        "image" => "yahoo.png",
                                        "title" => "Submit to Yahoo"),

                        "technorati" => array("url" => "http://technorati.com/cosmos/search.html?url=[thisurl]&amp;t=[title]",
                                        "alt" => "technorati.com",
                                        "image" => "technorati.png",
                                        "title" => "Search on technorati.com"),

            "twitter" => array("url" => "http://twitter.com/home?status=[thisurl]",
                                        "alt" => "twitter",
                                        "image" => "twitter.png",
                                        "title" => "Submit to twitter"),

                        "identi" => array("url" => "http://identi.ca/notice/new?status_textarea=[thisurl]",
                                        "alt" => "identi.ca",
                                        "image" => "identi_ca.png",
                                        "title" => "Submit to identi.ca"),

                //This is part added by Andrzej Kardaś with support to polish social sites
                        "kciuk" => array("url" => "http://www.kciuk.pl/Dodaj-link/?[thisurl]/?[title]",
                                        "alt" => "kciuk",
                                        "image" => "kciuk.png",
                                        "title" => "Submit to kciuk"),

                        "wykop" => array("url" =>"http://www.wykop.pl/add2/link/url,[thisurl],title,[title]",
                                        "alt" => "wykop",
                                        "image" => "wykop.png",    
                                        "title" => "Submit to wykop"),

                        "blip" => array("url" =>"http://blip.pl/dashboard?body=[thisurl]",
                                        "alt" => "blip",
                                        "image" => "blip.png",
                                        "title" => "Submit to blip"),

            "sledzik" => array("url" => "http://nasza-klasa.pl/sledzik?shout=[thisurl]",
                                        "alt" => "śledzik",
                                                                                "image" => "sledzik.png",
                                        "title" => "Submit to Śledzik")
                //end of Andrzej Kardaś part
                );

    global $gCms;  // Eduardo
                //global $gCms, $config;
    $title_prefix = isset($params['title'])?$params['title']:""; // Page title prefix.
    $link_target = isset($params['target'])?$params['target']:""; // _blank etc.
    $submitto = isset($params['submitto'])?$params['submitto']:""; // array containing list of sites to print links to
    $img_dir = isset($params['img_dir'])?$params['img_dir']:""; //directory images are uploaded to
        $real_url = (isset($params['real_url']) && $params['real_url']);
    $pageinfo = &$gCms->variables['pageinfo'];
    $curtitle = urlencode($title_prefix);
    $curtitle .= urlencode(cms_htmlentities($pageinfo->content_title)); //title with prefix

        if($real_url){
                $isHTTPS = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on");
                $port = (isset($_SERVER["SERVER_PORT"]) && ((!$isHTTPS && $_SERVER["SERVER_PORT"] != "80") || ($isHTTPS && $_SERVER["SERVER_PORT"] != "443")));
                $port = ($port) ? ':'.$_SERVER["SERVER_PORT"] : '';
                $url = ($isHTTPS ? 'https://' : 'http://').$_SERVER["SERVER_NAME"].$port.$_SERVER["REQUEST_URI"];
        }else{ 
                $hm =& $gCms->GetHierarchyManager();
                $page_content_id = $gCms->variables['content_id'];
                $curnode =& $hm->getNodeById($page_content_id);
                $curcontent =& $curnode->GetContent();
                $url = $curcontent->GetURL(); // url of current page
        }
        $url = urlencode($url);
       
    if ($link_target != "") {
       $target = ' target="'.$link_target.'"';
    } else {
       $target = "";
    }
   
    if ($img_dir == "") {
                        //$img_dir = $config['root_url']."/images/socialBookmarking/";
      $img_dir = "images/socialbookmarking/";  // Eduardo
    }

    $result = " ";

    if ($submitto == "all" || $submitto == "ALL" || $submitto == "All" || $submitto == "") {

       foreach ($url_array as $value) {

          $print_url = str_replace("[thisurl]", $url, $value["url"]);
          $print_url = str_replace("[title]", $curtitle, $print_url);
          $result .= '<a href="'.$print_url.'" title="'.$value["title"].'" rel="nofollow"'.$target.'><img src="'.$img_dir.$value["image"].'" alt="'.$value["alt"].'" class="social-img"  /></a> ';
       }

    } else {

       $submit_array = explode("|",$submitto);

       foreach($submit_array as $value ) {

          $print_url = str_replace("[thisurl]", $url, $url_array[$value]["url"]);
          $print_url = str_replace("[title]", $curtitle, $print_url);
          $result .= '<a href="'.$print_url.'" title="'.$url_array[$value]["title"].'" rel="nofollow"'.$target.'><img src="'.$img_dir.$url_array[$value]["image"].'" alt="'.$url_array[$value]["alt"].'" class="social-img" /></a> | ';

       }

    }

        return $result;

}

function smarty_cms_help_function_SocialBookmarking() {
        ?>
        <h3>What does this do?</h3>
        <p>Prints links to submit the page to various social Bookmarks managers - del.icio.us, digg.com, reddit.com, ma.gnolia.com, newsvine.com, furl.net, google, yahoo, technorati, stumbleupon, buzzup, blinklist, mixx, myspace, linkedin and facebook</p>
        <h3>How do I use it?</h3>
        <p>Insert the tag into your template/page: <code>{socialBookmarking}</code> please notice the lowercase 's' in the tag.</p>
        <h3>What parameters does it take?</h3>
        <p><ul><li><em>(optional)</em> title - allows text to be prefixed as a constant to the title information. Eg <code>{SocialBookmarking title="My Website - "}</code></li>
        <li><em>(optional)</em> target - populates the "target" atribute of the link. _blank, etc.  eg <code>{SocialBookmarking target="_blank"}</code></li>
        <li><em>(optional)</em> submitto - choose which Social Bookmark Managers to submit to. Values separated by a pipe |. Eg <code>{SocialBookmarking submitto="delicious|digg|reddit"}</code>. <strong>Possible values:</strong>
        delicious, digg, reddit, magnolia, newsvine, furl, google, yahoo, technorati, <strong>OR</strong> all (will print all values. If the value "all" is used, do not enter any other value). Leaving this parameter blank, or not using this parameter will automatically print all supported Social Bookmark links.</li>
        <li><em>(optional)</em> img_dir - the directory you have uploaded the images to. <strong>DO NOT DEFINE, OR JUST LEAVE BLANK IF YOU HAVE UPLOADED TO THE DEFAULT INSTALL DIRECTORY - /images/socialbookmarking/</strong> (<strong>Important:</strong>: if you define a directory, include the leading and trailing slashes / e.g. <code>{SocialBookmarking img_dir="<strong>/</strong>my/image/directory<strong>/</strong>"}</code></li>
        <li><em>(optional)</em> real_url - leave empty or set to 0 to use the content page url (without consideration for modules), and set to 1 to use the real url.</li>
        </ul></p>
        <?php
}

function smarty_cms_about_function_SocialBookmarking() {
        ?>
        <p>Author: Paul Hodgson<br/>
        Updated/Maintained by: Eduardo Martinez (hexdj)</p>
        <p>Version: 1.2</p>
        <p>Change History:<br/>
        1.2 - Minor update: clarified help text.<br />
        1.1 - Fixed notices that were displayed on some servers and other fixes (thanks to plger).<br/><br/>
        1.01 - Added in version 1.01: stumbleupon, buzzup, blinklist, mixx, myspace, linkedin and facebook, fixed issue with default images path, updated icons<br/><br/>
        1.0 - The directory the images are stored in can be changed from the default install dir, and the dir defined within the tag.<br/>
            - Cleaned up some code, added more comments etc.<br/><br/>
        0.3 Beta 1 - added the "submitto" parameter, allowing a selection ro be made, on which Social Bookmarks are output.<br />
                   - added the variable <code>$img_dir</code> to the code, so any directory can be used to store the images<br /><br/>
        0.2 Beta 1 - added two parameters, "title" and "target"<br /><br />
        0.1 Beta 1 - First release
        </p>
        <?php
}
?>