| 1 |
<?php |
<?php |
| 2 |
// $Id: nodefamily.module,v 1.19.2.16 2008/06/09 07:13:18 fago Exp $ |
// $Id: nodefamily.module,v 1.19.2.17 2008/06/11 09:24:34 fago Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 52 |
'#type' => 'select', |
'#type' => 'select', |
| 53 |
'#title' => t('Parent type'), |
'#title' => t('Parent type'), |
| 54 |
'#options' => $typenames, |
'#options' => $typenames, |
| 55 |
'#required' => true, |
'#required' => TRUE, |
| 56 |
); |
); |
| 57 |
$form['add']['child'] = array( |
$form['add']['child'] = array( |
| 58 |
'#type' => 'select', |
'#type' => 'select', |
| 59 |
'#title' => t('Child type'), |
'#title' => t('Child type'), |
| 60 |
'#options' => $typenames, |
'#options' => $typenames, |
| 61 |
'#required' => true, |
'#required' => TRUE, |
| 62 |
); |
); |
| 63 |
$form['add']['submit'] = array( |
$form['add']['submit'] = array( |
| 64 |
'#type' => 'submit', |
'#type' => 'submit', |
| 92 |
|
|
| 93 |
//if we manage to reach the parent from the child, we would have a cycle |
//if we manage to reach the parent from the child, we would have a cycle |
| 94 |
if (!array_key_exists($child, $relations)) { |
if (!array_key_exists($child, $relations)) { |
| 95 |
return false; |
return FALSE; |
| 96 |
} |
} |
| 97 |
else { |
else { |
| 98 |
$new_relatives = array($child); |
$new_relatives = array($child); |
| 121 |
function nodefamily_ct_relation_overview() { |
function nodefamily_ct_relation_overview() { |
| 122 |
$relations = variable_get('nodefamily_relations', array()); |
$relations = variable_get('nodefamily_relations', array()); |
| 123 |
if (!$relations) { |
if (!$relations) { |
| 124 |
return ''; |
return ''; |
| 125 |
} |
} |
| 126 |
|
|
| 127 |
if (arg(3) && arg(4)) { |
if (arg(3) && arg(4)) { |
| 128 |
// delete the relation |
// delete the relation |
| 129 |
nodefamily_ct_relation_remove(arg(3), arg(4)); |
nodefamily_ct_relation_remove(arg(3), arg(4)); |
| 130 |
drupal_goto('admin/content/nodefamily'); |
drupal_goto('admin/content/nodefamily'); |
| 131 |
} |
} |
| 132 |
|
|
| 133 |
$header = array(t('Parent type'), t('Child type'), ''); |
$header = array(t('Parent type'), t('Child type'), ''); |
| 729 |
); |
); |
| 730 |
} |
} |
| 731 |
|
|
| 732 |
/* |
/** |
| 733 |
* Implementation of pageroutes' hook_page() |
* Implementation of pageroutes' hook_page() |
| 734 |
*/ |
*/ |
| 735 |
function nodefamily_page_manage_lonely($route, $page, $form) { |
function nodefamily_page_manage_lonely($route, $page, $form) { |
| 749 |
return pageroute_page_edit($route, $page, $form, $node->nid ? $node->nid : FALSE); |
return pageroute_page_edit($route, $page, $form, $node->nid ? $node->nid : FALSE); |
| 750 |
} |
} |
| 751 |
|
|
| 752 |
/* |
/** |
| 753 |
* Implementation of pageroutes' hook_page() |
* Implementation of pageroutes' hook_page() |
| 754 |
*/ |
*/ |
| 755 |
function nodefamily_page_view_lonely($route, $page, $form) { |
function nodefamily_page_view_lonely($route, $page, $form) { |
| 773 |
t('You have not created a @type yet. Go ahead and create one!', array('@type' => $type_name)) .'</div>'; |
t('You have not created a @type yet. Go ahead and create one!', array('@type' => $type_name)) .'</div>'; |
| 774 |
} |
} |
| 775 |
|
|
| 776 |
/* |
/** |
| 777 |
* Implementations of hook_page_ui(). |
* Implementation of hook_page_ui(). |
| 778 |
*/ |
*/ |
| 779 |
function nodefamily_page_view_lonely_ui($route, $page, &$form, $type) { |
function nodefamily_page_view_lonely_ui($route, $page, &$form, $type) { |
| 780 |
$form['options']['content-type'] = array( |
$form['options']['content-type'] = array( |
| 788 |
'nodefamily population set to one!'), |
'nodefamily population set to one!'), |
| 789 |
); |
); |
| 790 |
} |
} |
| 791 |
|
|
| 792 |
function nodefamily_page_manage_lonely_ui($route, $page, &$form, $type) { |
function nodefamily_page_manage_lonely_ui($route, $page, &$form, $type) { |
| 793 |
nodefamily_page_view_lonely_ui($route, $page, $form, $type); |
nodefamily_page_view_lonely_ui($route, $page, $form, $type); |
| 794 |
pageroute_pages_node_ui($route, $page, $form, $type); |
pageroute_pages_node_ui($route, $page, $form, $type); |
| 795 |
} |
} |
| 796 |
|
|
| 797 |
/* |
/** |
| 798 |
* Returns an array of lonely node types |
* Returns an array of lonely node types |
| 799 |
*/ |
*/ |
| 800 |
function nodefamily_lonely_node_types($op = 'names') { |
function nodefamily_lonely_node_types($op = 'names') { |
| 808 |
return $lonely_node_types; |
return $lonely_node_types; |
| 809 |
} |
} |
| 810 |
|
|
| 811 |
/* |
/** |
| 812 |
* Implementations of hook_page_help(). |
* Implementation of hook_page_help(). |
| 813 |
*/ |
*/ |
| 814 |
function nodefamily_page_manage_lonely_help() { |
function nodefamily_page_manage_lonely_help() { |
| 815 |
return t('The "lonely" page types may be used only with content types, '. |
return t('The "lonely" page types may be used only with content types, '. |
| 1013 |
$joininfo = $table_data['nodefamily_parent']['join']; |
$joininfo = $table_data['nodefamily_parent']['join']; |
| 1014 |
$joininfo['left']['table'] = $query->get_table_name('nodefamily_parent', $num); |
$joininfo['left']['table'] = $query->get_table_name('nodefamily_parent', $num); |
| 1015 |
$joininfo['left']['field'] = 'child_nid'; |
$joininfo['left']['field'] = 'child_nid'; |
| 1016 |
$num = $query->add_table('nodefamily_parent', false, 1, $joininfo); |
$num = $query->add_table('nodefamily_parent', FALSE, 1, $joininfo); |
| 1017 |
$tablename = $query->get_table_name('nodefamily_parent', $num); |
$tablename = $query->get_table_name('nodefamily_parent', $num); |
| 1018 |
$query->add_where($tablename .".child_nid = %d", $arg); |
$query->add_where($tablename .".child_nid = %d", $arg); |
| 1019 |
break; |
break; |
| 1040 |
$joininfo = $table_data['nodefamily_child']['join']; |
$joininfo = $table_data['nodefamily_child']['join']; |
| 1041 |
$joininfo['left']['table'] = $query->get_table_name('nodefamily_child', $num); |
$joininfo['left']['table'] = $query->get_table_name('nodefamily_child', $num); |
| 1042 |
$joininfo['left']['field'] = 'parent_nid'; |
$joininfo['left']['field'] = 'parent_nid'; |
| 1043 |
$num = $query->add_table('nodefamily_child', false, 1, $joininfo); |
$num = $query->add_table('nodefamily_child', FALSE, 1, $joininfo); |
| 1044 |
$tablename = $query->get_table_name('nodefamily_child', $num); |
$tablename = $query->get_table_name('nodefamily_child', $num); |
| 1045 |
$query->add_where($tablename .".parent_nid = %d", $arg); |
$query->add_where($tablename .".parent_nid = %d", $arg); |
| 1046 |
break; |
break; |