本文整理匯總了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.";
}
}
}