Menus And The Like On PHP Programs
Main working screen

Menus And The Like On PHP Programs

Since it is snowy out today and I have experienced four stokes so don't mind the spelling if it you see an error, I figure it was some time for some meatier subjects to write about before I die. Hence some discussion on a program that I wrote some time ago. Enough of the basic data structures (though I need to write one on trees!) There is a lot going on, so there will be some sides on it.

(Plus I am thinking of Lorena and wondering what is happening with her. Perhaps if Michelle or Nina see this, they will plop me or her a message! Somebody is thinking good thoughts.)

Below is the code to display the above screen:

<?php

// $Header: file:///Users/scottauge/Documents/SVN/theatre/main.php 31 2019-08-09 03:09:48Z scottauge $

/**************************************************************************

MIT License

Copyright (c) 2021 Scott Auge

Permission is hereby granted, free of charge, to any person obtaining a copy

of this software and associated documentation files (the "Software"), to deal

in the Software without restriction, including without limitation the rights

to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

copies of the Software, and to permit persons to whom the Software is

furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all

copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

SOFTWARE.

**************************************************************************/

include_once "nonotice.php";

include_once "incLoginSession.php";

include_once "clsParameter.php";

include_once "clsDB.php";

$DB = new clsDB();

$Parameter = new clsParameter($DB);

$Parameter->FindByName("title");

$User = new clsLogins($DB);

$User->FindByID($Session->SessionValue);

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<html xmlns="https://www.w3.org/1999/xhtml ">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title><?php print($Parameter->Value) ?> - Main</title>

</head>

<!--

$Id: main.php 31 2019-08-09 03:09:48Z scottauge $

/**************************************************************************

MIT License

Copyright (c) 2021 Scott Auge

Permission is hereby granted, free of charge, to any person obtaining a copy

of this software and associated documentation files (the "Software"), to deal

in the Software without restriction, including without limitation the rights

to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

copies of the Software, and to permit persons to whom the Software is

furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all

copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

SOFTWARE.

**************************************************************************/

-->

<?php include "incMenu.php" ?>

<body class="claro">

<?php include_once "incAppTitle.php" ?>

<div id="wrapper"></div>

<!-- <p>Last selected: <span id="lastSelected">none</span></p> -->

<p align="center">&nbsp;</p>

<p align="center">&nbsp;</p>

<p align="center">&nbsp;</p>

<p align="center">&nbsp;</p>

<!-- <p align="center"><?php $Parameter->FindByName("Organization"); print $Parameter->Value?></p> -->

<p align="center">Welcome <?php print $User->UserID ?></p>

<p align="center">&nbsp;</p>

<p align="center">&nbsp;</p>

<p align="center">&nbsp;</p>

<?php include "footer.php" ?>

</body>

</html>

