当前位置: 首页>>代码示例>>PHP>>正文


PHP Widget::delete方法代码示例

本文整理汇总了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;
    }
}
开发者ID:parrain27,项目名称:yana-server,代码行数:92,代码来源:dashboard.plugin.php

示例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 {
开发者ID:jetmirhaxhisefa,项目名称:rezervime,代码行数:31,代码来源:addAndDeleteWidget.php

示例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: / ');
 }
开发者ID:Christian1998,项目名称:php_btc_exchange,代码行数:16,代码来源:widgetControlController.php


注:本文中的Widget::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。