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


PHP Documents::FindById方法代码示例

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


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

示例1: display_page_content

function display_page_content()
{
    $document_id = requestIdParam();
    $document = Documents::FindById($document_id);
    ?>

	<script type="text/javascript">
		$().ready(function() {
			$("#edit_document").validate({
				rules : {
					name: "required"
				},
				messages: {
					name: "Please enter a name for this document"
				}
			});
		});
	</script>
	
	<div id="edit-header" class="documentnav">
		<h1>Edit Document</h1>
	</div>
	
	<form method="POST" enctype="multipart/form-data" id="edit_document">
		<input type="hidden" name="MAX_FILE_SIZE" value="15800000">
		
		<p class="display_name">
			<label for="name">Name:</label>
			<?php 
    textField("name", $document->name, "required: true");
    ?>
<br />
			<span class="hint">This is a more descriptive name for the file that will be displayed as the link when you insert it into a page. The name can start with the words &ldquo;Click here to download&hellip;&rdquo; in order t be most clear on the front-end display, but that is up to you.</span>
		</p>
		
		<p>
			<label for="filename">File Name (uneditable):</label>
			<?php 
    echo $document->filename;
    ?>
<br />
			<span class="hint">This is the physical name of the file that was uploaded.</span>
		</p>
		
		<p>
			<label for="file">Replace with a new document:</label>
			<?php 
    fileField('file');
    ?>
		</p>
		
		
		<div id="edit-footer" class="documentnav clearfix">
			<div class="column half">
		
				<p>
					<input type="submit" class="submitbutton" name="submit" value="Save Document" /> <br />
					<input type="submit" class="submitbuttonsmall" name="submit" value="Save and Return to List" />
				</p>
				
			</div>
			<div class="column half last">
<?php 
    $user = Users::GetCurrentUser();
    if ($user->has_role()) {
        ?>
	
				<p><label for="delete">Delete this document?</label>
					<input name="delete" class="boxes" type="checkbox" value="<?php 
        echo $document->id;
        ?>
" />
					<span class="hint">Check the box and then click &ldquo;Save&rdquo; above to delete this document from the database</span>
				</p>
<?php 
    }
    ?>
			</div>
		</div>
	
	</form>
<?php 
}
开发者ID:highchair,项目名称:hcd-trunk,代码行数:83,代码来源:edit_document.php

示例2: initialize_page

function initialize_page()
{
    $item = Items::FindById(getRequestVaratIndex(3));
    // get all the sections
    $sections = Sections::FindPublicSections();
    /* get this section
     * We do this mostly for the previous and next item functions. If we dont know what section we are currently inside, 
     * the user may get bounced over to a different place than they started. */
    $sectionname = getRequestVaratIndex(2);
    if ($sectionname != "item_orphan") {
        $section = Sections::FindByName($sectionname);
    }
    // get the associated gallery
    if ($item) {
        $gallery = $item->getGallery();
    }
    // finally, get the post action. Harder to hack if we explicitly check the value this way.
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Save Item" || $post_action == "Add Image" || $post_action == "Add Document" || $post_action == "Add or Edit Video" || $post_action == "Save and Return to List") {
        /* 
         * Delete this item and its associated components
         */
        if (isset($_POST['delete'])) {
            // delete $photos and $gallery
            if (is_object($gallery)) {
                $gallery->delete(true);
                $success .= "Gallery and Images Deleted / ";
            }
            /* Documents ... Why not keep them?
            			if ( ITEM_DOCUMENTS ) {
            			    $itemdocuments = $item->findDocuments( 'display_order ASC' );
            			    foreach ( $itemdocuments as $thedoc ) {
               				    $thedoc->delete(true); 
            			    }
            			    $success .= "Documents Deleted / ";
            			}*/
            $item->delete(true);
            $success .= "Item Deleted / ";
            setFlash("<h3>" . substr($success, 0, -3) . "</h3>");
            //$main_portlink = ( DISPLAY_ITEMS_AS_LIST ) ? "admin/portfolio_list/alphabetical" : "admin/portfolio_list";
            //redirect( $main_portlink );
            redirect("admin/portfolio_list");
        } else {
            $item->content = $_POST['item_content'];
            $item->display_name = $_POST['display_name'];
            $previous_name = $item->name;
            $item->name = slug($_POST['display_name']);
            $item->template = 'inherit';
            $item->public = checkboxValue($_POST, 'public');
            $item->date_revised = date('Y-m-d H:i:s');
            // optional fields
            $item->sku = ITEM_SKU ? $_POST['item_sku'] : null;
            $item->taxonomy = ITEM_TAXONOMY ? $_POST['taxonomy'] : null;
            $item->price = ITEM_PRICE ? $_POST['item_price'] : null;
            // SAVE item... uses a MyActiveRecord method
            $item->save();
            $success = "Item Saved / ";
            // synchronize the users section selections only if they are different
            $selected_sections = array();
            $previous_sections = $item->getSections();
            if (isset($_POST['selected_sections'])) {
                $update_sections = false;
                $selected_sections = $_POST['selected_sections'];
                // Problem: If we loop on only the $previous_sections, we may have fewer or more loops than $selected_sections.
                // Compare one to the other.
                if (count($previous_sections) != count($selected_sections)) {
                    // The two do not match, so there has been a change
                    $update_sections = true;
                } else {
                    // In case the two match, let's make sure something is different.
                    foreach ($previous_sections as $sect) {
                        if (!in_array($sect->id, $selected_sections)) {
                            $update_sections = true;
                        }
                    }
                }
                if ($update_sections) {
                    $item->updateSelectedSections($selected_sections);
                    // update the revision dates of sections, too
                    $item->updateSectionRevisionDates();
                }
            }
            /* 
             * Rename the gallery if the slug has changed. 
             * We need the name of the gallery and the name of the slug to be consistent. 
             * If there isn't a gallery – something broke, so – create a new one. 
             */
            if (is_object($gallery) && $previous_name != $item->name) {
                $gallery->slug = "portfolioGal_" . $item->id . "_" . $item->name;
                $gallery->save();
                $success .= "Gallery name changed / ";
            }
            if (!is_object($gallery)) {
                $gallery = MyActiveRecord::Create('Galleries');
                $gallery->name = $_POST['display_name'] . " Gallery";
                $gallery->slug = "portfolioGal_" . $item->id . "_" . slug($_POST['display_name']);
                $gallery->save();
//.........这里部分代码省略.........
开发者ID:highchair,项目名称:hcd-trunk,代码行数:101,代码来源:portfolio_edit.php


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