v7‰PNG
IHDR Ÿ f Õ†C1 sRGB ®Îé gAMA ±üa pHYs à ÃÇo¨d GIDATx^íÜL”÷ð÷Yçªö("Bh_ò«®¸¢§q5kÖ*:þ0AºšÖ¥]VkJ¢M»¶f¸±8\k2íll£1]q®ÙÔ‚ÆT
PK C\Aˢw w Abstract.phpnu [ hasPermissions()) {
$grid->addCallback(Am_Grid_ReadOnly::CB_TR_ATTRIBS, array($this, 'getTrAttribs'));
$grid->addCallback(Am_Grid_Editable::CB_RENDER_CONTENT, array($this, 'renderContent'));
$grid->prependField(new Am_Grid_Field_Sort('_sort'));
}
}
final public function getTrAttribs(array & $attribs, $obj)
{
$grid_id = $this->grid->getId();
$params = array(
$grid_id . '_' . Am_Grid_ReadOnly::ACTION_KEY => $this->getId(),
$grid_id . '_' . Am_Grid_ReadOnly::ID_KEY => $this->grid->getDataSource()->getIdForRecord($obj),
);
$attribs['data-params'] = json_encode($params);
$attribs['data-sort-record'] = json_encode($this->getRecordParams($obj));
}
public function renderContent(& $out, Am_Grid_Editable $grid)
{
$url = json_encode($grid->makeUrl());
$grid_id = $this->grid->getId();
$msg = ___("Drag&Drop rows to change display order. You may want to temporary change setting '%sRecords per Page (for grids)%s' to some big value so all records were on one page and you can arrange all items.",
'','');
$out .= <<$msg
CUT;
}
public function run()
{
$request = $this->grid->getRequest();
$id = $request->getFiltered('id');
$move_before = $request->getParam('move_before', null);
$move_after = $request->getParam('move_after', null);
$move_item = $request->getParam('move_item');
$resp = array(
'ok' => true,
);
if ($this->callback)
$resp['callback'] = $this->callback;
try {
$this->setSortBetween($move_item, $move_after, $move_before);
} catch (Exception $e) {
throw $e;
$resp = array('ok' => false, );
}
Am_Di::getInstance()->response->ajaxResponse($resp);
exit();
}
protected function getRecordParams($obj)
{
return array(
'id' => $this->grid->getDataSource()->getIdForRecord($obj),
);
}
abstract protected function setSortBetween($item, $after, $before);
}
class Am_Grid_Field_Sort extends Am_Grid_Field
{
public function __construct($field='_', $title=null, $sortable = true, $align = null, $renderFunc = null, $width = null)
{
parent::__construct($field, '', false);
$this->addDecorator(new Am_Grid_Field_Decorator_Sort());
}
public function render($obj, $grid)
{
/* @var $grid Am_Grid_ReadOnly */
return $grid->getRequest()->getParam('sort') ?
'' :
'| | ';
}
}
class Am_Grid_Field_Decorator_Sort extends Am_Grid_Field_Decorator_Abstract {
function renderTitle(& $out, $controller)
{
/* @var $controller Am_Grid_ReadOnly */
$out = $controller->getRequest()->getParam('sort') ?
'' :
preg_replace('#^( |