]> git.mxchange.org Git - friendica.git/blob - theme.php
move js from theme.php to theme.js
[friendica.git] / theme.php
1 <?php
2 /*
3  * Name: frio
4  * Description: Bootstrap V3 theme. The theme is currently under construction, so it is far from finished. For further information have a look at the <a href="https://github.com/rabuzarus/frio/blob/master/README.md">ReadMe</a> and <a href="https://github.com/rabuzarus/frio">GitHub</a>.
5  * Version: V.0.1 Alpha
6  * Author: Rabuzarus <https://friendica.kommune4.de/profile/rabuzarus>
7  * 
8  */
9
10 $frio = "view/theme/frio";
11
12 global $frio;
13
14 function frio_init(&$a) {
15         set_template_engine($a, 'smarty3');
16
17         $baseurl = $a->get_baseurl();
18
19         $style = get_pconfig(local_user(), 'frio', 'style');
20
21         $frio = "view/theme/frio";
22
23         global $frio;
24         
25         
26
27
28         if ($style == "")
29                 $style = get_config('frio', 'style');
30 }
31
32 function frio_install() {
33         register_hook('prepare_body_final', 'view/theme/frio/theme.php', 'frio_item_photo_links');
34
35         logger("installed theme frio");
36 }
37
38 function frio_uninstall() {
39         unregister_hook('prepare_body_final', 'view/theme/frio/theme.php', 'frio_item_photo_links');
40
41         logger("uninstalled theme frio");
42 }
43 /**
44  * @brief Replace friendica photo links
45  * 
46  *  This function does replace the links to photos
47  *  of other friendica users. Original the photos are
48  *  linked to the photo page. Now they will linked directly
49  *  to the photo file. This function is nessesary to use colorbox
50  *  in the network stream
51  * 
52  * @param App $a
53  * @param array $body_info The item and its html output
54  */
55 function frio_item_photo_links(&$a, &$body_info) {
56         require_once('include/Photo.php');
57
58         $phototypes = Photo::supportedTypes();
59         $occurence = 1;
60         $p = bb_find_open_close($body_info['html'], "<a", ">");
61
62         while($p !== false && ($occurence++ < 500)) {
63                 $link = substr($body_info['html'], $p['start'], $p['end'] - $p['start']);
64                 $matches = array();
65
66                 preg_match("/\/photos\/[\w]+\/image\/([\w]+)/", $link, $matches);
67                 if($matches) {
68                         // Replace the link for the photo's page with a direct link to the photo itself
69                         $newlink = str_replace($matches[0], "/photo/{$matches[1]}", $link);
70
71                         // Add a "quiet" parameter to any redir links to prevent the "XX welcomes YY" info boxes
72                         $newlink = preg_replace("/href=\"([^\"]+)\/redir\/([^\"]+)&url=([^\"]+)\"/", 'href="$1/redir/$2&quiet=1&url=$3"', $newlink);
73
74                          // Having any arguments to the link for Colorbox causes it to fetch base64 code instead of the image
75                         $newlink = preg_replace("/\/[?&]zrl=([^&\"]+)/", '', $newlink);
76
77                         $body_info['html'] = str_replace($link, $newlink, $body_info['html']);
78                 }
79
80                 $p = bb_find_open_close($body_info['html'], "<a", ">", $occurence);
81         }
82 }