示例#1
0
 protected function loadData()
 {
     $instance_id = $this->app->getInstanceId();
     $where_clause = sprintf('visible = %s and instance %s %s', $this->app->db->quote($this->parent, 'boolean'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
     $order_widget = $this->ui->getWidget('order');
     $order_widget->addOptionsByArray(SwatDB::getOptionArray($this->app->db, 'PinholeMetaData', 'title', 'id', 'displayorder, title', $where_clause));
     $sql = 'select sum(displayorder) from PinholeMetaData where ' . $where_clause;
     $sum = SwatDB::queryOne($this->app->db, $sql, 'integer');
     $options_list = $this->ui->getWidget('options');
     $options_list->value = $sum == 0 ? 'auto' : 'custom';
 }
示例#2
0
 protected function buildInternal()
 {
     parent::buildInternal();
     $this->buildAuthorWarning();
     $instance_id = $this->app->getInstanceId();
     $where_clause = sprintf('visible = %s and instance %s %s', $this->app->db->quote(true, 'boolean'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
     $author_flydown = $this->ui->getWidget('search_author');
     $author_flydown->show_blank = true;
     $author_flydown->addOptionsByArray(SwatDB::getOptionArray($this->app->db, 'BlorgAuthor', 'name', 'id', 'name', $where_clause));
 }
示例#3
0
 /**
  * Get the meta data from a photo
  *
  * @param array An array of PinholePhotoMetaDataBinding data objects
  *               with $shortname as the key of the array.
  * @return array An array of PinholeMetaData dataobjects
  */
 protected function saveMetaDataInternal($meta_data)
 {
     $instance_id = $this->image_set->instance === null ? null : $this->image_set->instance->id;
     $where_clause = sprintf('PinholeMetaData.instance %s %s', SwatDB::equalityOperator($instance_id), $this->db->quote($instance_id, 'integer'));
     $existing_meta_data = SwatDB::getOptionArray($this->db, 'PinholeMetaData', 'shortname', 'id', null, $where_clause);
     foreach ($meta_data as $data) {
         $shortname = substr($data->shortname, 0, 255);
         $title = substr($data->title, 0, 255);
         if (mb_check_encoding($data->value, 'UTF-8')) {
             $value = $data->value;
         } else {
             // assume ISO-8859-1
             $value = iconv('ISO-8859-1', 'UTF-8', $data->value);
         }
         $value = substr($value, 0, 255);
         if (!in_array($shortname, $existing_meta_data)) {
             $meta_data_id = SwatDB::insertRow($this->db, 'PinholeMetaData', array('text:shortname', 'text:title', 'integer:instance'), array('shortname' => $shortname, 'title' => $title, 'instance' => $instance_id), 'id');
         } else {
             $meta_data_id = array_search($shortname, $existing_meta_data);
         }
         SwatDB::insertRow($this->db, 'PinholePhotoMetaDataBinding', array('integer:photo', 'integer:meta_data', 'text:value'), array('photo' => $this->id, 'meta_data' => $meta_data_id, 'value' => $value));
     }
 }