Subversion Repositories My Stuff

Rev

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

Rev Author Line No. Line
9 kardasa 1
<?php
2
 
3
///////////////////////////////////////////////////////////////////////////////////////
4
// Originally socialBookmarks v1.0 - 04-10-2006
5
// Currently SocialBookmarking v.1.01 01-30-2009
6
// GPL Licensing malarky. Use it, change it  whatever. As long as it's useful to you :)
7
// Originally created by Paul Hodgson, 01-10-2006 or 10-01-2006 if you're in the US :)
8
// Modified/Updated by Eduardo Martinez, 12-28-2009
9
///////////////////////////////////////////////////////////////////////////////////////
10
 
11
function smarty_cms_function_SocialBookmarking($params, &$smarty)
12
{
13
 
14
    $url_array = array(
15
 
16
                        "delicious" => array("url" => "http://del.icio.us/post?url=[thisurl]&amp;title=[title]",
17
                                        "alt" => "del.icio.us",
18
                                        "image" => "delicious.png",
19
                                        "title" => "Submit to del.icio.us"),
20
 
21
                        "digg" => array("url" => "http://digg.com/submit?phase=2&amp;url=[thisurl]",
22
                                        "alt" => "digg",
23
                                        "image" => "digg.png",
24
                                        "title" => "Submit to digg"),
25
 
26
                        //new Sites added by Eduardo
27
                        "stumbleupon" => array("url" => "http://www.stumbleupon.com/submit?url=[thisurl]",
28
                                        "alt" => "stumbleupon",
29
                                        "image" => "stumble.png",
30
                                        "title" => "Submit to StumbleUpon"),
31
 
32
                        "buzzup" => array("url" => "http://buzz.yahoo.com/submit/?submitUrl=[thisurl]",
33
                                        "alt" => "buzzup",
34
                                        "image" => "buzzup.png",
35
                                        "title" => "Submit to buzzup"),
36
 
18 kardasa 37
                        "BlinkList" => array("url" => "http://blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=[thisurl]",
9 kardasa 38
                                        "alt" => "BlinkList",
39
                                        "image" => "blinklist.png",
40
                                        "title" => "Submit to BlinkList"),
41
 
42
                        "mixx" => array("url" => "http://www.mixx.com/submit?page_url=[thisurl]",
43
                                        "alt" => "mixx",
44
                                        "image" => "mixx.png",
45
                                        "title" => "Submit to mixx"),
46
 
18 kardasa 47
                        "myspace" => array("url" => "http://www.myspace.com/Modules/PostTo/Pages/?l=3&amp;u=[thisurl]",
9 kardasa 48
                                        "alt" => "myspace",
49
                                        "image" => "myspace.png",
50
                                        "title" => "Post to myspace"),
51
 
18 kardasa 52
                        "LinkedIn" => array("url" => "http://www.linkedin.com/shareArticle?mini=true&amp;url[thisurl]",
9 kardasa 53
                                        "alt" => "linkedin",
54
                                        "image" => "linkedin.png",
55
                                        "title" => "Post to LinkedIn"),
56
 
57
                        "facebook" => array("url" => "http://www.facebook.com/share.php?u=[thisurl]",
58
                                        "alt" => "facebook",
59
                                        "image" => "facebook.png",
60
                                        "title" => "Post to facebook"),
61
                        // end of new Social Sites
62
 
63
                        "reddit" => array("url" => "http://reddit.com/submit?url=[thisurl]&amp;title=[title]",
64
                                        "alt" => "reddit.com",
65
                                        "image" => "reddit.png",
66
                                        "title" => "Submit to reddit.com"),
67
 
68
                        "magnolia" => array("url" => "http://ma.gnolia.com/bookmarklet/add?url=[thisurl]&amp;title=[title]",
69
                                        "alt" => "ma.gnolia.com",
70
                                        "image" => "magnolia.png",
71
                                        "title" => "Submit to ma.gnolia.com"),
72
 
73
                        "newsvine" => array("url" => "http://www.newsvine.com/_tools/seed&amp;save?u=[thisurl]&amp;h=[title]",
74
                                        "alt" => "newsvine.com",
75
                                        "image" => "newsvine.png",
76
                                        "title" => "Submit to newsvine.com"),
77
 
78
                        "furl" => array("url" => "http://www.furl.net/storeIt.jsp?u=[thisurl]&amp;t=[title]",
79
                                        "alt" => "furl.net",
80
                                        "image" => "furl.png",
81
                                        "title" => "Submit to furl.net"),
82
 
83
                        "google" => array("url" => "http://www.google.com/bookmarks/mark?op=add&amp;bkmk=[thisurl]&amp;title=[title]",
84
                                        "alt" => "google",
85
                                        "image" => "google.png",
86
                                        "title" => "Submit to Google"),
87
 
88
                        "yahoo" => array("url" => "http://myweb2.search.yahoo.com/myresults/bookmarklet?u=[thisurl]&amp;t=[title]",
89
                                        "alt" => "yahoo",
90
                                        "image" => "yahoo.png",
91
                                        "title" => "Submit to Yahoo"),
92
 
93
                        "technorati" => array("url" => "http://technorati.com/cosmos/search.html?url=[thisurl]&amp;t=[title]",
94
                                        "alt" => "technorati.com",
95
                                        "image" => "technorati.png",
96
                                        "title" => "Search on technorati.com"),
97
 
98
            "twitter" => array("url" => "http://twitter.com/home?status=[thisurl]",
99
                                        "alt" => "twitter",
100
                                        "image" => "twitter.png",
101
                                        "title" => "Submit to twitter"),
102
 
103
                        "identi" => array("url" => "http://identi.ca/notice/new?status_textarea=[thisurl]",
104
                                        "alt" => "identi.ca",
105
                                        "image" => "identi_ca.png",
106
                                        "title" => "Submit to identi.ca"),
107
 
108
                //This is part added by Andrzej Kardaś with support to polish social sites
109
                        "kciuk" => array("url" => "http://www.kciuk.pl/Dodaj-link/?[thisurl]/?[title]",
110
                                        "alt" => "kciuk",
111
                                        "image" => "kciuk.png",
112
                                        "title" => "Submit to kciuk"),
113
 
114
                        "wykop" => array("url" =>"http://www.wykop.pl/add2/link/url,[thisurl],title,[title]",
115
                                        "alt" => "wykop",
116
                                        "image" => "wykop.png",    
117
                                        "title" => "Submit to wykop"),
118
 
119
                        "blip" => array("url" =>"http://blip.pl/dashboard?body=[thisurl]",
120
                                        "alt" => "blip",
121
                                        "image" => "blip.png",
122
                                        "title" => "Submit to blip"),
123
 
124
            "sledzik" => array("url" => "http://nasza-klasa.pl/sledzik?shout=[thisurl]",
125
                                        "alt" => "śledzik",
126
                                                                                "image" => "sledzik.png",
127
                                        "title" => "Submit to Śledzik")
128
                //end of Andrzej Kardaś part
129
                );
130
 
131
    global $gCms;  // Eduardo
132
                //global $gCms, $config;
133
    $title_prefix = isset($params['title'])?$params['title']:""; // Page title prefix.
134
    $link_target = isset($params['target'])?$params['target']:""; // _blank etc.
135
    $submitto = isset($params['submitto'])?$params['submitto']:""; // array containing list of sites to print links to
136
    $img_dir = isset($params['img_dir'])?$params['img_dir']:""; //directory images are uploaded to
137
        $real_url = (isset($params['real_url']) && $params['real_url']);
138
    $pageinfo = &$gCms->variables['pageinfo'];
139
    $curtitle = urlencode($title_prefix);
140
    $curtitle .= urlencode(cms_htmlentities($pageinfo->content_title)); //title with prefix
141
 
142
        if($real_url){
143
                $isHTTPS = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on");
144
                $port = (isset($_SERVER["SERVER_PORT"]) && ((!$isHTTPS && $_SERVER["SERVER_PORT"] != "80") || ($isHTTPS && $_SERVER["SERVER_PORT"] != "443")));
145
                $port = ($port) ? ':'.$_SERVER["SERVER_PORT"] : '';
146
                $url = ($isHTTPS ? 'https://' : 'http://').$_SERVER["SERVER_NAME"].$port.$_SERVER["REQUEST_URI"];
147
        }else{ 
148
                $hm =& $gCms->GetHierarchyManager();
149
                $page_content_id = $gCms->variables['content_id'];
150
                $curnode =& $hm->getNodeById($page_content_id);
151
                $curcontent =& $curnode->GetContent();
152
                $url = $curcontent->GetURL(); // url of current page
153
        }
154
        $url = urlencode($url);
155
 
156
    if ($link_target != "") {
157
       $target = ' target="'.$link_target.'"';
158
    } else {
159
       $target = "";
160
    }
161
 
162
    if ($img_dir == "") {
163
                        //$img_dir = $config['root_url']."/images/socialBookmarking/";
164
      $img_dir = "images/socialbookmarking/";  // Eduardo
165
    }
166
 
167
    $result = " ";
168
 
169
    if ($submitto == "all" || $submitto == "ALL" || $submitto == "All" || $submitto == "") {
170
 
171
       foreach ($url_array as $value) {
172
 
173
          $print_url = str_replace("[thisurl]", $url, $value["url"]);
174
          $print_url = str_replace("[title]", $curtitle, $print_url);
18 kardasa 175
          $result .= '<a href="'.$print_url.'" title="'.$value["title"].'" rel="nofollow"'.$target.'><img src="'.$img_dir.$value["image"].'" alt="'.$value["alt"].'" class="social-img"  /></a> ';
9 kardasa 176
       }
177
 
178
    } else {
179
 
180
       $submit_array = explode("|",$submitto);
181
 
182
       foreach($submit_array as $value ) {
183
 
184
          $print_url = str_replace("[thisurl]", $url, $url_array[$value]["url"]);
185
          $print_url = str_replace("[title]", $curtitle, $print_url);
11 kardasa 186
          $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> | ';
9 kardasa 187
 
188
       }
189
 
190
    }
191
 
192
        return $result;
193
 
194
}
195
 
