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


PHP FileModel::getById方法代码示例

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


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

示例1: renderContent

 protected function renderContent()
 {
     $homeUrl = Yii::app()->createUrl('home/default');
     $content = '<div class="clearfix">';
     $content .= '<a href="#" id="nav-trigger" title="Toggle Navigation">&rsaquo;</a>';
     $content .= '<div id="corp-logo">';
     if ($logoFileModelId = ZurmoConfigurationUtil::getByModuleName('ZurmoModule', 'logoFileModelId')) {
         $logoFileModel = FileModel::getById($logoFileModelId);
         $logoFileSrc = Yii::app()->getAssetManager()->getPublishedUrl(Yii::getPathOfAlias('application.runtime.uploads') . DIRECTORY_SEPARATOR . $logoFileModel->name);
     } else {
         $logoFileSrc = Yii::app()->themeManager->baseUrl . '/default/images/Zurmo_logo.png';
     }
     $logoHeight = ZurmoConfigurationFormAdapter::resolveLogoHeight();
     $logoWidth = ZurmoConfigurationFormAdapter::resolveLogoWidth();
     if (Yii::app()->userInterface->isMobile()) {
         $content .= '<a href="' . $homeUrl . '"><img src="' . $logoFileSrc . '" alt="Zurmo Logo" /></a>';
         //make sure width and height are NEVER defined
     } else {
         $content .= '<a href="' . $homeUrl . '"><img src="' . $logoFileSrc . '" alt="Zurmo Logo" height="' . $logoHeight . '" width="' . $logoWidth . '" /></a>';
     }
     if ($this->applicationName != null) {
         $content .= ZurmoHtml::tag('span', array(), $this->applicationName);
     }
     $content .= '</div>';
     if (!empty($this->userMenuItems) && !empty($this->settingsMenuItems)) {
         $content .= '<div id="user-toolbar" class="clearfix">';
         $content .= static::renderHeaderMenus($this->userMenuItems, $this->settingsMenuItems);
         $content .= '</div>';
     }
     $content .= '</div>';
     return $content;
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:32,代码来源:HeaderLinksView.php

示例2: actionDelete

 public function actionDelete($id)
 {
     $fileModel = FileModel::getById((int) $id);
     $fileModel->delete();
     //todo: add error handling.
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:6,代码来源:FileModelController.php

示例3: attachFilesToMessage

 /**
  * @param array $filesIds
  * @param EmailMessage $emailMessage
  */
 public static function attachFilesToMessage(array $filesIds, $emailMessage)
 {
     foreach ($filesIds as $fileId) {
         $attachment = FileModel::getById((int) $fileId);
         $emailMessage->files->add($attachment);
     }
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:11,代码来源:EmailMessageUtil.php

示例4: deleteCurrentCustomLogo

 public static function deleteCurrentCustomLogo()
 {
     if ($logoFileModelId = ZurmoConfigurationUtil::getByModuleName('ZurmoModule', 'logoFileModelId')) {
         //Get path of currently uploaded logo, required to delete/unlink legacy logo from runtime/uploads
         $logoFileModel = FileModel::getById($logoFileModelId);
         $currentLogoFileName = $logoFileModel->name;
         $currentLogoFilePath = Yii::getPathOfAlias('application.runtime.uploads') . DIRECTORY_SEPARATOR . $currentLogoFileName;
         if (file_exists($currentLogoFilePath)) {
             unlink($currentLogoFilePath);
         }
     }
 }
开发者ID:KulturedKitsch,项目名称:kulturedkitsch.info,代码行数:12,代码来源:ZurmoUserInterfaceConfigurationFormAdapter.php

示例5: testDifferentMimeTypes

 public function testDifferentMimeTypes()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $pathToFiles = Yii::getPathOfAlias('application.modules.zurmo.tests.unit.files');
     $contents1 = file_get_contents($pathToFiles . DIRECTORY_SEPARATOR . 'testNote.txt');
     $contents2 = file_get_contents($pathToFiles . DIRECTORY_SEPARATOR . 'testDocument.docx');
     $contents3 = file_get_contents($pathToFiles . DIRECTORY_SEPARATOR . 'testImage.png');
     $contents4 = file_get_contents($pathToFiles . DIRECTORY_SEPARATOR . 'testPDF.pdf');
     $contents5 = file_get_contents($pathToFiles . DIRECTORY_SEPARATOR . 'testZip.zip');
     $file1 = ZurmoTestHelper::createFileModel();
     $file2 = ZurmoTestHelper::createFileModel('testDocument.docx');
     $file3 = ZurmoTestHelper::createFileModel('testImage.png');
     $file4 = ZurmoTestHelper::createFileModel('testPDF.pdf');
     $file5 = ZurmoTestHelper::createFileModel('testZip.zip');
     $file1Id = $file1->id;
     $file2Id = $file2->id;
     $file3Id = $file3->id;
     $file4Id = $file4->id;
     $file5Id = $file5->id;
     $file1->forget();
     $file2->forget();
     $file3->forget();
     $file4->forget();
     $file5->forget();
     $file1 = FileModel::getById($file1Id);
     $this->assertEquals($contents1, $file1->fileContent->content);
     $this->assertEquals('testNote.txt', $file1->name);
     $this->assertEquals('text/plain', $file1->type);
     $this->assertEquals(6495, $file1->size);
     $file2 = FileModel::getById($file2Id);
     $this->assertEquals($contents2, $file2->fileContent->content);
     $this->assertEquals('testDocument.docx', $file2->name);
     $this->assertEquals('application/msword', $file2->type);
     $this->assertEquals(14166, $file2->size);
     $file3 = FileModel::getById($file3Id);
     $this->assertEquals($contents3, $file3->fileContent->content);
     $this->assertEquals('testImage.png', $file3->name);
     $this->assertEquals('image/png', $file3->type);
     $this->assertEquals(3332, $file3->size);
     $file4 = FileModel::getById($file4Id);
     $this->assertEquals($contents4, $file4->fileContent->content);
     $this->assertEquals('testPDF.pdf', $file4->name);
     $this->assertEquals('application/pdf', $file4->type);
     $this->assertEquals(81075, $file4->size);
     $file5 = FileModel::getById($file5Id);
     $this->assertEquals($contents5, $file5->fileContent->content);
     $this->assertEquals('testZip.zip', $file5->name);
     $this->assertEquals('application/zip', $file5->type);
     $this->assertEquals(3492, $file5->size);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:50,代码来源:FileModelUtilTest.php

示例6: resolveAndRenderLogoContent

 protected function resolveAndRenderLogoContent()
 {
     $homeUrl = Yii::app()->createUrl('home/default');
     $content = null;
     if ($logoFileModelId = ZurmoConfigurationUtil::getByModuleName('ZurmoModule', 'logoFileModelId')) {
         $logoFileModel = FileModel::getById($logoFileModelId);
         $logoFileSrc = Yii::app()->getAssetManager()->getPublishedUrl(Yii::getPathOfAlias('application.runtime.uploads') . DIRECTORY_SEPARATOR . $logoFileModel->name);
     } else {
         $logoFileSrc = Yii::app()->themeManager->baseUrl . '/default/images/Zurmo_logo.png';
     }
     $logoHeight = ZurmoUserInterfaceConfigurationFormAdapter::resolveLogoHeight();
     $logoWidth = ZurmoUserInterfaceConfigurationFormAdapter::resolveLogoWidth();
     if (Yii::app()->userInterface->isMobile()) {
         //make sure width and height are NEVER defined
         $content .= '<img src="' . $logoFileSrc . '" alt="Zurmo Logo" />';
     } else {
         $content .= '<img src="' . $logoFileSrc . '" alt="Zurmo Logo" height="' . $logoHeight . '" width="' . $logoWidth . '" />';
     }
     if ($this->applicationName != null) {
         $content .= ZurmoHtml::tag('span', array(), $this->applicationName);
     }
     return ZurmoHtml::link($content, $homeUrl, array('class' => 'clearfix', 'id' => 'corp-logo'));
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:23,代码来源:HeaderView.php

示例7: handlePublishLogoAssets

 public function handlePublishLogoAssets($event)
 {
     if (null !== ZurmoConfigurationUtil::getByModuleName('ZurmoModule', 'logoFileModelId')) {
         $logoFileModelId = ZurmoConfigurationUtil::getByModuleName('ZurmoModule', 'logoFileModelId');
         $logoFileModel = FileModel::getById($logoFileModelId);
         $logoFileSrc = Yii::app()->getAssetManager()->getPublishedUrl(Yii::getPathOfAlias('application.runtime.uploads') . DIRECTORY_SEPARATOR . $logoFileModel->name);
         //logoFile is either not published or we have dangling url for asset
         if ($logoFileSrc === false || file_exists($logoFileSrc) === false) {
             //Logo file is not published in assets
             //Check if it exists in runtime/uploads
             if (file_exists(Yii::getPathOfAlias('application.runtime.uploads') . DIRECTORY_SEPARATOR . $logoFileModel->name) === false) {
                 $logoFilePath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $logoFileModel->name;
                 file_put_contents($logoFilePath, $logoFileModel->fileContent->content, LOCK_EX);
                 ZurmoUserInterfaceConfigurationFormAdapter::publishLogo($logoFileModel->name, $logoFilePath);
             } else {
                 //Logo File exist in runtime/uploads but not published
                 Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.runtime.uploads') . DIRECTORY_SEPARATOR . $logoFileModel->name);
             }
         }
     }
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:21,代码来源:BeginRequestBehavior.php

示例8: testMakeByExistingFileModelId

 public function testMakeByExistingFileModelId()
 {
     $oldFileContentsCount = FileContent::getCount();
     $file1 = ZurmoTestHelper::createFileModel('testNote.txt');
     $file2 = FileModelUtil::makeByExistingFileModelId($file1->id, true);
     $file1Content = $file1->fileContent;
     $file2Id = $file2->id;
     $this->assertTrue($file2 !== false);
     $this->assertEquals($file1->name, $file2->name);
     $this->assertEquals($file1->type, $file2->type);
     $this->assertEquals($file1->size, $file2->size);
     $this->assertEquals($file1Content->content, $file2->fileContent->content);
     // because fileContent was not replicated but referenced in file2.
     $this->assertEquals($file1Content->id, $file2->fileContent->id);
     $this->assertEquals($oldFileContentsCount + 1, FileContent::getCount());
     $file1->delete();
     FileModel::forgetAll();
     $file2 = FileModel::getById($file2Id);
     $this->assertEquals($file1Content->content, $file2->fileContent->content);
     // deleting file1 should still preserve its content as its being used by file2.
     $this->assertEquals($oldFileContentsCount + 1, FileContent::getCount());
     $file2->delete();
     // deleting fil2 should get rid of the fileContent too.
     $this->assertEquals($oldFileContentsCount, FileContent::getCount());
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:25,代码来源:FileModelUtilTest.php

示例9: testSavingFileContentWhenNotModified

 public function testSavingFileContentWhenNotModified()
 {
     $fileContent = new FileContent();
     $fileContent->content = 'testContent';
     $file = new FileModel();
     $file->fileContent = $fileContent;
     $file->name = 'aTestName';
     $file->type = 'aTestType';
     $file->size = 500;
     $saved = $file->save();
     $this->assertTrue($saved);
     $fileId = $file->id;
     $file->forget();
     //Now retrieve the file and make sure the content matches.
     $fileModel = FileModel::getById($fileId);
     $this->assertTrue($fileModel->save());
     $file->forget();
     $fileModel = FileModel::getById($fileId);
     $this->assertEquals('testContent', $file->fileContent->content);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:20,代码来源:ModelWithAttachmentTest.php

示例10: actionLogo

 public function actionLogo()
 {
     $id = (int) ZurmoConfigurationUtil::getByModuleName('ZurmoModule', 'logoThumbFileModelId');
     $logo = FileModel::getById($id);
     header("Content-Type:   {$logo->type}");
     header("Content-Length: {$logo->size}");
     header("Content-Name:   {$logo->name}");
     echo $logo->fileContent->content;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:9,代码来源:DefaultController.php

示例11: resolveAttachmentsByPostSourceData

 protected function resolveAttachmentsByPostSourceData(array $sourceData)
 {
     $attachments = array();
     if (isset($sourceData['attachmentIds']) && is_array($sourceData['attachmentIds'])) {
         foreach ($sourceData['attachmentIds'] as $attachmentId) {
             $attachments[] = FileModel::getById(intval($attachmentId));
         }
     }
     return $attachments;
 }
开发者ID:KulturedKitsch,项目名称:kulturedkitsch.info,代码行数:10,代码来源:SendTestEmailUtil.php

示例12: makeByExistingFileModelId

 /**
  *
  * @param integer $fileModelId
  * @param bool $sharedContent
  * @return $fileModel or false on failure
  */
 public static function makeByExistingFileModelId($fileModelId, $sharedContent = true)
 {
     assert('is_int($fileModelId) || (is_string($fileModelId) && !empty($fileModelId))');
     $existingFileModel = FileModel::getById($fileModelId);
     return static::makeByFileModel($existingFileModel, $sharedContent);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:12,代码来源:FileModelUtil.php

示例13: makeByExistingFileModelId

 /**
  *
  * @param integer $fileModelId
  * @return $fileModel or false on failure
  */
 public static function makeByExistingFileModelId($fileModelId)
 {
     assert('is_int($fileModelId) || (is_string($fileModelId) && !empty($fileModelId))');
     $existingFileModel = FileModel::getById($fileModelId);
     $file = new FileModel();
     // TODO: @Shoaibi/@Jason: High: Following should also clone FileContent as its HAS_ONE.
     ZurmoCopyModelUtil::copy($existingFileModel, $file);
     $fileContent = new FileContent();
     $fileContent->content = $existingFileModel->fileContent->content;
     $file->fileContent = $fileContent;
     if (!$file->save()) {
         return false;
     }
     return $file;
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:20,代码来源:FileModelUtil.php

示例14: actionLogo

 public function actionLogo($id)
 {
     $logo = FileModel::getById($id);
     header("Content-Type:   {$logo->type}");
     header("Content-Length: {$logo->size}");
     header("Content-Name:   {$logo->name}");
     echo $logo->fileContent->content;
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:8,代码来源:DefaultController.php


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