本文整理汇总了PHP中Widget::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Widget::delete方法的具体用法?PHP Widget::delete怎么用?PHP Widget::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Widget
的用法示例。
在下文中一共展示了Widget::delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dashboard_plugin_actions
function dashboard_plugin_actions()
{
global $myUser, $_, $conf;
switch ($_['action']) {
case 'GET_WIDGETS':
header('Content-type: application/json');
require_once dirname(__FILE__) . '/Dashboard.class.php';
require_once dirname(__FILE__) . '/Widget.class.php';
$dashManager = new Dashboard();
$dashManager->change(array('default' => '0'));
$dashManager->change(array('default' => '1'), array('id' => $_['dashboard']));
$widgetManager = new Widget();
$model = array();
Plugin::callHook("widgets", array(&$model));
$widgets = $widgetManager->loadAll(array('dashboard' => $_['dashboard']), 'cell');
$data = array();
foreach ($widgets as $widget) {
$data[] = array('data' => $widget->data, 'column' => $widget->column, 'id' => $widget->id, 'cell' => $widget->cell, 'minified' => $widget->minified, 'model' => $widget->model);
}
echo json_encode(array('model' => $model, 'data' => $data));
break;
case 'ADD_WIDGET':
header('Content-type: application/json');
require_once dirname(__FILE__) . '/Widget.class.php';
$response = array();
$widget = new Widget();
$widget->data = json_encode($_POST['data']);
$widget->column = $_['column'];
$widget->cell = $_['cell'];
$widget->model = $_['model'];
$widget->dashboard = $_['view'];
$widget->save();
$response['id'] = $widget->id;
echo json_encode($response);
break;
case 'MINIMIZE_WIDGET':
header('Content-type: application/json');
require_once dirname(__FILE__) . '/Widget.class.php';
$response = array();
$widgetManager = new Widget();
$widgetManager = $widgetManager->getById($_['id']);
$widgetManager->minified = 1;
$widgetManager->save();
echo json_encode($response);
break;
case 'MAXIMIZE_WIDGET':
header('Content-type: application/json');
require_once dirname(__FILE__) . '/Widget.class.php';
$response = array();
$widgetManager = new Widget();
$widgetManager = $widgetManager->getById($_['id']);
$widgetManager->minified = 0;
$widgetManager->save();
echo json_encode($response);
break;
case 'MOVE_WIDGET':
header('Content-type: application/json');
require_once dirname(__FILE__) . '/Widget.class.php';
$response = array();
$widgetManager = new Widget();
foreach ($_['sort']['cells'] as $id => $sort) {
$widgetManager->change(array('cell' => $sort['cell'], 'column' => $sort['column']), array('id' => $id));
}
echo json_encode($response);
break;
case 'DELETE_WIDGET':
header('Content-type: application/json');
require_once dirname(__FILE__) . '/Widget.class.php';
$response = array();
$widgetManager = new Widget();
$widgetManager->delete(array('id' => $_['id']));
echo json_encode($response);
break;
case 'DASH_ADD_VIEW':
global $_, $myUser;
require_once dirname(__FILE__) . '/Dashboard.class.php';
$entity = new Dashboard();
$entity->user = $myUser->getId();
$entity->label = $_['viewName'];
$entity->default = 0;
$entity->save();
header('location: setting.php?section=preference&block=dashboard');
break;
case 'DASH_DELETE_VIEW':
global $_, $myUser;
require_once dirname(__FILE__) . '/Dashboard.class.php';
$entity = new Dashboard();
$entity->delete(array('id' => $_['id']));
header('location: setting.php?section=preference&block=dashboard');
break;
}
}
示例2: foreach
$widgetId = $database->escapeString($_POST['widgetName']);
$widgetName = "Widget " . $widgetId;
$widget->setWidgetId($widgetId);
$widget->setName($widgetName);
$widget->setMenuId(0);
$widget->setPostId(0);
if ($widget->create($database)) {
echo "true";
} else {
echo "false";
}
} else {
if (isset($_POST['widgetIds'])) {
foreach ($_POST['widgetIds'] as $widgetId) {
$widget->setWidgetId($widgetId);
$widget->delete($database);
}
echo "true";
} else {
if (isset($_POST['widgetId'])) {
$widgetId = $database->escapeString($_POST['widgetId']);
$type = $database->escapeString($_POST['type']);
$array = [];
$widget->setWidgetId($widgetId);
if ($type == "menu") {
$menuOrPostId = $database->escapeString($_POST['menuOrPostId']);
$widget->setMenuId($menuOrPostId);
$widget->setPostId(0);
$widget->update($database);
echo "true";
} else {
示例3: removeWidget
public static function removeWidget()
{
$usr = usr::getCurrentUser(1);
if (!isset($usr)) {
return;
}
$widgetId = Core::validate(self::getVar('id'));
$widget = new Widget();
$result = $widget->findBy(array('UID' => $usr->getId(), 'id' => $widgetId));
if (count($result) <= 0) {
return;
}
$widget->setId($widgetId);
$widget->delete();
header('Location: / ');
}