Example #1
0
 protected function afterInit()
 {
     if (!$this->label && !is_bool($this->label)) {
         $this->label = ucfirst($this->name);
     }
     if (!is_object($this->cfg->value)) {
         $this->cfg->value = utils::htmlOut($this->cfg->value);
     }
     $this->id = str_replace(array('[]', '[', ']'), array('_', '_', ''), $this->name);
 }
Example #2
0
    public function toHtml()
    {
        if ($this->cfg->mode == 'view') {
            return $this->getValue();
        }
        $options = $this->tinyMce;
        if (is_array($this->cfg->tinyBrowser) && $this->cfg->getInArray('tinyBrowser', 'active')) {
            $tinyBrowser = $this->cfg->tinyBrowser;
            $options['file_browser_callback'] = 'function(field_name, url, type, win) {
				tinyMCE.activeEditor.windowManager.open({
					file : "' . $tinyBrowser['url'] . '?' . session::getInstance()->getSessIdForce() . '=' . urlencode(session_id()) . '&type=" + type' . ($tinyBrowser['subdir'] ? '+"&subdir=' . $tinyBrowser['subdir'] . '"' : '') . ',
					title : "' . $tinyBrowser['title'] . '",
					width : ' . $tinyBrowser['width'] . ',
					height : ' . $tinyBrowser['height'] . ',
					resizable : "yes",
					scrollbars : "yes",
					inline : "yes",  // This parameter only has an effect if you use the inlinepopups plugin!
					close_previous : "no"
				}, {
					window : win,
					input : field_name
				});
				return false;
			}';
        } else {
            if (is_array($this->cfg->nyroBrowser) && $this->cfg->getInArray('nyroBrowser', 'active')) {
                $nyroBrowser = $this->cfg->nyroBrowser;
                $options['file_browser_callback'] = 'function(field_name, url, type, win) {
				tinyMCE.activeEditor.windowManager.open({
					file : "' . $nyroBrowser['url'] . '?' . session::getInstance()->getSessIdForce() . '=' . urlencode(session_id()) . '&type="+type+"&config=' . $nyroBrowser['config'] . '&",
					title : "' . $nyroBrowser['title'] . '",
					width : ' . $nyroBrowser['width'] . ',
					height : ' . $nyroBrowser['height'] . ',
					resizable : "yes",
					scrollbars : "yes",
					inline : "yes",  // This parameter only has an effect if you use the inlinepopups plugin!
					close_previous : "no"
				}, {
					window : win,
					input : field_name
				});
				return false;
			}';
            }
        }
        if (array_key_exists('content_css', $options) && $options['content_css']) {
            $contentCss = $options['content_css'];
            $options['setup'] = 'function(ed) {ed.onInit.add(function(ed) {setTimeout(function() {ed.dom.add(ed.dom.select("head"), "link", {rel : "stylesheet", href : "' . $contentCss . '"});}, 5);});}';
        }
        unset($options['content_css']);
        $resp = response::getInstance()->getProxy();
        $resp->addJs('jquery.tinymce');
        $resp->blockjQuery('$("#' . $this->id . '").tinymce(' . utils::jsEncode($options) . ');');
        return utils::htmlTag($this->htmlTagName, array_merge($this->html, array('name' => $this->name, 'id' => $this->id)), utils::htmlOut($this->getValue()));
    }
Example #3
0
 /**
  * Set the form element value
  *
  * @param mixed $value The value
  * @param boolean $refill Indicate if the value is a refill one
  * @param null|string $key Null if set both values or string to set only one value
  */
 public function setValue($value, $refill = false, $key = null)
 {
     $value = utils::htmlOut($value);
     if (is_array($value)) {
         $min = array_key_exists('min', $value) ? $value['min'] : (array_key_exists(0, $value) ? $value[0] : null);
         $max = array_key_exists('max', $value) ? $value['max'] : (array_key_exists(1, $value) ? $value[1] : null);
         $this->cfg->setInArray('rangeValue', 'min', $min);
         $this->cfg->setInArray('rangeValue', 'max', $max);
         $this->cfg->value = $value;
     } else {
         if (!is_null($key)) {
             $this->cfg->setInArray('rangeValue', $key, $value);
             $this->cfg->setInArray('value', $key, $value);
         }
     }
 }
