-
Notifications
You must be signed in to change notification settings - Fork 1
/
semanticweblog.module
executable file
·769 lines (693 loc) · 26.4 KB
/
semanticweblog.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
<?php
// $Id$
/* Author: Benjamin Birkenhake <benjamin@birkenhake.org>*/
/**
* @file:
* A more or less small Module to create simple Ontologies, Topic Maps with Drupal while blogging.
*
* @author Benjamin Birkenhake <benjamin@birkenhake.org>
* @package semanticweblog
* @copyright creative commons by-sa
*
*
* @todo [prio 1] Add functions and pages for massediting of associations
* @todo [prio 1] Add functions for adding association from within the register
* @todo [prio 1] Add functions for adding association from within the term/taxonomy pages, when none exist
* @todo [prio 1] Add Filter and Template Tag for including Topic information into Text-Body.
* See: http://konnexus.net/stories/artikellayout-mit-integrierten-topics
* @todo [prio 1] Refactor recurrent Form-Fields for Terms and Associationtypes.
*
* @todo [prio 2] Add function semanticweblog_nodes_linking_to_me
* @todo [prio 2] Enhance the Output on the taxonomy/term pages configurable via Admins settings.
* @todo [prio 2] extend API functionality to request association information inside Themes and other Modules
* @todo [prio 2] Improve Term Description use.
* @todo [prio 2] Add local Task 'url aliases' for Terms.
* @todo [prio 2] More Admin Settings.
*
* @todo [prio 3] Add Versions
* @todo [prio 3] Keep .po file for German translation up to date.
* @todo [prio 3] Make sure all Strings from the module are using t().
* @todo [prio 3] Add helptext
* @todo [prio 3] Do more Documentation.
* @todo [prio 3] Remove all non-hook, non-theme functions from the file.
*
*
*
*
*
*
*/
/**
* History
* 2010 02 03 [fym]: Added local tasks on term pages (associate, add)
* 2010 02 03 [fym]: Revised display of association creation form on term pages
* 2010 01 31 [fym]: fixed missing "/" and typo in semanticweblog_ajax_add_association()
* 2010 01 31 [fym]: Added semanticweblog_api_check_associations() for use in template files
* 2010 01 31 [fym]: Added association creation form on term pages with no listed associations
* 2010 01 30 [fym]: Added Option to sort listed associations on Term Pages
* 2010 01 27 [fym]: Added Option to group listed associations (up- and downwards) on Term Pages
* 2010 01 22 [fym]: refactored filtering for the Association Admin Page.
* 2010 01 21 [ben]: Added basic and advanced Filter for the Association Admin Page.
* 2010 01 12 [fym]: added deletion of options on deinstallation
* 2010 01 10 [fym]: added semanticweblog_vocab_is_set() to warn if no vocabulary is set for use in forms
* 2010 01 10 [fym]: refactored warnings on admin associations pages
* 2010 01 10 [ben]: Bugfix. Removed absolute path form the JS.
* 2010 01 09 [ben]: Removed _semanticweblog_taxonomy_term_page()
* 2010 01 09 [fym]: Added warning on Association page, when no Association Type exists
* 2010 01 09 [fym]: Added options for Display of Associations on the topic page (ordered and unordered lists)
* 2010 01 07 [fym]: Added option for Display of Associations on the topic page - before or after the listed nodes
* 2010 01 06 [ben]: Added a basic option for Display of Associations on the topic page.
* 2010 01 05 [fym]: Added blank de.po for translation
* 2010 01 03 [ben]: Added some Documentation and some refactoring
* 2010 01 03 [ben]: Added first Output of Associations on the taxonomy/term pages.
* 2010 01 03 [ben]: Minor Refactoring in the semanticweblog.association.inc
* 2009 12 30 [ben]: Added API File for all non-hook, non-theme functions to be used outside of the module
* 2009 12 21 [ben]: Added deletion of Associations when a term is deleted
* 2009 12 21 [ben]: Added Bulk Block Creation for Association Creation
* 2009 12 20 [ben]: Chache semanticweblog_load_all_types() DB-Request
* 2009 12 20 [ben]: Added name2id function for Association Types
* 2009 12 20 [ben]: Added Sentence for Association Types
* 2009 12 19 [ben]: Added Pager on Association Administer Page
* 2009 12 19 [ben]: Renamed the form elementes of the two association creation forms
* 2009 12 19 [ben]: Added Delete function for Associations.
* 2009 12 19 [ben]: Added double Association prevention
* 2009 12 18 [ben]: Added Ajax Block for Association Creation
* 2009 12 14 [ben]: Added Module Settings
* 2009 12 13 [ben]: Added new Association Type Creations, Editing, Deleting
* 2009 11 22 [ben]: Added local tasks to terms page (from old module)
* 2009 11 22 [ben]: Added Nodes' Terms Block (from old module)
* 2009 11 22 [ben]: Added Register (from old module)
* 2009 11 22 [ben]: Recreated this Module
*
*/
/**
* About the use of this module
*
* There are some basic Arrays, which a used as parameter for several functions
*
* #1 raw_associations
*
* This array is a direkt output of one row from the semanticweblog_association table.
*
* $raw_associations[$aid]["aid"] = ID of the Association
* $raw_associations[$aid]["uid"] = ID of the user who created it
* $raw_associations[$aid]["member1tid"] = ID of the first (downward) Term
* $raw_associations[$aid]["atid"] = ID of the Association Type
* $raw_associations[$aid]["member2tid"] = ID of the second (upward) Term
* $raw_associations[$aid]["created"] = TIMESTAMP of the date the association was created
*
* # 2 rich_associations
*
* This is a more complex Array, containing the Names of the Terms and Association Types
*
* // The type of this Association
* $rich_associations[$aid]["type"]["atid"] = ID of the Association Type
* $rich_associations[$aid]["type"]["name"] = Name of the Association Type
* $rich_associations[$aid]["type"]["sentence"] = Sentence Version of the Association Type
* $rich_associations[$aid]["type"]["role1"] = First Role of the Association Type
* $rich_associations[$aid]["type"]["role2"] = Second of the Association Type
* // The first member of this Associattion
* $rich_associations[$aid]["member1"]["tid"] = ID of the first (downward) Term
* $rich_associations[$aid]["member1"]["name"] = Name of the first (downward) Term
* $rich_associations[$aid]["member1"]["role"] = Role of the first (downward) Term
* // The second memeber of this Association
* $rich_associations[$aid]["member2"]["tid"] = ID of the second (upward) Term
* $rich_associations[$aid]["member2"]["name"] = Name of the second (upward) Term
* $rich_associations[$aid]["member2"]["role"] = Role of the second (upward) Term
*
*
*
*/
// To rebuild the menu and the theme registry during development
// menu_rebuild();
// drupal_rebuild_theme_registry();
// Including non-regular Files
include("semanticweblog.types.inc");
include("semanticweblog.associations.inc");
include("semanticweblog.api.inc");
// Global Variable
global $semanticweblog_association_types;
// Add CSS
drupal_add_js(drupal_get_path('module', 'semanticweblog') . '/semanticweblog.js');
/**
* Implementation of hook_perm
*
* @author Benjamin Birkenhake <benjamin@birkenhake.org>
*
*/
function semanticweblog_perm() {
return array('access semanticweblog', 'administer semanticweblog');
}
/**
* Implementation of hook_menu
*
* @author Benjamin Birkenhake <benjamin@birkenhake.org>
*
*/
function semanticweblog_menu() {
$items = array();
// Modules Settings
$items['admin/settings/semanticweblog'] = array(
'title' => 'Semantic Weblog',
'description' => 'Several Settings for your Semantic Weblog',
'page callback' => 'drupal_get_form',
'page arguments' => array('semanticweblog_admin_settings'),
'access arguments' => array('administer semanticweblog'),
'menu_name' => 'Semantic Weblog',
);
// Menu Items for the Register
$items['register/%/%'] = array(
'title' => 'Register',
'description' => 'The Register of a single Vocabulary',
'page arguments' => array(1,2),
'page callback' => 'semanticweblog_register_vocabulary',
'access arguments' => array('access semanticweblog'),
'file' => 'semanticweblog.pages.inc',
);
$items['register/%'] = array(
'title' => 'Register',
'description' => 'The Register of a single Vocabulary',
'page arguments' => array(1),
'page callback' => 'semanticweblog_register_vocabulary',
'access arguments' => array('access semanticweblog'),
'file' => 'semanticweblog.pages.inc',
);
$items['register'] = array(
'title' => 'Register',
'description' => 'The Register of a single Vocabulary',
'page callback' => 'semanticweblog_register_vocabulary',
'access arguments' => array('access semanticweblog'),
'file' => 'semanticweblog.pages.inc',
);
// Menu Items for Local Term Tasks
$items['taxonomy/term/%/edit'] = array(
'title' => 'Edit',
'description' => 'Edit this Term',
'access arguments' => array('administer taxonomy'),
'page callback' => 'semanticweblog_term_edit',
'type' => MENU_LOCAL_TASK,
);
$items['taxonomy/term/%/view'] = array(
'title' => 'View',
'description' => 'View this Term',
'access arguments' => array('access taxonomy'),
'page callback' => 'semanticweblog_term_view',
'type' => MENU_LOCAL_TASK,
);
$items['taxonomy/term/%/associate'] = array(
'title' => 'Associate',
'description' => 'Edit Associations of this Term',
'access arguments' => array('access taxonomy'),
'page callback' => 'semanticweblog_term_associate',
'type' => MENU_LOCAL_TASK,
);
$items['taxonomy/term/%/addterm'] = array(
'title' => 'Add',
'description' => 'Add a new term',
'access arguments' => array('administer taxonomy'),
'page callback' => 'semanticweblog_term_add',
'type' => MENU_LOCAL_TASK,
);
// Menu Items for Association Types
$items['admin/content/associationtype'] = array(
'title' => 'Association Types',
'description' => 'Add, edit and delete Association Types',
'page callback' => 'semanticweblog_administer_associationtypes',
'access arguments' => array('administer semanticweblog'),
'file' => 'semanticweblog.pages.inc',
);
$items['admin/content/associationtype/%/edit'] = array(
'title' => 'Association Types',
'page arguments' => array(3),
'description' => 'Edit an Association Type',
'page callback' => 'semanticweblog_administer_associationtypes_edit',
'access arguments' => array('administer semanticweblog'),
'file' => 'semanticweblog.pages.inc',
);
$items['admin/content/associationtype/%/delete'] = array(
'title' => 'Association Types',
'page arguments' => array(3),
'description' => 'Delete an Association Type',
'page callback' => 'semanticweblog_administer_associationtypes_delete',
'access arguments' => array('administer semanticweblog'),
'file' => 'semanticweblog.pages.inc',
);
// Menu Items for Associations
$items['admin/content/association'] = array(
'title' => 'Associations',
'description' => 'Add, edit and delete Associations',
'page callback' => 'semanticweblog_administer_associations',
'access arguments' => array('administer semanticweblog'),
'file' => 'semanticweblog.pages.inc',
);
$items['admin/content/association/%/delete'] = array(
'title' => 'Associations',
'description' => 'Delete an Associations',
'page arguments' => array(3),
'page callback' => 'semanticweblog_administer_associations_delete',
'access arguments' => array('administer semanticweblog'),
'file' => 'semanticweblog.pages.inc',
);
$items['association/add/%/%/%'] = array(
'title' => 'Associations',
'page arguments' => array(2,3,4),
'description' => 'Add an Association',
'page callback' => 'semanticweblog_add_add_association',
'access arguments' => array('administer semanticweblog'),
'file' => 'semanticweblog.pages.inc',
);
return $items;
}
/**
* Implementation of hook_admin_settings
*
* @author Benjamin Birkenhake <benjamin@birkenhake.org>
*
*/
function semanticweblog_admin_settings() {
$form["semanticweblog"] = array();
$vocabs = taxonomy_get_vocabularies();
//dprint_r($vocabs);
foreach ($vocabs as $voc) {
$option = array();
$options[$voc->vid] = $voc->name;
}
$form['semanticweblog']['semanticweblog_lexicon'] = array('#type' => 'select',
'#title' => t('Lexicon Vocabulary'),
'#default_value' => variable_get('semanticweblog_lexicon', ""),
'#size' => 1,
'#description' => t('Which Vocabulary shall be your Lexicon?'),
'#options' => $options,
);
$pager_options = array(
'10' => '10',
'20' => '20',
'50' => '50',
'100' => '100',
'All' => 'All',
);
$form['semanticweblog']['semanticweblog_admin_associations_pager'] = array('#type' => 'select',
'#title' => t('No. of Assciations per Page'),
'#default_value' => variable_get('semanticweblog_admin_associations_pager', "10"),
'#size' => 1,
'#description' => t('The Number of Associations per Page on the Association Admin Page'),
'#options' => $pager_options,
);
$form['semanticweblog']['semanticweblog_bulk_separator'] = array('#type' => 'textfield',
'#title' => t('Separator for Bulk-Uploads'),
'#default_value' => variable_get('semanticweblog_bulk_separator', "#"),
'#size' => 30,
'#description' => t('The Separator for you natural language bulk upload of Associations'),
);
$position_options = array(
'before' => 'Before nodes',
'after' => 'After nodes',
);
$form['semanticweblog']['semanticweblog_admin_associations_position'] = array('#type' => 'select',
'#title' => t('Position of Associations'),
'#default_value' => variable_get('semanticweblog_admin_associations_position', "before"),
'#size' => 1,
'#description' => t('Position of Associations relative to listed nodes'),
'#options' => $position_options,
);
$display_options = array(
'not' => 'No Associations at all',
'plain' => 'A Plain List of all Associated Terms',
'unorderedlist' => 'Unordered list (ul) of all Associated Terms',
'orderedlist' => 'Ordered list (ol) of all Associated Terms',
);
$form['semanticweblog']['semanticweblog_admin_associations_display'] = array('#type' => 'select',
'#title' => t('Type of Display'),
'#default_value' => variable_get('semanticweblog_admin_associations_display', "plain"),
'#size' => 1,
'#description' => t('Type of Display of the associations on the Term pages'),
'#options' => $display_options,
);
$grouping_options = array(
'none' => 'No particular order',
'updown' => 'Up- then downwards',
'downup' => 'Down- then upwards',
);
$form['semanticweblog']['semanticweblog_admin_associations_grouping'] = array('#type' => 'select',
'#title' => t('Grouping order of associations'),
'#default_value' => variable_get('semanticweblog_admin_associations_grouping', "none"),
'#size' => 1,
'#description' => t('The order in which associations are grouped on term pages, e.g. upwards associations first then downwards associations'),
'#options' => $grouping_options,
);
$sorting_options = array(
'none' => 'none',
'alpha_asc' => 'alphabetically, ascending',
'alpha_desc' => 'alphabetically, descending',
);
$form['semanticweblog']['semanticweblog_admin_associations_sorting'] = array('#type' => 'select',
'#title' => t('Sort order of listed associations'),
'#default_value' => variable_get('semanticweblog_admin_associations_sorting', "none"),
'#size' => 1,
'#description' => t('The sort order in which associations are listed on term pages'),
'#options' => $sorting_options,
);
return system_settings_form($form);
}
/**
* Implementation of hook_block
*
* @author Benjamin Birkenhake <benjamin@birkenhake.org>
*
*/
function semanticweblog_block($op = 'list', $delta = 0, $edit = array()) {
if ($op == 'list') {
$blocks[0] = array(
'info' => t('Semantic Weblog: Nodes Terms'),
);
$blocks[1] = array(
'info' => t('Semantic Weblog: Create Association Ajax'),
);
$blocks[2] = array(
'info' => t('Semantic Weblog: Create Association Bulk'),
);
return $blocks;
}
else if ($op == 'configure' && $delta == 0) {
}
else if ($op == 'save' && $delta == 0) {
}
else if ($op == 'view') {
switch ($delta) {
case 0:
$content = semanticweblog_block_nodesterms();
//drupal_set_message("Content:".$content.":");
if ($content) {
$block = array(
'subject' => t('Node Terms'),
'content' => semanticweblog_block_nodesterms(),
);
}
else{
return null;
}
break;
case 1:
$block = array(
'subject' => t('Create an Association'),
'content' => semanticweblog_block_add_association_ajax(),
);
break;
case 2:
$block = array(
'subject' => t('Create multiple Associations'),
'content' => semanticweblog_block_add_association_bulk(),
);
break;
}
return $block;
}
}
/**
* Delovers a block with the terms of a node
*
* @author Benjamin Birkenhake <benjamin@birkenhake.org>
*
*/
function semanticweblog_block_nodesterms() {
if (arg(0) == 'node') {
if (is_numeric(arg(1))) {
$node = node_load(arg(1));
//dprint_r($node);
}
}
return $node ? theme("semanticweblog_nodesterms_block", $node) : NULL;
}
/**
* Additional Lokal Task "View" for Terms
*
* @author Benjamin Birkenhake <benjamin@birkenhake.org>
*
*/
function semanticweblog_term_view() {
drupal_goto("taxonomy/term/" . arg(2));
}
/**
* Additional Lokal Task "Edit" for Terms
*
* @author Benjamin Birkenhake <benjamin@birkenhake.org>
*
*/
function semanticweblog_term_edit() {
drupal_goto("admin/content/taxonomy/edit/term/" . arg(2));
}
/**
* Additional Local Task "Associate" for Terms
*/
function semanticweblog_term_associate() {
drupal_goto("admin/content/association/" . arg(2));
}
/**
* Additional Local Task "add" for Terms - redirect to taxonomy
*/
function semanticweblog_term_add() {
$lexicon = variable_get('semanticweblog_lexicon', "");
if ($lexicon != "") {
drupal_goto("admin/content/taxonomy/" . $lexicon . "/add/term");
} else {
drupal_goto("admin/content/taxonomy/");
}
}
/**
* Implementation of hook_form_alter
*
* To position the taxonomy
*
* @author Benjamin Birkenhake <benjamin@birkenhake.org>
*
*/
function semanticweblog_form_alter(&$form, $form_state, $form_id) {
$form['taxonomy']['#weight'] = 1;
return $form;
}
/**
* Add additional semantic Information to the Head
*
* @author Benjamin Birkenhake <benjamin@birkenhake.org>
*
*/
function semanticweblog_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if ($op=="view" and !$a3) {
//dprint_r($a3);
semanticweblog_extend_head();
}
}
/**
* Add Terms as keywords to the head
*
* @author Benjamin Birkenhake <benjamin@birkenhake.org>
*
*/
function semanticweblog_extend_head() {
if (arg(0) == 'node') {
if (is_numeric(arg(1))) {
$node = node_load(arg(1));
if (is_array($node->taxonomy)) {
$terms = array();
foreach ($node->taxonomy as $term) {
$terms[] = $term->name;
drupal_set_html_head(' <link rel="index" title="' . thememe_cleanxml($term->name) . '" href="'.url("taxonomy/term/".$term->tid).'" />');
}
drupal_set_html_head(' <meta name="keywords" content="' . implode(", ", $terms) . '" />');
}
}
}
}
/**
* Implementation of hook_taxonomy
*
* We have to delete all Associations if a term is beeing deleted
*/
function semanticweblog_taxonomy($op, $type, $array = NULL){
//dprint_r($array);
$termid = $array["tid"];
if($op=="delete" and $type=="term" and is_numeric($termid)){
db_query("DELETE FROM {semanticweblog_associations} WHERE member1tid = %d or member2tid = %d", $termid, $termid);
drupal_set_message(t('All Associations of the term have been deleted.'));
}
}
// Theming
/**
* Implementation of hook_theme
*
* @author Benjamin Birkenhake <benjamin@birkenhake.org>
*
*/
function semanticweblog_theme() {
return array(
// The hook or form id in this case.
'taxonomy_term_page' => array(
// Default arguments.
'arguments' => array('tids' => NULL, 'result' => NULL),
'function' => "semanticweblog_taxonomy_term_page",
),
'semanticweblog_nodesterms_block' => array(
'arguments' => array('node' => NULL),
),
'semanticweblog_register_vocabulary' => array(
'arguments' => array('terms' => array(), 'letter' => NULL),
),
'semanticweblog_register_alphabet' => array(
'arguments' => array('vid' => NULL, 'letter' => NULL),
),
);
}
/**
* Render a taxonomy term page HTML output.
*
* This function adds an link to edit the term, if access to taxonomy management is given.
*
* @param $tids
* An array of term ids.
* @param $result
* A pager_query() result, such as that performed by taxonomy_select_nodes().
*/
function semanticweblog_taxonomy_term_page($tids, $result) {
drupal_add_css(drupal_get_path('module', 'semanticweblog') . '/semanticweblog.css');
$association_output = '';
// Only display the description if we have a single term, to avoid clutter and confusion.
if (count($tids) == 1) {
$term = taxonomy_get_term($tids[0]);
// Add Keywords to the header.
drupal_set_html_head(' <meta name="keywords" content="' . $term->name .'" />');
// Add Description
$association_output .= '<div class="taxonomy-term-description">';
$association_output .= filter_xss_admin($term->description);
$association_output .= '</div>';
// determine in which way the associations are grouped
switch(variable_get('semanticweblog_admin_associations_grouping', "none")){
case "none":
$associations = semanticweblog_api_term_get_all_associations($term->tid);
break;
case "updown":
$associations_up = semanticweblog_api_term_get_own_associations($term->tid);
$associations_down = semanticweblog_api_term_get_foreign_associations($term->tid);
$associations = array_merge($associations_up, $associations_down);
break;
case "downup":
$associations_up = semanticweblog_api_term_get_own_associations($term->tid);
$associations_down = semanticweblog_api_term_get_foreign_associations($term->tid);
$associations = array_merge($associations_down, $associations_up);
break;
}
// Add Associations depending on the Settings.
// To Add more options here, do this:
// 1. Add an Option in the semanticweblog_admin_settings() to the $display_options
// 2. Add a funciton semanticweblog_theme_term_page_associations_yourdisplaytype($term)
// 3. Add a case in this switch here.
switch(variable_get('semanticweblog_admin_associations_display', "plain")){
case "plain":
$association_output .= semanticweblog_theme_term_page_associations_plainlist($term, $associations);
break;
case "unorderedlist":
$association_output .= semanticweblog_theme_term_page_associations_lists($term, $associations, 'unordered');
break;
case "orderedlist":
$association_output .= semanticweblog_theme_term_page_associations_lists($term, $associations, 'ordered');
break;
case "not":
break;
}
// A Title for the Nodes
$nodetitle = '<h2 class="taxonomy-term-content-title">' . t('Content on the Topic') . '</h2>';
}
// should associations be listed before or after regular content
switch(variable_get('semanticweblog_admin_associations_position', "before")){
case "before":
$output = $association_output . $nodetitle . taxonomy_render_nodes($result);
break;
case "after":
$output .= $nodetitle . taxonomy_render_nodes($result) . $association_output;
break;
}
return $output;
}
function semanticweblog_theme_term_page_associations_plainlist($term, $associations){
if(count($associations)>0){
if (user_access('administer semanticweblog')) {
$output .= "<div class=\"admin-add-association\">\n";
$output .= drupal_get_form("semanticweblog_ajax_add_association");
$output .= "</div>\n";
}
$output .= "<div id=\"term-page-associations\">\n";
$output .= '<h2 class="taxonomy-term-assciation-title">' . t('Associations of this Term') . '</h2>';
$output .= '<div class="associations-plainlist">';
foreach ($associations as $assoc) {
$output .= "<p>". l($assoc["member1"]["name"], "taxonomy/term/" . $assoc["member1"]["tid"]) . ' ' . $assoc["type"]["sentence"] . ' ' . l($assoc["member2"]["name"], "taxonomy/term/" . $assoc["member2"]["tid"]). "</p>\n";
}
$output .= "</div>\n";
$output .= "</div>\n";
}elseif($term->vid == variable_get('semanticweblog_lexicon', "")){
if (user_access('administer semanticweblog')) {
$output .= "<div id=\"term-page-associations\" class=\"administer-semanticweblog add-association\">\n";
$output .= drupal_get_form("semanticweblog_ajax_add_association");
$output .= "</div>\n";
}
}
return $output;
}
function semanticweblog_theme_term_page_associations_lists($term, $associations, $mode){
switch($mode) {
case "unordered":
$listtype = "ul";
break;
case "ordered":
$listtype = "ol";
break;
}
if(count($associations)>0){
if (user_access('administer semanticweblog')) {
$output .= "<div class=\"admin-add-association\">\n";
$output .= drupal_get_form("semanticweblog_ajax_add_association");
$output .= "</div>\n";
}
$output = "<div id=\"term-page-associations\">\n";
$output .= "<h2 class=\"taxonomy-term-assciation-title\">" . t('Associations of this Term') . "</h2>\n";
$output .= "<div class=\"associations-".$mode."list\">\n";
$output .= "<".$listtype.">\n";
foreach ($associations as $assoc) {
$output .= "<li>". l($assoc["member1"]["name"], "taxonomy/term/" . $assoc["member1"]["tid"]) . ' ' . $assoc["type"]["sentence"] . ' ' . l($assoc["member2"]["name"], "taxonomy/term/" . $assoc["member2"]["tid"]). "</li>\n";
}
$output .= "</".$listtype.">\n";
$output .= "</div>\n";
$output .= "</div>\n";
}elseif($term->vid == variable_get('semanticweblog_lexicon', "")){
if (user_access('administer semanticweblog')) {
$output .= "<div id=\"term-page-associations\" class=\"administer-semanticweblog add-association\">\n";
$output .= drupal_get_form("semanticweblog_ajax_add_association");
$output .= "</div>\n";
}
}
return $output;
}
/**
* This functions searches for Links between Nodes
*/
function semanticweblog_nodes_linking_to_me($node) {
}
/**
* This function thmes a Block which contains all Terms of one Node
*
* @param object $node
* @return string html-output
*/
function theme_semanticweblog_nodesterms_block($node) {
//drupal_set_message("theme block");
if (is_array($node->taxonomy) and count($node->taxonomy)>0) {
foreach ($node->taxonomy as $term) {
$item["data"] = l($term->name,"taxonomy/term/" . $term->tid, array('absolute' => true));
$items[] = $item;
}
$output = theme_item_list($items);
}
else{
$output = NULL;
}
//dprint($items);
return $output;
}