Esempio n. 1
0
 /**
  * constructor
  *
  * @param string      $guid           guid
  * @param string      $date           [day h:m:s]
  * @param int         $length         length of the event (minutes)
  * @param string      $title          title displayed of the event
  * @param null        $color          background color of the event
  * @param bool        $important      is the event important
  * @param null|string $css_class      css class
  * @param null        $draggable_guid is the guid dragable
  * @param bool        $html_escape    do I escape the html from title
  */
 function __construct($guid, $date, $length = 0, $title = "", $color = null, $important = true, $css_class = null, $draggable_guid = null, $html_escape = true)
 {
     $this->guid = $guid;
     $this->draggable_guid = $draggable_guid;
     $this->internal_id = "CPlanningEvent-" . md5(uniqid(null, true));
     $this->start = $date;
     $this->length = $length;
     $this->title = $html_escape ? CMbString::htmlEntities($title) : $title;
     $this->color = $color;
     $this->important = $important;
     $this->css_class = is_array($css_class) ? implode(" ", $css_class) : $css_class;
     $this->mb_object = array("id" => "", "guid" => "", "view" => "");
     if (preg_match("/[0-9]+ /", $this->start)) {
         $parts = explode(" ", $this->start);
         $this->end = "{$parts[0]} " . CMbDT::time("+{$this->length} MINUTES", $parts[1]);
         $this->day = $parts[0];
         $this->hour = CMbDT::format($parts[1], "%H");
         $this->minutes = CMbDT::format($parts[1], "%M");
     } else {
         $this->day = CMbDT::date($date);
         $this->end = CMbDT::dateTime("+{$this->length} MINUTES", $date);
         $this->hour = CMbDT::format($date, "%H");
         $this->minutes = CMbDT::format($date, "%M");
     }
 }
 /**
  * @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} />";
 }
 /**
  * Constructor
  *
  * @param CExchangeHprimSante $exchange   Exchange
  * @param String              $type_error Error type
  * @param String              $code_error Error code
  * @param String[]            $address    Error address
  * @param String              $field      Error field
  * @param String              $comment    Comment
  */
 function CHPrimSanteError($exchange, $type_error, $code_error, $address, $field, $comment = null)
 {
     $this->type_error = $type_error;
     $this->code_error = $code_error;
     $this->address = $address;
     $this->field = $field;
     $this->type = $exchange->type;
     $this->sous_type = $exchange->sous_type;
     $this->exchange = $exchange;
     $this->comment = CMbString::removeAllHTMLEntities($comment);
 }
Esempio n. 4
0
/**
 * Process the exported data
 * 
 * @param string $export Data
 * @param string $label  Add an optionnal label
 * @param bool   $log    Log to file or echo data
 * 
 * @return int The size of the data written in the log file
 **/
function processLog($export, $label = null, $log = false)
{
    $export = CMbString::htmlSpecialChars($export);
    $time = date("Y-m-d H:i:s");
    $msg = "\n<pre>[{$time}] {$label}: {$export}</pre>";
    if ($log) {
        return file_put_contents(LOG_PATH, $msg, FILE_APPEND);
    }
    echo $msg;
    return null;
}
Esempio n. 5
0
 /**
  * @see parent::build
  */
 function build(CHPREvent $event)
 {
     parent::build($event);
     $error = $this->error;
     $acknowledgment = $this->acknowledgment;
     $exchange_hpr = $event->_exchange_hpr;
     $data = array();
     if ($error instanceof CHL7v2Error) {
         // ERR-1: Segment Row
         $data[] = $acknowledgment->_row;
         // ERR-2: Filename
         $data[] = $exchange_hpr->nom_fichier;
         // ERR-3: Date / Time of receipt
         $data[] = $exchange_hpr->date_production;
         // ERR-4: Severity
         $data[] = null;
         // ERR-5: Line number
         $data[] = null;
         // ERR-6: Error Location
         $data[] = null;
         // ERR-7: Field Position
         $data[] = null;
         // ERR-8: Error value
         $data[] = null;
         // ERR-9: Error type
         $data[] = null;
         // ERR-10: Original Text
         $data[] = null;
     } else {
         // ERR-1
         $data[] = $acknowledgment->_row;
         // ERR-2
         $data[] = $exchange_hpr->nom_fichier;
         // ERR-3
         $data[] = $exchange_hpr->date_production;
         // ERR-4
         $data[] = $error[0];
         // ERR-5
         $data[] = null;
         // ERR-6
         $data[] = array(array($error[2][0], $error[2][1], $error[2][2]));
         // ERR-7
         $data[] = null;
         // ERR-8
         $data[] = $error[4];
         // ERR-9
         $data[] = $error[5];
         // ERR-10
         $data[] = CMbString::removeAllHTMLEntities($error[6]);
     }
     $this->fill($data);
 }
