using custom classes in application delegate class

A place for users and developers of the Xataface to discuss and receive support.

Postby yusif » Fri Dec 01, 2006 2:11 pm

Hi All,
Greatly interested in the dataface application framework. I'm trying my hand on some application using dataface. I got a php class that displays a menu just like windows explorer does. I mean colapsible/ expandible sort of menu. I want my application to use this feature at the block__before_left_column by defining it in the conf_ApplicationDelegate class. Few problems...

1. How do I make dataface include the menu class file in the conf_ApplicationDelegate class so that the
function block__before_left_column look like this:

function block__before_left_column(){


$applicationMenu = new HTML_TreeMenuXL();
$applicationNodeAttributes = array("icon"=>"folder.gif");
$applicationNode = new HTML_TreeNodeXL ("Accounts","#");
$applicationSubNode = &$applicationNode->addItem(new HTML_TreeNodeXL("Assets","#link",$applicationNodeAttributes));

$applicationSubNode = &$applicationSubNode->addItem(new HTML_TreeNodeXL("Current Assets","#link"));
$applicationSubNode->addItem(new HTML_TreeNodeXL("Fixed Assets","#link"));
$applicationSubNode->addItem(new HTML_TreeNodeXL("Other Assets","#link"));

$applicationNode->addItem(new HTML_TreeNodeXL("Liabilities and Capital","#link"));
$applicationSubNode2 = &$applicationNode->addItem(new HTML_TreeNodeXL("Current Liabilities","#link"));
$applicationSubNode2->addItem("Long Term Liabilities","#link");
$applicationSubNode2->addItem("Capital","#link");
$applicationNode->addItem(new HTML_TreeNodeXL("Balance Sheet","#link"));
$applicationMenu->addItem($applicationNode);

$demodMenu = & new HTML_DHTMLXL($applicationMenu, array("images"=>"images"));
$demodMenu->printMenu();

}


I get the following error with the above code



Warning: main(C:/Program Files/Apache Group/Apache2/htdocs/bin/TreeMenu.php): failed to open stream: No such file or directory in C:\Program Files\Apache Group\Apache2\htdocs\dataface\htmltreemenu\TreeMenuXL.php on line 50

Warning: main(): Failed opening 'C:/Program Files/Apache Group/Apache2/htdocs/bin/TreeMenu.php' for inclusion (include_path='.;c:\apache\php\pear') in C:\Program Files\Apache Group\Apache2\htdocs\dataface\htmltreemenu\TreeMenuXL.php on line 50

Warning: main(C:/Program Files/Apache Group/Apache2/htdocs/bin/ccBrowserInfo.php): failed to open stream: No such file or directory in C:\Program Files\Apache Group\Apache2\htdocs\dataface\htmltreemenu\TreeMenuXL.php on line 55

Warning: main(): Failed opening 'C:/Program Files/Apache Group/Apache2/htdocs/bin/ccBrowserInfo.php' for inclusion (include_path='.;c:\apache\php\pear') in C:\Program Files\Apache Group\Apache2\htdocs\dataface\htmltreemenu\TreeMenuXL.php on line 55

Fatal error: Class html_treemenuxl: Cannot inherit from undefined class html_treemenu in C:\Program Files\Apache Group\Apache2\htdocs\dataface\htmltreemenu\TreeMenuXL.php on line 68

Help Please!!!!!
yusif
 
Posts: 28
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Fri Dec 01, 2006 3:50 pm

You can include files just the way you would normally do in PHP. Use require, or dataface also defines a function called import that has a little better performance on repeated calls.

It looks as though you are using PEAR classes here also. PEAR classes should be placed in the proper directory structure. In this case the TreeMenuXL.php file should be located in a folder called HTML.

e.g. import('HTML/TreeMenuXL.php');
...

Also note that there are a number of places that PHP will look for files to import. YOu can place them directly in your application's directory, or in the dataface/lib directory or in the dataface directory (best to place them in your application's directory). Additionally you may have defined other places to locate class files using the include_path directive in the php.ini file.

Does this help a little?

-Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby yusif » Mon Dec 04, 2006 4:33 am

Hi Steve,
Thanks for the response, I have resolved the path issue by setting the include path but when I use import('...') it seems to redeclare the class so i took that out and had no errors but the menu does not display.

Any suggestions ...?

NB: I have all the necessary files for the menu at
"c:/Program Files/Apache Group/Apache2/htdocs/bin/" and my application delegate looks like

class conf_ApplicationDelegate {
/**
* Returns permissions array. This method is called every time an action is
* performed to make sure that the user has permission to perform the action.
* @param record A Dataface_Record object (may be null) against which we check
* permissions.
* @see Dataface_PermissionsTool
* @see Dataface_AuthenticationTool
*/



function getPermissions(&$record){
$auth =& Dataface_AuthenticationTool::getInstance();
$user =& $auth->getLoggedInUser();
if ( !isset($user) ) return Dataface_PermissionsTool::NO_ACCESS();
// if the user is null then nobody is logged in... no access.
// This will force a login prompt.
$role = $user->val('Role');
return Dataface_PermissionsTool::getRolePermissions($role);
// Returns all of the permissions for the user's current role.
}


function block__before_left_column(){


$applicationMenu = new HTML_TreeMenuXL();
$applicationNodeAttributes = array("icon"=>"folder.gif");
$applicationNode = new HTML_TreeNodeXL ("Accounts","#");
$applicationSubNode = &$applicationNode->addItem(new HTML_TreeNodeXL("Assets","#link",$applicationNodeAttributes));

$applicationSubNode = &$applicationSubNode->addItem(new HTML_TreeNodeXL("Current Assets","#link"));
$applicationSubNode->addItem(new HTML_TreeNodeXL("Fixed Assets","#link"));
$applicationSubNode->addItem(new HTML_TreeNodeXL("Other Assets","#link"));

//$applicationNode->addItem(new HTML_TreeNodeXL("Liabilities and Capital","#link"));
//$applicationSubNode2 = &$applicationNode->addItem(new HTML_TreeNodeXL("Current Liabilities","#link"));
//$applicationSubNode2->addItem("Long Term Liabilities","#link");
//$applicationSubNode2->addItem("Capital","#link");
//$applicationNode->addItem(new HTML_TreeNodeXL("Balance Sheet","#link"));
//$applicationMenu->addItem($applicationNode);

$demodMenu = & new HTML_TreeMenu_DHTMLXL($applicationMenu, array("images"=>"images"));
$demodMenu->printMenu();

}
yusif
 
Posts: 28
Joined: Wed Dec 31, 1969 5:00 pm

Postby yusif » Mon Dec 04, 2006 11:28 am

Hi Steve,
Everything is working fine now. It was truely the include path problem and also I needed to add a to the head_slot.html file to make the client side display work.

Thanks once again.
yusif
 
Posts: 28
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Mon Dec 04, 2006 1:17 pm

Good to hear everything is working!
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 15 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved