public static function mlookup($control) { /* $idHidden = new MHiddenField(); $idHidden->setId($control->id); $textHidden = new MHiddenField(); $textHidden->setId($control->id . '_text'); */ //$id = $control->id; //$control->property->id = $id . '_lookup'; //$control->property->name = $id . '_lookup'; //$control->property->filters = $control->property->filter; $control->style->width = $control->style->width ?: '100px'; //$related = "{$idHidden->id}:{$control->idField},{$textHidden->id}:{$control->textField},"; //$control->property->related = $related . $control->related; //$control->property->filters = $control->filters; $control->property->filters .= "," . $control->id; $lookup['idField'] = strtoupper($control->idField); $lookup['textField'] = strtoupper($control->textField); $lookup['url'] = Manager::getAppURL($control->property->action); if ($control->hasControls()) { foreach ($control->controls as $child) { if ($child->tag == 'mlookupcolumn') { $columns[] = array('field' => strtoupper($child->property->field), 'hidden' => $child->property->visible === false, 'title' => $child->property->title, 'width' => $child->width); } /* else { if ($child instanceof mlookupoptions) { $lookup['loadMsg'] = $child->loadMsg ? : "Carregando..."; $lookup['minLength'] = $child->minLength; $lookup['panelWidth'] = $child->panelWidth; $lookup['fitColumns'] = $child->fitColumns; } } */ } $lookup['columns'][0] = $columns; } //$control->property->lookup = urlencode(json_encode($lookup)); self::$page->addJsCode("\$('#{$control->property->id}').data('lookup', '" . MJSON::encode($lookup) . "');\n"); self::$page->addJsCode("\$('#{$control->property->id}').data('related', '" . MJSON::encode($control->property->related) . "');\n"); self::$page->addJsCode("\$('#{$control->property->id}').data('filters', '" . MJSON::encode($control->property->filters) . "');\n"); self::$page->onLoad("mlookup('{$control->property->id}');"); $attributes = self::getAttributes($control); /* {self::mhiddenfield($idHidden)} {self::mhiddenfield($textHidden)} */ return <<<EOT <select {$attributes}></select> EOT; }
public function buildURL($action = '', $parameters = array()) { $app = Manager::getApp(); $module = Manager::getModule(); if ($action[0] == '@') { $url = Manager::getAppURL($app); $action = substr($action, 1); } elseif ($action[0] == '>') { $url = Manager::getAppURL($app); $action = substr($action, 1); } elseif ($action[0] == '#') { $url = Manager::getStaticURL(); $action = substr($action, 1); } else { $url = Manager::getAppURL($app); } $path = ''; $parts = explode('/', $action); $i = 0; $n = count($parts); if ($parts[$i] == $app) { ++$i; --$n; } if ($n == 3) { //module $path = '/' . $parts[$i] . '/' . $parts[$i + 1] . '/' . $parts[$i + 2]; } elseif ($n == 2) { $path = '/' . $parts[$i] . '/' . $parts[$i + 1]; } elseif ($n == 1) { $path = '/' . $parts[$i]; } else { throw new EMException(_M('Error building URL. Action = ' . $action)); } if (count($parameters)) { $query = http_build_query($parameters); $path .= (strpos($path, '?') === false ? '?' : '') . $query; } $url .= $path; return $url; }
public function __construct($msg = null, $code = 0) { parent::__construct(_M($msg), $code, Manager::getAppURL('', 'main')); $this->log(); }