tangra logo
   
[ class tree: tangra_lib ] [ index: tangra_lib ] [ all elements ]
 

Class: Tangra_Module_Installer

Source Location: /modules_manager/tangra_module_installer.class.php

Class Tangra_Module_Installer

Class Overview
Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From Tangra_Class

Tangra_Class::get_class_name()
Alias of get_class(). Exist because of historical reasons.
Tangra_Class::__set()
Overides PHP built-in method and just throws exception if called. Purpose - to "forbid" autosetting of nonexisting class properties.

[ Top ]
Property Summary
integer   $dir_permissions   Permissions that will be used to chmod dirs to
array   $files   List of installed files and directories
string   $file_group   Usergroup to which intalled files will be chown-ed
integer   $file_permissions   Filepermissions that will be used to chmod installed files to
string   $module_dir   Module source dir
string   $module_name   Name of the module
boolean   $overwrite   Flag for overwrite
boolean   $overwrite_all   Flag for overwrite all
string   $target_dir   Root directory of the site where module will be installed
array   $upgrade_matrix   Contains array with version => upgrade method pairs

[ Top ]
Method Summary
Tangra_Module_Installer   __construct()   Constructor
string   abstract_path()   Converts full path to abstract path, this way files.list is portable between depoyments
void   add_section_to_conf_file()   Adds new section to conf file
void   add_to_files_list_dir()   Adds dir to files list
void   add_to_files_list_file()   Adds file to files list
void   add_to_files_list_symlink()   Adds symlink to files list
void   backup_files_list()   Makes a copy of current files.list in order to be used later when generating new one (after upgrade)
boolean   can_upgrade()   This function is called to check if installer can upgrade from given version.
void   check_params()   Checks if all required parameters are present
void   compile_bulk()   Compiles bulk of files contained in $source_dir into $destination_dir
void   compile_tpl_file()   Compiles template file and writes the rezult in destination file. Adds full destination path to files list.
void   copy_module_ctrl()   Copies module.ctrl file to modules conf dir
void   copy_static_content_bulk()   Recursive copy of given directory
void   copy_static_file()   Copies file.
void   create_dir()   Creates directory and adds it to files list.
void   create_dir_full_path()   Creates directory and adds it to files list.
void   create_module_conf_dir()   Creates modules conf dir (hidden/conf/modules)
void   create_module_dir()   Creates module's config dir, i.e. where module.ctrl file will be installed
void   create_sym_link()   Creates symlink and adds it to files list
array   find_start_and_end_of_conf_section()   Find start and end indexes of module's section
integer   get_dir_permissions()   Returns permission that will be used to chmod installed dirs to
unknown   get_files()   Returns installed files list
unknown   get_file_group()   Returns usergroup to which intalled files will be chown-ed
integer   get_file_permissions()   Returns permission that will be used to chmod installed files to
unknown   get_module_dir()   Returns module source dir
string   get_module_name()   Returns module name
boolean   get_overwrite()   Returns overwrite flag
boolean   get_overwrite_all()   Returns overwrite all flag
unknown   get_target_dir()   Gets root directory of the site where module will be installed
void   get_upgrade_method()   Returns name of the method that will perform upgrade from version $from_version
void   init_can_upgrade()  
void   install()   Actual installation. This method have to be overwrited by inherited clases.
boolean   is_parameter_present()   Checks if parameter is present
void   post_install()   Activities that have to be performed after actual installation have to be placed here.
void   post_upgrade()   Activities that have to be performed after actual upgrade have to be placed here.
void   pre_install()   Activities that have to be performed before actual installation have to be placed here.
void   pre_upgrade()   Activities that have to be performed before actual upgrade have to be placed here.
void   remove_section_from_conf_file()   Removes module section from conf file
void   set_dir_permissions()   Sets permission that will be used to chmod installed dirs to
void   set_files()   Sets installed files list.
void   set_file_group()   Sets usergroup to which intalled files will be chown-ed
void   set_file_permissions()   Sets permission that will be used to chmod installed files to
void   set_item_permissions()   Sets file/dirs permissions and group (if values available)
void   set_module_dir()   Sets module source dir
void   set_module_name()   Sets module name
void   set_overwrite()   Sets overwrite flag
void   set_overwrite_all()   Sets overwrite all flag
void   set_target_dir()   Sets root directory of the site where module will be installed
void   set_upgrade_method()   Adds new class method that will handle upgrade from particular version
void   uninstall()   Deinstallation of the module
void   upgrade()   Performs upgrade of module
void   write_files_list()   Writes installed files list to files.list
void   _add_section_to_conf_file()   Actual adding of section to conf file
void   _compile_bulk()   Actual compilation of bulk files. See compile_bulk();
void   _compile_tpl_file()   Actual compilation of template file
void   _copy_static_content_bulk()   Recursive copy of given directory (actual copy)
boolean   _copy_static_file()   Actual copy of file
unknown   _create_sym_link()   Enter description here...

