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
Content.php 0000644 00000015202 15210162235 0006664 0 ustar 00 joinSort($this->createAdapter());
parent::__construct('_'.$this->getContentGridId(), $this->getTitle(), $adapter, $request, $view);
$this->setEventId('gridContent' . ucfirst($this->getContentGridId()));
$this->addCallback(self::CB_AFTER_INSERT, array($this, 'afterInsert'));
$this->addCallback(self::CB_AFTER_UPDATE, array($this, 'afterInsert'));
$this->addCallback(self::CB_VALUES_TO_FORM, array($this, '_valuesToForm'));
foreach ($this->getActions() as $action)
$action->setTarget('_top');
}
/**
* Add join to resource_access_sort and sort field
* to be present in the result
*/
protected function joinSort(Am_Query $q)
{
$q->getTable()->addDefaultSort($q);
return $q;
}
public function getTitle()
{
return ___(ucfirst($this->getContentGridId()));
}
public function getContentGridId()
{
$id = preg_split('#[\\\\_]#', get_class($this));
$id = strtolower(array_pop($id));
return $id;
}
function renderAccessTitle(ResourceAbstract $r)
{
$title = $this->escape($r->title);
if (!empty($r->hide))
$title = "$title";
return $this->renderTd($title, false);
}
protected function initGridFields()
{
$this->addField(new Am_Grid_Field_Expandable('_access', ___('Products'), false))
->setPlaceholder(array($this, 'getPlaceholder'))
->setRenderFunction(array($this, 'renderProducts'))
->setGetFunction(array($this, 'getProducts'))
->setMaxLength(200);
$this->addField('_link', ___('Link'), false)->setRenderFunction(array($this, 'renderLink'));
$this->actionAdd(new Am_Grid_Action_SortContent());
parent::initGridFields();
}
public function renderLink(ResourceAbstract $resource)
{
$html = "";
$url = $resource->getUrl();
if (!empty($url))
$html = sprintf('%s',
$this->escape($url), ___('link'));
return $this->renderTd($html, false);
}
public function renderProducts($obj, $fieldName, $controller, $field)
{
return $this->renderTd($field->get($obj, $controller), false);
}
public function renderCategory(ResourceAbstract $e)
{
$res = array();
$options = $this->getDi()->resourceCategoryTable->getOptions();
foreach ($e->getCategories() as $resc_id)
{
$res[] = $options[$resc_id];
}
return $this->renderTd(implode(", ", $res));
}
public function getProducts(ResourceAbstract $resource)
{
$s = "";
foreach ($resource->getAccessList() as $access) {
$l = "";
if ($access->getStart())
$l .= " from " . $access->getStart();
if ($access->getStop())
$l .= " to " . $access->getStop();
$s .= sprintf("%s %s %s
\n", $access->getClassTitle(), $access->getTitle(), $l);
}
return $s;
}
public function getPlaceholder($val, ResourceAbstract $resource)
{
return ___('%d access records…', count($resource->getAccessList()));
}
public function afterInsert(array & $values, ResourceAbstract $record)
{
$record->setAccess($values['_access']);
}
public function _valuesToForm(array & $values, Am_Record $record)
{
$values['_access'] = $this->getRecord()->getAccessList();
}
public function renderPath(ResourceAbstractFile $file)
{
$upload = $file->getUpload();
try{
$file->isLocal();
} catch (Exception $e) {
if (!$upload)
return $this->renderTd(
'' . ___('The file has been removed from disk or corrupted. Please re-upload it.') . '' .
' (' . ___('Error from Storage Engine') . ': ' . $this->escape($e->getMessage()) . ')' .
'
' . ___('Real Path') . ': ' . $this->escape($file->path), false);
}
return $upload && !file_exists($upload->getFullPath()) ?
$this->renderTd(
'