Exemplo n.º 1
0
/**
 * Get all of the options set in $_REQUEST and/or $_SESSION
 */
function g2ic_get_request_and_session_options()
{
    global $g2ic_options;
    // Get the root album
    // Check for G2 Core API >= 7.5.  getDefaultAlbumId only available at 7.5 or above
    if (GalleryUtilities::isCompatibleWithApi(array(7, 5), GalleryCoreApi::getApiVersion())) {
        list($error, $g2ic_options['root_album']) = GalleryCoreApi::getDefaultAlbumId();
    } else {
        list($error, $g2ic_options['root_album']) = GalleryCoreApi::getPluginParameter('module', 'core', 'id.rootAlbum');
    }
    g2ic_magic_quotes_remove($_REQUEST);
    // Is this a TinyMCE window?
    if (isset($_REQUEST['g2ic_tinymce'])) {
        $g2ic_options['tinymce'] = $_REQUEST['g2ic_tinymce'];
        $_SESSION['g2ic_tinymce'] = $_REQUEST['g2ic_tinymce'];
    } else {
        if (isset($_SESSION['g2ic_tinymce'])) {
            $g2ic_options['tinymce'] = $_SESSION['g2ic_tinymce'];
        } else {
            $g2ic_options['tinymce'] = 0;
        }
    }
    // Get the form name (if set) for insertion (not TinyMCE or FCKEditor)
    if (isset($_REQUEST['g2ic_form'])) {
        $g2ic_options['form'] = $_REQUEST['g2ic_form'];
        $_SESSION['g2ic_form'] = $_REQUEST['g2ic_form'];
    } else {
        if (isset($_SESSION['g2ic_form'])) {
            $g2ic_options['form'] = $_SESSION['g2ic_form'];
        } else {
            $g2ic_options['form'] = '';
        }
    }
    // Get the field name (if set) for insertion (not TinyMCE or FCKEditor)
    if (isset($_REQUEST['g2ic_field'])) {
        $g2ic_options['field'] = $_REQUEST['g2ic_field'];
        $_SESSION['g2ic_field'] = $_REQUEST['g2ic_field'];
    } else {
        if (isset($_SESSION['g2ic_field'])) {
            $g2ic_options['field'] = $_SESSION['g2ic_field'];
        } else {
            $g2ic_options['field'] = '';
        }
    }
    // Get the last album visited
    if (isset($_SESSION['g2ic_last_album_visited'])) {
        $g2ic_options['last_album'] = $_SESSION['g2ic_last_album_visited'];
    } else {
        $g2ic_options['last_album'] = $g2ic_options['root_album'];
    }
    // Get the current album
    if (isset($_REQUEST['current_album'])) {
        $g2ic_options['current_album'] = $_REQUEST['current_album'];
    } else {
        $g2ic_options['current_album'] = $g2ic_options['last_album'];
    }
    // Get the current page
    if (isset($_REQUEST['g2ic_page']) and is_numeric($_REQUEST['g2ic_page'])) {
        $g2ic_options['current_page'] = floor($_REQUEST['g2ic_page']);
    } else {
        $g2ic_options['current_page'] = 1;
    }
    // Get the current sort method
    if (isset($_REQUEST['sortby'])) {
        $g2ic_options['sortby'] = $_REQUEST['sortby'];
    }
    // Determine whether to display the titles or keep them hidden
    if (isset($_REQUEST['display'])) {
        if ($_REQUEST['display'] == 'filenames') {
            $g2ic_options['display_filenames'] = TRUE;
        }
    }
    // Determine how many images to display per page
    if (isset($_REQUEST['images_per_page'])) {
        $g2ic_options['images_per_page'] = $_REQUEST['images_per_page'];
    }
    return;
}