Example #4
0
 public function setValue($value, $refill = false, $key = null)
 {
     $value = utils::htmlOut($value);
     if (is_array($value)) {
         $min = array_key_exists('min', $value) ? $value['min'] : (array_key_exists(0, $value) ? $value[0] : null);
         $max = array_key_exists('max', $value) ? $value['max'] : (array_key_exists(1, $value) ? $value[1] : null);
         $this->setValue($min, $refill, 'min');
         $this->setValue($max, $refill, 'max');
     } else {
         if (!is_null($key)) {
             if ($refill) {
                 $this->dates[$key]->set($value, 'formatDate', 'short2');
             } else {
                 $this->dates[$key]->set($value);
             }
             $this->cfg->setInArray('rangeValue', $key, $this->dates[$key]->format());
             $this->cfg->setInArray('value', $key, $value);
             $this->set[$key] = true;
         }
     }
 }
Example #5
0
	/**
	 * Get the translation for a keyword
	 *
	 * @param string $key The keyword
	 * @param bool $show Indicate if the word found should be directly shown
	 * @param bool $out Indicate if the word should be outted
	 * @return null|string
	 */
	public static function __($key, $show=false, $out=true) {
		self::initCfg();
		$ret = null;
		if (strpos($key, '_') !== false) {
			$keys = explode('_', $key);
			$ret = self::$cfg->getInArray($keys[0], $keys[1]);
		} else
			$ret = self::$cfg->get($key);
		
		if ($out)
			$ret = utils::htmlOut($ret);
		
		if (is_array($ret))
			$ret = array_map('nl2br', $ret);
		else
			$ret = nl2br($ret);
		
		if ($show)
			echo $ret;
		else
			return $ret;
	}
Example #6
0
 /**
  * Parse values send through POST data and eventually add the new ones
  *
  * @param array $values Valeus to parse
  * @return array Values to use
  */
 protected function addNew(array $values)
 {
     $new = isset($values['new']) && is_array($values['new']) ? array_filter($values['new']) : null;
     unset($values['new']);
     if ($this->cfg->allowAdd && count($new) && is_array($new)) {
         $dbList = $this->cfg->dbList;
         if (is_array($dbList) && $dbList['table']) {
             $tbl = db::get('table', $dbList['table']);
             $list = utils::htmlDeOut($this->cfg->list);
             $i18n = isset($dbList['i18nFields']) && $dbList['i18nFields'];
             if (!$i18n) {
                 $field = substr($dbList['fields'], strlen($dbList['ident']) + 1);
             }
             foreach ($new as $v) {
                 $exists = array_search($v, $list);
                 if ($exists === false) {
                     $row = $tbl->getRow();
                     if ($i18n) {
                         $i18nRow = $row->getI18nRow();
                         $i18nRow->set($dbList['i18nFields'], $v);
                     } else {
                         $row->set($field, $v);
                     }
                     $id = $row->save();
                     $values[] = $id;
                     $list[$id] = $v;
                 } else {
                     $values[] = $exists;
                 }
             }
             $this->cfg->list = utils::htmlOut($list);
             if (is_array($this->cfg->list)) {
                 $this->addRule('in', array_keys($this->cfg->list));
             }
         }
     }
     return $values;
 }
Example #7
0
<?php

