Example #1
0
File: common.php Project: Gutza/LPC
function exposeDirClasses($dir)
{
	$result=array(
		'name'=>array(),
		'formal'=>array(),
	);
	$d = dir($dir);
	while (false !== ($entry = $d->read())) {
		$fname=$dir."/".$entry;
		$class=substr($entry,0,-4);

		// First skip filesystem entries and known auxiliary classes
		if (!validClassFile($fname) || !validClassName($class))
			continue;

		// Second, skip abstract classes
		$cr=new ReflectionClass($class);
		if ($cr->isAbstract())
			continue;

		// Next, skip classes you don't have the right to
		if (!validateClassRights($class))
			continue;

		// Finally, skip internationalization children
		$instance=new $class();
		if (isset($instance->user_fields['i18n_parent']))
			continue;

		// Record everything else for display
		$result['name'][]=$class;
		$result['formal'][]=getFormalName($class);
	}
	$d->close();
	return $result;
}
Example #2
0
$p=LPC_Page::getCurrent();
$p->title=_LS('scaffoldingTitle');
$p->st();

/*
$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;
}

$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;
}