Introduction to Mys v1.3.3's GUI Programming

Forum
Last Post
Threads / Messages

Hall of Famer

Administrator
Staff member
Administrator
Joined
Dec 15, 2008
Messages
4,564
Points
48
Location
United States
Mysidian Dollar
214,223
I hereby present Mysidia's new GUI API. You may wonder what this is, well, it may not seem that alien to you if you are a Java programmer. The GUI system is designed to work like Java, and give coders a good experience working on the document construction.

Before we move into details, let's take a look at what Mys v1.3.2 has to do with building up the content of a document at this point. The below code demonstrates some basic idea:

PHP:
$mysidia->page->settitle("The document title");
$mysidia->page->addcontent("The first line of content<br>");
$mysidia->page->addcontent("The second line of content<br>");
It does look easy to use, but there is a problem involved when the document content gets more complex. What if we have to build a table or a form? A standard way to accomplish this is:

PHP:
$form = "<form name='form1' method='post' action='login.php'>
                    <p>Username: <input name='username' type='text' id='username'></p>
                    <p>Password: <input name='password' type='password' id='password'></p>
                    <p><input type='submit' name='Submit' value='Submit'></p>
                    <p>Don't have an account?<br>
                    <a href='register.php'>Register Free</a>  </p>
                    <a href='forgotpass.php'>Forgot your password?  Click Here</a>
                    </form>";
$mysidia->page->addcontent($form);
I am not sure how you feel about it, but mixing html inside php main script files makes it look messy and unprofessional. In many cases we have to build a dropdown menu by fetching data from mysql table, which gives it an even worse nightmare.

By Mys v1.3.3 I decide to design a GUI API package, which handles the construction of the document body like a charm. It uses composite design pattern, each component can be added into a container. A container can be added to a higher-level container until it reaches the top layer called Document. A document may contain text, paragraph, division(div), links, images, forms, tables and anything you can think of.

I know its pointless to give a long speech that does not do anything, so I will show you an example that makes use of the GUI API:

PHP:
$document = $mysidia->frame->getDocument();
$document->setTitle("register");
$form = new Form("regform", "register.php", "post");
$form->setAlign(new Align("center", "middle"));

$src = new URL("http://www.tivo.com/assets/images/abouttivo/resources/downloads/backgrounds/Green_bkgd_72rgb.jpg");
$field = new FieldSet();
$field->setLineBreak(FALSE);
$field->setBackground(new Image($src, "back", 300));

$field->add(new Legend("Required Field"));
$field->add(new Division(new Comment("Please enter your username here, it must be alphanumeric."), "username"));
$field->add(new TextField("username", "admin", 10));
$field->add(new Paragraph(new Comment("Please fill in your password confirmed password here.")));
$field->add(new PasswordField("password", "password", "123456"));
$field->add(new PasswordField("password", "password2"));

$email = new Paragraph();
$email->setID("email");
$email->setFont(new Font(14, "Times New Roman"));
$email->getFont()->setWeight("bolder");
$email->setForeground(new Color("#000080"));

$email->add(new Comment("Please type your email and confirmed email here.", TRUE));
$email->add(new PasswordField("email", "email"));
$email->add(new PasswordField("email", "email2"));
$field->add($email);
$checkbox = new CheckBox("I agree to the terms of services", "tos", "yes", "yes");
$field->add($checkbox);

$field2 = new FieldSet(new Legend("Additional Fields"));
$field2->setBackground(new Color("red"));

$radiolist = new RadioList("gender");
$radiolist->add(new RadioButton("Male", "gender", "male"));
$radiolist->add(new RadioButton("Female", "gender", "female"));
$radiolist->add(new RadioButton("Unknown", "gender", "unknown"));
$radiolist->check("unknown");

$countries = array("Britain", "France", "Germany", "Italy", "Spain", "America", "Canada", "Russia", "Australia");
$alias = array("gbr", "fra", "ger", "ita", "esp", "usa", "can", "rus", "aus");
$default = "usa";
$dropdown = new DropdownList("country");
$dropdown->fill($countries, $alias, $default);

$comment2 = new Comment("Your Citizenship: ", FALSE);
$comment2->setBold();
$comment2->setUnderlined();
$comment2->setForeground(new Color("yellow"));

$field2->add(new Comment("Your Gender: ", FALSE));
$field2->add($radiolist);
$field2->add($comment2);
$field2->add($dropdown);
$field2->add(new Comment("Select an Avatar: ", FALSE));
$field2->add(new FileField("avatar"));
$field2->add(new CheckBox("Receive System/Administrator Email", "systememail", "enabled"));

$submit = new Button("Register", "submit", "submit");
$submit->setLineBreak(FALSE);

$form->add($field);
$form->add($field2);
$form->add(new Image(new URL("../templates/icons/facebook.gif"), "facebook", 20));
$form->add($submit);
$form->add(new Image(new URL("../templates/icons/twitter.gif"), "twitter", 20));

$lang = new Comment("Registratio Form", FALSE);
$lang->setCentered();
$lang->setBold();
$lang->setUnderlined();
$lang2 = new Comment("Note: It is your own responsibility to protect your password!");
$lang2->setCentered();
$lang2->setForeground(new Color("red"));

$document->add($lang);
$document->add($form);
$document->add($lang2);
It may seem tough for those who have absolutely no knowledge of PHP to interpret. Nonetheless, if you really are a programmer/coder(especially if you are comfortable with Java GUI Programming), you'd be thrilled at how easy it is to manipulate HTML form and form elements with this GUI API. The above code renders to give the following document and the HTML code:

http://www.mysidiarpg.com/site/mys133a/demo/form_document.php

HTML:
 <article> 
