public function output(Pagemill_Data $data, Pagemill_Stream $stream) { $data = $data->fork(); if (!empty($this->attributes['menuplugid'])) { $menuplugid = $this->attributes['menuplugid']; $db = Typeframe::Database(); $base = substr(Typeframe::CurrentPage()->uri(), STRLEN(TYPEF_WEB_DIR)); if ($base == '') { $base = '/'; } $search = new Model_Nav(); $search->where('plugid = ?', $menuplugid); $search->where('url = ? OR url = ? OR url = ? OR url = ? OR url = ? OR url = ? OR pageid = ?', "~{$base}", "~{$base}/", "/{$base}", "/{$base}/", TYPEF_WEB_DIR . $base, TYPEF_WEB_DIR . $base . '/', Typeframe::CurrentPage()->pageid()); foreach ($search->select() as $current) { $current['url'] = $this->_convertUrl($current['url']); $data->set('current', $current); $parentid = $current['parent']; $siblings = new Model_Nav(); $siblings->where('plugid = ?', $menuplugid); $siblings->where('parent = ?', $parentid); $siblings->order('sortnum'); $data['siblings'] = $siblings; /*$sibArray = array(); foreach ($siblings->select() as $sib) { $sib['url'] = $this->_convertUrl($sib['url']); $sibArray[] = $sib; } $data['siblings'] = $sibArray;*/ if (!empty($this->attributes['showparent'])) { $parent = $db->execute('SELECT * FROM #__nav WHERE itemid = ' . $parentid); foreach ($parent as $par) { $par['url'] = $this->_convertUrl($par['url']); $data->set('parent', $par); } } if (!empty($this->attributes['showchildren'])) { $childArray = array(); $children = $db->execute('SELECT * FROM #__nav WHERE plugid = ' . $menuplugid . ' AND parent = ' . $current['itemid'] . ' ORDER BY sortnum'); foreach ($children as $chi) { $chi['url'] = $this->_convertUrl($chi['url']); $childArray[] = $chi; } $data['children'] = $childArray; } } } $this->pluginTemplate = "navigation/submenu.plug.html"; parent::output($data, $stream); }
<?php // This needs to be able to support retrieving fields from existing items, ie: edit. if (isset($_POST['type'])) { $type = $_POST['type']; } else { $type = 'none'; } if (isset($_POST['itemid'])) { $itemid = (int) $_POST['itemid']; } else { $itemid = 0; } // If an itemID was requested, retrieve that information. if ($itemid) { $item = Model_Nav::Get($itemid); $item['type'] = $type; // Strip mailto: from URL of mailto links for display in admin if ($item['type'] == 'mailto') { $item['url'] = substr($item['url'], 7); } } else { // A few defaults. $item = array(); if ($type != 'mailto' && $type != 'arbint') { $item['url'] = 'http://'; } $item['type'] = $type; } // Different types may require different data to be populated into the template. switch ($type) {
public function action_ajax_saveseo() { $seotitle = Arr::get($_POST, 'seotitle'); $keyword = Arr::get($_POST, 'keyword'); $description = Arr::get($_POST, 'description'); $tagword = Arr::get($_POST, 'tagword'); $jieshao = Arr::get($_POST, 'jieshao'); if (!empty($seotitle) && !empty($keyword) && !empty($description) && !empty($tagword) && !empty($jieshao)) { $isfinish = 1; } else { $isfinish = 0; } $navid = Arr::get($_POST, 'navid'); $model = new Model_Nav($navid); $model->seotitle = $seotitle; $model->keyword = $keyword; $model->description = $description; $model->tagword = $tagword; $model->jieshao = $jieshao; $model->isfinishseo = $isfinish; /*$model->set('seotitle', Arr::get($_POST,'seotitle')); $model->set('keyword',Arr::get($_POST,'keyword')); $model->set('description',Arr::get($_POST,'description')); $model->set('tagword' , Arr::get($_POST,'tagword')); $model->set('jieshao' , Arr::get($_POST,'jieshao'));*/ $model->update(); echo json_encode(array('status' => true)); }
/** * Build an array tree from a given navigation item. * * Works by taking a node and attaches the children */ private function get_tree_down($navitem) { $children = new Model_Nav(); $children->where('parent = ?', $navitem->get('itemid')); $childs = array(); foreach ($children->getAll() as $child) { $childs[] = $this->get_tree_down($child); } if (!empty($childs)) { $navitem['children'] = $childs; } return $navitem; }
<?php // This page is an ajax-only page... sorry if ($_SERVER['REQUEST_METHOD'] != 'POST') { die('Unexpected submission type.'); } if (!(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')) { die('Unexpected submission type.'); } if (!isset($_POST['itemid'])) { die(json_encode(array('status' => 'ok', 'message' => 'No records provided.'))); } // prepare('UPDATE #__nav SET sortnum = ? WHERE itemid = ?'); foreach ($_POST['itemid'] as $k => $v) { $navitem = Model_Nav::Get($v); $navitem->set('sortnum', $k); $navitem->save(); } die(json_encode(array('status' => 'ok', 'message' => 'Updated records')));