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');
34 register_hook('item_photo_menu', 'view/theme/frio/theme.php', 'frio_item_photo_menu');
36 logger("installed theme frio");
39 function frio_uninstall() {
40 unregister_hook('prepare_body_final', 'view/theme/frio/theme.php', 'frio_item_photo_links');
41 unregister_hook('item_photo_menu', 'view/theme/frio/theme.php', 'frio_item_photo_menu');
43 logger("uninstalled theme frio");
46 * @brief Replace friendica photo links
48 * This function does replace the links to photos
49 * of other friendica users. Original the photos are
50 * linked to the photo page. Now they will linked directly
51 * to the photo file. This function is nessesary to use colorbox
52 * in the network stream
55 * @param array $body_info The item and its html output
57 function frio_item_photo_links(&$a, &$body_info) {
58 require_once('include/Photo.php');
60 $phototypes = Photo::supportedTypes();
62 $p = bb_find_open_close($body_info['html'], "<a", ">");
64 while($p !== false && ($occurence++ < 500)) {
65 $link = substr($body_info['html'], $p['start'], $p['end'] - $p['start']);
68 preg_match("/\/photos\/[\w]+\/image\/([\w]+)/", $link, $matches);
70 // Replace the link for the photo's page with a direct link to the photo itself
71 $newlink = str_replace($matches[0], "/photo/{$matches[1]}", $link);
73 // Add a "quiet" parameter to any redir links to prevent the "XX welcomes YY" info boxes
74 $newlink = preg_replace("/href=\"([^\"]+)\/redir\/([^\"]+)&url=([^\"]+)\"/", 'href="$1/redir/$2&quiet=1&url=$3"', $newlink);
76 // Having any arguments to the link for Colorbox causes it to fetch base64 code instead of the image
77 $newlink = preg_replace("/\/[?&]zrl=([^&\"]+)/", '', $newlink);
79 $body_info['html'] = str_replace($link, $newlink, $body_info['html']);
82 $p = bb_find_open_close($body_info['html'], "<a", ">", $occurence);
87 * @brief Replace links of the item_photo_menu
89 * This function replaces the original poke and the message links
90 * to call the addToModal javascript function so this pages can
91 * be loaded in a bootstrap modal
93 * @param app $a The app data
94 * @param array $arr Contains item data and the original photo_menu
96 function frio_item_photo_menu($a, &$arr){
98 foreach($arr["menu"] as $k =>$v) {
99 if(strpos($v,'poke/?f=&c=') === 0 || strpos($v,'message/new/') === 0) {
100 $v = "javascript:addToModal('" . $v . "'); return false;";
101 $arr["menu"][$k] = $v;
102 $testvariable = $testvariable+1;
105 $args = array('item' => $item, 'menu' => $menu);