echo '<h1>' . $error . '</h1>';
echo utils::htmlOut(session::getFlash('nyroError')) . '<br /><br />';
echo security::getInstance()->getLoginForm();
Example #8
0
 /**
  * Format the date directly by a string format 
  *
  * @param string $format Date format
  * @return string The date formated
  */
 public function formatDirect($format)
 {
     $time = $this->getArray();
     $month = $this->cfg->getInArray('month', 'm' . intval($time['m']));
     $day = $this->cfg->getInArray('day', 'd' . intval($time['w']));
     $places = array('H' => str_pad($time['H'], 2, '0', STR_PAD_LEFT), 'A' => $time['A'], 'h' => str_pad($time['h'], 2, '0', STR_PAD_LEFT), 'i' => str_pad($time['i'], 2, '0', STR_PAD_LEFT), 's' => str_pad($time['s'], 2, '0', STR_PAD_LEFT), 'o' => ($time['o'] < 0 ? '-' : '+') . str_pad($time['o'], 4, '0', STR_PAD_LEFT), 'YYYY' => $time['y'], 'YY' => substr($time['y'], -2), 'MMM' => $month['l'], 'MM' => $month['m'], 'M' => str_pad($time['m'], 2, '0', STR_PAD_LEFT), 'D' => str_pad($time['d'], 2, '0', STR_PAD_LEFT), 'EEE' => $day['l'], 'EE' => $day['m']);
     $intermediate = array();
     $i = 0;
     foreach ($places as $k => $p) {
         $intermediate[$k] = '_|_' . $i . '_|_';
         $i++;
     }
     $ret = str_replace($intermediate, $places, str_replace(array_keys($intermediate), $intermediate, $format));
     if ($this->cfg->htmlOut) {
         $ret = utils::htmlOut($ret);
     }
     return $ret;
 }
Example #9
0
	/**
	 * Get the HTML Meta
	 *
	 * @param string $ln New line character
	 * @return strings
	 */
	protected function getHtmlMeta($ln = "\n") {
		$ret = null;

		if (array_key_exists('Content-Type', $this->headers))
			$ret.= '<meta http-equiv="Content-Type" content="'.$this->headers['Content-Type'].'" />'.$ln;

		if ($this->cfg->titleInDes)
			$this->cfg->setInArray('meta', 'description',
					$this->cfg->getInarray('meta', 'title').
					$this->cfg->titleInDes.
					$this->cfg->getInarray('meta', 'description'));
		foreach($this->cfg->meta as $k=>$v) {
			if ($k != 'title' || $this->cfg->useTitleInMeta)
				$ret.= '<meta name="'.$k.'" content="'.utils::htmlOut($v).'" />'.$ln;
		}
		foreach($this->cfg->metaProperty as $k=>$v)
			$ret.= '<meta property="'.$k.'" content="'.utils::htmlOut($v).'" />'.$ln;
		foreach($this->cfg->link as $k=>$v)
			$ret.= utils::htmlTag('link', array_merge(array('rel'=>$k), utils::htmlOut($v))).$ln;
		return $ret;
	}
Example #10
0
	public function getLoginForm(array $prm = array()) {
		if (!$this->form) {
			$this->form = $this->table->getRow()->getForm(array(
				$this->cfg->getInArray('fields', 'login'),
				$this->cfg->getInArray('fields', 'pass')
			), array_merge($this->cfg->formOptions, $prm, array(
				'action'=>request::uri($this->getPage('login'))
			)), false);
			$this->form->get($this->cfg->getInArray('fields', 'login'))->getValid()->delRule('dbUnique');
			if ($this->cfg->stayConnected) {
				$this->form->add('checkbox', array(
					'name'=>'stayConnected',
					'label'=>false,
					'uniqValue'=>true,
					'valid'=>array('required'=>false),
					'list'=>array(
						1=>utils::htmlOut($this->cfg->labelStayConnected)
					)
				));
			}
		}

		return $this->form;
	}
Example #11
0
 /**
  * Get the description field
  *
  * @return string
  */
 public function getDescription()
 {
     $ret = $this->cfg->description;
     if ($this->cfg->outDescription) {
         $ret = utils::htmlOut($ret);
     }
     return $ret;
 }
