Packagecom.soma.model
Classpublic class PageManager
ImplementsIDisposable

Author: Romuald Quantin - www.soundstep.com

Information:
Blog page - SomaUI
How does it work - Soma Protest
Project Host - Google Code
Documentation - Soma ASDOC
Class version: 2.0.1
Actionscript version: 3.0

Copyright:

The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.mozilla.org/MPL/

Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied.
See the License for the specific language governing rights and
limitations under the License.

The Original Code is Soma.
The Initial Developer of the Original Code is Romuald Quantin.
Initial Developer are Copyright (C) 2008-2009 Soundstep. All Rights Reserved.

Usage:
The PageManager is a big part in Soma and it is not the purpose of the documentation to explain all the options and how it is used by Soma. Instead you can visit the Soma Protest Page Sytem page for more explanation.

The PageManager role is instantiating and removing pages from the XML Site Definition as well as handling the deep-linking URL with the SWFAddress. The first to thing remember is: The PageManager will instantiate Page classes using the String found in the type attribute of the page node (this page class must be registered in the config file using Soma.getInstance().registerClass(MyPageClass)).

Here is an example of a page node:

<page id="home_id" type="Home" urlfriendly="home">
    <title><![CDATA[Welcome]]></title>
</page>
     
This page can be called using the Soma Command:
new PageEvent(PageEvent.SHOW, "home_id").dispatch();
     