<u><b><center>Registratio Form</center></b></u> 
<form style=' text-align:center;' name='myform' id='myform' action='form.php' method='post'>  
<fieldset style=' background-image: url(http://www.tivo.com/assets/images/abouttivo/resources/downloads/backgrounds/Green_bkgd_72rgb.jpg);'> 
 <legend>Required Field </legend> 
<div name='username' id='username'> 
Please enter your username here, it must be alphanumeric.<br> 
</div> 
<input name='username' id='username' maxlength='10' value='admin'><br>
<p> 
Please fill in your password confirmed password here.<br> 
</p> 
<input name='password' id='password' type='password' value='123456'> 
<input name='password2' id='password2' type='password'> 
<p style=' font-size: 14px; font-family: Times New Roman; font-weight: bolder; color:#000080;' id='email'> 
Please type your email and confirmed email here.<br> 
<input name='email' id='email' type='email'>
<input name='email2' id='email2' type='email'> 
</p> 
<input name='tos' id='tos' value='yes' checked='checked' type='checkbox'>
I agree to the terms of services<br> 
</fieldset>
<fieldset style=' background-color:red;' name='Additional Fields'>  
<legend>Additional Fields </legend>
Your Gender:  
<input name='gender' id='gender' value='male' type='radio'>Male 
<input name='gender' id='gender' value='female' type='radio'>Female 
<input name='gender' id='gender' value='unknown' type='radio' checked='checked'>Unknown<br> 
<span style=' color:yellow;'> 
<u><b>Your Citizenship: </b></u> 
</span> 
<select name='country' id='country'> 
 <option id='gbr' value='gbr'>Britain </option> 
<option id='fra' value='fra'>France </option> 
<option id='ger' value='ger'>Germany </option> 
<option id='ita' value='ita'>Italy </option> 
<option id='esp' value='esp'>Spain </option> 
<option id='usa' value='usa' selected='selected'>America </option> 
<option id='can' value='can'>Canada </option> 
<option id='rus' value='rus'>Russia </option> 
<option id='aus' value='aus'>Australia </option> 
</select><br>
Select an Avatar:  
<input name='avatar' id='avatar' type='file'><br> 
<input name='systememail' id='systememail' value='enabled' type='checkbox'>
Receive System/Administrator Email<br> 
</fieldset><br> 
<img id='facebook' src='../templates/icons/facebook.gif' alt='facebook' width='20' height='20'>  
<button name='submit' id='submit' value='submit' type='submit'>
Register 
</button> 
<img id='twitter' src='../templates/icons/twitter.gif' alt='twitter' width='20' height='20'>  
</form> 
<span style=' color:red;'> 
<center>Note: It is your own responsibility to protect your password!</center> 
</span><br>
 </article>
The GUI API will make its first appearance in Mys v1.3.3, its role is vital in the design of the new Widget System. It will continue to evolve throughout the course of Mys v1.3.x's development, and its usefulness will become more evident when Mysidia's MVC structure is completed. The GUI API will be used extensively in the View classes, which you will see in a few months. Note Mys v1.3.3 does not separate controllers from views, so the code may still look messy in some way.

And what do you think? I know it makes little difference to absolute non-coders, but the well-organized code is an excellent news for programmers. Lemme know if you have any suggestions to make, Id love to hear.
 
I know that I'm not a coder at all, but I have been looking at all the PHP code that you've done in the mysidia script and have seen that a lot of things are hard to change.

When I look at this I see that users are getting much more customization options. I've noticed how that I can't seperate different parts of the PHP to put them wherever I want on the website, (I tried moving the Online users in the :SIDEBAR:), oh course, it didn't work. It looks like we'll have many more different ways of customizing our forms and information on the website. I like the looks of it!

I also appreciate you doing all of this work for free, I realize that this is a project for you, and that you probably enjoy working on it, but I would still like to extend my thanks for making this public for people to use.

I'm looking forward to all of the improvements!

-Nieth
 
Thanks for the comment, I try my best to make Mysidia Adoptables as much customizable as possible. XD

And lol are you kidding me? Even with this script being free I still only have about 20 customers. Imagine how many I'd have left if its a paidware.
 
It's a shame though, this community has so much going for it. It seems like there used to be a lot of active users earlier this year,but I haven't seen many recently.
 
umm this you can blame it on me lol. Mys v1.3.1 was released by Apr 8th, while Mys v1.3.2's release date was Nov 22nd. People were expecting something big in summer, but instead I made use of that time improving my PHP skills rather than actively developing the product.

Its a dilemma though, if I havent done that in the summer, we might as well have Mys v1.3.4 or v1.3.5 by now. But the quality of the script will be even worse than Mys v1.3.2 currently is. Do you guys wanna see script with better quality, or more frequent releases? Id say I have to find a balance between the two, thats why I did release Mys v1.3.2 by Thanksgivings so as not to lose all still lurking customers.

The sad truth is that if users do not see the script being active developed they are gone for good. The bright news is that my PHP skill is good enough to handle the development of Mys v1.3.x and v1.4.x now. I do not need to spend months off learning new stuff like I had to previously lol.
 
That's true, I would much rather have something of higher quality than something more frequent. Well, you can be sure that me and Cless won't go anywhere.
 
Thats great, thanks.

Btw, I have submitted the GUI API to PHPClasses.org. Its a highly reusable package not specifically tied to the script, although I have ended up extending its functionalities in Mys v1.3.3 to make it more useful for this script. If you are developing another software, you may use the GUI API so long as you give credits to Hall of Famer:

http://www.phpclasses.org/package/7857-PHP-Render-HTML-pages-composed-programmatically.html
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,118
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top