if (!isset($attr['class'])) { $attr['class'] = array(); } $attr['class'] = array_merge(array('text-' . $kind), (array) $attr['class']); return Cell::unit('a', $text, $attr, $indent); }); // File uploader Jot::add('uploader', function ($action, $accept = null, $fields = array()) { $speak = Config::speak(); $html = Cell::begin('form', array('class' => array('form-ignite', 'form-upload'), 'action' => Converter::url($action), 'method' => 'post', 'enctype' => 'multipart/form-data')) . NL; $html .= Form::hidden('token', Guardian::token(), array(), 1) . NL; foreach ($fields as $name => $value) { $html .= Form::hidden($name, $value, array(), 1) . NL; } $html .= Cell::begin('span', array('class' => array('input-outer', 'btn', 'btn-default')), 1) . NL; $html .= Cell::unit('span', Jot::icon('folder-open') . ' ' . $speak->manager->placeholder_file, array(), 2) . NL; $html .= Form::file('file', array('title' => $speak->manager->placeholder_file, 'data' => array('icon-ready' => 'fa fa-check', 'icon-error' => 'fa fa-times', 'accepted-extensions' => $accept)), 2) . NL; $html .= Cell::end() . ' ' . Jot::button('action:cloud-upload', $speak->upload) . NL; $html .= Cell::end(); return $html; }); // File finder Jot::add('finder', function ($action, $name = 'q', $fields = array()) { $html = Cell::begin('form', array('class' => 'form-ignite form-find', 'action' => Converter::url($action), 'method' => 'get')) . NL; foreach ($fields as $key => $value) { $html .= Form::hidden($key, $value) . NL; } $html .= Form::text($name, Request::get($name, null), null, array(), 1) . ' ' . Jot::button('action:search', Config::speak('find')) . NL; $html .= Cell::end(); return $html; });
return Cell::unit('a', $content, $attr, $indent); }); // `<img>` Cell::add('img', function ($src = null, $alt = null, $attr = array(), $indent = 0) { $attr['src'] = Converter::url($src); $attr['alt'] = Cell::protect($alt); return Cell::unit('img', false, $attr, $indent); }); // `<(ol|ul)>` foreach (array('ol', 'ul') as $unit) { Cell::add($unit, function ($list = array(), $attr = array(), $indent = 0) use($unit) { $html = Cell::begin($unit, $attr, $indent) . NL; foreach ($list as $k => $v) { if (is_array($v)) { $html .= Cell::begin('li', array(), $indent + 1) . $k . NL; $html .= call_user_func('Cell::' . $unit, $v, $attr, $indent + 2) . NL; $html .= Cell::end('li', $indent + 1) . NL; } else { $html .= Cell::unit('li', $v, array(), $indent + 1) . NL; } } return $html . Cell::end($unit, $indent); }); } // `<(hr|br)>` foreach (array('hr', 'br') as $unit) { Cell::add($unit, function ($repeat = 1, $attr = array(), $indent = 0) use($unit) { $indent = $indent ? str_repeat(TAB, $indent) : ""; return $indent . str_repeat(Cell::unit($unit, false, $attr), $repeat); }); }
} return Cell::unit('script', $content, $attr, $indent); }); // `<a>` Cell::add('a', function ($href = null, $content = "", $target = null, $attr = array(), $indent = 0) { $attr['href'] = Converter::url($href); $attr['target'] = $target; return Cell::unit('a', $content, $attr, $indent); }); // `<img>` Cell::add('img', function ($src = null, $alt = null, $attr = array(), $indent = 0) { $attr['src'] = Converter::url($src); $attr['alt'] = Cell::protect($alt); return Cell::unit('img', false, $attr, $indent); }); // `<(ol|ul)>` foreach (array('ol', 'ul') as $unit) { Cell::add($unit, function ($list = array(), $attr = array(), $indent = 0) use($unit) { $html = Cell::begin($unit, $attr, $indent) . NL; foreach ($list as $k => $v) { if (is_array($v)) { $html .= Cell::begin('li', array(), $indent + 1) . $k . NL; $html .= call_user_func('Cell::' . $unit, $v, $attr, $indent + 2) . NL; $html .= Cell::end('li', $indent + 1) . NL; } else { $html .= Cell::unit('li', $v, array(), $indent + 1) . NL; } } return $html . Cell::end($unit, $indent); }); }