[ Top ]
Properties
integer   $dir_permissions = '' [line 157]

Permissions that will be used to chmod dirs to

API Tags:
Access:  private


[ Top ]
array   $files = array() [line 121]

List of installed files and directories

API Tags:
Internal:  
Access:  protected


[ Top ]
string   $file_group = '' [line 142]

Usergroup to which intalled files will be chown-ed

API Tags:
Internal:  
Access:  private


[ Top ]
integer   $file_permissions = '' [line 150]

Filepermissions that will be used to chmod installed files to

API Tags:
Internal:  
Access:  private


[ Top ]
string   $module_dir [line 107]

Module source dir

API Tags:
Internal:  
Access:  private


[ Top ]
string   $module_name [line 100]

Name of the module

API Tags:
Internal:  
Access:  private


[ Top ]
boolean   $overwrite [line 135]

Flag for overwrite

API Tags:
Internal:  
Access:  private


[ Top ]
boolean   $overwrite_all [line 128]

Flag for overwrite all

API Tags:
Internal:  
Access:  private


[ Top ]
string   $target_dir [line 114]

Root directory of the site where module will be installed

API Tags:
Internal:  
Access:  private


[ Top ]
array   $upgrade_matrix = array() [line 166]

Contains array with version => upgrade method pairs

Each instance of module installer must provide values (in __constructor) here if it is capable of upgrade

API Tags:
Access:  private


[ Top ]
Methods
Constructor __construct  [line 178]

  Tangra_Module_Installer __construct( array $params  )

Constructor

Parameter $params is a structured array that must have at least key 'target-path'. Other parameters have to be fed as key-value pairs.

Example $params['smarty-dir'] = '/some/path';

Parameters:
array   $params: 


[ Top ]
abstract_path  [line 1057]

  string abstract_path( string $item  )

Converts full path to abstract path, this way files.list is portable between depoyments

This method accepts $item like /var/www/sites/test/hidden/inc/classes/some_class.class.php and converts it to %HIDDEN%inc/classes/some_class.class.php

Parameters:
string   $item:  Full path of a item

API Tags:
Return:  abstracted path
Access:  private


[ Top ]
add_section_to_conf_file  [line 844]

  void add_section_to_conf_file( string $file, string $section_content, [boolean $strict = false]  )

Adds new section to conf file

Parameters:
string   $file:  Path to config file relative to site target dir
string   $section_content:  Content of the section
boolean   $strict:  If true will throw exception if section already exists.

API Tags:
Access:  protected

Information Tags:
Throws:  TE_TMM_Exception

[ Top ]
add_to_files_list_dir  [line 1026]

  void add_to_files_list_dir( string $item  )

Adds dir to files list

Parameters:
string   $item:  Full path to the dir

API Tags:
Access:  protected


[ Top ]
add_to_files_list_file  [line 1009]

  void add_to_files_list_file( string $item  )

Adds file to files list

Parameters:
string   $item:  Full path to the file

API Tags:
Access:  protected


[ Top ]
add_to_files_list_symlink  [line 1041]

  void add_to_files_list_symlink( string $item  )

Adds symlink to files list

Parameters:
string   $item:  Full path to the symlink

API Tags:
Access:  protected


[ Top ]
backup_files_list  [line 1165]

  void backup_files_list( string $from_version  )

Makes a copy of current files.list in order to be used later when generating new one (after upgrade)

Parameters:
string   $from_version: 

API Tags:
Access:  protected


[ Top ]
can_upgrade  [line 1141]

  boolean can_upgrade( string $from_version  )

This function is called to check if installer can upgrade from given version.

Parameters:
string   $from_version: 

API Tags:
Access:  public


[ Top ]
check_params  [line 242]

  void check_params( array $params  )

Checks if all required parameters are present

Parameters:
array   $params: 

API Tags:
Access:  protected

Information Tags:
Throws:  TE_TMM_Exception

[ Top ]
compile_bulk  [line 1078]

  void compile_bulk( Tangra_Simple_Tple $tple, string $source_dir, string $destination_dir, [boolean $is_root = true]  )

Compiles bulk of files contained in $source_dir into $destination_dir

