예제 #1
0
 /**
  * 
  */
 public function GetMediaAttributeViewerHTMLBundle($po_request, $pa_options = null)
 {
     $va_access_values = isset($pa_options['access']) && is_array($pa_options['access']) ? $pa_options['access'] : array();
     $vs_display_type = isset($pa_options['display']) && $pa_options['display'] ? $pa_options['display'] : 'media_overlay';
     $vs_container_dom_id = isset($pa_options['containerID']) && $pa_options['containerID'] ? $pa_options['containerID'] : null;
     $pn_value_id = isset($pa_options['value_id']) && $pa_options['value_id'] ? $pa_options['value_id'] : null;
     $t_attr_val = new ca_attribute_values();
     $t_attr_val->load($pn_value_id);
     $t_attr_val->useBlobAsMediaField(true);
     $o_view = new View($po_request, $po_request->getViewsDirectoryPath() . '/bundles/');
     $o_view->setVar('containerID', $vs_container_dom_id);
     $va_rep_display_info = caGetMediaDisplayInfo('media_overlay', $t_attr_val->getMediaInfo('value_blob', 'INPUT', 'MIMETYPE'));
     $va_rep_display_info['poster_frame_url'] = $t_attr_val->getMediaUrl('value_blob', $va_rep_display_info['poster_frame_version']);
     $o_view->setVar('display_options', $va_rep_display_info);
     $o_view->setVar('representation_id', $pn_representation_id);
     $o_view->setVar('t_attribute_value', $t_attr_val);
     $o_view->setVar('versions', $va_versions = $t_attr_val->getMediaVersions('value_blob'));
     $t_media = new Media();
     $ps_version = $po_request->getParameter('version', pString);
     if (!in_array($ps_version, $va_versions)) {
         if (!($ps_version = $va_rep_display_info['display_version'])) {
             $ps_version = null;
         }
     }
     $o_view->setVar('version', $ps_version);
     $o_view->setVar('version_info', $t_attr_val->getMediaInfo('value_blob', $ps_version));
     $o_view->setVar('version_type', $t_media->getMimetypeTypename($t_attr_val->getMediaInfo('value_blob', $ps_version, 'MIMETYPE')));
     $o_view->setVar('mimetype', $t_attr_val->getMediaInfo('value_blob', 'INPUT', 'MIMETYPE'));
     return $o_view->render('media_attribute_viewer_html.php');
 }
예제 #2
0
 public static function reload_service_values($po_opts = null)
 {
     $va_infoservice_elements = ca_metadata_elements::getElementsAsList(false, null, null, true, false, false, array(__CA_ATTRIBUTE_VALUE_INFORMATIONSERVICE__));
     $o_db = new Db();
     foreach ($va_infoservice_elements as $va_element) {
         $qr_values = $o_db->query("\n\t\t\t\t\tSELECT * FROM ca_attribute_values\n\t\t\t\t\tWHERE element_id = ?\n\t\t\t\t", $va_element['element_id']);
         print CLIProgressBar::start($qr_values->numRows(), "Reloading values for element code " . $va_element['element_code']);
         $t_value = new ca_attribute_values();
         while ($qr_values->nextRow()) {
             $o_val = new InformationServiceAttributeValue($qr_values->getRow());
             $vs_uri = $o_val->getUri();
             print CLIProgressBar::next();
             // inc before first continuation point
             if (!$vs_uri || !strlen($vs_uri)) {
                 continue;
             }
             if (!$t_value->load($qr_values->get('value_id'))) {
                 continue;
             }
             $t_value->editValue($vs_uri);
             if ($t_value->numErrors() > 0) {
                 print _t('There were errors updating an attribute row: ') . join(' ', $t_value->getErrors());
             }
         }
         print CLIProgressBar::finish();
     }
     return true;
 }
예제 #3
0
 /**
  *
  */
 public function editAttribute($pa_values, $pa_options = null)
 {
     if (!$this->getPrimaryKey()) {
         return null;
     }
     $vb_already_in_transaction = $this->inTransaction();
     if (!$vb_already_in_transaction) {
         $o_trans = new Transaction();
         $this->setTransaction($o_trans);
     } else {
         $o_trans = $this->getTransaction();
     }
     unset(ca_attributes::$s_get_attributes_cache[$this->get('table_num') . '/' . $this->get('row_id')]);
     $this->setMode(ACCESS_WRITE);
     $this->set('locale_id', $pa_values['locale_id']);
     $this->update();
     if ($this->numErrors()) {
         if (!$vb_already_in_transaction) {
             $o_trans->rollback();
         }
         $vs_errors = join('; ', $this->getErrors());
         $this->clearErrors();
         $this->postError(1971, $vs_errors, 'ca_attributes->editAttribute()');
         return false;
     }
     $t_attr_val = new ca_attribute_values();
     $t_attr_val->purify($this->purify());
     $t_attr_val->setTransaction($o_trans);
     $t_attr_val->setMode(ACCESS_WRITE);
     $t_element = ca_attributes::getElementInstance($this->get('element_id'));
     $va_elements = $t_element->getElementsInSet();
     $va_attr_vals = $this->getAttributeValues();
     foreach ($va_attr_vals as $o_attr_val) {
         $vn_element_id = intval($o_attr_val->getElementID());
         if ($t_attr_val->load($o_attr_val->getValueID())) {
             if (isset($pa_values[$vn_element_id])) {
                 $vm_value = $pa_values[$vn_element_id];
             } else {
                 $vm_value = $pa_values[$o_attr_val->getElementCode()];
             }
             if ($t_attr_val->editValue($vm_value, $pa_options) === false) {
                 $this->postError(1973, join('; ', $t_attr_val->getErrors()), 'ca_attributes->editAttribute()');
             }
             foreach ($va_elements as $vn_i => $va_element_info) {
                 if ($va_element_info['element_id'] == $vn_element_id) {
                     unset($va_elements[$vn_i]);
                 }
             }
         }
     }
     $vn_attribute_id = $this->getPrimaryKey();
     // Add values that don't already exist (added after the fact?)
     foreach ($va_elements as $vn_index => $va_element) {
         if ($va_element['datatype'] == 0) {
             continue;
         }
         // skip containers
         $vn_element_id = $va_element['element_id'];
         if (isset($pa_values[$vn_element_id])) {
             $vm_value = $pa_values[$vn_element_id];
         } else {
             $vm_value = $pa_values[$va_element['element_code']];
         }
         if ($t_attr_val->addValue($vm_value, $va_element, $vn_attribute_id, $pa_options) === false) {
             $this->postError(1972, join('; ', $t_attr_val->getErrors()), 'ca_attributes->editAttribute()');
             break;
         }
     }
     if ($this->numErrors()) {
         if (!$vb_already_in_transaction) {
             $o_trans->rollback();
         }
         return false;
     }
     if (!$vb_already_in_transaction) {
         $o_trans->commit();
     }
     return true;
 }
 /**
  * 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');
 }