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>.
6 * Author: Rabuzarus <https://friendica.kommune4.de/profile/rabuzarus>
10 $frio = "view/theme/frio";
14 function frio_init(&$a) {
15 set_template_engine($a, 'smarty3');
17 $baseurl = $a->get_baseurl();
19 $style = get_pconfig(local_user(), 'frio', 'style');
21 $frio = "view/theme/frio";
29 $style = get_config('frio', 'style');
32 function frio_install() {
33 register_hook('prepare_body_final', 'view/theme/frio/theme.php', 'frio_item_photo_links');
35 logger("installed theme frio");
38 function frio_uninstall() {
39 unregister_hook('prepare_body_final', 'view/theme/frio/theme.php', 'frio_item_photo_links');
41 logger("uninstalled theme frio");
44 * @brief Replace friendica photo links
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
53 * @param array $body_info The item and its html output
55 function frio_item_photo_links(&$a, &$body_info) {
56 require_once('include/Photo.php');
58 $phototypes = Photo::supportedTypes();
60 $p = bb_find_open_close($body_info['html'], "<a", ">");
62 while($p !== false && ($occurence++ < 500)) {
63 $link = substr($body_info['html'], $p['start'], $p['end'] - $p['start']);
66 preg_match("/\/photos\/[\w]+\/image\/([\w]+)/", $link, $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);
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);
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);
77 $body_info['html'] = str_replace($link, $newlink, $body_info['html']);
80 $p = bb_find_open_close($body_info['html'], "<a", ">", $occurence);