I was inspired today, i dunno by what but I was in the mood and now I am on an adventure to write my own markup/scripting language. I am calling it XPL which stands for:
eXtensible Precompiled Language
It is a mix of xhtml, css, and php. My goal for this inner language of php is to make the blending of regular xhtml code with the syntax of php easier, aswell as making webpages using xhtml, xml, css easier by leaps and bounds.
Below is what I have coded so far, I don't plan on devoting to much time to this since, I am devoting most of my attention to PHPublisher, however I figured I would post it here and ask for some criticism and what you think overall about the idea :-)
<?php
/***********************************************************************
/
/ Language: eXtensible Precompiled Language
/ Mix of: xhtml, xml, css, and php
/ Goal: To make the blending of xhtml/html and php easier, aswell as
/ making webpages using xhtml, xml, css easier by leaps and bounds.
/ Version: 0.01
/
/**********************************************************************/
define("_CONSTRUCT_ERROR", "\n<p style=\"margin-top: 15px; font-weigth: bold;\">CONSTRUCTION ERROR:</p>");
//
// xhref
// (XPL 0.01)
// xhref -- Creates an xhtml valid web link
// xhref($_HYPERLINK_P, $_TITLE_P, $_TARGET_P [, $_ID_P[, $_CLASS_P]])
// Rturns a valid weblink on success, or returns an error on failure
//
function xhref($_HYPERLINK_P = "", $_TITLE_P = "", $_TARGET_P = "", $_ID_P = "", $_CLASS_P = ""){
if(isset($_ID_P)){
$_ID = "id=\"".$_ID_P."\" ";
$_ID_ERROR = ",\"".$_ID_P."\"";
}
if(isset($_CLASS)){
if(ereg('^[a-zA-Z0-9_-]+$', $_CLASS_P) !== TRUE){
die(_CONSTRUCT_ERROR."<p>Illegal characters in use in the CLASS parameter in the xhref() function. Illegal Character: <strong>".$_CLASS_P."</strong></p>");
}
$_CLASS = "class=\"".$_CLASS_P."\" ";
$_CLASS_ERROR = ",\"".$_CLASS_P."\"";
}
$_HYPERLINK = trim($_HYPERLINK_P);
$_TARGET = strtolower(trim($_TARGET_P));
$_ERROR = "xhref(\"".$_HYPERLINK_P."\", \"".$_TITLE_P."\",\"".$_TARGET_P."\"".$_ID_ERROR.$_CLASS_ERROR.")";
if(isset($_HYPERLINK) && isset($_TITLE_P) && isset($_TARGET)){
switch($_TARGET)
{
case "_blank":
case "_parent":
case "_self":
case "_top":
continue;
break;
default:
die(_CONSTRUCT_ERROR."<p>Incorrect parameter values in use in the xhref() function. Incorrect Code: <strong>".$_ERROR."</strong></p>");
break;
}
return "<a href=\"".$_HYPERLINK."\" target=\"".$_TARGET."\" ".$_ID.$_CLASS.">".$_TITLE_P."</a>\n";
}else{
die(_CONSTRUCT_ERROR."<p>Missing required parameters in use in the xhref() function. Incorrect Code: <strong>".$_ERROR."</strong></p>");
}
}
//
// xspan
// (XPL 0.01)
// xspan -- Creates a xhtml <span> tag
// xspan($_CONTENT_P [, $_ID_P[, $_CLASS_P]])
// Rturns a xhtml <span> tag on success, or an error on failure
//
function xspan($_CONTENT_P = "", $_ID_P = "", $_CLASS_P = ""){
if(isset($_ID_P)){
$_ID = "id=\"".$_ID_P."\" ";
$_ID_ERROR = ",\"".$_ID_P."\"";
}
if(isset($_CLASS_P)){
if(ereg('^[a-zA-Z0-9_-]+$', $_CLASS_P) !== TRUE){
die(_CONSTRUCT_ERROR."<p>Illegal characters in use in the CLASS parameter in the xspan() function. Illegal Character(s): <strong>".$_CLASS_P."</strong></p>");
}
$_CLASS = "class=\"".$_CLASS_P."\" ";
$_CLASS_ERROR = ",\"".$_CLASS_P."\"";
}
$_ERROR = "xspan(\"".$_CONTENT_P."\"".$_ID_ERROR.$_CLASS_ERROR.")";
if(isset($_CONTENT_P)){
echo "<span ".$_ID.$_CLASS.">".$_CONTENT_P."</span>\n";
}else{
die(_CONSTRUCT_ERROR."<p>Missing required parameters in use in the xspan() function. Incorrect Code: <strong>".$_ERROR."</strong></p>");
}
}
//
// xdiv
// (XPL 0.01)
// xdiv -- Alias of xspan
// xdiv($_CONTENT_P [, $_ID_P[, $_STYLE_P]])
// Rturns a xhtml <div> tag on success or an error on failure. Almost exactly like the xspan() function
// xdiv() allows for the use of "text/css" in the function, instead of only allowing the
// optional class field.
//
function xdiv($_CONTENT_P = "", $_ID_P = "", $_STYLE_P = ""){
if(isset($_ID_P)){
$_ID = "id=\"".$_ID_P."\" ";
$_ID_ERROR = ",\"".$_ID_P."\"";
}
if(isset($_STYLE_P)){
$_STYLE = "style=\"".$_STYLE_P."\" ";
$_STYLE_ERROR = ",\"".$_STYLE_P."\"";
}
$_ERROR = "xdiv(\"".$_CONTENT_P."\"".$_ID_ERROR.$_STYLE_ERROR.")";
if(isset($_CONTENT_P)){
echo "<div ".$_ID.$_STYLE.">".$_CONTENT_P."</div>\n";
}else{
die(_CONSTRUCT_ERROR."<p>Missing required parameters in use in the xdiv() function. Incorrect Code: <strong>".$_ERROR."</strong></p>");
}
}
xdiv("Check it out!!! Its XPL xhtml generated content!", "My First XPL Content!", "margin-bottom: 25px; font-weight: bold;");
xdiv("".xhref("http://phpublisher.net", "Click here to check out PHPublisher!", "_self", "PHPublisher")."", "My First XPL Web Link!", "margin: 25px;");
?>