Parameters:
Tangra_Simple_Tple   $tple:  Tangra_Simple_Tple instance. You have to set all exports before calling this method
string   $source_dir:  Relative to $tple->get_tpl_path(). Example: 'htdocs'
string   $destination_dir:  Relative to $this->get_target_dir(). Example: 'htdocs/admin'
boolean   $is_root:  If false tries to create $destionation_dir if not already exist. If true will copy just the content of $source_dir.

API Tags:
Access:  protected


[ Top ]
compile_tpl_file  [line 700]

  void compile_tpl_file( Tangra_Simple_Tple $tple, string $file, string $destination_file, [boolean $special_file = false]  )

Compiles template file and writes the rezult in destination file. Adds full destination path to files list.

Parameters:
Tangra_Simple_Tple   $tple:  Template engine object with preassigned values that will be substituted
string   $file:  Temlate file
string   $destination_file:  Destination file
boolean   $special_file:  Flags file that will not be overwrited if just 'overwrite' flag is set. Such files are for example configuration files that you don't want to get overwrited when preinstalling module. If you want to overwrite special files use 'overwrite-all' flag.

API Tags:
Access:  protected

Information Tags:
Throws:  TE_TMM_Item_Already_Exist

[ Top ]
copy_module_ctrl  [line 816]

  void copy_module_ctrl( )

Copies module.ctrl file to modules conf dir


API Tags:
Internal:  
Access:  private

Information Tags:
Throws:  TE_TMM_Exception

[ Top ]
copy_static_content_bulk  [line 454]

  void copy_static_content_bulk( string $source_dir, string $destination_dir, [boolean $is_root = true]  )

Recursive copy of given directory

Parameters:
string   $source_dir:  Source dir
string   $destination_dir:  destination dir
boolean   $is_root:  If false tries to create $destionation_dir if not already exist. If true will copy just the content of $source_dir.

API Tags:
Access:  protected

Information Tags:
Throws:  TE_TMM_Exception

[ Top ]
copy_static_file  [line 592]

  void copy_static_file( string $source_file, string $target_file, [boolean $special_file = false]  )

Copies file.

Parameters:
string   $source_file:  Path to source file relative to module source dir
string   $target_file:  Path to target file relative to site target path
boolean   $special_file:  Flags file that will not be overwrited if just 'overwrite' flag is set. Such files are for example configuration files that you don't want to get overwrited when preinstalling module. If you want to overwrite special files use 'overwrite-all' flag.

API Tags:
Access:  protected

Information Tags:
Throws:  TE_TMM_Exception,TE_TMM_Item_Already_Exist

[ Top ]
create_dir  [line 665]

  void create_dir( string $dir  )

Creates directory and adds it to files list.

If directory already exists is just added to files list.

Parameters:
string   $dir:  Directory to be created. Relative to target_path

API Tags:
Access:  protected

Information Tags:
Throws:  TE_TMM_Exception

[ Top ]
create_dir_full_path  [line 682]

  void create_dir_full_path( string $dir  )

Creates directory and adds it to files list.

If directory already exists is just added to files list.

Parameters:
string   $dir:  Directory to be created specified with full path

API Tags:
Access:  protected


[ Top ]
create_module_conf_dir  [line 233]

  void create_module_conf_dir( )

Creates modules conf dir (hidden/conf/modules)


API Tags:
Abstract:  
Access:  protected


[ Top ]
create_module_dir  [line 651]

  void create_module_dir( string $modules_conf_dir  )

Creates module's config dir, i.e. where module.ctrl file will be installed

Parameters:
string   $modules_conf_dir: 

API Tags:
Access:  protected


[ Top ]
create_sym_link  [line 760]

  void create_sym_link( string $source_file, string $link_name, [string $alternative_source_for_copy = '']  )

Creates symlink and adds it to files list

Parameters:
string   $source_file:  Source file that symlink will point to
string   $link_name:  Link name
string   $alternative_source_for_copy:  If symlinks are not available (like in Windows), just copy this file instead of creating symlink

API Tags:
Access:  protected

Information Tags:
Throws:  TE_TMM_Exception,TE_TMM_Item_Already_Exist

[ Top ]
find_start_and_end_of_conf_section  [line 924]

  array find_start_and_end_of_conf_section( array $arr  )

Find start and end indexes of module's section

Parameters:
array   $arr: 

API Tags:
Return:  Structured array 'start' => start index, 'end' => end index
Internal:  
Access:  private


[ Top ]
get_dir_permissions  [line 409]

  integer get_dir_permissions( )

Returns permission that will be used to chmod installed dirs to


API Tags:
Access:  public


[ Top ]
get_files  [line 525]

  unknown get_files( )

Returns installed files list


API Tags:
Access:  public


