PDA

View Full Version : Need help with creating a SMALL component


Heart
07.04.2004, 11:37
Hi,

I made a module which shows me the status of some servers. The code is:

<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

$eBanking = "1"; // auf 1 oder 2 stellen, wenn Störung vorliegt!
$PinTan = "0"; // auf 1 oder 2 stellen, wenn Störung vorliegt!
$InterCept = "0"; // auf 1 oder 2 stellen, wenn Störung vorliegt!
$HBCI = "1"; // auf 1 oder 2 stellen, wenn Störung vorliegt!
$FTAM = "0"; // auf 1 oder 2 stellen, wenn Störung vorliegt!

echo "<table width=\"95%\" border=\"0\" align=\"center\"><tr><td><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr align=\"center\"><td width=\"16\" class=\"newsheading\" align=\"center\"><img src=\"faq/info.png\" border=\"0\"></td><td width=\"100%\" class=\"statusheader\" align=\"center\"><strong>&nbsp;&nbsp;Verfügbarkeit</strong></td></tr></table><table width=\"100%\" cellpadding=\"2\" cellspacing=\"0\" border=\"0\">";
if ($eBanking == 1) {
echo "<tr><td onclick=\"window.open('inhalt/upload/status_eBanking.php', 'eBanking', 'width=500,height=300,scrollbars=no')\"; class=\"statuslinks-rot\" width=\"6%\" align=\"center\" valign=\"top\"><img src=\"status_rot.gif\" width=\"9\" height=\"9\" border=\"0\" align=\"middle\" vspace=\"3\"></td><td onclick=\"window.open('inhalt/upload/status_eBanking.php', 'eBanking', 'width=500,height=300,scrollbars=no')\"; class=\"statusmitte-rot\" width=\"50%\" align=\"left\" valign=\"top\"><a href=\"inhalt/upload/status_eBanking.php\" target=\"_blank\">eBanking</a></td><td onclick=\"window.open('inhalt/upload/status_eBanking.php', 'eBanking', 'width=500,height=300,scrollbars=no')\"; class=\"statusrechts-rot\" width=\"44%\" align=\"left\" valign=\"top\">[<a href=\"status_eBanking.php\" target=\"_blank\"><font color=\"red\"> offline</font></a> ]</td></tr>";
} elseif ($eBanking == 2) {
echo "<tr><td onclick=\"window.open('inhalt/upload/status_eBanking.php', 'eBanking', 'width=500,height=300,scrollbars=no')\"; class=\"statuslinks-gelb\" width=\"6%\" align=\"center\" valign=\"top\"><img src=\"status_gelb.gif\" width=\"9\" height=\"9\" border=\"0\" align=\"middle\" vspace=\"3\"></td><td onclick=\"window.open('inhalt/upload/status_eBanking.php', 'eBanking', 'width=500,height=300,scrollbars=no')\"; class=\"statusmitte-gelb\" width=\"50%\" align=\"left\" valign=\"top\"><a href=\"inhalt/upload/status_eBanking.php\" target=\"_blank\">eBanking</a></td><td onclick=\"window.open('inhalt/upload/status_eBanking.php', 'eBanking', 'width=500,height=300,scrollbars=no')\"; class=\"statusrechts-gelb\" width=\"44%\" align=\"left\" valign=\"top\">[<a href=\"status_eBanking.php\" target=\"_blank\"><font color=\"#bcb72a\"> teilweise</font></a> ]</td></tr>";
} else {
echo "<tr><td class=\"statuslinks\" width=\"6%\" align=\"center\" valign=\"top\"><img src=\"status_gruen.gif\" width=\"9\" height=\"9\" border=\"0\" align=\"middle\" vspace=\"3\"></td><td class=\"statusmitte\" width=\"50%\" align=\"left\" valign=\"top\">eBanking</td><td class=\"statusrechts\" width=\"44%\" align=\"left\" valign=\"top\">[ <font color=\"#008000\">online</font> ]</td></tr>";
}
if ($PinTan == 1) {
echo "<tr><td onclick=\"window.open('inhalt/upload/status_PinTan.php', 'PinTan', 'width=500,height=300,scrollbars=no')\"; class=\"statuslinks-rot\" width=\"6%\" align=\"center\" valign=\"top\"><img src=\"status_rot.gif\" width=\"9\" height=\"9\" border=\"0\" align=\"middle\" vspace=\"3\"></td><td onclick=\"window.open('inhalt/upload/status_PinTan.php', 'PinTan', 'width=500,height=300,scrollbars=no')\"; class=\"statusmitte-rot\" width=\"50%\" align=\"left\" valign=\"top\"><a href=\"inhalt/upload/status_PinTan.php\" target=\"_blank\">PIN/TAN</a></td><td onclick=\"window.open('inhalt/upload/status_PinTan.php', 'PinTan', 'width=500,height=300,scrollbars=no')\"; class=\"statusrechts-rot\" width=\"44%\" align=\"left\" valign=\"top\">[ <a href=\"status_PinTan.php\" target=\"_blank\"><font color=\"red\">offline</font></a> ]</td></tr>";
} elseif ($PinTan == 2) {
echo "<tr><td onclick=\"window.open('inhalt/upload/status_PinTan.php', 'PinTan', 'width=500,height=300,scrollbars=no')\"; class=\"statuslinks-gelb\" width=\"6%\" align=\"center\" valign=\"top\"><img src=\"status_gelb.gif\" width=\"9\" height=\"9\" border=\"0\" align=\"middle\" vspace=\"3\"></td><td onclick=\"window.open('inhalt/upload/status_PinTan.php', 'PinTan', 'width=500,height=300,scrollbars=no')\"; class=\"statusmitte-gelb\" width=\"50%\" align=\"left\" valign=\"top\"><a href=\"inhalt/upload/status_PinTan.php\" target=\"_blank\">PIN/TAN</a></td><td onclick=\"window.open('inhalt/upload/status_PinTan.php', 'PinTan', 'width=500,height=300,scrollbars=no')\"; class=\"statusrechts-gelb\" width=\"44%\" align=\"left\" valign=\"top\">[ <a href=\"status_PinTan.php\" target=\"_blank\"><font color=\"#bcb72a\">teilweise</font></a> ]</td></tr>";
} else {
echo "<tr><td class=\"statuslinks\" width=\"6%\" align=\"center\" valign=\"top\"><img src=\"status_gruen.gif\" width=\"9\" height=\"9\" border=\"0\" align=\"middle\" vspace=\"3\"></td><td class=\"statusmitte\" width=\"50%\" align=\"left\" valign=\"top\">PIN/TAN</td><td class=\"statusrechts\" width=\"44%\" align=\"left\" valign=\"top\">[ <font color=\"#008000\">online</font> ]</td></tr>";
}
if ($InterCept == 1) {........and so on

So the component i need in the mambo backend must only change the red variables (0,1 or 2) in the module-file (at the top). I think it could be done with checkboxes or input fields where I type in 0, 1 or 2 and the module-file will change.

How can I do that :question:

THANKS a lot for your help!

keliix06
07.04.2004, 15:33
You can accomplish this with a config file. A component to change just that is a bit much. If you really want one, download AkoGallery and strip it down to just the config task. I'd put it together for you, but I'm particularly busy right now.

Heart
10.04.2004, 12:16
Oh oh.... tried but not successful yet

Could anyone please have a look at my component-try?

Tried to edit/cut the not necessary lines out from akogallery so that I only have the edit settings menu link with only the Backend - configtable in there.
Install of the component is fine but when I go to "Status">"Status editieren" nothing happens

zip-file with the code (http://www.sg-apfeltrach.de/status.zip)

THANKS
Heart

alwarren
10.04.2004, 13:45
Have you considered using module parameters?

Heart
10.04.2004, 14:26
How should I have considered that exactly?

SvenErik
10.04.2004, 14:47
Take a look at the mambo.sql file, locate the CREATE TABLE `mos_modules' part. Get the component to set the values in the params field for your module which has its name in the module field. Something like this, I would think [any REAL PHP programmers correct me if I am wrong here ;) ]:


// The new values you want to give the module
$NewValues="eBanking=1\r\nPinTan=0\r\nInterCept=0\r\nHBCI=1\r\ nFTAM=0";

// The name of your module
$MyModuleName="mod_statuswindow";

// Set the query
$this->_db->setQuery( "UPDATE #__modules.params SET params='$NewValues' WHERE module='$MyModuleName'");



Strange.. The board keeps adding spaces into the code... :confused: I included the code in a text file

SvenErik
10.04.2004, 20:15
To continue on my suggestion in previous post:

Then you get the module to retrieve its parameters:

// Load module parameters
$query = "SELECT * FROM #__modules WHERE module = 'mod_statuswindow'";
$database->setQuery($query);
$rows = $database->loadObjectList();
$params = mosParseParams($rows[0]->params);

$eBanking = $params->eBanking;
$PinTan = $params->PinTan;
$InterCept = $params->InterCept;
$HBCI = $params->HBCI;
$FTAM = $params->FTAM;

Then the module do whatever it needs to do with the parameters it retrieved.

SvenErik
11.04.2004, 00:43
Heart, how does it go with your component?

Heart
11.04.2004, 12:49
Thank you VERY MUCH Sven, I will take a look at it nearly....
"Must" spend some time with my affinity and eat cook and so, you know... Easter :)

stingrey
11.04.2004, 17:15
If you want an example of how a module can accept parameters, you could download my Display News modules (any of the three) and have a look inside.
It accepts 57 parameters

In the code i have some code to check the variables entered to ensure that only relevant parameters are entered. if it isnt valid, then it defaults to the default value.

Heart
13.04.2004, 15:48
OK, I finished my FIRST component successfully :)

I don't use/need mysql-tables for this little thing so I took a deeper look at Arthurs "AkoLegal" component....

Edit this for my needs and now it works ;)
I edit the config file in the component and in my module i require this config file....

Thanks again for your help!!!

prj
22.09.2004, 01:58
OK, I finished my FIRST component successfully :)

I don't use/need mysql-tables for this little thing so I took a deeper look at Arthurs "AkoLegal" component....

Edit this for my needs and now it works ;)
I edit the config file in the component and in my module i require this config file....

Thanks again for your help!!!

Didyou release it?