summaryrefslogtreecommitdiff
path: root/includes/servicefunctions_inc.php
blob: 84d33e61fd26cc3d69eb87fc0dbe7d7980d09ee6 (plain)
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
<?php
/**
 * $Header$
 *
 * @package nexus
 * @subpackage functions
 */

namespace Bitweaver\Nexus;

/**
 * Nexus edit template service
 */
function nexus_content_edit( $pObject=null ) {
	global $gBitSmarty;

	$nexus = new Nexus();

	$nexusList = $nexus->getMenuList();
	$gBitSmarty->assign( 'nexusList', $nexusList );

	foreach( $nexusList as $menu ) {
		foreach( $menu['items'] as $item ) {
			if( !empty( $item['rsrc'] ) && $item['rsrc'] == $pObject->mContentId && $item['rsrc_type'] == 'content_id' ) {
				$gBitSmarty->assign( 'inNexusMenu', $menu );
				$gBitSmarty->assign( 'inNexusMenuItem', $item['item_id'] );
			}
		}
	}
}

/**
 * Nexus preview service
 * when we hit preview, we make the selections persistent
 */
function nexus_content_preview( $pObject=null ) {
}

/**
 * Nexus store service
 * store the content as part of an existing menu
 */
function nexus_content_store( $pObject, $pParamHash ) {
	global $gBitSystem, $gBitUser, $gBitSmarty;

	$nexus = new Nexus();

	if( !empty( $pParamHash['content_id'] ) && !empty( $pParamHash['nexus']['menu_id'] ) ) {
		$nexusHash['title'] = $pParamHash['content_store']['title'];
		$nexusHash['hint'] = !empty( $pParamHash['description'] ) ? $pParamHash['description'] : null;
		$nexusHash['menu_id'] = $pParamHash['nexus']['menu_id'];
		$nexusHash['after_ref_id'] = $pParamHash['nexus']['after_ref_id'];
		$nexusHash['rsrc'] = $pParamHash['content_id'];
		$nexusHash['rsrc_type'] = 'content_id';
		if( !$nexus->storeItem( $nexusHash ) ) {
			$gBitSystem->fatalError( "There was an error storing the item: ".\Bitweaver\vc( $nexus->mErrors ));
		}
		$nexus->load();
	} elseif( !empty( $pParamHash['nexus']['remove_item'] ) ) {
		$nexus->expungeItem( $pParamHash['nexus']['remove_item'] );
	}
}