[ Top ]
get_file_group  [line 429]

  unknown get_file_group( )

Returns usergroup to which intalled files will be chown-ed


API Tags:
Access:  public


[ Top ]
get_file_permissions  [line 387]

  integer get_file_permissions( )

Returns permission that will be used to chmod installed files to


API Tags:
Access:  public


[ Top ]
get_module_dir  [line 291]

  unknown get_module_dir( )

Returns module source dir


API Tags:
Access:  public


[ Top ]
get_module_name  [line 271]

  string get_module_name( )

Returns module name


API Tags:
Access:  public


[ Top ]
get_overwrite  [line 344]

  boolean get_overwrite( )

Returns overwrite flag


API Tags:
Access:  public


[ Top ]
get_overwrite_all  [line 365]

  boolean get_overwrite_all( )

Returns overwrite all flag


API Tags:
Access:  public


[ Top ]
get_target_dir  [line 324]

  unknown get_target_dir( )

Gets root directory of the site where module will be installed


API Tags:
Access:  public


[ Top ]
get_upgrade_method  [line 1225]

  void get_upgrade_method( string $from_version  )

Returns name of the method that will perform upgrade from version $from_version

Name of the metod is lookup in $this->upgrade_matrix

Parameters:
string   $from_version: 

API Tags:
Access:  protected


[ Top ]
init_can_upgrade  [line 1236]

  void init_can_upgrade( )


API Tags:
Access:  public


[ Top ]
install  [line 213]

  void install( )

Actual installation. This method have to be overwrited by inherited clases.


API Tags:
Access:  public


[ Top ]
is_parameter_present  [line 441]

  boolean is_parameter_present( array $params, string $parameter  )

Checks if parameter is present

Parameters:
array   $params: 
string   $parameter:  Parameter to be checked

API Tags:
Access:  protected


[ Top ]
post_install  [line 223]

  void post_install( )

Activities that have to be performed after actual installation have to be placed here.

If you overwrite this method don't forget to call parent::post_install()


API Tags:
Access:  public


[ Top ]
post_upgrade  [line 1198]

  void post_upgrade( string $from_version  )

Activities that have to be performed after actual upgrade have to be placed here.

If you overwrite this method don't forget to call parent::post_upgrade()

Parameters:
string   $from_version: 

API Tags:
Access:  public


[ Top ]
pre_install  [line 207]

  void pre_install( )

Activities that have to be performed before actual installation have to be placed here.


API Tags:
Abstract:  


[ Top ]
pre_upgrade  [line 1155]

  void pre_upgrade( string $from_version  )

Activities that have to be performed before actual upgrade have to be placed here.

If you overwrite this method don't forget to call parent::pre_upgrade()

Parameters:
string   $from_version: 

API Tags:
Access:  public


[ Top ]
remove_section_from_conf_file  [line 894]

  void remove_section_from_conf_file( string $file, [boolean $strict = true]  )

Removes module section from conf file

Parameters:
string   $file:  Path to conh file relative to site target dir
boolean   $strict:  If true will throw exception if section does not exists.

API Tags:
Access:  protected

Information Tags:
Throws:  TE_TMM_Exception

[ Top ]
set_dir_permissions  [line 399]

  void set_dir_permissions( integer $dir_permissions  )

Sets permission that will be used to chmod installed dirs to

Please note that you have to pass parameter $dir_permissions without leading zero (for octal value).

Parameters:
integer   $dir_permissions: 

API Tags:
Access:  public


[ Top ]
set_files  [line 511]

  void set_files( array $files  )

Sets installed files list.

Parameters:
array   $files: 

API Tags:
Access:  public

Information Tags:
Throws:  Tangra_Exception

[ Top ]
set_file_group  [line 419]

  void set_file_group( string $file_group  )

Sets usergroup to which intalled files will be chown-ed

Parameters:
string   $file_group: 

API Tags:
Access:  public


[ Top ]
set_file_permissions  [line 377]

  void set_file_permissions( integer $file_permissions  )

Sets permission that will be used to chmod installed files to

Please note that you have to pass parameter $file_permissions without leading zero (for octal value).

Parameters:
integer   $file_permissions: 

API Tags:
Access:  public


[ Top ]
set_item_permissions  [line 562]

  void set_item_permissions( string $item  )

Sets file/dirs permissions and group (if values available)

Parameters:
string   $item:  Path to file / dir

API Tags:
Access:  protected


[ Top ]
set_module_dir  [line 281]

  void set_module_dir( string $module_dir  )

Sets module source dir

Parameters:
string   $module_dir: 

API Tags:
Access:  protected


