From 6d234e929d29fc3c9c6c8fb5d3e87712fcd84efa Mon Sep 17 00:00:00 2001 From: JT Smith Date: Fri, 25 Apr 2003 03:38:30 +0000 Subject: [PATCH] Added the RootTab, RandomSnippet, RandomImage, CanEditText, If, Spacer, SpecificDropMenu, TopDropMenu, LastModified, PreviousDropMenu, and SI (scaled image) macros. --- docs/credits.txt | 1 + docs/upgrades/upgrade_5.2.5-5.3.0.pl | 35 +++++++ docs/upgrades/upgrade_5.2.5-5.3.0.sql | 12 ++- lib/WebGUI/Macro/CanEditText.pm | 31 +++++++ lib/WebGUI/Macro/If.pm | 35 +++++++ lib/WebGUI/Macro/LastModified.pm | 37 ++++++++ lib/WebGUI/Macro/PreviousDropMenu.pm | 64 +++++++++++++ lib/WebGUI/Macro/RandomImage.pm | 11 ++- lib/WebGUI/Macro/RandomSnippet.pm | 11 ++- lib/WebGUI/Macro/RootTab.pm | 59 ++++++++++++ lib/WebGUI/Macro/SI_scaledImage.pm | 124 +++++++++++++++++++++++++ lib/WebGUI/Macro/Spacer.pm | 29 ++++++ lib/WebGUI/Macro/SpecificDropMenu.pm | 69 ++++++++++++++ lib/WebGUI/Macro/TopDropMenu.pm | 40 ++++++++ www/extras/htmlArea/popups/macros.html | 12 +++ 15 files changed, 564 insertions(+), 6 deletions(-) create mode 100644 docs/upgrades/upgrade_5.2.5-5.3.0.pl create mode 100644 lib/WebGUI/Macro/CanEditText.pm create mode 100644 lib/WebGUI/Macro/If.pm create mode 100644 lib/WebGUI/Macro/LastModified.pm create mode 100644 lib/WebGUI/Macro/PreviousDropMenu.pm create mode 100644 lib/WebGUI/Macro/RootTab.pm create mode 100644 lib/WebGUI/Macro/SI_scaledImage.pm create mode 100644 lib/WebGUI/Macro/Spacer.pm create mode 100644 lib/WebGUI/Macro/SpecificDropMenu.pm create mode 100644 lib/WebGUI/Macro/TopDropMenu.pm diff --git a/docs/credits.txt b/docs/credits.txt index 68e392758..a9ccf88e3 100644 --- a/docs/credits.txt +++ b/docs/credits.txt @@ -30,6 +30,7 @@ Contributing Developers..............Peter Beardsley / Appropriate Solutions Ben Simpson Jeff Szpak / Plain Black Sean Tu / WDI + Madsen Wikholm Contributing Translators.............AGOFER Ltda. Natalia Almazova diff --git a/docs/upgrades/upgrade_5.2.5-5.3.0.pl b/docs/upgrades/upgrade_5.2.5-5.3.0.pl new file mode 100644 index 000000000..d7ea7eac0 --- /dev/null +++ b/docs/upgrades/upgrade_5.2.5-5.3.0.pl @@ -0,0 +1,35 @@ +#!/usr/bin/perl + +use lib "../../lib"; +use Getopt::Long; +use Parse::PlainConfig; +use strict; +use WebGUI::Utility; + + +my $configFile; +my $quiet; + +GetOptions( + 'configFile=s'=>\$configFile, + 'quiet'=>\$quiet +); + +print "\tUpdating config file.\n" unless ($quiet); + +my $pathToConfig = '../../etc/'.$configFile; +my $conf = Parse::PlainConfig->new('DELIM' => '=', 'FILE' => $pathToConfig); +my $macros = $conf->get("macros"); +$macros->{RootTab} = "RootTab"; +$macros->{RandomSnippet} = "RandomSnippet"; +$macros->{RandomImage} = "RandomImage"; +$macros->{CanEditText} = "CanEditText"; +$macros->{If} = "If"; +$macros->{Spacer} = "Spacer"; +$macros->{SpecificDropMenu} = "SpecificDropMenu"; +$macros->{LastModified} = "LastModified"; +$macros->{PreviousDropMenu} = "PreviousDropMenu"; +$macros->{TopDropMenu} = "TopDropMenu"; +$macros->{SI} = "SI_scaledImage"; +$conf->set("macros"=>$macros); +$conf->write; diff --git a/docs/upgrades/upgrade_5.2.5-5.3.0.sql b/docs/upgrades/upgrade_5.2.5-5.3.0.sql index 473c8c3fe..39e3dbcdb 100644 --- a/docs/upgrades/upgrade_5.2.5-5.3.0.sql +++ b/docs/upgrades/upgrade_5.2.5-5.3.0.sql @@ -1,6 +1,4 @@ insert into webguiVersion values ('5.3.0','upgrade',unix_timestamp()); -delete from international where languageId=1 and namespace='WebGUI' and internationalId=844; -insert into international (internationalId,languageId,namespace,message,lastUpdated) values (844,1,'WebGUI','These macros have to do with users and logins.\r\n

\r\n\r\n^a; or ^a(); - My Account Link
\r\nA link to your account information. In addition you can change the link text by creating a macro like this ^a("Account Info");. \r\n

\r\n\r\nNOTES: You can also use the special case ^a(linkonly); to return only the URL to the account page and nothing more. Also, the .myAccountLink style sheet class is tied to this macro.\r\n

