本文整理汇总了PHP中General::createFileName方法的典型用法代码示例。如果您正苦于以下问题:PHP General::createFileName方法的具体用法?PHP General::createFileName怎么用?PHP General::createFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类General
的用法示例。
在下文中一共展示了General::createFileName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SymDate
$fields = $_POST['fields'];
$date = new SymDate($Admin->getConfigVar("time_zone", "region"), $Admin->getConfigVar("date_format", "region"));
##Make sure all required fields are filled
$required = array('name', 'source');
for ($i = 0; $i < count($required); $i++) {
if (trim($fields[$required[$i]]) == "") {
$errors[$required[$i]] = true;
}
}
if (is_array($errors)) {
define("__SYM_ENTRY_MISSINGFIELDS__", true);
} else {
$defines = array();
$fields['name'] = str_replace(array('\'', '"'), "", $fields['name']);
$handle = General::createFileName($fields['name'], $Admin->getConfigVar('handle_length', 'admin'), '_');
$rootelement = General::createFileName($fields['name'], $Admin->getConfigVar('handle_length', 'admin'), '-');
$classname = ucfirst($handle);
$source = $fields['source'];
$var = array('HANDLE' => $handle, 'ROOT-ELEMENT' => $rootelement, 'CLASS NAME' => $classname, 'NAME' => $fields['name'], 'DESCRIPTION' => "", 'AUTHOR-NAME' => $Admin->getAuthorName(), 'AUTHOR-WEBSITE' => General::validateURL(URL), 'AUTHOR-EMAIL' => $Admin->getAuthorEmail(), 'VERSION' => "1.0", 'RELEASE DATE' => date("Y-m-d H:i:s", $date->get(true, false)));
$xml_elements = array();
if (is_array($fields['xml-elements']) && !empty($fields['xml-elements'])) {
foreach ($fields['xml-elements'] as $f) {
$f = trim($f, '[]');
$bits = preg_split('/\\]\\[/i', $f, -1, PREG_SPLIT_NO_EMPTY);
list($group, $element) = $bits;
$xml_elements[$group][] = $element;
}
}
switch ($source) {
case "authors":
$defines['status'] = $fields['status'];
示例2: extract
if (array_key_exists("save", $_POST['action']) || array_key_exists("done", $_POST['action'])) {
##Split open the POST var into $fields & $hierarchy
extract($_POST);
##Make sure all required fields are filled
$required = array('name', 'body');
for ($i = 0; $i < count($required); $i++) {
if (trim($fields[$required[$i]]) == "") {
$errors[$required[$i]] = true;
}
}
if (is_array($errors)) {
define("__SYM_ENTRY_MISSINGFIELDS__", true);
} else {
$fields["data_sources"] = @implode(",", $fields["data_sources"]);
$fields["events"] = @implode(",", $fields["events"]);
$fields['name'] = General::createFileName(trim($fields['name']));
$file = WORKSPACE . "/masters/" . $fields['name'] . ".xsl";
if ($_REQUEST['file'] != $fields['name'] && @is_file($file)) {
$Admin->pageAlert("duplicate", array("A Page Master", "name"), false, 'error');
} elseif (!($write = General::writeFile($file, $fields['body'], $Admin->getConfigVar("write_mode", "file")))) {
$Admin->pageAlert("write-failed", array("Page Master"), false, 'error');
} else {
$id = $DB->fetchVar("id", 0, "SELECT `id` FROM tbl_masters WHERE `name` = '" . $_REQUEST['file'] . "'");
##No longer need the body text
unset($fields['body']);
##Insert the new data
if (!$DB->update($fields, "tbl_masters", "WHERE `id` = '{$id}'")) {
define("__SYM_DB_INSERT_FAILED__", true);
} else {
$DB->query("UPDATE `tbl_pages` SET `master` = '" . $fields['name'] . ".xsl' WHERE `master` = '" . $_REQUEST['file'] . ".xsl'");
##Ensure our metadata for the template is set
示例3: extract
***/
if (array_key_exists("save", $_POST['action']) || array_key_exists("done", $_POST['action'])) {
##Split open the POST var into $fields
extract($_POST);
##Make sure all required fields are filled
$required = array('name', 'body');
for ($i = 0; $i < count($required); $i++) {
if (trim($fields[$required[$i]]) == "") {
$errors[$required[$i]] = true;
}
}
if (is_array($errors)) {
define("__SYM_ENTRY_MISSINGFIELDS__", true);
} else {
$fields['type'] = strtolower($fields['type']);
$fields['name'] = General::createFileName($fields['name']);
$file_rel = str_replace("workspace/", "", $fields['location']) . $fields['name'];
$file = DOCROOT . "/" . $fields['location'] . $fields['name'];
if ($_REQUEST['file'] != "/" . $file_rel && @is_file($file)) {
$Admin->pageAlert("duplicate", array("An Asset", "name"), false, 'error');
} elseif (!($write = General::writeFile($file, $fields['body'], $Admin->getConfigVar("write_mode", "file")))) {
$Admin->pageAlert("write-failed", array("Asset"), false, 'error');
} else {
if ($file != WORKSPACE . $_REQUEST['file']) {
unlink(WORKSPACE . $_REQUEST['file']);
}
###
# Delegate: Edit
# Description: After saving the asset, the file path is provided.
$CampfireManager->notifyMembers('Edit', CURRENTPAGE, array("file" => $file));
if (@array_key_exists("save", $_POST['action'])) {