本文整理汇总了PHP中ViewList::viewExists方法的典型用法代码示例。如果您正苦于以下问题:PHP ViewList::viewExists方法的具体用法?PHP ViewList::viewExists怎么用?PHP ViewList::viewExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ViewList
的用法示例。
在下文中一共展示了ViewList::viewExists方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: viewFileName
}
function viewFileName($view_name)
{
global $conf;
$view_suffix = str_replace(" ", "_", $view_name);
return $conf['views_dir'] . "/view_" . preg_replace('/[^a-zA-Z0-9_-]/', '', $view_suffix) . ".json";
}
$viewList = new ViewList();
///////////////////////////////////////////////////////////////////////////////
// Create new view
///////////////////////////////////////////////////////////////////////////////
if (isset($_GET['create_view'])) {
if (!checkAccess(GangliaAcl::ALL_VIEWS, GangliaAcl::EDIT, $conf)) {
$output = "You do not have access to edit views.";
} else {
if ($viewList->viewExists($view_name)) {
$output = "<strong>Alert:</strong> View with the name " . $view_name . " already exists.";
} else {
$empty_view = array("view_name" => $view_name, "items" => array());
$view_filename = viewFileName($view_name);
if (pathinfo($view_filename, PATHINFO_DIRNAME) != $conf['views_dir']) {
die('Invalid path detected');
}
$json = json_encode($empty_view);
if (file_put_contents($view_filename, json_prettyprint($json)) === FALSE) {
$output = "<strong>Alert:</strong>" . " Can't write to file " . htmlspecialchars($view_filename) . " Perhaps permissions are wrong.";
} else {
$output = "View has been created successfully.";
}
}
}