<?php

/**
 * $Id:$
 *  
 * @package    Mediboard
 * @subpackage dPsante400
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision:$
 * @link       http://www.mediboard.org
 */
$object_id = CValue::get('object_id');
$object_class = CValue::get('object_class');
$hypertext_link_id = CValue::get('hypertext_link_id', 0);
$hypertext_link = new CHyperTextLink();
$hypertext_link->object_id = $object_id;
$hypertext_link->object_class = $object_class;
if ($hypertext_link_id) {
    $hypertext_link->load($hypertext_link_id);
}
$smarty = new CSmartyDP();
$smarty->assign('hypertext_link', $hypertext_link);
$smarty->assign('show_widget', CValue::get('show_widget', 0));
$smarty->display('inc_edit_hypertext_link.tpl');
 /**
  * OBX Segment with reference pointer to external report
  *
  * @param DOMNode   $OBX    DOM node
  * @param CMbObject $object object
  * @param String    $name   name
  *
  * @return bool
  */
 function getReferencePointerToExternalReport(DOMNode $OBX, CMbObject $object, $name)
 {
     $exchange_hl7v2 = $this->_ref_exchange_hl7v2;
     $sender = $exchange_hl7v2->_ref_sender;
     //Récupération de l'emplacement et du type du fichier (full path)
     $observation = $this->getObservationValue($OBX);
     $rp = explode("^", $observation);
     $pointer = CMbArray::get($rp, 0);
     $type = CMbArray::get($rp, 2);
     // Création d'un lien Hypertext sur l'objet
     if ($type == "HTML") {
         $hyperlink = new CHyperTextLink();
         $hyperlink->setObject($object);
         $hyperlink->name = $name;
         $hyperlink->link = $pointer;
         $hyperlink->loadMatchingObject();
         if ($msg = $hyperlink->store()) {
             $this->codes[] = "E343";
             return false;
         }
         return true;
     }
     // Chargement des objets associés à l'expéditeur
     /** @var CInteropSender $sender_link */
     $object_links = $sender->loadRefsObjectLinks();
     if (!$object_links) {
         $this->codes[] = "E340";
         return false;
     }
     $sender_link = new CInteropSender();
     $files_category = new CFilesCategory();
     // On récupère toujours une seule catégorie, et une seule source associée à l'expéditeur
     foreach ($object_links as $_object_link) {
         if ($_object_link->_ref_object instanceof CFilesCategory) {
             $files_category = $_object_link->_ref_object;
         }
         if ($_object_link->_ref_object instanceof CInteropSender) {
             $sender_link = $_object_link->_ref_object;
             continue 1;
         }
     }
     // Aucun expéditeur permettant de récupérer les fichiers
     if (!$sender_link->_id) {
         $this->codes[] = "E340";
         return false;
     }
     $authorized_sources = array("CSenderFileSystem", "CSenderFTP");
     // L'expéditeur n'est pas prise en charge pour la réception de fichiers
     if (!CMbArray::in($sender_link->_class, $authorized_sources)) {
         $this->codes[] = "E341";
         return false;
     }
     $sender_link->loadRefsExchangesSources();
     // Aucune source permettant de récupérer les fichiers
     if (!$sender_link->_id) {
         $this->codes[] = "E342";
         return false;
     }
     $source = $sender_link->getFirstExchangesSources();
     $path = str_replace("\\", "/", $pointer);
     $path = basename($path);
     if ($source instanceof CSourceFileSystem) {
         $path = $source->getFullPath() . "/{$path}";
     }
     // Exception déclenchée sur la lecture du fichier
     try {
         $content = $source->getData("{$path}");
     } catch (Exception $e) {
         $this->codes[] = "E345";
         return false;
     }
     if (!$type) {
         $type = CMbPath::getExtension($path);
     }
     $file_type = $this->getFileType($type);
     $file_name = $this->getObservationFilename($OBX);
     // Gestion du CFile
     $file = new CFile();
     $file->setObject($object);
     $file->file_name = $file_name ? $file_name : $name;
     $file->file_type = $file_type;
     $file->loadMatchingObject();
     if ($files_category->_id && $sender->_configs["associate_category_to_a_file"]) {
         $file->file_category_id = $files_category->_id;
     }
     $file->file_date = "now";
     $file->doc_size = strlen($content);
     $file->fillFields();
     $file->updateFormFields();
     $file->putContent($content);
     if ($msg = $file->store()) {
         $this->codes[] = "E343";
     }
     $this->codes[] = "I340";
     return true;
 }
/**
 * $Id: ajax_list_hypertextlinks.php 28759 2015-06-29 13:13:35Z aurelie17 $
 *  
 * @package    Mediboard
 * @subpackage dPsante400
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 28759 $
 * @link       http://www.mediboard.org
 */
$object_id = CValue::get('object_id', 0);
$object_class = CValue::get('object_class', '');
$show_widget = CValue::get('show_widget', 0);
$smarty = new CSmartyDP();
if ($object_id && $object_class) {
    $filter = new CHyperTextLink();
    $filter->object_id = $object_id;
    $filter->object_class = $object_class;
    $hypertext_links = $filter->loadMatchingList();
} else {
    $hypertext_links = array();
}
$smarty->assign('hypertext_links', $hypertext_links);
$smarty->assign('object_id', $object_id);
$smarty->assign('object_class', $object_class);
$smarty->assign('show_only', CValue::getOrSession('show_only', 0));
$smarty->assign('count_links', CValue::get('count_links', 0));
if (!$show_widget) {
    $smarty->display('inc_list_hypertext_links.tpl');
} else {
    $smarty->display('inc_widget_list_hypertext_links.tpl');