[ Top ]
set_module_name  [line 257]

  void set_module_name( string $name  )

Sets module name

Parameters:
string   $name: 

API Tags:
Access:  protected

Information Tags:
Throws:  TE_TMM_Exception

[ Top ]
set_overwrite  [line 334]

  void set_overwrite( boolean $owr  )

Sets overwrite flag

Parameters:
boolean   $owr: 

API Tags:
Access:  public


[ Top ]
set_overwrite_all  [line 355]

  void set_overwrite_all( boolean $owr  )

Sets overwrite all flag

Parameters:
boolean   $owr: 

API Tags:
Access:  public


[ Top ]
set_target_dir  [line 302]

  void set_target_dir( string $target_dir  )

Sets root directory of the site where module will be installed

Parameters:
string   $target_dir: 

API Tags:
Access:  protected

Information Tags:
Throws:  TE_TMM_Target_Dir_Not_Writable, TE_TMM_Target_Dir_Not_Exists, TE_TMM_Target_Dir_Not_Exists

[ Top ]
set_upgrade_method  [line 1209]

  void set_upgrade_method( string $version, string $method_name  )

Adds new class method that will handle upgrade from particular version

Parameters:
string   $version: 
string   $method_name: 

API Tags:
Access:  protected


[ Top ]
uninstall  [line 999]

  void uninstall( $params  )

Deinstallation of the module

Incomplete method. TCC has functionality to remove modules.

Parameters:
   $params: 

API Tags:
Access:  public


[ Top ]
upgrade  [line 1183]

  void upgrade( string $from_version  )

Performs upgrade of module

Parameters:
string   $from_version: 

API Tags:
Access:  public


[ Top ]
write_files_list  [line 534]

  void write_files_list( )

Writes installed files list to files.list


API Tags:
Access:  protected


[ Top ]
_add_section_to_conf_file  [line 877]

  void _add_section_to_conf_file( string $full_path, string $section_content  )

Actual adding of section to conf file

Parameters:
string   $full_path:  Full path to conf file
string   $section_content:  Content of the section

API Tags:
Internal:  
Access:  private


[ Top ]
_compile_bulk  [line 1097]

  void _compile_bulk( Tangra_Simple_Tple $tple, string $source_dir, string $destination_dir, [boolean $is_root = true]  )

Actual compilation of bulk files. See compile_bulk();

This method is not ment to be called directly by the user. Use compile_bulk() instead.

Parameters:
Tangra_Simple_Tple   $tple:  Tangra_Simple_Tple instance. You have to set all exports before calling this method
string   $source_dir:  Relative to $tple->get_tpl_path(). Example: 'htdocs'
string   $destination_dir:  Relative to $this->get_target_dir(). Example: 'htdocs/admin'
boolean   $is_root:  If false tries to create $destionation_dir if not already exist. If true will copy just the content of $source_dir.

API Tags:
Access:  private

Information Tags:
Throws:  TE_TMM_Item_Already_Exist,TE_TMM_Exception

[ Top ]
_compile_tpl_file  [line 736]

  void _compile_tpl_file( Tangra_Simple_Tple $tple, string $file, string $destination_file  )

Actual compilation of template file

Parameters:
Tangra_Simple_Tple   $tple: 
string   $file: 
string   $destination_file: 

API Tags:
See:  Tangra_Module_Installer::compile_tpl_file()
Internal:  
Access:  private

Information Tags:
Throws:  TE_TMM_Exception

[ Top ]
_copy_static_content_bulk  [line 469]

  void _copy_static_content_bulk( string $source_dir, string $destination_dir, [boolean $is_root = true]  )

Recursive copy of given directory (actual copy)

Parameters:
string   $source_dir:  Source dir
string   $destination_dir:  destination dir
boolean   $is_root:  If false tries to create $destionation_dir if not already exist. If true will copy just the content of $source_dir.

API Tags:
Access:  private

Information Tags:
Throws:  TE_TMM_Item_Already_Exist

[ Top ]
_copy_static_file  [line 634]

  boolean _copy_static_file( string $source_file, string $target_file  )

Actual copy of file

Parameters:
string   $source_file: 
string   $target_file: 

API Tags:
Internal:  
Access:  private

Information Tags:
Throws:  TE_TMM_Exception

[ Top ]
_create_sym_link  [line 798]

  unknown _create_sym_link( unknown_type $source_file, unknown_type $link_name  )

Enter description here...

Parameters:
unknown_type   $source_file: 
unknown_type   $link_name: 

API Tags:
Access:  private

Information Tags:
Throws:  TE_TMM_Exception

[ Top ]