当前位置: 首页>>代码示例>>PHP>>正文


PHP General::createFileName方法代码示例

本文整理汇总了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'];
开发者ID:symphonycms,项目名称:symphony-1.7,代码行数:31,代码来源:sym_blueprint_datasources_new.php

示例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
开发者ID:symphonycms,项目名称:symphony-1.7,代码行数:31,代码来源:sym_blueprint_masters_edit.php

示例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'])) {
开发者ID:symphonycms,项目名称:symphony-1.7,代码行数:31,代码来源:sym_blueprint_assets_edit.php


注:本文中的General::createFileName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。