requireAttributes('field');
$error = $context->get($this->getAttribute('field') . '_error');
if ($error)
{
return $renderer->doNode($node);
}
}
}
class k4InputTag extends FATemplateTag
{
function parse(&$context, &$renderer, &$node)
{
$this->requireAttributes('name');
$error = $context->get($this->getAttribute('name') . '_error');
foreach ($this->attribs as $attrib => $value)
{
$this->setAttribute($attrib, $renderer->doText($value));
}
if ($error)
{
$this->setAttribute('class', $this->getAttribute('class') . ' invalid');
}
$attribs = $this->getAttributeString();
return "";
}
}
class k4TextareaTag extends FATemplateTag
{
function parse(&$context, &$renderer, &$node)
{
$this->requireAttributes('name');
$error = $context->get($this->getAttribute('name') . '_error');
foreach ($this->attribs as $attrib => $value)
{
$this->setAttribute($attrib, $renderer->doText($value));
}
if ($error)
{
$this->setAttribute('class', $this->getAttribute('class') . ' invalid');
}
$attribs = $this->getAttributeString();
return "" . $renderer->doNode($node) . "";
}
}
class k4CanDoTag extends FATemplateTag
{
function parse(&$context, &$renderer, &$node)
{
$this->requireAttributes('object', 'perm');
$user = &$context->get('k4_user');
$perm = $this->getAttribute('perm');
$object = $this->getAttribute('object');
$perm_has_and = strpos($perm, ',');
$perm_has_or = strpos($perm, '|');
$object_has_and = strpos($object, ',');
$object_has_or = strpos($object, '|');
$perms_array = $objects_array = array();
$singleperms = $singleobjects = 0;
if($perm_has_and !== FALSE || $perm_has_or !== FALSE)
{
$glue = $perm_has_and !== FALSE ? ',' : '|';
$perms_array = explode($glue, $perm);
}
else
{
$singleperms = 1;
$perms_array[] = $perm;
}
if($object_has_and !== FALSE || $object_has_or !== FALSE)
{
$glue = $object_has_and !== FALSE ? ',' : '|';
$objects_array = explode($glue, $object);
$multiobjects = TRUE;
}
else
{
$singleobjects = 1;
$objects_array[] = $object;
}
$res = FALSE;
if($singleobjects * $singleperms == 0)
{
foreach($objects_array as $object)
{
$sub_res = FALSE;
foreach($perms_array as $perm)
{
$sub_res = $user->canDo($perm, $object);
if($sub_res && !$perm_has_and)
{
break;
}
}
if($sub_res && !$object_has_and)
{
$res = TRUE;
break;
}
}
}
else
{
$res = $user->canDo($perms_array[0], $objects_array[0]);
}
if($res)
{
return $renderer->doNode($node);
}
}
}
?>