本文整理汇总了PHP中Navigation::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Navigation::update方法的具体用法?PHP Navigation::update怎么用?PHP Navigation::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Navigation
的用法示例。
在下文中一共展示了Navigation::update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editAction
function editAction()
{
$request = new RivetyCore_Request($this->getRequest());
if ($request->has('role_id'))
{
$nav_id = $request->nav_id;
$role_id = $request->role_id;
$nav_table = new Navigation($role_id, $this->locale_code);
$roles_table = new Roles();
$role = $roles_table->fetchRow("id = " . $role_id);
if (!is_null($role))
{
$role = $role->toArray();
$this->view->role = $role;
}
else
{
die("Invalid role.");
}
if ($this->getRequest()->isPost())
{
$parent_id = $request->parent_id;
$short_name = $request->short_name;
$link_text = $request->link_text;
$url = $request->url;
$data = array(
'parent_id' => $parent_id,
'short_name' => $short_name,
'link_text' => $link_text,
'url' => $url,
);
if ($nav_id == 0)
{
// INSERT
$data['role_id'] = $role_id;
// make sure it's the last item
$data['sort_order'] = '99999999999';
$params = array($role_id,$this->locale_code);
$nav_table->insert($data);
// now get rid of all those nines
RivetyCore_Sort::reNumber('Navigation', "parent_id = " . $parent_id . " and role_id = " . $role_id, 'id', 'sort_order', 10, $params);
}
else
{
// UPDATE
$nav_table->update($data, 'id = ' . $nav_id);
}
RivetyCore_Cache::removeByTags(array('navigation'));
$this->_redirect('/default/navigation/editrole/id/' . $role_id);
}
else
{
$nav_s = new Navigation($role_id,$this->locale_code);
$new_nav = $nav_s->getNavTree();
$this->view->parent_choices = $new_nav;
$this->view->role_id = $role_id;
if ($nav_id == 0)
{
// CREATE
$this->view->pagetitle = 'Create Nav Link for ' . $role['shortname'] . ' Role';
$this->view->nav_id = '0';
$this->view->parent_id = '0';
$this->view->short_name = '';
$this->view->link_text = '';
$this->view->url = '';
}
else
{
// EDIT
$nav_item_temp = $nav_table->fetchRow("id = " . $nav_id);
if (!is_null($nav_item_temp))
{
$this->view->pagetitle = "Edit Nav Link for " . $role["shortname"] . " Role";
$this->view->nav_id = $nav_id;
$this->view->parent_id = $nav_item_temp->parent_id;
$this->view->short_name = $nav_item_temp->short_name;
$this->view->link_text = $nav_item_temp->link_text;
$this->view->url = $nav_item_temp->url;
}
else
{
$this->_forward('default', 'auth', 'missing'); return;
}
}
}
}
else
{
$this->_forward('default', 'auth', 'missing'); return;
}
}
示例2: header
header('WWW-Authenticate: Basic realm="Navigation"');
header('HTTP/1.0 401 Unauthorized');
echo json_encode($res);
return;
}
$error = false;
$out = null;
$nav = new Navigation();
switch ($this->params[0]) {
case 'update':
$tree = $_POST['tree'];
if (empty($tree)) {
$tree = array();
}
require_once 'apps/navigation/lib/Functions.php';
if ($nav->update($tree) && $nav->save()) {
$out = array('msg' => sprintf('Nav json has been updated'));
} else {
$error = $nav->error;
}
break;
default:
$error = 'Unknown method';
break;
}
if (!$error) {
require_once 'apps/navigation/lib/Functions.php';
navigation_clear_cache();
}
$res = new StdClass();
if ($error) {