When the PageManager will receive a command to show a page, it will find out what pages have to be removed before showing (if there are depth attributes found), find the attribute type and instantiate the class that will match that name (the page class has to be registered: Soma.getInstance().registerClass(MyPageClass).

The registration is important, the PageManager instantiates classes using String and getDefinitionByName and the classes needs to be imported by the compiler and that's the role of the registration.

The only attribute required in the page node is the id. If there is no "type", no page will instantiated and if there is no "urlfriendly", the will not appear in the URL (note: the title node of a page is a requirement in the XML Site Definition).

Four options attributes are available on the page node: See the Soma Protest Page System for more information.

A page node can contain a content node (assets) that will be parsed, see the Page documentation.

See also

Soma
PageEvent
Page
ClassImport


Public Properties
 PropertyDefined by
  container : Sprite
[read-only] Return the Sprite that contains all the pages.
PageManager
  currentPage : Page
[read-only] Get the current page displayed (Page).
PageManager
  DEEPLINKING_ENABLED : Boolean = true
[static] Enables the deep-linking, the URL is built with the urlfriendly attribute of a page node.
PageManager
  isRemoving : Boolean
[read-only] Whether or not the PageManager is currently removing pages.
PageManager
  started : Boolean
[read-only] Whether or not the PageManager has been started.
PageManager
  TITLE_BROWSER_ENABLED : Boolean = false
[static] Enables the PageManager instance to change the title of the browser, the title is built with the site name (Soma.getInstance().config.siteName) and the value of the title or the titleBrowser (priority on titleBrowser) node of a page node.
PageManager
Public Methods
 MethodDefined by
  
Creates an PageManager instance
PageManager
  
dispose():void
Removes the children of the page container and destroys the container.
PageManager
  
getPageDepth(id:String):int
Get the depth attribute of a page node.
PageManager
  
getPageID(urlFriendly:String):String
Get the id attribute of a page node using the deep-linking value (URL).
PageManager
  
getPageType(id:String):String
Get the type attribute of a page node (the type is the class name that will be instantiated by the PageManager).
PageManager
  
getParentNonExcluded(idPage:String):String
Get the first parent that is not excluded (first page node parent that is not containing the attribute "exclude" set to true).
PageManager
  
getTitle(id:String):String
Get the value of the title node of a page node.
PageManager
  
getTitleBrowser(id:String):String
Get the value of the titleBrowser node of a page node.
PageManager
  
getUrlFriendly(id:String):String
Get the URL (deep-linking) value for a page.
PageManager
  
hasExcludedChildren(idPage:String):Boolean
Whether or not the page has nodes children that are excluded (page node child containing the attribute "exclude" set to true).
PageManager
  
isExcluded(idPage:String):Boolean
Whether or not the page node is excluded (contains the attribute "exclude" set to true).
PageManager
  
isExternalPage(id:String):Boolean
Whether or not a page node is an external page (contains the attribute "external" set to true).
PageManager
  
isMovieClipMode(id:String):Boolean
Whether or not a page node is a movieclip page (contains the attribute "movieclip" set to true).
PageManager
  
removePages(e:PageEvent = null):void
Meant to an internal Soma use: continue the process of hiding pages (called at the end of the "transition out complete" event of a page).
PageManager
  
setBrowserTitle(value:String):void
Set the title of the browser window depending of the page.
PageManager
  
show(id:String):void
Show a page (internally used by Soma after a PageEvent.SHOW event dispatched).
PageManager
  
showExternalLink(url:String):void
Show an external link (open a new browser window).
PageManager
  
showPages(e:PageEvent = null):void
Meant to an internal Soma use: continue the process of showing pages (called at the end of the "transition in complete" event of a page).
PageManager
  
start():void
Starts the PageManager (called by Soma during initialization process).
PageManager
Property detail
containerproperty
container:Sprite  [read-only]

Return the Sprite that contains all the pages.

Implementation
    public function get container():Sprite
currentPageproperty 
currentPage:Page  [read-only]

Get the current page displayed (Page). You can cast the class result to your own page:

   MyPage(Soma.getInstance().page.currentPage)
   

Implementation
    public function get currentPage():Page
DEEPLINKING_ENABLEDproperty 
public static var DEEPLINKING_ENABLED:Boolean = true

Enables the deep-linking, the URL is built with the urlfriendly attribute of a page node.

isRemovingproperty 
isRemoving:Boolean  [read-only]

Whether or not the PageManager is currently removing pages.

Implementation
    public function get isRemoving():Boolean
startedproperty 
started:Boolean  [read-only]

Whether or not the PageManager has been started.

Implementation
    public function get started():Boolean
TITLE_BROWSER_ENABLEDproperty 
public static var TITLE_BROWSER_ENABLED:Boolean = false

Enables the PageManager instance to change the title of the browser, the title is built with the site name (Soma.getInstance().config.siteName) and the value of the title or the titleBrowser (priority on titleBrowser) node of a page node.

Constructor detail
PageManager()constructor
public function PageManager()

Creates an PageManager instance

Method detail
dispose()method
public function dispose():void

Removes the children of the page container and destroys the container.

getPageDepth()method 
public function getPageDepth(id:String):int

Get the depth attribute of a page node.

Parameters
id:String — Attribute id of the page node.

Returns
int — A int (depth value).
getPageID()method 
public function getPageID(urlFriendly:String):String

Get the id attribute of a page node using the deep-linking value (URL).

Parameters
urlFriendly:String — String (value of the deep-linking).

Returns
String — A String (id of the page).
getPageType()method 
public function getPageType(id:String):String

Get the type attribute of a page node (the type is the class name that will be instantiated by the PageManager).

Parameters
id:String — Attribute id of the page node.

Returns
String — A String (the type attribute).
getParentNonExcluded()method 
public function getParentNonExcluded(idPage:String):String

Get the first parent that is not excluded (first page node parent that is not containing the attribute "exclude" set to true).

Parameters
idPage:String — Attribute id of the page node.

Returns
String — A String (id of the page node parent).
getTitle()method 
public function getTitle(id:String):String

Get the value of the title node of a page node.

Parameters
id:String — Attribute id of the page node.

Returns
String — A String.
getTitleBrowser()method 
public function getTitleBrowser(id:String):String

Get the value of the titleBrowser node of a page node.

Parameters
id:String — Attribute id of the page node.

Returns
String — A String.
getUrlFriendly()method 
public function getUrlFriendly(id:String):String

Get the URL (deep-linking) value for a page.

Parameters
id:String — Attribute id of the page node.

Returns
String — A string (string that will be append to the real URL).
hasExcludedChildren()method 
public function hasExcludedChildren(idPage:String):Boolean

Whether or not the page has nodes children that are excluded (page node child containing the attribute "exclude" set to true).

Parameters
idPage:String — Attribute id of the page node.

Returns
Boolean — A Boolean.
isExcluded()method 
public function isExcluded(idPage:String):Boolean

Whether or not the page node is excluded (contains the attribute "exclude" set to true).

Parameters
idPage:String — Attribute id of the page node.

Returns
Boolean — A Boolean.
isExternalPage()method 
public function isExternalPage(id:String):Boolean

Whether or not a page node is an external page (contains the attribute "external" set to true).

Parameters
id:String — Attribute id of the page node.

Returns
Boolean — A Boolean.
isMovieClipMode()method 
public function isMovieClipMode(id:String):Boolean

Whether or not a page node is a movieclip page (contains the attribute "movieclip" set to true).

Parameters
id:String — Attribute id of the page node.

Returns
Boolean — A Boolean.
removePages()method 
public function removePages(e:PageEvent = null):void

Meant to an internal Soma use: continue the process of hiding pages (called at the end of the "transition out complete" event of a page).

Parameters
e:PageEvent (default = null) — PageEvent instance.
setBrowserTitle()method 
public function setBrowserTitle(value:String):void

Set the title of the browser window depending of the page. It is internally used by the page manager but you can set the static variable PageManager.TITLE_BROWSER_ENABLED to false (default true) and set a custom value.

By default, the title is built with the site name (Soma.getInstance().config.siteName) and the value of the title or the titleBrowser (priority on titleBrowser) node of a page node.

Parameters
value:String — Title of the browser window.
show()method 
public function show(id:String):void

Show a page (internally used by Soma after a PageEvent.SHOW event dispatched).

Parameters
id:String — Attribute id of the page node.
showExternalLink()method 
public function showExternalLink(url:String):void

Show an external link (open a new browser window).

Parameters
url:String — Strig value of the external link to open.
showPages()method 
public function showPages(e:PageEvent = null):void

Meant to an internal Soma use: continue the process of showing pages (called at the end of the "transition in complete" event of a page).

Parameters
e:PageEvent (default = null) — PageEvent instance.
start()method 
public function start():void

Starts the PageManager (called by Soma during initialization process).