Example #1
0
 static function generate_summary($activity, $target = null)
 {
     if (!$target && $activity->target) {
         try {
             $target = midcom::get('dbfactory')->get_object_by_guid($activity->target);
             $reflector = new midcom_helper_reflector($target);
             $class_label = $reflector->get_class_label();
             $target_label = "{$class_label} " . $reflector->get_object_label($target);
         } catch (midcom_error $e) {
             $target_label = $activity->target;
         }
     }
     switch ($activity->verb) {
         case 'http://activitystrea.ms/schema/1.0/post':
             $verb = 'saved';
             break;
         case 'http://community-equity.org/schema/1.0/delete':
             $verb = 'deleted';
             break;
         case 'http://community-equity.org/schema/1.0/clone':
             $verb = 'cloned';
             break;
         default:
             // TODO: Check if the originating component can provide this
             return '';
     }
     try {
         $actor = new midcom_core_user($activity->actor);
         return sprintf(midcom::get('i18n')->get_string('%s ' . $verb . ' %s', 'midcom.helper.activitystream'), $actor->name, $target_label);
     } catch (midcom_error $e) {
         return sprintf(midcom::get('i18n')->get_string('%s was ' . $verb, 'midcom.helper.activitystream'), $target_label);
     }
 }
Example #2
0
 /**
  * @dataProvider providerGet_object_label
  */
 public function testGet_object_label($classname, $data, $label)
 {
     $object = new $classname();
     foreach ($data as $field => $value) {
         $object->{$field} = $value;
     }
     $reflector = new midcom_helper_reflector($object);
     $this->assertEquals($label, $reflector->get_object_label($object));
 }
Example #3
0
 public function render_content()
 {
     if (count($this->_type->selection) == 0) {
         return $this->_translate('type select: no selection');
     } else {
         $selection = array();
         foreach ($this->_type->selection as $key) {
             if ($this->id_field == 'id') {
                 $key = (int) $key;
             }
             try {
                 $object = new $this->class($key);
             } catch (midcom_error $e) {
                 $e->log();
                 continue;
             }
             if (!class_exists('midcom_helper_reflector')) {
                 $selection[] = get_class($object) . " #{$object->id}";
                 continue;
             }
             $ref = new midcom_helper_reflector($object);
             $selection[] = $ref->get_object_label($object);
         }
         return implode(', ', $selection);
     }
 }
Example #4
0
 public function _handler_list($handler_id, $args, &$data)
 {
     if (isset($args[0])) {
         $this->_output_mode = $args[0];
     }
     //output_mode different from html means we just want the data
     if ($this->_output_mode != 'html') {
         $this->qb_journal_entries = org_openpsa_relatedto_journal_entry_dba::new_query_builder();
         $this->qb_journal_entries->add_order('followUp');
         $this->_prepare_journal_query();
         //show the corresponding object of the entry
         $this->_request_data['show_object'] = true;
         $this->_request_data['show_closed'] = false;
         $this->_request_data['page'] = 1;
         if (array_key_exists('show_closed', $_POST)) {
             $this->_request_data['show_closed'] = true;
         }
         $this->_request_data['entries'] = $this->qb_journal_entries->execute();
         //get the corresponding objects
         if ($this->_request_data['show_object'] == true && !empty($this->_request_data['entries'])) {
             $this->_request_data['linked_objects'] = array();
             $this->_request_data['linked_raw_objects'] = array();
             foreach ($this->_request_data['entries'] as $entry) {
                 if (array_key_exists($entry->linkGuid, $this->_request_data['linked_objects'])) {
                     continue;
                 }
                 //create reflector with linked object to get the right label
                 try {
                     $linked_object = midcom::get('dbfactory')->get_object_by_guid($entry->linkGuid);
                 } catch (midcom_error $e) {
                     $e->log();
                     continue;
                 }
                 $reflector = new midcom_helper_reflector($linked_object);
                 $link_html = "<a href='" . midcom::get('permalinks')->create_permalink($linked_object->guid) . "'>" . $reflector->get_object_label($linked_object) . "</a>";
                 $this->_request_data['linked_objects'][$entry->linkGuid] = $link_html;
                 $this->_request_data['linked_raw_objects'][$entry->linkGuid] = $reflector->get_object_label($linked_object);
             }
         }
         //url_prefix to build the links to the entries
         $this->_request_data['url_prefix'] = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . "__mfa/org.openpsa.relatedto/journalentry/";
     } else {
         //url where the xml-data can be loaded
         $this->_request_data['data_url'] = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . "__mfa/org.openpsa.relatedto/journalentry/list/xml/";
         //enable jqgrid for html-output
         org_openpsa_widgets_grid::add_head_elements();
     }
     $this->_prepare_header();
 }
Example #5
0
 private function _resolve_object_name($object)
 {
     if (!class_exists('midcom_helper_reflector')) {
         return get_class($object) . " #{$object->id}";
     }
     $ref = new midcom_helper_reflector($object);
     return $ref->get_object_label($object);
 }