( ! ) Warning: session_start(): open(/var/lib/php/session/sess_nk8dlaj7em46em4pvd1b1t8gn5, O_RDWR) failed: No such file or directory (2) in /var/www/bitweaver/live/users/includes/bit_setup_inc.php on line 82
Call Stack
#TimeMemoryFunctionLocation
10.0001232848{main}( ).../page_history.php:0
20.0001234904require_once( '/var/www/bitweaver/live/kernel/includes/setup_inc.php' ).../page_history.php:16
30.07291909072BitSystem->scanPackages( ).../setup_inc.php:141
40.08152177352BitSystem->loadPackage( ).../BitSystem.php:1183
50.08162180384include_once( '/var/www/bitweaver/live/users/includes/bit_setup_inc.php' ).../BitSystem.php:1109
60.08292584632session_start ( ).../bit_setup_inc.php:82

( ! ) Warning: session_write_close(): open(/var/lib/php/session/sess_nk8dlaj7em46em4pvd1b1t8gn5, O_RDWR) failed: No such file or directory (2) in /var/www/bitweaver/live/kernel/includes/classes/BitSystem.php on line 580
Call Stack
#TimeMemoryFunctionLocation
10.0001232848{main}( ).../page_history.php:0
20.26435247768BitSystem->display( ).../page_history.php:57
30.26625249736BitSystem->preDisplay( ).../BitSystem.php:505
40.27335264464session_write_close ( ).../BitSystem.php:580

( ! ) Warning: session_write_close(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session) in /var/www/bitweaver/live/kernel/includes/classes/BitSystem.php on line 580
Call Stack
#TimeMemoryFunctionLocation
10.0001232848{main}( ).../page_history.php:0
20.26435247768BitSystem->display( ).../page_history.php:57
30.26625249736BitSystem->preDisplay( ).../BitSystem.php:505
40.27335264464session_write_close ( ).../BitSystem.php:580
- bitweaver

Version 19

Framework - Developer's Guide

Created by: hiran, Last modification: 16 Jan 2007 (19:22 UTC) by hiran
The Bitweaver Framework, consisting of Liberty and Kernel, offers you a lot of functionality. Here we'll try to show how you can make use of that.

Business Objects a la Liberty

Which base class?

If you want to create your own Business Object, you will probably use LibertyAttachable as base class, as it offers most functionality. Use LibertyContent or LibertyBase when you know what you are doing.

LibertyAttachable

Classes derived from LibertyAttachable come with this functionality:
  • They can take title and formatted text
  • They maintain creation date, creator and modification date/modificator information
  • their text content is subject to the full text seach
  • The calendar can display events occurring to LibertyAttachable objects.
  • Upon database access (store, load) other service plugins are triggered

If all you need is a new data type that contains some formatted text, you might be pretty quick in implementation:

<?php
require_once( LIBERTY_PKG_PATH.'LibertyAttachable.php' ); //import base class

define'BITRESOURCE_CONTENT_TYPE_GUID''bitresource' ); // This is used to uniquely identify the object type

class BitResource extends LibertyAttachable {

    
/**
    * During initialisation, be sure to call our base constructors
    **/
    
function BitResource$pContentId=NULL ) {
        
LibertyAttachable::LibertyAttachable();

        
$this->mContentId $pContentId;
        
$this->mContentTypeGuid BITRESOURCE_CONTENT_TYPE_GUID;

        
$parms = array(
            
'content_type_guid' => BITRESOURCE_CONTENT_TYPE_GUID,
            
'content_description' => 'Managed Resource',
            
'handler_class' => 'BitResource',
            
'handler_package' => 'mypackage',
            
'handler_file' => 'BitResource.php',
            
'maintainer_url' => 'mailto:guess@who.com'
        
);
        
$this->registerContentTypeBITRESOURCE_CONTENT_TYPE_GUID$parms ); // register class with Bitweaver
    
}

}
?>


Custom fields

Probably you will want to add some custom fields. This will be some more work, as Liberty won't know about them and we have to handle them ourselves.

First think of a place to store the data. We will have to use our own table in the database. To match the liberty data with our own we should use an identifier. content_id is the one provided by liberty, and it will serve us well now. So create a table with two columns, just as shown. Later you will see how Bitweaver automatically creates the table upon package installation.

<?php
create table mydata 
(
    
content_id integer(4),
    
expires timestamp
)
?>


  • getServicesSQL
  • prepGetList
  • postGetList

History functionality

How can you enable history tracking in Liberty?

LibertyContent

LibertyBase

Sorted Lists

Up to now, the answer is to look at the SamplePackage and guess.
  • $gBitSystem->display(...)

Detail Views

Up to now, the answer is to look at the SamplePackage and guess.

Feedback and Confirmation

Up to now, the answer is to look at the SamplePackage and guess.
  • gBitSystem->setBrowserTitle()
  • gBitSystem->confirmDialog()

