Ejemplo n.º 1
0
	/**
	 * prepares a URL for component plugin usage
	 *
	 * @param  array   $variables
	 * @param  string  $msg
	 * @param  boolean $htmlspecialchars
	 * @param  boolean $redirect
	 * @param  string  $type
	 * @param  boolean $return
	 * @param  boolean $ajax
	 * @param boolean $back
	 * @return string
	 */
    static public function getPluginURL( $variables = array(), $msg = null, $htmlspecialchars = true, $redirect = false, $type = null, $return = false, $ajax = false, $back = false ) {
		global $_CB_framework;

		$getReturn				=	cbgjClass::getReturnURL();

		if ( $back && $getReturn ) {
			$url				=	$getReturn;
		} else {
			$plugin				=	cbgjClass::getPlugin();
			$generalDynamicid	=	$plugin->params->get( 'general_dynamicid', 0 );
			$action				=	( isset( $variables[0] ) ? '&action=' . urlencode( $variables[0] ) : null );

			if ( $return === 'current' ) {
				$setReturn		=	( $getReturn ? '&return=' . base64_encode( $getReturn ) : null );
			} else {
				$setReturn		=	( $return ? cbgjClass::setReturnURL() : null );
			}

			if ( $_CB_framework->getUi() == 2 ) {
				$function		=	( isset( $variables[1] ) ? '.' . urlencode( $variables[1] ) : null );
				$id				=	( isset( $variables[2] ) ? '&id=' . urlencode( $variables[2] ) : null );
				$vars			=	$action . $function . $id . $setReturn;
				$format			=	( $ajax ? 'raw' : 'html' );
				$url			=	'index.php?option=' . $plugin->option . '&task=editPlugin&cid=' . $plugin->id . $vars;

				if ( $htmlspecialchars ) {
					$url		=	htmlspecialchars( $url );
				}

				$url			=	$_CB_framework->backendUrl( $url, $htmlspecialchars, $format );
			} else {
				$function		=	( isset( $variables[1] ) ? '&func=' . urlencode( $variables[1] ) : null );
				$category		=	( isset( $variables[2] ) ? '&cat=' . urlencode( $variables[2] ) : null );
				$group			=	( isset( $variables[3] ) ? '&grp=' . urlencode( $variables[3] ) : null );
				$id				=	( isset( $variables[4] ) ? '&id=' . urlencode( $variables[4] ) : null );
				$vars			=	$action . $function . $category . $group . $id;

				if ( isset( $variables[5] ) && is_array( $variables[5] ) ) foreach( $variables[5] as $k => $v ) {
					$vars		.=	'&' . urlencode( $k ) . '=' . urlencode( $v );
				}

				if ( $generalDynamicid ) {
					$vars		.=	cbgjClass::getItemid( false, $vars );
				} else {
					$vars		.=	cbgjClass::getItemid();
				}

				$vars			.=	$setReturn;
				$format			=	( $ajax ? 'component' : 'html' );
				$url			=	cbSef( 'index.php?option=' . $plugin->option . '&task=pluginclass&plugin=' . $plugin->element . $vars, $htmlspecialchars, $format );
			}
		}

		if ( $msg ) {
			if ( $redirect ) {
				cbgjClass::setRedirect( $url, ( $msg === true ? null : $msg ), $type );
			} else {
				if ( $msg === true ) {
					$url		=	"javascript: location.href = '" . addslashes( $url ) . "';";
				} else {
					$url		=	"javascript: if ( confirm( '" . addslashes( $msg ) . "' ) ) { location.href = '" . addslashes( $url ) . "'; }";
				}
			}
		}

		return $url;
	}