Example #1
0
if (isset($_POST['submit'])) {
    check_pwg_token();
    $offsetX = trim($_POST['offsetX']);
    $offsetY = trim($_POST['offsetY']);
    if (strlen($offsetX) === 0 || strlen($offsetY) === 0 || !is_numeric($offsetX) || !is_numeric($offsetY)) {
        $page['errors'][] = 'Invalid offset value';
    }
    if (count($page['errors']) === 0) {
        $stereoTable = $prefixeTable . 'stereo';
        if (isset($picture['x'])) {
            $query = "UPDATE {$stereoTable}\n\t\t\t\tSET x={$offsetX}, y={$offsetY}\n\t\t\t\tWHERE media_id = {$id};";
        } else {
            $picture['x'] = $offsetX;
            $picture['y'] = $offsetY;
            $query = "INSERT INTO {$stereoTable} (media_id, x, y)\n\t\t\t\tVALUES ({$id}, {$offsetX}, {$offsetY})";
        }
        pwg_query($query);
        array_push($page['infos'], l10n('STEREO_EDIT_SUCCESS'));
    }
}
// needed for the photo tabsheet
$admin_photo_base_url = get_root_url() . 'admin.php?page=photo-' . $id;
$self_url = Stereo_get_admin_url($id);
include_once PHPWG_ROOT_PATH . 'admin/include/tabsheet.class.php';
$tabsheet = new tabsheet();
$tabsheet->set_id('photo');
$tabsheet->select('stereo');
$tabsheet->assign();
$template->assign(array('PWG_TOKEN' => get_pwg_token(), 'F_ACTION' => $self_url, 'TITLE' => render_element_name($picture), 'PICTURE' => Stereo_render_element_content('', $picture), 'OFFSET_X' => empty($picture['x']) ? 0 : $picture['x'], 'OFFSET_Y' => empty($picture['y']) ? 0 : $picture['y']));
$template->set_filename('plugin_admin_content', STEREO_PATH . 'admin.tpl');
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
Example #2
0
function Stereo_tabsheet($tabs, $context)
{
    global $prefixeTable;
    if ($context != 'photo') {
        return $tabs;
    }
    load_language('plugin.lang', STEREO_PATH);
    check_input_parameter('image_id', $_GET, false, PATTERN_ID);
    $id = $_GET['image_id'];
    $query = '
		SELECT file from ' . $prefixeTable . 'images
		WHERE id = ' . $id;
    $result = pwg_db_fetch_assoc(pwg_query($query));
    if ($result && preg_match('/.*mpo$/i', $result['file'])) {
        $tabs['stereo'] = array('caption' => l10n('STEREO_ADJUSTMENT'), 'url' => Stereo_get_admin_url($id));
    }
    return $tabs;
}