Authorisation Required

Up to now, the answer is to look at the SamplePackage and guess.
Up to now, the answer is to look at the SamplePackage and guess.
Layout assigned module titles and parameters

Services

The previous section showed how you can add a nice HTML GUI to your code. Now see what can be done behind the scenes.

Installation and Migration

The Database Schema

Your package contributes to Bitweaver. That also is during database creation. To setup the correct tables, privileges and the such make use of the _admin/schema_inc.php_ script. It is called by the Bitweaver package installer during database creation time.

<?php
$tables 
= array(
    
'resources' => "
        content_id I4 NOTNULL PRIMARY,
        expires T
    "
,
);

global 
$gBitInstaller;

foreach( 
array_keys$tables ) AS $tableName ) {
    
$gBitInstaller->registerSchemaTableMYPACKAGE_PKG_NAME$tableName$tables[$tableName] );
}

$gBitInstaller->registerPackageInfoMYPACKAGE_PKG_NAME, array(
    
'description' => "What my package is made for",
    
'license' => '<a href="http://www.gnu.org/licenses/licenses.html#LGPL">LGPL</a>',
    
'version' => '0.1',
    
'state' => 'developing',
    
'dependencies' => 'users',
) );

// ### Default UserPermissions
$gBitInstaller->registerUserPermissionsMYPACKAGE_PKG_NAME, array(
    array(
'p_event_create''Can create a resource''registered'MYPACKAGE_PKG_NAME),
    array(
'p_event_admin''Can admin resources''editors'MYPACKAGE_PKG_NAME),
    array(
'p_event_read''Can read resources''registered'MYPACKAGE_PKG_NAME),
) );

?>


Data Pump

If you want to populate the database with sample data during the installation process, you have to make use of the data pump.

For the easy to use BitResource type, simply create a file named _pump_mypackage_inc.php_ in the bitweaver/install directory with the following content. All it does is fill an array with the data to populate, then loop through that array and feed everything into BitResource::store(). Error/success messages are stored in variables.

This file will be called from the Bitweaver installer after the user agreed to populate the database, and afterwards the installer will display the error or success messages.


<?php
require_once( MYPACKAGE_PKG_PATH.'BitResource.php' );

$resourcesHash = array (
    array(
        
'title' => 'Coffee',
        
'edit' => 'just the classic instant coffe',
),
);

foreach( 
$resourcesHash as $resource ) {
    
$newResource = new BitResource();
    if( 
$newResource->store$resource ) ) {
        
$pumpedData['EventCal'][] = $resource['title'];
    } else {
        
$error $newResource->mErrors;
        
error_log('Error creating mypackage resources: '.$error0);
        
xdebug_debug_zval('error');
        
$gBitSmarty->assign'error',$error );
    }
}

?>


If you have custom fields that need population, simply add them to the array above and you are done.

Data Format

National language characters

What encoding should be used for the PHP file? How shall national language characters (at worst the complete unicode character set) be escaped?

Timestamps

Bitweaver is said to use UTC times within the database. What times are used on timestamps in the installer?
(MySQL does not support timestamps with timezone information. However the timezone used must be set in the database connection. How is that handled?
Page History
Date/CommentUserIPVersion
27 Jan 2007 (17:03 UTC)
dspt213.184.224.341
Current • Source
hiran85.233.40.19239
View • Compare • Difference • Source
hiran85.233.40.19238
View • Compare • Difference • Source
hiran85.233.40.19234
View • Compare • Difference • Source
hiran85.233.40.19233
View • Compare • Difference • Source
hiran85.233.40.19228
View • Compare • Difference • Source
hiran85.233.40.19227
View • Compare • Difference • Source
hiran85.233.40.19226
View • Compare • Difference • Source
hiran85.233.40.19225
View • Compare • Difference • Source
hiran85.233.40.19224
View • Compare • Difference • Source
hiran85.233.40.19223
View • Compare • Difference • Source
hiran85.233.40.19222
View • Compare • Difference • Source
hiran85.233.40.19221
View • Compare • Difference • Source
hiran85.233.40.19220
View • Compare • Difference • Source
hiran85.233.40.19219
View • Compare • Difference • Source
hiran85.233.40.19218
View • Compare • Difference • Source
hiran85.233.40.19217
View • Compare • Difference • Source
hiran85.233.40.19216
View • Compare • Difference • Source
hiran85.233.40.19214
View • Compare • Difference • Source
hiran85.233.40.19212
View • Compare • Difference • Source
hiran85.233.40.19211
View • Compare • Difference • Source
hiran85.233.40.19210
View • Compare • Difference • Source
hiran85.233.40.1928
View • Compare • Difference • Source
hiran85.233.40.1927
View • Compare • Difference • Source
hiran85.233.40.1925
View • Compare • Difference • Source
hiran85.233.40.1924
View • Compare • Difference • Source