Esempio n. 6
0
 /**
  * Process the exported data
  *
  * @param string $export         Data
  * @param string $label          Add an optionnal label
  * @param bool   $onlyPlainField Only get DB fields and there values if export is object
  *
  * @return int The size of the data written in the log file
  **/
 static function log($export, $label = null, $onlyPlainField = false)
 {
     if (!CAppUI::conf("debug")) {
         return null;
     }
     if ($export instanceof CMbObject && $onlyPlainField) {
         $export = $export->getPlainFields();
     }
     $export = print_r($export, true);
     $export = CMbString::htmlSpecialChars($export);
     $time = date("Y-m-d H:i:s");
     $msg = "\n<pre>[{$time}] {$label}: {$export}</pre>";
     return file_put_contents(DEBUG_PATH, $msg, FILE_APPEND);
 }
 /**
  * Generate acknowledgment
  *
  * @param string $ack_code       Acknowledgment code
  * @param string $mb_error_codes Mediboard error code
  * @param null   $hl7_error_code HL7 error code
  * @param string $severity       Severity
  * @param null   $comments       Comments
  * @param null   $object         Object
  *
  * @return null|string
  */
 function generateAcknowledgment($ack_code, $mb_error_codes, $hl7_error_code = null, $severity = "E", $comments = null, $object = null)
 {
     $this->ack_code = $ack_code;
     $this->mb_error_codes = $mb_error_codes;
     $this->hl7_error_code = $hl7_error_code;
     $this->severity = $severity;
     $this->comments = CMbString::removeAllHTMLEntities($comments);
     $this->object = $object;
     $this->event->_exchange_hl7v2 = $this->_ref_exchange_hl7v2;
     $this->event_ack = new CHL7v2EventORR($this->event);
     $this->event_ack->build($this);
     $this->event_ack->flatten();
     $this->event_ack->msg_hl7 = utf8_encode($this->event_ack->msg_hl7);
     return $this->event_ack->msg_hl7;
 }
Esempio n. 8
0
 /**
  * Ajout des codes pour les Groups
  *
  * @return bool
  */
 protected function addCodeToGroups()
 {
     $ds = CSQLDataSource::get("std");
     $request = new CRequest();
     $request->addSelect(array("group_id", "code", "text"));
     $request->addTable("groups_mediboard");
     $query = $request->makeSelect();
     $groups = $ds->loadList($query);
     foreach ($groups as $_group) {
         $group_id = $_group["group_id"];
         $code = CMbString::makeInitials($_group["text"]);
         $query = $ds->prepare("UPDATE `groups_mediboard` SET `code`=?1 WHERE `group_id`= ?2", $code, $group_id);
         $ds->exec($query);
     }
     return true;
 }
Esempio n. 9
0
/**
 * import the csv firstname file
 *
 * @param string $targetPath filepath
 * @param int    $start      start from
 * @param int    $count      step of import
 *
 * @return void
 */
