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


PHP Documents::FindByFilename方法代码示例

本文整理汇总了PHP中Documents::FindByFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP Documents::FindByFilename方法的具体用法?PHP Documents::FindByFilename怎么用?PHP Documents::FindByFilename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Documents的用法示例。


在下文中一共展示了Documents::FindByFilename方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: initialize_page

function initialize_page()
{
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Add Document" || $post_action == "Add and Return to List") {
        $name = $_POST['name'];
        $file_type = getFileExtension($_FILES['file']['name']);
        $filename = slug(getFileName($_FILES['file']['name']));
        $filename_string = $filename . "." . $file_type;
        // Check to make sure there isn't already a file with that name
        $possibledoc = Documents::FindByFilename($filename_string);
        if (is_object($possibledoc)) {
            setFlash("<h3>Failure: Document filename already exists!</h3>");
            redirect("admin/add_document");
        }
        $target_path = SERVER_DOCUMENTS_ROOT . $filename_string;
        if (move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
            $new_doc = MyActiveRecord::Create('Documents', array('name' => $name, 'filename' => $filename_string, 'file_type' => $file_type));
            $new_doc->save();
            if (!chmod($target_path, 0644)) {
                setFlash("<h3>Warning: Document Permissions not set; this file may not display properly</h3>");
            }
            setFlash("<h3>Document uploaded</h3>");
        } else {
            setFlash("<h3>Failure: Document could not be uploaded</h3>");
        }
        if ($post_action == "Add and Return to List") {
            redirect("admin/list_documents");
        }
    }
}
开发者ID:highchair,项目名称:hcd-trunk,代码行数:33,代码来源:add_document.php

示例2: document_display

function document_display($content_to_display)
{
    $documentPattern = "/{{2}(document:[A-Za-z0-9\\-\\_ \\.\\(\\)'\"]+){{2}/";
    $documentIds = getFilterIds($content_to_display, $documentPattern);
    $documents = array();
    foreach ($documentIds as $documentId) {
        $filename = end(explode(":", $documentId));
        $documents[] = Documents::FindByFilename($filename);
    }
    foreach ($documents as $document) {
        if (is_object($document)) {
            $replacement = "<a class=\"hcd-document " . getFileExtension($document->filename) . "\" href=\"{$document->getPublicUrl()}\">" . cleanupSpecialChars($document->name) . "</a> (" . getFileExtension($document->filename) . ")";
            $content_to_display = updateContent($content_to_display, "/{{2}document:" . str_replace(")", "\\)", str_replace("(", "\\(", $document->filename)) . "{{2}/", $replacement);
        } else {
            $content_to_display = "<span class=\"database_error\">HCd&gt;CMS Warning: Document &ldquo;{$filename}&rdquo; not found!</span> " . $content_to_display;
        }
    }
    return $content_to_display;
}
开发者ID:highchair,项目名称:hcd-trunk,代码行数:19,代码来源:replacement.php


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