* sample/*.php (Controller)
|
+The remaining files usually are called by the browser and process the HTTP request. Data entered by the user can be stored in the model before the [http://smarty.php.net/|Smarty] template engine is called to render the new page. These files contain the proramming logic.
|
|
-! A Breakdown of the files included in the SamplePackage
|
+! 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?
|
+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.
|
+!! 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
|
[http://phplens.com/lens/adodb/docs-datadict.htm|ADOdb Data Dictionary Documentation] Note that the last column in the table can not be followed by a ',' or the installer will choke when trying to create the table.
|
|
The next bit of code tells bitweaver that this package can be used as
|
a homepage:
|
-{code}$gBitInstaller->makePackageHomeable( SAMPLE_PKG_NAME ); //R1 style
|
+{code}// Release One style (this is outdated and will not work in Release 2 |
+$gBitInstaller->makePackageHomeable( SAMPLE_PKG_NAME ); |
|
+// Release Two style |
$registerHash = array(
|
'package_name' => 'sample',
|
'package_path' => dirname( __FILE__ ).'/',
|
'homeable' => TRUE,
|
);
|
-$gBitSystem->registerPackage( $registerHash ); //R2 style{/code}
|
+$gBitSystem->registerPackage( $registerHash );{/code} |
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/templates/menu_sample_admin.tpl
|
-
|
+!! sample/templates/menu_sample_admin.tpl |
This is the template which is used to create the entry in the Administration menu for the package. Bitweaver finds this template using a standard naming scheme and the package name.
|
|
-! sample/admin/admin_sample_inc.php
|
-
|
+!! 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
|
-
|
+!! 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
|
-
|
+!! 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
|
-
|
+!! 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.
|