/**
  * 
  * @param string $ps_format
  * @return BaseInformationService 
  */
 public static function getInformationServiceForFormat($ps_format)
 {
     InformationServiceManager::initInformationServices();
     $va_services = InformationServiceManager::getInformationServiceNames();
     foreach ($va_services as $vs_service) {
         if ($o_reader = InformationServiceManager::getInformationServiceInstance($vs_service)) {
             if ($o_reader->canReadFormat($ps_format)) {
                 return $o_reader;
             }
         }
     }
     return null;
 }
 /**
  *
  *
  */
 public function getAvailableSettings($pa_element_info = null)
 {
     global $_ca_attribute_settings;
     $vs_service = isset($pa_element_info['service']) ? $pa_element_info['service'] : null;
     $va_names = InformationServiceManager::getInformationServiceNames();
     if (!in_array($vs_service, $va_names)) {
         $vs_service = $va_names[0];
     }
     if ($this->opo_plugin = InformationServiceManager::getInformationServiceInstance($vs_service)) {
         $va_settings = $this->opo_plugin->getAvailableSettings() + $_ca_attribute_settings['InformationServiceAttributeValue'];
         $va_settings['service']['options'] = InformationServiceManager::getInformationServiceNamesOptionList();
         $va_service = $va_settings['service'];
         unset($va_settings['service']);
         $va_settings = array('service' => $va_service) + $va_settings;
     } else {
         $va_settings = array();
     }
     return $va_settings;
 }
 /**
  * Fetch details on an item from a remote data source and output results of the 'display' key in the response.
  *
  */
 public function GetDetail()
 {
     $pn_element_id = $this->request->getParameter('element_id', pInteger);
     $t_element = new ca_metadata_elements($pn_element_id);
     $va_data = array();
     if (!$t_element->getPrimaryKey()) {
         // error
         $va_items['error'] = array('label' => _t('ERROR: Invalid element_id'), 'idno' => '');
     } else {
         $vs_service = $t_element->getSetting('service');
         $va_settings = $t_element->getSettings();
         $pn_attribute_id = $this->request->getParameter('id', pInteger);
         $t_attr_val = new ca_attribute_values();
         if ($t_attr_val->load(array('attribute_id' => $pn_attribute_id, 'element_id' => $pn_element_id))) {
             $t_attr = new ca_attributes();
             if ($t_attr->load($pn_attribute_id)) {
                 if (!caCanRead($this->request->getUserID(), $t_attr->get('table_num'), $t_attr->get('row_id'), $t_element->get('element_code'))) {
                     $va_items['error'] = array('label' => _t('ERROR: You do not have access to this item'), 'idno' => '');
                 } else {
                     $vs_url = $t_attr_val->get('value_longtext2');
                     if (!($o_plugin = InformationServiceManager::getInformationServiceInstance($vs_service))) {
                         $va_items['error'] = array('label' => _t('ERROR: Invalid service'), 'idno' => '');
                     } else {
                         $vs_cache_key = md5(print_r($va_settings, true) . $vs_url);
                         if (CompositeCache::contains($vs_cache_key, 'InformationServiceExtendedInfo')) {
                             $va_data = CompositeCache::fetch($vs_cache_key, 'InformationServiceExtendedInfo');
                         } else {
                             $va_data = $o_plugin->getExtendedInformation($va_settings, $vs_url);
                             CompositeCache::save($vs_cache_key, $va_data, 'InformationServiceExtendedInfo');
                         }
                     }
                 }
             }
         }
     }
     $this->view->setVar('detail', $va_data);
     return $this->render('ajax_information_service_detail_html.php');
 }