本文整理汇总了PHP中Widget::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Widget::create方法的具体用法?PHP Widget::create怎么用?PHP Widget::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Widget
的用法示例。
在下文中一共展示了Widget::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initForUser
public static function initForUser($id)
{
foreach (array('Salon', 'Cuisine', 'Chambre', 'Garage', 'Système') as $room) {
$entity = new Dashboard();
$entity->create();
$entity->user = $id;
$entity->label = $room;
$entity->default = 0;
$entity->save();
}
$entity = new Dashboard();
$entity->create();
$entity->user = $id;
$entity->label = "Général";
$entity->default = 1;
$entity->save();
$dashboard = $entity->id;
$entity = new Widget();
$entity->create();
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_profil\', \'null\', \'0\', \'0\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_ram\', \'null\', \'0\', \'1\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_system\', \'null\', \'0\', \'2\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_network\', \'null\', \'0\', \'2\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_hdd\', \'null\', \'3\', \'1\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_disk\', \'null\', \'0\', \'1\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_gpio\', \'null\', \'1\', \'0\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_services\', \'null\', \'0\', \'2\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_users\', \'null\', \'0\', \'0\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_ram\', \'null\', \'0\', \'1\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_vocal\', \'null\', \'1\', \'2\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_logs\', \'null\', \'1\', \'2\', \'\',\'' . $dashboard . '\');');
return $dashboard;
}
示例2: redirect
if (!$session->isLogin) {
redirect("../login.php");
}
$database = new Database();
$user = new User();
$widget = new Widget();
$menu = new Menu();
$post = new Post();
if (isset($_POST['widgetName'])) {
$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']);
示例3: Dashboard
<?php
global $myUser;
require_once 'Dashboard.class.php';
require_once 'Widget.class.php';
$entity = new Dashboard();
$entity->create();
$entity->user = $myUser->getId();
$entity->label = "Général";
$entity->default = 1;
$entity->save();
$dashboard = $entity->id;
$entity = new Widget();
$entity->create();
$s1 = new Section();
$s1->setLabel('dashboard');
$s1->save();
$r1 = new Right();
$r1->setSection($s1->getId());
$r1->setRead('1');
$r1->setDelete('1');
$r1->setCreate('1');
$r1->setUpdate('1');
$r1->setRank('1');
$r1->save();
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("id", "model", "data", "cell", "column", "minified","dashboard") VALUES (1, \'dash_profil\', \'null\', \'0\', \'0\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("id", "model", "data", "cell", "column", "minified","dashboard") VALUES (2, \'dash_monitoring_ram\', \'null\', \'0\', \'1\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("id", "model", "data", "cell", "column", "minified","dashboard") VALUES (3, \'dash_monitoring_system\', \'null\', \'0\', \'2\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("id", "model", "data", "cell", "column", "minified","dashboard") VALUES (4, \'dash_monitoring_network\', \'null\', \'0\', \'2\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("id", "model", "data", "cell", "column", "minified","dashboard") VALUES (5, \'dash_monitoring_hdd\', \'null\', \'3\', \'1\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("id", "model", "data", "cell", "column", "minified","dashboard") VALUES (6, \'dash_monitoring_disk\', \'null\', \'0\', \'1\', \'\',\'' . $dashboard . '\');');