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 Enum.php000064400000001577152101622450006171 0ustar00{$this->field}) ? $obj->{$this->field} : null; if (array_key_exists($v, $this->translation)) { $v = $this->translation[$v]; } else { $v = htmlentities($v, null, 'UTF-8'); } return "$v"; } public function translate($k, $v) { $this->translation[$k] = $v; return $this; } public function setTranslations(array $translations) { $this->translation = $translations; return $this; } }Actions.php000064400000003102152101622450006647 0ustar00%s', $controller->escape($this->title)); } public function render($obj, $grid) { $out = '' . PHP_EOL; $id = $grid->getDataSource()->getIdForRecord($obj); foreach ($grid->getActions(Am_Grid_Action_Abstract::SINGLE) as $action) { if (!$action->isAvailable($obj)) continue; $attributes = ""; foreach ($action->getAttributes() as $k => $v) $attributes .= htmlentities ($k, null, 'UTF-8') . '="' . htmlentities($v, ENT_QUOTES, 'UTF-8') . '" '; $icon = $grid->getView()->icon($action->getId(), $grid->getRecordTitle($action->getTitle())); if (!$icon) $icon = $action->getTitle(); $url = $action->getUrl($obj, $id); $out .= sprintf(' %s' . PHP_EOL, $attributes, $url, $icon ); } $out .= '' . PHP_EOL; return $out; } }IsDisabled.php000064400000001605152101622450007260 0ustar00actionAdd(new Am_Grid_Action_LiveCheckbox($this->field)) ->setCallback('l = function(newValue){jQuery(this).closest("tr").toggleClass("disabled", newValue == "1")}'); $grid->addCallback(Am_Grid_ReadOnly::CB_TR_ATTRIBS, array($this, 'cbGetTrAttribs')); } public function cbGetTrAttribs(& $ret, $record) { if ($record->is_disabled) { $ret['class'] = isset($ret['class']) ? $ret['class'] . ' disabled' : 'disabled'; } } }Checkboxes.php000064400000005054152101622450007335 0ustar00countRecords++; $out = '' . PHP_EOL; $id = $grid->getDataSource()->getIdForRecord($obj); $out .= sprintf('' . PHP_EOL, htmlentities($id, ENT_QUOTES, 'UTF-8')); $out .= '' . PHP_EOL; return $out; } public function renderTitle($controller) { $this->countRecords = 0; return ' ' . PHP_EOL; } public function init(Am_Grid_ReadOnly $grid) { $grid->addCallback(Am_Grid_Editable::CB_RENDER_TABLE, array($this, 'renderCheckAllOffer')); } public function renderCheckAllOffer(& $output, Am_Grid_ReadOnly $grid) { if (!empty($grid->_check_all_offer_added)) return; $start = (int)strpos($output, ''.$this->countRecords.'') . '.' . PHP_EOL; $div .= ''; $div .= ___("Select all %s records matching your search", ''.$grid->getDataSource()->getFoundRows().''); $div .= '.' . PHP_EOL; $div .= '' . PHP_EOL; $div .= '' . PHP_EOL; $div .= '' . PHP_EOL; $div .= '' . PHP_EOL; $output = substr_replace($output, $div, $start, 0); $grid->_check_all_offer_added = true; } }Expandable.php000064400000013413152101622450007320 0ustar00setGetFunction(array($this, 'expandableGet')); parent::__construct($field, $title, $sortable, $align, $renderFunc, $width); $this->isNeedExpand = array($this, '_defaultIsNeedExpand'); } /** * * @param int $maxLength * @return Am_Grid_Field_Expandable */ public function setMaxLength($maxLength) { $this->maxLength = (int) $maxLength; return $this; } /** * You can use variables like * {user_id} and {getInvoiceId()} in the template * it will be automatically fetched from record, escaped and substituted */ public function setAjax($url) { $this->isAjax = true; $this->url = $url; return $this; } /** * * @param string $placeholder * @return Am_Grid_Field_Expandable */ public function setPlaceholder($placeholder) { $this->placeholder = $placeholder; return $this; } public function render($obj, $controller) { $val = $this->get($obj, $controller, $this->field); if (!$this->isNeedExpand($val, $obj)) { return parent::render($obj, $controller); } else { $align_class = $this->align ? ' align_' . $this->align : null; $placeholder = $this->getPlaceholder($val, $obj); $data_class = ($this->isHtml ? ' isHtml' : '') . ($this->isAjax ? ' isAjax' : '') . ($this->isSafeHtml ? ' isSafeHtml' : ''); $data_val = $controller->escape($this->isAjax ? $this->parseUrl($this->url, $obj) : $val); $id = "{$controller->getId()}-$this->field-{$controller->getDataSource()->getIdForRecord($obj)}"; $out = <<
$placeholder
CUT; } return $out; } function setIsNeedExpandFunction($func) { $this->isNeedExpand = $func; return $this; } protected function isNeedExpand($val, $obj) { return call_user_func($this->isNeedExpand, $val, $obj, $this->field, $this); } function _defaultIsNeedExpand($val, $obj, $field, $fieldObj) { return $this->isAjax || mb_strlen($val) > $this->maxLength; } protected function parseUrl($url, $record) { $that = $this; $ret = preg_replace_callback('|{(.+?)}|', function($matches) use ($that, $record) { return $that->_pregReplace($matches, $record); }, $url); if ((strpos($ret, 'http')!==0) && ($ret[0] != '/')) $ret = Am_Di::getInstance()->url($ret,null,false); return $ret; } public function _pregReplace($matches, $record) { $var = $matches[1]; if ($var == 'THIS_URL') { $ret = Am_Di::getInstance()->request->getRequestUri(); } elseif (preg_match('|^(.+)\(\)$|', $var, $regs)) { $ret = call_user_func(array($record, $regs[1])); } else { $ret = $record->{$var}; } return urlencode($ret); } /** * * @param string $val * @return string html code of placeholder */ protected function getPlaceholder($val, $obj) { if (is_null($this->placeholder) || $this->placeholder == self::PLACEHOLDER_SELF_TRUNCATE_END) { $placeholder = htmlentities(mb_substr($val, 0, $this->maxLength), null, 'UTF-8') . ( mb_strlen($val) > $this->maxLength ? '…' : ''); } elseif ($this->placeholder == self::PLACEHOLDER_SELF_TRUNCATE_BEGIN) { $placeholder = ( mb_strlen($val) > $this->maxLength ? '…' : '') . htmlentities(mb_substr($val, -1 * $this->maxLength), null, 'UTF-8'); } elseif(is_callable($this->placeholder)) { $placeholder = call_user_func($this->placeholder, $val, $obj); } else { $placeholder = htmlentities($this->placeholder, null, 'UTF-8'); } return $placeholder; } public function expandableGet($obj, $controller, $field) { $val = $obj->{$field}; if (!$val) return $val; // try unserialize if (is_string($val)) { if (($x = @unserialize($val)) !== false) $val = $x; } switch (true) { case is_array($val) : $out = ''; foreach ($val as $k => $v) $out .= $k . ' = ' . ((is_array($v)) ? print_r($v, true) : (string) $v) . PHP_EOL; return $out; case is_object($val) : return get_class($val) . "\n" . (string) $obj; } return $val; } public function setEscape($flag = null) { $ret = ! $this->isHtml; if ($flag !== null) $this->isHtml = ! $flag; return $ret; } public function setSafeHtml($flag) { $this->isSafeHtml = $flag; return $this; } public function renderStatic() { $view = new Am_View; $url = $view->escape($view->_scriptJs('htmlreg.js')); return parent::renderStatic() . ' '; } } Data.php000064400000000706152101622450006127 0ustar00setGetFunction(array($this, '_get')); } public function _get(Am_Record_WithData $record, $fontroller, $field) { return $record->data()->get($field); } }Date.php000064400000002071152101622450006130 0ustar00setFormatFunction(array($this, '_format')); } public function setFormatTime(){ $this->format = self::TIME; return $this;} public function setFormatDatetime(){ $this->format = self::DATETIME; return $this;} public function setFormatDate(){ $this->format = self::DATE; return $this;} public function _format($d) { if (trim($d)=='') return ''; if ($d == Am_Period::MAX_SQL_DATE) return ___('Lifetime'); switch ($this->format) { case self::DATE: return amDate($d); case self::TIME: return amTime($d); default: return amDatetime($d); } } }Decorator/Link.php000064400000001604152101622450010073 0ustar00target = $target; } function setTarget($target) { $this->target = $target; } public function render(&$out, $obj, $controller) { $url = $this->parseTpl($obj); $target = $this->target ? " target=\"$this->target\"" : null; $start = sprintf('', htmlentities($url, ENT_QUOTES, 'UTF-8'), $target ); $stop = ''; $out = preg_replace('|()(.+)()|', '\1'.$start.'\2'.$stop.'\3', $out); } }Decorator/Tpl.php000064400000002634152101622450007741 0ustar00setTpl($tpl); } /** * You can use variables like * {user_id} and {getInvoiceId()} in the template * it will be automatically fetched from record, escaped and substituted */ function setTpl($tpl) { $this->tpl = $tpl; } protected function parseTpl($record) { $this->_record = $record; $ret = preg_replace_callback('|{(.+?)}|', array($this, '_pregReplace'), $this->tpl); unset($this->_record); if ((strpos($ret, 'http')!==0) && ($ret[0] != '/')) { $ret = Am_Di::getInstance()->url($ret, false); } return $ret; } public function _pregReplace($matches) { $var = $matches[1]; if ($var == 'THIS_URL') { $ret = Am_Di::getInstance()->request->getRequestUri(); } elseif (preg_match('|^(.+)\(\)$|', $var, $regs)) { $ret = call_user_func(array($this->_record, $regs[1])); } else { $ret = $this->_record->{$var}; } return htmlentities(urlencode($ret), ENT_QUOTES, 'UTF-8'); } public function render(&$out, $obj, $controller) { $content = $this->parseTpl($obj); $out = preg_replace('|()(.+)()|', '\1'.$content.'\3', $out); } }Decorator/Abstract.php000064400000000736152101622450010746 0ustar00field = $field; } function render(& $out, $obj, $controller) { } function get(& $out, $obj, $controller, $field) { } function renderTitle(& $out, $controller) { } function renderStatic(& $out) { } } Decorator/Attrs.php000064400000001341152101622450010271 0ustar00hAttrs = $hAttrs; $this->dAttrs = $dAttrs; } public function render(&$out, $obj, $grid) { if ($this->dAttrs) { $attrs = Am_Html::attrs($this->dAttrs); $out = preg_replace('|()|', '\1 '.$attrs.'\2', $out); } } function renderTitle(&$out, $grid) { if ($this->hAttrs) { $attrs = Am_Html::attrs($this->hAttrs); $out = preg_replace('|()|', '\1 '.$attrs.'\2', $out); } } }Decorator/Shorten.php000064400000001341152101622450010616 0ustar00len = $len; parent::__construct(); } public function render(&$out, $obj, $controller) { $out = preg_replace_callback('|()(.+)()|i', array($this, '_cb'), $out); } public function _cb($regs) { if (strlen($regs[2]) > $this->len) { $regs[2] = sprintf('%s', htmlentities($regs[2], ENT_QUOTES, 'UTF-8'), substr($regs[2], 0, $this->len) . '...'); } $val = $regs[1] . $regs[2] . $regs[3]; return $val; } }Decorator/LiveSelect.php000064400000003754152101622450011245 0ustar00action = $action; parent::__construct(); } public function render(&$out, $obj, $grid) { $options = $this->action->getOptions(); $wrap = $this->getWrapper($obj, $grid); preg_match('{()(.*)()}is', $out, $match); $out = $match[1] . '
'. $wrap[0] . ($match[2] ? $grid->escape($options[$match[2]]) : $grid->escape($this->action->getPlaceholder())) . $wrap[1] . $match[3]; } protected function divideUrlAndParams($url) { $ret = explode('?', $url, 2); if (count($ret)<=1) return array($ret[0], null); parse_str($ret[1], $params); return array($ret[0], $params); } protected function getWrapper($obj, $grid) { $id = $this->action->getIdForRecord($obj); $val = $obj->{$this->field->getFieldName()}; list($url, $params) = $this->divideUrlAndParams($this->action->getUrl($obj, $id)); $start = sprintf('', $val ? '' : ' live-edit-placeholder', $grid->getId() . '_' . $this->field->getFieldName() . '-' . $grid->escape($id), $url, $grid->escape(json_encode($params)), $grid->escape($this->action->getPlaceholder()), $grid->escape(json_encode($this->action->getOptions())), $grid->escape(sprintf('', Am_Html::renderOptions($this->action->getOptions()))), $grid->escape($val) ); $stop = ''; return array($start, $stop); } }Decorator/LiveCheckbox.php000064400000003342152101622450011545 0ustar00action = $action; parent::__construct(); } public function render(&$out, $obj, $grid) { $content = $this->getContent($obj, $grid); preg_match('{()(.*)()}i', $out, $match); $out = $match[1] . $content . $match[3]; } protected function divideUrlAndParams($url) { $ret = explode('?', $url, 2); if (count($ret) <= 1) return array($ret[0], null); parse_str($ret[1], $params); return array($ret[0], $params); } protected function getContent($obj, Am_Grid_Editable $grid) { if (!$this->action->isAvailable($obj)) return; $id = $this->action->getIdForRecord($obj); $val = $obj->{$this->field->getFieldName()}; list($url, $params) = $this->divideUrlAndParams($this->action->getUrl($obj, $id)); $content = sprintf('', $grid->escape($grid->getId() . '_' . $this->field->getFieldName() . '-' . $grid->escape($id)), $grid->escape($url), $id, $grid->escape(json_encode($params)), $grid->escape($this->action->getValue()), $grid->escape($this->action->getEmptyValue()), (($val == $this->action->getValue()) ? 'checked ' : '')); return $content; } }Decorator/DetailGrid.php000064400000004103152101622450011203 0ustar00title = $title; $this->fnName = $fnName; if (empty($this->fnName)) $this->fnName = 'dg_'. str_replace('.', '', microtime(true)); parent::__construct($tpl); } public function render(&$out, $obj, $controller) { $url = $this->parseTpl($obj); $start = sprintf('', $this->fnName, htmlentities($url, ENT_QUOTES, 'UTF-8') ); $stop = ''; $out = preg_replace('|()(.+)()|', '\1'.$start.'\2'.$stop.'\3', $out); } public function renderStatic(&$out) { $title = json_encode($this->title); $out .= << jQuery(document).on('click',".grid-detail-link", function(event){ var href = this.href; var field = jQuery(this).data("field"); event.stopPropagation(); if (!jQuery(".grid-detail-dialog.grid-detail-field" + field).length) jQuery("body").append("
"); var div = jQuery(".grid-detail-dialog:first"); div.data('href', href); jQuery(div).load(href, function(){ if (!div.find('grid-wrap').length) { div.html("
" + div.html() + "
"); } div.data('href', this.href); div.dialog({ autoOpen: true ,width: 800 ,closeOnEscape: true ,title: $title ,modal: true }); } ); return false; }); CUT; } }Decorator/LiveEdit.php000064400000004421152101622450010703 0ustar00action = $action; parent::__construct(); } public function render(&$out, $obj, $grid) { $wrap = $this->getWrapper($obj, $grid); preg_match('{()(.*)()}is', $out, $match); $out = $match[1] . '
'. $wrap[0] . ($match[2] ? $match[2] : $grid->escape($this->action->getPlaceholder())) . $wrap[1] . $match[3]; } protected function divideUrlAndParams($url) { $ret = explode('?', $url, 2); if (count($ret)<=1) return array($ret[0], null); parse_str($ret[1], $params); return array($ret[0], $params); } protected function getWrapper($obj, $grid) { $id = $this->action->getIdForRecord($obj); $val = $obj->{$this->field->getFieldName()}; list($url, $params) = $this->divideUrlAndParams($this->action->getUrl($obj, $id)); $start = sprintf('', $val ? '' : ' live-edit-placeholder', $grid->getId() . '_' . $this->field->getFieldName() . '-' . $grid->escape($id), $grid->escape($this->getInputTemplate()), $url, $grid->escape(json_encode($params)), $grid->escape($this->action->getPlaceholder()), $grid->escape($this->action->getInitCallback()) ); $stop = ''; return array($start, $stop); } public function getInputTemplate() { if ($this->inputTemplate) return $this->inputTemplate; else return sprintf("", $this->inputSize); } public function setInputTemplate($tpl) { $this->inputTemplate = $tpl; } public function setInputSize($size) { $this->inputSize = (int)$size; return $this; } }