\r\n\r\n\r\n^AdminText();
\r\nDisplays a small text message to a user who is in admin mode. Example: ^AdminText("You are in admin mode!");\r\n

\r\n\r\n^AdminToggle; or ^AdminToggle();
\r\nPlaces a link on the page which is only visible to content managers and adminstrators. The link toggles on/off admin mode. You can optionally specify other messages to display like this: ^AdminToggle("Edit On","Edit Off");\r\n

\r\n\r\n\r\n\r\n^GroupText();
\r\nDisplays a small text message to the user if they belong to the specified group. Example: ^GroupText("Visitors","You need an account to do anything cool on this site!");\r\n

\r\n\r\n^L; or ^L(); - Login Box
\r\nA small login form. You can also configure this macro. You can set the width of the login box like this ^L(20);. You can also set the message displayed after the user is logged in like this ^L(20,Hi ^a(^@;);. Click %here% if you wanna log out!)\r\n

\r\n\r\nNOTE: The .loginBox style sheet class is tied to this macro.\r\n

\r\n\r\n^LoginToggle; or ^LoginToggle();
\r\nDisplays a "Login" or "Logout" message depending upon whether the user is logged in or not. You can optionally specify other labels like this: ^LoginToggle("Click here to log in.","Click here to log out.");. You can also use the special case ^LoginToggle(linkonly); to return only the URL with no label.\r\n

\r\n\r\n^@; - Username
\r\nThe username of the currently logged in user.\r\n

\r\n\r\n\r\n^#; - User ID
\r\nThe user id of the currently logged in user.\r\n

\r\n\r\n', 1050100597); delete from template where namespace='Article' and templateId<10; INSERT INTO template VALUES (4,'Linked Image with Caption','\r\n

\r\n\r\n\r\n\r\n\r\n
\r\n
\r\n \r\n \">\r\n \" border=\"0\">\r\n
\r\n \r\n \" border=\"0\">\r\n
\r\n
\r\n
\r\n\r\n\r\n\r\n\r\n

\r\n\r\n\r\n\r\n

\r\n\r\n\r\n\r\n\r\n

\r\n
\r\n
\r\n\r\n\r\n \r\n·\r\n\r\n·\r\n\r\n\r\n\r\n\r\n\r\n\r\n

\r\n \r\n \r\n
\"> ()\">
\r\n\r\n\r\n\r\n','Article'); INSERT INTO template VALUES (1,'Default Article','\r\n

\r\n
\r\n\r\n\r\n\r\n
\r\n \" align=\"right\" border=\"0\">\r\n\r\n\r\n\r\n\r\n

\r\n\r\n\r\n\r\n\r\n\r\n \r\n

\">\r\n \r\n\r\n\r\n

\r\n\r\n\r\n\r\n\r\n \r\n·\r\n\r\n·\r\n\r\n\r\n\r\n\r\n\r\n

\r\n
\r\n
\r\n\r\n\r\n\r\n

\r\n \r\n \r\n
\"> ()\">
\r\n\r\n\r\n','Article'); @@ -380,6 +378,16 @@ delete from international where languageId=1 and namespace='WebGUI' and internat insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (900,1,'WebGUI','Manage themes.', 1050189066,NULL); delete from international where languageId=1 and namespace='WebGUI' and internationalId=899; insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (899,1,'WebGUI','Manage Themes', 1050189012,NULL); +delete from international where languageId=1 and namespace='WebGUI' and internationalId=840; +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (840,1,'WebGUI','These macros are designed to provide programming-like functionality. They are powerful when used appropriately, and dangerous when used carelessly. Take care when using these macros.\r\n\r\n

\r\nNOTE: These macros are included in WebGUI in order to provide very powerful display mechanisms. Though they could be used to write simple web applications, this is not their intended use, nor is it supported or condoned by Plain Black. If you find yourself trying to do something like that, just write a macro. =)\r\n\r\n

\r\n\r\n^D; or ^D(); - Date
\r\nThe current date and time.\r\n

\r\n\r\nYou can configure the date by using date formatting symbols. For instance, if you created a macro like this ^D("%c %D, %y"); it would output September 26, 2001. The following are the available date formatting symbols:\r\n

\r\n\r\n
%%%
%y4 digit year
%Y2 digit year
%m2 digit month
%Mvariable digit month
%cmonth name
%d2 digit day of month
%Dvariable digit day of month
%wday of week name
%h2 digit base 12 hour
%Hvariable digit base 12 hour
%j2 digit base 24 hour
%Jvariable digit base 24 hour
%plower case am/pm
%Pupper case AM/PM
%zuser preference date format
%Zuser preference time format
\r\n

\r\n\r\n^Env()
\r\nCan be used to display a web server environment variable on a page. The environment variables available on each server are different, but you can find out which ones your web server has by going to: http://www.yourwebguisite.com/env.pl\r\n

\r\n\r\nThe macro should be specified like this ^Env("REMOTE_ADDR");\r\n

\r\n\r\n^Execute();
\r\nAllows a content manager or administrator to execute an external program. Takes the format of ^Execute("/this/file.sh");.\r\n

\r\n\r\n\r\n^FormParam();
\r\nThis macro is mainly used in generating dynamic queries in SQL Reports. Using this macro you can pull the value of any form field simply by specifing the name of the form field, like this: ^FormParam("phoneNumber");\r\n

\r\n\r\n\r\n^If();
\r\nA simple conditional statement (IF/THEN/ELSE) to control layout and messages.\r\n

