本文整理汇总了PHP中Nette\String::webalize方法的典型用法代码示例。如果您正苦于以下问题:PHP String::webalize方法的具体用法?PHP String::webalize怎么用?PHP String::webalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\String
的用法示例。
在下文中一共展示了String::webalize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createComponentAddTagForm
protected function createComponentAddTagForm()
{
$form = new AppForm();
$form->addText("name", "Name", 40, 50);
$form->addSubmit("s", "Add");
$presenter = $this;
$form->onSubmit[] = function ($form) use($presenter) {
$name = $form->values["name"];
$tag = new Tag();
$tag->name = $name;
$tag->url = String::webalize($name);
try {
$tag->save();
$presenter->flashMessage("Tag was added!");
$presenter->redirect("default");
} catch (\ModelException $e) {
$tag->addErrorsToForm($form);
}
};
return $form;
}
示例2: setUrl
public function setUrl($url)
{
$this->url = String::webalize($url);
}
示例3: json_encode
// security check
//if (!$allowed) {
// $state["error"] = "You are not allowed to upload files.";
//}
if (empty($file)) {
$state["error"] = "No file was uploaded";
}
// check directory
if ($root === false || $dir === false || !String::startsWith($dir, $root) || !is_dir($dir) || !is_writable($dir)) {
$state["error"] = "Problem with directory to upload.";
}
if (!empty($state["error"])) {
die(json_encode($state));
}
if ($file->isOk()) {
$filename = String::webalize($file->getName(), ".");
$success = @$file->move("{$dir}/{$filename}");
if ($success) {
// nastavit typ - je to obrázek?
$type = @$file->getImageSize() ? "image" : "file";
$prefix = $type == "image" ? FILES_IMAGE_INCLUDE_PREFIX : FILES_FILE_INCLUDE_PREFIX;
$state["filename"] = $prefix . ($folder ? "{$folder}/" : "") . $filename;
$state["type"] = $type;
} else {
$state["error"] = "Move failed";
}
} else {
$state["error"] = "Upload error " . $file->getError();
}
// výstup
echo json_encode($state);
示例4: setName
public function setName($name)
{
$this->name = $name;
$this->url = \Nette\String::webalize($name);
}
示例5: actionRename
/**
* Rename file or directory
* @param string folder
* @param string old item name
* @param string new item name
*/
public function actionRename($folder, $oldname, $newname)
{
// check rights
if (!$this->getUser()->isInRole("admin")) {
$this->sendError("Access denied.");
}
$oldpath = $this->getFolderPath($folder) . "/" . $oldname;
$newpath = $this->getFolderPath($folder) . "/" . String::webalize($newname, ".");
if (!file_exists($oldpath)) {
$this->sendError("File does not exist.");
}
if (rename($oldpath, $newpath)) {
$this->sendResponse(new JsonResponse(array("deleted" => true)));
} else {
$this->sendError("Unable to rename file.");
}
}