예제 #1
0
파일: Track.php 프로젝트: redokes/Framework
	public function delete($doAudit = true) {
		// get top level items and delete them, which will delete all children
		$itemTable = new Navigation_Model_Db_Item();
		$select = $itemTable->select()->where('trackId = ?', $this->row->trackId)->where('parentId = 0');
		$rows = $itemTable->fetchAll($select);
		$numRows = count($rows);
		if ($numRows) {
			for ($i = 0; $i < $numRows; $i++) {
				$item = new Navigation_Model_Item();
				$item->row = $rows[$i];
				$item->delete($doAudit);
			}
		}
		parent::delete($doAudit);
	}
예제 #2
0
	public function getNodesAction() {
		$items = array();
		
		$node = Redokes_Controller_Front::getInstance()->getParam('node');
		
		// if this is the root node, return the tracks
		if ($node == 'rootNode') {

			// select all tracks order by title
			$trackTable = new Navigation_Model_Db_Track();
			$select = $trackTable->select()->order('title');
			$rows = $trackTable->fetchAll($select);
			$numRows = count($rows);
			if ($numRows) {
				for ($i = 0; $i < $numRows; $i++) {
					$items[] = array(
						'text' => $rows[$i]['title'],
						'id' => 'trackId-' . $rows[$i]['trackId'],
						'cls' => 'folder',
						'itemType' => 'track',
						'trackId' => $rows[$i]->trackId,
						'title' => $rows[$i]->title,
						'itemId' => 0,
						'allowDrag' => false
					);
				}
			}
		}
		else if (preg_match('/trackId\-(\d+)/', $node, $matches)) {
			// get the top level children of the track
			$trackId = intval($matches[1]);
			$itemTable = new Navigation_Model_Db_Item();
			$select = $itemTable->select()->where('trackId = ?', $trackId)->where('parentId = 0')->order('sortOrder');
			$rows = $itemTable->fetchAll($select);
			$numRows = count($rows);
			if ($numRows) {
				for ($i = 0; $i < $numRows; $i++) {
					$items[] = array(
						'text' => $rows[$i]['title'],
						'id' => 'itemId-' . $rows[$i]['itemId'],
						'cls' => 'folder',
						'itemType' => 'item',

						'itemId' => $rows[$i]['itemId'],
						'title' => $rows[$i]['title'],
						'trackId' => $rows[$i]['trackId'],
						'parentId' => $rows[$i]['parentId'],
						'url' => $rows[$i]['url'],
						'target' => $rows[$i]['target']
					);
				}
			}
		}
		else if (preg_match('/itemId\-(\d+)/', $node, $matches)) {
			// get the children of this navigation item
			$itemId = intval($matches[1]);
			$item = new Navigation_Model_Item($itemId);
			if ($item->row->itemId) {
				$itemTable = new Navigation_Model_Db_Item();
				$select = $itemTable->select()->where('parentId = ?', $item->row->itemId)->order('sortOrder');
				$rows = $itemTable->fetchAll($select);
				$numRows = count($rows);
				if ($numRows) {
					for ($i = 0; $i < $numRows; $i++) {
						$items[] = array(
							'text' => $rows[$i]['title'],
							'id' => 'itemId-' . $rows[$i]['itemId'],
							'cls' => 'folder',
							'itemType' => 'item',

							'itemId' => $rows[$i]['itemId'],
							'title' => $rows[$i]['title'],
							'trackId' => $rows[$i]['trackId'],
							'parentId' => $rows[$i]['parentId'],
							'url' => $rows[$i]['url'],
							'target' => $rows[$i]['target']
						);
					}
				}
			}
		}

		// encode the array of nodes and output it as plain text
		$this->sendPlainText();
		echo json_encode($items);
	}