Example #12
0
 /**
  * Create the data Table out
  *
  * @param string $type Out type
  * @return string
  */
 public function to($type)
 {
     $tpl = factory::get('tpl', array('module' => $this->cfg->module, 'action' => $this->cfg->name, 'default' => 'dataTable', 'cache' => $this->cfg->cache, 'layout' => false));
     $data = $this->getData();
     if (count($data)) {
         if (empty($this->cfg->fields)) {
             $headersT = $data->getFields('flatReal');
             if ($keyRelated = array_search('related', $headersT)) {
                 unset($headersT[$keyRelated]);
             }
             foreach ($this->table->getI18nFields() as $f) {
                 $headersT[] = db::getCfg('i18n') . $f['name'];
             }
         } else {
             $headersT = $this->cfg->fields;
             if ($this->cfg->addIdentField && !in_array($this->table->getIdent(), $headersT)) {
                 array_unshift($headersT, $this->table->getIdent());
             }
         }
         $headers = array();
         $prmReplaceSortBy = '[sortBy]';
         $prmReplaceSortDir = '[sortDir]';
         $paramUrlA = request::get('paramA');
         unset($paramUrlA['page' . $this->cfg->nameParam]);
         $paramUrlA['sortBy' . $this->cfg->nameParam] = $prmReplaceSortBy;
         $paramUrlA['sortDir' . $this->cfg->nameParam] = $prmReplaceSortDir;
         $paramUrlA['page' . $this->cfg->nameParam] = 1;
         $tmpSortLink = request::uriDef(array('paramA' => $paramUrlA));
         foreach ($headersT as $k => $h) {
             $typeField = $this->table->getField($h, 'type');
             if ($typeField == 'file' && is_array($tmp = $this->table->getField($h, 'comment')) && array_key_exists(0, $tmp)) {
                 $typeField = $tmp[0];
             }
             $headers[$k] = array('label' => $this->table->getLabel($h), 'name' => $h, 'url' => str_replace(array($prmReplaceSortBy, $prmReplaceSortDir), array(db::isI18nName($h) ? $this->table->getI18nTable()->getName() . '_' . db::unI18nName($h) : $h, $this->cfg->sortBy == $h && $this->cfg->sortDir == 'asc' ? 'desc' : 'asc'), $tmpSortLink), 'type' => $typeField);
         }
         $actions = null;
         $actionsAlt = null;
         $actionsImg = null;
         if (is_array($this->cfg->actions) && !empty($this->cfg->actions)) {
             $actions = array();
             if (!$this->cfg->addIdentField) {
                 array_unshift($headersT, $this->table->getIdent());
             }
             array_walk($headersT, create_function('&$h', '$h = "[".$h."]";'));
             $dataK = null;
             $i = 0;
             foreach ($data as $d) {
                 $tmp = $this->getActions($d);
                 $tmpVals = $d->getValues('flatNoRelated');
                 $vals = array();
                 foreach ($headersT as $k => $v) {
                     $v = substr($v, 1, -1);
                     $vals[$k] = array_key_exists($v, $tmpVals) ? $tmpVals[$v] : null;
                 }
                 $curData = $d->getValues('data');
                 unset($curData['related']);
                 unset($curData['linked']);
                 if (is_null($dataK)) {
                     $dataK = array_keys($curData);
                     array_walk($dataK, create_function('&$h', '$h = "[".$h."]";'));
                 }
                 foreach ($tmp as &$t) {
                     $t = str_replace($dataK, $curData, $t);
                 }
                 $actions[$i] = $tmp;
                 $i++;
             }
             if (!empty($actions) && $this->cfg->actionsConfirmDelete) {
                 response::getInstance()->addJs('actionsConfirmDelete');
             }
             $actionsKey = array_keys($this->cfg->actions);
             $actionsAlt = $this->cfg->actionsAlt;
             if (!is_array($actionsAlt) || count($actionsAlt) < count($actionsKey)) {
                 foreach ($actionsKey as $v) {
                     if (!array_key_exists($v, $actionsAlt)) {
                         $actionsAlt[$v] = ucfirst($v);
                     }
                 }
             }
             $actionsImg = $this->cfg->actionsImg;
             foreach ($actionsKey as $v) {
                 if (!array_key_exists($v, $actionsImg)) {
                     $actionsImg[$v] = utils::getIcon(array('name' => $v, 'attr' => array('title' => $actionsAlt[$v]), 'alt' => $actionsAlt[$v], 'type' => $this->cfg->iconType));
                 }
             }
         }
         if ($this->cfg->sortBy) {
             $paramUrlA['sortBy' . $this->cfg->nameParam] = $this->cfg->sortBy;
             $paramUrlA['sortDir' . $this->cfg->nameParam] = $this->cfg->sortDir;
         } else {
             unset($paramUrlA['sortBy' . $this->cfg->nameParam]);
             unset($paramUrlA['sortDir' . $this->cfg->nameParam]);
         }
         $nbPage = $this->getNbPage();
         $pageLinks = array();
         $prmReplace = $this->cfg->pageLinkReplace;
         if (!$this->cfg->pageLinkTpl) {
             $paramUrlA['page' . $this->cfg->nameParam] = $prmReplace;
             $tmpPageLink = request::uriDef(array('paramA' => $paramUrlA));
         } else {
             $tmpPageLink = $this->cfg->pageLinkTpl;
         }
         for ($i = 1; $i <= $nbPage; $i++) {
             $pageLinks[$i] = str_replace($prmReplace, $i, $tmpPageLink);
         }
         if ($this->cfg->pageLinkTpl1) {
             $pageLinks[1] = $this->cfg->pageLinkTpl1;
         }
         $hasMultiple = count($this->cfg->multiple) > 0;
         if ($hasMultiple && $this->cfg->addCheckAllJs) {
             response::getInstance()->addJs('checkAll');
         }
         $tpl->setA(array_merge(array('headers' => $headers, 'list' => $data, 'nbPage' => $nbPage, 'currentPage' => $this->cfg->page, 'pageLinks' => $pageLinks, 'actions' => $actions, 'actionsImg' => $actionsImg, 'actionsAlt' => $actionsAlt, 'iconType' => $this->cfg->iconType, 'tblName' => $this->table->getName(), 'sortBy' => $this->cfg->sortBy, 'sortByReal' => $this->sortBy, 'sortDir' => $this->cfg->sortDir, 'hasMultiple' => $hasMultiple, 'multipleLabel' => $this->cfg->multipleLabel, 'multipleSubmit' => $this->cfg->multipleSubmit, 'multipleAction' => $this->cfg->multipleAction, 'multipleIdent' => $this->table->getIdent(), 'multiple' => $this->cfg->multiple), $this->cfg->tplVars));
     } else {
         // No data
         if ($this->cfg->page > 1) {
             $newPage = $this->cfg->page - 1;
             $uri = null;
             if ($newPage == 1 && $this->cfg->pageLinkTpl1) {
                 $uri = $this->cfg->pageLinkTpl1;
             }
             if (!$uri) {
                 $prmReplace = $this->cfg->pageLinkReplace;
                 if (!$this->cfg->pageLinkTpl) {
                     $paramUrlA = request::get('paramA');
                     unset($paramUrlA['page' . $this->cfg->nameParam]);
                     $prmReplaceSortBy = '[sortBy]';
                     $prmReplaceSortDir = '[sortDir]';
                     $paramUrlA['sortBy' . $this->cfg->nameParam] = $prmReplaceSortBy;
                     $paramUrlA['sortDir' . $this->cfg->nameParam] = $prmReplaceSortDir;
                     $paramUrlA['page' . $this->cfg->nameParam] = 1;
                     if ($this->cfg->sortBy) {
                         $paramUrlA['sortBy' . $this->cfg->nameParam] = $this->cfg->sortBy;
                         $paramUrlA['sortDir' . $this->cfg->nameParam] = $this->cfg->sortDir;
                     } else {
                         unset($paramUrlA['sortBy' . $this->cfg->nameParam]);
                         unset($paramUrlA['sortDir' . $this->cfg->nameParam]);
                     }
                     $paramUrlA['page' . $this->cfg->nameParam] = $prmReplace;
                     $tmpPageLink = request::uriDef(array('paramA' => $paramUrlA));
                 } else {
                     $tmpPageLink = $this->cfg->pageLinkTpl;
                 }
                 $uri = str_replace($prmReplace, $newPage, $tmpPageLink);
             }
             response::getInstance()->redirect($uri);
         }
         $tpl->set('noData', utils::htmlOut($this->cfg->noData));
         $tpl->set('list', null);
         $tpl->setA($this->cfg->tplVars);
     }
     return $tpl->fetch(array('tplExt' => $type));
 }
