function __construct() { parent::__construct(); $headbox=new LPC_HTML_node("DIV"); $headbox->setAttr("class","content header"); $a=new LPC_HTML_node("A"); $a->setAttr('href','?'); $img=new LPC_HTML_node("IMG"); $img->setAttr('src',LPC_css."/images/LPC_medium_logo.png"); $img->setAttr('style','float:left; margin-top: -45px'); $img->setAttr('alt','LPC logo'); $a->a($img); $headbox->a($a); $this->menu=new LPCI_Menu($this); $headbox->a($this->menu); $this->a($headbox); $inner=new LPC_HTML_node("DIV"); $inner->setAttr('class','content'); $this->a($inner,"inner"); $this->body=&$this->content['body']->content['inner']; }
protected function renderFooter() { $result=array(); if ($this->noFooter) return $result; $copy=new LPC_HTML_node("DIV"); $copy->setAttr('class','copyright'); $copy->content="Powered by <b>LPC</b> v".LPC_version." by <a href='http://www.moongate.eu/'>Moongate</a>"; $result[]=$copy; if (!strlen(LPC_user_class) || !LPC_User::getCurrent(true)) return $result; // no info in footer if you're not logged in $loadInfo=""; if ($this->loadAvgFile && is_readable($this->loadAvgFile)) { $coreCount=`cat {$this->cpuinfoFile} | grep processor | wc -l`; list($loadInfo)=explode(" ",file_get_contents($this->loadAvgFile)); $loadInfo="; load 5s: ".($loadInfo*100/$coreCount)."% (avg on ".$coreCount.($coreCount>1?' cores':' core').")"; } $result[]=$this->renderMessageTranslations(); $runtime=new LPC_HTML_node("DIV"); $runtime->setAttr('style',"color:#c0c0c0; text-align:center; font-size:80%; margin-top:10px"); $runTime=number_format(microtime(true)-LPC_start_time,3); $runtime->content="Page rendered in ".$runTime." seconds".$loadInfo; $result[]=$runtime; return $result; }
function prepare() { $this->addClass("row"); foreach($this->meta as $atom) { $col = new LPC_HTML_node(); $col->setClass($this->colClass); $this->a($col); if (isset($atom["content"])) { $col->a($atom["content"]); continue; } $ig = new LPC_HTML_node(); $ig->setClass("input-group"); $col->a($ig); $labelSpan = new LPC_HTML_node("span"); $labelSpan->setClass("input-group-addon"); $labelSpan->a($atom["label"]); $ig->a($labelSpan); if (is_object($atom["input"])) { $atom["input"]->setClass("form-control"); $ig->a($atom["input"]); } else { $fc = new LPC_HTML_node("span"); $fc->setClass("form-control"); $fc->a($atom["input"]); $ig->a($fc); } } }
function generateOption($label, $value=NULL, $attrs=array()) { $o=new LPC_HTML_node('option'); if ($value===NULL) $value=$label; $attrs['value']=$value; $o->setAttrs($attrs); $o->content=$label; return $o; }
function prepare() { if (!count($this->excel) || $this->renderMode=='Excel') { if (isset($this->content[$this->metaKey])) unset($this->content[$this->metaKey]); return; } $meta=new LPC_HTML_node('span'); $meta->setClass($this->metaClass); $meta->setAttr('style','display:none'); $meta->compact=true; $meta->a(LPC_JSON::encode($this->excel)); $this->content[$this->metaKey]=$meta; }
function __construct($href, $content, $attrs=array()) { parent::__construct(); $this->content=$content; $this->setAttr('href', $href); $this->setAttrs($attrs); }
public function prepare() { $this->ownerDocument->content['head']->content['LPC list filter CSS']=new LPC_HTML_link('stylesheet','text/css',LPC_css."/LPC_list_filter.css"); $default=addslashes($this->getCurrentValue()); $form=new LPC_HTML_form(false,'get'); $this->searchForm=$form; $this->a($form); foreach($_GET as $key=>$value) { if ($key==$this->GET_key) continue; $form->a("<input type='hidden' name='$key' value=\"".addslashes($value)."\">"); } $table=new LPC_HTML_node('table'); $table->setAttr('class','table_filter'); $form->a($table, 'filterTable'); $tr=new LPC_HTML_node('tr'); $table->a($tr, 'filterTR'); $td=new LPC_HTML_node('td'); $td->setAttr('class','table_filter'); $tr->a($td, 'filterTD'); $td->a("<input type='hidden' name='".$this->listObject->getParam('p')."' value='1'>"); $td=new LPC_HTML_node('td'); $td->setAttr('class','table_filter'); $tr->a($td, 'filterControls'); $td->a( "<button type='submit' style='border: none; background: none; padding: 0px'>". $this->getIcon("search", _LS('lpcFilterIcon'))." </button>" ); if (strlen($default)) $td->a( "<a href='".LPC_URI::getCurrent()->delVar($this->GET_key)->toString()."'>". $this->getIcon("remove", _LS('lpcRemoveFilterIcon')). "</a>" ); if (isset($this->helpKey)) { $td->a( "<a href='#' onClick='alert(".self::JS_translation_var.".".$this->helpKey."); return false;'>". $this->getIcon("info"). "</a>" ); if (!isset($this->ownerDocument->content['head']->content['JS_help_'.$this->helpKey])) { $js=new LPC_HTML_script(); $this->ownerDocument->content['head']->content['JS_help_'.$this->helpKey]=$js; $js->a(" if (typeof ".self::JS_translation_var." == 'undefined') var ".self::JS_translation_var." = {}; ".self::JS_translation_var.".".$this->helpKey."=\"".str_replace("\n","\\n",str_replace("\r","",addslashes(_LS($this->helpKey))))."\"; "); } } }
function prepare() { $this->addClass("container"); $ol = new LPC_HTML_node("ol"); $ol->setClass("breadcrumb"); $this->a($ol); foreach($this->meta as $atom) { $li = new LPC_HTML_node("li"); $ol->a($li); if (isset($atom["url"])) { $labelNode = new LPC_HTML_node("a"); $labelNode->setAttr("href", $atom["url"]); $li->a($labelNode); } else { $labelNode = $li; $li->setClass("active"); } $labelNode->a($atom["label"]); } }
function prepare() { $this->setClass('LPC_translated_message_list'); foreach(LPC_I18n_messageFormatter::$object_cache as $langID=>$msgs) { $this->a("<h1>Messages used in this page</h1>"); $lang=LPC_Language::newLanguage($langID); $this->a("<h2>".$lang->getNameH()."</h2>"); $msgList=new LPC_HTML_node(); $this->a($msgList); foreach($msgs as $key=>$obj) { $a=new LPC_HTML_node('a'); $a->a(htmlspecialchars($key)); $a->setAttr('href',LPC_url."/translate/message_translate.php?l=$langID&m=".rawurlencode($key)); if ($trans=$obj->getPattern()) $a->setAttr('title',$trans); if ($msgList->content) $msgList->a(" • "); $msgList->a($a); } } }
function processNodes($structure,$level=0) { $result=array(); $first=true; foreach($structure as $atom) { if ($atom['hidden']) continue; $node=new LPC_HTML_node("LI"); if (isset($atom['focus'])) $node->setAttr('class','menu_focus'); if (isset($atom['anchor'])) $node->a($atom['anchor']); elseif (isset($atom['url'])) $node->a("<a href='".$atom['url']."'>".$atom['label']."</a>"); else $node->a("<a href='#' onClick='return false'>".$atom['label']."</a>"); if (isset($atom['children'])) { $children=new LPC_HTML_node("UL"); $children->a($this->processNodes($atom['children'],$level+1)); $node->a($children); } $result[]=$node; } return $result; }
public function __construct($action=false, $method='post', $files=false) { parent::__construct(); if ($action===false) $action=LPC_URI::getCurrentURI(); $this->setAttr('action', $action); $this->setAttr('method', $method); if ($files) $this->setAttr('enctype','multipart/form-data'); else $this->setAttr('enctype','application/x-www-form-urlencoded'); }
} $rObj=new $_GET['rc']($_GET['rid']); if (isset($_GET['caid'])) { $rObj->createLink($_GET['rd'],$_GET['caid']); header("Location: ".LPC_URI::getCurrent()->delVar('caid')->toString()); exit; } if (isset($_GET['crid'])) { $rObj->dropLink($_GET['rd'],$_GET['crid']); header("Location: ".LPC_URI::getCurrent()->delVar('crid')->toString()); exit; } $obj=new $class(); $cancelDiv=new LPC_HTML_node('p'); $cancelDiv->a("[<a href='".$_GET['rt']."'>"._LS('scaffoldingCancelPick')."</a>]"); $p->a($cancelDiv); $l=$obj->getBaseList(); $l->onProcessHeaderRow='rhr'; $l->onProcessBodyRow='rbr'; $p->a($l); $p->a($cancelDiv); function rhr($row) { $th=new LPC_HTML_node('th'); $row->a($th);
$form=new LPC_HTML_form(); $form->a("<input type='hidden' name='m' value=\"".$msg->getAttrF('message_key')."\">"); $p->a($form); $t=new LPC_HTML_table(); $t->addClass('two-column-60'); $form->a($t); $t->a(new LPC_HTML_form_row(array( 'label'=>'Message key', 'input'=>$msg->getAttrH('message_key'), ))); $t->a(new LPC_HTML_form_row(array( 'label'=>'Message in reference language ('.$reference_lang->getAttrH('name').')', 'input'=>"<div style='max-height: 300px; overflow: auto'><tt>".nl2br($ref_trans->getAttrH('translation'))."</tt></div>", ))); $trans = new LPC_HTML_node('textarea'); $trans->setAttrs(array( 'name' => 'translation', 'style' => 'width: 100%; height: 300px', )); $trans->a($msg->getAttrH("translation")); $input = new LPC_HTML_html_editor($trans); $t->a(new LPC_HTML_form_row(array( 'label'=>'Translation to target language ('.$target_lang->getAttrH('name').')', 'input'=>$input, 'explain'=>"If any parameters are specified in the code, they are formatted here as {0}, {1} etc in the most basic form. If you need more complex stuff, see <a href='http://www.php.net/manual/en/messageformatter.formatmessage.php#refsect1-messageformatter.formatmessage-examples'>the documentation</a>.", ))); $t->a(new LPC_HTML_form_row(array( 'label'=>'Comment', 'input'=>"<textarea name='comment' rows='5' style='width:100%; font-size: 85%'>".$ref->getAttrH('comment')."</textarea>", )));
function __construct($glyph) { parent::__construct("span"); $this->setClass("glyphicon glyphicon-".$glyph); }
<?php $u=LPC_User::getCurrent(); if (isset($_GET['langID'])) { $lang=new LPC_Language(); $lang->fromKey($_GET, 'langID'); if ($lang->id) { LPC_Language::setCurrent($lang); header("Location: ".LPC_URI::getCurrent()->delVar('langID')->toString()); exit; } } $langSelect=new LPC_HTML_node('div'); $langSelect->setAttr('style','float: right'); $langSelect->a(_LH('scaffoldingSelectLang')." "); $langs=new LPC_HTML_select(); $langSelect->a($langs); $langObjs=new LPC_Language(); $langObjs=$langObjs->search(NULL,NULL,'name'); foreach($langObjs as $langObj) $langs->addOption($langObj->getAttr('name'),$langObj->id); $langs->setAttr('onChange',"window.location=location.pathname+location.search+(location.search?'&':'?')+'langID='+this.options[this.selectedIndex].value;"); $langs->selected=LPC_Language::getCurrent()->id; LPC_Page::getCurrent()->a($langSelect); function exposeDirClasses($dir) { $result=array( 'name'=>array(),
public function render($indent=0) { $lang = LPC_Language::getCurrent(); $POSIX = $lang->getAttr("locale_POSIX"); if (strlen($POSIX) > 1) // at least 2 $this->setAttr("lang", substr($POSIX, 0, 2)); $this->prepareContent($this->content); if ($this->doctype & LPC_HTML_doctype::type_XHTML1) $this->setAttr("xmlns","http://www.w3.org/1999/xhtml"); if (!$this->body->content || self::RM_NONE == $this->renderMode) return ''; if (!$this->beforeRender($indent)) return ''; if (self::RM_RAW == $this->renderMode) return $this->body->renderContent($indent); if (self::RM_HTML != $this->renderMode) throw new RuntimeException("Unknown render mode: [".$this->renderMode."]"); $title=""; if ($this->title) { $titleObj=new LPC_HTML_fragment(); $titleObj->content=$this->title; $titleObj->compact=true; $title=$titleObj->render(); } if (strlen(trim($title))) $this->content['head']->content['title']->content=sprintf($this->title_format,$title); else $this->content['head']->content['title']->content=$this->title_default; $content=$this->output(LPC_HTML_doctype::$doctypes[$this->doctype],$indent); // <!DOCTYPE...> $content.=parent::render($indent); $this->onRender($indent); return $content; }
function getIconconBS($order) { $icon = new LPC_HTML_node("span"); $icon->setClass("glyphicon")->setAttr("style", "margin-left: 3px"); if ($order == "up") $icon->addClass("glyphicon-sort-by-attributes-alt"); else $icon->addClass("glyphicon-sort-by-attributes"); return $icon; }
$p->head->a(new LPC_HTML_script(LPC_js."/jquery.js")); $p->head->a(new LPC_HTML_script(LPC_js."/LPC_scaffolding.js")); if (empty($_GET['c'])) { $p->a(new LPC_HTML_error(_LH('scaffoldingErrorNeedClass'))); return; } $class=$_GET['c']; if (!validClassName($class) || !validateClassRights($class)) { $p->a(new LPC_HTML_error(_LH('genericErrorRights'))); return; } $obj=new $class(); $cancelDiv=new LPC_HTML_node('p'); $cancelDiv->a("[<a href='#' onClick='return LPC_scaffolding_cancelPick()'>"._LS('scaffoldingCancelPick')."</a>]"); $p->a($cancelDiv); $l=$obj->getBaseList(); $l->onProcessHeaderRow='rhr'; $l->onProcessBodyRow='rbr'; $p->a($l); if ($cancelDiv) $p->a($cancelDiv); function rhr($row) { $th=new LPC_HTML_node('th');
public function render() { if (!$this->content || $this->unconditional_preparation) $this->prepare(); return parent::render(); }
public function getScaffoldingEditRow($attName,$options=array()) { $row=$this->getScaffoldingFileRow($attName,$options); if ($row!==false) return $row; $link=""; if (isset($this->dataStructure['fields'][$attName]['link_class'])) { $class=$this->dataStructure['fields'][$attName]['link_class']; if ( $this->id && $this->getAttr($attName) ) { $obj=$this->getObject($attName); $name=$obj->getNameH(); if ($name) $name=" (".$name.")"; $link=$name." <a href='objectEdit.php?c=".rawurlencode($class)."&id=".rawurlencode($this->getAttr($attName))."'>"._LS('scaffoldingEditLink',htmlspecialchars($class),$this->getAttrH($attName))."</a>"; } $link.=" <a href='#' onClick='return LPC_scaffolding_pickObject(\"".addslashes($class)."\",$(this).prevAll(\"input\").get(0))'>☞</a>"; } if (!$this->id) $this->setAttr($attName,$this->getScaffoldingDefault($attName)); $type=""; if (isset($this->dataStructure['fields'][$attName]['type'])) $type=$this->dataStructure['fields'][$attName]['type']; switch($type) { case 'integer': $input="<input type='text' name='attr[$attName]' size='6' value=\"".$this->getAttrH($attName)."\">".$link; break; case 'date': if ($val=$this->getAttr($attName)) $val=date('Y-m-d',$val); case 'datetime': if (!isset($val) && ($val=$this->getAttr($attName))) $val=date('Y-m-d H:i',$val); $input= "<input type='text' name='attr[$attName]' value=\"".$val."\" class='input-date' id='attr_$attName'>". "<input type='button' value=\"".addslashes(_LS('scaffoldingSetDateNow'))."\" onClick=\"$('#attr_$attName').val('+0 minutes')\">"; break; case 'longtext': case 'html': // HTML + longtext $input = new LPC_HTML_node('textarea'); $input->setAttrs(array( 'name' => "attr[$attName]", 'style' => 'width: 100%; height: 150px', )); $input->a($this->getAttrH($attName)); if ('longtext' == $type) break; // HTML only $input->setAttr('style', $input->getAttr('style')."; min-width: 600px; height: 250px"); $input = new LPC_HTML_html_editor($input, true); break; case 'boolean': if ($this->getAttr($attName)) { $checked_yes=" checked"; $checked_no=""; } else { $checked_yes=""; $checked_no=" checked"; } $input= "<input type='radio' name='attr[$attName]' value='1'$checked_yes id='{$attName}_yes'> <label for='{$attName}_yes'>"._LH('scaffoldingBooleanYes')."</label><br>". "<input type='radio' name='attr[$attName]' value='0'$checked_no id='{$attName}_no'> <label for='{$attName}_no'>"._LH('scaffoldingBooleanNo')."</label>"; break; case 'enum': case 'set': if (!isset($this->dataStructure['fields'][$attName]['options'])) throw new RuntimeException("You need to define the options explicitly for enum and set fields (key 'options' in the data structure)."); $input=new LPC_HTML_node('div'); $inputS=new LPC_HTML_select("attr[$attName]"); $input->a($inputS); if ($type=='set') { // Allow for an empty set by providing an empty option which will be processed on POST $input->a("<input type='hidden' name=\"attr[$attName][]\" value='NULL'>"); $inputS->setAttr('name',"attr[$attName][]"); $inputS->setAttr('multiple','multiple'); $inputS->setAttr('size',min(5,count($this->dataStructure['fields'][$attName]['options']))); } $values=explode(",",$this->getAttr($attName)); foreach($this->dataStructure['fields'][$attName]['options'] as $option) { $optionH=new LPC_HTML_node('option'); $optionH->compact=true; if (in_array($option,$values)) $optionH->setAttr('selected',1); $optionH->setAttr('value',addslashes($option)); $optionH->a(htmlspecialchars($option)); $inputS->a($optionH); } break; default: $input="<input type='text' name='attr[$attName]' oninput=\"LPC_scaffolding_onTextInput(this)\" value=\"".$this->getAttrH($attName)."\" style='width:90%;'>".$link; } if (isset($this::$scaffoldingDesc[$attName])) $attDesc=_LS($this::$scaffoldingDesc[$attName]['name']); else $attDesc=$attName; if (empty($options['NO_SQL_DESC'])) { $rs=$this->query("DESCRIBE ".$this->getTableName()." ".$this->getFieldName($attName,true)); $attDesc = "<span title=\"".htmlspecialchars($rs->fields['Type'])."\">".$attDesc."</span>"; } if (isset($this::$scaffoldingDesc[$attName]['desc']) && empty($options['NO_LPC_DESC'])) $attDesc.="<div style='font-weight:normal; font-size:80%'>"._LS($this::$scaffoldingDesc[$attName]['desc'])."</div>"; $row=new LPC_HTML_form_row(array( 'label'=>$attDesc, 'input'=>$input, )); $row->compact=true; return $row; }
function error($message) { $e=new LPC_HTML_node('div'); $e->setAttr('class','error'); $e->setAttr('style','font-weight: normal'); $e->a("<big><b>EROARE</b></big><br>"); $e->a($message); return $e; }
$p->a(new LPC_HTML_error(_LH('scaffoldingErrorNeedClass'))); return; } $class=$_GET['c']; if (!validClassName($class) || !validateClassRights($class)) { $p->a(new LPC_HTML_error(_LH('genericErrorRights'))); return; } $p->st(_LS('scaffoldingTitleObjectList', getFormalName($class))); $editDiv=false; $obj=new $class(); if ($obj->hasScaffoldingRight('W')) { $editDiv=new LPC_HTML_node('p'); $editDiv->a("[<a href='objectEdit.php?c=$class'>"._LS('scaffoldingCreateObject',$class)."</a>]"); $p->a($editDiv); } $refdata=array('rd','rc','rid'); $rd=NULL; foreach($refdata as $refatom) { if (isset($_POST['LPC_scaffolding_'.$refatom])) $$refatom=$_POST['LPC_scaffolding_'.$refatom]; elseif (isset($_GET[$refatom])) $$refatom=$_GET[$refatom]; } $query=$rObj=NULL; if (strlen($rd)) { $rObj=new $rc($rid);
function deleteConfirm($fname,$ok=true) { $good=new LPC_HTML_confirm("The deleted messages were saved in ".htmlspecialchars($fname)); if ($ok) return $good; $mixed=new LPC_HTML_node('div'); $mixed->a($good); $bad=new LPC_HTML_error("Some messages couldn't be deleted."); $mixed->a($bad); return $mixed; }