196
function smarty_cms_help_function_SocialBookmarking() {
197
        ?>
198
        <h3>What does this do?</h3>
199
        <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>
200
        <h3>How do I use it?</h3>
201
        <p>Insert the tag into your template/page: <code>{socialBookmarking}</code> please notice the lowercase 's' in the tag.</p>
202
        <h3>What parameters does it take?</h3>
203
        <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>
204
        <li><em>(optional)</em> target - populates the "target" atribute of the link. _blank, etc.  eg <code>{SocialBookmarking target="_blank"}</code></li>
205
        <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>
206
        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>
207
        <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>
208
        <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>
209
        </ul></p>
210
        <?php
211
}
212
 
213
function smarty_cms_about_function_SocialBookmarking() {
214
        ?>
215
        <p>Author: Paul Hodgson<br/>
216
        Updated/Maintained by: Eduardo Martinez (hexdj)</p>
217
        <p>Version: 1.2</p>
218
        <p>Change History:<br/>
219
        1.2 - Minor update: clarified help text.<br />
220
        1.1 - Fixed notices that were displayed on some servers and other fixes (thanks to plger).<br/><br/>
221
        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/>
222
        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/>
223
            - Cleaned up some code, added more comments etc.<br/><br/>
224
        0.3 Beta 1 - added the "submitto" parameter, allowing a selection ro be made, on which Social Bookmarks are output.<br />
225
                   - added the variable <code>$img_dir</code> to the code, so any directory can be used to store the images<br /><br/>
226
        0.2 Beta 1 - added two parameters, "title" and "target"<br /><br />
227
        0.1 Beta 1 - First release
228
        </p>
229
        <?php
230
}
231
?>