Example #13
0
 /**
  * Transform the element to a string to be shown
  *
  * @param string $type The output type
  * @return string
  */
 public function to($type)
 {
     $this->addCaptcha();
     $ret = null;
     $prm = $this->cfg->get($type);
     if ($this->cfg->check($tmp = $type . ucfirst($this->cfg->mode))) {
         $prm = array_merge($prm, $this->cfg->get($tmp));
     }
     if (!$this->cfg->showSection) {
         $prm = array_merge($prm, $this->cfg->get($type . 'NoSection'));
         if ($this->cfg->check($tmp = $type . 'NoSection' . ucfirst($this->cfg->mode))) {
             $prm = array_merge($prm, $this->cfg->get($tmp));
         }
     }
     $hiddenGlobal = is_array($prm) && (array_key_exists('noHidden', $prm) && $prm['noHidden']) || !(strpos($prm['global'], '[hidden]') === false);
     $hiddens = null;
     $errorPos = $prm['errorPos'];
     $errorsGlobal = array();
     foreach ($this->section as $kSection => $sectionName) {
         $fields = null;
         $errorsSection = array();
         foreach ($this->elements[$kSection] as $name => $e) {
             $des = $e->description ? str_replace('[des]', $e->getDescription(), $prm['des']) : null;
             $line = $e->isHidden() ? 'lineHidden' : 'line';
             $errors = null;
             if ($this->isBound() && !$e->isValid() && !$e->isHidden()) {
                 $tmp = array();
                 foreach ($e->getErrors() as $err) {
                     $tmp[] = str_replace('[error]', $err, $prm['lineErrorLine']);
                     $errorsSection[] = str_replace('[error]', $err, $prm['sectionErrorLine']);
                     $errorsGlobal[] = str_replace('[error]', $err, $prm['globalErrorLine']);
                 }
                 $errors = $errorPos == 'field' ? str_replace('[errors]', implode('', $tmp), $prm['lineErrorWrap']) : null;
                 $line = 'lineError';
             }
             $requiredMoreLabel = $e->getValidRule('required') ? $this->cfg->requiredMoreLabel : null;
             $label = $e->label ? $e->label . $requiredMoreLabel . $this->cfg->sepLabel : $this->cfg->emptyLabel;
             $tmp = str_replace(array('[des]', '[label]', '[field]', '[errors]', '[id]', '[classLine]'), array($des, $label, $e->to($type), $errors, $e->id, $e->classLine), $prm[$line]);
             if ($e->isHidden() && $hiddenGlobal) {
                 $hiddens .= $tmp;
             } else {
                 $fields .= $tmp;
             }
         }
         if ($fields) {
             $errors = null;
             $section = 'section';
             if (!empty($errorsSection) && $errorPos == 'section') {
                 $errors = implode('', $errorsSection);
                 $section .= 'Error';
             }
             $ret .= str_replace(array('[errors]', '[fields]', '[label]'), array($errors, $fields, $this->cfg->outSection ? utils::htmlOut($sectionName) : $sectionName), $prm[$section]);
         }
     }
     $plus = null;
     if ($type == 'html') {
         if (array_key_exists('incFiles', $prm)) {
             foreach ($prm['incFiles'] as $f) {
                 response::getInstance()->add($f);
             }
         }
         $plus = 'action="' . $this->cfg->action . '" method="' . $this->cfg->method . '"';
         if ($this->hasFiles) {
             $plus .= ' enctype="multipart/form-data"';
         }
     }
     $plus .= $this->cfg->formPlus;
     $errors = null;
     if (!empty($errorsGlobal) && $errorPos == 'global') {
         $errors = str_replace('[errors]', implode('', $errorsGlobal), $prm['globalError']);
     }
     return str_replace(array('[hidden]', '[errors]', '[content]', '[plus]', '[submit]', '[submitText]', '[submitPlus]'), array($hiddens, $errors, $ret, $plus, $prm['submit'], $this->cfg->submitText, $this->cfg->submitPlus), $prm['global']);
 }