\r\nExamples:
\r\nDisplay Happy New Year on 1st January:\r\n ^If(\'^D("%m%d");\' eq \'0101\' , Happy New Year);\r\n

\r\nDisplay a message to people on your subnet (192.168.1.*):
\r\n^If(\'^Env("REMOTE_ADDR");\' =~ /^192.168.1/,"Hi co-worker","Hi Stranger");\r\n

\r\nDisplay a message to Windows users:
\r\n ^If(\'^Env("HTTP_USER_AGENT");\' =~ /windows/i,"Hey... Linux is free !");\r\n

\r\nDisplay a message if a user is behind a proxy:
\r\n ^If(\'^Env("HTTP_VIA");\' ne "", You\'re behind a proxy !, Proxy-free is the best...);\r\n

\r\nDisplay Good Morning/Afternoon/Evening:
\r\n ^If(^D("%J");<=12,Good Morning,^If(^D("%J");<=18,Good Afternoon,Good evening););\r\n

\r\n\r\n^Include();
\r\nAllows a content manager or administrator to include a file from the local filesystem. \r\n

\r\nExample: ^Include("/this/file.html");\r\n

\r\n\r\n^International();
\r\nPull a translated message from the internationalization system.\r\n

\r\nExample: ^International(45,"Article");\r\n

\r\n\r\n\r\n^Quote();
\r\nUse this to escape a string before using it in a database query.\r\n

\r\n\r\n\r\n^Page();
\r\nThis can be used to retrieve information about the current page. For instance it could be used to get the page URL like this ^Page("urlizedTitle"); or to get the menu title like this ^Page("menuTitle");.\r\n

\r\n\r\n^SQL();
\r\nA one line SQL report. Sometimes you just need to pull something back from the database quickly. This macro is also useful in extending the SQL Report wobject. It uses the numeric macros (^0; ^1; ^2; etc) to position data and can also use the ^rownum; macro just like the SQL Report wobject. Examples:

\r\n ^SQL("select count(*) from users","There are ^0; users on this system.");\r\n

\r\n^SQL("select userId,username from users order by username","<a href=\'^/;?op=viewProfile&uid=^0;\'>^1;</a><br>");\r\n

\r\n^URLEncode();
\r\nThis macro is mainly useful in SQL reports, but it could be useful elsewhere as well. It takes the input of a string and URL Encodes it so that the string can be passed through a URL. It\'s syntax looks like this: ^URLEncode("Is this my string?");\r\n

\r\n\r\n\r\n^User();
\r\nThis macro will allow you to display any information from a user\'s account or profile. For instance, if you wanted to display a user\'s email address you\'d create this macro: ^User("email");\r\n

\r\n\r\n^*; or ^*(); - Random Number
\r\nA randomly generated number. This is often used on images (such as banner ads) that you want to ensure do not cache. In addition, you may configure this macro like this ^*(100); to create a random number between 0 and 100.\r\n

\r\n\r\n^-;,^0;,^1;,^2;,^3;, etc.
\r\nThese macros are reserved for system/wobject-specific functions as in the SQL Report wobject and the Body in the Style Manager.\r\n

\r\n', 1051223757,NULL); +delete from international where languageId=1 and namespace='WebGUI' and internationalId=846; +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (846,1,'WebGUI','These macros are mainly useful in maintaining styles in WebGUI.\r\n

\r\n\r\n^AdminBar;
\r\nPlaces the administrative tool bar on the page. This is a required element in the "body" segment of the Style Manager.\r\n

\r\n\r\n\r\n^c; - Company Name
\r\nThe name of your company specified in the settings by your Administrator.\r\n

\r\n\r\n\r\n^e; - Company Email Address
\r\nThe email address for your company specified in the settings by your Administrator.\r\n

\r\n\r\n^Extras;
\r\nReturns the path to the WebGUI "extras" folder, which contains things like WebGUI icons.\r\n

\r\n\r\n^LastModified; or ^LastModified();
\r\nDisplays the date that the current page was last modified based upon the wobjects on the page. The date is defaultly displayed based upon the user\'s date preferences. Optionally, it can take two parameters. The first is text to display before the date. The second is a date format string (see the D (date) macro for details.\r\n

\r\nExample: ^LastModified("Updated: ","%c %D, %y");\r\n

\r\n\r\n\r\n^PageTitle;
\r\nDisplays the title of the current page.\r\n

\r\n\r\nNOTE: If you begin using admin functions or the indepth functions of any wobject, the page title will become a link that will quickly bring you back to the page.\r\n

\r\n\r\n^r; or ^r(); - Make Page Printable
\r\nCreates a link to remove the style from a page to make it printable. In addition, you can change the link text by creating a macro like this ^r("Print Me!");.\r\n

\r\n\r\nBy default, when this link is clicked, the current page\'s style is replaced with the "Make Page Printable" style in the Style Manager. However, that can be overridden by specifying the name of another style as the second parameter, like this: ^r("Print!","WebGUI");\r\n

\r\n\r\nNOTES: You can also use the special case ^r(linkonly); to return only the URL to the make printable page and nothing more. Also, the .makePrintableLink style sheet class is tied to this macro.\r\n

\r\n\r\n^RootTitle;
\r\nReturns the title of the root of the current page. For instance, the main root in WebGUI is the "Home" page. Many advanced sites have many roots and thus need a way to display to the user which root they are in.\r\n

\r\n\r\n^u; - Company URL
\r\nThe URL for your company specified in the settings by your Administrator.\r\n

\r\n\r\n\r\n\r\n^?; - Search
\r\nAdd a search box to the page. The search box is tied to WebGUI\'s built-in search engine.\r\n

\r\n\r\nNOTE: The .searchBox style sheet class is tied to this macro.\r\n

\r\n\r\n^Spacer();
\r\nCreate a spacer in your layout. Great for creating blocks of color with divs and tables. It takes two parameters, width and height.\r\n

\r\nExample: ^Spacer("100","50");\r\n

\r\n\r\n^-;
\r\nThis is known as the separator macro. It must appear exactly once in every style. Wherever it appears is where the content for any given page will be put.\r\n

', 1051223157,NULL); +delete from international where languageId=1 and namespace='WebGUI' and internationalId=842; +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (842,1,'WebGUI','These macros are used to create navigation on the site.\r\n

\r\n\r\n^C; or ^C(); - Crumb Trail
\r\nA dynamically generated crumb trail to the current page. You can optionally specify a delimeter to be used between page names by using ^C(::);. The default delimeter is >.\r\n

\r\n\r\nNOTE: The .crumbTrail style sheet class is tied to this macro.\r\n

\r\n\r\n^FlexMenu;
\r\nThis menu macro creates a top-level menu that expands as the user selects each menu item.\r\n

\r\n\r\n^H; or ^H(); - Home Link
\r\nA link to the home page of this site. In addition you can change the link text by creating a macro like this ^H("Go Home");.\r\n

\r\n\r\nNOTES: You can also use the special case ^H(linkonly); to return only the URL to the home page and nothing more. Also, the .homeLink style sheet class is tied to this macro.\r\n

\r\n\r\n^M; or ^M(); - Current Menu (Vertical)
\r\nA vertical menu containing the sub-pages at the current level. In addition, you may configure this macro by specifying how many levels deep the menu should go. By default it will show only the first level. To go three levels deep create a macro like this ^M(3);. If you set the macro to "0" it will track the entire site tree.\r\n

\r\n\r\n^m; - Current Menu (Horizontal)
\r\nA horizontal menu containing the sub-pages at the current level. You can optionally specify a delimeter to be used between page names by using ^m(:--:);. The default delimeter is ·.\r\n

\r\n\r\n^PreviousDropMenu;
\r\nCreate a drop down menu containing the sub-pages at the previous level in the page tree.\r\n

\r\nExample: ^PreviousDropMenu;\r\n

\r\n\r\n^P; or ^P(); - Previous Menu (Vertical)
\r\nA vertical menu containing the sub-pages at the previous level. In addition, you may configure this macro by specifying how many levels deep the menu should go. By default it will show only the first level. To go three levels deep create a macro like this ^P(3);. If you set the macro to "0" it will track the entire site tree.\r\n

\r\n\r\n^p; - Previous Menu (Horizontal)
\r\nA horizontal menu containing the sub-pages at the previous level. You can optionally specify a delimeter to be used between page names by using ^p(:--:);. The default delimeter is ·.\r\n

\r\n\r\n^rootmenu; or ^rootmenu(); (Horizontal)
\r\nCreates a horizontal menu of the various roots on your system (except for the WebGUI system roots). You can optionally specify a menu delimiter like this: ^rootmenu(|);\r\n

\r\n\r\n^RootTab;
\r\nCreate a tab navigation system from the roots on your site (except WebGUI\'s system roots) similar to the tabs used in the tab forms (editing wobjects or pages).\r\n

\r\nNOTE: Has two special style sheet classes: .RootTabOn{} and .RootTabOff{}.\r\n

\r\nExample:
\r\n<style>\r\n.rootTabOn {\r\n line-height: 17px;\r\n font-size: 16px;\r\n spacing: 3px;\r\n border: 1px solid black;\r\n border-bottom-width: 0px;\r\n background-color: #333333;\r\n z-index: 10000;\r\n padding: 3px 9px 5px 9px;\r\n color: white;\r\n}\r\n\r\n.rootTabOn A, .rootTabOn A:visited {\r\n color: white;\r\n font-weight: bold;\r\n text-decoration: none;\r\n}\r\n\r\n.rootTabOff {\r\n line-height: 15px;\r\n font-size: 14px;\r\n border: 1px solid black;\r\n border-bottom-width: 0px;\r\n background-color: #c8c8c8;\r\n z-index: 1000;\r\n padding: 2px 9px 2px 9px;\r\n}\r\n\r\n.rootTabOff A, .rootTabOff A:visited {\r\n color: black;\r\n text-decoration: underline;\r\n}\r\n\r\n.rootTabOff A:hover {\r\n font-weight: bold;\r\n}\r\n</style>\r\n^RootTab;\r\n

\r\n\r\n\r\n^SpecificDropMenu();
\r\nCreate a drop down menu starting at a specific point in your navigation tree. This takes two parameters. The first is the url of the page to start with and the second (optional parameter) is the depth to traverse to.\r\n

\r\nExample: ^SpecificDropMenu("home",3);\r\n

\r\n\r\n^S(); - Specific SubMenu (Vertical)
\r\nThis macro allows you to get the submenu of any page, starting with the page you specified. For instance, you could get the home page submenu by creating a macro that looks like this ^S("home",0);. The first value is the urlized title of the page and the second value is the depth you\'d like the menu to go. By default it will show only the first level. To go three levels deep create a macro like this ^S("home",3);.\r\n

\r\n\r\n\r\n^s(); - Specific SubMenu (Horizontal)
\r\nThis macro allows you to get the submenu of any page, starting with the page you specified. For instance, you could get the home page submenu by creating a macro that looks like this ^s("home");. The value is the urlized title of the page. You can optionally specify a delimeter to be used between page names by using ^s("home",":--:");. The default delimeter is ·.\r\n

\r\n\r\n^Synopsis; or ^Synopsis(); Menu
\r\nThis macro allows you to get the submenu of a page along with the synopsis of each link. You may specify an integer to specify how many levels deep to traverse the page tree.\r\n

\r\n\r\nNOTES: The .synopsis_sub, .synopsis_summary, and .synopsis_title style sheet classes are tied to this macro.\r\n

\r\n\r\n^TopDropMenu;
\r\nCreate a drop down menu of your top level navigation.\r\n

\r\nExample: ^TopDropMenu;\r\n

\r\n\r\n^T; or ^T(); - Top Level Menu (Vertical)
\r\nA vertical menu containing the main pages of the site (aka the sub-pages from the home page). In addition, you may configure this macro by specifying how many levels deep the menu should go. By default it will show only the first level. To go three levels deep create a macro like this ^T(3);. If you set the macro to "0" it will track the entire site tree.\r\n

\r\n\r\n^t; - Top Level Menu (Horizontal)
\r\nA vertical menu containing the main pages of the site (aka the sub-pages from the home page). You can optionally specify a delimeter to be used between page names by using ^t(:--:);. The default delimeter is ·.\r\n

\r\n\r\n^/; - System URL
\r\nThe URL to the gateway script (example: /index.pl/).\r\n

\r\n\r\n^\\; - Page URL
\r\nThe URL to the current page (example: /index.pl/pagename).\r\n

\r\n\r\n', 1051222723,NULL); +delete from international where languageId=1 and namespace='WebGUI' and internationalId=844; +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (844,1,'WebGUI','These macros have to do with users and logins.\r\n

\r\n\r\n^a; or ^a(); - My Account Link
\r\nA link to your account information. In addition you can change the link text by creating a macro like this ^a("Account Info");. \r\n

\r\n\r\nNOTES: You can also use the special case ^a(linkonly); to return only the URL to the account page and nothing more. Also, the .myAccountLink style sheet class is tied to this macro.\r\n

\r\n\r\n\r\n^AdminText();
\r\nDisplays a small text message to a user who is in admin mode. Example: ^AdminText("You are in admin mode!");\r\n

\r\n\r\n^AdminToggle; or ^AdminToggle();
\r\nPlaces a link on the page which is only visible to content managers and adminstrators. The link toggles on/off admin mode. You can optionally specify other messages to display like this: ^AdminToggle("Edit On","Edit Off");\r\n

\r\n\r\n^CanEditText();
\r\nDisplay a message to a user that can edit the current page.\r\n

\r\nExample: ^CanEditText(^AdminToggle;);\r\n

\r\n\r\n\r\n^GroupText();
\r\nDisplays a small text message to the user if they belong to the specified group. And you can specify an alternate message to those who are not in the group.\r\n

\r\nExample: ^GroupText("Visitors","You need an account to do anything cool on this site!","We value our registered users!");\r\n

\r\n\r\n^L; or ^L(); - Login Box
\r\nA small login form. You can also configure this macro. You can set the width of the login box like this ^L(20);. You can also set the message displayed after the user is logged in like this ^L(20,Hi ^a(^@;);. Click %here% if you wanna log out!)\r\n

\r\n\r\nNOTE: The .loginBox style sheet class is tied to this macro.\r\n

\r\n\r\n^LoginToggle; or ^LoginToggle();
\r\nDisplays a "Login" or "Logout" message depending upon whether the user is logged in or not. You can optionally specify other labels like this: ^LoginToggle("Click here to log in.","Click here to log out.");. You can also use the special case ^LoginToggle(linkonly); to return only the URL with no label.\r\n

\r\n\r\n^@; - Username
\r\nThe username of the currently logged in user.\r\n

\r\n\r\n\r\n^#; - User ID
\r\nThe user id of the currently logged in user.\r\n

\r\n\r\n', 1051222028,NULL); +delete from international where languageId=1 and namespace='WebGUI' and internationalId=832; +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (832,1,'WebGUI','The collateral management system has several macros for its specific purpose.\r\n

\r\n\r\n^File();
\r\nThis macro builds a quick file link. It creates an icon for the file and outputs the files name. Then it links them both to the file for downloading.\r\n

\r\n\r\n^I();
\r\nThis macro retrieves an image from the collateral management system along with an HTML image tag so that you can quickly display an image from the repository in your content.\r\n

\r\nExample: ^I("logo");\r\n

\r\n\r\n^i();
\r\nThis macro retrieves the URL for any file in the collateral management system.\r\n

\r\nExample: ^i("status report");\r\n

\r\n\r\n\r\n^RandomImage();
\r\nThis macro takes a collateral folder as a parameter. If the folder name is omitted, then the root folder will be used. The macro then randomly chooses an image in the folder and returns it in much the same way the ^I(); macro works.\r\n

\r\nExample: ^RandomImage("site headers");\r\n

\r\n\r\n^RandomSnippet();
\r\nThis macro takes a collateral folder as a parameter. If the folder name is omitted, then the root folder will be used. The macro then randomly chooses a snippet from the folder and returns it in much the same way the ^Snippet(); macro works.\r\n

\r\nExample: ^RandomSnippet("quips");\r\n

\r\n\r\n\r\n^SI();
\r\nThe Scaled Image macro allows images to be found in the collateral and scaled (on the server-side), either maintaining the original aspect ratio or an entirely new ratio of your design. \r\n

\r\nIt takes four parameters. The first is the image name or optionally the collateral id. The second is the width. Set the width to "0" to maintain aspect ratio by height. The third is height. Set the height to "0" to maintain aspect ratio by width. The fourth parameter allows you to specify additional parameters to the image.\r\n

\r\nExamples:
\r\nRetrieving an image by name (no scaling)
\r\n^SI(myimage);\r\n

\r\nRetrieving an image by collateralId (no scaling)
\r\n^SI(66);\r\n

\r\nScaling by width, maintaining aspect ratio
\r\n^SI(66,25);\r\n

\r\nScaling by height, maintaining aspect ratio
\r\n^SI(66,0,25);\r\n

\r\nPlaying with the aspect ratio
\r\n^SI(66,148,25);\r\n

\r\nUsing parameters
\r\n^SI(66,0,0,\'border="0"\');\r\n

\r\n\r\n\r\n^Snippet();
\r\nThis macro retrieves the contents of a snippet in the collateral management system and inserts it into the page.\r\n

\r\nExample: ^Snippet("flash code");\r\n

\r\n\r\n^Thumbnail();
\r\nThis macro retrieves the URL for the thumbnail of any image in the collateral management system.\r\n

\r\nExample: ^Thumbnail("logo");\r\n

\r\n\r\n^ThumbnailLinker();
\r\nThis macro builds a quick image viewer using nothing more than the collateral management system. It creates a thumbnail image with the name of the image under it and then links them both to the full sized image. You can also specify a "1" as a second parameter to have the linker create a new window to display the linked image.\r\n

\r\nExample: ^ThumbnailLinker("logo");\r\n

\r\n\r\n', 1051221379,NULL); diff --git a/lib/WebGUI/Macro/CanEditText.pm b/lib/WebGUI/Macro/CanEditText.pm new file mode 100644 index 000000000..2b44d930c --- /dev/null +++ b/lib/WebGUI/Macro/CanEditText.pm @@ -0,0 +1,31 @@ +package WebGUI::Macro::CanEditText; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2003 Plain Black LLC. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use strict; +use WebGUI::Macro; +use WebGUI::Session; +use WebGUI::Privilege; + +#------------------------------------------------------------------- +sub process { + my @param = WebGUI::Macro::getParams($_[0]); + if (WebGUI::Privilege::canEditPage()) { + return $param[0]; + } else { + return ""; + } +} + + +1; + + diff --git a/lib/WebGUI/Macro/If.pm b/lib/WebGUI/Macro/If.pm new file mode 100644 index 000000000..1da69e108 --- /dev/null +++ b/lib/WebGUI/Macro/If.pm @@ -0,0 +1,35 @@ +package WebGUI::Macro::If; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2003 Plain Black Software. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + + +use strict; +use Safe; +use WebGUI::Macro; + +sub process { + my ($expression, $true, $false) = WebGUI::Macro::getParams(shift); + my $output = $false; + + # Workaround to "Safely" eval $expression + my $compartment = new Safe; + my $return = $compartment->reval($expression); + + return "

If Macro failed: $@

Expression: $expression +
Display if true: $true
Display if false: $false" if ($@); + + $output = $true if ($return); + + return $output; +} + +1; + diff --git a/lib/WebGUI/Macro/LastModified.pm b/lib/WebGUI/Macro/LastModified.pm new file mode 100644 index 000000000..7472edc6c --- /dev/null +++ b/lib/WebGUI/Macro/LastModified.pm @@ -0,0 +1,37 @@ +package WebGUI::Macro::LastModified; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2003 Plain Black LLC. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use strict; +use WebGUI::DateTime; +use WebGUI::Macro; +use WebGUI::Session; +use WebGUI::SQL; + +#------------------------------------------------------------------- +sub process { + my ($label, $format, $time, $output); + + ($label, $format) = WebGUI::Macro::getParams(shift); + $format = '%z' if ($format eq ""); + $output = ""; + + ($time) = WebGUI::SQL->quickArray("SELECT max(lastEdited) FROM wobject where pageId=$session{page}{pageId}"); + if ($time) { + $output = $label.epochToHuman($time,$format); + } + + return $output; +} + +1; + + diff --git a/lib/WebGUI/Macro/PreviousDropMenu.pm b/lib/WebGUI/Macro/PreviousDropMenu.pm new file mode 100644 index 000000000..1503a4747 --- /dev/null +++ b/lib/WebGUI/Macro/PreviousDropMenu.pm @@ -0,0 +1,64 @@ +package WebGUI::Macro::PreviousDropMenu; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2003 Plain Black LLC. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use strict; +use WebGUI::Macro; +use WebGUI::Navigation; +use WebGUI::Session; +use WebGUI::SQL; + +#------------------------------------------------------------------- +sub _draw { + my ($output, $i, $padding, $pageId); + my ($tree, $indent, $maxDepth, $currentDepth) = @_; + unless ($currentDepth >= $maxDepth) { + for ($i=1;$i<=$indent;$i++) { + $padding .= "  "; + } + foreach $pageId (keys %{$tree}) { + $output .= ''; + $output .= _draw($tree->{$pageId}{sub}, ($indent+1), $maxDepth, ($currentDepth+1)); + } + } + return $output; +} + +#------------------------------------------------------------------- +sub process { + my ($temp, @param, $tree); + @param = WebGUI::Macro::getParams($_[0]); + $param[2] = 99 unless ($param[2]); + if ($param[0] ne "") { + $tree = WebGUI::Navigation::tree($session{page}{parentId},$param[0]); + } else { + $tree = WebGUI::Navigation::tree($session{page}{parentId},1); + } + $temp = ''; + $temp .= '

'; + return $temp; +} + + +1; + + diff --git a/lib/WebGUI/Macro/RandomImage.pm b/lib/WebGUI/Macro/RandomImage.pm index bf5692ccb..997287f84 100644 --- a/lib/WebGUI/Macro/RandomImage.pm +++ b/lib/WebGUI/Macro/RandomImage.pm @@ -20,8 +20,15 @@ use WebGUI::SQL; #------------------------------------------------------------------- sub process { my @param = WebGUI::Macro::getParams($_[0]); - my ($collateralFolderId) = WebGUI::SQL->quickArray("select collateralFolderId from collateralFolder where name=".quote($param[0])); - my @images = WebGUI::SQL->buildArray("select collateralId from collateral where collateralType='image' and collateralFolderId=".$collateralFolderId); + my $collateralFolderId; + if ($param[0] ne "") { + ($collateralFolderId) = WebGUI::SQL->quickArray("select collateralFolderId from collateralFolder + where name=".quote($param[0])); + } else { + $collateralFolderId = 0; #Root + } + my @images = WebGUI::SQL->buildArray("select collateralId from collateral + where collateralType='image' and collateralFolderId=".$collateralFolderId); my $collateral = WebGUI::Collateral->new($images[rand($#images+1)]); return 'get("parameters").' />'; } diff --git a/lib/WebGUI/Macro/RandomSnippet.pm b/lib/WebGUI/Macro/RandomSnippet.pm index c173d995d..65346e70c 100644 --- a/lib/WebGUI/Macro/RandomSnippet.pm +++ b/lib/WebGUI/Macro/RandomSnippet.pm @@ -20,8 +20,15 @@ use WebGUI::SQL; #------------------------------------------------------------------- sub process { my @param = WebGUI::Macro::getParams($_[0]); - my ($collateralFolderId) = WebGUI::SQL->quickArray("select collateralFolderId from collateralFolder where name=".quote($param[0])); - my @snippets = WebGUI::SQL->buildArray("select collateralId from collateral where collateralType='snippet' and collateralFolderId=".$collateralFolderId); + my $collateralFolderId; + if ($param[0] ne "") { + ($collateralFolderId) = WebGUI::SQL->quickArray("select collateralFolderId from collateralFolder + where name=".quote($param[0])); + } else { + $collateralFolderId = 0; #Root + } + my @snippets = WebGUI::SQL->buildArray("select collateralId from collateral + where collateralType='snippet' and collateralFolderId=".$collateralFolderId); my $collateral = WebGUI::Collateral->new($snippets[rand($#snippets+1)]); return $collateral->get("parameters"); } diff --git a/lib/WebGUI/Macro/RootTab.pm b/lib/WebGUI/Macro/RootTab.pm new file mode 100644 index 000000000..228b509bc --- /dev/null +++ b/lib/WebGUI/Macro/RootTab.pm @@ -0,0 +1,59 @@ +package WebGUI::Macro::RootTab; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2002 Plain Black LLC. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use strict; +use WebGUI::Navigation; +use WebGUI::Session; +use WebGUI::SQL; + +#------------------------------------------------------------------- +sub _draw { + my ($tree, $root) = @_; + #my $output;# = ''; + my $output;# = '
'; + foreach my $key (keys %{$tree}) { + $output .= ' {$key}{url}.'">'.$tree->{$key}{title}.''; + $output .= ' '; + } + #$output .= '
'; + #$output .= '
'; + return $output; +} + +#------------------------------------------------------------------- +sub _findRoot { + my ($pageId,$parentId) = WebGUI::SQL->quickArray("select pageId,parentId from page where pageId=$_[0]"); + if ($parentId == 0) { + return $pageId; + } else { + return _findRoot($parentId); + } +} + + +#------------------------------------------------------------------- +sub process { + my $root = _findRoot($session{page}{pageId}); + my $tree = WebGUI::Navigation::tree(0,1); + return _draw($tree,$root); +} + + +1; + diff --git a/lib/WebGUI/Macro/SI_scaledImage.pm b/lib/WebGUI/Macro/SI_scaledImage.pm new file mode 100644 index 000000000..6a31bafe2 --- /dev/null +++ b/lib/WebGUI/Macro/SI_scaledImage.pm @@ -0,0 +1,124 @@ +package WebGUI::Macro::SI_scaledImage; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2003 Plain Black LLC. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use strict; +use WebGUI::Collateral; +use WebGUI::Macro; +use WebGUI::ErrorHandler; +use WebGUI::Session; + +# test for Image::Magick + +# (Would be nice if the results of this test were availiable somewhere +# central) + +my $hasImageMagick=1; +eval " use Image::Magick; "; $hasImageMagick=0 if $@; + +#------------------------------------------------------------------- +sub _getImage { + my ($collateral) = @_; + return undef unless ($hasImageMagick); + my $image = Image::Magick->new(); + if (my $error = $image->Read($collateral->getPath)) { + WebGUI::ErrorHandler::warn("Couldn't read image for resizing: ".$error); + return undef; + } + return $image; +} + +#------------------------------------------------------------------- +sub process { + my ($collateralIdent,$width,$height,$parameters) = WebGUI::Macro::getParams($_[0]); + my ($collateral,$url); + + if ($collateralIdent =~ /^\d+$/) { + $collateral = WebGUI::Collateral->new($collateralIdent); + } + else { + $collateral = WebGUI::Collateral->find($collateralIdent); + } + + unless ($collateral) { + WebGUI::ErrorHandler::warn("collateral not found: $collateralIdent"); + return ''; + } + + unless ($collateral->isImage()) { + WebGUI::ErrorHandler::warn("Bad image type: $collateralIdent"); + return ''; + } + + if ($width || $height) { + $url = GuideGuide::scaleImage( + collateral => $collateral, + width => $width, + height => $height + ); + } + else { + WebGUI::ErrorHandler::warn("width or heigth must be specified"); + } + + $url ||= $collateral->getURL; + + return qq!!; +} + +#------------------------------------------------------------------- +sub scaleImage { + my (%p) = @_; + + my ($collateral,$width,$height) = @p{qw(collateral width height)}; + + # paranoia + return undef unless ($height || $width); + + my $filename = "SIThumb_".($width || 'r')."x".($height || 'r')."_".$collateral->getFilename(); + $filename .= '.png' if (isIn($collateral->getType(), qw(tif tiff bmp))); + + my $pathName = $collateral->{_node}->getPath().$session{os}{slash}.$filename; + unless (-e $pathName) { + my $image = _getImage($collateral); + return undef unless $image; + my ($newWidth,$newHeight); + + if ($width && $height) { + ($newWidth,$newHeight) = ($width,$height); + } + else { + my ($x, $y) = $image->Get('width','height'); + my $ratio = $x / $y; + $newWidth = $width ? $width : $height * $ratio; + $newHeight = $height ? $height : $width / $ratio; + } + + my $max = $session{setting}{maxImageSize}; + if ($newHeight > $max || $newWidth > $max) { + WebGUI::ErrorHandler::warn( + "Image too large ($newWidth,$newHeight) :".$collateral->get('name') + ); + return undef; + } + + $image->Scale(width => $newWidth, height => $newHeight); + if (my $error = $image->Write($pathName)) { + WebGUI::ErrorHandler::warn("Couldn't resize image: ".$error); + } + } + + return $collateral->{_node}->getURL."/$filename"; +} + +1; + + diff --git a/lib/WebGUI/Macro/Spacer.pm b/lib/WebGUI/Macro/Spacer.pm new file mode 100644 index 000000000..0e7fa48d6 --- /dev/null +++ b/lib/WebGUI/Macro/Spacer.pm @@ -0,0 +1,29 @@ +package WebGUI::Macro::Spacer; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2003 Plain Black LLC. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use strict; +use WebGUI::Session; +use WebGUI::Macro; + +#------------------------------------------------------------------- + +sub process { + my ($output, @param, $width, $height); + @param = WebGUI::Macro::getParams($_[0]); + $width = $param[0] if defined $param[0]; + $height = $param[1] if defined $param[1]; + $output = ''; + return $output; +} + +1; + diff --git a/lib/WebGUI/Macro/SpecificDropMenu.pm b/lib/WebGUI/Macro/SpecificDropMenu.pm new file mode 100644 index 000000000..da5f5cfe8 --- /dev/null +++ b/lib/WebGUI/Macro/SpecificDropMenu.pm @@ -0,0 +1,69 @@ +package WebGUI::Macro::SpecificDropMenu; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2003 Plain Black LLC. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use strict; +use WebGUI::Macro; +use WebGUI::Navigation; +use WebGUI::Session; +use WebGUI::SQL; + +#------------------------------------------------------------------- +sub _draw { + my ($output, $i, $padding, $pageId); + my ($tree, $indent, $maxDepth, $currentDepth) = @_; + unless ($currentDepth >= $maxDepth) { + for ($i=1;$i<=$indent;$i++) { + $padding .= "  "; + } + foreach $pageId (keys %{$tree}) { + $output .= ''; + $output .= _draw($tree->{$pageId}{sub}, ($indent+1), $maxDepth, ($currentDepth+1)); + } + } + return $output; +} + +#------------------------------------------------------------------- +sub process { + my ($temp, @param, $pageId, $tree); + @param = WebGUI::Macro::getParams($_[0]); + ($pageId) = WebGUI::SQL->quickArray("select pageId from page where urlizedTitle='$param[0]'"); + if (defined $pageId) { + $param[2] = 99 unless ($param[2]); + if ($param[1] ne "") { + $tree = WebGUI::Navigation::tree($pageId,$param[1]); + } else { + $tree = WebGUI::Navigation::tree($pageId,1); + } + $temp = ''; + $temp .= '
'; + } else { + $temp = "No page specified."; + } + return $temp; +} + + +1; + + diff --git a/lib/WebGUI/Macro/TopDropMenu.pm b/lib/WebGUI/Macro/TopDropMenu.pm new file mode 100644 index 000000000..44c45b104 --- /dev/null +++ b/lib/WebGUI/Macro/TopDropMenu.pm @@ -0,0 +1,40 @@ +package WebGUI::Macro::TopDropMenu; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2003 Plain Black LLC. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use strict; +use WebGUI::Navigation; +use WebGUI::Session; + +#------------------------------------------------------------------- +sub process { + my ($temp, $tree, $pageId); + $tree = WebGUI::Navigation::tree(1,1); + $temp = ''; + $temp .= '
'; + return $temp; +} + + +1; + + diff --git a/www/extras/htmlArea/popups/macros.html b/www/extras/htmlArea/popups/macros.html index 8792b7477..22b4674b0 100644 --- a/www/extras/htmlArea/popups/macros.html +++ b/www/extras/htmlArea/popups/macros.html @@ -20,10 +20,13 @@ function returnSelected(in_values) { @@ -37,11 +40,15 @@ function returnSelected(in_values) { + + + + @@ -58,6 +65,7 @@ function returnSelected(in_values) { + @@ -79,8 +87,10 @@ function returnSelected(in_values) { + + @@ -88,9 +98,11 @@ function returnSelected(in_values) {