/** * @see parent::getValue() */ function getValue($object, $smarty = null, $params = array()) { $value = $object->{$this->fieldName}; $decimals = CMbArray::extract($params, "decimals", $this->decimals); $empty = CMbArray::extract($params, "empty"); return CSmartyMB::currency($value, $decimals, $this->precise, $empty); }
/** * @see parent::getFormHtmlElement() */ function getFormHtmlElement($object, $params, $value, $className) { $field = CMbString::htmlSpecialChars($this->fieldName); $value = CMbString::htmlSpecialChars($value); $class = CMbString::htmlSpecialChars("{$className} {$this->prop}"); $form = CMbArray::extract($params, "form"); $extra = CMbArray::makeXmlAttributes($params); return "<input type=\"tel\" name=\"{$field}\" value=\"{$value}\" class=\"{$class} styled-element\" {$extra} />"; }
/** * @see parent::updateFormFields() */ function updateFormFields() { $this->_query_params_get = $get = json_decode($this->query_params_get, true); $this->_query_params_post = $post = json_decode($this->query_params_post, true); $this->_session_data = $session = json_decode($this->session_data, true); $get = is_array($get) ? $get : array(); $post = is_array($post) ? $post : array(); $this->_module = CValue::first(CMbArray::extract($get, "m"), CMbArray::extract($post, "m")); $this->_action = CValue::first(CMbArray::extract($get, "tab"), CMbArray::extract($get, "a"), CMbArray::extract($post, "dosql")); }
/** * @see parent::getValue() */ function getValue($object, $smarty = null, $params = array()) { if ($smarty) { include_once $smarty->_get_plugin_filepath('modifier', 'date_format'); } $propValue = $object->{$this->fieldName}; $format = CMbArray::extract($params, "format", CAppUI::conf("datetime")); if ($format === "relative") { $relative = CMbDate::relative($propValue, CMbDT::dateTime()); return $relative["count"] . " " . CAppUI::tr($relative["unit"] . ($relative["count"] > 1 ? "s" : "")); } $date = CMbArray::extract($params, "date"); if ($date && CMbDT::date($propValue) == $date) { $format = CAppUI::conf("time"); } return $propValue && $propValue != "0000-00-00 00:00:00" ? smarty_modifier_date_format($propValue, $format) : ""; }
/** * @see parent::getFormHtmlElement() */ function getFormHtmlElement($object, $params, $value, $className) { $field = CMbString::htmlSpecialChars($this->fieldName); $form = CMbArray::extract($params, "form"); $extra = CMbArray::makeXmlAttributes($params); $readonly = CMbArray::extract($params, "readonly"); $default_color = $this->default ? $this->default : "ffffff"; $reset_value = $this->notNull ? $default_color : ""; $bg_reset = $reset_value ? "#{$reset_value}" : "transparent"; $value = !$value && ($this->notNull || $this->default) ? $default_color : $value; $sHtml = "\n <input type=\"text\" class=\"color_picker\" name=\"{$field}\" value=\"{$value}\" {$extra} />\n <button type=\"button\" onclick=\"var elem = \$(this).previous('input'); \$V(elem, '{$reset_value}', true); elem.setStyle({backgroundColor: '{$bg_reset}'});\" class='cancel notext'></button>\n "; if ($form && !$readonly) { $js_params = "{}"; if (!$this->notNull) { $js_params = "{required:false}"; } $sHtml .= "<script type=\"text/javascript\">\n Main.add(function(){\n var _e = getForm('" . $form . "').elements['" . $field . "'];\n new jscolor.color(_e, {$js_params});\n })\n </script>"; } return $sHtml; }
/** * @see parent::getFormHtmlElement() */ function getFormHtmlElement($object, $params, $value, $className) { $form = CMbArray::extract($params, "form"); // needs to be extracted $field = CMbString::htmlSpecialChars($this->fieldName); $extra = CMbArray::makeXmlAttributes($params); $sHtml = '<input type="password" name="' . $field . '" class="' . CMbString::htmlSpecialChars(trim($className . ' ' . $this->prop)) . ' styled-element" '; if ($this->revealable) { $sHtml .= ' value="' . CMbString::htmlSpecialChars($value) . '" '; } $sHtml .= $extra . ' />'; if ($this->revealable) { $sHtml .= '<button class="lookup notext" type="button" onclick="var i=$(this).previous(\'input\');i.type=(i.type==\'password\')?\'text\':\'password\'"></button>'; } if ($this->randomizable) { $random_call = "getRandomPassword('{$object->_class}', '{$field}');"; $title = CAppUI::tr("common-action-Get random password"); $sHtml .= '<button class="change notext" type="button" onclick="' . $random_call . '" title="' . $title . '"></button>'; } $sHtml .= '<span id="' . $field . '_message"></span>'; return $sHtml; }
/** * The constructor * * @param string $rooturl The URL of the wsdl file * @param string $type The type of exchange * @param array $options An array of options * @param boolean $loggable True if you want to log all the exchanges with the web service * @param string $local_cert Path of the certifacte * @param string $passphrase Pass phrase for the certificate * @param bool $safe_mode Safe mode * @param boolean $verify_peer Require verification of SSL certificate used * @param string $cafile Location of Certificate Authority file on local filesystem * @param String $wsdl_external Location of external wsdl * @param int $socket_timeout Default timeout (in seconds) for socket based streams * * @throws CMbException * * @return CMbSOAPClient */ function __construct($rooturl, $type = null, $options = array(), $loggable = null, $local_cert = null, $passphrase = null, $safe_mode = false, $verify_peer = false, $cafile = null, $wsdl_external = null, $socket_timeout = null) { $this->return_mode = CMbArray::extract($options, "return_mode", "normal"); $this->xop_mode = CMbArray::extract($options, "xop_mode", false); $this->use_tunnel = CMbArray::extract($options, "use_tunnel", false); $this->wsdl_url = $rooturl; if ($loggable) { $this->loggable = $loggable; } if ($type) { $this->type_echange_soap = $type; } $login = CMbArray::get($this->options, "login"); $password = CMbArray::get($this->options, "password"); $check_option["local_cert"] = $local_cert; $check_option["ca_cert"] = $cafile; $check_option["passphrase"] = $passphrase; $check_option["username"] = $login; $check_option["password"] = $password; $this->check_option = $check_option; if (!$safe_mode) { if (!($html = CHTTPClient::checkUrl($this->wsdl_url, $this->check_option, true))) { $this->soap_client_error = true; throw new CMbException("CSourceSOAP-unable-to-parse-url", $this->wsdl_url); } if (strpos($html, "<?xml") === false) { $this->soap_client_error = true; throw new CMbException("CSourceSOAP-wsdl-invalid"); } } // Ajout des options personnalisées $options = array_merge($options, array("connection_timeout" => CAppUI::conf("webservices connection_timeout"))); if (CAppUI::conf("webservices trace")) { $options = array_merge($options, array("trace" => true)); } // Authentification HTTP if ($local_cert) { $this->local_cert = $local_cert; $options = array_merge($options, array("local_cert" => $local_cert)); } if ($passphrase) { $this->passphrase = $passphrase; $options = array_merge($options, array("passphrase" => $passphrase)); } if (array_key_exists('stream_context', $options)) { $context = $options['stream_context']; } else { $context = stream_context_create(); } // Authentification SSL if ($verify_peer && $cafile) { $this->ca_info = $cafile; stream_context_set_option($context, "ssl", "verify_peer", $verify_peer); stream_context_set_option($context, "ssl", "cafile", $cafile); } // Délai maximal d'attente pour la lecture $socket_timeout = $socket_timeout ? $socket_timeout : CAppUI::conf("webservices response_timeout"); if ($socket_timeout) { ini_set("default_socket_timeout", $socket_timeout); } $options = array_merge($options, array("stream_context" => $context)); $this->options = $options; if ($wsdl_external) { $this->wsdl_url = $wsdl_external; } parent::__construct($this->wsdl_url, $options); }
$prof = $user->profile_id ? CUser::get($user->profile_id) : new CUser(); if ($user_id == "default") { $user->_id = null; } $prefvalues = array("default" => CPreferences::get(null, true), "template" => $user->profile_id ? CPreferences::get($user->profile_id, true) : array(), "user" => $user->_id !== "" ? CPreferences::get($user->_id, true) : array()); // common sera toujours au debut $prefs = array("common" => array()); // Classement par module et par permission fonctionnelle CPreferences::loadModules(true); foreach (CPreferences::$modules as $modname => $prefnames) { $module = CModule::getActive($modname); $canRead = $module ? CPermModule::getPermModule($module->_id, PERM_READ, $user_id) : false; if ($modname == "common" || $user_id == "default" || $canRead) { $prefs[$modname] = array(); foreach ($prefnames as $prefname) { $prefs[$modname][$prefname] = array("default" => CMbArray::extract($prefvalues["default"], $prefname), "template" => CMbArray::extract($prefvalues["template"], $prefname), "user" => CMbArray::extract($prefvalues["user"], $prefname)); } } } // Warning: user clone necessary! // Some module index change $user global $user_clone = $user; // Chargement des modules $modules = CPermModule::getVisibleModules(); foreach ($modules as $module) { // Module might not be present @(include "./modules/{$module->mod_name}/index.php"); } $user = $user_clone; $smarty = new CSmartyDP(); $smarty->assign("user", $user);
/** * Do action, single object mode * * @param bool $reinstanciate_objects Make new instances of the object (don't use the ones instanciated in the constructor) * * @return void */ function doSingle($reinstanciate_objects) { $this->doBind($reinstanciate_objects); if (CMbArray::extract($this->request, 'del')) { $this->doDelete(); } else { $this->doStore(); } }
function mb_colonne($params, &$smarty) { $class = CMbArray::extract($params, "class", null, true); $field = CMbArray::extract($params, "field", null, true); $order_col = CMbArray::extract($params, "order_col", null, true); $order_way = CMbArray::extract($params, "order_way", null, true); $order_suffixe = CMbArray::extract($params, "order_suffixe", "", false); $url = CMbArray::extract($params, "url", null, false); $function = CMbArray::extract($params, "function", null, false); $label = CMbArray::extract($params, "label", null, false); $sHtml = "<label for=\"{$field}\" title=\"" . CAppUI::tr("{$class}-{$field}-desc") . "\">"; $sHtml .= $label ? $label : CAppUI::tr("{$class}-{$field}-court"); $sHtml .= "</label>"; $css_class = $order_col == $field ? "sorted" : "sortable"; $order_way_inv = $order_way == "ASC" ? "DESC" : "ASC"; if ($url) { if ($css_class == "sorted") { return "<a class='{$css_class} {$order_way}' href='{$url}&order_col{$order_suffixe}={$order_col}&order_way{$order_suffixe}={$order_way_inv}'>{$sHtml}</a>"; } if ($css_class == "sortable") { return "<a class='{$css_class}' href='{$url}&order_col{$order_suffixe}={$field}&order_way{$order_suffixe}=ASC'>{$sHtml}</a>"; } } if ($function) { if ($css_class == "sorted") { return "<a class='{$css_class} {$order_way}' onclick=\"{$function}('{$order_col}','{$order_way_inv}');\">{$sHtml}</a>"; } if ($css_class == "sortable") { return "<a class='{$css_class}' onclick=\"{$function}('{$field}','ASC');\">{$sHtml}</a>"; } } }
/** * Get the patient state * * @param DOMNode $node Node * @param CPatient $newPatient Patient * * @return void */ function getPatientState(DOMNode $node, CPatient $newPatient) { if ($states = $this->queryNodes("PID.32", $node)) { $list_state = array(); foreach ($states as $_state) { $list_state[] = $this->queryTextNode(".", $_state); } $state = CMbArray::extract($list_state, 0); if (!$state) { return; } if ($state == "CACH") { $newPatient->vip = true; $status = CMbArray::get($list_state, 1); if ($status) { $state = $status; } } else { if (in_array("CACH", $list_state)) { $newPatient->vip = true; } } $newPatient->_status_no_guess = true; $newPatient->status = $state; } }
/** * @see parent::getLabelForAttribute() */ function getLabelForAttribute($object, &$params) { $typeEnum = CMbArray::extract($params, "typeEnum", "radio"); switch ($typeEnum) { //case "radio": return "{$this->fieldName}_1"; case "checkbox": return "__{$this->fieldName}"; default: case "radio": case "select": return $this->fieldName; } }
public function testExtract() { $array = array("key" => "val", "key2" => "val2"); $this->assertEquals("val", $this->stub->extract($array, "key")); $this->assertNull($this->stub->extract($array, "notAkey")); }
/** * Get an HTML form datetime input corresponding to the bound object value * * @param object $object Object holding the field * @param array $params Extra parameters * @param string $value The actual value * @param string $className Extra CSS class name * @param string $format Optional datetime format * * @return string HTML form datetime string */ function getFormElementDateTime($object, $params, $value, $className, $format = "%d/%m/%Y %H:%M") { if ($object->_locked) { $params["readonly"] = "readonly"; } $class = CMbString::htmlSpecialChars(trim("{$className} {$this->prop}")); $field = CMbString::htmlSpecialChars($this->fieldName); // Format the date $date = ""; if ($value && $value != '0000-00-00' && $value != '00:00:00' && $value != '0000-00-00 00:00:00') { $date = $this instanceof CDateSpec && $this->progressive ? $this->getValue($object, null, $params) : CMbDT::format($value, $format); } $form = CMbArray::extract($params, "form"); $register = CMbArray::extract($params, "register"); $style = CMbArray::extract($params, "style"); $tabindex = CMbArray::extract($params, "tabindex"); $readonly = CMbArray::get($params, "readonly"); $extra = CMbArray::makeXmlAttributes($params); $html = array(); $html[] = '<input name="' . $field . '_da" type="text" value="' . $date . '" class="' . $class . ' styled-element" readonly="readonly" ' . (isset($tabindex) ? 'tabindex="' . $tabindex . '" ' : '') . ' style="' . $style . '" />'; $html[] = '<input name="' . $field . '" type="hidden" value="' . $value . '" class="' . $class . '" ' . $extra . ' data-visual-element="' . $field . '_da" />'; if ($form && !$readonly && ($register || $this instanceof CTimeSpec)) { $register = $this instanceof CDateSpec && $this->progressive ? 'regProgressiveField' : 'regField'; $html[] = '<script type="text/javascript"> Main.add(function(){Calendar.' . $register . '(getForm("' . $form . '").elements["' . $field . '"])}) </script>'; } return implode("\n", $html); }
/** * $Id: do_configure.php 21614 2014-01-08 16:57:12Z flaviencrochard $ * * @package Mediboard * @subpackage System * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision: 21614 $ */ global $mbpath, $dPconfig; CCanDo::checkAdmin(); $mbpath = ""; CMbArray::extract($_POST, "m"); CMbArray::extract($_POST, "dosql"); CMbArray::extract($_POST, "suppressHeaders"); $ajax = CMbArray::extract($_POST, "ajax"); $config_db = CAppUI::conf("config_db"); if ($config_db) { $configs = $_POST; // Ne pas inclure de config relatives aux bases de données foreach ($_POST as $key => $_config) { if (in_array($key, CMbConfig::$forbidden_values) || $key == "db") { unset($configs[$key]); } else { unset($_POST[$key]); } } $configs = array_map_recursive('stripslashes', $configs); // DB Version $inserts = array(); $ds = CSQLDataSource::get("std");
/** * @see parent::getLabelForAttribute() */ function getLabelForAttribute($object, &$params) { // to extract the XHTML invalid attribute "typeEnum" $typeEnum = CMbArray::extract($params, "typeEnum"); return parent::getLabelForAttribute($object, $params); }
<?php /** * $Id$ * * @package Mediboard * @subpackage SSR * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ $do = new CDoObjectAddEdit('CReplacement'); if ($sejour_ids = CMbArray::extract($_POST, "sejour_ids")) { $do->redirect = null; foreach (explode("-", $sejour_ids) as $sejour_id) { $_POST["sejour_id"] = $sejour_id; $do->doIt(); } echo CAppUI::getMsg(); CApp::rip(); } $do->doIt();
/** * return a detail list of directory * * @param string $folder Directory path * * @return array * @throws CMbException */ private function _getListFilesDetails($folder = ".") { if (!$this->connexion) { throw new CMbException("CSourceSFTP-connexion-failed", $this->hostname); } if (!($files = $this->connexion->rawList($folder))) { throw new CMbException("CSourceSFTP-getlistfiles-failed", $this->hostname); } CMbArray::extract($files, "."); CMbArray::extract($files, ".."); $list = array(); foreach ($files as $key => $_file) { if ($_file["type"] === 2) { continue; } $list[$key] = $_file; } return $list; }
/** * @param array $params Template params: * - options : array of objects with IDs * - choose : string alternative for Choose default option * - size : interger for size of text input * @see classes/CMbFieldSpec#getFormHtmlElement($object, $params, $value, $className) * * @return string */ function getFormHtmlElement($object, $params, $value, $className) { if ($options = CMbArray::extract($params, "options")) { $field = CMbString::htmlSpecialChars($this->fieldName); $className = CMbString::htmlSpecialChars(trim("{$className} {$this->prop}")); $extra = CMbArray::makeXmlAttributes($params); $choose = CMbArray::extract($params, "choose", "Choose"); $choose = CAppUI::tr($choose); $html = "\n<select name=\"{$field}\" class=\"{$className}\" {$extra}>"; $html .= "\n<option value=\"\">— {$choose}</option>"; foreach ($options as $_option) { $selected = $value == $_option->_id ? "selected=\"selected\"" : ""; $html .= "\n<option value=\"{$_option->_id}\" {$selected}>{$_option->_view}</option>"; } $html .= "\n</select>"; return $html; } CMbArray::defaultValue($params, "size", 25); return $this->getFormElementText($object, $params, $value, $className); }
/** * @see parent::getValue() */ function getValue($object, $smarty = null, $params = array()) { $decimals = CMbArray::extract($params, "decimals"); return number_format($object->{$this->fieldName}, $decimals ? $decimals : 2, ',', ' ') . ' %'; }
/** * @see parent::getFormHtmlElement() */ function getFormHtmlElement($object, $params, $value, $className) { $form = CMbArray::extract($params, "form"); $increment = CMbArray::extract($params, "increment"); $showPlus = CMbArray::extract($params, "showPlus"); $fraction = CMbArray::extract($params, "fraction"); $showFraction = CMbArray::extract($params, "showFraction"); $deferEvent = CMbArray::extract($params, "deferEvent"); $bigButtons = CMbArray::extract($params, "bigButtons"); $readonly = CMbArray::get($params, "readonly"); $field = CMbString::htmlSpecialChars($this->fieldName); $min = CMbArray::extract($params, "min"); if ($min === null) { $min = CMbFieldSpec::checkNumeric($this->min, false); } $max = CMbArray::extract($params, "max"); if ($max === null) { $max = CMbFieldSpec::checkNumeric($this->max, false); } $new_value = CMbArray::extract($params, "value"); if ($new_value !== null) { $value = $new_value; } $decimals = CMbArray::extract($params, "decimals", $this->decimals); if ($decimals == null) { $decimals = isset($this->precise) ? 4 : 2; } $step = CMbArray::extract($params, "step"); $step = CMbFieldSpec::checkNumeric($step, false); CMbArray::defaultValue($params, "size", 4); if ($form && $increment && !$readonly) { $sHtml = $this->getFormElementText($object, $params, ($value >= 0 && $showPlus ? '+' : '') . ($value == 0 && $showPlus ? '0' : $value), $className, "number"); $sHtml .= ' <script type="text/javascript"> Main.add(function(){ var element = $(document.forms["' . $form . '"]["' . $field . '"]); if ($(element.form).isReadonly()) return; element.addSpinner({'; if ($step) { $sHtml .= "step: {$step},"; } if ($decimals) { $sHtml .= "decimals: {$decimals},"; } if ($this->pos) { $sHtml .= "min: 0,"; } elseif (isset($min)) { $sHtml .= "min: {$min},"; } if (isset($max)) { $sHtml .= "max: {$max},"; } if ($deferEvent) { $sHtml .= "deferEvent: true,"; } if ($bigButtons) { $sHtml .= "bigButtons: true,"; } if ($showPlus) { $sHtml .= "showPlus: true,"; } if ($fraction) { $sHtml .= "fraction: true,"; } if ($showFraction) { $sHtml .= "showFraction: true,"; } $sHtml .= '_:0 // IE rules }); }); </script>'; } else { $sHtml = $this->getFormElementText($object, $params, $value, $className, "number"); } return $sHtml; }
/** * Assigns a unique id to a variable * * @param array $params Smarty params * - var: Name of the var * @param self &$smarty The Smarty object * * @return void */ function unique_id($params, &$smarty) { $var = CMbArray::extract($params, "var", null, true); // The dot is removed to get valide CSS ID identifiers $smarty->assign($var, str_replace(".", "", uniqid("", true))); }