function importFile($targetPath, $start, $count)
{
    $fp = fopen($targetPath, 'r');
    //0 = first line
    if ($start == 0) {
        $start++;
    }
    $line_nb = 0;
    while ($line = fgetcsv($fp, null, ";")) {
        if ($line_nb >= $start && $line_nb < $start + $count) {
            $found = false;
            $fn = CMbString::removeDiacritics(trim($line[0]));
            $sex = trim($line[1]);
            $language = CMbString::removeDiacritics(trim($line[2]));
            if ($sex == "m,f" || $sex == "f,m") {
                $sex = "u";
            }
            $firstname = new CFirstNameAssociativeSex();
            $firstname->firstname = $fn;
            $firstname->language = $language;
            $firstname->loadMatchingObjectEsc();
            if ($firstname->_id) {
                // found
                $found = true;
                if ($sex != $firstname->sex) {
                    $firstname->sex = "u";
                }
            } else {
                // not found
                $firstname->sex = $sex;
            }
            // store & message
            if ($msg = $firstname->store()) {
                CAppUI::stepAjax($msg, UI_MSG_WARNING);
            } else {
                if ($found == true) {
                    CAppUI::stepAjax("prénom <strong>{$fn}</strong>, mis à jour <strong>[{$firstname->sex}]</strong>");
                } else {
                    CAppUI::stepAjax("prénom <strong>{$fn}</strong>, ajouté <strong>[{$firstname->sex}]</strong>");
                }
            }
        }
        $line_nb++;
    }
    return;
}
Esempio n. 10
0
 /**
  * Construct the datum for logging
  *
  * @param array   $names_types Types
  * @param string  $contexte    Contexte
  * @param integer $user_id     User who have make the search
  * @param string  $words       the words of the search
  * @param bool    $aggregation aggregation or not
  *
  * @return void
  */
 function log($names_types, $contexte, $user_id, $words, $aggregation)
 {
     if (!$names_types) {
         $names_types = array();
     }
     $document = array();
     $document['aggregation'] = $aggregation;
     $document['body'] = CMbString::normalizeUtf8($words);
     $document['user_id'] = $user_id;
     $document['types'] = implode(" ", $names_types);
     $document['date'] = CMbDT::format(null, "%Y/%m/%d");
     $this->createClient();
     $index = $this->loadIndex($this->loadNameIndex());
     $type = $index->getType($contexte);
     $log = $type->createDocument('', $document);
     $type->addDocument($log);
     $type->getIndex()->refresh();
 }
Esempio n. 11
0
 /**
  * @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;
 }
 /**
  * Range constructor
  *
  * @param string $guid      GUID
  * @param string $date      Date
  * @param int    $length    Length
  * @param string $title     Title
  * @param null   $color     Color
  * @param null   $css_class CSS class
  */
 function __construct($guid, $date, $length = 0, $title = "", $color = null, $css_class = null)
 {
     $this->guid = $guid;
     $this->internal_id = "CPlanningRange-" . uniqid();
     $this->start = $date;
     $this->length = $length;
     $this->title = CMbString::htmlEntities($title);
     $this->color = $color;
     $this->css_class = is_array($css_class) ? implode(" ", $css_class) : $css_class;
     if (preg_match("/[0-9]+ /", $this->start)) {
         $parts = split(" ", $this->start);
         $this->end = "{$parts[0]} " . CMbDT::time("+{$this->length} MINUTES", $parts[1]);
         $this->day = $parts[0];
         $this->hour = CMbDT::format($parts[1], "%H");
         $this->minutes = CMbDT::format($parts[1], "%M");
     } else {
         $this->day = CMbDT::date($date);
         $this->end = CMbDT::dateTime("+{$this->length} MINUTES", $date);
         $this->hour = CMbDT::format($date, "%H");
         $this->minutes = CMbDT::format($date, "%M");
     }
 }
 /**
  * Nettoie du code HTML
  *
  * @param string $html the html string
  *
  * @return string the cleaned html
  */
 static function sanitizeHTML($html)
 {
     //check if html is present
     if (!preg_match("/<html/", $html)) {
         $html = '<html><head><title>E-mail</title></head><body>' . $html . '</body></html>';
     }
     //=>XML
     $html = CMbString::convertHTMLToXMLEntities($html);
     //load & repair dom
     $document = new CMbXMLDocument();
     $document->preserveWhiteSpace = false;
     @$document->loadHTML($html);
     //remove scripts tag
     $xpath = new DOMXpath($document);
     $filter = array("//script", "//meta", "//applet", "//iframe");
     //some dangerous
     foreach ($filter as $_filter) {
         $elements = $xpath->query($_filter);
         foreach ($elements as $_element) {
             $_element->parentNode->removeChild($_element);
         }
     }
     $html = $document->saveHTML();
     //Cleanup after save
     $html = preg_replace("/<!DOCTYPE(.*?)>/", '', $html);
     $html = preg_replace("/\\/\\/>/mu", "/>", $html);
     $html = preg_replace("/nowrap/", '', $html);
     $html = preg_replace("/<[b|h]r([^>]*)>/", "<br \$1/>", $html);
     $html = preg_replace("/<img([^>]+)>/", "<img\$1/>", $html);
     return $html;
 }
