5 * Author: Fabio <http://kirgroup.com/profile/fabrixxm>
6 * Author: Ike <http://pirati.ca/profile/heluecht>
7 * Author: Beanow <https://fc.oscp.info/profile/beanow>
8 * Maintainer: Ike <http://pirati.ca/profile/heluecht>
9 * Description: "Vier" is a very compact and modern theme. It uses the font awesome font library: http://fortawesome.github.com/Font-Awesome/
12 function vier_init(&$a) {
14 $a->theme_events_in_profile = false;
16 set_template_engine($a, 'smarty3');
18 $baseurl = $a->get_baseurl();
20 $a->theme_info = array();
22 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] or $a->argv[0] === "network" && local_user()) {
23 vier_community_info();
25 $a->page['htmlhead'] .= "<link rel='stylesheet' media='screen and (min-width: 1300px)' href='view/theme/vier/wide.css' />";
28 $a->page['htmlhead'] .= <<< EOT
29 <link rel='stylesheet' media='screen and (max-width: 1100px)' href='view/theme/vier/narrow.css' />
30 <script type="text/javascript">
32 function insertFormatting(comment,BBcode,id) {
34 var tmpStr = $("#comment-edit-text-" + id).val();
35 if(tmpStr == comment) {
37 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
38 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
39 openMenu("comment-edit-submit-wrapper-" + id);
40 $("#comment-edit-text-" + id).val(tmpStr);
43 textarea = document.getElementById("comment-edit-text-" +id);
44 if (document.selection) {
46 selected = document.selection.createRange();
48 selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]";
50 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
51 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
52 var start = textarea.selectionStart;
53 var end = textarea.selectionEnd;
55 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
57 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
63 function showThread(id) {
64 $("#collapsed-comments-" + id).show()
65 $("#collapsed-comments-" + id + " .collapsed-comments").show()
67 function hideThread(id) {
68 $("#collapsed-comments-" + id).hide()
69 $("#collapsed-comments-" + id + " .collapsed-comments").hide()
73 function cmtBbOpen(id) {
74 $("#comment-edit-bb-" + id).show();
76 function cmtBbClose(id) {
77 $("#comment-edit-bb-" + id).hide();
82 // Hide the left menu bar
83 if (($a->page['aside'] == "") AND in_array($a->argv[0], array("community", "events", "help", "manage", "notifications", "probe", "webfinger", "login")))
84 $a->page['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
87 function get_vier_config($key, $default = false) {
89 $result = get_pconfig(local_user(), "vier", $key);
90 if ($result !== false)
94 $result = get_config("vier", $key);
95 if ($result !== false)
101 function vier_community_info() {
104 $close_pages = get_vier_config("close_pages", 1);
105 $close_profiles = get_vier_config("close_profiles", 0);
106 $close_helpers = get_vier_config("close_helpers", 0);
107 $close_services = get_vier_config("close_services", 0);
108 $close_friends = get_vier_config("close_friends", 0);
109 $close_lastusers = get_vier_config("close_lastusers", 0);
110 $close_lastphotos = get_vier_config("close_lastphotos", 0);
111 $close_lastlikes = get_vier_config("close_lastlikes", 0);
113 $close_pages = false;
114 $close_profiles = true;
115 $close_helpers = false;
116 $close_services = false;
117 $close_friends = false;
118 $close_lastusers = true;
119 $close_lastphotos = true;
120 $close_lastlikes = true;
123 if(!$close_profiles) {
124 $aside['$comunity_profiles_title'] = t('Community Profiles');
125 $aside['$comunity_profiles_items'] = array();
126 $r = q("select gcontact.* from gcontact left join glink on glink.gcid = gcontact.id
127 where glink.cid = 0 and glink.uid = 0 order by rand() limit 9");
128 $tpl = get_markup_template('ch_directory_item.tpl');
132 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
133 $entry = replace_macros($tpl,array(
135 '$profile_link' => zrl($rr['url']),
136 '$photo' => $rr[$photo],
137 '$alt_text' => $rr['name'],
139 $aside['$comunity_profiles_items'][] = $entry;
145 if(!$close_lastusers) {
146 $aside['$lastusers_title'] = t('Last users');
147 $aside['$lastusers_items'] = array();
149 $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 ");
150 $order = " ORDER BY `register_date` DESC ";
152 $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
153 FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
154 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra $order LIMIT %d , %d ",
157 $tpl = get_markup_template('ch_directory_item.tpl');
161 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
162 $entry = replace_macros($tpl,array(
164 '$profile_link' => $profile_link,
165 '$photo' => $a->get_cached_avatar_image($rr[$photo]),
166 '$alt_text' => $rr['name']));
167 $aside['$lastusers_items'][] = $entry;
172 // last 10 liked items
174 if(!$close_lastlikes) {
175 $aside['$like_title'] = t('Last likes');
176 $aside['$like_items'] = array();
177 $r = q("SELECT `T1`.`created`, `T1`.`liker`, `T1`.`liker-link`, `item`.* FROM
178 (SELECT `parent-uri`, `created`, `author-name` AS `liker`,`author-link` AS `liker-link`
179 FROM `item` WHERE `verb`='http://activitystrea.ms/schema/1.0/like' GROUP BY `parent-uri` ORDER BY `created` DESC) AS T1
180 INNER JOIN `item` ON `item`.`uri`=`T1`.`parent-uri`
181 WHERE `T1`.`liker-link` LIKE '%s%%' OR `item`.`author-link` LIKE '%s%%'
183 ORDER BY `T1`.`created` DESC
185 $a->get_baseurl(),$a->get_baseurl());
187 foreach ($r as $rr) {
188 $author = '<a href="' . $rr['liker-link'] . '">' . $rr['liker'] . '</a>';
189 $objauthor = '<a href="' . $rr['author-link'] . '">' . $rr['author-name'] . '</a>';
191 //var_dump($rr['verb'],$rr['object-type']); killme();
193 case 'http://activitystrea.ms/schema/1.0/post':
194 switch ($rr['object-type']){
195 case 'http://activitystrea.ms/schema/1.0/event':
196 $post_type = t('event');
199 $post_type = t('status');
203 if ($rr['resource-id']){
204 $post_type = t('photo');
206 preg_match("/\[url=([^]]*)\]/", $rr['body'], $m);
207 $rr['plink'] = $m[1];
209 $post_type = t('status');
211 $plink = '<a href="' . $rr['plink'] . '">' . $post_type . '</a>';
213 $aside['$like_items'][] = sprintf( t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
219 if(!$close_lastphotos) {
220 $aside['$photos_title'] = t('Last photos');
221 $aside['$photos_items'] = array();
222 $r = q("SELECT `photo`.`id`, `photo`.`resource-id`, `photo`.`scale`, `photo`.`desc`, `user`.`nickname`, `user`.`username` FROM
223 (SELECT `resource-id`, MAX(`scale`) as maxscale FROM `photo`
224 WHERE `profile`=0 AND `contact-id`=0 AND `album` NOT IN ('Contact Photos', '%s', 'Profile Photos', '%s')
225 AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`='' GROUP BY `resource-id`) AS `t1`
226 INNER JOIN `photo` ON `photo`.`resource-id`=`t1`.`resource-id` AND `photo`.`scale` = `t1`.`maxscale`,
228 WHERE `user`.`uid` = `photo`.`uid`
229 AND `user`.`blockwall`=0
230 AND `user`.`hidewall`=0
231 ORDER BY `photo`.`edited` DESC
233 dbesc(t('Contact Photos')),
234 dbesc(t('Profile Photos'))
237 $tpl = get_markup_template('ch_directory_item.tpl');
239 $photo_page = $a->get_baseurl() . '/photos/' . $rr['nickname'] . '/image/' . $rr['resource-id'];
240 $photo_url = $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] .'.jpg';
242 $entry = replace_macros($tpl,array(
244 '$profile_link' => $photo_page,
245 '$photo' => $photo_url,
246 '$alt_text' => $rr['username']." : ".$rr['desc']));
248 $aside['$photos_items'][] = $entry;
253 //right_aside FIND FRIENDS
254 if (!$close_friends AND local_user()) {
256 $nv['title'] = Array("", t('Find Friends'), "", "");
257 $nv['directory'] = Array('directory', t('Local Directory'), "", "");
258 $nv['global_directory'] = Array('http://dir.friendica.com/', t('Global Directory'), "", "");
259 $nv['match'] = Array('match', t('Similar Interests'), "", "");
260 $nv['suggest'] = Array('suggest', t('Friend Suggestions'), "", "");
261 $nv['invite'] = Array('invite', t('Invite Friends'), "", "");
263 $nv['search'] = '<form name="simple_bar" method="get" action="http://dir.friendica.com/directory">
264 <span class="sbox_l"></span>
266 <input type="text" name="search" size="13" maxlength="50">
268 <span class="sbox_r" id="srch_clear"></span>';
273 //Community_Pages at right_aside
274 if(!$close_pages AND local_user()) {
276 <h3 style="margin-top:0px;">'.t("Community Pages").'<a id="closeicon" href="#boxsettings" onClick="open_boxsettings(); return false;" style="text-decoration:none;" class="icon close_box" title="'.t("Settings").'"></a></h3>
277 <div id=""><ul style="margin-left: 7px;margin-top: 0px;padding-left: 0px;padding-top: 0px;">';
281 $contacts = q("SELECT `id`, `url`, `name`, `micro`FROM `contact`
282 WHERE `network`= 'dfrn' AND `forum` = 1 AND `uid` = %d
283 ORDER BY `name` ASC",
284 intval($a->user['uid']));
288 // Look if the profile is a community page
289 foreach($contacts as $contact) {
290 $pageD[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
296 foreach($contacts as $contact) {
297 $page .= '<li style="list-style-type: none;" class="tool"><img height="20" width="20" style="float: left; margin-right: 3px;" src="' . $contact['micro'] .'" alt="' . $contact['url'] . '" /> <a href="'.$a->get_baseurl().'/redir/'.$contact["id"].'" style="margin-top: 2px; word-wrap: break-word; width: 132px;" title="' . $contact['url'] . '" class="label" target="external-link">'.
298 $contact["name"]."</a></li>";
300 $page .= '</ul></div>';
301 //if (sizeof($contacts) > 0)
302 $aside['$page'] = $page;
307 if(!$close_helpers) {
309 $helpers['title'] = Array("", t('Help or @NewHere ?'), "", "");
310 $aside['$helpers'] = $helpers;
314 //connectable services
315 if (!$close_services) {
316 $con_services = array();
317 $con_services['title'] = Array("", t('Connect Services'), "", "");
318 $aside['$con_services'] = $con_services;
320 //end connectable services
323 if($ccCookie != "9") {
324 $close_pages = get_vier_config( "close_pages", 1 );
325 $close_profiles = get_vier_config( "close_profiles", 0 );
326 $close_helpers = get_vier_config( "close_helpers", 0 );
327 $close_services = get_vier_config( "close_services", 0 );
328 $close_friends = get_vier_config( "close_friends", 0 );
329 $close_lastusers = get_vier_config( "close_lastusers", 0 );
330 $close_lastphotos = get_vier_config( "close_lastphotos", 0 );
331 $close_lastlikes = get_vier_config( "close_lastlikes", 0 );
332 $close_or_not = array('1'=>t("don't show"), '0'=>t("show"),);
333 $boxsettings['title'] = Array("", t('Show/hide boxes at right-hand column:'), "", "");
334 $aside['$boxsettings'] = $boxsettings;
335 $aside['$close_pages'] = array('vier_close_pages', t('Community Pages'), $close_pages, '', $close_or_not);
336 $aside['$close_profiles'] = array('vier_close_profiles', t('Community Profiles'), $close_profiles, '', $close_or_not);
337 $aside['$close_helpers'] = array('vier_close_helpers', t('Help or @NewHere ?'), $close_helpers, '', $close_or_not);
338 $aside['$close_services'] = array('vier_close_services', t('Connect Services'), $close_services, '', $close_or_not);
339 $aside['$close_friends'] = array('vier_close_friends', t('Find Friends'), $close_friends, '', $close_or_not);
340 $aside['$close_lastusers'] = array('vier_close_lastusers', t('Last users'), $close_lastusers, '', $close_or_not);
341 $aside['$close_lastphotos'] = array('vier_close_lastphotos', t('Last photos'), $close_lastphotos, '', $close_or_not);
342 $aside['$close_lastlikes'] = array('vier_close_lastlikes', t('Last likes'), $close_lastlikes, '', $close_or_not);
343 $aside['$sub'] = t('Submit');
344 $baseurl = $a->get_baseurl($ssl_state);
345 $aside['$baseurl'] = $baseurl;
347 if (isset($_POST['vier-settings-box-sub']) && $_POST['vier-settings-box-sub']!=''){
348 set_pconfig(local_user(), 'vier', 'close_pages', $_POST['vier_close_pages']);
349 set_pconfig(local_user(), 'vier', 'close_profiles', $_POST['vier_close_profiles']);
350 set_pconfig(local_user(), 'vier', 'close_helpers', $_POST['vier_close_helpers']);
351 set_pconfig(local_user(), 'vier', 'close_services', $_POST['vier_close_services']);
352 set_pconfig(local_user(), 'vier', 'close_friends', $_POST['vier_close_friends']);
353 set_pconfig(local_user(), 'vier', 'close_lastusers', $_POST['vier_close_lastusers']);
354 set_pconfig(local_user(), 'vier', 'close_lastphotos', $_POST['vier_close_lastphotos']);
355 set_pconfig(local_user(), 'vier', 'close_lastlikes', $_POST['vier_close_lastlikes']);
358 $close = t('Settings');
359 $aside['$close'] = $close;
362 $url = $a->get_baseurl($ssl_state);
363 $aside['$url'] = $url;
366 $tpl = get_markup_template('communityhome.tpl');
367 $a->page['right_aside'] = replace_macros($tpl, $aside);