當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Version::update方法代碼示例

本文整理匯總了PHP中Version::update方法的典型用法代碼示例。如果您正苦於以下問題:PHP Version::update方法的具體用法?PHP Version::update怎麽用?PHP Version::update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Version的用法示例。


在下文中一共展示了Version::update方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: update_version

    public function update_version()
    {
        if (!isset($_POST['version_id'])) {
            error(__("Error"), __("No version ID specified.", "extend"));
        }
        $version = new Version($_POST['version_id'], array("filter" => false));
        if ($version->no_results) {
            error(__("Error"), __("Invalid version ID specified.", "extend"));
        }
        if (!$version->editable()) {
            show_403(__("Access Denied"), __("You do not have sufficient privileges to edit this version.", "extend"));
        }
        $files = array();
        if (!empty($_FILES['attachment'])) {
            foreach ($_FILES['attachment'] as $key => $val) {
                foreach ($val as $file => $attr) {
                    $files[$file][$key] = $attr;
                }
            }
        }
        foreach ($files as $attachment) {
            if ($attachment['error'] != 4) {
                $path = upload($attachment, null, "attachments");
                Attachment::add(basename($path), $path, "version", $version->id);
            }
        }
        $version->extension->update($_POST['name']);
        if ($_FILES['extension']['error'] == 0) {
            @unlink(uploaded($version->filename, true));
            # Add the MIT license if no license is specified
            $zip = new ZipArchive();
            if ($zip->open($_FILES['extension']['tmp_name']) === true and $zip->locateName("LICENSE") === false) {
                $header = "Copyright (c) " . date("Y") . " " . oneof($visitor->full_name, $visitor->login);
                $mit = <<<EOF
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise
to promote the sale, use or other dealings in this Software
without prior written authorization.
EOF;
                $zip->addFromString("LICENSE", $header . "\n\n" . $mit . "\n");
                $zip->close();
            }
            $filename = upload($_FILES['extension'], "zip", "extension/" . pluralize($version->extension->type->url));
        } else {
            $filename = $version->filename;
        }
        if ($_FILES['image']['error'] == 0) {
            @unlink(uploaded($version->image, true));
            $image = upload($_FILES['image'], null, "previews/" . pluralize($version->extension->type->url));
        } else {
            $image = $version->image;
        }
        $version->update($_POST['number'], $_POST['description'], comma_sep($_POST['compatible']), comma_sep($_POST['tags']), $filename, $image);
        Flash::notice(__("Version updated.", "extend"), $version->url());
    }
開發者ID:vito,項目名稱:chyrp-site,代碼行數:76,代碼來源:controller.Extend.php

示例2: redirect

        $hasData = true;
    }
    if (!empty($_POST['url'])) {
        $v->url = $_POST['url'];
        $hasData = true;
    }
    if (!empty($_POST['signature'])) {
        $v->signature = $_POST['signature'];
        $hasData = true;
    }
    if (!empty($_POST['filesize'])) {
        $v->filesize = $_POST['filesize'];
        $hasData = true;
    }
    if ($hasData) {
        $v->update();
    }
    redirect('version-edit.php?id=' . $v->id);
}
// END adib 7-Apr-2010 18:53
if (isset($_POST['btnDelete'])) {
    $v->delete();
    redirect('versions.php?id=' . $app->id);
}
$version_number = $v->version_number;
$human_version = $v->human_version;
$release_notes = $v->release_notes;
$url = $v->url;
$signature = $v->signature;
$filesize = $v->filesize;
?>
開發者ID:adib,項目名稱:Shine,代碼行數:31,代碼來源:version-edit.php


注:本文中的Version::update方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。