Esempio n. 14
0
 /**
  * @see parent::filter()
  */
 function filter($value)
 {
     if (CAppUI::conf("purify_text_input")) {
         $value = CMbString::purifyHTML($value);
     }
     return parent::filter($value);
 }
 * @package    Mediboard
 * @subpackage forms
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 17759 $
 */
CCanDo::checkEdit();
$ex_class_event_id = CValue::get("ex_class_event_id");
$keywords = CValue::get("_host_field_view");
$ex_class_event = new CExClassEvent();
$ex_class_event->load($ex_class_event_id);
$list = $ex_class_event->buildHostFieldsList();
$show_views = false;
// filtrage
if ($keywords) {
    $show_views = true;
    $re = preg_quote($keywords);
    $re = CMbString::allowDiacriticsInRegexp($re);
    $re = str_replace("/", "\\/", $re);
    $re = "/({$re})/i";
    foreach ($list as $_key => $element) {
        if (!preg_match($re, $element["title"])) {
            unset($list[$_key]);
        }
    }
}
$smarty = new CSmartyDP();
$smarty->assign("ex_class_event", $ex_class_event);
$smarty->assign("host_fields", $list);
$smarty->assign("show_views", $show_views);
$smarty->display("inc_autocomplete_hostfields.tpl");
Esempio n. 16
0
/**
 * @package Mediboard
 * @subpackage hl7
 * @version $Revision: 15455 $
 * @author SARL OpenXtrem
 * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 */
