本文整理汇总了PHP中Widgets::edit方法的典型用法代码示例。如果您正苦于以下问题:PHP Widgets::edit方法的具体用法?PHP Widgets::edit怎么用?PHP Widgets::edit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Widgets
的用法示例。
在下文中一共展示了Widgets::edit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
/**
* The Edit action of the Admin module should be triggered through an HTTP POST request
* in order to edit a widget that is already installed in the widget repository.
*
* @param integer $category The category's identifier in which the updated widget will be assigned.
* @param string $widget The widget's identifier relevant to the widget to update.
*/
public function edit($category, $widget)
{
// Security check.
if (!Auth::isAuth() && (Auth::isAdmin() || Auth::isGod())) {
DefaultFC::redirection('users/index?ref=admin');
}
try {
// When editing, two cases may occur :
// 1. Both widget file (xml manifest or zip archive) and category
// are provided.
// 2. Only the category is provided. Dev note: the $_FILES global has
// a strange behaviour when something is not provided... for instance
// if a file named 'widgetFile' was not uploaded, the $_FILES['widgetFile']['name']
// value will not be empty, or null, but filled with an empty string oO !
$widgetName = null;
if ($_FILES['widgetFile']['name'] == '') {
// Case 1.
$widgetName = Widgets::edit($widget, $category);
} else {
// Case 2.
$widgetName = Widgets::edit($widget, $category, $_FILES['widgetFile']['name'], $_FILES['widgetFile']['tmp_name']);
}
// If we are here, no exceptions was thrown by Widgets::edit so we assume
// as successful widget edition.
$_SESSION['isError'] = false;
$_SESSION['message'] = sprintf(__("Widget '%s' has been successfully updated."), $widgetName);
} catch (Exception $e) {
$_SESSION['isError'] = true;
$_SESSION['message'] = __("The widget could not be updated.");
}
DefaultFC::redirection('admin/index');
}