>> YANA 4 PHP Framework >> Docs For Class Yana

Class Yana

Description

«Singleton» Yana

This is a primary controller and application loader for the YANA-Framework.

  • access: public

Located in /includes/class_yana.php

Object
   |
   --Singleton
      |
      --Yana
Variable Summary
Method Summary

Variables

Language $language = null

to load language strings

This variable is «readonly».

  • access: public
PluginManager $plugins = null

to communicate with plugins

This variable is «readonly».

  • access: public
Registry $registry = null

to read and write data to the global registry

This variable is «readonly».

  • access: public
SessionManager $session = null

to read and write user data and permissions

This variable is «readonly».

  • since: 2.9
  • access: public
Skin $skin = null

to load skins and templates

This variable is «readonly».

  • access: public

Methods

«Singleton» Constructor
Yana Yana (
string $filename, array $ARGS
)
List of parameters:
Name Type Description
$filename string path to system.config
$ARGS array associative array of request vars
Description:

This function creates a new instance of the framework. Note that you may only operate one instance at a time.

Examples:

If you want to use a web interface:

  1.  global $YANA;
  2.  $YANA new yana("config/system.config"$_REQUEST);

If you want to use a command line interface:

  1.  global $YANA;
  2.  $YANA new yana("config/system.config"$_SERVER['argv]);

  • access: public
  • uses: new - yana("config/system.config", $_REQUEST)
«factory» connect()
mixed &connect (
string $source
)
List of parameters:
Name Type Description
$source string name of the database *.config file that describes the names and structure of tables within the database (see config/db/*.config)
Description:

Returns a ready-to-use database connection.

If you enter more than 1 argument, each additional database structure file will be loaded as well and merged with the others.

Example:

  1.  global $YANA;
  2.  // Connect to database using 'config/db/user.config'
  3.   $db $YANA->connect('user');
  4.  // Connect to database using multiple files
  5.   $db $YANA->connect('user','foo','bar');

  • access: public
exit the current script
void exitTo (
[string $event = '']
)
List of parameters:
Name Type Description
$event string upcoming event to route to
Description:

This will flush error messages and warnings to the screen, write all reported errors (if any) to the framework's logs and then exit the current script. After that it will call itself again to handle the event provided by the argument $event.

You may use the special event 'null' to prevent the framework from handling an event. In this case it will just exit.

If the argument $event is not provided, the default event will be used instead.

Examples:

  1.  global $YANA;
  2.  
  3.  // print an error and go to start page
  4.   $YANA->reportnew Error('404') );
  5.  $YANA->exitTo();
  6.  
  7.  // same as:
  8.   $YANA->exitTo('');
  9.  
  10.  // Use special event 'null' if you just want to
  11.  // view the error message and exit the script
  12.  // without handling another event.
  13.  // ( You may translate this to: "exit to 'nowhere'" )
  14.   $YANA->reportnew Error('500') );
  15.  $YANA->exitTo(null);
  16.  
  17.  // output message and route to 'login' page
  18.   $YANA->reportnew Error('access denied') );
  19.  $YANA->exitTo('login');

Please note: any code followed after a call to this function will never be executed.

  • since: 2.9.0 RC2
  • access: public
returns the default value for a given var (if any) else returns null (not false!)
mixed getDefault (
string $key
)
List of parameters:
Name Type Description
$key string adress of data in memory (case insensitive)
Description:
  • access: public
  • uses: $YANA->getDefault('CONTAINER1.CONTAINER2.DATA')
returns the current profile id
string getId ()
Description:

This is a shortcut for $YANA->getVar('ID')

  • access: public
returns current type of session (0=using profile|1=using default data)
int getMode ()
Description:
  • access: public
  • uses: $YANA->getMode()
get a value from the request vars
mixed getRequestVar (
[string $key = '*']
)
List of parameters:
Name Type Description
$key string adress of data in memory (case insensitive)
Description:

Returns the value identified by $key from an untainted, merged copy of the $_POST and $_GET arrays. (Or the input arguments, if the framework is run via a command line interface)

In this case "untainted" means, the result is either a string with at most 50000 characters, or an array of such strings, or the constant NULL if the var does not exist. If an input string contains a template token, or a '$' character they are automatically escaped to HTML entities. This is done to reduce the risk of code injection.

Note that this version is case-insensitive. This means "var", "Var" and "VAR" all refer to the same input.

If you call this function without the $key parameter or you use the wildcard '*' the whole "request" array is returned.

  • access: public
  • uses: $YANA->getRequestVar('CONTAINER.DATA')
retrieves var from registry (memory shared by all plugins)
mixed getVar (
string $key
)
List of parameters:
Name Type Description
$key string adress of data in memory (case insensitive)
Description:
  • access: public
  • uses: $YANA->getVar('CONTAINER1.CONTAINER2.DATA')
resolves event and calls plugin(s), with the given arguments
bool handle (
[string $event = ""], [array $ARGS = null]
)
List of parameters:
Name Type Description
$event string script action parameter
$ARGS array array of passed arguments
Description:
  • access: public
  • uses: $YANA->handle('test', - $_REQUEST)
merges the value at adresse $key with the provided array data
bool merge (
string $key, array $array
)
List of parameters:
Name Type Description
$key string adress of data in memory (case insensitive)
$array array associative array to merge
Description:
  • access: public
  • uses: $YANA->merge('CONTAINER1.CONTAINER2.DATA', - $array)
outputs an text message (while terminating the current script)
void message (
string $level, scalar $errcode, [string $event = ""]
)
List of parameters:
Name Type Description
$level string type of message ('OK'|'ALERT'|'ERROR')
$errcode scalar code of corresponding message in message.config
$event string upcoming event to route to
Description:

Examples:

  1.  global $YANA;
  2.  // error - page not found
  3.   $YANA->message('ERROR''404');
  4.  // internal error
  5.   $YANA->message('ERROR''500');
  6.  // alert - entry allready exists
  7.  // (the token 'ID' is used in the error message)
  8.   $YANA->setVar('ID'$existing_id);
  9.  $YANA->message('ALERT''ALLREADY_EXISTS');
  10.  // OK - changes have been saved
  11.   $YANA->message('OK''200');
  12.  // output message and route to 'login' page
  13.   $YANA->message('ERROR''access denied''login');

This function is deprecated as of version 2.9.0 RC2. It is strongly recommended, to use the following code instead:

  1.  global $YANA;
  2.  // error - page not found
  3.   $YANA->reportnew Error('404') );
  4.  $YANA->exitTo('');
  5.  // internal error
  6.   $YANA->reportnew Error('500') );
  7.  $YANA->exitTo('');
  8.  // alert - entry allready exists
  9.  // (the token 'ID' is used in the error message)
  10.   $YANA->reportnew Alert('ALLREADY_EXISTS')array('ID' => $existing_id) );
  11.  $YANA->exitTo('');
  12.  // OK - changes have been saved
  13.   $YANA->reportnew Message('200') );
  14.  $YANA->exitTo('');
  15.  // output message and route to 'login' page
  16.   $YANA->reportnew Error('access denied') );
  17.  $YANA->exitTo('login');

  • deprecated: since 2.9.0 RC2
  • access: public
adds an entry to the log-queue
void report (
Report $log
)
List of parameters:
Name Type Description
$log Report object containing the log entry
Description:

The entry will be printed to screen or written to log-file, depending on it's base-class.

Examples:

  1.  global $YANA;
  2.  // report an error level message
  3.   $msg new error("Oups! Something went wrong and I can't fix it.");
  4.  $db $YANA->report($msg);
  5.  // report a warning level message
  6.   $msg new warning("the string 'my dog ate my homework' is not a valid excuse");
  7.  $db $YANA->report($msg);
  8.  // report an alert level message
  9.   $msg new alert("Swimming in lava might cause your shorts to catch fire");
  10.  $db $YANA->report($msg);
  11.  // report a status level message
  12.   $msg new message("Thanks for your request. All is fine!");
  13.  $db $YANA->report($msg);
  14.  // report a log entry
  15.   $msg new log("this is a note that goes to the logs");
  16.  $db $YANA->report($msg);

  • access: public
  • uses: $YANA->report($report)
sets the type of a var on registry (memory shared by all plugins)
bool setType (
string $key, string $type
)
List of parameters:
Name Type Description
$key string adress of data in memory (case insensitive)
$type string new type of variable
Description:
  • access: public
  • uses: $YANA->setType('CONTAINER1.CONTAINER2.DATA', - 'string')
sets var on registry
bool setVar (
string $key, mixed $value
)
List of parameters:
Name Type Description
$key string adress of data in memory (case insensitive)
$value mixed new value (may be scalar value or array)
Description:

The "registry" is memory shared by all plugins.

  • access: public
  • uses: $YANA->setVar('CONTAINER1.CONTAINER2.DATA', - $value)
sets var on registry by Reference
bool setVarByReference (
string $key, mixed &$value
)
List of parameters:
Name Type Description
$key string adress of data in memory (case insensitive)
&$value mixed new value (may be scalar value or array)
Description:

The "registry" is memory shared by all plugins.

  • access: public
  • uses: $YANA->setVar('CONTAINER1.CONTAINER2.DATA', - $value)
removes var from registry (memory shared by all plugins)
bool unsetVar (
string $key
)
List of parameters:
Name Type Description
$key string adress of data in memory (case insensitive)
Description:
  • access: public
  • uses: $YANA->unsetVar('CONTAINER1.CONTAINER2.DATA')
provides GUI from current data
void writeView ()
Description:
  • access: public
  • uses: $YANA->writeView()
inherited from base classes

Inherited From Singleton

Inherited From Object

Documentation generated on Sun, 11 Mar 2007 15:02:50 +0100 by phpDocumentor 1.3.1

yana author: Thomas MeyerHomepage: www.yanaframework.net