$er7 = CValue::post("er7");
$query = CValue::post("query");
$hl7_message = new CHL7v2Message();
$hl7_message->parse($er7);
$xml = $hl7_message->toXML();
if ($query) {
    $xpath = new CMbXPath($xml);
    $results = @$xpath->query("//{$query}");
    $nodes = array();
    // Création du template
    $smarty = new CSmartyDP();
    if ($results) {
        foreach ($results as $result) {
            $nodes[] = CMbString::highlightCode("xml", $xml->saveXML($result));
        }
    }
    $smarty->assign("nodes", $nodes);
    $smarty->display("inc_er7_xml_result.tpl");
} else {
    ob_clean();
    header("Content-Type: text/xml");
    echo $xml->saveXML();
    CApp::rip();
}
Esempio n. 17
0
 /**
  * @see parent::updateFormFields()
  */
 function updateFormFields()
 {
     parent::updateFormFields();
     $this->_view = CMbString::truncate($this->traitement, 40);
 }
 /**
  * @see parent::build
  */
 function build(CHPrimSanteEvent $event)
 {
     parent::build($event);
     $patient = $this->patient;
     $sejour = $this->sejour;
     $actor = isset($event->_sender->_id) ? $event->_sender : $event->_receiver;
     $group = $actor->loadRefGroup();
     $patient->loadIPP($group->_id);
     // P-1: type segment - P(par défaut) (ST)
     // P-2: rang segment - (NM)
     $data[] = "1";
     // P-3: Patient ID (SPEC) (optional)
     $data[] = array(array($patient->_IPP, $patient->_patient_elimine ? $patient->_patient_elimine->_IPP : null, $patient->_patient_elimine ? "FU" : null));
     // P-4: Patient ID (ST) (optional)
     $data[] = null;
     // P-5: sejour ID (ST) (optional)
     $data[] = null;
     // P-6: Nom patient (PN) (optional)
     $data[] = array(array($patient->_p_last_name, $patient->_p_first_name, $patient->prenom_2, $patient->civilite));
     // P-7: Nom de naissance (ST) (optional)
     $data[] = $patient->_p_maiden_name;
     // P-8: Date de naissance (TS) (optional)
     $data[] = $patient->_p_birth_date;
     // P-9: Sexe (ID) (optional)
     $data[] = CMbString::upper($patient->sexe);
     // P-10: race (forbidden)
     $data[] = null;
     $address = explode("\n", $patient->_p_street_address, 1);
     // P-11: adresse (AD) (optional)
     $data[] = array(array(CMbArray::get($address, 0), str_replace("\n", " ", CMbArray::get($address, 1)), $patient->_p_city, null, $patient->_p_postal_code, $patient->pays_insee));
     // P-12: INS (version 2.3) (optional)
     $data[] = null;
     // P-13: téléphone (TN) (optional) (repeatable)
     $data[] = array($patient->_p_phone_number, $patient->_p_mobile_phone_number);
     // P-14: Médecins (CNA) (optional) (repeatable)
     $data[] = null;
     // P-15: Traitement local 1 (ST) (optional)
     $data[] = null;
     // P-16: Traitement local 2 (ST) (optional)
     $data[] = null;
     // P-17: Taille (CQ) (optional)
     $data[] = null;
     // P-18: Poids (CQ) (optional)
     $data[] = null;
     // P-19: Diagnostic (CE) (optional) (repeatable)
     $data[] = null;
     // P-20: Traitement (ST) (optional) (repeatable)
     $data[] = null;
     // P-21: Régime (ST) (optional)
     $data[] = null;
     // P-22: Commentaire 1 (ST) (optional)
     $data[] = null;
     // P-23: Commentaire 2 (ST) (optional)
     $data[] = null;
     // P-24: Date de mouvement (TS) (optional) (repeatable)
     $data[] = null;
     // P-25: Statut de l'admission (ID) (optional)
     $data[] = null;
     // P-26: Localisation (SPEC) (optional)
     $data[] = null;
     // P-27: classification diagnostic (CE) (optional)
     $data[] = null;
     // P-28: Religion (forbidden)
     $data[] = null;
     // P-29: Situation maritale (ID) (optional)
     $data[] = $this->getMaritalStatus($patient->situation_famille);
     // P-30: Précauton à prendre (ID) (optional)
     $data[] = null;
     // P-31: Langue (ST) (optional)
     $data[] = null;
     // P-32: Statut de confidentialité (ID) (optional)
     $data[] = null;
     // P-33: Date de dernière modification (TS) (optional)
     $data[] = null;
     // P-34: Date de décès (TS) (optional)
     $data[] = null;
     $this->fill($data);
 }