Example #14
0
 public function to($type)
 {
     if ($this->cfg->mode == 'view') {
         if ($this->cfg->uniqValue) {
             return $this->cfg->getInArray('list', $this->getValue(false));
         } else {
             $tmp = array();
             if (is_array($this->cfg->list)) {
                 foreach ($this->cfg->list as $k => $v) {
                     if ($this->isInValue($k)) {
                         $tmp[] = $this->updateLine($type, $k, $v);
                     }
                 }
             }
             /*
             foreach($this->getValue(false) as $v)
             	$tmp[] = $this->cfg->getInArray('list', $v);
             */
             return implode(', ', $tmp);
         }
     }
     $prm = $this->cfg->get($type);
     $inline = $this->cfg->inline ? 'Inline' : null;
     $ret = null;
     $tmp = $prm;
     unset($tmp['plus'], $tmp['global'], $tmp['globalInline'], $tmp['value'], $tmp['selected'], $tmp['disabled'], $tmp['group'], $tmp['name'], $tmp['des']);
     $prm['plus'] .= ' ';
     foreach ($tmp as $k => $v) {
         $prm['plus'] .= $k . '="' . $v . '" ';
     }
     $tmpGr = null;
     $tmpVal = null;
     $descriptions = $this->cfg->descriptions;
     if ($this->cfg->outDescriptions) {
         $descriptions = utils::htmlOut($descriptions);
     }
     if (is_array($this->cfg->list)) {
         foreach ($this->cfg->list as $k => $v) {
             if (is_array($this->cfg->group) && array_key_exists($k, $this->cfg->group) && $tmpGr != $k) {
                 $tmpGr = $k;
                 $ret .= str_replace(array('[label]', '[group]'), array($this->cfg->group[$k], $tmpVal), $prm['group']);
                 $tmpVal = null;
             }
             $plus = $this->isInValue($k) ? $prm['selected'] : null;
             $plus .= $this->isDisabled($k) ? $prm['disabled'] : null;
             $tmpVal .= $this->updateLine($type, $k, str_replace(array('[plus]', '[value]', '[label]', '[des]'), array($plus, $k, $v, isset($descriptions[$k]) ? $descriptions[$k] : null), isset($prm['value' . $inline]) ? $prm['value' . $inline] : $prm['value']));
         }
     }
     if (!empty($tmpGr)) {
         $ret .= str_replace(array('[label]', '[group]'), array($this->cfg->group[$k], $tmpVal), $prm['group']);
     } else {
         $ret .= $tmpVal;
     }
     $this->id = !$this->cfg->uniqValue ? substr($this->cfg->name, 0, -2) : $this->cfg->name;
     return str_replace(array('[values]', '[plus]', '[name]', '[id]'), array($ret, $prm['plus'], $this->cfg->name, $this->id), $prm['global' . $inline]);
 }
