コード例 #1
0
ファイル: locks.php プロジェクト: hunter2814/reason_package
 /**
  * Get the relationships that can be locked
  * @return array('rel_id'=>array([alrel info]),'rel_id'=>array([alrel info]),...)
  * @todo There should be a better way to identify non-lockable relationships
  */
 public function get_lockable_relationships()
 {
     $rels = get_allowable_relationships_for_type($this->_entity->get_value('type'));
     $rel_unique_names = reason_relationship_names_are_unique();
     foreach ($rels as $rel_id => $rel) {
         $not_lockable = $rel_unique_names ? $rel['type'] == 'archive' || $rel['type'] == 'borrows' : strpos($rel['name'], 'archive') !== false || strpos($rel['name'], 'borrows') !== false;
         if ($not_lockable) {
             unset($rels[$rel_id]);
         }
     }
     return $rels;
 }
コード例 #2
0
ファイル: type.php プロジェクト: hunter2814/reason_package
 function post_show_entity()
 {
     echo '<h3>Tables and Fields</h3>';
     // the name is the only relevant field included by default, so it is hard-coded
     echo "\n" . '<table border="0" cellpadding="0" cellspacing="0"><tr class="listRow1"><td align="right">&nbsp;<strong>default</strong></td><td align="left"><ul><li>name &lt;tinytext&gt;</li></ul></td></tr>';
     // get all of this type's entity tables
     $ets = new entity_selector($this->admin_page->site_id);
     $ets->description = "Get entity tables associated with the type.";
     $ets->add_type(id_of('content_table'));
     $ets->add_right_relationship($this->_entity->id(), relationship_id_of('type_to_table'));
     $entities = $ets->run_one();
     $n = 2;
     // get the fields of each entity table
     foreach ($entities as $entity) {
         $fs = new entity_selector();
         $fs->description = "Get fields associated with the entity table.";
         $fs->add_type(id_of('field'));
         $fs->add_left_relationship($entity->id(), relationship_id_of('field_to_entity_table'));
         $fields = $fs->run_one();
         echo '<tr class="listRow' . $n % 2 . '"><td align="right">&nbsp;<strong>' . $entity->get_value('name') . '</strong></td><td align="left"><ul>';
         $b = 0;
         // output each field and its database type
         foreach ($fields as $field) {
             echo '<li>' . $field->get_value('name') . ' &lt;' . $field->get_value('db_type') . '&gt;</li>';
             $b++;
         }
         echo '</ul></td></tr>';
         $n++;
     }
     echo '</table>';
     if ($rels = get_allowable_relationships_for_type($this->_entity->id())) {
         echo '<h3>Allowable Relationships</h3>' . "\n";
         echo '<table border="0" cellpadding="4" cellspacing="0">' . "\n";
         echo '<thead><tr><th>A Side</th><th>B Side</th><th>Name</th></tr></thead>' . "\n";
         echo '<tbody>' . "\n";
         $n = 1;
         foreach ($rels as $rel) {
             $a_entity = new entity($rel['relationship_a']);
             $b_entity = new entity($rel['relationship_b']);
             echo '<tr class="listRow' . $n % 2 . '"><td>' . $a_entity->get_value('name') . '</td><td>' . $b_entity->get_value('name') . '</td><td>' . $rel['name'] . '</td></tr>' . "\n";
             $n++;
         }
         echo '</tbody>' . "\n";
         echo '</table>' . "\n";
     }
     /*echo '<h3>Right Relationships</h3>';
     			$right_rels = $this->_entity->get_right_relationships(); 
     
     			foreach( $right_rels AS $key => $r )
     			{
     				if( !empty( $r ) )
     				{
     					if( !is_int( $key ) )
     					{
     						echo '<strong>'.$key.'</strong><br />';
     						foreach( $r AS $actual_rel )
     						{
     							echo $actual_rel->get_value( 'name' ).'<br />';
     						}
     						echo '<br />';
     					}
     				}
     			} */
 }