function bb2html() { global $cb_ref_title, $smilie_folder, $insert_link, $effin_casinos, $prevent_xss, $spammer_strings; $args = func_num_args(); $bb2html = func_get_arg(0); if ($args == 2) { $title = func_get_arg(1); $id_title = make_valid_id($title); // fix up bad id's } else { $id_title = $title = ''; } // oops! if ($bb2html == '') { return false; } /* special code formatting because this happens first, it's not possible do to [[pre]] or [[ccc]] in your bbcode, (for demo purposes) (though technically, you could put [[ccc]]code[[/ccc]] inside [pre] tags) pre-formatted text (even bbcode inside [pre] text will remain untouched, as it should be) there may be multiple [pre] or [ccc] blocks, so we grab them all and create arrays.. */ $pre = array(); $i = 0; while ($pre_str = stristr($bb2html, '[pre]')) { $pre_str = substr($pre_str, 0, strpos($pre_str, '[/pre]') + 6); $bb2html = str_replace($pre_str, "***pre_string***{$i}", $bb2html); // we encode this, for html tags, etc.. $pre[$i] = encode($pre_str); $i++; } /* syntax highlighting (Cool Colored Code™) och, why not! */ $ccc = array(); $i = 0; while ($ccc_str = stristr($bb2html, '[ccc]')) { $ccc_str = substr($ccc_str, 0, strpos($ccc_str, '[/ccc]') + 6); $bb2html = str_replace($ccc_str, "***ccc_string***{$i}", $bb2html); $ccc[$i] = str_replace("\r\n", "\n", $ccc_str); $i++; } /* rudimentary tag balance checking.. this works really well! */ //$removers = array("/\[\[(.*)\]\]/i","/\<hr (.*) \/\>/"); $check_string = preg_replace("/\\[\\[(.*)\\]\\]/i", "", $bb2html); // add tags that don't need closed.. $removers = array('[[', ']]', '[hr]', '[hr2]', '[hr3]', '[hr4]', '[sp]', '[*]', '[/*]'); $check_string = str_replace($removers, '', $check_string); // simple counting.. if (substr_count($check_string, "[") != substr_count($check_string, "]") or substr_count($check_string, "[/") != substr_count($check_string, "[") / 2 or substr_count($check_string, "[b]") != substr_count($check_string, "[/b]") or substr_count($check_string, "[i]") != substr_count($check_string, "[/i]")) { return false; } $bb2html = str_replace('<', '***lt***', $bb2html); $bb2html = str_replace('>', '***gt***', $bb2html); // xss attack prevention [99.9% safe!].. if ($prevent_xss) { $bb2html = xssclean($bb2html); } // oh dem pesky casinos... if ($effin_casinos == true) { if (stristr($bb2html, 'casino')) { $bb2html = preg_replace("/\\[url(.*)\\](.*)\\[\\/url\\]/i", "[url=\"http://{$insert_link}\" title=\"hahahah\\!\"]\$2[/url]", $bb2html); } } // now the bbcode proper.. // grab any *real* square brackets first, store 'em $bb2html = str_replace('[[[', '**$@$**[', $bb2html); // catch tags next to demo tags $bb2html = str_replace(']]]', ']**@^@**', $bb2html); // ditto $bb2html = str_replace('[[', '**$@$**', $bb2html); $bb2html = str_replace(']]', '**@^@**', $bb2html); // news headline block $bb2html = str_replace('[news]', '<div class="cb-news">', $bb2html); $bb2html = str_replace('[/news]', '<!--news--></div>', $bb2html); // references - we need to create the whole string first, for the str_replace $r1 = '<a class="cb-refs-title" href="#refs-' . $id_title . '" title="' . $cb_ref_title . '">'; $bb2html = str_replace('[ref]', $r1, $bb2html); $bb2html = str_replace('[/ref]', '<!--ref--></a>', $bb2html); $ref_start = '<div class="cb-ref" id="refs-' . $id_title . '"> <a class="ref-title" title="back to the text" href="javascript:history.go(-1)">references:</a> <div class="reftext">'; $bb2html = str_replace('[reftxt]', $ref_start, $bb2html); $bb2html = str_replace('[/reftxt]', '<!--reftxt--> </div> </div>', $bb2html); // ordinary transformations.. $bb2html = str_replace('&', '&', $bb2html); // we rely on the browser producing \r\n (DOS) carriage returns, as per spec. $bb2html = str_replace("\r", '<br />', $bb2html); // the \n remains, and makes the raw html readable $bb2html = str_replace('[b]', '<strong>', $bb2html); //ie. "\r\n" becomes "<br />\n" $bb2html = str_replace('[/b]', '</strong>', $bb2html); $bb2html = str_replace('[i]', '<em>', $bb2html); $bb2html = str_replace('[/i]', '</em>', $bb2html); $bb2html = str_replace('[u]', '<span class="underline">', $bb2html); $bb2html = str_replace('[/u]', '<!--u--></span>', $bb2html); $bb2html = str_replace('[big]', '<big>', $bb2html); $bb2html = str_replace('[/big]', '</big>', $bb2html); $bb2html = str_replace('[sm]', '<small>', $bb2html); $bb2html = str_replace('[/sm]', '</small>', $bb2html); // tables (couldn't resist this, too handy) hmm.. will we do these in css now? //:2do: $bb2html = str_replace('[t]', '<div class="cb-table">', $bb2html); $bb2html = str_replace('[bt]', '<div class="cb-table-b">', $bb2html); $bb2html = str_replace('[st]', '<div class="cb-table-s">', $bb2html); $bb2html = str_replace('[/t]', '<!--table--></div><div class="clear"></div>', $bb2html); $bb2html = str_replace('[c]', '<div class="cell">', $bb2html); // regular 50% width $bb2html = str_replace('[c1]', '<div class="cell1">', $bb2html); // cell data 100% width $bb2html = str_replace('[c3]', '<div class="cell3">', $bb2html); $bb2html = str_replace('[c4]', '<div class="cell4">', $bb2html); $bb2html = str_replace('[c5]', '<div class="cell5">', $bb2html); $bb2html = str_replace('[/c]', '<!--end-cell--></div>', $bb2html); $bb2html = str_replace('[r]', '<div class="cb-tablerow">', $bb2html); // a row $bb2html = str_replace('[/r]', '<!--row--></div>', $bb2html); $bb2html = str_replace('[box]', '<span class="box">', $bb2html); $bb2html = str_replace('[/box]', '<!--box--></span>', $bb2html); $bb2html = str_replace('[bbox]', '<div class="box">', $bb2html); $bb2html = str_replace('[/bbox]', '<!--box--></div>', $bb2html); // a simple list $bb2html = str_replace('[*]', '<li>', $bb2html); $bb2html = str_replace('[/*]', '</li>', $bb2html); $bb2html = str_replace('[ul]', '<ul>', $bb2html); $bb2html = str_replace('[/ul]', '</ul>', $bb2html); $bb2html = str_replace('[list]', '<ul>', $bb2html); $bb2html = str_replace('[/list]', '</ul>', $bb2html); $bb2html = str_replace('[ol]', '<ol>', $bb2html); $bb2html = str_replace('[/ol]', '</ol>', $bb2html); // fix up gaps.. $bb2html = str_replace('</li><br />', '</li>', $bb2html); $bb2html = str_replace('<ul><br />', '<ul>', $bb2html); $bb2html = str_replace('</ul><br />', '</ul>', $bb2html); $bb2html = str_replace('<ol><br />', '<ol>', $bb2html); $bb2html = str_replace('</ol><br />', '</ol>', $bb2html); // smilies (just starting these, *ahem*) .. if (file_exists($_SERVER['DOCUMENT_ROOT'] . $smilie_folder)) { $bb2html = str_replace(':lol:', '<img alt="smilie for :lol:" title=":lol:" src="' . $smilie_folder . 'lol.gif" />', $bb2html); $bb2html = str_replace(':ken:', '<img alt="smilie for :ken:" title=":ken:" src="' . $smilie_folder . 'ken.gif" />', $bb2html); $bb2html = str_replace(':D', '<img alt="smilie for :D" title=":D" src="' . $smilie_folder . 'grin.gif" />', $bb2html); $bb2html = str_replace(':eek:', '<img alt="smilie for :eek:" title=":eek:" src="' . $smilie_folder . 'eek.gif" />', $bb2html); $bb2html = str_replace(':geek:', '<img alt="smilie for :geek:" title=":geek:" src="' . $smilie_folder . 'geek.gif" />', $bb2html); $bb2html = str_replace(':roll:', '<img alt="smilie for :roll:" title=":roll:" src="' . $smilie_folder . 'roll.gif" />', $bb2html); $bb2html = str_replace(':erm:', '<img alt="smilie for :erm:" title=":erm:" src="' . $smilie_folder . 'erm.gif" />', $bb2html); $bb2html = str_replace(':cool:', '<img alt="smilie for :cool:" title=":cool:" src="' . $smilie_folder . 'cool.gif" />', $bb2html); $bb2html = str_replace(':blank:', '<img alt="smilie for :blank:" title=":blank:" src="' . $smilie_folder . 'blank.gif" />', $bb2html); $bb2html = str_replace(':idea:', '<img alt="smilie for :idea:" title=":idea:" src="' . $smilie_folder . 'idea.gif" />', $bb2html); $bb2html = str_replace(':ehh:', '<img alt="smilie for :ehh:" title=":ehh:" src="' . $smilie_folder . 'ehh.gif" />', $bb2html); $bb2html = str_replace(':aargh:', '<img alt="smilie for :aargh:" title=":aargh:" src="' . $smilie_folder . 'aargh.gif" />', $bb2html); } // anchors and stuff.. $bb2html = str_replace('[img]', '<img class="cb-img" src="', $bb2html); $bb2html = str_replace('[imgr]', '<img class="cb-img-right" src="', $bb2html); $bb2html = str_replace('[imgl]', '<img class="cb-img-left" src="', $bb2html); $bb2html = str_replace('[/img]', '" alt="an image" />', $bb2html); // clickable mail URL .. $bb2html = preg_replace_callback("/\\[mmail\\=(.+?)\\](.+?)\\[\\/mmail\\]/i", "create_mmail", $bb2html); $bb2html = preg_replace_callback("/\\[email\\=(.+?)\\](.+?)\\[\\/email\\]/i", "create_mail", $bb2html); // other URLs.. $bb2html = str_replace('[url=', '<a onclick="window.open(this.href); return false;" href=', $bb2html); $bb2html = str_replace('[turl=', '<a class="turl" title=', $bb2html); /* title-only url */ $bb2html = str_replace('[purl=', '<a class="purl" href=', $bb2html); /* page url */ $bb2html = str_replace('[/url]', '<!--url--></a>', $bb2html); // floaters.. $bb2html = str_replace('[right]', '<div class="right">', $bb2html); $bb2html = str_replace('[/right]', '<!--right--></div>', $bb2html); $bb2html = str_replace('[left]', '<div class="left">', $bb2html); $bb2html = str_replace('[/left]', '<!--left--></div>', $bb2html); // code $bb2html = str_replace('[tt]', '<tt>', $bb2html); $bb2html = str_replace('[/tt]', '</tt>', $bb2html); $bb2html = str_replace('[code]', '<span class="code">', $bb2html); $bb2html = str_replace('[/code]', '<!--code--></span>', $bb2html); $bb2html = str_replace('[coderz]', '<div class="coderz">', $bb2html); $bb2html = str_replace('[/coderz]', '<!--coderz--></div>', $bb2html); // simple quotes.. $bb2html = str_replace('[quote]', '<cite>', $bb2html); $bb2html = str_replace('[/quote]', '</cite>', $bb2html); // divisions.. $bb2html = str_replace('[hr]', '<hr class="cb-hr" />', $bb2html); $bb2html = str_replace('[hr2]', '<hr class="cb-hr2" />', $bb2html); $bb2html = str_replace('[hr3]', '<hr class="cb-hr3" />', $bb2html); $bb2html = str_replace('[hr4]', '<hr class="cb-hr4" />', $bb2html); $bb2html = str_replace('[hrr]', '<hr class="cb-hr-regular" />', $bb2html); $bb2html = str_replace('[block]', '<blockquote><div class="blockquote">', $bb2html); $bb2html = str_replace('[/block]', '</div></blockquote>', $bb2html); $bb2html = str_replace('</div></blockquote><br />', '</div></blockquote>', $bb2html); $bb2html = str_replace('[mid]', '<div class="cb-center">', $bb2html); $bb2html = str_replace('[/mid]', '<!--mid--></div>', $bb2html); // dropcaps. five flavours, small up to large.. [dc1]I[/dc] -> [dc5]W[/dc] $bb2html = str_replace('[dc1]', '<span class="dropcap1">', $bb2html); $bb2html = str_replace('[dc2]', '<span class="dropcap2">', $bb2html); $bb2html = str_replace('[dc3]', '<span class="dropcap3">', $bb2html); $bb2html = str_replace('[dc4]', '<span class="dropcap4">', $bb2html); $bb2html = str_replace('[dc5]', '<span class="dropcap5">', $bb2html); $bb2html = str_replace('[/dc]', '<!--dc--></span>', $bb2html); $bb2html = str_replace('[h2]', '<h2>', $bb2html); $bb2html = str_replace('[/h2]', '</h2>', $bb2html); $bb2html = str_replace('[h3]', '<h3>', $bb2html); $bb2html = str_replace('[/h3]', '</h3>', $bb2html); $bb2html = str_replace('[h4]', '<h4>', $bb2html); $bb2html = str_replace('[/h4]', '</h4>', $bb2html); $bb2html = str_replace('[h5]', '<h5>', $bb2html); $bb2html = str_replace('[/h5]', '</h5>', $bb2html); $bb2html = str_replace('[h6]', '<h6>', $bb2html); $bb2html = str_replace('[/h6]', '</h6>', $bb2html); // fix up input spacings.. $bb2html = str_replace('</h2><br />', '</h2>', $bb2html); $bb2html = str_replace('</h3><br />', '</h3>', $bb2html); $bb2html = str_replace('</h4><br />', '</h4>', $bb2html); $bb2html = str_replace('</h5><br />', '</h5>', $bb2html); $bb2html = str_replace('</h6><br />', '</h6>', $bb2html); // oh, all right then.. // my [color=red]colour[/color] [color=blue]test[/color] [color=#C5BB41]test[/color] $bb2html = preg_replace('/\\[color\\=(.+?)\\](.+?)\\[\\/color\\]/i', "<span style=\"color:\$1\">\$2<!--color--></span>", $bb2html); // common special characters (html entity encoding) .. // still considering just throwing them all into the one php function. hmmm.. $bb2html = str_replace('[sp]', ' ', $bb2html); $bb2html = str_replace('±', '±', $bb2html); $bb2html = str_replace('™', '™', $bb2html); $bb2html = str_replace('•', '•', $bb2html); $bb2html = str_replace('°', '°', $bb2html); $bb2html = str_replace('***lt***', '<', $bb2html); $bb2html = str_replace('***gt***', '>', $bb2html); $bb2html = str_replace('©', '©', $bb2html); $bb2html = str_replace('®', '®', $bb2html); $bb2html = str_replace('…', '…', $bb2html); // for URL's, and InfiniTags™.. $bb2html = str_replace('[', ' <', $bb2html); // you can just replace < and > with [ and ] in your bbcode $bb2html = str_replace(']', ' >', $bb2html); // for instance, [center] cool [/center] would work! // get back those square brackets.. $bb2html = str_replace('**$@$**', '[', $bb2html); $bb2html = str_replace('**@^@**', ']', $bb2html); // prevent some twat running arbitary php commands on our web server // I may roll this into the xss prevention and just keep it all enabled. hmm. $bb2html = preg_replace("/<\\?(.*)\\? ?>/i", "<strong>script-kiddie prank: <?\\1 ?></strong>", $bb2html); // re-insert the preformatted text blocks.. $cp = count($pre) - 1; for ($i = 0; $i <= $cp; $i++) { $bb2html = str_replace("***pre_string***{$i}", '<pre>' . $pre[$i] . '</pre>', $bb2html); } // insert the cool colored code.. $cp = count($ccc) - 1; for ($i = 0; $i <= $cp; $i++) { //$tmp_str = str_replace("\\", "\", $ccc[$i]); $tmp_str = substr($ccc[$i], 5, -6); $tmp_str = highlight_string(stripslashes($tmp_str), true); $tmp_str = str_replace('font color="', 'span style="color:', $tmp_str); $tmp_str = str_replace('font', 'span', $tmp_str); $bb2html = str_replace("***ccc_string***{$i}", '<div class="cb-ccc">' . addslashes($tmp_str) . '<!--ccccode--></div>', $bb2html); } // slash me! if (get_magic_quotes_gpc()) { return stripslashes($bb2html); } else { return $bb2html; } }
function make_safety_code_allele_combination_owl($human_with_genotype_at_locus, $allele_1, $allele_2, $rs_id) { $variant_qname = "sc:human_with_genotype_rs" . $rs_id . "_variant_" . make_valid_id($allele_1 . "_" . $allele_2); $allele_1_id = "rs" . $rs_id . "_" . make_valid_id($allele_1); $allele_2_id = "rs" . $rs_id . "_" . make_valid_id($allele_2); $owl_fragment = "Class: {$variant_qname} \n" . " SubClassOf: sc:{$human_with_genotype_at_locus} \n"; if ($allele_1 == "null" or $allele_2 == "null") { // if information is absent, do not add OWL axiom } else { if ($allele_1 == $allele_2) { // if homozygous... $owl_fragment .= " SubClassOf: has exactly 2 {$allele_1_id} \n"; } else { // if heterozygous... $owl_fragment .= " SubClassOf: has some {$allele_1_id} and has some {$allele_2_id} \n"; } } $owl_fragment .= " Annotations: rdfs:label \"human with rs" . $rs_id . "(" . $allele_1 . ";" . $allele_2 . ")\" \n" . " Annotations: sc:criteria_syntax \"rs" . $rs_id . "(" . $allele_1 . ";" . $allele_2 . ")\" \n"; return $owl_fragment; }
function save_phpcode($filename) { global $wb; // Set project variables foreach ($wb->project_array as $var) { ${$var} = $wb->form[$wb->currentform]->{$var}; if (!$var) { $var = constant("DEFAULT_" . strtoupper($var)); } } // Set up some useful variables $form = $wb->form[$wb->currentform]; $valueid = $wb->form[$wb->currentform]->startval; $ctrlid = $wb->form[$wb->currentform]->startctrlval; $ncontrols = $form->numcontrols; $tabnumber = 0; // Empty table of IDs make_unique_id(null); // Start PHP code if ($filename) { $phpcode = "<?php\r\n\r\n" . PHP_HEADER; } else { $phpcode = ""; } //--------------------- Code to generate identifiers for all controls $phpcode .= "// Control identifiers\r\n\r\n"; $invalid = array(); $defined = array(); // Loop for all controls for ($nctrl = 0; $nctrl < $ncontrols; $nctrl++) { $ct = $wb->form[$wb->currentform]->ct[$nctrl]; $define_this = false; if (!$ct->id) { // Null ID } else { if (preg_match("/^-?[0-9]+\$/", $ct->id)) { // Numeric ID } else { if (preg_match('/^[a-z][a-z0-9_]*$/i', $ct->id)) { if (in_array($ct->id, $wb->presetids)) { continue; } // Valid string identifier if (!in_array($ct->id, $defined)) { $defined[] = $ct->id; if (preg_match("/^" . $wb->form[$wb->currentform]->prefix . "[a-z]+([0-9]+)\$/i", $ct->id, $matches)) { $valueid = $matches[1]; } else { $valueid++; } $define_this = true; } } else { // Invalid ID: fix it $inv = $ct->id; $wb->form[$wb->currentform]->ct[$nctrl]->id = make_valid_id($ct->id, 'MAKEID_'); if (!in_array($ct->id, $defined)) { $defined[] = $ct->id; $ct = $wb->form[$wb->currentform]->ct[$nctrl]; $valueid++; $valueid = make_unique_id($valueid); $invalid[] = "{$inv} (changed to {$ct->id})"; $define_this = true; } } } } // Create a define() call if ($define_this) { $valueid = make_unique_id($valueid); $phpcode .= "if(!defined('{$ct->id}')) define('{$ct->id}', {$valueid});\r\n"; } } // Create code to generate the form (optional) if (!$wb->form[$wb->currentform]->istabpage) { $phpcode .= "\r\n// Create window\r\n\r\n"; $phpcode .= "{$formvar} = wb_create_window({$parent}, " . ($form->cclass == "TabPage" ? "AppWindow" : $form->cclass) . ', ' . ($wb->form[$wb->currentform]->localize && $filename ? make_valid_id(str_replace('.prj', '', basename($filename))) : "'{$form->caption}'") . ", WBC_CENTER, WBC_CENTER, {$form->width}, {$form->height}, " . sprintf("0x%08X", $form->style) . ", {$form->value});\r\n"; } else { $tabnumber = $wb->form[$wb->currentform]->tabnumber; } //--------------------- Code to generate the controls $phpcode .= "\r\n// Insert controls\r\n\r\n"; $last_tab = null; for ($i = 0; $i < $ncontrols; $i++) { $ct = $wb->form[$wb->currentform]->ct[$i]; $cid = !$ct->id ? '0' : $ct->id; $ctrlparent = $formvar; $ctrlcode = ''; $xoff = 0; $yoff = 0; //--------------------- Adds optional code for tabs if ($wb->form[$wb->currentform]->insertontabs) { // If a control is over a tab control, force its parent to be the tab static $xtaboffset = 0; static $ytaboffset = 0; if ($ct->cclass == 'TabControl') { $ctrlcode = '$tab = '; $ctrlparent = $formvar; $tabctrl = $ct; $xtaboffset = $tabctrl->left; $ytaboffset = $tabctrl->top + 22; // Height of a tab, should be read from API } else { $ctrlcode = ''; // Is the control inside the tab? if (isset($tabctrl) && ($ct->left >= $tabctrl->left && $ct->left <= $tabctrl->left + $tabctrl->width && $ct->top >= $tabctrl->top && $ct->top <= $tabctrl->top + $tabctrl->height)) { $ctrlparent = '$tab'; $xoff = $xtaboffset; $yoff = $ytaboffset; } else { $ctrlparent = $formvar; $xoff = 0; $yoff = 0; } } } //--------------------- Adds optional code (before control creation) if ($wb->form[$wb->currentform]->filllists) { switch ($ct->cclass) { case 'ComboBox': case 'ListBox': $ctrlcode .= '$ctrl = '; break; } } if ($wb->form[$wb->currentform]->fillheaders) { switch ($ct->cclass) { case 'ListView': case 'ImageButton': $ctrlcode .= '$ctrl = '; break; } } if ($wb->form[$wb->currentform]->imagenames) { switch ($ct->cclass) { case 'ImageButton': $ctrlcode .= '$ctrl = '; break; } } if ($wb->form[$wb->currentform]->applyvalues) { switch ($ct->cclass) { case 'ScrollBar': case 'Slider': case 'Gauge': $ctrlcode .= '$ctrl = '; break; } } //--------------------- Add variable name (if any) $var = $wb->form[$wb->currentform]->ctrlvar; if ($var) { if ($var[0] != '$') { $var = '$' . $var; } $ctrlcode .= sprintf($var, $ctrlid) . ' = '; $ctrlid++; } //--------------------- Add code to create control $phpcode .= $ctrlcode . "wb_create_control({$ctrlparent}, {$ct->cclass}, " . ($wb->form[$wb->currentform]->localize && $filename && $ct->caption ? make_valid_id($ct->caption) : "'{$ct->caption}'") . ", " . ($ct->left - $xoff) . ", " . ($ct->top - $yoff) . ", {$ct->width}, {$ct->height}, {$cid}, " . sprintf("0x%08X", $ct->style) . ", {$ct->value}, {$tabnumber});\r\n"; //--------------------- Adds optional code (after control creation) switch ($ct->cclass) { case 'ImageButton': if ($wb->form[$wb->currentform]->imagenames) { if (substr($ct->caption, -4) == '.bmp' && file_exists($ct->caption)) { $imgfile = "'{$ct->caption}'"; } else { $imgfile = "'resources\\symb_imagebutton.bmp'"; } $phpcode .= "\$img = wb_load_image({$imgfile});\n" . " wb_set_image(\$ctrl, \$img, NOCOLOR, 0, {$ct->value});\n" . " wb_destroy_image(\$img);"; } break; case 'ListView': if ($wb->form[$wb->currentform]->fillheaders) { $phpcode .= "wb_set_text(\$ctrl, '{$ct->caption}');\n"; } break; case 'ComboBox': case 'ListBox': if ($wb->form[$wb->currentform]->filllists) { $phpcode .= "wb_set_text(\$ctrl, explode(',', '{$ct->caption}'));\n"; } break; case 'ScrollBar': case 'Slider': case 'Gauge': if ($wb->form[$wb->currentform]->applyvalues) { $phpcode .= "wb_set_value(\$ctrl, {$ct->value});\n"; } break; } } // end control loop if (!$filename) { $phpcode = str_replace('$this->', '$', $phpcode); } // Prevents errors in PHP 5 -- Stefano $phpcode .= "\r\n// End controls\r\n"; // Let the user know that invalid IDs were corrected if (!empty($invalid)) { update_control_data(); // Update ID field on main screen if necessary wb_message_box($wb->mainwin, "The following invalid IDs were automatically corrected:\n\n" . implode("\n", $invalid), APPNAME, WBC_INFO); } //--------------------- Add ending PHP code and save file if ($filename) { $phpcode .= "\r\n?>"; $filename = str_replace(".prj", ".form.php", $filename); file_put_contents($filename, $phpcode); // Generate localization file if ($wb->form[$wb->currentform]->localize) { $phpcode = "<?php\r\n\r\n" . PHP_HEADER; $phpcode .= "// Identifiers for localization\r\n\r\n"; // Generate line for dialog box title if (!$wb->form[$wb->currentform]->istabpage) { $id = make_valid_id(str_replace('.form.php', '', basename($filename))); echo "******" . "{$id}\n"; $phpcode .= "define('{$id}'," . str_repeat(' ', 26 - strlen($id)) . "'{$form->caption}');\n\n"; } // Create a define() call for each localization identifier for ($i = 0; $i < $ncontrols; $i++) { $ct = $wb->form[$wb->currentform]->ct[$i]; $cid = !$ct->id ? '0' : $ct->id; if ($ct->caption) { $id = make_valid_id($ct->caption); if (strlen($id) < 26) { $phpcode .= "define('{$id}'," . str_repeat(' ', 26 - strlen($id)) . "'{$ct->caption}');\n"; } else { $phpcode .= "define('{$id}', '{$ct->caption}');\n"; } } } $phpcode .= "\r\n?>"; $filename = str_replace(".form", ".lang", $filename); file_put_contents($filename, $phpcode); } } else { return $phpcode; } }