Example #15
0
 /**
  * Initialize the labels
  */
 protected function _initLabels()
 {
     $labels = array();
     $cfgLabel = $this->cfg->label;
     foreach ($this->cols as $c) {
         if (array_key_exists($c, $cfgLabel) && ($label = $cfgLabel[$c])) {
             $labels[$c] = utils::htmlOut($label);
             unset($cfgLabel[$c]);
         } else {
             if ($this->fields[$c]['type'] == 'file') {
                 $labels[$c] = ucwords(str_replace('_', ' ', strtolower(substr($c, 0, -5))));
             } else {
                 $use = $c;
                 $pos = strpos($c, '_');
                 if ($pos) {
                     $start = 0;
                     if ($pos == 1) {
                         $start = 2;
                         $pos = strpos($c, '_', $start) - $start;
                     }
                     $use = substr($c, $start, $pos);
                 }
                 $labels[$c] = ucwords(strtolower($use));
             }
         }
         $this->fields[$c]['label'] = $labels[$c];
     }
     foreach ($this->relatedTables as $r) {
         if (array_key_exists($r['table'], $cfgLabel) && ($label = $cfgLabel[$r['table']])) {
             $labels[$r['table']] = utils::htmlOut($label);
             unset($cfgLabel[$r['table']]);
         } else {
             $labels[$r['table']] = ucwords(str_replace('_', ' ', strtolower($r['table'])));
         }
     }
     $this->cfg->label = array_merge($labels, $cfgLabel);
 }
Example #16
0
	/**
	 * Get a message for an error
	 *
	 * @param string $name Error name
	 * @return string The message
	 */
	protected function getMessage($name) {
		return utils::htmlOut($this->cfg->getInArray('messages', $name));
	}