SA_package_001
Scouting Alphen Forms
0.0.2
2022-05-30 11:37:29
Jeroen
redactie@scoutingalphen.nl
scoutingalphen.nl
Contains all SA forms and scripts
This FacileForms package is released under the GNU/GPL license
FF
ff_addCustomCSSFile
Add custom CSS File
Before Form
Adds a custom css file to the form. To choose a css file\x2C execute this piece and call the function ff_addCustomCSSFile(\x27path/to/css/file\x27) with the RELATIVE (not full!) path to your joomla installation.\r\nDo not forget to call $this-\x3EexecPieceByName(\x27ff_InitLib\x27) before!\r\n\r\nExample:\r\n\r\nglobal $mainframe\x3B\r\n\r\n$this-\x3EexecPieceByName(\x27ff_InitLib\x27)\x3B\r\n$this-\x3EexecPieceByName(\x27ff_addCustomCSSFile\x27)\x3B\r\n\r\nff_addCustomCSSFile(\x27templates/\x27 . $mainframe-\x3EgetTemplate() . \x27/css/template.css\x27)\x3B
function ff_addCustomCSSFile($path){\r\n if(file_exists(JPATH_SITE . \x27/\x27 . $path)){\r\n JFactory::getDocument()-\x3EaddStyleSheet(JURI::root() . $path)\x3B\r\n }\r\n}
FF
ff_addCustomCSSFile
Add custom CSS File
Before Form
Adds a custom css file to the form. To choose a css file\x2C execute this piece and call the function ff_addCustomCSSFile(\x27path/to/css/file\x27) with the RELATIVE (not full!) path to your joomla installation.\r\nDo not forget to call $this-\x3EexecPieceByName(\x27ff_InitLib\x27) before!\r\n\r\nExample:\r\n\r\nglobal $mainframe\x3B\r\n\r\n$this-\x3EexecPieceByName(\x27ff_InitLib\x27)\x3B\r\n$this-\x3EexecPieceByName(\x27ff_addCustomCSSFile\x27)\x3B\r\n\r\nff_addCustomCSSFile(\x27templates/\x27 . $mainframe-\x3EgetTemplate() . \x27/css/template.css\x27)\x3B
function ff_addCustomCSSFile($path){\r\n if(file_exists(JPATH_SITE . \x27/\x27 . $path)){\r\n JFactory::getDocument()-\x3EaddStyleSheet(JURI::root() . $path)\x3B\r\n }\r\n}
FF
ff_Constants
Constansts definitions
Before Form
Library constants definitions
define(\x27FF_DIE\x27\x2C \x27_ff_die_on_errors_\x27)\x3B\r\ndefine(\x27FF_DONTDIE\x27\x2C \x27_ff_stay_alive_\x27)\x3B\r\ndefine(\x27FF_IGNOREDIE\x27\x2C \x27_ff_ignore_if_dying_\x27)\x3B\r\n\r\ndefine(\x27FF_ARRAY\x27\x2C \x27_ff_return_as_array_\x27)\x3B\r\ndefine(\x27FF_LIST\x27\x2C \x27_ff_return_as_list_\x27)\x3B\r\ndefine(\x27FF_SLIST\x27\x2C \x27_ff_return_as_slist_\x27)\x3B\r\ndefine(\x27FF_DLIST\x27\x2C \x27_ff_return_as_dlist_\x27)\x3B\r\n\r\ndefine(\x27FF_NOTRIM\x27\x2C 1)\x3B\r\ndefine(\x27FF_ALLOWHTML\x27\x2C 2)\x3B\r\ndefine(\x27FF_ALLOWRAW\x27\x2C 4)\x3B
FF
ff_Constants
Constansts definitions
Before Form
Library constants definitions
define(\x27FF_DIE\x27\x2C \x27_ff_die_on_errors_\x27)\x3B\r\ndefine(\x27FF_DONTDIE\x27\x2C \x27_ff_stay_alive_\x27)\x3B\r\ndefine(\x27FF_IGNOREDIE\x27\x2C \x27_ff_ignore_if_dying_\x27)\x3B\r\n\r\ndefine(\x27FF_ARRAY\x27\x2C \x27_ff_return_as_array_\x27)\x3B\r\ndefine(\x27FF_LIST\x27\x2C \x27_ff_return_as_list_\x27)\x3B\r\ndefine(\x27FF_SLIST\x27\x2C \x27_ff_return_as_slist_\x27)\x3B\r\ndefine(\x27FF_DLIST\x27\x2C \x27_ff_return_as_dlist_\x27)\x3B\r\n\r\ndefine(\x27FF_NOTRIM\x27\x2C 1)\x3B\r\ndefine(\x27FF_ALLOWHTML\x27\x2C 2)\x3B\r\ndefine(\x27FF_ALLOWRAW\x27\x2C 4)\x3B
FF
ff_databaseToSelect
ff_databaseToSelect
Before Form
Populates a select field with database stuff. Use like so:\r\n\r\ndatabaseToSelect($select\x2C $table\x2C $label\x2C $value\x2C $sql)\x3B\r\n\r\n$label and $value are fields you want to display as label and value in select options. $table\r\nis the name of the table you want to look for. $select is the name of the select input. $sql holds custom SQL query\x2C if supplied. If not\x2C\r\nfunction will perform a simple \x27SELECT $label\x2C $valueFROM $table\x27\x3B\r\n\r\nexample\x3B databaseToSelect(\x27mySelect\x27\x2C \x27users\x27\x2C \x27name\x27\x2C \x27ID)\x3B
function ff_databaseToSelect($st\x2C $tbl\x2C $lbl\x2C $val\x2C $sql)\r\n{\r\n $db = JFactory::getDBO()\x3B //Get Database Object\r\n global $ff_processor\x3B\r\n\r\n //Create your own query here\r\n if($sql and $sql!=\x27\x27){\r\n $db-\x3EsetQuery($sql)\x3B\r\n }else{\r\n $db-\x3EsetQuery(\x22SELECT $lbl\x2C $val FROM $tbl\x22)\x3B\r\n }\r\n \r\n\r\n $result = $db-\x3EloadObjectList()\x3B //load the result from the query\r\n $values = []\x3B\r\n foreach($result as $rrow){\r\n $values[]=(object)array(\x27selected\x27=\x3E0\x2C\x27label\x27=\x3E$rrow-\x3E{$lbl}\x2C \x27value\x27=\x3E$rrow-\x3E{$val})\x3B\r\n }\r\n \r\n unset($rrow)\x3B\r\n \r\n foreach($ff_processor-\x3Erows as $row)\r\n {\r\n if ($row-\x3Ename==$st){\r\n $row-\x3EselectList = $values\x3B\r\n foreach($values as $var){\r\n $row-\x3Edata2 .= $var-\x3Eselected.\x22\x3B\x22.$var-\x3Elabel.\x22\x3B\x22.$var-\x3Evalue.\x22\x5Cn\x22\x3B\r\n }\r\n break\x3B\r\n }\r\n unset($row)\x3B\r\n }\r\n}
FF
ff_die
Terminate form gracefully
Gracefully terminates the form and shows a message plus opionally a \r\nCONTINUE button for further redirection.\r\n\r\nCall:\r\n\r\n ff_die($message=null\x2C $action=\x27stop\x27\x2C $target=\x27\x27\x2C $params=\x27\x27\x2C $label=\x27Continue\x27)\x3B\r\n return\x3B\r\n\r\n $message = A message to display. If no message is provided\x2C it will\r\n display:\r\n\r\n Fatal error in $formname\x2C processing stopped.\r\n\r\n $action = \x27stop\x27 : Dont show a CONTINUE button (default)\r\n \x27self\x27 : Redirect to the same form\r\n \x27form\x27 : Redirect to another form \r\n \x27page\x27 : Redirect to another page of this site\r\n \x27home\x27 : Redirect to homepage of the site\r\n \x27url\x27 : Redirect to a url\r\n\r\n $target = Target name/url for \x27form\x27\x2C \x27page\x27 and \x27url\x27\r\n\r\n $params = Additional parameters for \x27self\x27 and \x27form\x27\r\n\r\n $label = Text for the continue button\r\n\r\nExamples:\r\n\r\n // Display standard message without continue button\r\n ff_die()\x3B \r\n\r\n // Display message without continue button\r\n ff_die(\x27Sorry\x2C cannot continue for some reason.\x27)\x3B\r\n\r\n // Display standard message and return to same form with a parameter\r\n ff_die(null\x2C \x27self\x27\x2C \x27\x26ff_param_foo=bar\x27)\x3B\r\n\r\n // Redirect to another form\r\n ff_die(\x27Guess you are hungry now...\x27\x2C \x27form\x27\x2C \x27SamplePizzaShop\x27\x2C null\x2C \x27Order\x27)\x3B\r\n\r\n // Redirect to another site page\r\n ff_die(\r\n \x27Something strange has happened!\x27\x2C \r\n \x27page\x27\x2C \r\n \x27index.php?option=com_content\x26task=section\x26id=1\x26Itemid=2\x27\r\n )\x3B
function ff_die($message=\x27\x27\x2C $action=\x27stop\x27\x2C $target=\x27\x27\x2C $params=\x27\x27\x2C $label=\x27Continue\x27)\r\n{\r\n global $ff_processor\x3B\r\n if ($ff_processor-\x3Edying) return\x3B\r\n\r\n ob_end_clean()\x3B\r\n $form =\x26 $ff_processor-\x3Eformrow\x3B\r\n if (!$message) \r\n $message = \r\n \x22\x3Cstrong\x3EFatal error in $form-\x3Ename\x2C form processing halted.\x3C/strong\x3E\x22\x3B\r\n switch ($action) {\r\n case \x27self\x27: $url = ff_makeSelfUrl($params)\x3B break\x3B\r\n case \x27form\x27: $url = ff_makeFormUrl($target\x2C $params)\x3B break\x3B\r\n case \x27page\x27: $url = ff_makePageUrl($target)\x3B break\x3B\r\n case \x27home\x27: $url = \x22{mossite}\x22\x3B break\x3B\r\n case \x27url\x27 : $url = $target\x3B break\x3B\r\n default : $url = \x27\x27\x3B\r\n } // switch\r\n if ($form-\x3Eclass1 != \x27\x27) echo \x27\x3Cdiv class=\x22\x27.$form-\x3Eclass1.\x27\x22\x3E\x27.nl()\x3B\r\n echo($message.\x27\x3Cbr/\x3E\x3Cbr/\x3E\x3Cbr/\x3E\x27.nl())\x3B\r\n if ($url) {\r\n if (!$ff_processor-\x3Einline) echo \x27\x3Cform action=\x22#redirect\x22\x3E\x27.nl()\x3B\r\n if ($ff_processor-\x3Einframe) $t = \x27parent\x27\x3B else $t = \x27document\x27\x3B\r\n echo \x27\x3Cinput type=\x22button\x22 class=\x22button\x22 value=\x22\x27.$label.\x27\x22\x27.\r\n \x27 onClick=\x22\x27.$t.\x27.location.href=\x5C\x27\x27.htmlentities($url\x2CENT_QUOTES).\x27\x5C\x27\x3B\x22\x27.\r\n \x27/\x3E\x27.nl()\x3B\r\n if (!$ff_processor-\x3Einline) echo \x27\x3C/form\x3E\x27.nl()\x3B\r\n } // if\r\n if ($form-\x3Eclass1 != \x27\x27) echo \x27\x3C/div\x3E\x27.nl()\x3B\r\n unset($form)\x3B\r\n ob_start()\x3B\r\n $ff_processor-\x3Esuicide()\x3B\r\n} // ff_die
FF
ff_die
Terminate form gracefully
Gracefully terminates the form and shows a message plus opionally a \r\nCONTINUE button for further redirection.\r\n\r\nCall:\r\n\r\n ff_die($message=null\x2C $action=\x27stop\x27\x2C $target=\x27\x27\x2C $params=\x27\x27\x2C $label=\x27Continue\x27)\x3B\r\n return\x3B\r\n\r\n $message = A message to display. If no message is provided\x2C it will\r\n display:\r\n\r\n Fatal error in $formname\x2C processing stopped.\r\n\r\n $action = \x27stop\x27 : Dont show a CONTINUE button (default)\r\n \x27self\x27 : Redirect to the same form\r\n \x27form\x27 : Redirect to another form \r\n \x27page\x27 : Redirect to another page of this site\r\n \x27home\x27 : Redirect to homepage of the site\r\n \x27url\x27 : Redirect to a url\r\n\r\n $target = Target name/url for \x27form\x27\x2C \x27page\x27 and \x27url\x27\r\n\r\n $params = Additional parameters for \x27self\x27 and \x27form\x27\r\n\r\n $label = Text for the continue button\r\n\r\nExamples:\r\n\r\n // Display standard message without continue button\r\n ff_die()\x3B \r\n\r\n // Display message without continue button\r\n ff_die(\x27Sorry\x2C cannot continue for some reason.\x27)\x3B\r\n\r\n // Display standard message and return to same form with a parameter\r\n ff_die(null\x2C \x27self\x27\x2C \x27\x26ff_param_foo=bar\x27)\x3B\r\n\r\n // Redirect to another form\r\n ff_die(\x27Guess you are hungry now...\x27\x2C \x27form\x27\x2C \x27SamplePizzaShop\x27\x2C null\x2C \x27Order\x27)\x3B\r\n\r\n // Redirect to another site page\r\n ff_die(\r\n \x27Something strange has happened!\x27\x2C \r\n \x27page\x27\x2C \r\n \x27index.php?option=com_content\x26task=section\x26id=1\x26Itemid=2\x27\r\n )\x3B
function ff_die($message=\x27\x27\x2C $action=\x27stop\x27\x2C $target=\x27\x27\x2C $params=\x27\x27\x2C $label=\x27Continue\x27)\r\n{\r\n global $ff_processor\x3B\r\n if ($ff_processor-\x3Edying) return\x3B\r\n\r\n ob_end_clean()\x3B\r\n $form =\x26 $ff_processor-\x3Eformrow\x3B\r\n if (!$message) \r\n $message = \r\n \x22\x3Cstrong\x3EFatal error in $form-\x3Ename\x2C form processing halted.\x3C/strong\x3E\x22\x3B\r\n switch ($action) {\r\n case \x27self\x27: $url = ff_makeSelfUrl($params)\x3B break\x3B\r\n case \x27form\x27: $url = ff_makeFormUrl($target\x2C $params)\x3B break\x3B\r\n case \x27page\x27: $url = ff_makePageUrl($target)\x3B break\x3B\r\n case \x27home\x27: $url = \x22{mossite}\x22\x3B break\x3B\r\n case \x27url\x27 : $url = $target\x3B break\x3B\r\n default : $url = \x27\x27\x3B\r\n } // switch\r\n if ($form-\x3Eclass1 != \x27\x27) echo \x27\x3Cdiv class=\x22\x27.$form-\x3Eclass1.\x27\x22\x3E\x27.nl()\x3B\r\n echo($message.\x27\x3Cbr/\x3E\x3Cbr/\x3E\x3Cbr/\x3E\x27.nl())\x3B\r\n if ($url) {\r\n if (!$ff_processor-\x3Einline) echo \x27\x3Cform action=\x22#redirect\x22\x3E\x27.nl()\x3B\r\n if ($ff_processor-\x3Einframe) $t = \x27parent\x27\x3B else $t = \x27document\x27\x3B\r\n echo \x27\x3Cinput type=\x22button\x22 class=\x22button\x22 value=\x22\x27.$label.\x27\x22\x27.\r\n \x27 onClick=\x22\x27.$t.\x27.location.href=\x5C\x27\x27.htmlentities($url\x2CENT_QUOTES).\x27\x5C\x27\x3B\x22\x27.\r\n \x27/\x3E\x27.nl()\x3B\r\n if (!$ff_processor-\x3Einline) echo \x27\x3C/form\x3E\x27.nl()\x3B\r\n } // if\r\n if ($form-\x3Eclass1 != \x27\x27) echo \x27\x3C/div\x3E\x27.nl()\x3B\r\n unset($form)\x3B\r\n ob_start()\x3B\r\n $ff_processor-\x3Esuicide()\x3B\r\n} // ff_die
FF
ff_DisableFormTrace
Disable tracing at view time
Before Form
Disables tracing for use as before form piece
//+trace dis
FF
ff_DisableFormTrace
Disable tracing at view time
Before Form
Disables tracing for use as before form piece
//+trace dis
FF
ff_DisableSubmitTrace
Disable tracing at submit time
Begin Submit
Disables tracing for use as begin submit piece
//+trace dis
FF
ff_DisableSubmitTrace
Disable tracing at submit time
Begin Submit
Disables tracing for use as begin submit piece
//+trace dis
FF
ff_dying
Query live status
Query if form is dying
//+trace max none\r\nfunction ff_dying()\r\n{\r\n global $ff_processor\x3B \r\n return $ff_processor-\x3Edying\x3B\r\n} // ff_dying
FF
ff_dying
Query live status
Query if form is dying
//+trace max none\r\nfunction ff_dying()\r\n{\r\n global $ff_processor\x3B \r\n return $ff_processor-\x3Edying\x3B\r\n} // ff_dying
FF
ff_expString
String export
Export string function: escapes special characters in c-codes
function ff_expString($text)\r\n{\r\n return expstring($text)\x3B\r\n} // ff_expString
FF
ff_expString
String export
Export string function: escapes special characters in c-codes
function ff_expString($text)\r\n{\r\n return expstring($text)\x3B\r\n} // ff_expString
FF
ff_getPageByNameX
Get page # by element name
Gets the page number by the name of an element. \r\nTypically used to redirect to a certain page in a before form piece \r\nas \r\n\r\n $this-\x3Epage = ff_getPageByName(\x27elementname\x27)\x3B
function ff_getPageByName($name)\r\n{\r\n global $ff_processor\x3B\r\n foreach($ff_processor-\x3Erows as $row)\r\n if ($row-\x3Ename==$name)\r\n return $row-\x3Epage\x3B\r\n return null\x3B\r\n} // ff_getPageByName
FF
ff_getPageByNameX
Get page # by element name
Gets the page number by the name of an element. \r\nTypically used to redirect to a certain page in a before form piece \r\nas \r\n\r\n $this-\x3Epage = ff_getPageByName(\x27elementname\x27)\x3B
function ff_getPageByName($name)\r\n{\r\n global $ff_processor\x3B\r\n foreach($ff_processor-\x3Erows as $row)\r\n if ($row-\x3Ename==$name)\r\n return $row-\x3Epage\x3B\r\n return null\x3B\r\n} // ff_getPageByName
FF
ff_getParam
Get GET/POST parameter
Direct replacement for mosGetParam. ff_getParam will attempt to filter \r\nout parameters that are targeted to another form on the same page.
function ff_getParam($name\x2C $default=null\x2C $mask=0)\r\n{\r\n global $ff_request\x3B\r\n if (substr($name\x2C0\x2C9)==\x27ff_param_\x27) {\r\n if (!isset($ff_request[$name])) return $default\x3B\r\n $val = $ff_request[$name]\x3B\r\n } else {\r\n if (!isset($_REQUEST[$name])) return $default\x3B\r\n $val = $_REQUEST[$name]\x3B\r\n } // if\r\n $dotrim = ($mask \x26 FF_NOTRIM)==0\x3B\r\n $dostrp = ($mask \x26 FF_ALLOWHTML)==0\x3B\r\n $addsla = ($mask \x26 FF_ALLOWRAW)==0 \x26\x26 !get_magic_quotes_gpc()\x3B\r\n $remsla = ($mask \x26 FF_ALLOWRAW)!=0 \x26\x26 get_magic_quotes_gpc()\x3B\r\n if (is_array($val)) {\r\n $cnt = count($val)\x3B\r\n for ($v = 0\x3B $v \x3C $cnt\x3B $v++)\r\n if (is_string($val[$v])) {\r\n if ($dotrim) $val[$v] = trim($val[$v])\x3B\r\n if ($dostrp) $val[$v] = strip_tags($val[$v])\x3B\r\n if ($addsla) $val[$v] = addslashes($val[$v])\x3B\r\n if ($remsla) $val[$v] = stripslashes($val[$v])\x3B\r\n } // if\r\n } else {\r\n if (is_string($val)) {\r\n if ($dotrim) $val = trim($val)\x3B\r\n if ($dostrp) $val = strip_tags($val)\x3B\r\n if ($addsla) $val = addslashes($val)\x3B\r\n if ($remsla) $val = stripslashes($val)\x3B\r\n } // if\r\n } // if\r\n return $val\x3B\r\n} // ff_getParam
FF
ff_getParam
Get GET/POST parameter
Direct replacement for mosGetParam. ff_getParam will attempt to filter \r\nout parameters that are targeted to another form on the same page.
function ff_getParam($name\x2C $default=null\x2C $mask=0)\r\n{\r\n global $ff_request\x3B\r\n if (substr($name\x2C0\x2C9)==\x27ff_param_\x27) {\r\n if (!isset($ff_request[$name])) return $default\x3B\r\n $val = $ff_request[$name]\x3B\r\n } else {\r\n if (!isset($_REQUEST[$name])) return $default\x3B\r\n $val = $_REQUEST[$name]\x3B\r\n } // if\r\n $dotrim = ($mask \x26 FF_NOTRIM)==0\x3B\r\n $dostrp = ($mask \x26 FF_ALLOWHTML)==0\x3B\r\n $addsla = ($mask \x26 FF_ALLOWRAW)==0 \x26\x26 !get_magic_quotes_gpc()\x3B\r\n $remsla = ($mask \x26 FF_ALLOWRAW)!=0 \x26\x26 get_magic_quotes_gpc()\x3B\r\n if (is_array($val)) {\r\n $cnt = count($val)\x3B\r\n for ($v = 0\x3B $v \x3C $cnt\x3B $v++)\r\n if (is_string($val[$v])) {\r\n if ($dotrim) $val[$v] = trim($val[$v])\x3B\r\n if ($dostrp) $val[$v] = strip_tags($val[$v])\x3B\r\n if ($addsla) $val[$v] = addslashes($val[$v])\x3B\r\n if ($remsla) $val[$v] = stripslashes($val[$v])\x3B\r\n } // if\r\n } else {\r\n if (is_string($val)) {\r\n if ($dotrim) $val = trim($val)\x3B\r\n if ($dostrp) $val = strip_tags($val)\x3B\r\n if ($addsla) $val = addslashes($val)\x3B\r\n if ($remsla) $val = stripslashes($val)\x3B\r\n } // if\r\n } // if\r\n return $val\x3B\r\n} // ff_getParam
FF
ff_getSubmit
Get submited data
Returns submitdata either as scalar\x2C array or list. In case of list the values\r\nare returned as a string with the values concatenated by comma.\r\n\r\nExamples:\r\n\r\n// Get as scalar: Optionally pass a default value as second parameter.\r\n// If no default is provided\x2C it will return NULL if no value was submitted\r\n\r\n $myval = ff_getSubmit(\x27myvar\x27)\x3B // return NULL if not submitted\r\n\r\n $myval = ff_getSubmit(\x27myvar\x27\x2C1)\x3B // return 1 if not submitted\r\n\r\n $myval = ff_getSubmit(\x27myvar\x27\x2C\x27foo\x27)\x3B // return \x27foo\x27 if not submitted\r\n\r\n ff_query(\r\n \x22insert into #__mytable(id\x2C name) \x22.\r\n \x22values (\x27\x22.\r\n ff_getSubmit(\x27id\x27).\x22\x2C \x22.\r\n ff_getSubmit(\x27name\x27\x2C\x27unknown\x27).\r\n \x22\x27)\x22\r\n )\x3B\r\n\r\n// Get as array: Pass FF_ARRAY as second Parameter\r\n\r\n $myarr = $ff_getSubmit(\x27myarr\x27\x2C FF_ARRAY)\x3B\r\n\r\n foreach ($myarr as $myval) ...\r\n\r\n// Get as list: Pass either FF_LIST\x2C FF_SLIST or FF_DLIST as 2nd parameter.\r\n\r\n // FF_LIST will return numeric data unquoted and strings in single quotes:\r\n // 1\x2C2\x2C\x27a\x27\x2C4\r\n\r\n // FF_SLIST will return all data single quoted:\r\n // \x271\x27\x2C\x272\x27\x2C\x27a\x27\x2C\x274\x27\r\n\r\n // FF_DLIST will return all data double quoted:\r\n // \x221\x22\x2C\x222\x22\x2C\x22a\x22\x2C\x224\x22\r\n\r\n ff_query(\r\n \x22delete from #__mytable \x22.\r\n \x22where id in (\x22.ff_getSubmit(\x27itemlist\x27\x2CFF_LIST).\x22)\x22\r\n )\x3B
function ff_getSubmit($name\x2C $default=null)\r\n{\r\n global $ff_processor\x3B\r\n\r\n switch ((string)$default) {\r\n case FF_ARRAY: $value = array()\x3B break\x3B\r\n case FF_LIST : \r\n case FF_SLIST:\r\n case FF_DLIST: $value = \x27\x27\x3B break\x3B\r\n default : $value = $default\x3B\r\n } // switch\r\n foreach ($ff_processor-\x3Esubmitdata as $data)\r\n if ($data[_FF_DATA_NAME]==$name) {\r\n $q = \x27\x27\x3B\r\n switch ((string)$default) {\r\n case FF_ARRAY:\r\n $value[] = $data[_FF_DATA_VALUE]\x3B\r\n break\x3B\r\n case FF_SLIST:\r\n $q = \x22\x27\x22\x3B\r\n case FF_DLIST:\r\n if ($q==\x27\x27) $q = \x27\x22\x27\x3B\r\n case FF_LIST:\r\n if ($q==\x27\x27 \x26\x26 !is_numeric($data[_FF_DATA_VALUE])) $q = \x22\x27\x22\x3B\r\n if ($value!=\x27\x27) $value.=\x27\x2C\x27\x3B\r\n $value .= $q.$data[_FF_DATA_VALUE].$q\x3B\r\n break\x3B\r\n default:\r\n return $data[_FF_DATA_VALUE]\x3B\r\n } // switch\r\n } // if\r\n return $value\x3B\r\n} // ff_getSubmit
FF
ff_getSubmit
Get submited data
Returns submitdata either as scalar\x2C array or list. In case of list the values\r\nare returned as a string with the values concatenated by comma.\r\n\r\nExamples:\r\n\r\n// Get as scalar: Optionally pass a default value as second parameter.\r\n// If no default is provided\x2C it will return NULL if no value was submitted\r\n\r\n $myval = ff_getSubmit(\x27myvar\x27)\x3B // return NULL if not submitted\r\n\r\n $myval = ff_getSubmit(\x27myvar\x27\x2C1)\x3B // return 1 if not submitted\r\n\r\n $myval = ff_getSubmit(\x27myvar\x27\x2C\x27foo\x27)\x3B // return \x27foo\x27 if not submitted\r\n\r\n ff_query(\r\n \x22insert into #__mytable(id\x2C name) \x22.\r\n \x22values (\x27\x22.\r\n ff_getSubmit(\x27id\x27).\x22\x2C \x22.\r\n ff_getSubmit(\x27name\x27\x2C\x27unknown\x27).\r\n \x22\x27)\x22\r\n )\x3B\r\n\r\n// Get as array: Pass FF_ARRAY as second Parameter\r\n\r\n $myarr = $ff_getSubmit(\x27myarr\x27\x2C FF_ARRAY)\x3B\r\n\r\n foreach ($myarr as $myval) ...\r\n\r\n// Get as list: Pass either FF_LIST\x2C FF_SLIST or FF_DLIST as 2nd parameter.\r\n\r\n // FF_LIST will return numeric data unquoted and strings in single quotes:\r\n // 1\x2C2\x2C\x27a\x27\x2C4\r\n\r\n // FF_SLIST will return all data single quoted:\r\n // \x271\x27\x2C\x272\x27\x2C\x27a\x27\x2C\x274\x27\r\n\r\n // FF_DLIST will return all data double quoted:\r\n // \x221\x22\x2C\x222\x22\x2C\x22a\x22\x2C\x224\x22\r\n\r\n ff_query(\r\n \x22delete from #__mytable \x22.\r\n \x22where id in (\x22.ff_getSubmit(\x27itemlist\x27\x2CFF_LIST).\x22)\x22\r\n )\x3B
function ff_getSubmit($name\x2C $default=null)\r\n{\r\n global $ff_processor\x3B\r\n\r\n switch ((string)$default) {\r\n case FF_ARRAY: $value = array()\x3B break\x3B\r\n case FF_LIST : \r\n case FF_SLIST:\r\n case FF_DLIST: $value = \x27\x27\x3B break\x3B\r\n default : $value = $default\x3B\r\n } // switch\r\n foreach ($ff_processor-\x3Esubmitdata as $data)\r\n if ($data[_FF_DATA_NAME]==$name) {\r\n $q = \x27\x27\x3B\r\n switch ((string)$default) {\r\n case FF_ARRAY:\r\n $value[] = $data[_FF_DATA_VALUE]\x3B\r\n break\x3B\r\n case FF_SLIST:\r\n $q = \x22\x27\x22\x3B\r\n case FF_DLIST:\r\n if ($q==\x27\x27) $q = \x27\x22\x27\x3B\r\n case FF_LIST:\r\n if ($q==\x27\x27 \x26\x26 !is_numeric($data[_FF_DATA_VALUE])) $q = \x22\x27\x22\x3B\r\n if ($value!=\x27\x27) $value.=\x27\x2C\x27\x3B\r\n $value .= $q.$data[_FF_DATA_VALUE].$q\x3B\r\n break\x3B\r\n default:\r\n return $data[_FF_DATA_VALUE]\x3B\r\n } // switch\r\n } // if\r\n return $value\x3B\r\n} // ff_getSubmit
FF
ff_impString
String import
Import string function: unescapes c-coded characters of a string
function ff_impString($text)\r\n{\r\n return impstring($text)\x3B\r\n} // ff_impString
FF
ff_impString
String import
Import string function: unescapes c-coded characters of a string
function ff_impString($text)\r\n{\r\n return impstring($text)\x3B\r\n} // ff_impString
FF
ff_InitLib
Init Library
Before Form
A collection of useful functions for use in form pieces. \r\n\r\nInclude by: \r\n\r\n $this-\x3EexecPieceByName(\x27ff_InitLib\x27)\x3B
//+trace high none\r\nif (!defined(\x27FF_DIE\x27)) $this-\x3EexecPieceByName(\x27ff_Constants\x27)\x3B\r\nif (!function_exists(\x27ff_expstring\x27)) $this-\x3EexecPieceByName(\x27ff_expstring\x27)\x3B\r\nif (!function_exists(\x27ff_makePageUrl\x27)) $this-\x3EexecPieceByName(\x27ff_makePageUrl\x27)\x3B\r\nif (!function_exists(\x27ff_makeFormUrl\x27)) $this-\x3EexecPieceByName(\x27ff_makeFormUrl\x27)\x3B\r\nif (!function_exists(\x27ff_makeSelfUrl\x27)) $this-\x3EexecPieceByName(\x27ff_makeSelfUrl\x27)\x3B\r\nif (!function_exists(\x27ff_die\x27)) $this-\x3EexecPieceByName(\x27ff_die\x27)\x3B\r\nif (!function_exists(\x27ff_dying\x27)) $this-\x3EexecPieceByName(\x27ff_dying\x27)\x3B\r\nif (!function_exists(\x27ff_redirect\x27)) $this-\x3EexecPieceByName(\x27ff_redirect\x27)\x3B\r\nif (!function_exists(\x27ff_redirectParent\x27)) $this-\x3EexecPieceByName(\x27ff_redirectParentX\x27)\x3B\r\nif (!function_exists(\x27ff_redirectPage\x27)) $this-\x3EexecPieceByName(\x27ff_redirectPage\x27)\x3B\r\nif (!function_exists(\x27ff_redirectForm\x27)) $this-\x3EexecPieceByName(\x27ff_redirectForm\x27)\x3B\r\nif (!function_exists(\x27ff_redirectSelf\x27)) $this-\x3EexecPieceByName(\x27ff_redirectSelf\x27)\x3B\r\nif (!function_exists(\x27ff_setChecked\x27)) $this-\x3EexecPieceByName(\x27ff_setCheckedX\x27)\x3B\r\nif (!function_exists(\x27ff_setSelected\x27)) $this-\x3EexecPieceByName(\x27ff_setSelectedX\x27)\x3B\r\nif (!function_exists(\x27ff_setValue\x27)) $this-\x3EexecPieceByName(\x27ff_setValueX\x27)\x3B\r\nif (!function_exists(\x27ff_getPageByName\x27)) $this-\x3EexecPieceByName(\x27ff_getPageByNameX\x27)\x3B\r\nif (!function_exists(\x27ff_getParam\x27)) $this-\x3EexecPieceByName(\x27ff_getParam\x27)\x3B\r\nif (!function_exists(\x27ff_getSubmit\x27)) $this-\x3EexecPieceByName(\x27ff_getSubmit\x27)\x3B\r\nif (!function_exists(\x27ff_impString\x27)) $this-\x3EexecPieceByName(\x27ff_impString\x27)\x3B\r\nif (!function_exists(\x27ff_expString\x27)) $this-\x3EexecPieceByName(\x27ff_expString\x27)\x3B\r\nif (!function_exists(\x27ff_securityImage\x27)) $this-\x3EexecPieceByName(\x27ff_securityImage\x27)\x3B\r\nif (!function_exists(\x27ff_select\x27)) $this-\x3EexecPieceByName(\x27ff_select\x27)\x3B\r\nif (!function_exists(\x27ff_selectValue\x27)) $this-\x3EexecPieceByName(\x27ff_selectValue\x27)\x3B\r\nif (!function_exists(\x27ff_query\x27)) $this-\x3EexecPieceByName(\x27ff_query\x27)\x3B\r\nif (!function_exists(\x27ff_markdown\x27)) $this-\x3EexecPieceByName(\x27ff_markdown\x27)\x3B
FF
ff_InitLib
Init Library
Before Form
A collection of useful functions for use in form pieces. \r\n\r\nInclude by: \r\n\r\n $this-\x3EexecPieceByName(\x27ff_InitLib\x27)\x3B
//+trace high none\r\nif (!defined(\x27FF_DIE\x27)) $this-\x3EexecPieceByName(\x27ff_Constants\x27)\x3B\r\nif (!function_exists(\x27ff_expstring\x27)) $this-\x3EexecPieceByName(\x27ff_expstring\x27)\x3B\r\nif (!function_exists(\x27ff_makePageUrl\x27)) $this-\x3EexecPieceByName(\x27ff_makePageUrl\x27)\x3B\r\nif (!function_exists(\x27ff_makeFormUrl\x27)) $this-\x3EexecPieceByName(\x27ff_makeFormUrl\x27)\x3B\r\nif (!function_exists(\x27ff_makeSelfUrl\x27)) $this-\x3EexecPieceByName(\x27ff_makeSelfUrl\x27)\x3B\r\nif (!function_exists(\x27ff_die\x27)) $this-\x3EexecPieceByName(\x27ff_die\x27)\x3B\r\nif (!function_exists(\x27ff_dying\x27)) $this-\x3EexecPieceByName(\x27ff_dying\x27)\x3B\r\nif (!function_exists(\x27ff_redirect\x27)) $this-\x3EexecPieceByName(\x27ff_redirect\x27)\x3B\r\nif (!function_exists(\x27ff_redirectParent\x27)) $this-\x3EexecPieceByName(\x27ff_redirectParentX\x27)\x3B\r\nif (!function_exists(\x27ff_redirectPage\x27)) $this-\x3EexecPieceByName(\x27ff_redirectPage\x27)\x3B\r\nif (!function_exists(\x27ff_redirectForm\x27)) $this-\x3EexecPieceByName(\x27ff_redirectForm\x27)\x3B\r\nif (!function_exists(\x27ff_redirectSelf\x27)) $this-\x3EexecPieceByName(\x27ff_redirectSelf\x27)\x3B\r\nif (!function_exists(\x27ff_setChecked\x27)) $this-\x3EexecPieceByName(\x27ff_setCheckedX\x27)\x3B\r\nif (!function_exists(\x27ff_setSelected\x27)) $this-\x3EexecPieceByName(\x27ff_setSelectedX\x27)\x3B\r\nif (!function_exists(\x27ff_setValue\x27)) $this-\x3EexecPieceByName(\x27ff_setValueX\x27)\x3B\r\nif (!function_exists(\x27ff_getPageByName\x27)) $this-\x3EexecPieceByName(\x27ff_getPageByNameX\x27)\x3B\r\nif (!function_exists(\x27ff_getParam\x27)) $this-\x3EexecPieceByName(\x27ff_getParam\x27)\x3B\r\nif (!function_exists(\x27ff_getSubmit\x27)) $this-\x3EexecPieceByName(\x27ff_getSubmit\x27)\x3B\r\nif (!function_exists(\x27ff_impString\x27)) $this-\x3EexecPieceByName(\x27ff_impString\x27)\x3B\r\nif (!function_exists(\x27ff_expString\x27)) $this-\x3EexecPieceByName(\x27ff_expString\x27)\x3B\r\nif (!function_exists(\x27ff_securityImage\x27)) $this-\x3EexecPieceByName(\x27ff_securityImage\x27)\x3B\r\nif (!function_exists(\x27ff_select\x27)) $this-\x3EexecPieceByName(\x27ff_select\x27)\x3B\r\nif (!function_exists(\x27ff_selectValue\x27)) $this-\x3EexecPieceByName(\x27ff_selectValue\x27)\x3B\r\nif (!function_exists(\x27ff_query\x27)) $this-\x3EexecPieceByName(\x27ff_query\x27)\x3B\r\nif (!function_exists(\x27ff_markdown\x27)) $this-\x3EexecPieceByName(\x27ff_markdown\x27)\x3B
FF
ff_makeFormUrl
Make URL to other form
Redirects to another facile form. \r\n\r\nCall: \r\n\r\n $url = ff_makeFormUrl($name\x2C $params = \x27\x27)\x3B\r\n\r\nExample:\r\n\r\n $url = ff_makeFormUrl(\r\n \x27OtherForm\x27\x2C \r\n \x27\x26ff_param_email=\x27.urlencode($email)\r\n )\x3B
function ff_makeFormUrl($name\x2C $params=\x27\x27)\r\n{\r\n global $ff_processor\x2C $ff_otherparams\x3B\r\n $url = \x27\x27\x3B\r\n switch ($ff_processor-\x3Erunmode) {\r\n case 2: // preview\r\n case 1: // backend\r\n $url .= \x27administrator/index2.php?option=com_breezingforms\x26act=run\x27.\r\n \x27\x26ff_name=\x27.urlencode($name)\x3B\r\n if ($ff_processor-\x3Einframe) $url .= \x27\x26ff_frame=1\x27\x3B\r\n if ($ff_processor-\x3Eborder) $url .= \x27\x26ff_border=1\x27\x3B\r\n break\x3B\r\n default: // frontend\r\n $url .= \x27index.php?ff_name=\x27.urlencode($name)\x3B\r\n if ($ff_otherparams[\x27option\x27] == \x27com_breezingforms\x27) {\r\n reset($ff_otherparams)\x3B\r\n while (list($prop\x2C $val) = each($ff_otherparams))\r\n $url .= \x27\x26\x27.urlencode($prop).\x27=\x27.urlencode($val)\x3B\r\n } else\r\n $url .= \x27\x26option=com_breezingforms\x27\x3B\r\n if ($ff_processor-\x3Etarget \x3E 1) $url .= \x27\x26ff_target=\x27.$ff_processor-\x3Etarget\x3B\r\n if ($ff_processor-\x3Einframe) $url .= \x27\x26ff_frame=1\x27\x3B\r\n if ($ff_processor-\x3Eborder) $url .= \x27\x26ff_border=1\x27\x3B\r\n if ($ff_processor-\x3Ealign !=1) $url .= \x27\x26ff_align=\x27.$ff_processor-\x3Ealign\x3B\r\n if ($ff_processor-\x3Etop\x3E0) $url .= \x27\x26ff_top=\x27.$ff_processor-\x3Etop\x3B\r\n } // switch\r\n return ff_makePageUrl($url. $params)\x3B\r\n} // ff_makeFormUrl
FF
ff_makeFormUrl
Make URL to other form
Redirects to another facile form. \r\n\r\nCall: \r\n\r\n $url = ff_makeFormUrl($name\x2C $params = \x27\x27)\x3B\r\n\r\nExample:\r\n\r\n $url = ff_makeFormUrl(\r\n \x27OtherForm\x27\x2C \r\n \x27\x26ff_param_email=\x27.urlencode($email)\r\n )\x3B
function ff_makeFormUrl($name\x2C $params=\x27\x27)\r\n{\r\n global $ff_processor\x2C $ff_otherparams\x3B\r\n $url = \x27\x27\x3B\r\n switch ($ff_processor-\x3Erunmode) {\r\n case 2: // preview\r\n case 1: // backend\r\n $url .= \x27administrator/index2.php?option=com_breezingforms\x26act=run\x27.\r\n \x27\x26ff_name=\x27.urlencode($name)\x3B\r\n if ($ff_processor-\x3Einframe) $url .= \x27\x26ff_frame=1\x27\x3B\r\n if ($ff_processor-\x3Eborder) $url .= \x27\x26ff_border=1\x27\x3B\r\n break\x3B\r\n default: // frontend\r\n $url .= \x27index.php?ff_name=\x27.urlencode($name)\x3B\r\n if ($ff_otherparams[\x27option\x27] == \x27com_breezingforms\x27) {\r\n reset($ff_otherparams)\x3B\r\n while (list($prop\x2C $val) = each($ff_otherparams))\r\n $url .= \x27\x26\x27.urlencode($prop).\x27=\x27.urlencode($val)\x3B\r\n } else\r\n $url .= \x27\x26option=com_breezingforms\x27\x3B\r\n if ($ff_processor-\x3Etarget \x3E 1) $url .= \x27\x26ff_target=\x27.$ff_processor-\x3Etarget\x3B\r\n if ($ff_processor-\x3Einframe) $url .= \x27\x26ff_frame=1\x27\x3B\r\n if ($ff_processor-\x3Eborder) $url .= \x27\x26ff_border=1\x27\x3B\r\n if ($ff_processor-\x3Ealign !=1) $url .= \x27\x26ff_align=\x27.$ff_processor-\x3Ealign\x3B\r\n if ($ff_processor-\x3Etop\x3E0) $url .= \x27\x26ff_top=\x27.$ff_processor-\x3Etop\x3B\r\n } // switch\r\n return ff_makePageUrl($url. $params)\x3B\r\n} // ff_makeFormUrl
FF
ff_makePageUrl
Make URL to other page
Builds an URL to another mambo page\r\n\r\nCall: \r\n\r\n $url = ff_makePageUrl($params = \x27\x27)\x3B\r\n\r\nExample:\r\n\r\n $url = ff_makePageUrl(\r\n \x27index.php?option=com_content\x26task=blogsection\x26id=0\x26Itemid=39\x27\r\n )\x3B
function ff_makePageUrl($params=\x27\x27)\r\n{\r\n $url = \x27{mossite}\x27\x3B\r\n if ($params != \x27\x27) {\r\n $len = strlen($url)\x3B\r\n if ($len \x3E 0 \x26\x26 $url[$len-1] != \x27/\x27) $url .= \x27/\x27\x3B\r\n $url .= $params\x3B\r\n } // if\r\n return $url\x3B\r\n} // ff_makePageUrl
FF
ff_makePageUrl
Make URL to other page
Builds an URL to another mambo page\r\n\r\nCall: \r\n\r\n $url = ff_makePageUrl($params = \x27\x27)\x3B\r\n\r\nExample:\r\n\r\n $url = ff_makePageUrl(\r\n \x27index.php?option=com_content\x26task=blogsection\x26id=0\x26Itemid=39\x27\r\n )\x3B
function ff_makePageUrl($params=\x27\x27)\r\n{\r\n $url = \x27{mossite}\x27\x3B\r\n if ($params != \x27\x27) {\r\n $len = strlen($url)\x3B\r\n if ($len \x3E 0 \x26\x26 $url{$len-1} != \x27/\x27) $url .= \x27/\x27\x3B\r\n $url .= $params\x3B\r\n } // if\r\n return $url\x3B\r\n} // ff_makePageUrl
FF
ff_makeSelfUrl
Make URL to same form
Make an URL to the same form. \r\n\r\nCall: \r\n\r\n $url = ff_makeSelfUrl($params = \x27\x27)\x3B\r\n\r\nExample:\r\n\r\n $url = ff_makeSelfUrl(\x27\x26ff_param_email=\x27.urlencode($email))\x3B
function ff_makeSelfUrl($params=\x27\x27)\r\n{\r\n global $ff_processor\x3B\r\n return ff_makeFormUrl($ff_processor-\x3Eformrow-\x3Ename\x2C $params)\x3B\r\n} // ff_makeSelfUrl
FF
ff_makeSelfUrl
Make URL to same form
Make an URL to the same form. \r\n\r\nCall: \r\n\r\n $url = ff_makeSelfUrl($params = \x27\x27)\x3B\r\n\r\nExample:\r\n\r\n $url = ff_makeSelfUrl(\x27\x26ff_param_email=\x27.urlencode($email))\x3B
function ff_makeSelfUrl($params=\x27\x27)\r\n{\r\n global $ff_processor\x3B\r\n return ff_makeFormUrl($ff_processor-\x3Eformrow-\x3Ename\x2C $params)\x3B\r\n} // ff_makeSelfUrl
FF
ff_mySetSelected
Set a select list option to *selected*
Before Form
Sets a select list option to selected. \r\n\r\nCall: \r\n\r\n ff_mySetSelected(\x27name\x27\x2C \x27value\x27\x2C \x27field\x27)\x3B //field can be label or value
function ff_mySetSelected($name\x2C $value\x2C $field=\x27value\x27)\r\n{\r\n global $ff_processor\x3B\r\n foreach($ff_processor-\x3Erows as $row) {\r\n if ($row-\x3Ename==$name){\r\n $row-\x3Edata2 = \x27\x27\x3B\r\n foreach($row-\x3EselectList as $var){\r\n if($var-\x3E{$field}==$value){\r\n $var-\x3Eselected = 1\x3B\r\n }else{\r\n $var-\x3Eselected = 0\x3B\r\n }\r\n $row-\x3Edata2 .= $var-\x3Eselected.\x22\x3B\x22.$var-\x3Elabel.\x22\x3B\x22.$var-\x3Evalue.\x22\x5Cn\x22\x3B\r\n }\r\n break\x3B\r\n }\r\n unset($row)\x3B\r\n }\r\n}
FF
ff_query
Non-select queries against db
Execute a simple db query.\r\n\r\nInclude by one of:\r\n\r\n $this-\x3EexecPieceByName(\x27ff_InitUtilities\x27)\x3B\r\n $this-\x3EexecPieceByName(\x27ff_SubmitUtilities\x27)\x3B\r\n if (!function_exists(\x27ff_query\x27)) $this-\x3EexecPieceByName(\x27ff_query\x27)\x3B\r\n\r\nCall syntax:\r\n\r\n [$newid = ] ff_query($sql [\x2C $insert = 0])\x3B\r\n\r\n $sql: Sql statement to call\r\n $insert: 1 = return key of auto column when inserting rows\r\n $newid: The key of the new row.
function ff_query($sql\x2C $insert=false\x2C $error=FF_DIE)\r\n{\r\n global $ff_processor\x3B\r\n $database = JFactory::getDBO()\x3B\r\n if ($ff_processor-\x3Edying \x26\x26 $error!=FF_IGNOREDIE) return -1\x3B\r\n $database-\x3EsetQuery($sql)\x3B\r\n $database-\x3Equery()\x3B\r\n if ($database-\x3EgetErrorNum()) {\r\n $dienow = $error==FF_DIE\x3B\r\n $error = $database-\x3Estderr()\x3B\r\n if ($dienow) ff_die($error)\x3B\r\n } else {\r\n $error = null\x3B\r\n if ($insert) return $database-\x3Einsertid()\x3B\r\n } // if\r\n return 0\x3B\r\n} // ff_query
FF
ff_query
Non-select queries against db
Execute a simple db query.\r\n\r\nInclude by one of:\r\n\r\n $this-\x3EexecPieceByName(\x27ff_InitUtilities\x27)\x3B\r\n $this-\x3EexecPieceByName(\x27ff_SubmitUtilities\x27)\x3B\r\n if (!function_exists(\x27ff_query\x27)) $this-\x3EexecPieceByName(\x27ff_query\x27)\x3B\r\n\r\nCall syntax:\r\n\r\n [$newid = ] ff_query($sql [\x2C $insert = 0])\x3B\r\n\r\n $sql: Sql statement to call\r\n $insert: 1 = return key of auto column when inserting rows\r\n $newid: The key of the new row.
function ff_query($sql\x2C $insert=false\x2C $error=FF_DIE)\r\n{\r\n global $ff_processor\x3B\r\n $database = JFactory::getDBO()\x3B\r\n if ($ff_processor-\x3Edying \x26\x26 $error!=FF_IGNOREDIE) return -1\x3B\r\n $database-\x3EsetQuery($sql)\x3B\r\n $database-\x3Equery()\x3B\r\n if ($database-\x3EgetErrorNum()) {\r\n $dienow = $error==FF_DIE\x3B\r\n $error = $database-\x3Estderr()\x3B\r\n if ($dienow) ff_die($error)\x3B\r\n } else {\r\n $error = null\x3B\r\n if ($insert) return $database-\x3Einsertid()\x3B\r\n } // if\r\n return 0\x3B\r\n} // ff_query
FF
ff_redirect
Basic redirection
Basic redirection routine supporting multiple targets and methods.\r\n\r\nCall:\r\n \r\nff_redirect($url [\x2C $target=\x27self\x27 \x2C $method=\x27post\x27])\r\n\r\n $url = The url to redirect to including the parameters appended.\r\n\r\n $target = \x27top\x27\x2C \x27parent\x27\x2C \x27self\x27 or \x27blank\x27\r\n\r\n \x27top\x27 = redirect to the top browser window\r\n \x27parent\x27 = redirect to the parent frame\r\n \x27self\x27 = redirect in the same frame (the default)\r\n \x27blank\x27 = redirect to a new browser window \r\n (blank works with post method only)\r\n\r\n $method = \x27post\x27 or \x27get\x27. The default is \x27post\x27.\r\n\r\n Example:\r\n\r\n ff_redirect(\r\n \x27http://mysite.net/index.php?option=xxx\x26Itemid=33\x27\x2C\r\n \x27top\x27\r\n )\x3B
function ff_redirect($url\x2C $target=\x27self\x27\x2C $method=\x27post\x27)\r\n{\r\n global $ff_processor\x2C $ff_request\x3B\r\n if ($ff_processor-\x3Edying) return\x3B\r\n ob_end_clean()\x3B //when debugging change this to ob_end_flush()\x3B\r\n switch (strtolower($method)) {\r\n case \x27get\x27: {\r\n switch (strtolower($target)) {\r\n case \x27top\x27 :\r\n case \x27parent\x27: break\x3B\r\n default : $target = \x27window\x27\x3B //window \x3E document\x2C because cross browser compat\x2C or so I read\r\n } // switch\r\n echo \x27\x3Cscript type=\x22text/javascript\x22\x3E\x27.nl().\r\n \x22onload=function() { \x22.$target.\x22.location.href=\x27\x22.$url.\x22\x27\x3B }\x22.nl().\r\n \x27\x3C/script\x3E\x27.nl().\r\n \x27\x3C/body\x3E\x27.nl()\x3B\r\n break\x3B\r\n } // url\r\n default: { // post\r\n $pos = strpos($url\x2C\x27?\x27)\x3B //find the location of \x27?\x27 after which get parameters usually start\r\n $ff_request = array()\x3B //create an array to set it later to hold get parameters in associative form\r\n if($pos){ //if query parameters are supplied\x2C the whole action becomes http://whatever.com/\r\n $action=substr($url\x2C 0\x2C $pos)\x3B\r\n }else{ //if no \x27?\x27 detected action is equal to supplied url\x2C which is a weak check because what if pretty url?\r\n $action = $url\x3B\r\n }\r\n switch (strtolower($target)) {\r\n case \x27blank\x27 : $target = \x27 target=\x22_blank\x22\x27\x3B break\x3B\r\n case \x27top\x27 : $target = \x27 target=\x22_top\x22\x27\x3B break\x3B\r\n case \x27parent\x27: $target = \x27 target=\x22_parent\x22\x27\x3B break\x3B\r\n default : $target = \x27 target=\x22_self\x22\x27\x3B\r\n } // switch\r\n $parts = parse_url($url)\x3B //$url still stores are query params\x2C so we parse them\r\n parse_str($parts[\x27query\x27]\x2C $ff_request)\x3B //get query part and store into ff_request (defined above)\r\n echo \x27\x3Cscript language=\x22javascript\x22 type=\x22text/javascript\x22\x3E\x27.nl(). //echo form and script that submits form on load (ajax maybe\x2C more \x27elegant\x27?)\r\n \x27\x3C!--\x27.nl().\r\n \x27onload = function() { document.ff_redirect.submit()\x3B }\x27.nl().\r\n \x27--\x3E\x27.nl().\r\n \x27\x3C/script\x3E\x27.nl().\r\n \x27\x3Cform action=\x22\x27.$action.\x27\x22 \x27.\r\n \x27method=\x22post\x22 \x27.\r\n \x27name=\x22ff_redirect\x22 id=\x22ff_redirect\x22 \x27.\r\n \x27enctype=\x22multipart/form-data\x22\x27.\r\n $target.\r\n \x27\x3E\x27.nl()\x3B\r\n foreach ($ff_request as $key =\x3E $value){ //print out input fields which store GET parameters\r\n echo \x27\x3Cinput type=\x22hidden\x22 name=\x22\x27.$key.\x27\x22 \x27.\x27value=\x22\x27.htmlentities(urldecode($value)).\x27\x22/\x3E\x27.nl()\x3B\r\n }\r\n echo \x27\x3C/form\x3E\x27.nl(). \x27\x3C/body\x3E\x27.nl()\x3B\r\n } // post\r\n } // switch\r\n exit\x3B\r\n} // ff_redirect
FF
ff_redirect
Basic redirection
Basic redirection routine supporting multiple targets and methods.\r\n\r\nCall:\r\n \r\nff_redirect($url [\x2C $target=\x27self\x27 \x2C $method=\x27post\x27])\r\n\r\n $url = The url to redirect to including the parameters appended.\r\n\r\n $target = \x27top\x27\x2C \x27parent\x27\x2C \x27self\x27 or \x27blank\x27\r\n\r\n \x27top\x27 = redirect to the top browser window\r\n \x27parent\x27 = redirect to the parent frame\r\n \x27self\x27 = redirect in the same frame (the default)\r\n \x27blank\x27 = redirect to a new browser window \r\n (blank works with post method only)\r\n\r\n $method = \x27post\x27 or \x27get\x27. The default is \x27post\x27.\r\n\r\n Example:\r\n\r\n ff_redirect(\r\n \x27http://mysite.net/index.php?option=xxx\x26Itemid=33\x27\x2C\r\n \x27top\x27\r\n )\x3B
function ff_redirect($url\x2C $target=\x27self\x27\x2C $method=\x27post\x27)\r\n{\r\n global $ff_processor\x2C $ff_request\x3B\r\n if ($ff_processor-\x3Edying) return\x3B\r\n\r\n ob_end_clean()\x3B\r\n switch (strtolower($method)) {\r\n case \x27get\x27: {\r\n switch (strtolower($target)) {\r\n case \x27top\x27 :\r\n case \x27parent\x27: break\x3B\r\n default : $target = \x27document\x27\x3B\r\n } // switch\r\n echo \x27\x3Cscript type=\x22text/javascript\x22\x3E\x27.nl().\r\n \x27\x3C!--\x27.nl().\r\n \x22onload=function() { \x22.$target.\x22.location.href=\x27\x22.$url.\x22\x27\x3B }\x22.nl().\r\n \x27--\x3E\x27.nl().\r\n \x27\x3C/script\x3E\x27.nl().\r\n \x27\x3C/body\x3E\x27.nl()\x3B\r\n break\x3B\r\n } // url\r\n default: { // post\r\n $pos = strpos($url\x2C\x27?\x27)\x3B\r\n $ff_request = array()\x3B\r\n if ($pos === false)\r\n $action = $url\x3B\r\n else {\r\n $action = substr($url\x2C0\x2C$pos)\x3B\r\n addRequestParams(substr($url\x2C $pos+1))\x3B\r\n } // if\r\n switch (strtolower($target)) {\r\n case \x27blank\x27 : $target = \x27 target=\x22_blank\x22\x27\x3B break\x3B\r\n case \x27top\x27 : $target = \x27 target=\x22_top\x22\x27\x3B break\x3B\r\n case \x27parent\x27: $target = \x27 target=\x22_parent\x22\x27\x3B break\x3B\r\n default : $target = \x27 target=\x22_self\x22\x27\x3B\r\n } // switch\r\n echo \x27\x3Cscript language=\x22javascript\x22 type=\x22text/javascript\x22\x3E\x27.nl().\r\n \x27\x3C!--\x27.nl().\r\n \x27onload = function() { document.ff_redirect.submit()\x3B }\x27.nl().\r\n \x27--\x3E\x27.nl().\r\n \x27\x3C/script\x3E\x27.nl().\r\n \x27\x3Cform action=\x22\x27.$action.\x27\x22 \x27.\r\n \x27method=\x22post\x22 \x27.\r\n \x27name=\x22ff_redirect\x22 id=\x22ff_redirect\x22 \x27.\r\n \x27enctype=\x22multipart/form-data\x22\x27.\r\n $target.\r\n \x27\x3E\x27.nl()\x3B\r\n while (list($prop\x2C $val) = each($ff_request))\r\n echo \x27\x3Cinput type=\x22hidden\x22 name=\x22\x27.$prop.\x27\x22 \x27.\r\n \x27value=\x22\x27.htmlentities(urldecode($val)).\x27\x22/\x3E\x27.nl()\x3B\r\n echo \x27\x3C/form\x3E\x27.nl().\r\n \x27\x3C/body\x3E\x27.nl()\x3B\r\n } // post\r\n } // switch\r\n exit\x3B\r\n} // ff_redirect
FF
ff_redirectForm
Redirect to other form
Redirects to another facile form. \r\n\r\nCall: \r\n\r\n ff_redirectForm($name\x2C $params = \x27\x27)\x3B\r\n\r\nExample:\r\n\r\n ff_redirectForm(\r\n $this\x2C \r\n \x27SecondForm\x27\x2C \r\n \x27\x26ff_param_email=\x27.urlencode($email)\r\n )\x3B
function ff_redirectForm($name\x2C $params=\x27\x27\x2C $method=\x27post\x27)\r\n{\r\n $url=ff_makeFormUrl($name\x2C $params)\x3B\r\n ff_redirectParent($url\x2C $method)\x3B\r\n} // ff_redirectForm
FF
ff_redirectForm
Redirect to other form
Redirects to another facile form. \r\n\r\nCall: \r\n\r\n ff_redirectForm($name\x2C $params = \x27\x27)\x3B\r\n\r\nExample:\r\n\r\n ff_redirectForm(\r\n $this\x2C \r\n \x27SecondForm\x27\x2C \r\n \x27\x26ff_param_email=\x27.urlencode($email)\r\n )\x3B
function ff_redirectForm($name\x2C $params=\x27\x27\x2C $method=\x27post\x27)\r\n{\r\n ff_redirectParent(ff_makeFormUrl($name\x2C $params)\x2C $method)\x3B\r\n} // ff_redirectForm
FF
ff_redirectPage
Redirect to other page
Redirects to another mambo page. \r\n\r\nCall: \r\n\r\n ff_redirectPage($params = \x27\x27)\x3B\r\n\r\nExample:\r\n\r\n ff_redirectPage(\r\n \x27index.php?option=com_content\x26task=blogsection\x26id=0\x26Itemid=39\x27\r\n )\x3B
function ff_redirectPage($params=\x27\x27\x2C $method=\x27post\x27)\r\n{\r\n ff_redirectParent(ff_makePageUrl($params)\x2C $method)\x3B\r\n} // ff_redirectPage
FF
ff_redirectPage
Redirect to other page
Redirects to another mambo page. \r\n\r\nCall: \r\n\r\n ff_redirectPage($params = \x27\x27)\x3B\r\n\r\nExample:\r\n\r\n ff_redirectPage(\r\n \x27index.php?option=com_content\x26task=blogsection\x26id=0\x26Itemid=39\x27\r\n )\x3B
function ff_redirectPage($params=\x27\x27\x2C $method=\x27post\x27)\r\n{\r\n ff_redirectParent(ff_makePageUrl($params)\x2C $method)\x3B\r\n} // ff_redirectPage
FF
ff_redirectParentX
Redirect to parent window
Redirects to the parent window when runing in iframe\x2C otherwise to self. \r\n\r\nff_redirectParent($url [\x2C $method=\x27post\x27])\r\n\r\n $url = The url to redirect to including the parameters appended.\r\n\r\n $method = \x27post\x27 or \x27url\x27. The default is \x27post\x27.\r\n\r\n Example:\r\n\r\n ff_redirectParent(\r\n \x27http://mysite.net/index.php?option=xxx\x26Itemid=33\x27\x2C\r\n \x27url\x27\r\n )\x3B
function ff_redirectParent($url\x2C $method = \x27post\x27)\r\n{\r\n global $ff_processor\x3B\r\n if ($ff_processor-\x3Einframe) $target = \x27parent\x27\x3B else $target = \x27self\x27\x3B \r\n ff_redirect($url\x2C $target\x2C $method)\x3B\r\n} // ff_redirectParent
FF
ff_redirectParentX
Redirect to parent window
Redirects to the parent window when runing in iframe\x2C otherwise to self. \r\n\r\nff_redirectParent($url [\x2C $method=\x27post\x27])\r\n\r\n $url = The url to redirect to including the parameters appended.\r\n\r\n $method = \x27post\x27 or \x27url\x27. The default is \x27post\x27.\r\n\r\n Example:\r\n\r\n ff_redirectParent(\r\n \x27http://mysite.net/index.php?option=xxx\x26Itemid=33\x27\x2C\r\n \x27url\x27\r\n )\x3B
function ff_redirectParent($url\x2C $method = \x27post\x27)\r\n{\r\n global $ff_processor\x3B\r\n if ($ff_processor-\x3Einframe) $target = \x27parent\x27\x3B else $target = \x27self\x27\x3B \r\n ff_redirect($url\x2C $target\x2C $method)\x3B\r\n} // ff_redirectParent
FF
ff_redirectSelf
Redirect to same form
Redirects to the same form. \r\n\r\nCall: \r\n\r\n ff_redirectSelf($params = \x27\x27)\x3B\r\n\r\nExample:\r\n\r\n ff_redirectSelf(\x27\x26ff_param_email=\x27.urlencode($email))\x3B
function ff_redirectSelf($params=\x27\x27\x2C $method=\x27post\x27)\r\n{\r\n ff_redirectParent(ff_makeSelfUrl($params)\x2C $method)\x3B\r\n} // ff_redirectSelf
FF
ff_redirectSelf
Redirect to same form
Redirects to the same form. \r\n\r\nCall: \r\n\r\n ff_redirectSelf($params = \x27\x27)\x3B\r\n\r\nExample:\r\n\r\n ff_redirectSelf(\x27\x26ff_param_email=\x27.urlencode($email))\x3B
function ff_redirectSelf($params=\x27\x27\x2C $method=\x27post\x27)\r\n{\r\n ff_redirectParent(ff_makeSelfUrl($params)\x2C $method)\x3B\r\n} // ff_redirectSelf
FF
ff_securityImage
Security Image
Create code to display the security image
global $ff_seccode\x3B\r\n\r\nif (!isset($this-\x3Erecord_id)) { $ff_seccode = null\x3B }\r\n\r\nfunction ff_securityImage()\r\n{\r\n global $ff_comsite\x2C $ff_seccode\x3B\r\n if (!isset($ff_seccode)) { \r\n mt_srand((double)microtime()*1000000)\x3B\r\n $ff_seccode = mt_rand(10000\x2C 99999)\x3B\r\n JFactory::getSession()-\x3Eset(\x27ff_seccode\x27\x2C $ff_seccode)\x3B\r\n } // if\r\n\r\n return \x27\x3Cimg src=\x22\x27.JURI::root().\x27ff_secimage.php?option=com_breezingforms\x26showSecImage=true\x22 title=\x22\x22 alt=\x22\x22 /\x3E\x27\x3B\r\n} // ff_securityImage
FF
ff_securityImage
Security Image
Create code to display the security image
global $ff_seccode\x3B\r\n\r\nif (!isset($this-\x3Erecord_id)) { $ff_seccode = null\x3B }\r\n\r\nfunction ff_securityImage()\r\n{\r\n global $ff_comsite\x2C $ff_seccode\x3B\r\n if (!isset($ff_seccode)) { \r\n mt_srand((double)microtime()*1000000)\x3B\r\n $ff_seccode = mt_rand(10000\x2C 99999)\x3B\r\n JFactory::getSession()-\x3Eset(\x27ff_seccode\x27\x2C $ff_seccode)\x3B\r\n } // if\r\n\r\n return \x27\x3Cimg src=\x22\x27.JURI::root().\x27ff_secimage.php?option=com_breezingforms\x26showSecImage=true\x22 title=\x22\x22 alt=\x22\x22 /\x3E\x27\x3B\r\n} // ff_securityImage
FF
ff_select
Select rows from db
Execute a select query\r\n\r\nInclude by one of:\r\n\r\n $this-\x3EexecPieceByName(\x27ff_InitUtilities\x27)\x3B\r\n $this-\x3EexecPieceByName(\x27ff_SubmitUtilities\x27)\x3B\r\n if (!function_exists(\x27ff_select\x27)) $this-\x3EexecPieceByName(\x27ff_select\x27)\x3B\r\n\r\nCall syntax:\r\n\r\n $rows = ff_select($sql)\x3B\r\n\r\n $sql: Sql SELECT-statement to call\r\n $rows: List of row objects
function ff_select($sql\x2C $error=FF_DIE)\r\n{\r\n $database = JFactory::getDBO()\x3B\r\n $database-\x3EsetQuery($sql)\x3B\r\n $rows = $database-\x3EloadObjectList()\x3B\r\n if ($database-\x3EgetErrorNum()) {\r\n $dienow = $error==FF_DIE\x3B\r\n $error = $database-\x3Estderr()\x3B\r\n $rows = array()\x3B\r\n if ($dienow) ff_die($error)\x3B\r\n } else\r\n $error = null\x3B\r\n return $rows\x3B\r\n} // ff_select
FF
ff_select
Select rows from db
Execute a select query\r\n\r\nInclude by one of:\r\n\r\n $this-\x3EexecPieceByName(\x27ff_InitUtilities\x27)\x3B\r\n $this-\x3EexecPieceByName(\x27ff_SubmitUtilities\x27)\x3B\r\n if (!function_exists(\x27ff_select\x27)) $this-\x3EexecPieceByName(\x27ff_select\x27)\x3B\r\n\r\nCall syntax:\r\n\r\n $rows = ff_select($sql)\x3B\r\n\r\n $sql: Sql SELECT-statement to call\r\n $rows: List of row objects
function ff_select($sql\x2C $error=FF_DIE)\r\n{\r\n $database = JFactory::getDBO()\x3B\r\n $database-\x3EsetQuery($sql)\x3B\r\n $rows = $database-\x3EloadObjectList()\x3B\r\n if ($database-\x3EgetErrorNum()) {\r\n $dienow = $error==FF_DIE\x3B\r\n $error = $database-\x3Estderr()\x3B\r\n $rows = array()\x3B\r\n if ($dienow) ff_die($error)\x3B\r\n } else\r\n $error = null\x3B\r\n return $rows\x3B\r\n} // ff_select
FF
ff_selectValue
Select single value from db
Execute query to read a single value\r\n\r\nInclude by one of:\r\n\r\n $this-\x3EexecPieceByName(\x27ff_InitUtilities\x27)\x3B\r\n $this-\x3EexecPieceByName(\x27ff_SubmitUtilities\x27)\x3B\r\n if (!function_exists(\x27ff_selectValue\x27)) $this-\x3EexecPieceByName(\x27ff_selectValue\x27)\x3B\r\n\r\nCall syntax:\r\n\r\n $value = ff_selectValue($sql)\x3B\r\n\r\n $sql: Sql SELECT-statement to call\r\n $value: The value returned by the database
function ff_selectValue($sql\x2C $def=null\x2C $error=FF_DIE)\r\n{\r\n $database = JFactory::getDBO()\x3B\r\n $database-\x3EsetQuery($sql)\x3B\r\n $value = $database-\x3EloadResult()\x3B\r\n if ($database-\x3EgetErrorNum()) {\r\n $dienow = $error==FF_DIE\x3B\r\n $error = $database-\x3Estderr()\x3B\r\n if ($dienow) ff_die($error)\x3B\r\n } else {\r\n $error = null\x3B\r\n if ($value) return $value\x3B\r\n } // if\r\n return $def\x3B\r\n} // ff_selectValue
FF
ff_selectValue
Select single value from db
Execute query to read a single value\r\n\r\nInclude by one of:\r\n\r\n $this-\x3EexecPieceByName(\x27ff_InitUtilities\x27)\x3B\r\n $this-\x3EexecPieceByName(\x27ff_SubmitUtilities\x27)\x3B\r\n if (!function_exists(\x27ff_selectValue\x27)) $this-\x3EexecPieceByName(\x27ff_selectValue\x27)\x3B\r\n\r\nCall syntax:\r\n\r\n $value = ff_selectValue($sql)\x3B\r\n\r\n $sql: Sql SELECT-statement to call\r\n $value: The value returned by the database
function ff_selectValue($sql\x2C $def=null\x2C $error=FF_DIE)\r\n{\r\n $database = JFactory::getDBO()\x3B\r\n $database-\x3EsetQuery($sql)\x3B\r\n $value = $database-\x3EloadResult()\x3B\r\n if ($database-\x3EgetErrorNum()) {\r\n $dienow = $error==FF_DIE\x3B\r\n $error = $database-\x3Estderr()\x3B\r\n if ($dienow) ff_die($error)\x3B\r\n } else {\r\n $error = null\x3B\r\n if ($value) return $value\x3B\r\n } // if\r\n return $def\x3B\r\n} // ff_selectValue
FF
ff_setCheckedX
Set checkbox/radiobutton checked
Set a radio button or checkbox checked. \r\n\r\nCall: \r\n\r\n ff_setChecked(\x27name\x27\x2C \x27value\x27)\x3B
function ff_setChecked($name\x2C $value)\r\n{\r\n global $ff_processor\x3B\r\n for ($r = 0\x3B $r \x3C $ff_processor-\x3Erowcount\x3B $r++) {\r\n $row =\x26 $ff_processor-\x3Erows[$r]\x3B\r\n if ($row-\x3Ename==$name \x26\x26 $row-\x3Edata1==$value)\r\n $row-\x3Eflag1 = 1\x3B\r\n unset($row)\x3B\r\n } // for\r\n} // ff_setChecked
FF
ff_setCheckedX
Set checkbox/radiobutton checked
Set a radio button or checkbox checked. \r\n\r\nCall: \r\n\r\n ff_setChecked(\x27name\x27\x2C \x27value\x27)\x3B
function ff_setChecked($name\x2C $value)\r\n{\r\n global $ff_processor\x3B\r\n for ($r = 0\x3B $r \x3C $ff_processor-\x3Erowcount\x3B $r++) {\r\n $row =\x26 $ff_processor-\x3Erows[$r]\x3B\r\n if ($row-\x3Ename==$name \x26\x26 $row-\x3Edata1==$value)\r\n $row-\x3Eflag1 = 1\x3B\r\n unset($row)\x3B\r\n } // for\r\n} // ff_setChecked
FF
ff_setSelectedX
Set a select list option to *selected*
Sets a select list option to selected. \r\n\r\nCall: \r\n\r\n ff_setSelected(\x27name\x27\x2C \x27value\x27)\x3B
function ff_setSelected($name\x2C $value)\r\n{\r\n global $ff_processor\x3B\r\n for ($r = 0\x3B $r \x3C $ff_processor-\x3Erowcount\x3B $r++) {\r\n $row =\x26 $ff_processor-\x3Erows[$r]\x3B\r\n if ($row-\x3Ename==$name)\r\n $row-\x3Edata2 =\r\n preg_replace(\r\n \x27/(^|\x5Cr\x5Cn|\x5Cn)(0|1)\x3B([^\x3B]*)\x3B(\x27.$value.\x27)($|\x5Cr\x5Cn|\x5Cn)/\x27\x2C\r\n \x27${1}1\x3B${3}\x3B${4}${5}\x27\x2C\r\n $row-\x3Edata2\r\n )\x3B\r\n unset($row)\x3B\r\n } // for\r\n} // ff_setSelected
FF
ff_setSelectedX
Set a select list option to *selected*
Sets a select list option to selected. \r\n\r\nCall: \r\n\r\n ff_setSelected(\x27name\x27\x2C \x27value\x27)\x3B
function ff_setSelected($name\x2C $value)\r\n{\r\n global $ff_processor\x3B\r\n for ($r = 0\x3B $r \x3C $ff_processor-\x3Erowcount\x3B $r++) {\r\n $row =\x26 $ff_processor-\x3Erows[$r]\x3B\r\n if ($row-\x3Ename==$name)\r\n $row-\x3Edata2 =\r\n preg_replace(\r\n \x27/(^|\x5Cr\x5Cn|\x5Cn)(0|1)\x3B([^\x3B]*)\x3B(\x27.$value.\x27)($|\x5Cr\x5Cn|\x5Cn)/\x27\x2C\r\n \x27${1}1\x3B${3}\x3B${4}${5}\x27\x2C\r\n $row-\x3Edata2\r\n )\x3B\r\n unset($row)\x3B\r\n } // for\r\n} // ff_setSelected
FF
ff_setValueX
Set text\x2C textarea\x2C hidden value
Set value of a Static Text\x2C Text\x2C Textarea or Hidden Input. \r\n\r\nCall: \r\n\r\n ff_setValue(\x27name\x27\x2C \x27value\x27)\x3B
function ff_setValue($name\x2C $value)\r\n{\r\n global $ff_processor\x3B\r\n for ($r = 0\x3B $r \x3C $ff_processor-\x3Erowcount\x3B $r++) {\r\n $row =\x26 $ff_processor-\x3Erows[$r]\x3B\r\n if ($row-\x3Ename==$name)\r\n $row-\x3Edata1 = $value\x3B\r\n unset($row)\x3B\r\n } // for\r\n} // ff_setValue
FF
ff_setValueX
Set text\x2C textarea\x2C hidden value
Set value of a Static Text\x2C Text\x2C Textarea or Hidden Input. \r\n\r\nCall: \r\n\r\n ff_setValue(\x27name\x27\x2C \x27value\x27)\x3B
function ff_setValue($name\x2C $value)\r\n{\r\n global $ff_processor\x3B\r\n for ($r = 0\x3B $r \x3C $ff_processor-\x3Erowcount\x3B $r++) {\r\n $row =\x26 $ff_processor-\x3Erows[$r]\x3B\r\n if ($row-\x3Ename==$name)\r\n $row-\x3Edata1 = $value\x3B\r\n unset($row)\x3B\r\n } // for\r\n} // ff_setValue
FF
Markdown
Original Markdown Processor
Converts text marked up by \x27Markdown\x27 into HTML.\r\n\r\nPlease use ff_markdown() in forms instead of Markdown()
#\r\n# Markdown - A text-to-HTML conversion tool for web writers\r\n#\r\n# Copyright (c) 2004-2005 John Gruber\r\n# \x3Chttp://daringfireball.net/projects/markdown/\x3E\r\n#\r\n# Copyright (c) 2004-2005 Michel Fortin - PHP Port\r\n# \x3Chttp://www.michelf.com/projects/php-markdown/\x3E\r\n#\r\n\r\nglobal $MarkdownPHPVersion\x2C $MarkdownSyntaxVersion\x2C\r\n $md_empty_element_suffix\x2C $md_tab_width\x2C\r\n $md_nested_brackets_depth\x2C $md_nested_brackets\x2C\r\n $md_escape_table\x2C $md_backslash_escape_table\x2C\r\n $md_list_level\x3B\r\n\r\n$MarkdownPHPVersion = \x271.0.1b\x27\x3B # Mon 6 Jun 2005\r\n$MarkdownSyntaxVersion = \x271.0.1\x27\x3B # Sun 12 Dec 2004\r\n\r\n\r\n#\r\n# Global default settings:\r\n#\r\n$md_empty_element_suffix = \x22 /\x3E\x22\x3B # Change to \x22\x3E\x22 for HTML output\r\n$md_tab_width = 4\x3B\r\n\r\n#\r\n# WordPress settings:\r\n#\r\n$md_wp_posts = true\x3B # Set to false to remove Markdown from posts.\r\n$md_wp_comments = true\x3B # Set to false to remove Markdown from comments.\r\n\r\n\r\n# -- WordPress Plugin Interface -----------------------------------------------\r\n/*\r\nPlugin Name: Markdown\r\nPlugin URI: http://www.michelf.com/projects/php-markdown/\r\nDescription: \x3Ca href=\x22http://daringfireball.net/projects/markdown/syntax\x22\x3EMarkdown syntax\x3C/a\x3E allows you to write using an easy-to-read\x2C easy-to-write plain text format. Based on the original Perl version by \x3Ca href=\x22http://daringfireball.net/\x22\x3EJohn Gruber\x3C/a\x3E. \x3Ca href=\x22http://www.michelf.com/projects/php-markdown/\x22\x3EMore...\x3C/a\x3E\r\nVersion: 1.0.1b\r\nAuthor: Michel Fortin\r\nAuthor URI: http://www.michelf.com/\r\n*/\r\nif (isset($wp_version)) {\r\n # More details about how it works here:\r\n # \x3Chttp://www.michelf.com/weblog/2005/wordpress-text-flow-vs-markdown/\x3E\r\n\r\n # Post content and excerpts\r\n if ($md_wp_posts) {\r\n remove_filter(\x27the_content\x27\x2C \x27wpautop\x27)\x3B\r\n remove_filter(\x27the_excerpt\x27\x2C \x27wpautop\x27)\x3B\r\n add_filter(\x27the_content\x27\x2C \x27Markdown\x27\x2C 6)\x3B\r\n add_filter(\x27get_the_excerpt\x27\x2C \x27Markdown\x27\x2C 6)\x3B\r\n add_filter(\x27get_the_excerpt\x27\x2C \x27trim\x27\x2C 7)\x3B\r\n add_filter(\x27the_excerpt\x27\x2C \x27md_add_p\x27)\x3B\r\n add_filter(\x27the_excerpt_rss\x27\x2C \x27md_strip_p\x27)\x3B\r\n\r\n remove_filter(\x27content_save_pre\x27\x2C \x27balanceTags\x27\x2C 50)\x3B\r\n remove_filter(\x27excerpt_save_pre\x27\x2C \x27balanceTags\x27\x2C 50)\x3B\r\n add_filter(\x27the_content\x27\x2C \x27balanceTags\x27\x2C 50)\x3B\r\n add_filter(\x27get_the_excerpt\x27\x2C \x27balanceTags\x27\x2C 9)\x3B\r\n\r\n function md_add_p($text) {\r\n if (strlen($text) == 0) return\x3B\r\n if (strcasecmp(substr($text\x2C -3)\x2C \x27\x3Cp\x3E\x27) == 0) return $text\x3B\r\n return \x27\x3Cp\x3E\x27.$text.\x27\x3C/p\x3E\x27\x3B\r\n }\r\n function md_strip_p($t) { return preg_replace(\x27{\x3C/?[pP]\x3E}\x27\x2C \x27\x27\x2C $t)\x3B }\r\n }\r\n\r\n # Comments\r\n if ($md_wp_comments) {\r\n remove_filter(\x27comment_text\x27\x2C \x27wpautop\x27)\x3B\r\n remove_filter(\x27comment_text\x27\x2C \x27make_clickable\x27)\x3B\r\n add_filter(\x27pre_comment_content\x27\x2C \x27Markdown\x27\x2C 6)\x3B\r\n add_filter(\x27pre_comment_content\x27\x2C \x27md_hide_tags\x27\x2C 8)\x3B\r\n add_filter(\x27pre_comment_content\x27\x2C \x27md_show_tags\x27\x2C 12)\x3B\r\n add_filter(\x27get_comment_text\x27\x2C \x27Markdown\x27\x2C 6)\x3B\r\n add_filter(\x27get_comment_excerpt\x27\x2C \x27Markdown\x27\x2C 6)\x3B\r\n add_filter(\x27get_comment_excerpt\x27\x2C \x27md_strip_p\x27\x2C 7)\x3B\r\n\r\n global $md_hidden_tags\x3B\r\n $md_hidden_tags = array(\r\n \x27\x3Cp\x3E\x27 =\x3E md5(\x27\x3Cp\x3E\x27)\x2C \x27\x3C/p\x3E\x27 =\x3E md5(\x27\x3C/p\x3E\x27)\x2C\r\n \x27\x3Cpre\x3E\x27 =\x3E md5(\x27\x3Cpre\x3E\x27)\x2C \x27\x3C/pre\x3E\x27=\x3E md5(\x27\x3C/pre\x3E\x27)\x2C\r\n \x27\x3Col\x3E\x27 =\x3E md5(\x27\x3Col\x3E\x27)\x2C \x27\x3C/ol\x3E\x27 =\x3E md5(\x27\x3C/ol\x3E\x27)\x2C\r\n \x27\x3Cul\x3E\x27 =\x3E md5(\x27\x3Cul\x3E\x27)\x2C \x27\x3C/ul\x3E\x27 =\x3E md5(\x27\x3C/ul\x3E\x27)\x2C\r\n \x27\x3Cli\x3E\x27 =\x3E md5(\x27\x3Cli\x3E\x27)\x2C \x27\x3C/li\x3E\x27 =\x3E md5(\x27\x3C/li\x3E\x27)\x2C\r\n )\x3B\r\n\r\n function md_hide_tags($text) {\r\n global $md_hidden_tags\x3B\r\n return str_replace(array_keys($md_hidden_tags)\x2C\r\n array_values($md_hidden_tags)\x2C $text)\x3B\r\n }\r\n function md_show_tags($text) {\r\n global $md_hidden_tags\x3B\r\n return str_replace(array_values($md_hidden_tags)\x2C\r\n array_keys($md_hidden_tags)\x2C $text)\x3B\r\n }\r\n }\r\n}\r\n\r\n\r\n# -- bBlog Plugin Info --------------------------------------------------------\r\nfunction identify_modifier_markdown() {\r\n global $MarkdownPHPVersion\x3B\r\n return array(\r\n \x27name\x27 =\x3E \x27markdown\x27\x2C\r\n \x27type\x27 =\x3E \x27modifier\x27\x2C\r\n \x27nicename\x27 =\x3E \x27Markdown\x27\x2C\r\n \x27description\x27 =\x3E \x27A text-to-HTML conversion tool for web writers\x27\x2C\r\n \x27authors\x27 =\x3E \x27Michel Fortin and John Gruber\x27\x2C\r\n \x27licence\x27 =\x3E \x27GPL\x27\x2C\r\n \x27version\x27 =\x3E $MarkdownPHPVersion\x2C\r\n \x27help\x27 =\x3E \x27\x3Ca href=\x22http://daringfireball.net/projects/markdown/syntax\x22\x3EMarkdown syntax\x3C/a\x3E allows you to write using an easy-to-read\x2C easy-to-write plain text format. Based on the original Perl version by \x3Ca href=\x22http://daringfireball.net/\x22\x3EJohn Gruber\x3C/a\x3E. \x3Ca href=\x22http://www.michelf.com/projects/php-markdown/\x22\x3EMore...\x3C/a\x3E\x27\r\n )\x3B\r\n}\r\n\r\n# -- Smarty Modifier Interface ------------------------------------------------\r\nfunction smarty_modifier_markdown($text) {\r\n return Markdown($text)\x3B\r\n}\r\n\r\n# -- Textile Compatibility Mode -----------------------------------------------\r\n# Rename this file to \x22classTextile.php\x22 and it can replace Textile anywhere.\r\nif (strcasecmp(substr(__FILE__\x2C -16)\x2C \x22classTextile.php\x22) == 0) {\r\n # Try to include PHP SmartyPants. Should be in the same directory.\r\n @include_once \x27smartypants.php\x27\x3B\r\n # Fake Textile class. It calls Markdown instead.\r\n class Textile {\r\n function TextileThis($text\x2C $lite=\x27\x27\x2C $encode=\x27\x27\x2C $noimage=\x27\x27\x2C $strict=\x27\x27) {\r\n if ($lite == \x27\x27 \x26\x26 $encode == \x27\x27) $text = Markdown($text)\x3B\r\n if (function_exists(\x27SmartyPants\x27)) $text = SmartyPants($text)\x3B\r\n return $text\x3B\r\n }\r\n }\r\n}\r\n\r\n\r\n\r\n#\r\n# Globals:\r\n#\r\n\r\n# Regex to match balanced [brackets].\r\n# Needed to insert a maximum bracked depth while converting to PHP.\r\n$md_nested_brackets_depth = 6\x3B\r\n$md_nested_brackets =\r\n str_repeat(\x27(?\x3E[^\x5C[\x5C]]+|\x5C[\x27\x2C $md_nested_brackets_depth).\r\n str_repeat(\x27\x5C])*\x27\x2C $md_nested_brackets_depth)\x3B\r\n\r\n# Table of hash values for escaped characters:\r\n$md_escape_table = array(\r\n \x22\x5C\x5C\x22 =\x3E md5(\x22\x5C\x5C\x22)\x2C\r\n \x22`\x22 =\x3E md5(\x22`\x22)\x2C\r\n \x22*\x22 =\x3E md5(\x22*\x22)\x2C\r\n \x22_\x22 =\x3E md5(\x22_\x22)\x2C\r\n \x22{\x22 =\x3E md5(\x22{\x22)\x2C\r\n \x22}\x22 =\x3E md5(\x22}\x22)\x2C\r\n \x22[\x22 =\x3E md5(\x22[\x22)\x2C\r\n \x22]\x22 =\x3E md5(\x22]\x22)\x2C\r\n \x22(\x22 =\x3E md5(\x22(\x22)\x2C\r\n \x22)\x22 =\x3E md5(\x22)\x22)\x2C\r\n \x22\x3E\x22 =\x3E md5(\x22\x3E\x22)\x2C\r\n \x22#\x22 =\x3E md5(\x22#\x22)\x2C\r\n \x22+\x22 =\x3E md5(\x22+\x22)\x2C\r\n \x22-\x22 =\x3E md5(\x22-\x22)\x2C\r\n \x22.\x22 =\x3E md5(\x22.\x22)\x2C\r\n \x22!\x22 =\x3E md5(\x22!\x22)\r\n)\x3B\r\n# Create an identical table but for escaped characters.\r\n$md_backslash_escape_table\x3B\r\nforeach ($md_escape_table as $key =\x3E $char)\r\n $md_backslash_escape_table[\x22\x5C\x5C$key\x22] = $char\x3B\r\n\r\n\r\nfunction Markdown($text) {\r\n#\r\n# Main function. The order in which other subs are called here is\r\n# essential. Link and image substitutions need to happen before\r\n# _EscapeSpecialCharsWithinTagAttributes()\x2C so that any *\x27s or _\x27s in the \x3Ca\x3E\r\n# and \x3Cimg\x3E tags get encoded.\r\n#\r\n # Clear the global hashes. If we don\x27t clear these\x2C you get conflicts\r\n # from other articles when generating a page which contains more than\r\n # one article (e.g. an index page that shows the N most recent\r\n # articles):\r\n global $md_urls\x2C $md_titles\x2C $md_html_blocks\x3B\r\n $md_urls = array()\x3B\r\n $md_titles = array()\x3B\r\n $md_html_blocks = array()\x3B\r\n\r\n # Standardize line endings:\r\n # DOS to Unix and Mac to Unix\r\n $text = str_replace(array(\x22\x5Cr\x5Cn\x22\x2C \x22\x5Cr\x22)\x2C \x22\x5Cn\x22\x2C $text)\x3B\r\n\r\n # Make sure $text ends with a couple of newlines:\r\n $text .= \x22\x5Cn\x5Cn\x22\x3B\r\n\r\n # Convert all tabs to spaces.\r\n $text = _Detab($text)\x3B\r\n\r\n # Strip any lines consisting only of spaces and tabs.\r\n # This makes subsequent regexen easier to write\x2C because we can\r\n # match consecutive blank lines with /\x5Cn+/ instead of something\r\n # contorted like /[ \x5Ct]*\x5Cn+/ .\r\n $text = preg_replace(\x27/^[ \x5Ct]+$/m\x27\x2C \x27\x27\x2C $text)\x3B\r\n\r\n # Turn block-level HTML blocks into hash entries\r\n $text = _HashHTMLBlocks($text)\x3B\r\n\r\n # Strip link definitions\x2C store in hashes.\r\n $text = _StripLinkDefinitions($text)\x3B\r\n\r\n $text = _RunBlockGamut($text)\x3B\r\n\r\n $text = _UnescapeSpecialChars($text)\x3B\r\n\r\n return $text . \x22\x5Cn\x22\x3B\r\n}\r\n\r\n\r\nfunction _StripLinkDefinitions($text) {\r\n#\r\n# Strips link definitions from text\x2C stores the URLs and titles in\r\n# hash references.\r\n#\r\n global $md_tab_width\x3B\r\n $less_than_tab = $md_tab_width - 1\x3B\r\n\r\n # Link defs are in the form: ^[id]: url \x22optional title\x22\r\n $text = preg_replace_callback(\x27{\r\n ^[ ]{0\x2C\x27.$less_than_tab.\x27}\x5C[(.+)\x5C]: # id = $1\r\n [ \x5Ct]*\r\n \x5Cn? # maybe *one* newline\r\n [ \x5Ct]*\r\n \x3C?(\x5CS+?)\x3E? # url = $2\r\n [ \x5Ct]*\r\n \x5Cn? # maybe one newline\r\n [ \x5Ct]*\r\n (?:\r\n (?\x3C=\x5Cs) # lookbehind for whitespace\r\n [\x22(]\r\n (.+?) # title = $3\r\n [\x22)]\r\n [ \x5Ct]*\r\n )? # title is optional\r\n (?:\x5Cn+|\x5CZ)\r\n }xm\x27\x2C\r\n \x27_StripLinkDefinitions_callback\x27\x2C\r\n $text)\x3B\r\n return $text\x3B\r\n}\r\nfunction _StripLinkDefinitions_callback($matches) {\r\n global $md_urls\x2C $md_titles\x3B\r\n $link_id = strtolower($matches[1])\x3B\r\n $md_urls[$link_id] = _EncodeAmpsAndAngles($matches[2])\x3B\r\n if (isset($matches[3]))\r\n $md_titles[$link_id] = str_replace(\x27\x22\x27\x2C \x27\x26quot\x3B\x27\x2C $matches[3])\x3B\r\n return \x27\x27\x3B # String that will replace the block\r\n}\r\n\r\n\r\nfunction _HashHTMLBlocks($text) {\r\n global $md_tab_width\x3B\r\n $less_than_tab = $md_tab_width - 1\x3B\r\n\r\n # Hashify HTML blocks:\r\n # We only want to do this for block-level HTML tags\x2C such as headers\x2C\r\n # lists\x2C and tables. That\x27s because we still want to wrap \x3Cp\x3Es around\r\n # \x22paragraphs\x22 that are wrapped in non-block-level tags\x2C such as anchors\x2C\r\n # phrase emphasis\x2C and spans. The list of tags we\x27re looking for is\r\n # hard-coded:\r\n $block_tags_a = \x27p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|\x27.\r\n \x27script|noscript|form|fieldset|iframe|math|ins|del\x27\x3B\r\n $block_tags_b = \x27p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|\x27.\r\n \x27script|noscript|form|fieldset|iframe|math\x27\x3B\r\n\r\n # First\x2C look for nested blocks\x2C e.g.:\r\n # \x3Cdiv\x3E\r\n # \x3Cdiv\x3E\r\n # tags for inner block must be indented.\r\n # \x3C/div\x3E\r\n # \x3C/div\x3E\r\n #\r\n # The outermost tags must start at the left margin for this to match\x2C and\r\n # the inner nested divs must be indented.\r\n # We need to do this before the next\x2C more liberal match\x2C because the next\r\n # match will start at the first `\x3Cdiv\x3E` and stop at the first `\x3C/div\x3E`.\r\n $text = preg_replace_callback(\x22{\r\n ( # save in $1\r\n ^ # start of line (with /m)\r\n \x3C($block_tags_a) # start tag = $2\r\n \x5C\x5Cb # word break\r\n (.*\x5C\x5Cn)*? # any number of lines\x2C minimally matching\r\n \x3C/\x5C\x5C2\x3E # the matching end tag\r\n [ \x5C\x5Ct]* # trailing spaces/tabs\r\n (?=\x5C\x5Cn+|\x5C\x5CZ) # followed by a newline or end of document\r\n )\r\n }xm\x22\x2C\r\n \x27_HashHTMLBlocks_callback\x27\x2C\r\n $text)\x3B\r\n\r\n #\r\n # Now match more liberally\x2C simply from `\x5Cn\x3Ctag\x3E` to `\x3C/tag\x3E\x5Cn`\r\n #\r\n $text = preg_replace_callback(\x22{\r\n ( # save in $1\r\n ^ # start of line (with /m)\r\n \x3C($block_tags_b) # start tag = $2\r\n \x5C\x5Cb # word break\r\n (.*\x5C\x5Cn)*? # any number of lines\x2C minimally matching\r\n .*\x3C/\x5C\x5C2\x3E # the matching end tag\r\n [ \x5C\x5Ct]* # trailing spaces/tabs\r\n (?=\x5C\x5Cn+|\x5C\x5CZ) # followed by a newline or end of document\r\n )\r\n }xm\x22\x2C\r\n \x27_HashHTMLBlocks_callback\x27\x2C\r\n $text)\x3B\r\n\r\n # Special case just for \x3Chr /\x3E. It was easier to make a special case than\r\n # to make the other regex more complicated.\r\n $text = preg_replace_callback(\x27{\r\n (?:\r\n (?\x3C=\x5Cn\x5Cn) # Starting after a blank line\r\n | # or\r\n \x5CA\x5Cn? # the beginning of the doc\r\n )\r\n ( # save in $1\r\n [ ]{0\x2C\x27.$less_than_tab.\x27}\r\n \x3C(hr) # start tag = $2\r\n \x5Cb # word break\r\n ([^\x3C\x3E])*? #\r\n /?\x3E # the matching end tag\r\n [ \x5Ct]*\r\n (?=\x5Cn{2\x2C}|\x5CZ) # followed by a blank line or end of document\r\n )\r\n }x\x27\x2C\r\n \x27_HashHTMLBlocks_callback\x27\x2C\r\n $text)\x3B\r\n\r\n # Special case for standalone HTML comments:\r\n $text = preg_replace_callback(\x27{\r\n (?:\r\n (?\x3C=\x5Cn\x5Cn) # Starting after a blank line\r\n | # or\r\n \x5CA\x5Cn? # the beginning of the doc\r\n )\r\n ( # save in $1\r\n [ ]{0\x2C\x27.$less_than_tab.\x27}\r\n (?s:\r\n \x3C!\r\n (--.*?--\x5Cs*)+\r\n \x3E\r\n )\r\n [ \x5Ct]*\r\n (?=\x5Cn{2\x2C}|\x5CZ) # followed by a blank line or end of document\r\n )\r\n }x\x27\x2C\r\n \x27_HashHTMLBlocks_callback\x27\x2C\r\n $text)\x3B\r\n\r\n return $text\x3B\r\n}\r\nfunction _HashHTMLBlocks_callback($matches) {\r\n global $md_html_blocks\x3B\r\n $text = $matches[1]\x3B\r\n $key = md5($text)\x3B\r\n $md_html_blocks[$key] = $text\x3B\r\n return \x22\x5Cn\x5Cn$key\x5Cn\x5Cn\x22\x3B # String that will replace the block\r\n}\r\n\r\n\r\nfunction _RunBlockGamut($text) {\r\n#\r\n# These are all the transformations that form block-level\r\n# tags like paragraphs\x2C headers\x2C and list items.\r\n#\r\n global $md_empty_element_suffix\x3B\r\n\r\n $text = _DoHeaders($text)\x3B\r\n\r\n # Do Horizontal Rules:\r\n $text = preg_replace(\r\n array(\x27{^[ ]{0\x2C2}([ ]?\x5C*[ ]?){3\x2C}[ \x5Ct]*$}mx\x27\x2C\r\n \x27{^[ ]{0\x2C2}([ ]? -[ ]?){3\x2C}[ \x5Ct]*$}mx\x27\x2C\r\n \x27{^[ ]{0\x2C2}([ ]? _[ ]?){3\x2C}[ \x5Ct]*$}mx\x27)\x2C\r\n \x22\x5Cn\x3Chr$md_empty_element_suffix\x5Cn\x22\x2C\r\n $text)\x3B\r\n\r\n $text = _DoLists($text)\x3B\r\n $text = _DoCodeBlocks($text)\x3B\r\n $text = _DoBlockQuotes($text)\x3B\r\n\r\n # We already ran _HashHTMLBlocks() before\x2C in Markdown()\x2C but that\r\n # was to escape raw HTML in the original Markdown source. This time\x2C\r\n # we\x27re escaping the markup we\x27ve just created\x2C so that we don\x27t wrap\r\n # \x3Cp\x3E tags around block-level tags.\r\n $text = _HashHTMLBlocks($text)\x3B\r\n $text = _FormParagraphs($text)\x3B\r\n\r\n return $text\x3B\r\n}\r\n\r\n\r\nfunction _RunSpanGamut($text) {\r\n#\r\n# These are all the transformations that occur *within* block-level\r\n# tags like paragraphs\x2C headers\x2C and list items.\r\n#\r\n global $md_empty_element_suffix\x3B\r\n\r\n $text = _DoCodeSpans($text)\x3B\r\n\r\n $text = _EscapeSpecialChars($text)\x3B\r\n\r\n # Process anchor and image tags. Images must come first\x2C\r\n # because ![foo][f] looks like an anchor.\r\n $text = _DoImages($text)\x3B\r\n $text = _DoAnchors($text)\x3B\r\n\r\n # Make links out of things like `\x3Chttp://example.com/\x3E`\r\n # Must come after _DoAnchors()\x2C because you can use \x3C and \x3E\r\n # delimiters in inline links like [this](\x3Curl\x3E).\r\n $text = _DoAutoLinks($text)\x3B\r\n $text = _EncodeAmpsAndAngles($text)\x3B\r\n $text = _DoItalicsAndBold($text)\x3B\r\n\r\n # Do hard breaks:\r\n $text = preg_replace(\x27/ {2\x2C}\x5Cn/\x27\x2C \x22\x3Cbr$md_empty_element_suffix\x5Cn\x22\x2C $text)\x3B\r\n\r\n return $text\x3B\r\n}\r\n\r\n\r\nfunction _EscapeSpecialChars($text) {\r\n global $md_escape_table\x3B\r\n $tokens = _TokenizeHTML($text)\x3B\r\n\r\n $text = \x27\x27\x3B # rebuild $text from the tokens\r\n# $in_pre = 0\x3B # Keep track of when we\x27re inside \x3Cpre\x3E or \x3Ccode\x3E tags.\r\n# $tags_to_skip = \x22!\x3C(/?)(?:pre|code|kbd|script|math)[\x5Cs\x3E]!\x22\x3B\r\n\r\n foreach ($tokens as $cur_token) {\r\n if ($cur_token[0] == \x27tag\x27) {\r\n # Within tags\x2C encode * and _ so they don\x27t conflict\r\n # with their use in Markdown for italics and strong.\r\n # We\x27re replacing each such character with its\r\n # corresponding MD5 checksum value\x3B this is likely\r\n # overkill\x2C but it should prevent us from colliding\r\n # with the escape values by accident.\r\n $cur_token[1] = str_replace(array(\x27*\x27\x2C \x27_\x27)\x2C\r\n array($md_escape_table[\x27*\x27]\x2C $md_escape_table[\x27_\x27])\x2C\r\n $cur_token[1])\x3B\r\n $text .= $cur_token[1]\x3B\r\n } else {\r\n $t = $cur_token[1]\x3B\r\n $t = _EncodeBackslashEscapes($t)\x3B\r\n $text .= $t\x3B\r\n }\r\n }\r\n return $text\x3B\r\n}\r\n\r\n\r\nfunction _DoAnchors($text) {\r\n#\r\n# Turn Markdown link shortcuts into XHTML \x3Ca\x3E tags.\r\n#\r\n global $md_nested_brackets\x3B\r\n #\r\n # First\x2C handle reference-style links: [link text] [id]\r\n #\r\n $text = preg_replace_callback(\x22{\r\n ( # wrap whole match in $1\r\n \x5C\x5C[\r\n ($md_nested_brackets) # link text = $2\r\n \x5C\x5C]\r\n\r\n [ ]? # one optional space\r\n (?:\x5C\x5Cn[ ]*)? # one optional newline followed by spaces\r\n\r\n \x5C\x5C[\r\n (.*?) # id = $3\r\n \x5C\x5C]\r\n )\r\n }xs\x22\x2C\r\n \x27_DoAnchors_reference_callback\x27\x2C $text)\x3B\r\n\r\n #\r\n # Next\x2C inline-style links: [link text](url \x22optional title\x22)\r\n #\r\n $text = preg_replace_callback(\x22{\r\n ( # wrap whole match in $1\r\n \x5C\x5C[\r\n ($md_nested_brackets) # link text = $2\r\n \x5C\x5C]\r\n \x5C\x5C( # literal paren\r\n [ \x5C\x5Ct]*\r\n \x3C?(.*?)\x3E? # href = $3\r\n [ \x5C\x5Ct]*\r\n ( # $4\r\n ([\x27\x5C\x22]) # quote char = $5\r\n (.*?) # Title = $6\r\n \x5C\x5C5 # matching quote\r\n )? # title is optional\r\n \x5C\x5C)\r\n )\r\n }xs\x22\x2C\r\n \x27_DoAnchors_inline_callback\x27\x2C $text)\x3B\r\n\r\n return $text\x3B\r\n}\r\nfunction _DoAnchors_reference_callback($matches) {\r\n global $md_urls\x2C $md_titles\x2C $md_escape_table\x3B\r\n $whole_match = $matches[1]\x3B\r\n $link_text = $matches[2]\x3B\r\n $link_id = strtolower($matches[3])\x3B\r\n\r\n if ($link_id == \x22\x22) {\r\n $link_id = strtolower($link_text)\x3B # for shortcut links like [this][].\r\n }\r\n\r\n if (isset($md_urls[$link_id])) {\r\n $url = $md_urls[$link_id]\x3B\r\n # We\x27ve got to encode these to avoid conflicting with italics/bold.\r\n $url = str_replace(array(\x27*\x27\x2C \x27_\x27)\x2C\r\n array($md_escape_table[\x27*\x27]\x2C $md_escape_table[\x27_\x27])\x2C\r\n $url)\x3B\r\n $result = \x22\x3Ca href=\x5C\x22$url\x5C\x22\x22\x3B\r\n if ( isset( $md_titles[$link_id] ) ) {\r\n $title = $md_titles[$link_id]\x3B\r\n $title = str_replace(array(\x27*\x27\x2C \x27_\x27)\x2C\r\n array($md_escape_table[\x27*\x27]\x2C\r\n $md_escape_table[\x27_\x27])\x2C $title)\x3B\r\n $result .= \x22 title=\x5C\x22$title\x5C\x22\x22\x3B\r\n }\r\n $result .= \x22\x3E$link_text\x3C/a\x3E\x22\x3B\r\n }\r\n else {\r\n $result = $whole_match\x3B\r\n }\r\n return $result\x3B\r\n}\r\nfunction _DoAnchors_inline_callback($matches) {\r\n global $md_escape_table\x3B\r\n $whole_match = $matches[1]\x3B\r\n $link_text = $matches[2]\x3B\r\n $url = $matches[3]\x3B\r\n $title =\x26 $matches[6]\x3B\r\n\r\n # We\x27ve got to encode these to avoid conflicting with italics/bold.\r\n $url = str_replace(array(\x27*\x27\x2C \x27_\x27)\x2C\r\n array($md_escape_table[\x27*\x27]\x2C $md_escape_table[\x27_\x27])\x2C\r\n $url)\x3B\r\n $result = \x22\x3Ca href=\x5C\x22$url\x5C\x22\x22\x3B\r\n if (isset($title)) {\r\n $title = str_replace(\x27\x22\x27\x2C \x27\x26quot\x3B\x27\x2C $title)\x3B\r\n $title = str_replace(array(\x27*\x27\x2C \x27_\x27)\x2C\r\n array($md_escape_table[\x27*\x27]\x2C $md_escape_table[\x27_\x27])\x2C\r\n $title)\x3B\r\n $result .= \x22 title=\x5C\x22$title\x5C\x22\x22\x3B\r\n }\r\n\r\n $result .= \x22\x3E$link_text\x3C/a\x3E\x22\x3B\r\n\r\n return $result\x3B\r\n}\r\n\r\n\r\nfunction _DoImages($text) {\r\n#\r\n# Turn Markdown image shortcuts into \x3Cimg\x3E tags.\r\n#\r\n global $md_nested_brackets\x3B\r\n\r\n #\r\n # First\x2C handle reference-style labeled images: ![alt text][id]\r\n #\r\n $text = preg_replace_callback(\x27{\r\n ( # wrap whole match in $1\r\n !\x5C[\r\n (\x27.$md_nested_brackets.\x27) # alt text = $2\r\n \x5C]\r\n\r\n [ ]? # one optional space\r\n (?:\x5Cn[ ]*)? # one optional newline followed by spaces\r\n\r\n \x5C[\r\n (.*?) # id = $3\r\n \x5C]\r\n\r\n )\r\n }xs\x27\x2C\r\n \x27_DoImages_reference_callback\x27\x2C $text)\x3B\r\n\r\n #\r\n # Next\x2C handle inline images: ![alt text](url \x22optional title\x22)\r\n # Don\x27t forget: encode * and _\r\n\r\n $text = preg_replace_callback(\x27{\r\n ( # wrap whole match in $1\r\n !\x5C[\r\n (\x27.$md_nested_brackets.\x27) # alt text = $2\r\n \x5C]\r\n \x5C( # literal paren\r\n [ \x5Ct]*\r\n \x3C?(\x5CS+?)\x3E? # src url = $3\r\n [ \x5Ct]*\r\n ( # $4\r\n ([\x5C\x27\x22]) # quote char = $5\r\n (.*?) # title = $6\r\n \x5C5 # matching quote\r\n [ \x5Ct]*\r\n )? # title is optional\r\n \x5C)\r\n )\r\n }xs\x27\x2C\r\n \x27_DoImages_inline_callback\x27\x2C $text)\x3B\r\n\r\n return $text\x3B\r\n}\r\nfunction _DoImages_reference_callback($matches) {\r\n global $md_urls\x2C $md_titles\x2C $md_empty_element_suffix\x2C $md_escape_table\x3B\r\n $whole_match = $matches[1]\x3B\r\n $alt_text = $matches[2]\x3B\r\n $link_id = strtolower($matches[3])\x3B\r\n\r\n if ($link_id == \x22\x22) {\r\n $link_id = strtolower($alt_text)\x3B # for shortcut links like ![this][].\r\n }\r\n\r\n $alt_text = str_replace(\x27\x22\x27\x2C \x27\x26quot\x3B\x27\x2C $alt_text)\x3B\r\n if (isset($md_urls[$link_id])) {\r\n $url = $md_urls[$link_id]\x3B\r\n # We\x27ve got to encode these to avoid conflicting with italics/bold.\r\n $url = str_replace(array(\x27*\x27\x2C \x27_\x27)\x2C\r\n array($md_escape_table[\x27*\x27]\x2C $md_escape_table[\x27_\x27])\x2C\r\n $url)\x3B\r\n $result = \x22\x3Cimg src=\x5C\x22$url\x5C\x22 alt=\x5C\x22$alt_text\x5C\x22\x22\x3B\r\n if (isset($md_titles[$link_id])) {\r\n $title = $md_titles[$link_id]\x3B\r\n $title = str_replace(array(\x27*\x27\x2C \x27_\x27)\x2C\r\n array($md_escape_table[\x27*\x27]\x2C\r\n $md_escape_table[\x27_\x27])\x2C $title)\x3B\r\n $result .= \x22 title=\x5C\x22$title\x5C\x22\x22\x3B\r\n }\r\n $result .= $md_empty_element_suffix\x3B\r\n }\r\n else {\r\n # If there\x27s no such link ID\x2C leave intact:\r\n $result = $whole_match\x3B\r\n }\r\n\r\n return $result\x3B\r\n}\r\nfunction _DoImages_inline_callback($matches) {\r\n global $md_empty_element_suffix\x2C $md_escape_table\x3B\r\n $whole_match = $matches[1]\x3B\r\n $alt_text = $matches[2]\x3B\r\n $url = $matches[3]\x3B\r\n $title = \x27\x27\x3B\r\n if (isset($matches[6])) {\r\n $title = $matches[6]\x3B\r\n }\r\n\r\n $alt_text = str_replace(\x27\x22\x27\x2C \x27\x26quot\x3B\x27\x2C $alt_text)\x3B\r\n $title = str_replace(\x27\x22\x27\x2C \x27\x26quot\x3B\x27\x2C $title)\x3B\r\n # We\x27ve got to encode these to avoid conflicting with italics/bold.\r\n $url = str_replace(array(\x27*\x27\x2C \x27_\x27)\x2C\r\n array($md_escape_table[\x27*\x27]\x2C $md_escape_table[\x27_\x27])\x2C\r\n $url)\x3B\r\n $result = \x22\x3Cimg src=\x5C\x22$url\x5C\x22 alt=\x5C\x22$alt_text\x5C\x22\x22\x3B\r\n if (isset($title)) {\r\n $title = str_replace(array(\x27*\x27\x2C \x27_\x27)\x2C\r\n array($md_escape_table[\x27*\x27]\x2C $md_escape_table[\x27_\x27])\x2C\r\n $title)\x3B\r\n $result .= \x22 title=\x5C\x22$title\x5C\x22\x22\x3B # $title already quoted\r\n }\r\n $result .= $md_empty_element_suffix\x3B\r\n\r\n return $result\x3B\r\n}\r\n\r\n\r\nfunction _DoHeaders($text) {\r\n # Setext-style headers:\r\n # Header 1\r\n # ========\r\n #\r\n # Header 2\r\n # --------\r\n #\r\n $text = preg_replace(\r\n array(\x27{ ^(.+)[ \x5Ct]*\x5Cn=+[ \x5Ct]*\x5Cn+ }emx\x27\x2C\r\n \x27{ ^(.+)[ \x5Ct]*\x5Cn-+[ \x5Ct]*\x5Cn+ }emx\x27)\x2C\r\n array(\x22\x27\x3Ch1\x3E\x27._RunSpanGamut(_UnslashQuotes(\x27\x5C\x5C1\x27)).\x27\x3C/h1\x3E\x5Cn\x5Cn\x27\x22\x2C\r\n \x22\x27\x3Ch2\x3E\x27._RunSpanGamut(_UnslashQuotes(\x27\x5C\x5C1\x27)).\x27\x3C/h2\x3E\x5Cn\x5Cn\x27\x22)\x2C\r\n $text)\x3B\r\n\r\n # atx-style headers:\r\n # # Header 1\r\n # ## Header 2\r\n # ## Header 2 with closing hashes ##\r\n # ...\r\n # ###### Header 6\r\n #\r\n $text = preg_replace(\x22{\r\n ^(\x5C\x5C#{1\x2C6}) # $1 = string of #\x27s\r\n [ \x5C\x5Ct]*\r\n (.+?) # $2 = Header text\r\n [ \x5C\x5Ct]*\r\n \x5C\x5C#* # optional closing #\x27s (not counted)\r\n \x5C\x5Cn+\r\n }xme\x22\x2C\r\n \x22\x27\x3Ch\x27.strlen(\x27\x5C\x5C1\x27).\x27\x3E\x27._RunSpanGamut(_UnslashQuotes(\x27\x5C\x5C2\x27)).\x27\x3C/h\x27.strlen(\x27\x5C\x5C1\x27).\x27\x3E\x5Cn\x5Cn\x27\x22\x2C\r\n $text)\x3B\r\n\r\n return $text\x3B\r\n}\r\n\r\n\r\nfunction _DoLists($text) {\r\n#\r\n# Form HTML ordered (numbered) and unordered (bulleted) lists.\r\n#\r\n global $md_tab_width\x2C $md_list_level\x3B\r\n $less_than_tab = $md_tab_width - 1\x3B\r\n\r\n # Re-usable patterns to match list item bullets and number markers:\r\n $marker_ul = \x27[*+-]\x27\x3B\r\n $marker_ol = \x27\x5Cd+[.]\x27\x3B\r\n $marker_any = \x22(?:$marker_ul|$marker_ol)\x22\x3B\r\n\r\n $markers = array($marker_ul\x2C $marker_ol)\x3B\r\n\r\n foreach ($markers as $marker) {\r\n # Re-usable pattern to match any entirel ul or ol list:\r\n $whole_list = \x27\r\n ( # $1 = whole list\r\n ( # $2\r\n [ ]{0\x2C\x27.$less_than_tab.\x27}\r\n (\x27.$marker.\x27) # $3 = first list item marker\r\n [ \x5Ct]+\r\n )\r\n (?s:.+?)\r\n ( # $4\r\n \x5Cz\r\n |\r\n \x5Cn{2\x2C}\r\n (?=\x5CS)\r\n (?! # Negative lookahead for another list item marker\r\n [ \x5Ct]*\r\n \x27.$marker.\x27[ \x5Ct]+\r\n )\r\n )\r\n )\r\n \x27\x3B // mx\r\n\r\n # We use a different prefix before nested lists than top-level lists.\r\n # See extended comment in _ProcessListItems().\r\n\r\n if ($md_list_level) {\r\n $text = preg_replace_callback(\x27{\r\n ^\r\n \x27.$whole_list.\x27\r\n }mx\x27\x2C\r\n \x27_DoLists_callback_top\x27\x2C $text)\x3B\r\n }\r\n else {\r\n $text = preg_replace_callback(\x27{\r\n (?:(?\x3C=\x5Cn\x5Cn)|\x5CA\x5Cn?)\r\n \x27.$whole_list.\x27\r\n }mx\x27\x2C\r\n \x27_DoLists_callback_nested\x27\x2C $text)\x3B\r\n }\r\n }\r\n\r\n return $text\x3B\r\n}\r\nfunction _DoLists_callback_top($matches) {\r\n # Re-usable patterns to match list item bullets and number markers:\r\n $marker_ul = \x27[*+-]\x27\x3B\r\n $marker_ol = \x27\x5Cd+[.]\x27\x3B\r\n $marker_any = \x22(?:$marker_ul|$marker_ol)\x22\x3B\r\n\r\n $list = $matches[1]\x3B\r\n $list_type = preg_match(\x22/$marker_ul/\x22\x2C $matches[3]) ? \x22ul\x22 : \x22ol\x22\x3B\r\n\r\n $marker_any = ( $list_type == \x22ul\x22 ? $marker_ul : $marker_ol )\x3B\r\n\r\n # Turn double returns into triple returns\x2C so that we can make a\r\n # paragraph for the last item in a list\x2C if necessary:\r\n $list = preg_replace(\x22/\x5Cn{2\x2C}/\x22\x2C \x22\x5Cn\x5Cn\x5Cn\x22\x2C $list)\x3B\r\n $result = _ProcessListItems($list\x2C $marker_any)\x3B\r\n\r\n # Trim any trailing whitespace\x2C to put the closing `\x3C/$list_type\x3E`\r\n # up on the preceding line\x2C to get it past the current stupid\r\n # HTML block parser. This is a hack to work around the terrible\r\n # hack that is the HTML block parser.\r\n $result = rtrim($result)\x3B\r\n $result = \x22\x3C$list_type\x3E\x22 . $result . \x22\x3C/$list_type\x3E\x5Cn\x22\x3B\r\n return $result\x3B\r\n}\r\nfunction _DoLists_callback_nested($matches) {\r\n # Re-usable patterns to match list item bullets and number markers:\r\n $marker_ul = \x27[*+-]\x27\x3B\r\n $marker_ol = \x27\x5Cd+[.]\x27\x3B\r\n $marker_any = \x22(?:$marker_ul|$marker_ol)\x22\x3B\r\n\r\n $list = $matches[1]\x3B\r\n $list_type = preg_match(\x22/$marker_ul/\x22\x2C $matches[3]) ? \x22ul\x22 : \x22ol\x22\x3B\r\n\r\n $marker_any = ( $list_type == \x22ul\x22 ? $marker_ul : $marker_ol )\x3B\r\n\r\n # Turn double returns into triple returns\x2C so that we can make a\r\n # paragraph for the last item in a list\x2C if necessary:\r\n $list = preg_replace(\x22/\x5Cn{2\x2C}/\x22\x2C \x22\x5Cn\x5Cn\x5Cn\x22\x2C $list)\x3B\r\n $result = _ProcessListItems($list\x2C $marker_any)\x3B\r\n $result = \x22\x3C$list_type\x3E\x5Cn\x22 . $result . \x22\x3C/$list_type\x3E\x5Cn\x22\x3B\r\n return $result\x3B\r\n}\r\n\r\n\r\nfunction _ProcessListItems($list_str\x2C $marker_any) {\r\n#\r\n# Process the contents of a single ordered or unordered list\x2C splitting it\r\n# into individual list items.\r\n#\r\n global $md_list_level\x3B\r\n\r\n # The $md_list_level global keeps track of when we\x27re inside a list.\r\n # Each time we enter a list\x2C we increment it\x3B when we leave a list\x2C\r\n # we decrement. If it\x27s zero\x2C we\x27re not in a list anymore.\r\n #\r\n # We do this because when we\x27re not inside a list\x2C we want to treat\r\n # something like this:\r\n #\r\n # I recommend upgrading to version\r\n # 8. Oops\x2C now this line is treated\r\n # as a sub-list.\r\n #\r\n # As a single paragraph\x2C despite the fact that the second line starts\r\n # with a digit-period-space sequence.\r\n #\r\n # Whereas when we\x27re inside a list (or sub-list)\x2C that line will be\r\n # treated as the start of a sub-list. What a kludge\x2C huh? This is\r\n # an aspect of Markdown\x27s syntax that\x27s hard to parse perfectly\r\n # without resorting to mind-reading. Perhaps the solution is to\r\n # change the syntax rules such that sub-lists must start with a\r\n # starting cardinal number\x3B e.g. \x221.\x22 or \x22a.\x22.\r\n\r\n $md_list_level++\x3B\r\n\r\n # trim trailing blank lines:\r\n $list_str = preg_replace(\x22/\x5Cn{2\x2C}\x5C\x5Cz/\x22\x2C \x22\x5Cn\x22\x2C $list_str)\x3B\r\n\r\n $list_str = preg_replace_callback(\x27{\r\n (\x5Cn)? # leading line = $1\r\n (^[ \x5Ct]*) # leading whitespace = $2\r\n (\x27.$marker_any.\x27) [ \x5Ct]+ # list marker = $3\r\n ((?s:.+?) # list item text = $4\r\n (\x5Cn{1\x2C2}))\r\n (?= \x5Cn* (\x5Cz | \x5C2 (\x27.$marker_any.\x27) [ \x5Ct]+))\r\n }xm\x27\x2C\r\n \x27_ProcessListItems_callback\x27\x2C $list_str)\x3B\r\n\r\n $md_list_level--\x3B\r\n return $list_str\x3B\r\n}\r\nfunction _ProcessListItems_callback($matches) {\r\n $item = $matches[4]\x3B\r\n $leading_line =\x26 $matches[1]\x3B\r\n $leading_space =\x26 $matches[2]\x3B\r\n\r\n if ($leading_line || preg_match(\x27/\x5Cn{2\x2C}/\x27\x2C $item)) {\r\n $item = _RunBlockGamut(_Outdent($item))\x3B\r\n }\r\n else {\r\n # Recursion for sub-lists:\r\n $item = _DoLists(_Outdent($item))\x3B\r\n $item = preg_replace(\x27/\x5Cn+$/\x27\x2C \x27\x27\x2C $item)\x3B\r\n $item = _RunSpanGamut($item)\x3B\r\n }\r\n\r\n return \x22\x3Cli\x3E\x22 . $item . \x22\x3C/li\x3E\x5Cn\x22\x3B\r\n}\r\n\r\n\r\nfunction _DoCodeBlocks($text) {\r\n#\r\n# Process Markdown `\x3Cpre\x3E\x3Ccode\x3E` blocks.\r\n#\r\n global $md_tab_width\x3B\r\n $text = preg_replace_callback(\x22{\r\n (?:\x5C\x5Cn\x5C\x5Cn|\x5C\x5CA)\r\n ( # $1 = the code block -- one or more lines\x2C starting with a space/tab\r\n (?:\r\n (?:[ ]\x5C{$md_tab_width} | \x5C\x5Ct) # Lines must start with a tab or a tab-width of spaces\r\n .*\x5C\x5Cn+\r\n )+\r\n )\r\n ((?=^[ ]{0\x2C$md_tab_width}\x5C\x5CS)|\x5C\x5CZ) # Lookahead for non-space at line-start\x2C or end of doc\r\n }xm\x22\x2C\r\n \x27_DoCodeBlocks_callback\x27\x2C $text)\x3B\r\n\r\n return $text\x3B\r\n}\r\nfunction _DoCodeBlocks_callback($matches) {\r\n $codeblock = $matches[1]\x3B\r\n\r\n $codeblock = _EncodeCode(_Outdent($codeblock))\x3B\r\n// $codeblock = _Detab($codeblock)\x3B\r\n # trim leading newlines and trailing whitespace\r\n $codeblock = preg_replace(array(\x27/\x5CA\x5Cn+/\x27\x2C \x27/\x5Cs+\x5Cz/\x27)\x2C \x27\x27\x2C $codeblock)\x3B\r\n\r\n $result = \x22\x5Cn\x5Cn\x3Cpre\x3E\x3Ccode\x3E\x22 . $codeblock . \x22\x5Cn\x3C/code\x3E\x3C/pre\x3E\x5Cn\x5Cn\x22\x3B\r\n\r\n return $result\x3B\r\n}\r\n\r\n\r\nfunction _DoCodeSpans($text) {\r\n#\r\n# * Backtick quotes are used for \x3Ccode\x3E\x3C/code\x3E spans.\r\n#\r\n# * You can use multiple backticks as the delimiters if you want to\r\n# include literal backticks in the code span. So\x2C this input:\r\n#\r\n# Just type ``foo `bar` baz`` at the prompt.\r\n#\r\n# Will translate to:\r\n#\r\n# \x3Cp\x3EJust type \x3Ccode\x3Efoo `bar` baz\x3C/code\x3E at the prompt.\x3C/p\x3E\r\n#\r\n# There\x27s no arbitrary limit to the number of backticks you\r\n# can use as delimters. If you need three consecutive backticks\r\n# in your code\x2C use four for delimiters\x2C etc.\r\n#\r\n# * You can use spaces to get literal backticks at the edges:\r\n#\r\n# ... type `` `bar` `` ...\r\n#\r\n# Turns to:\r\n#\r\n# ... type \x3Ccode\x3E`bar`\x3C/code\x3E ...\r\n#\r\n $text = preg_replace_callback(\x27@\r\n (?\x3C!\x5C\x5C\x5C) # Character before opening ` can\x5C\x27t be a backslash\r\n (`+) # $1 = Opening run of `\r\n (.+?) # $2 = The code block\r\n (?\x3C!`)\r\n \x5C1 # Matching closer\r\n (?!`)\r\n @xs\x27\x2C\r\n \x27_DoCodeSpans_callback\x27\x2C $text)\x3B\r\n\r\n return $text\x3B\r\n}\r\nfunction _DoCodeSpans_callback($matches) {\r\n $c = $matches[2]\x3B\r\n $c = preg_replace(\x27/^[ \x5Ct]*/\x27\x2C \x27\x27\x2C $c)\x3B # leading whitespace\r\n $c = preg_replace(\x27/[ \x5Ct]*$/\x27\x2C \x27\x27\x2C $c)\x3B # trailing whitespace\r\n $c = _EncodeCode($c)\x3B\r\n return \x22\x3Ccode\x3E$c\x3C/code\x3E\x22\x3B\r\n}\r\n\r\n\r\nfunction _EncodeCode($_) {\r\n#\r\n# Encode/escape certain characters inside Markdown code runs.\r\n# The point is that in code\x2C these characters are literals\x2C\r\n# and lose their special Markdown meanings.\r\n#\r\n global $md_escape_table\x3B\r\n\r\n # Encode all ampersands\x3B HTML entities are not\r\n # entities within a Markdown code span.\r\n $_ = str_replace(\x27\x26\x27\x2C \x27\x26amp\x3B\x27\x2C $_)\x3B\r\n\r\n # Do the angle bracket song and dance:\r\n $_ = str_replace(array(\x27\x3C\x27\x2C \x27\x3E\x27)\x2C\r\n array(\x27\x26lt\x3B\x27\x2C \x27\x26gt\x3B\x27)\x2C $_)\x3B\r\n\r\n # Now\x2C escape characters that are magic in Markdown:\r\n $_ = str_replace(array_keys($md_escape_table)\x2C\r\n array_values($md_escape_table)\x2C $_)\x3B\r\n\r\n return $_\x3B\r\n}\r\n\r\n\r\nfunction _DoItalicsAndBold($text) {\r\n # \x3Cstrong\x3E must go first:\r\n $text = preg_replace(\x27{\r\n ( # $1: Marker\r\n (?\x3C!\x5C*\x5C*) \x5C*\x5C* | # (not preceded by two chars of\r\n (?\x3C!__) __ # the same marker)\r\n )\r\n (?=\x5CS) # Not followed by whitespace\r\n (?!\x5C1) # or two others marker chars.\r\n ( # $2: Content\r\n (?:\r\n [^*_]+? # Anthing not em markers.\r\n |\r\n # Balence any regular emphasis inside.\r\n ([*_]) (?=\x5CS) .+? (?\x3C=\x5CS) \x5C3 # $3: em char (* or _)\r\n |\r\n (?! \x5C1 ) . # Allow unbalenced * and _.\r\n )+?\r\n )\r\n (?\x3C=\x5CS) \x5C1 # End mark not preceded by whitespace.\r\n }sx\x27\x2C\r\n \x27\x3Cstrong\x3E\x5C2\x3C/strong\x3E\x27\x2C $text)\x3B\r\n # Then \x3Cem\x3E:\r\n $text = preg_replace(\r\n \x27{ ( (?\x3C!\x5C*)\x5C* | (?\x3C!_)_ ) (?=\x5CS) (?! \x5C1) (.+?) (?\x3C=\x5CS) \x5C1 }sx\x27\x2C\r\n \x27\x3Cem\x3E\x5C2\x3C/em\x3E\x27\x2C $text)\x3B\r\n\r\n return $text\x3B\r\n}\r\n\r\n\r\nfunction _DoBlockQuotes($text) {\r\n $text = preg_replace_callback(\x27/\r\n ( # Wrap whole match in $1\r\n (\r\n ^[ \x5Ct]*\x3E[ \x5Ct]? # \x22\x3E\x22 at the start of a line\r\n .+\x5Cn # rest of the first line\r\n (.+\x5Cn)* # subsequent consecutive lines\r\n \x5Cn* # blanks\r\n )+\r\n )\r\n /xm\x27\x2C\r\n \x27_DoBlockQuotes_callback\x27\x2C $text)\x3B\r\n\r\n return $text\x3B\r\n}\r\nfunction _DoBlockQuotes_callback($matches) {\r\n $bq = $matches[1]\x3B\r\n # trim one level of quoting - trim whitespace-only lines\r\n $bq = preg_replace(array(\x27/^[ \x5Ct]*\x3E[ \x5Ct]?/m\x27\x2C \x27/^[ \x5Ct]+$/m\x27)\x2C \x27\x27\x2C $bq)\x3B\r\n $bq = _RunBlockGamut($bq)\x3B # recurse\r\n\r\n $bq = preg_replace(\x27/^/m\x27\x2C \x22 \x22\x2C $bq)\x3B\r\n # These leading spaces screw with \x3Cpre\x3E content\x2C so we need to fix that:\r\n $bq = preg_replace_callback(\x27{(\x5Cs*\x3Cpre\x3E.+?\x3C/pre\x3E)}sx\x27\x2C\r\n \x27_DoBlockQuotes_callback2\x27\x2C $bq)\x3B\r\n\r\n return \x22\x3Cblockquote\x3E\x5Cn$bq\x5Cn\x3C/blockquote\x3E\x5Cn\x5Cn\x22\x3B\r\n}\r\nfunction _DoBlockQuotes_callback2($matches) {\r\n $pre = $matches[1]\x3B\r\n $pre = preg_replace(\x27/^ /m\x27\x2C \x27\x27\x2C $pre)\x3B\r\n return $pre\x3B\r\n}\r\n\r\n\r\nfunction _FormParagraphs($text) {\r\n#\r\n# Params:\r\n# $text - string to process with html \x3Cp\x3E tags\r\n#\r\n global $md_html_blocks\x3B\r\n\r\n # Strip leading and trailing lines:\r\n $text = preg_replace(array(\x27/\x5CA\x5Cn+/\x27\x2C \x27/\x5Cn+\x5Cz/\x27)\x2C \x27\x27\x2C $text)\x3B\r\n\r\n $grafs = preg_split(\x27/\x5Cn{2\x2C}/\x27\x2C $text\x2C -1\x2C PREG_SPLIT_NO_EMPTY)\x3B\r\n\r\n #\r\n # Wrap \x3Cp\x3E tags.\r\n #\r\n foreach ($grafs as $key =\x3E $value) {\r\n if (!isset( $md_html_blocks[$value] )) {\r\n $value = _RunSpanGamut($value)\x3B\r\n $value = preg_replace(\x27/^([ \x5Ct]*)/\x27\x2C \x27\x3Cp\x3E\x27\x2C $value)\x3B\r\n $value .= \x22\x3C/p\x3E\x22\x3B\r\n $grafs[$key] = $value\x3B\r\n }\r\n }\r\n\r\n #\r\n # Unhashify HTML blocks\r\n #\r\n foreach ($grafs as $key =\x3E $value) {\r\n if (isset( $md_html_blocks[$value] )) {\r\n $grafs[$key] = $md_html_blocks[$value]\x3B\r\n }\r\n }\r\n\r\n return implode(\x22\x5Cn\x5Cn\x22\x2C $grafs)\x3B\r\n}\r\n\r\n\r\nfunction _EncodeAmpsAndAngles($text) {\r\n# Smart processing for ampersands and angle brackets that need to be encoded.\r\n\r\n # Ampersand-encoding based entirely on Nat Irons\x27s Amputator MT plugin:\r\n # http://bumppo.net/projects/amputator/\r\n $text = preg_replace(\x27/\x26(?!#?[xX]?(?:[0-9a-fA-F]+|\x5Cw+)\x3B)/\x27\x2C\r\n \x27\x26amp\x3B\x27\x2C $text)\x3B\x3B\r\n\r\n # Encode naked \x3C\x27s\r\n $text = preg_replace(\x27{\x3C(?![a-z/?\x5C$!])}i\x27\x2C \x27\x26lt\x3B\x27\x2C $text)\x3B\r\n\r\n return $text\x3B\r\n}\r\n\r\n\r\nfunction _EncodeBackslashEscapes($text) {\r\n#\r\n# Parameter: String.\r\n# Returns: The string\x2C with after processing the following backslash\r\n# escape sequences.\r\n#\r\n global $md_escape_table\x2C $md_backslash_escape_table\x3B\r\n # Must process escaped backslashes first.\r\n return str_replace(array_keys($md_backslash_escape_table)\x2C\r\n array_values($md_backslash_escape_table)\x2C $text)\x3B\r\n}\r\n\r\n\r\nfunction _DoAutoLinks($text) {\r\n $text = preg_replace(\x22!\x3C((https?|ftp):[^\x27\x5C\x22\x3E\x5C\x5Cs]+)\x3E!\x22\x2C\r\n \x27\x3Ca href=\x22\x5C1\x22\x3E\x5C1\x3C/a\x3E\x27\x2C $text)\x3B\r\n\r\n # Email addresses: \x3Caddress@domain.foo\x3E\r\n $text = preg_replace(\x27{\r\n \x3C\r\n (?:mailto:)?\r\n (\r\n [-.\x5Cw]+\r\n \x5C@\r\n [-a-z0-9]+(\x5C.[-a-z0-9]+)*\x5C.[a-z]+\r\n )\r\n \x3E\r\n }exi\x27\x2C\r\n \x22_EncodeEmailAddress(_UnescapeSpecialChars(_UnslashQuotes(\x27\x5C\x5C1\x27)))\x22\x2C\r\n $text)\x3B\r\n\r\n return $text\x3B\r\n}\r\n\r\n\r\nfunction _EncodeEmailAddress($addr) {\r\n#\r\n# Input: an email address\x2C e.g. \x22foo@example.com\x22\r\n#\r\n# Output: the email address as a mailto link\x2C with each character\r\n# of the address encoded as either a decimal or hex entity\x2C in\r\n# the hopes of foiling most address harvesting spam bots. E.g.:\r\n#\r\n# \x3Ca href=\x22\x26#x6D\x3B\x26#97\x3B\x26#105\x3B\x26#108\x3B\x26#x74\x3B\x26#111\x3B:\x26#102\x3B\x26#111\x3B\x26#111\x3B\x26#64\x3B\x26#101\x3B\r\n# x\x26#x61\x3B\x26#109\x3B\x26#x70\x3B\x26#108\x3B\x26#x65\x3B\x26#x2E\x3B\x26#99\x3B\x26#111\x3B\x26#109\x3B\x22\x3E\x26#102\x3B\x26#111\x3B\x26#111\x3B\r\n# \x26#64\x3B\x26#101\x3Bx\x26#x61\x3B\x26#109\x3B\x26#x70\x3B\x26#108\x3B\x26#x65\x3B\x26#x2E\x3B\x26#99\x3B\x26#111\x3B\x26#109\x3B\x3C/a\x3E\r\n#\r\n# Based by a filter by Matthew Wickline\x2C posted to the BBEdit-Talk\r\n# mailing list: \x3Chttp://tinyurl.com/yu7ue\x3E\r\n#\r\n $addr = \x22mailto:\x22 . $addr\x3B\r\n $length = strlen($addr)\x3B\r\n\r\n # leave \x27:\x27 alone (to spot mailto: later)\r\n $addr = preg_replace_callback(\x27/([^\x5C:])/\x27\x2C\r\n \x27_EncodeEmailAddress_callback\x27\x2C $addr)\x3B\r\n\r\n $addr = \x22\x3Ca href=\x5C\x22$addr\x5C\x22\x3E$addr\x3C/a\x3E\x22\x3B\r\n # strip the mailto: from the visible part\r\n $addr = preg_replace(\x27/\x22\x3E.+?:/\x27\x2C \x27\x22\x3E\x27\x2C $addr)\x3B\r\n\r\n return $addr\x3B\r\n}\r\nfunction _EncodeEmailAddress_callback($matches) {\r\n $char = $matches[1]\x3B\r\n $r = rand(0\x2C 100)\x3B\r\n # roughly 10% raw\x2C 45% hex\x2C 45% dec\r\n # \x27@\x27 *must* be encoded. I insist.\r\n if ($r \x3E 90 \x26\x26 $char != \x27@\x27) return $char\x3B\r\n if ($r \x3C 45) return \x27\x26#x\x27.dechex(ord($char)).\x27\x3B\x27\x3B\r\n return \x27\x26#\x27.ord($char).\x27\x3B\x27\x3B\r\n}\r\n\r\n\r\nfunction _UnescapeSpecialChars($text) {\r\n#\r\n# Swap back in all the special characters we\x27ve hidden.\r\n#\r\n global $md_escape_table\x3B\r\n return str_replace(array_values($md_escape_table)\x2C\r\n array_keys($md_escape_table)\x2C $text)\x3B\r\n}\r\n\r\n\r\n# _TokenizeHTML is shared between PHP Markdown and PHP SmartyPants.\r\n# We only define it if it is not already defined.\r\nif (!function_exists(\x27_TokenizeHTML\x27)) :\r\nfunction _TokenizeHTML($str) {\r\n#\r\n# Parameter: String containing HTML markup.\r\n# Returns: An array of the tokens comprising the input\r\n# string. Each token is either a tag (possibly with nested\x2C\r\n# tags contained therein\x2C such as \x3Ca href=\x22\x3CMTFoo\x3E\x22\x3E\x2C or a\r\n# run of text between tags. Each element of the array is a\r\n# two-element array\x3B the first is either \x27tag\x27 or \x27text\x27\x3B\r\n# the second is the actual value.\r\n#\r\n#\r\n# Regular expression derived from the _tokenize() subroutine in\r\n# Brad Choate\x27s MTRegex plugin.\r\n# \x3Chttp://www.bradchoate.com/past/mtregex.php\x3E\r\n#\r\n $index = 0\x3B\r\n $tokens = array()\x3B\r\n\r\n $match = \x27(?s:\x3C!(?:--.*?--\x5Cs*)+\x3E)|\x27. # comment\r\n \x27(?s:\x3C\x5C?.*?\x5C?\x3E)|\x27. # processing instruction\r\n # regular tags\r\n \x27(?:\x3C[/!$]?[-a-zA-Z0-9:]+\x5Cb(?\x3E[^\x22\x5C\x27\x3E]+|\x22[^\x22]*\x22|\x5C\x27[^\x5C\x27]*\x5C\x27)*\x3E)\x27\x3B\r\n\r\n $parts = preg_split(\x22{($match)}\x22\x2C $str\x2C -1\x2C PREG_SPLIT_DELIM_CAPTURE)\x3B\r\n\r\n foreach ($parts as $part) {\r\n if (++$index % 2 \x26\x26 $part != \x27\x27)\r\n $tokens[] = array(\x27text\x27\x2C $part)\x3B\r\n else\r\n $tokens[] = array(\x27tag\x27\x2C $part)\x3B\r\n }\r\n\r\n return $tokens\x3B\r\n}\r\nendif\x3B\r\n\r\n\r\nfunction _Outdent($text) {\r\n#\r\n# Remove one level of line-leading tabs or spaces\r\n#\r\n global $md_tab_width\x3B\r\n return preg_replace(\x22/^(\x5C\x5Ct|[ ]{1\x2C$md_tab_width})/m\x22\x2C \x22\x22\x2C $text)\x3B\r\n}\r\n\r\n\r\nfunction _Detab($text) {\r\n#\r\n# Replace tabs with the appropriate amount of space.\r\n#\r\n global $md_tab_width\x3B\r\n\r\n # For each line we separate the line in blocks delemited by\r\n # tab characters. Then we reconstruct every line by adding the\r\n # appropriate number of space between each blocks.\r\n\r\n $lines = explode(\x22\x5Cn\x22\x2C $text)\x3B\r\n $text = \x22\x22\x3B\r\n\r\n foreach ($lines as $line) {\r\n # Split in blocks.\r\n $blocks = explode(\x22\x5Ct\x22\x2C $line)\x3B\r\n # Add each blocks to the line.\r\n $line = $blocks[0]\x3B\r\n unset($blocks[0])\x3B # Do not add first block twice.\r\n foreach ($blocks as $block) {\r\n # Calculate amount of space\x2C insert spaces\x2C insert block.\r\n $amount = $md_tab_width - strlen($line) % $md_tab_width\x3B\r\n $line .= str_repeat(\x22 \x22\x2C $amount) . $block\x3B\r\n }\r\n $text .= \x22$line\x5Cn\x22\x3B\r\n }\r\n return $text\x3B\r\n}\r\n\r\n\r\nfunction _UnslashQuotes($text) {\r\n#\r\n# This function is useful to remove automaticaly slashed double quotes\r\n# when using preg_replace and evaluating an expression.\r\n# Parameter: String.\r\n# Returns: The string with any slash-double-quote (\x5C\x22) sequence replaced\r\n# by a single double quote.\r\n#\r\n return str_replace(\x27\x5C\x22\x27\x2C \x27\x22\x27\x2C $text)\x3B\r\n}\r\n\r\n\r\n/*\r\n\r\nPHP Markdown\r\n============\r\n\r\nDescription\r\n-----------\r\n\r\nThis is a PHP translation of the original Markdown formatter written in\r\nPerl by John Gruber.\r\n\r\nMarkdown is a text-to-HTML filter\x3B it translates an easy-to-read /\r\neasy-to-write structured text format into HTML. Markdown\x27s text format\r\nis most similar to that of plain text email\x2C and supports features such\r\nas headers\x2C *emphasis*\x2C code blocks\x2C blockquotes\x2C and links.\r\n\r\nMarkdown\x27s syntax is designed not as a generic markup language\x2C but\r\nspecifically to serve as a front-end to (X)HTML. You can use span-level\r\nHTML tags anywhere in a Markdown document\x2C and you can use block level\r\nHTML tags (like \x3Cdiv\x3E and \x3Ctable\x3E as well).\r\n\r\nFor more information about Markdown\x27s syntax\x2C see:\r\n\r\n\x3Chttp://daringfireball.net/projects/markdown/\x3E\r\n\r\n\r\nBugs\r\n----\r\n\r\nTo file bug reports please send email to:\r\n\r\n\x3Cmichel.fortin@michelf.com\x3E\r\n\r\nPlease include with your report: (1) the example input\x3B (2) the output you\r\nexpected\x3B (3) the output Markdown actually produced.\r\n\r\n\r\nVersion History\r\n---------------\r\n\r\nSee the readme file for detailed release notes for this version.\r\n\r\n1.0.1b - 6 Jun 2005\r\n\r\n1.0.1a - 15 Apr 2005\r\n\r\n1.0.1 - 16 Dec 2004\r\n\r\n1.0 - 21 Aug 2004\r\n\r\n\r\nAuthor \x26 Contributors\r\n---------------------\r\n\r\nOriginal Perl version by John Gruber\r\n\x3Chttp://daringfireball.net/\x3E\r\n\r\nPHP port and other contributions by Michel Fortin\r\n\x3Chttp://www.michelf.com/\x3E\r\n\r\n\r\nCopyright and License\r\n---------------------\r\n\r\nCopyright (c) 2004-2005 Michel Fortin\r\n\x3Chttp://www.michelf.com/\x3E\r\nAll rights reserved.\r\n\r\nCopyright (c) 2003-2004 John Gruber\r\n\x3Chttp://daringfireball.net/\x3E\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms\x2C with or without\r\nmodification\x2C are permitted provided that the following conditions are\r\nmet:\r\n\r\n* Redistributions of source code must retain the above copyright notice\x2C\r\n this list of conditions and the following disclaimer.\r\n\r\n* Redistributions in binary form must reproduce the above copyright\r\n notice\x2C this list of conditions and the following disclaimer in the\r\n documentation and/or other materials provided with the distribution.\r\n\r\n* Neither the name \x22Markdown\x22 nor the names of its contributors may\r\n be used to endorse or promote products derived from this software\r\n without specific prior written permission.\r\n\r\nThis software is provided by the copyright holders and contributors \x22as\r\nis\x22 and any express or implied warranties\x2C including\x2C but not limited\r\nto\x2C the implied warranties of merchantability and fitness for a\r\nparticular purpose are disclaimed. In no event shall the copyright owner\r\nor contributors be liable for any direct\x2C indirect\x2C incidental\x2C special\x2C\r\nexemplary\x2C or consequential damages (including\x2C but not limited to\x2C\r\nprocurement of substitute goods or services\x3B loss of use\x2C data\x2C or\r\nprofits\x3B or business interruption) however caused and on any theory of\r\nliability\x2C whether in contract\x2C strict liability\x2C or tort (including\r\nnegligence or otherwise) arising in any way out of the use of this\r\nsoftware\x2C even if advised of the possibility of such damage.\r\n\r\n*/