Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
1
Abbreviations
2
1. Using the iTask CMS
1.1. Getting started:
Unzip the iTast2.0.zip file in you’re a folder to get the following folders, given in
the picture:
1.1.1. Copy the module_generator and project_folder also to your htdocs folder
1.1.2. Create a database from phpmyadmin named itask_db and dump the sql file
in the db folder inside admin folder to the database via php myadmin.
1.1.3. You can login to the system with username is admin and password is also
admin by going to http://localhost/project_folder/admin in your browser.
1.1.4. You can rename the project_folder to your project name but do consider
the paths in tbl_cms_menu for desired functioning of the menu links.
1.1.5. The configuration of the CMS is in the configuration.php file in the admin
folder. Its code is given below:
3
1.1.6. You can change the database details and path as per your need but
remember to dump the database before trying to access the CMS.
1.1.7. You will know other thing to change as you progress further in this
document.
4
*PS: Example of page module will be used for things below.
5
1.3.2. Then in the form fill the details as below, explanation is given about the
details filled. Use zoom to see the picture better. (Tip: use two browsers one
with phpMyadmin with table view and other with form below.)
6
1.3.3. After all the details are filled click generate module and then the following
page appears:
7
(Remember: project_folder is an imaginary name it will be the folder of the
project you are working on.)
1.3.6. If this is your first module there will be 5 folder, 4 core required folder and
now added mod_page as below:
8
1.3.7. Then go to
http://localhost/module_generator/module_access_generator_iTask/ to
generate the access for the module/modules created.
1.3.8. Click on Step1.php as below:
1.3.9. Then type in your project folder name (project_folder is being used to
demonstrate only).
9
1.3.10. After you click next following page appears:
1.3.11. All the modules in the back end will be listed and their use will be given
as "Use by System" and "Published" to use it. Make sure all modules are
"Published" and auth and default modules are checked for "Use by System".
Then click generate SQL to get following page:
1.3.12. Then copy all the code in the text area and go to your database like below:
10
1.3.13. Then paste it and click go.
11
1.3.15. Then login into your iTask admin at http://localhost/project_folder/admin/
like below:
12
1.3.18. Ok you are done with adding module now other things will follow.
13
1.4.1.2. module_name: lists the database objects which has two database
objects database and database2, these are usable when you do coding
for related tables like if there is a menu for each page then link should
be maintained. Other things included in this file are the possible
operation that can be run by default it has 5 operations add, edit, delete,
enable and disable. Add, edit and delete operation from here and
created needed files. Like if you want to add a new operation detail it
can be done from here and a file module_name.operation_name in our
case page_detail.html.php should be created. It is the back end side of
the page works in conjunction with module_name.html file.
1.4.1.3.module_name.add: Performs the insertion process of the data
submitted from module_name.add.html.php which contains the form to
add data. Message about record being added can be edited form here. In
case of related tables and adding multiple records like menu link record
for the page should be added from here.
1.4.1.4.module_name.add.html: The file has form and html elements to
input the data. It has text field validation of Spry other validation
should be added by self if needed like checkbox validation. Refer to
Spry section here for more details visit the URLs under Spry. In case
you have to add select boxes and other elements in place of text fields it
should be coded by yourself in this file.
1.4.1.5.module_name.delete: has code that calls the delete function in the
module_name.class file which deletes one or multiple records. In case
you need to delete related records or multiple records then it should be
called here and coded in the module_name.class file.
1.4.1.6.module_name.disable: has the code to disable one or multiple
records, it changes the published to 0 calling the update function of the
module_name.class file.
1.4.1.7.module_name.edit: Similar to module_name.add it gets the data from
the module_name.edit.html which has the form and formats it to be
updated in the database. It calls the update function in the
module_name.class file.
1.4.1.8.module_name.edit.html: has the form to edit the record it has the
values stored in the database. In case of using select it should be coded
specifically for the value to be selected. It has form so needs some
tweaking for validating other form elements except text filed.
1.4.1.9.module_name.enable: has the code to enable the record/records by
setting the value of published field to 1 calling the update function in
the module_name.class file. It works as reverse of the
module_name.disable file.
1.4.1.10. module_name.html : has the database objects by default database
and database2 with actions/operations to be performed. Working in
conjunction with module_name file (3.4.1.2) it also has four operations
by default add, edit, delete and list. If new database object is added say
database3 then it should be added in this file and module_name file
same for added operation like detail.
14
1.4.1.11. module_name.list.html: controls the listing of the fields of the
database table. The column types can be label for simple text, bool for
Boolean value like published or unpublished. Link for link to edit it or
view detail and image to display image.
1.4.1.12. module_name.toolbar.html: has code to show the buttons in the
toolbar, in list mode there are 6 buttons as below:
15
Initially there are 15 records to show the menu as below:
1.5.1. Showing your custom menu link and sub link in it: Now we will insert
some records in the database to show "Front End" menu link first then show
"Page management" under it. Steps to do this are given below:
1.5.1.1.Go to your phpmyadmin and to your tbl_cms_menu table then click
insert as indicated below:
16
1.5.1.2. And input the data as follows:
If there was a module for this link it could have been put in the URL
field.
1.5.1.3.Then add the record.
1.5.1.4.Login to the admin panel and see the menu it should be like below:
17
In my case it has id 4,note it down as well.
1.5.1.8.Now insert a new record to the table tbl_cms menu as below:
Similar to above addition but notice to parent is 814 of the "Front End"
link.
1.5.1.9.After the insert check the menu to get something like below:
1.5.2. Displaying the module in the main default module list display, to do this
go to /htdocs/project_folder/admin/modules/mod_default and spot the
default.list.html file and edit it.
18
I'm using notepad++. Use your favorite IDE.
1.5.3. You will see some code like below:
19
1.5.4. Paste the code below after the div close of mod=default&act=config
<div style="float: left;">
<div class="icon"> <a href="?mod=page"> <img
src="<?=$caConfig_live_site?>/theme/images/header/icon-48-article.png"
alt="Page Management System" align="top" border="0"> <span>Page
Management System </span> </a>
</div>
</div>
1.5.5. You must get the page to look something like below:
1.5.6. Save the file and see your CMS after logging in it should be changed to
something like below:
20
1.5.7. If your module is for configuration or for other purpose and you feel the
icon does not represent what the module does then you can change the icon.
The options are:
Resulted to:
1.5.9. For further demonstration I'll change the icon back to icon-48-article.png.
21
1.6. Adding, listing, editing, deleting data:
Now you have generated your module, added its link to the menu and even added
it to the main page display. Now let's add some data and see how things are done.
1.6.1. Modifying toolbar
You might need to edit the toolbar to adjust things like the module name
display and the buttons displayed in the tool bar as per the operation. Refer
here to see what this file shows.
1.6.1.1. Change module name display in listing page.
1.6.1.1.1. If you have noticed your "page manager" has a small p like
below:
1.6.1.1.5. You can name the module wish but maintaining consistency
with module_name Manager is preferred and advised.
22
1.6.1.2.2. As per the above code add and edit operations have 3 buttons
"Save", "Cancel" and "Help" you can remove help if its not
needed by delete that line's code.
1.6.1.2.3. Let's remove "Publish" and "Unpublish" from the toolbar of the
page module just to check. To do this remove the two lines of <td
to get a code something like below:
1.6.1.2.4. Save file and see the listing page of the module which will
have a toolbar like below:
1.6.1.2.5. I'll change it back as there should be enable and disable option
for the page as it also has the published field in the database table.
23
1.6.2.1.2. In case of error you will get an error like below:
1.6.2.1.3. So thing to consider here, in the form page your can see the
right side is blank, you can add form elements there as well, we
will deal about it in next segment.
1.6.2.1.4. Click "Save" button and you will get following notification if
you have not error in data validation and get redirected to the
listing page as below.
1.6.2.1.5. The data was successfully added, check database table via
PHPmyAdmin to confirm☺.
24
1.6.2.2.1. To make the URL field a select box which is a text field now
go to the page.add.html.php file in your mod_page directory. It
will have code like below:
1.6.2.2.2. Edit the <input to <select and make the code like below:
<tr>
<td class="key">Page URL:</td>
<td class=""><span id="url">
<select name="url" class="inputbox" id="url" value="<?=$url?>"
/>
<option value="home">Home</option>
<option value="aboutus">About Us</option>
<option value="download">Download</option>
</select>
</span>
</td>
</tr>
Which is:
25
1.6.2.2.3. Remember to comment the javascript to validate the URL as
compulsory. Done below:
1.6.2.2.4. Save file and try to add a new page, you will get a form like
below:
1.6.2.2.5. Notice the Page URL field is a select box, also consider that
the right part col40 div area is blank.
1.6.2.2.6. Just fill in some data and click save, let it be the about us page
in the url. After adding page you will get a page something like
below:
26
1.6.2.2.7. Now lets add a dummy form with menu related items to the
right area of the form. To do this go to the page.add.html.php file
in your mod_page directory. Add the code below just above
<input name="mod" type="hidden" id="mod" value="page">.
<div class="col40">
<fieldset class="adminform">
<table class="admintable" cellspacing="1">
<tr>
<td class="key">Menu Title:</td>
<td class=""><span id="menu_title"><input
name="menu_title" type="text" class="inputbox" id="mneu_title"
size="40" maxlength="255" value="<?=$menu_title?>" title="Give the
menu title" /><span class="textfieldRequiredMsg">Menu title is
required.</span> </span></td>
</tr>
<tr>
<td class="key">Menu Link:</td>
<td class=""><span id="menu_link"><input
name="menu_link" type="text" class="inputbox" id="mneu_link"
size="40" maxlength="255" value="<?=$menu_link?>" title="Give the
menu link" /><span class="textfieldRequiredMsg">Menu link is
required.</span> </span></td>
</tr>
</table>
</fieldset>
</div>
Which is:
27
1.6.2.2.9. Notice the other table in the right side but it will not add
anything as nothing has been coded for it in the class file and the
page.add.php file.
1.6.2.2.10. Lets see how the data gets added, the data form the for is
thrown to page.add.php file which can be divided into two parts
part 1 prepares data like below:
28
1.6.2.2.12. The $database->insert($arr) function call, calls the insert
function in class.page.php as given below:
29
1.6.2.2.13. So this is what happens. If you had to add a page with a menu
link with a table called tbl_menu which had menu_id, page_id,
menu_title and menu_url.
1.6.2.2.14. Then in page.add.html.php you must first code the form as
above then in the page.add.php get the data of the menu title and
menu body like below:
30
1.6.2.2.15. Changes in the class.page.php file should also be made, you
should code the InsertMenu function with related table as
variable, see below:
1.6.2.2.16. You are done adding the menu but there is no table called
tbl_menu. You have to code these things in update and delete as
31
well to synchronize the functions. If a tbl_menu is created with
above mentioned fields the code should work.
1.6.2.2.17. Single table addition are no big deal but related table addition
should be done like this, it's up to you to try it now. Test things.
(Tip: multiple inserts can be handled by multiple functions as per need;
always check the phpMyAdmin to test if your code is doing what it is
meant to do.)
32
1.6.3.1.2. The code to get this from in page.add.html.php and
page.add.php is in the iTask_Sample_Modules folder inside
mod_page folder or try it yourself to get something like this.
1.6.3.1.3. Let's add a download page and see its listing in the listing page
with page title, page url, menu title and published.
1.6.3.1.4. After the page is added something like this is displayed:
1.6.3.1.5. Now go to the class.page.php and find the code snippet that
displays the list above, function name is listAll.
1.6.3.1.6. Edit the code to:
function listAll() {
$query = " SELECT
$this->pms.page_id,
$this->pms.title,
$this->pms.url,
$this->pms.published,
$this->pms.register_date,
$this->pms.modified_date,
$this->tblmenu.menu_title
FROM
$this->pms,
$this->tblmenu
WHERE
$this->pms.page_id=$this-
>tblmenu.page_id";
$this->Query ($query);
}
33
Check the code in the iTask_Sample_Modules folder.
1.6.3.1.7. Add the menu items for already created page so that they also
display as the code has been edited to show two joined tables.
Therefore, after you add the menu links for home and about us
page and add other pages you should get a list like below:
1.6.3.1.8. Use your coder brain it's not as easy as it looks read the code in
the sample module folder.
1.6.3.1.9. Order of column to be displayed depends on how it is selected
in listAll( ) function and how it is placed in the page.list.html.php
file. Try to achieve the display below yourself, there is menu title
after pageURL.
34
1.6.3.2.5. Click in one of the pageURL links to get a form like below:
1.6.3.2.6. If you change and edit the text it will be updated but as there is
not menu editing fields menu options will remain as it is.
35
1.6.4.1.4. Now edit a record from the list, check it and click edit or just
click the pageUrl link to get the following form:
36
1.6.4.1.5. Now check the page.edit.html.php file's top part
<?php // no direct access
defined( '_VALID_ACCESS' ) or die( 'Restricted access' );
?>
<?php
if(isset($_SESSION['page'])) {
$page_id = $_SESSION['page']['page_id'];
$title = $_SESSION['page']['title'];
$url = $_SESSION['page']['url'];
$meta_keyword = $_SESSION['page']['meta_keyword'];
$meta_description = $_SESSION['page']['meta_description'];
$body = $_SESSION['page']['body'];
$published = $_SESSION['page']['published'];
}
else {
$page_id = $io->getVar('id','get',TRUE);
if( !$page_id ) {
print "<script> alert('Please select an item first.');
window.history.go(-1);</script>
";
exit();
}
$database2->getDetail($page_id);
if( $database2->RecordCount <= 0 ) {
print "<script> alert('No Such Data Defined'); window.history.go(-
1);</script>
";
exit();
}
$title = $database2->Fields('title');
$url = $database2->Fields('url');
37
$meta_keyword = $database2->Fields('meta_keyword');
$meta_description = $database2->Fields('meta_description');
$body = $database2->Fields('body');
$published = $database2->Fields('published');
}
unset ($_SESSION['page']);
?>
1.6.4.1.6. So the problem is Session does not have the values of the
menu, notice that $database2->getDetail($page_id); is called so
this function should be altered in class.page.php file to get the
values of the tbl_menu as well.
1.6.4.1.7. Got the class.page.php file and locate getDetail function like
below:
1.6.4.1.9. Now goto the page.edit.html.php page and add the new menu
table related variables to the code. First add session related
variables as below:
38
1.6.4.1.10. Then add variables to get form the database:
1.6.4.1.11. Now check if the fields have the value variable of the col40 div
menu elements in case of select use the following code:
39
1.6.4.1.13. Now you have successfully got the related values to the form,
front end part is done with. For the back end interaction with the
database we will have to edit the page.edit.php file that gets the
values on submission as in page.add.php.
1.6.4.1.14. Got o page.edit.php and add the following code as below:
40
1.6.4.1.16. After that call the functions to update the page and menu with
same sub query variable subQ as both have the same page_id, like
below:
1.6.4.1.18. Now save the files, refresh your edit form page and test your
update it must be functional. Mine is working see below,
downloads is changed to downloads2 in both page title and menu
title: (See the code in mod_page in iTask_Sample_Modules folder
if you have problem)
41
1.6.5. Deleting data
Deleting record/records of single table is easy as its already coded by the
generator. In case of deleting record/records from multiple tables
following steps should be followed:
1.6.5.1.5. Now save the file and code the DeleteMenu( ) function in
class.page.php as below:
42
1.6.5.1.6. Now when you delete the page its associated menu item will
also be deleted, try it see phpMyAdmin to verify its functionality
like below:
1.6.5.1.7. Before new release delete tbl_menu had
Similarly the page called new release has also been deleted, see below:
43
1.6.5.1.10. Check your operation from phpMyAdmin to verify it properly.
1.7. Using sub modules for ease of work and display sub modules in main
module
Let's picture a scenario first, we are trying to get a main module that only
displays sub modules in side it all the work is done by the sub modules. So, in
this case lets take an example of "Page Elements" module as main module and
"Block" module as its sub module.
tbl_block has the schema as shown in 3.6.3, click here to go there and have a
look at the schema. Follow the following steps to make your module and sub
module structure clear:
1.7.1. Sub modules holder main module and sub module addition
1.7.1.1. Create a main modules directory in you modules folder like say
mod_room that holds sub modules like chair and table.
1.7.1.2. To make your main module that holds your sub module functional
copy the mod_page_elements module's files only from the
iTask_Sample_modules folder not sub folders to your directory
supposed room in your modules directory.
1.7.1.3.After you copy, rename the files in your room folder as below:
44
1.7.1.4.Now open all the files and replace page_elemets by your new main
module's name here room is taken as example, so it will be like below:
1.7.1.4.1. class.room.php code
45
1.7.1.4.3. So if you browse to
http://localhost/project_folder/admin/index.php?mod=page_elements
{replace page_elements in the above URL with your module name} you
should get a page similar to above display.
1.7.1.4.4. Now generate a module called block following the steps given
at 3. 3 here and schema given in section 3.6.3 and lets make it a
sub module of your room main module.
1.7.1.4.5. After you generate your module mod_block in generate code
folder rename the folder to block.
1.7.1.4.6. Copy the folder to
/htdocs/project_folder/admin/modules/your_main_module_name , your
main module name is supposed room for this exercise.
1.7.1.4.7. Then open the block.add.html.php and edit the code as follows
Original line: <input name="mod" type="hidden" id="mod"
value="page_elements,block">
Edit it to: <input name="mod" type="hidden" id="mod"
value="room,block"> - as room is supposed to be your main module's
name.
1.7.1.4.8. Then open block.edit.html.php and edit a line of code as
follows:
Original line: <input name="mod" type="hidden" id="mod"
value="page_elements,block">
Edit it to: <input name="mod" type="hidden" id="mod"
value="room,block"> - room is supposed to be your main module.
1.7.1.4.9. Now open the block.php file and edit the code to as below:
46
1.7.1.4.10. It is done to make add and edit function properly.
1.7.1.4.11. Now you are done editing it, after that go to the main module
room in this example and open room.list.html.php file
47
1.7.1.4.13. Check the working of your block module it must be functional,
if you have problems check the block module code in the
iTask_Sample_modules folder.
1.7.1.4.14. You can list your new main module in the menu and the default
module list by following steps in 3.5.1 and 3.5.2.
1.7.1.4.15. Try to get this and do edit the menu as well.
48
1.8.1. Handling image and file upload with module.
1.8.1.1. For this example we will use a simple product table with just 4 fields
as below:
Product tables are not necessarily this simple but for the example we are
using a very simple product table to demonstrate the upload of image and
things.
1.8.1.2. Lets populate our mod_product as below:
1.8.1.3. Now copy the module form generate_code to you modules folder.
1.8.1.4.Then generate the access to the module using access generator.
1.8.1.5.After it add the menu link and or the icon on the main display page
like below:
49
1.8.1.6.The go to the product manager and add "New" icon from the toolbar to
got the following page, but don’t add a product it will cause error:
50
1.8.1.10. In case everything goes ok product will be added like below:
1.8.1.11. Now to display the product picture correctly first verify that it has
been uploaded and the thumbnail has been generated correctly by
browsing at /htdocs/project_folder/images/product as below:
51
1.8.1.14. Then edit a product to get something like below:
1.8.1.15. If you click save when editing there will be an error debug it by
commenting a line in product.edit.php as below as there is no modified
date field in tbl_procuct:
52
given and updated in the database. The filename is returned from
GenerateUniqueFilename( ) function in the class.caFileObj.php
file found in lib folder.
1.8.1.16.2. Image dimension 400*400 px is controlled by following code:
if($fileImageName != false){
list($width, $height, $type, $attr) =
getimagesize($caConfig_documentroot_image."/product/".$fileImageNam
e);
if($width > 400 || $height > 400) {
$fileImageName = "Empty";
$msg .= "Image file has to be less than 400
by 400 Resolution";
} else {
$arr = array ("image" => $fileImageName) ;
$database->Update ($arr,"WHERE
product_id='$product_id'");
}
The above code can be found in product.add.php and product.edit.php.
53
2. Conclusion
This developer guide is a surface guide on using the iTask Content Management
System (CMS), the possibilities are endless and as it has a modular design many
things can be efficiently incorporated in this highly flexible system. The extent of its
can be known when you explore yourself, indulge in some code reading and try. Hit
and trial may also bring out new avenues so start it now.
This guide has be developed to give the kick start only now you are able to do
something develop yourself to a better coder and a better solution provider using
iTask CMS 2.0.
54
References
http://en.wikipedia.org/wiki/Datagrid
http://en.wikipedia.org/wiki/Create%2C_read%2C_update_and_delete
http://en.wikipedia.org/wiki/Spry_framework
http://en.wikipedia.org/wiki/TinyMCE
Thttp://en.wikipedia.org/wiki/Content_management_system
55