⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 design

📁 Event Calendar是一个在线事件日程
💻
📖 第 1 页 / 共 2 页
字号:
the very least they contain opening and closing HTML tags).  Between theheader and footer is a single rowed table (left and right columns) whoseleft column contains a bunch of modular boxes that perform differentactions on the calendar.  The right column contains the output ofwhichever box has been used last.The source is only slightly more complicated.  First, a few variables areset, such as the current session and whether the remote host is within theSimon's Rock domain.  An array of "boxes" (discussed soon) is initializedfor the left side, and if one requires the use of HTTP headers(setcookie), the the box is called to perform its action.  The header isincluded, and the inner table built.  For the first column, the page loopsthrough the array of boxes and has them output their box.  The backgroundcolors of these boxes are controlled by the main page, with thealternation achieved through an incrementing variable.  For the rightcolumn, the currently selected box outputs its results.The main page also tests whether cookies are enabled, since cookies areessential for storing a session key.  The page sets a test cookie andpasses another variable along to the next page in the URL.  When thisvariable from the URL is set, the main page checks to see if the cookie isalso set.  A global cookies_enabled variable is set to 1 or 0 for otherobjects to test.BOXES=====To simplify the main page's code, an abstract "box" class was created.  Asubclass could then be created to handle the specifics of each action,while still allowing the main page to simply call the same functions foreach one.The abstract contains several variables, some set as constants in the codeand others set during initialization.  Among the constants are whether ornot the box requires the use of headers, whether help is available for thebox, and what the name of the help topic should be (if there is one).These are set in the code because they are directly affected by what iscoded in the file.Those variables set during initialization are: a URL to use as the actionin forms that are output, the name of a global variable that holds thecurrent session, and whether a login is required.  The are set duringinitialization because they may be affected by code outside the class.The box class also defines a few generic functions that are used inperforming the various required tasks.  Not all of them need to beoverridden in the inherited classes, especially is they won't be used bythe subclass.The outputPDeniedNotice spits out a generic error saying "You're notallowed to do this."  outputBox will generate the HTML for the module inthe left column of the page, sometimes as simple as a single link.parseBox and outputResults will perform the box's action.  parseBox shouldonly be called if headers are required, since it only parses input andsets necessary cookies, etc.  outputResults is what actually outputs stuffon the right half of the page.  outputHelp can just be a chunk of HTMLwrapped in a function.  This is called to display help for the box'saction if there is any.  verifyPermissions will check to see if thecurrent session is allowed to use the box (or just return 1 if permissionsdon't matter).BOX - CALENDAR==============The calendar box displays the little month view at the top of the leftcolumn.  Users can browse through the calendar by date using this box,viewing a day or week at a time, or a certain day of the week through theentire month.  The calendar box makes extensive use of a global variable"timestamp", which is usually passed in the URL.  (The main page willactually put it in the action URL that it passes to boxes.)When outputting the box, the calendar box looks at the set timestamp, ordefaults to the current time if there isn't one, and generates a calendarfor the given month and outputs it in an HTML table.  The numbers andheaders are links that set the timestamp and select a view for theresults.  Links are also included to cycle through the months, as well asa toggle to view/hide unapproved events.Viewing unapproved events makes use of a cookie so the option persiststhrough HTTP connections, thus parseBox is used to set or delete thecookie before anything is output.  The text-only result view also makesuse of parseBox to output the event text and exit PHP without finishingexecution.Otherwise, assuming the calendar box is active, SQL will be built to findthe appropriate list of events, and the box will run through the list andhave the events output their details.  This is done using an index tablewhich keeps a list of event IDs for the events that occur on each day.  Tocheck for events on that day, a search is done for the timestamp ofmidnight that morning, which is where all the events for that day arelisted in the index.  When the calendar box loads, it fetches the indexfor the entire month.  While outputting the calendar it checks this indexfor the presence of events so it can highlight days which contain eventsin green.  When outputting week and day views, the box also uses thisindex so it may simply search for event IDs instead of building a morecomplicated query.BOX - SEARCH============The search box is pretty self explanatory, but unfortunately the codecouldn't be simplified as much as I'd like.  The search box consists of asingle text field for a basic search, and a link to the advanced searchform.The basic search will search for events with the key string in the titleor description.  The advanced search lists all fields with a text box forvalues, or a list of checkboxes if there are multiple choices.  Searchresults must match at least one value in each field where a value isselected.In both cases, results are displayed as a simple list, ordered by date, ofevents.  The event details can be viewed, using the event class foroutputting values.BOX - LOGIN===========The login box is a little tricky.  First, there's an extra variable,declared globally, stating whether logins require SSL (generally a GoodThing).  If so, and the global variable SSL_PROTOCOL_VERSION is not set,the box will output a notice stating that you must switch to SSL.  Next,it checks a global variable set by the main page to see if cookies areenabled.  If not, the box outputs a notice that cookies must be enabled tolog in. Otherwise, if you are not logged in, the box outputs a form inwhich you can log in.  When you've logged in, the box contains options todisplay session information, logout, or renew the session.  Most of theactual functionality is done through the session class and the verifyPassword function, both discussed above.BOX - SUBMIT============The submit box could not be easier.  The box itself is simply a link tothe submit form.  The form creates an empty event and tells it to outputan edittable form.  Through the use of multiple submit buttons, the eventcan then be submitted (a new event is created from globals and saved) orpreviewed (the event from globals outputs its detail view and then itsedittable view).  Almost everything is handled by the event class,including an e-mail notification to any administrators for the event'slocation.BOX - APPROVE=============The approve box, as is the case with most of the components, works prettysimply.  When asked to output a form with a list of events to approve, itgrabs permissions from the current session and goes through each locationlooking for approve access.  The approve box searches for events that haveno approver ID and are in the allowed locations.  It lists them, alongwith their details, and a couple options (approve, reject, ignore).  Whenthe form is submitted, the appropriate actions are taken. Reject has atext field for the rejecter to include the reason for rejection.  Approvaland rejection are both handled by the event class.With the addition of submitted modifications, the approve box also looksfor events which contain a modify_id and are in locations for which theuser is allowed to *modify* events.  Using the modify bits allows users tobe allowed only to approve events and not get around lack of modificationprivileges by approving their own submitted modification.BOX - MODIFY============The modification box is based heavily on the submit box, using the eventclass to output an edittable form of the event.  The event class alsosaves the changes, using an UPDATE statement instead of INSERT as it wouldfor the submit box.  If the user is not allowed to modify the event, a newevent is submitted with a modify_id to mark it as a submittedmodification.BOX - DELETE============The delete box works similarly to the approve box, in that it first looksat permissions and then searches for events.  The main difference,however, is that there is a cutoff for the number of events listed in theform (since there will probably be many more deleteable events than thoseawaiting approval).  After the cutoff, a link is displayed that will causethe box to search again with a minimum event ID added to the query.Beneath each listed event are the options to delete or ignore the event.If any events are deleted, the submit button will bring up a confirmationform that lists those events to be deleted, each with a confirmationoption.  A function is called from the event class to delete each event.BOX - HELP==========When the help box is called upon to display some help, it goes through themain page's array of boxes and checks to see which have help available.It then lists the topics of those available boxes, along with some helptext beneath.  Which box's help text is displayed is determined by thetopic chosen, but defaults to the help box's help text.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -