"source": {
"type": "git",
"url": "git://git.andy128k.net/missing-tools.git",
- "reference": "c02b63b393ec05d0fa55c9eff64023618bf3ebfa"
+ "reference": "f1558fc778b002767a5dde8428b4ddb366697638"
},
"require": {
"andy128k/pegp": "0.1.*@dev",
}
],
"description": "Miscellaneous utilities",
- "time": "2014-08-24 18:59:36"
+ "time": "2014-09-01 17:54:03"
},
{
"name": "andy128k/pegp",
},
{
"name": "phpunit/php-token-stream",
- "version": "1.2.2",
+ "version": "1.3.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
- "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32"
+ "reference": "f8d5d08c56de5cfd592b3340424a81733259a876"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/ad4e1e23ae01b483c16f600ff1bebec184588e32",
- "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/f8d5d08c56de5cfd592b3340424a81733259a876",
+ "reference": "f8d5d08c56de5cfd592b3340424a81733259a876",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"php": ">=5.3.3"
},
+ "require-dev": {
+ "phpunit/phpunit": "~4.2"
+ },
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.2-dev"
+ "dev-master": "1.3-dev"
}
},
"autoload": {
"classmap": [
- "PHP/"
+ "src/"
]
},
"notification-url": "https://packagist.org/downloads/",
- "include-path": [
- ""
- ],
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
- "email": "sb@sebastian-bergmann.de",
- "role": "lead"
+ "email": "sebastian@phpunit.de"
}
],
"description": "Wrapper around PHP's tokenizer extension.",
"keywords": [
"tokenizer"
],
- "time": "2014-03-03 05:10:30"
+ "time": "2014-08-31 06:12:13"
},
{
"name": "phpunit/phpunit",
<?php
+use \PFF\HtmlBuilder\Text as Text;
use \PFF\HtmlBuilder\Tag as Tag;
class IPF_Admin_Model extends IPF_Admin_Component
else
return '<img src="'.IPF::get('static_url').'admin/img/icon-no.gif" alt="False" />';
case 'timestamp':
- return htmlspecialchars(IPF_Utils::formatDate($value), ENT_COMPAT, 'UTF-8');
+ return Text::escape(IPF_Utils::formatDate($value));
default:
- return htmlspecialchars($value, ENT_COMPAT, 'UTF-8');
+ return Text::escape($value);
}
}
public abstract function list_display();
- protected function columnTitle($column)
+ public function list_display_links()
{
- return IPF_Utils::humanTitle($column);
+ return null;
}
- public function ListItemsHeader()
+ protected function columnTitle($column)
{
- $this->header = array();
- $this->names = $this->list_display();
-
- foreach ($this->names as $name) {
- if (is_array($name)) {
- list($name, $title) = $name;
- } else {
- $title = $this->columnTitle($name);
- }
-
- $this->header[$name] = array(
- 'title' => $title,
- 'name' => $name,
- );
- }
- return $this->header;
+ return IPF_Utils::humanTitle($column);
}
+ public abstract function renderCell($object, $column);
+
protected abstract function getItems($searchValue, $filters, $page, $pageSize);
protected abstract function itemsCount($searchValue, $filters);
public abstract function getObjectByID($id);
return false;
}
- public abstract function renderCell($object, $column);
-
- public function ListRow($o, $id)
- {
- $row = array();
-
- foreach ($this->header as &$h) {
- $listMethod = 'column_'.$h['name'];
- if (method_exists($this,$listMethod)) {
- $str = $this->$listMethod($o);
- } else {
- $str = $this->renderCell($o, $h['name']);
- }
- $row[$h['name']] = $str;
- }
- $this->linksRow($row, $o, $id);
- return $row;
- }
-
- protected function linksRow(&$row, $o, $id)
- {
- if (method_exists($this, 'list_display_links')) {
- $links_display = $this->list_display_links();
- } else {
- $links_display = null;
- $i = 1;
- }
- foreach ($row as $name => &$v) {
- if ($links_display) {
- if (array_search($name, $links_display) !== false)
- $v = '<a href="'.$id.'/">'.$v.'</a>';
- } else {
- if ($i == 1)
- $v = '<a href="'.$id.'/">'.$v.'</a>';
- $i++;
- }
- }
- }
-
protected abstract function _getForm($obj, $data);
protected function _getEditForm($obj, $data)
$count = $this->itemsCount($searchValue, $filters);
$objects = $this->getItems($searchValue, $filters, $currentPage, $this->perPage);
- $this->ListItemsHeader();
+
+ $header = array();
+ foreach ($this->list_display() as $name) {
+ if (is_array($name)) {
+ list($name, $title) = $name;
+ } else {
+ $title = $this->columnTitle($name);
+ }
+
+ $header[] = array(
+ 'title' => $title,
+ 'name' => $name,
+ );
+ }
+
+ $links_display = $this->list_display_links();
+ if (!$links_display && count($header))
+ $links_display = array($header[0]['name']);
+
+ $rows = array();
+ foreach ($objects as $id => $o) {
+ $cells = array();
+ foreach ($header as $h) {
+ $listMethod = 'column_'.$h['name'];
+ if (method_exists($this,$listMethod)) {
+ $cell = $this->$listMethod($o);
+ } else {
+ $cell = $this->renderCell($o, $h['name']);
+ }
+
+ if (array_search($h['name'], $links_display) !== false)
+ $cell = '<a href="'.$id.'/">'.$cell.'</a>';
+
+ $cells[] = $cell;
+ }
+ $rows[] = array(
+ 'cells' => $cells,
+ 'object' => $o,
+ 'object_id' => $id,
+ );
+ }
$pagerLayout = new IPF_Pager_Layout;
$pages = $pagerLayout->layout($currentPage, ceil($count / $this->perPage));
$context = array(
'orderable'=>$this->_orderable(),
'page_title'=>$this->titleList(),
- 'header'=>$this->header,
- 'objects' => $objects,
+ 'header' => $header,
+ 'rows' => $rows,
'count' => $count,
'pages' => $pages,
'current_page' => $currentPage,
</tr>
</thead>
<tbody>
- {foreach $objects as $id => $o}
- <tr class="trsort" id="{$id}">
- {foreach $component->ListRow($o, $id) as $v}
- <td>{$v|safe}</td>
+ {foreach $rows as $row}
+ <tr class="trsort" id="{$row['object_id']}">
+ {foreach $row['cells'] as $cell}
+ <td>{$cell|safe}</td>
{/foreach}
</tr>
{/foreach}
->attrs($this->attrs)
->attrs($extra_attrs);
foreach ($this->choices as $option_label => $option_value) {
- $radio = Tag::input(array('type' => 'radio', 'name' => $name, 'value' => $option_value));
- if ($option_value == $value)
- $radio->attr('checked', 'checked');
-
$output->append(Tag::li(null,
- Tag::label(null, $radio, ' ', $option_label)));
+ Tag::label(null,
+ Tag::input()
+ ->attr('type', 'radio')
+ ->attr('name', $name)
+ ->attr('value', $option_value)
+ ->toggleAttr('checked', 'checked', $option_value == $value),
+ ' ',
+ $option_label)));
}
return $output->html();
}
->attr('name', $name);
$choices = $this->choices + $choices;
foreach ($choices as $option_label => $option_value) {
- $option = Tag::option()
+ $select->append(Tag::option()
->attr('value', $option_value)
- ->append($option_label);
- if ($option_value == $value)
- $option->attr('selected', 'selected');
- $select->append($option);
+ ->toggleAttr('selected', 'selected', $option_value == $value)
+ ->append($option_label));
}
return $select->html();
}
parent::__construct($attrs);
}
- public function render($name, $value, $extra_attrs=array(), $choices=array())
+ public function render($name, $value, $extra_attrs=array())
{
- $output = array();
- if ($value === null) {
+ if ($value === null)
$value = array();
- }
+
$select = Tag::select($this->attrs)
->attrs($extra_attrs)
->attr('name', $name.'[]')
->attr('multiple', 'multiple');
- $choices = array_merge($this->choices, $choices);
- foreach ($choices as $option_label => $option_value) {
- $option = Tag::option()->attr('value', $option_value)->append($option_label);
- if (@in_array($option_value, $value))
- $option->attr('selected', 'selected');
- $select->append($option);
+ foreach ($this->choices as $option_label => $option_value) {
+ $select->append(Tag::option()
+ ->attr('value', $option_value)
+ ->toggleAttr('selected', 'selected', @in_array($option_value, $value))
+ ->append($option_label));
}
return $select->html();
}
->attrs($this->attrs)
->attrs($extra_attrs);
foreach ($this->choices as $option_label => $option_value) {
- $selected = in_array($option_value, $value);
-
- $checkbox = Tag::input()
- ->attr('type', 'checkbox')
- ->attr('name', "{$name}[]")
- ->attr('value', $option_value);
-
- if ($selected)
- $checkbox->attr('checked', 'checked');
-
$output->append(Tag::li(null,
- Tag::label(null, $checkbox, ' ', $option_label)));
+ Tag::label(null,
+ Tag::input()
+ ->attr('type', 'checkbox')
+ ->attr('name', "{$name}[]")
+ ->attr('value', $option_value)
+ ->toggleAttr('checked', 'checked', in_array($option_value, $value)),
+ ' ',
+ $option_label)));
}
return $output->html();
}