Esempio n. 19
0
 /**
  * Writes a locale file
  * 
  * @param string $language The language code (fr, en, ...)
  * @param array  $locales  The locales
  * @param string $label    A code to istinguish different locales listes
  * 
  * @return void
  */
 static function writeLocaleFile($language, $locales = null, $label = null)
 {
     global $version;
     if (!$locales) {
         $localeFiles = array_merge(glob("./locales/{$language}/*.php"), glob("./modules/*/locales/{$language}.php"), glob("./mobile/modules/*/locales/{$language}.php"));
         foreach ($localeFiles as $localeFile) {
             if (basename($localeFile) != "meta.php") {
                 include $localeFile;
             }
         }
     }
     $path = self::getLocaleFilePath($language, $label);
     if ($fp = fopen($path, 'w')) {
         $locales = CMbString::filterEmpty($locales);
         // TODO: change the invalid keys (with accents) of the locales to simplify this
         $keys = array_map('utf8_encode', array_keys($locales));
         $values = array_map('utf8_encode', array_values($locales));
         foreach ($values as &$_value) {
             $_value = CMbString::unslash($_value);
         }
         $compress = false;
         if ($compress) {
             $delim = "/([\\.-])/";
             $arr = new stdClass();
             foreach ($keys as $_pos => $_key) {
                 $parts = preg_split($delim, $_key, -1, PREG_SPLIT_DELIM_CAPTURE);
                 $_arr = $arr;
                 $last_key = count($parts) - 1;
                 foreach ($parts as $i => $_token) {
                     $last = $i == $last_key;
                     if ($_token === "") {
                         $_token = '_$_';
                     }
                     if ($last) {
                         $_arr->{$_token} = (object) array('$' => $values[$_pos]);
                         break;
                     } elseif (!isset($_arr->{$_token})) {
                         $_arr->{$_token} = new stdClass();
                     }
                     $_arr = $_arr->{$_token};
                 }
                 //unset($_arr);
             }
             self::clearLocalesKeys($arr);
             $json = $arr;
         } else {
             $json = array_combine($keys, $values);
         }
         $script = '//' . $version['build'] . "\nwindow.locales=" . json_encode($json) . ";";
         fwrite($fp, $script);
         fclose($fp);
     }
 }
 /**
  * @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;
 }
Esempio n. 21
0
 /**
  * Apply the mode of identito vigilance
  *
  * @param String $string                  String
  * @param Bool   $firstname               Apply the lower and the capitalize
  * @param string $mode_identito_vigilance Identito-vigilance mode
  * @param bool   $anonyme                 Is anonyme
  *
  * @return string
  */
 static function applyModeIdentitoVigilance($string, $firstname = false, $mode_identito_vigilance = null, $anonyme = false)
 {
     $mode = $mode_identito_vigilance ? $mode_identito_vigilance : CAppUI::conf("dPpatients CPatient mode_identito_vigilance", CGroups::loadCurrent());
     switch ($mode) {
         case "medium":
             $result = CMbString::removeBanCharacter($string, true);
             $result = $firstname ? CMbString::capitalize(CMbString::lower($result)) : CMbString::upper($result);
             break;
         case "strict":
             $result = CMbString::upper(CMbString::removeBanCharacter($string, $anonyme));
             break;
         default:
             $result = $firstname ? CMbString::capitalize(CMbString::lower($string)) : CMbString::upper($string);
     }
     return $result;
 }
