Ejemplo n.º 1
0
function annotate_file_data($data)
{
    global $CONFIG, $LINEBREAK, $lang_plugin_annotate, $annotate_icon_array, $REFERER;
    // Disable for mobile devices
    if ($CONFIG['plugin_annotate_disable_mobile'] && defined('MOBILE_VIEW')) {
        return $data;
    }
    // Disable for non-image files
    if (!is_image($data['filename'])) {
        return $data;
    }
    // disable on 360° panoramas
    if (function_exists(panorama_viewer_is_360_degree_panorama) && panorama_viewer_is_360_degree_panorama()) {
        return $data;
    }
    // Logged in user can view annotations? (see check for guests some lines below)
    if (USER_ID && annotate_get_level('permissions') == 0) {
        return $data;
    }
    global $cpg_udb;
    $notes = array();
    $sql = "SELECT n.*, u." . $cpg_udb->field['username'] . " AS user_name FROM {$CONFIG['TABLE_PREFIX']}plugin_annotate n INNER JOIN " . $cpg_udb->usertable . " u ON n.user_id = u." . $cpg_udb->field['user_id'] . " WHERE n.pid = {$data['pid']} ORDER BY note ASC";
    $result = cpg_db_query($sql);
    while ($row = mysql_fetch_assoc($result)) {
        //$row['note'] = addslashes($row['note']);
        $notes[] = $row;
    }
    mysql_free_result($result);
    $nr_notes = count($notes);
    // Promote annotations to guests
    if (!USER_ID && annotate_get_level('permissions') == 0) {
        $result = cpg_db_query("SELECT MAX(value) FROM {$CONFIG['TABLE_CONFIG']} WHERE name LIKE 'plugin_annotate_permissions_%'");
        $max_permission_level = mysql_result($result, 0);
        mysql_free_result($result);
        if ($max_permission_level >= 1 && $nr_notes > 0 && $CONFIG['allow_user_registration'] != 0) {
            if ($nr_notes == 1) {
                $data['footer'] .= $lang_plugin_annotate['1_annotation_for_file'] . '<br />' . $LINEBREAK;
            } elseif ($nr_notes > 1) {
                $data['footer'] .= sprintf($lang_plugin_annotate['x_annotations_for_file'], $nr_notes) . '<br />' . $LINEBREAK;
            }
            $data['footer'] .= sprintf($lang_plugin_annotate['registration_promotion'], '<a href="login.php?referer=' . $REFERER . '">', '</a>', '<a href="register.php?referer=' . $REFERER . '">', '</a>');
        }
        return $data;
    }
    set_js_var('pid', $data['pid']);
    set_js_var('annotations', $notes);
    // Determine if the user is allowed to have that button
    if (annotate_get_level('permissions') >= 2) {
        $menu_buttons = "";
        // list existing annotations of the currently viewed album
        $btns_person = "";
        if (annotate_get_level('display_notes') == 1) {
            $superCage = Inspekt::MakeSuperCage();
            if ($superCage->get->testInt('album')) {
                $result = cpg_db_query("\n                    SELECT DISTINCT note FROM {$CONFIG['TABLE_PREFIX']}plugin_annotate n\n                    INNER JOIN {$CONFIG['TABLE_PICTURES']} p\n                    ON p.pid = n.pid\n                    WHERE p.aid = " . $superCage->get->getInt('album') . "\n                    ORDER BY note\n                ");
                if (mysql_num_rows($result)) {
                    $btns_person .= "<div id=\"btns_person\" style=\"white-space:normal; cursor:default;\"> {$lang_plugin_annotate['rapid_annotation']}: ";
                    while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
                        $note = stripslashes($row[0]);
                        $btns_person .= "<button onclick=\"return addnote('{$row[0]}')\" class=\"admin_menu\" title=\"" . sprintf($lang_plugin_annotate['annotate_x_on_this_pic'], $note) . "\">{$note}</button> ";
                    }
                    $btns_person .= "</div><hr />";
                    $data['menu'] = $btns_person . $data['menu'];
                }
                mysql_free_result($result);
            }
        }
        // free text
        if ($CONFIG['plugin_annotate_type'] == 1 || $CONFIG['plugin_annotate_type'] == 3) {
            $menu_buttons .= <<<EOT
            <script type="text/javascript">
                document.write('<li><a href="javascript:void();" title="{$lang_plugin_annotate['plugin_name']}" onclick="return addnote(\\'\\');" rel="nofollow">');
                document.write('<span>{$annotate_icon_array['annotate']}{$lang_plugin_annotate['annotate']}</span>');
                document.write('</a></li>');
            </script>
EOT;
        }
        // list of annotions or user names
        if ($CONFIG['plugin_annotate_type'] != 1) {
            $select_box = '<select id="livesearch_output" size="1" class="button" style="margin-left: 12px;" onmousedown="load_annotation_list();" onmouseover="load_annotation_list();" onchange="return addnote(this.options[this.selectedIndex].value);"><option selected=\\"selected\\" disabled=\\"disabled\\">-- ' . $lang_plugin_annotate['annotate'] . ' --</option></select>';
            $loading_replacement = '<span id="livesearch_output_loading" style="display: none; margin-right: 4px;"><img src="images/loader.gif" /></span>';
            $livesearch_button = '<input id="livesearch_input" type="text" class="textinput" size="8" title="' . $lang_plugin_annotate['filter_annotations'] . '" style="cursor:help; padding-right: 16px; background-image: url(images/icons/search.png); background-repeat: no-repeat; background-position: right center;" />';
            $menu_buttons .= <<<EOT
            <script type="text/javascript">
                document.write('<li>{$select_box}{$loading_replacement}&nbsp;{$livesearch_button}</li>');
            </script>
EOT;
        }
    }
    $html =& $data['html'];
    $html = str_replace("<img ", "<img style=\"padding:0px\" ", $html);
    if (function_exists(panorama_viewer_image)) {
        $search = "/(<table.*style=\"table-layout:fixed.*<div style=\"overflow:auto.*>)(.*)(<\\/div><\\/td><\\/tr><\\/table>)/Uis";
        preg_match($search, $html, $panorama_viewer_matches);
        $html = preg_replace($search, "\\2", $html);
    }
    $container_width = $data['pwidth'];
    if ($data['mode'] == 'normal') {
        $imagesize = getimagesize($CONFIG['fullpath'] . $data['filepath'] . $CONFIG['normal_pfx'] . $data['filename']);
        $container_width = $imagesize[0];
    }
    $container_width += 4;
    set_js_var('container_width', $container_width);
    $html = '<div class="Photo fn-container" style="width:' . $container_width . 'px;" id="PhotoContainer">' . $html . '</div>';
    if (function_exists(panorama_viewer_image)) {
        $html = $panorama_viewer_matches[1] . $html . $panorama_viewer_matches[3];
    }
    // list annotations from the currently viewed picture and generate link to meta album
    if (annotate_get_level('display_links') == 1 && $nr_notes > 0) {
        set_js_var('lang_on_this_pic', $lang_plugin_annotate['on_this_pic']);
        set_js_var('lang_all_pics_of', $lang_plugin_annotate['all_pics_of']);
        $html = "<div id=\"on_this_pic\"></div>" . $html;
    }
    // Display annotation statistics of the currently viewed album
    if (annotate_get_level('display_stats') == 1) {
        $superCage = Inspekt::MakeSuperCage();
        if ($superCage->get->testInt('album')) {
            $annotations_pic = $nr_notes;
            $annotated_pics = mysql_num_rows(cpg_db_query("SELECT DISTINCT n.pid FROM {$CONFIG['TABLE_PREFIX']}plugin_annotate n INNER JOIN {$CONFIG['TABLE_PICTURES']} p ON p.pid = n.pid WHERE p.aid = " . $superCage->get->getInt('album')));
            $annotations_album = mysql_num_rows(cpg_db_query("SELECT DISTINCT n.nid FROM {$CONFIG['TABLE_PREFIX']}plugin_annotate n INNER JOIN {$CONFIG['TABLE_PICTURES']} p ON p.pid = n.pid WHERE p.aid = " . $superCage->get->getInt('album')));
            $annotation_stats = "\n                <span title=\"{$lang_plugin_annotate['annotations_pic']}\">({$annotations_pic})</span>\n                <span title=\"{$lang_plugin_annotate['annotations_album']}\">({$annotations_album})</span>\n                <span title=\"{$lang_plugin_annotate['annotated_pics']}\">({$annotated_pics})</span>\n            ";
            $menu_buttons .= '<li>&nbsp;' . $annotation_stats . '</li>';
        }
    }
    if (empty($data['menu']) || substr($data['menu'], -6) == '<hr />') {
        $data['menu'] .= '<div class="buttonlist align_right"><ul>' . $menu_buttons . '</ul></div>';
    } else {
        $data['menu'] = str_replace('</ul>', $menu_buttons . '</ul>', $data['menu']);
    }
    return $data;
}
Ejemplo n.º 2
0
        function panorama_viewer_image($pic_html)
        {
            global $CURRENT_PIC_DATA;
            $pwidth = $CURRENT_PIC_DATA['pwidth'];
            $pheight = $CURRENT_PIC_DATA['pheight'];
            $div_height_extra_pixel = 24;
            $div_height = $CURRENT_PIC_DATA['pheight'] + $div_height_extra_pixel;
            if ($CURRENT_PIC_DATA['mode'] == 'normal') {
                global $CONFIG;
                $imagesize = getimagesize($CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CONFIG['normal_pfx'] . $CURRENT_PIC_DATA['filename']);
                $pwidth = $imagesize[0];
                $pheight = $imagesize[1];
                $div_height = $imagesize[1] + $div_height_extra_pixel;
            }
            if (panorama_viewer_is_360_degree_panorama()) {
                $pic_html = <<<EOT
                    <script type="text/javascript">
                        function scrollBackInit() {
                            backWidth = {$pwidth};
                            backXStep = 1;
                            backXCall = 20;
                            backXMove = 0;
                            if(document.getElementsByTagName) {
                                backXPos = backYPos = 0;
                                scrollBackObj = document.getElementById("360pano").style;
                                scrollBackObj.backgroundPosition = backXPos + "px " + backYPos + "px";
                                scrollBack();
                            }
                        }
                        function scrollBack() {
                            if(backXMove) {
                                backXPos = (Math.abs(backXPos) > backWidth) ? 0 : backXMove * backXStep + backXPos;
                                scrollBackObj.backgroundPosition = backXPos + "px " + backYPos + "px";
                            }
                            window.setTimeout("scrollBack()", backXCall);
                        }
                        \$(document).ready(function() {
                            scrollBackInit();
                        });
                    </script>
                    <table id="360pano" background="{$CURRENT_PIC_DATA['url']}" style="width:100%; height:{$pheight}px; background-repeat:repeat-x; " border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td width="10%" onmouseover="backXMove=8;" onmouseout="backXMove=0;" valign="middle" align="left"><img src="plugins/panorama_viewer/arrow_left.png" /></td>
                            <td width="10%" onmouseover="backXMove=4;" onmouseout="backXMove=0;"></td>
                            <td width="10%" onmouseover="backXMove=2;" onmouseout="backXMove=0;"></td>
                            <td width="10%" onmouseover="backXMove=1;" onmouseout="backXMove=0;"></td>
                            <td width="20%"></td>
                            <td width="10%" onmouseover="backXMove=-1;" onmouseout="backXMove=0;"></td>
                            <td width="10%" onmouseover="backXMove=-2;" onmouseout="backXMove=0;"></td>
                            <td width="10%" onmouseover="backXMove=-4;" onmouseout="backXMove=0;"></td>
                            <td width="10%" onmouseover="backXMove=-8;" onmouseout="backXMove=0;" valign="middle" align="right"><img src="plugins/panorama_viewer/arrow_right.png" /></td>
                        </tr>
                    </table>
EOT;
            }
            if (panorama_viewer_is_panorama()) {
                $pic_html = "<div style=\"overflow:auto; width:100%; height:{$div_height}px;\">" . $pic_html . "</div>";
                $pic_html = "<table width=\"100%\" style=\"table-layout:fixed;\"><tr><td width=\"100%\" align=\"center\">" . $pic_html . "</td></tr></table>";
            }
            return $pic_html;
        }