Version 9

SamplePackageDissection

A Breakdown of the files that make up the SamplePackage

Created by: WaterDragon, Last modification: 29 Jun 2006 (07:38 UTC) by WaterDragon

A Breakdown of the files included in the SamplePackage


This is an attempt to list and explain all of the files in the SamplePackage put together by spiderr. Any corrections you make or additions you have to this document are warmly appreciated. After all, that is what a wiki is for, right?

These files are being tackled in an order that seems a bit odd - Start where bitweaver starts - I.E. the install. After that - index.php and bit_setup_inc.php. Then a list of everything in a directory one at a time.

sample/admin/schema_inc.php


sample/admin/schema_inc.php is the file responsible for integrating SamplePackage into the InstallPackage and thus into bitweaver. When you go to the kernal/admin/index.php page and click on Packages this file gets automatically loaded in order to display the information about your package as provided in the call to registerPackageInfo. When you click on "Activate bitweaver packages" the various things you registered are actually stored into the database for use by your package.

At the top of the file is the array of tables that the package will use to do its job. The format for the schema is not straight SQL but rather is ADOdb style DataDict style code as documented in the
ADOdb Data Dictionary Documentation

The next bit of code tells bitweaver that this package can be used as
a homepage:

<?php
$gBitInstaller
->makePackageHomeableSAMPLE_PKG_NAME );
?>
This should only be called if it is appropriate for your package, i.e. it is content and not some kind of plugin package.

The rest of the code registers the tables, indexes, sequences, package information, preferences and permissions for the package. This is all relatively straight forward and should be self explanatory.

sample/admin/admin_sample_inc.php


This file is the interface for administrating the package itself. It is used when you go to kernel/admin/index.php and click on Sample Settings. This page places the data into the smarty context for the "list settings tab" in the admin interface. This works in conjunction with the next file we will talk about sample/templates/admin_sample.tpl which is used to create the html used to display the settings loaded into the smarty context in this file. It also loads all the samples you have created and places them in context as well so that the home selection portion of the template can select from the available samples.

sample/templates/admin_sample.tpl


This is the template which renders the settings loaded by sample/admin/admin_sample_inc.php. It is pretty simple over all just creating two different tabs, one for setting the home tab and one for selecting the packages preferences.

sample/index.php


This is the main php script that is run if you go to the sample package directory as most webservers are configured to run index.php when the bare directory is given. It starts with including the bit_setup_inc.php that sets up all the bitweaver magic.

It then verifies that the package is installed and activated properly. This is the bit of code that will generate an error page indicating that the package is disabled if you haven't run through the installer to install the package yet. The next check ensures that the user has permissions to read pages of this type in the permissions system. This will generate a not-allowed error page if the user is lacking that permission.

The next chunk of code checks to see if the id of a particular sample has been given and if it hasn't loads the 'home_directory' configuration. This is the default which is set in the admin screen discussed above. Finally the lookup_sample_inc.php file is run to load the content in question. The addHit() function is called to increment the hit counter for this content. Finally the page is rendered by making a call to display and passing in the template sample_display.tpl which is stored in sample/templates. The tra call attempts to translate the package name if it is possible.

sample/lookup_sample_inc.php


This bit of code is responsible for loading a particular instance of sample from the database and placing it in $gContent.

The top require includes the class that will hold the particular content for this package and the second one includes some magic from liberty to load the content by structure_id or content_id if that is how the object to load is being requested. This is why the next bit checks to see if $gContent is already loaded.

If a valid object isn't loaded by the inclusion of the liberty magic then the code attempts to load the content by the unique ID associated with the content, i.e. the sample_id provided in one of two places in the request.

It seems that the load by content_id is redundant since it would have been loaded by liberty if it matches but there may be some case where the liberty load fails but it works in this file though the author (Nick Palmer) has a hard time seeing how this could be the case. At worst it is never called and it is only a couple of lines of code so it is still there.

sample/templates/sample_display.tpl


This template renders an instance of the content stored in $gContent.

The first line in the file includes any templates that are registered with Liberty as navigational services. Likewise the last line includes templates for any services which are registered as view related services.

The middle portion of the file simply displays the content including edit and remove icons and information on the modifier of the content. It should be pretty self explanatory but does demonstrate the use of permissions, icons and various bits of information stored in $gContent->mInfo.

sample/mkpackage.sh


This script can be used to rename the sample package in order to make it easier to use it as a base for new packages. See SamplePackage for more information on using this to repackage the sample package as your own.


Page History
Date/CommentUserIPVersion
25 Nov 2008 (08:16 UTC)
xing62.47.229.16433
Current • Source
xing62.47.229.16432
View • Compare • Difference • Source
xing62.47.229.16431
View • Compare • Difference • Source
xing62.47.229.16430
View • Compare • Difference • Source
xing62.47.229.16429
View • Compare • Difference • Source
hiran85.233.40.19228
View • Compare • Difference • Source
hiran85.233.40.19226
View • Compare • Difference • Source
hiran85.233.40.19224
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.19218
View • Compare • Difference • Source
hiran85.233.40.19217
View • Compare • Difference • Source
hiran85.233.40.19215
View • Compare • Difference • Source
hiran85.233.40.19214
View • Compare • Difference • Source
hiran85.233.40.19213
View • Compare • Difference • Source
WaterDragon66.93.180.15112
View • Compare • Difference • Source
WaterDragon66.93.180.15111
View • Compare • Difference • Source
WaterDragon66.93.180.15110
View • Compare • Difference • Source
WaterDragon66.93.180.1519
View • Compare • Difference • Source
WaterDragon85.144.104.2477
View • Compare • Difference • Source
WaterDragon85.144.104.2476
View • Compare • Difference • Source
xing194.152.164.455
View • Compare • Difference • Source
Sean Lee71.241.129.1744
View • Compare • Difference • Source