Esempio n. 22
0
     $headerfooter = substr($_POST["_source"], 0, $posBody);
     $index_div = strrpos($_POST["_source"], "</div>") - ($posBody + strlen($bodyTag));
     $body = substr($_POST["_source"], $posBody + strlen($bodyTag), $index_div);
 } else {
     $headerfooter = "";
     $body = $_POST["_source"];
 }
 // On fait le doBind avant le foreach si la config est à 1.
 if (CAppUI::conf("dPcompteRendu CCompteRendu multiple_doc_correspondants")) {
     $do->doBind();
 }
 $allSources = array();
 $modele_base = clone $do->_obj;
 $source_base = $body;
 foreach ($destinataires as &$curr_dest) {
     $fields = array(CMbString::htmlEntities("[Courrier - Formule de politesse - Début]"), CMbString::htmlEntities("[Courrier - Formule de politesse - Fin]"), CMbString::htmlEntities("[Courrier - nom destinataire]"), CMbString::htmlEntities("[Courrier - adresse destinataire]"), CMbString::htmlEntities("[Courrier - cp ville destinataire]"), CMbString::htmlEntities("[Courrier - confraternite]"), CMbString::htmlEntities("[Courrier - copie à - simple]"), CMbString::htmlEntities("[Courrier - copie à - simple (multiligne)]"), CMbString::htmlEntities("[Courrier - copie à - complet]"), CMbString::htmlEntities("[Courrier - copie à - complet (multiligne)]"));
     // Champ copie à : on reconstruit en omettant le destinataire.
     $confraternie = "";
     $copyTo = "";
     $copyToMulti = "";
     $copyToComplet = "";
     $copyToCompletMulti = "";
     foreach ($destinataires as $_dest) {
         if ($curr_dest[0] == $_dest[0]) {
             continue;
         }
         $_destinataire = $allDest[$_dest[1]][$_dest[2]];
         $_destinataire->nom = preg_replace("/(.*)(\\([^\\)]+\\))/", '$1', $_destinataire->nom);
         $_destinataire->confraternite = $_destinataire->confraternite ? $_destinataire->confraternite . "," : null;
         $copyTo .= $_destinataire->nom . "; ";
         $copyToMulti .= $_destinataire->nom . "<br />";
 */
global $version;
CCanDo::checkEdit();
/////////// Locales
foreach (glob("locales/*", GLOB_ONLYDIR) as $localeDir) {
    $localeName = basename($localeDir);
    $locales = array();
    $localeFiles = CAppUI::getLocaleFilesPaths($localeName);
    foreach ($localeFiles as $localeFile) {
        if (basename($localeFile) != "meta.php") {
            include $localeFile;
        }
    }
    $locales = CMbString::filterEmpty($locales);
    foreach ($locales as &$_locale) {
        $_locale = CMbString::unslash($_locale);
    }
    $path = "./tmp/locales-{$localeName}.js";
    if (!is_file($path)) {
        CAppUI::stepAjax("Locales-javascript-cache-none", UI_MSG_OK, $localeName);
        continue;
    }
    $fp = fopen($path, 'r');
    preg_match('#^//(\\d+)#', fgets($fp), $v);
    if ($v[1] < $version['build']) {
        CAppUI::stepAjax("Locales-javascript-cache-ko", UI_MSG_WARNING, $localeName);
        fclose($fp);
        continue;
    }
    if (null == SHM::get("locales-{$localeName}-" . CAppUI::LOCALES_PREFIX)) {
        CAppUI::stepAjax("Locales-shm-none", UI_MSG_OK, $localeName);
 /**
  * Check all properties according to specification
  *
  * @return string|null Store-like message, null when no problem
  */
 function check()
 {
     $debug = CAppUI::conf("debug");
     $msg = "";
     // Property level checking
     foreach ($this->_props as $name => $prop) {
         if ($name[0] !== '_') {
             if (!property_exists($this, $name)) {
                 trigger_error("La spécification cible la propriété '{$name}' inexistante dans la classe '{$this->_class}'", E_USER_WARNING);
             } else {
                 $value = $this->{$name};
                 if (!$this->_id || $value !== null) {
                     $msgProp = $this->checkProperty($name);
                     $truncated = CMbString::truncate($value);
                     $debugInfo = $debug ? "(val:\"{$truncated}\", prop:\"{$prop}\")" : "(valeur: \"{$truncated}\")";
                     $fieldName = CAppUI::tr("{$this->_class}-{$name}");
                     $msg .= $msgProp ? " &bull; <strong title='{$name}'>{$fieldName}</strong> : {$msgProp} {$debugInfo} <br/>" : null;
                 }
             }
         }
     }
     if ($this->_merging) {
         return $msg;
     }
     // Class level unique checking
     foreach ($this->_spec->uniques as $unique => $names) {
         /** @var self $other */
         $other = new $this->_class();
         $values = array();
         foreach ($names as $name) {
             $this->completeField($name);
             $other->{$name} = addslashes($this->{$name});
             $value = "";
             if ($this->_specs[$name] instanceof CRefSpec) {
                 $fwd = $this->loadFwdRef($name);
                 if ($fwd) {
                     $value = $fwd->_view;
                 }
             } else {
                 $value = $this->{$name};
             }
             $values[] = $value;
         }
         $other->loadMatchingObject();
         if ($other->_id && $this->_id != $other->_id) {
             return CAppUI::tr("{$this->_class}-failed-{$unique}") . " : " . implode(", ", $values);
         }
     }
     // Class-level xor checking
     foreach ($this->_spec->xor as $xor => $names) {
         $n = 0;
         $fields = array();
         foreach ($names as $name) {
             $this->completeField($name);
             $fields[] = CAppUI::tr("{$this->_class}-{$name}");
             if ($this->{$name}) {
                 $n++;
             }
         }
         if ($n != 1) {
             return CAppUI::tr("{$this->_class}-xorFailed-{$xor}") . ": " . implode(", ", $fields) . ")";
         }
     }
     return $msg;
 }
 /**
  * Obtention des listes utilisées dans le document
  *
  * @param CListeChoix[] $lists Listes de choix
  *
  * @return CListeChoix[]
  */
 function getUsedLists($lists)
 {
     $this->usedLists = array();
     foreach ($lists as $value) {
         $nom = CMbString::htmlEntities(stripslashes("[Liste - {$value->nom}]"), ENT_QUOTES);
         $pos = strpos($this->document, $nom);
         if ($pos !== false) {
             $this->usedLists[$pos] = $value;
         }
     }
     ksort($this->usedLists);
     return $this->usedLists;
 }
Esempio n. 26
0
 /**
  * @see parent::updateFormFields()
  */
 function updateFormFields()
 {
     parent::updateFormFields();
     $this->_view = $this->_name;
     $this->_shortview = CMbString::truncate($this->_name);
     $this->_cp_court = substr($this->cp, 0, 2);
 }
 /**
  * @see parent::getAutocompleteList()
  */
 function getAutocompleteList($keywords, $where = null, $limit = null, $ljoin = null, $order = null)
 {
     /** @var self[] $list */
     $list = $this->loadList($where, null, null, null, $ljoin);
     $real_list = array();
     $re = preg_quote($keywords);
     $re = CMbString::allowDiacriticsInRegexp($re);
     $re = str_replace("/", "\\/", $re);
     $re = "/({$re})/i";
     foreach ($list as $_ex_field) {
         if ($keywords == "%" || $keywords == "" || preg_match($re, $_ex_field->_view)) {
             $_ex_field->updateTranslation();
             $_group = $_ex_field->loadRefExGroup();
             $_ex_field->_view = "{$_group->_view} - {$_ex_field->_view}";
             $real_list[$_ex_field->_id] = $_ex_field;
         }
     }
     return $real_list;
 }
 /**
  * Truncate a string to a given maximum length
  *
  * @param string $string The string to truncate
  *
  * @return string The truncated string
  */
 public static function truncate($string)
 {
     if (!is_string($string)) {
         return $string;
     }
     // Truncate
     $max = 1024;
     $result = CMbString::truncate($string, $max);
     // Indicate true size
     $length = strlen($string);
     if ($length > 1024) {
         $result .= " [{$length} bytes]";
     }
     return $result;
 }
Esempio n. 29
0
 /**
  * @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;
 }
 function getAutocompleteList($keywords, $where = null, $limit = null, $ljoin = null, $order = null)
 {
     $list = $this->loadList($where, null, null, null, $ljoin);
     /** @var self[] $real_list */
     $real_list = array();
     $re = preg_quote($keywords);
     $re = CMbString::allowDiacriticsInRegexp($re);
     $re = str_replace("/", "\\/", $re);
     $re = "/({$re})/i";
     foreach ($list as $_match) {
         if ($keywords == "%" || $keywords == "" || preg_match($re, $_match->_view)) {
             $_match->loadView();
             $real_list[$_match->_id] = $_match;
         }
     }
     $views = CMbArray::pluck($real_list, "_view");
     array_multisort($views, $real_list);
     $empty = new self();
     $empty->_id = null;
     $empty->_guid = "{$this->_class}-{$this->_id}";
     // FIXME
     $empty->_view = " -- ";
     array_unshift($real_list, $empty);
     return $real_list;
 }