The interesting line is <?php include "incMenu.php" ?> which includes the menu. This is actually using dojo/dijit (https://dojotoolkit.org/ ) and once you get use to using this tool, this kind of interface comes easy! Lets take a look at that:

<!-- Menu system via DOJO/DIJIT -->

<!-- This will be made into an include -->

<!-- $Id: incMenu.php 13 2019-07-09 02:18:15Z scottauge $ -->

<link rel="stylesheet" href="dijit/themes/claro/claro.css">

<script>dojoConfig = {async: true}</script>

<script src='dojo/dojo.js'></script>

<script language="javascript">

require([

"dojo/dom",

"dijit/registry",

"dijit/MenuBar",

"dijit/PopupMenuBarItem",

"dijit/Menu",

"dijit/MenuItem",

"dijit/DropDownMenu",

"dojo/domReady!"

], function(dom, registry, MenuBar, PopupMenuBarItem, Menu, MenuItem, DropDownMenu){

// Here we set up for menu items selected

var onItemSelect = function(event){

switch (this.get("label")) {

case "Logout":

location.assign("index.php");

break;

case "New Activity":

location.assign("newactivity.php");

break;

case "Search Activity":

location.assign("searchactivity.php");

break;

case "My Account":

location.assign("myaccount.php");

break;

case "Search Person":

location.assign("searchpeople.php");

break;

case "New Person":

location.assign("newpeople.php");

break;

case "New Advertiser":

location.assign("newadvertiser.php");

break;

case "Search Advertiser":

location.assign("searchadvertiser.php");

break;

case "New Vendor":

location.assign("newvendor.php");

break;

case "Search Vendor":

location.assign("searchvendor.php");

break;

case "Change Log":

window.open ("changelog.php", "ChangeLog");

break;

case "Tasks":

location.assign("tasks.php");

break;

case "By Activity":

location.assign("rptbyactivity.php");

break;

case "By Membership":

location.assign("rptbymembership.php");

break;

case "Advertiser":

location.assign("rptAdvertiser.php");

break;

// Campaigns

case "Send Emails":

location.assign("rptemail.php");

break;

case "Print Letters":

location.assign("rptletter.php");

break;

case "Print Mail Labels":

location.assign("rptletterlabel.php");

break;

case "Edit Letter/Email":

location.assign("listletters.php");

break;

// Parameters

case "Parameters":

location.assign("ParameterMaintenance.php");

break;

case "Suggestion Box":

location.assign("SuggestionBox.php");

break;

case "Review Suggestions":

location.assign("ReviewSuggestions.php");

break;

} // switch

dom.byId("lastSelected").innerHTML = this.get("label");

};

var pMenuBar = new MenuBar({});

var People = new DropDownMenu({});

People.addChild(new MenuItem({

label: "New Person",

onClick: onItemSelect

}));

People.addChild(new MenuItem({

label: "Search Person",

onClick: onItemSelect

}));

People.addChild(new MenuItem({

label: "New Advertiser",

onClick: onItemSelect

}));

People.addChild(new MenuItem({

label: "Search Advertiser",

onClick: onItemSelect

}));

People.addChild(new MenuItem({

label: "New Vendor",

onClick: onItemSelect

}));

People.addChild(new MenuItem({

label: "Search Vendor",

onClick: onItemSelect

}));

pMenuBar.addChild(new PopupMenuBarItem({

label: "People",

popup: People

}));

var Activity = new DropDownMenu({});

Activity.addChild(new MenuItem({

label: "New Activity",

//iconClass: "dijitEditorIcon dijitEditorIconCut",

onClick: onItemSelect

}));

Activity.addChild(new MenuItem({

label: "Search Activity",

//iconClass: "dijitEditorIcon dijitEditorIconCopy",

onClick: onItemSelect

}));

/*

Activity.addChild(new MenuItem({

label: "Paste",

iconClass: "dijitEditorIcon dijitEditorIconPaste",

onClick: onItemSelect

}));

*/

pMenuBar.addChild(new PopupMenuBarItem({

label: "Activities",

popup: Activity

}));

var Reports = new DropDownMenu({});

Reports.addChild(new MenuItem({

label: "Advertiser",

onClick: onItemSelect

}));

Reports.addChild(new MenuItem({

label: "By Membership",

onClick: onItemSelect

}));

Reports.addChild(new MenuItem({

label: "By Activity",

onClick: onItemSelect

}));

pMenuBar.addChild(new PopupMenuBarItem({

label: "Reports",

popup: Reports

}));

var Tasks = new DropDownMenu({});

Tasks.addChild(new MenuItem({

label: "Tasks",

onClick: onItemSelect

}));

/*

Tasks.addChild(new MenuItem({

label: "Search Tasks",

onClick: onItemSelect

}));

*/

pMenuBar.addChild(new PopupMenuBarItem({

label: "Tasks",

popup: Tasks

}));

var Campaign = new DropDownMenu({});

Campaign.addChild(new MenuItem({

label: "Edit Letter/Email",

onClick: onItemSelect

}));

Campaign.addChild(new MenuItem({

label: "Print Letters",

onClick: onItemSelect

}));

//Campaign.addChild(new MenuItem({

// label: "Print Mail Labels",

// onClick: onItemSelect

//}));

Campaign.addChild(new MenuItem({

label: "Send Emails",

onClick: onItemSelect

}));

pMenuBar.addChild(new PopupMenuBarItem({

label: "Campaign",

popup: Campaign

}));

var Admin = new DropDownMenu({});

/*

Admin.addChild(new MenuItem({

label: "Review Suggestions",

onClick: onItemSelect

}));

*/

Admin.addChild(new MenuItem({

label: "Suggestion Box",

onClick: onItemSelect

}));

Admin.addChild(new MenuItem({

label: "Parameters",

onClick: onItemSelect

}));

Admin.addChild(new MenuItem({

label: "Change Log",

onClick: onItemSelect

}));

pMenuBar.addChild(new PopupMenuBarItem({

label: "Admin",

popup: Admin

}));

var Account = new DropDownMenu({});

Account.addChild(new MenuItem({

label: "Logout",

onClick: onItemSelect

}));

Account.addChild(new MenuItem({

label: "My Account",

onClick: onItemSelect

}));

pMenuBar.addChild(new PopupMenuBarItem({

label: "Account",

popup: Account

}));

pMenuBar.placeAt("wrapper");

pMenuBar.startup();

});

</script>

There are three classes that we are interested in... the Menubar, the DropDownMenu, and the PopupMenuBarItem. One begets the next, begets the next. Once everything is on the Menubar, it gets placed at a div called "wrapper" and you display it via startup().

Note this is kinda tricky if you use CSS and Javascript for non-programming things. If you are past that, this isn't tricky at all.

Where ever you see "label:" is how that item is viewed on the screen. The CSS is mostly for "purdiness."

When you click on the menu item, it gets redirected to onItemSelect which uses its label for the webpage to show up next. Of course that web page should include the menu code to one can go back or to another page from there.

Feel free to connect up with me!

要查看或添加评论,请登录

社区洞察

其他会员也浏览了