Exemple #1
0
	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;
	}
Exemple #2
0
	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'];
	}
Exemple #3
0
	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;
	}
Exemple #4
0
	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(" &bull; ");
				$msgList->a($a);
			}
		}
	}
Exemple #5
0
	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;
	}
Exemple #6
0
	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"]);
		}
	}
Exemple #7
0
	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))))."\";
				");
			}
		}
	}
Exemple #8
0
	function getIconHTML($order)
	{
		$icon = new LPC_HTML_node("img");
		$icon->setAttr('style', 'margin-bottom:-3px;');

		if ($order == "up")
			$icon->setAttr("src", LPC_ICON_UP_ENABLED);
		else
			$icon->setAttr('src', LPC_ICON_DOWN_ENABLED);

		return $icon;
	}
Exemple #9
0
	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)."&amp;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;
	}
Exemple #10
0
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;
}
Exemple #11
0
<?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(),