Ejemplo n.º 1
0
 function alter_values()
 {
     $this->add_column('site');
     $this->update_es();
     $ass_es = new entity_selector($this->admin_page->site_id);
     $ass_es->add_type($this->admin_page->type_id);
     $ass_es->set_sharing('borrows');
     $ass_es->limit_fields();
     //grab site name as well
     $this->alias = $ass_es->add_right_relationship_field('owns', 'entity', 'name', 'site');
     $ass_es->add_right_relationship_field('owns', 'entity', 'id', 'site_id');
     if ($this->site_is_live()) {
         $ass_es->add_right_relationship_field('owns', 'entity', 'state', 'site_state', 'Live');
     }
     $this->apply_order_and_limits($ass_es);
     $this->ass_vals = $ass_es->run_one();
     if ($this->ass_vals) {
         $this->es->add_relation('entity.id NOT IN ("' . implode('","', array_keys($this->ass_vals)) . '")');
     }
     if (!empty($this->admin_page->request['__old_rel_id'])) {
         $conn_name = $this->get_connection($this->admin_page->request['__old_rel_id']);
         if ($conn_name == 'many_to_one') {
             $ass_related_es = carl_clone($this->es);
             $ass_related_es->add_right_relationship_field(relationship_name_of($this->admin_page->request['__old_rel_id']), 'entity', 'id', 'related_id');
             $this->related_vals = $ass_related_es->run_one();
             if ($this->related_vals) {
                 $this->es->add_relation('entity.id NOT IN ("' . implode('","', array_keys($this->related_vals)) . '")');
             }
         }
     }
 }
Ejemplo n.º 2
0
 function show_entity_relationships_info($entity, $show_right)
 {
     $rel_info = $show_right ? $this->get_entity_relationships_info($entity, true) : $this->get_entity_relationships_info($entity, false);
     if (!empty($rel_info)) {
         $rel_types = $this->separate_relationships($rel_info);
         $descriptions = $this->separate_descriptions($rel_info);
         foreach ($rel_types as $type => $rels) {
             echo '<h4>' . relationship_name_of($type) . ' - (' . $descriptions[$type] . ')</h4>' . "\n";
             echo '<table class="entityInfoTable">' . "\n";
             echo '<tr>' . "\n";
             $e = $show_right ? new entity($rels[0]['relationship_a']) : new entity($rels[0]['relationship_b']);
             echo '<th>' . $e->get_value('name') . ' Entity Name</th>' . "\n";
             echo '<th>ID #</th>' . "\n";
             echo '</tr>' . "\n";
             foreach ($rels as $rel) {
                 $other = $show_right ? new entity($rel['entity_a']) : new entity($rel['entity_b']);
                 echo '<tr>' . "\n";
                 echo '<td>' . $other->get_value('name') . '</td>' . "\n";
                 echo '<td>' . $this->get_id_markup($other->id()) . '</td>' . "\n";
                 echo '</tr>' . "\n";
             }
             echo '</table>' . "\n";
             echo '<br/>';
         }
     } else {
         return false;
     }
     return true;
 }
Ejemplo n.º 3
0
 /**
  * @access private
  * @param array $rels
  * @param array $rels_info
  * @param integer $alrel_id
  * @param string $dir
  * @param string $indent
  * @return array lines
  */
 function _get_rel_xml_lines($rels, $rels_info, $alrel_id, $dir, $indent)
 {
     $lines = array();
     $lines[] = $indent . '<alrel name="' . relationship_name_of($alrel_id) . '" id="' . $alrel_id . '" dir="' . $dir . '">';
     foreach ($rels as $position => $rel) {
         $uname = $rel->get_value('unique_name') ? ' to_uname="' . htmlspecialchars($rel->get_value('unique_name')) . '"' : '';
         $lines[] = $indent . "\t" . '<rel to_entity_id="' . $rel->id() . '" ' . $uname . '>';
         if (isset($rels_info[$position])) {
             foreach ($rels_info[$position] as $key => $val) {
                 if ($key != 'type' && $key != 'entity_a' && $key != 'entity_b') {
                     $lines[] = $indent . "\t\t" . '<attr name="' . $key . '">' . htmlspecialchars($val) . '</attr>';
                 }
             }
         }
         $lines[] = $indent . "\t" . '</rel>';
     }
     $lines[] = $indent . '</alrel>';
     return $lines;
 }
Ejemplo n.º 4
0
 function show_disassociated_items()
 {
     $this->remove_column('rel_sort_order');
     $this->select = true;
     $row = 0;
     $columns = count($this->columns) + 1;
     echo '<div class="unassociatedItemsWrapper">' . "\n";
     $class = !empty($this->admin_page->rel_id) ? ' class="' . htmlspecialchars(relationship_name_of($this->admin_page->rel_id)) . '" ' : ' ';
     echo '<table id="disassociatedItems"' . $class . 'cellspacing="0" cellpadding="8">';
     echo '<tr><td colspan="' . $columns . '" class="disassocHead">';
     $this->show_paging();
     echo '</td></tr>' . "\n";
     foreach ($this->values as $id => $item) {
         if (!array_key_exists($id, $this->related_vals)) {
             if ($row % $this->rows_per_sorting == 0) {
                 $this->show_sorting();
             }
             $this->show_item($item);
             $row++;
         }
     }
     $columns = count($this->columns) + 1;
     echo '<tr><td colspan="' . $columns . '" class="disassocPaging">';
     $this->show_paging();
     echo '</td></tr>' . "\n";
     echo '</table>' . "\n";
     echo '</div>' . "\n";
 }