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


PHP MidasLoader::loadModel方法代码示例

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


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

示例1: itemrevisionGet

 /**
  * Fetch the information about an ItemRevision.
  *
  * @path /itemrevision/{id}
  * @http GET
  * @param id The id of the ItemRevision
  * @return ItemRevision object
  *
  * @param array $args parameters
  * @throws Exception
  */
 public function itemrevisionGet($args)
 {
     /** @var ApihelperComponent $apihelperComponent */
     $apihelperComponent = MidasLoader::loadComponent('Apihelper');
     $apihelperComponent->validateParams($args, array('id'));
     $apihelperComponent->requirePolicyScopes(array(MIDAS_API_PERMISSION_SCOPE_READ_DATA));
     $userDao = $apihelperComponent->getUser($args);
     $itemrevision_id = $args['id'];
     /** @var ItemRevisionModel $itemRevisionModel */
     $itemRevisionModel = MidasLoader::loadModel('ItemRevision');
     $itemRevision = $itemRevisionModel->load($itemrevision_id);
     /** @var ItemModel $itemModel */
     $itemModel = MidasLoader::loadModel('Item');
     $item = $itemModel->load($itemRevision->getItemId());
     if ($item === false || !$itemModel->policyCheck($item, $userDao, MIDAS_POLICY_READ)) {
         throw new Exception("This item doesn't exist or you don't have the permissions.", MIDAS_INVALID_POLICY);
     }
     $in = $itemRevision->toArray();
     $out = array();
     $out['id'] = $in['itemrevision_id'];
     $out['item_id'] = $in['item_id'];
     $out['date_created'] = $in['date'];
     $out['date_updated'] = $in['date'];
     // fix this
     $out['changes'] = $in['changes'];
     $out['user_id'] = $in['user_id'];
     $out['license_id'] = $in['license_id'];
     $out['uuid'] = $in['uuid'];
     $out['bitstreams'] = array_map(array($this, 'getBitstreamId'), $itemRevision->getBitstreams());
     return $out;
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:42,代码来源:ApiitemrevisionComponent.php

示例2: postUpgrade

 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $piwikUrl = isset($config->piwik->url) ? $config->piwik->url : STATISTICS_PIWIK_URL_DEFAULT_VALUE;
         $settingModel->setConfig(STATISTICS_PIWIK_URL_KEY, $piwikUrl, $this->moduleName);
         $piwikId = isset($config->piwik->id) ? $config->piwik->id : STATISTICS_PIWIK_SITE_ID_DEFAULT_VALUE;
         $settingModel->setConfig(STATISTICS_PIWIK_SITE_ID_KEY, $piwikId, $this->moduleName);
         $piwikApiKey = isset($config->piwik->apikey) ? $config->piwik->apikey : STATISTICS_PIWIK_API_KEY_DEFAULT_VALUE;
         $settingModel->setConfig(STATISTICS_PIWIK_API_KEY_KEY, $piwikApiKey, $this->moduleName);
         $ipInfoDbApiKey = isset($config->ipinfodb->apikey) ? $config->ipinfodb->apikey : STATISTICS_IP_INFO_DB_API_KEY_DEFAULT_VALUE;
         $settingModel->setConfig(STATISTICS_IP_INFO_DB_API_KEY_KEY, $ipInfoDbApiKey, $this->moduleName);
         $settingModel->setConfig(STATISTICS_SEND_DAILY_REPORTS_KEY, $config->get('report', STATISTICS_SEND_DAILY_REPORTS_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->piwik->url);
         unset($config->global->piwik->id);
         unset($config->global->piwik->pikey);
         unset($config->global->ipinfodb->apikey);
         unset($config->global->report);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(STATISTICS_PIWIK_URL_KEY, STATISTICS_PIWIK_URL_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(STATISTICS_PIWIK_SITE_ID_KEY, STATISTICS_PIWIK_SITE_ID_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(STATISTICS_PIWIK_API_KEY_KEY, STATISTICS_PIWIK_API_KEY_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(STATISTICS_IP_INFO_DB_API_KEY_KEY, STATISTICS_IP_INFO_DB_API_KEY_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(STATISTICS_SEND_DAILY_REPORTS_KEY, STATISTICS_SEND_DAILY_REPORTS_DEFAULT_VALUE, $this->moduleName);
     }
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:35,代码来源:1.1.0.php

示例3: otpLogin

 /**
  * Submit your OTP after calling core login, and you will receive your api token.
  *
  * @param otp The one-time password
  * @param mfaTokenId The id of the temporary MFA token
  * @return The api token
  * @throws Exception
  */
 public function otpLogin($params)
 {
     $this->_checkKeys(array('otp', 'mfaTokenId'), $params);
     /** @var Mfa_ApitokenModel $tempTokenModel */
     $tempTokenModel = MidasLoader::loadModel('Apitoken', 'mfa');
     /** @var Mfa_OtpdeviceModel $otpDeviceModel */
     $otpDeviceModel = MidasLoader::loadModel('Otpdevice', 'mfa');
     /** @var TokenModel $apiTokenModel */
     $apiTokenModel = MidasLoader::loadModel('Token');
     $tempToken = $tempTokenModel->load($params['mfaTokenId']);
     if (!$tempToken) {
         throw new Exception('Invalid MFA token id', -1);
     }
     $apiToken = $apiTokenModel->load($tempToken->getTokenId());
     if (!$apiToken) {
         $tempTokenModel->delete($tempToken);
         throw new Exception('Corresponding api token no longer exists', -1);
     }
     $user = $tempToken->getUser();
     $otpDevice = $otpDeviceModel->getByUser($user);
     if (!$otpDevice) {
         $tempTokenModel->delete($tempToken);
         throw new Exception('User does not have an OTP device', -1);
     }
     $tempTokenModel->delete($tempToken);
     /** @var Mfa_OtpComponent $otpComponent */
     $otpComponent = MidasLoader::loadComponent('Otp', 'mfa');
     if (!$otpComponent->authenticate($otpDevice, $params['otp'])) {
         throw new Exception('Incorrect OTP', -1);
     }
     $token = $apiToken->getToken();
     return array('token' => $token);
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:41,代码来源:ApiComponent.php

示例4: postUpgrade

 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_PROVIDER_KEY, MIDAS_THUMBNAILCREATOR_PROVIDER_PHMAGICK, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_FORMAT_KEY, MIDAS_THUMBNAILCREATOR_FORMAT_JPG, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_IMAGE_MAGICK_KEY, $config->get('imagemagick', MIDAS_THUMBNAILCREATOR_IMAGE_MAGICK_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_USE_THUMBNAILER_KEY, $config->get('useThumbnailer', MIDAS_THUMBNAILCREATOR_USE_THUMBNAILER_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_THUMBNAILER_KEY, $config->get('thumbnailer', MIDAS_THUMBNAILCREATOR_THUMBNAILER_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->imageFormats);
         unset($config->global->imagemagick);
         unset($config->global->thumbnailer);
         unset($config->global->useThumbnailer);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_PROVIDER_KEY, MIDAS_THUMBNAILCREATOR_PROVIDER_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_FORMAT_KEY, MIDAS_THUMBNAILCREATOR_FORMAT_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_IMAGE_MAGICK_KEY, MIDAS_THUMBNAILCREATOR_IMAGE_MAGICK_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_USE_THUMBNAILER_KEY, MIDAS_THUMBNAILCREATOR_USE_THUMBNAILER_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_THUMBNAILER_KEY, MIDAS_THUMBNAILCREATOR_THUMBNAILER_DEFAULT_VALUE, $this->moduleName);
     }
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:30,代码来源:1.1.0.php

示例5: delete

 /** Delete a group */
 public function delete($group)
 {
     if (!$group instanceof GroupDao) {
         throw new Zend_Exception('Should be a group.');
     }
     $users = $group->getUsers();
     foreach ($users as $user) {
         $this->removeUser($group, $user);
     }
     /** @var FeedpolicygroupModel $feedpolicygroupModel */
     $feedpolicygroupModel = MidasLoader::loadModel('Feedpolicygroup');
     $feedpolicygroupModel->deleteGroupPolicies($group);
     /** @var ItempolicygroupModel $itempolicygroupModel */
     $itempolicygroupModel = MidasLoader::loadModel('Itempolicygroup');
     $itempolicygroupModel->deleteGroupPolicies($group);
     /** @var FolderpolicygroupModel $folderpolicygroupModel */
     $folderpolicygroupModel = MidasLoader::loadModel('Folderpolicygroup');
     $folderpolicygroupModel->deleteGroupPolicies($group);
     /** @var NewUserInvitationModel $newUserInvitationModel */
     $newUserInvitationModel = MidasLoader::loadModel('NewUserInvitation');
     $newUserInvitationModel->deleteByGroup($group);
     parent::delete($group);
     unset($group->group_id);
     $group->saved = false;
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:26,代码来源:GroupModelBase.php

示例6: scheduleOrCancelSendReportJob

 /**
  * Schedule or cancel the send report job.
  *
  * @param bool $schedule schedule the job if true, cancel the job if false
  * @param null|UserDao $userDao user scheduling the job
  *
  * @throws Zend_Exception
  */
 public function scheduleOrCancelSendReportJob($schedule, $userDao = null)
 {
     /** @var Scheduler_JobModel $jobModel */
     $jobModel = MidasLoader::loadModel('Job', 'scheduler');
     $jobDaos = $jobModel->getJobsByTask('TASK_STATISTICS_SEND_REPORT');
     $reportJobDao = false;
     foreach ($jobDaos as $jobDao) {
         if ($jobDao->getTask() === 'TASK_STATISTICS_SEND_REPORT') {
             $reportJobDao = $jobDao;
             break;
         }
     }
     if ($schedule) {
         if ($reportJobDao === false) {
             /** @var Scheduler_JobDao $reportJobDao */
             $reportJobDao = MidasLoader::newDao('JobDao', 'scheduler');
             $reportJobDao->setTask('TASK_STATISTICS_SEND_REPORT');
             $reportJobDao->setPriority(1);
             $reportJobDao->setRunOnlyOnce(0);
             $reportJobDao->setFireTime(date('Y-m-d', strtotime('+1 day' . date('Y-m-d H:i:s'))) . ' 01:00:00');
             $reportJobDao->setTimeInterval(86400);
             $reportJobDao->setStatus(SCHEDULER_JOB_STATUS_TORUN);
             $reportJobDao->setCreatorId($this->userSession->Dao->getKey());
             $reportJobDao->setParams(JsonComponent::encode(array()));
             if (!is_null($userDao)) {
                 $reportJobDao->setCreatorId($userDao->getKey());
             }
             $jobModel->save($reportJobDao);
         }
     } else {
         if ($reportJobDao !== false) {
             $jobModel->delete($reportJobDao);
         }
     }
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:43,代码来源:AdminComponent.php

示例7: schedulePerformCleanupJob

 /**
  * Schedule the perform cleanup job.
  *
  * @param int $days days to keep partial files
  * @param string $tempDirectory temporary directory
  * @param null|UserDao $userDao user scheduling the job
  */
 public function schedulePerformCleanupJob($days, $tempDirectory, $userDao = null)
 {
     /**  @var Scheduler_JobModel $jobModel */
     $jobModel = MidasLoader::loadModel('Job', 'scheduler');
     $jobDaos = $jobModel->getJobsByTask('TASK_CLEANUP_PERFORM_CLEANUP');
     $cleanupJobDao = false;
     foreach ($jobDaos as $jobDao) {
         if ($jobDao->getTask() === 'TASK_CLEANUP_PERFORM_CLEANUP') {
             $cleanupJobDao = $jobDao;
             break;
         }
     }
     if ($cleanupJobDao === false) {
         /** @var Scheduler_JobDao $cleanupJobDao */
         $cleanupJobDao = MidasLoader::newDao('JobDao', 'scheduler');
         $cleanupJobDao->setTask('TASK_CLEANUP_PERFORM_CLEANUP');
         $cleanupJobDao->setPriority(1);
         $cleanupJobDao->setRunOnlyOnce(0);
         $cleanupJobDao->setFireTime(date('Y-m-d', strtotime('+1 day' . date('Y-m-d H:i:s'))) . ' 01:00:00');
         $cleanupJobDao->setTimeInterval(86400);
         $cleanupJobDao->setStatus(SCHEDULER_JOB_STATUS_TORUN);
         if (!is_null($userDao)) {
             $cleanupJobDao->setCreatorId($userDao->getKey());
         }
     }
     $cleanupJobDao->setParams(JsonComponent::encode(array('days' => $days, 'tempDirectory' => $tempDirectory)));
     $jobModel->save($cleanupJobDao);
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:35,代码来源:AdminComponent.php

示例8: testIndexAction

 /** test index action */
 public function testIndexAction()
 {
     /** @var GroupModel $groupModel */
     $groupModel = MidasLoader::loadModel('Group');
     /** @var ItempolicygroupModel $itempolicygroupModel */
     $itempolicygroupModel = MidasLoader::loadModel('Itempolicygroup');
     /** @var UserModel $userModel */
     $userModel = MidasLoader::loadModel('User');
     /** @var FolderModel $folderModel */
     $folderModel = MidasLoader::loadModel('Folder');
     /** @var UploadComponent $uploadComponent */
     $uploadComponent = MidasLoader::loadComponent('Upload');
     $usersFile = $this->loadData('User', 'default');
     $userDao = $userModel->load($usersFile[0]->getKey());
     Zend_Registry::set('notifier', new MIDAS_Notifier(false, null));
     $privateFolder = $folderModel->load(1002);
     $item = $uploadComponent->createUploadedItem($userDao, 'test.png', BASE_PATH . '/tests/testfiles/search.png', $privateFolder, null, '', true);
     $anonymousGroup = $groupModel->load(MIDAS_GROUP_ANONYMOUS_KEY);
     $itempolicygroupModel->createPolicy($anonymousGroup, $item, MIDAS_POLICY_READ);
     $this->params['itemId'] = $item->getKey();
     $this->dispatchUrl('/visualize/index/index');
     $this->assertController('index');
     $this->dispatchUrl('/visualize/image/index');
     $this->assertController('image');
     $this->dispatchUrl('/visualize/media/index');
     $this->assertController('media');
     $this->dispatchUrl('/visualize/pdf/index');
     $this->assertController('pdf');
     $this->dispatchUrl('/visualize/txt/index');
     $this->assertController('txt');
     $this->dispatchUrl('/visualize/webgl/index');
     $this->assertController('webgl');
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:34,代码来源:IndexControllerTest.php

示例9: postInstall

 /** Post database install. */
 public function postInstall()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $settingModel->setConfig(GOOGLE_AUTH_CLIENT_ID_KEY, GOOGLE_AUTH_CLIENT_ID_DEFAULT_VALUE, $this->moduleName);
     $settingModel->setConfig(GOOGLE_AUTH_CLIENT_SECRET_KEY, GOOGLE_AUTH_CLIENT_SECRET_DEFAULT_VALUE, $this->moduleName);
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:8,代码来源:InstallScript.php

示例10: searchAll

 /**
  * Search all the results.
  *
  * @param UserDao $userDao
  * @param string $search
  * @param string $order
  * @return array
  */
 public function searchAll($userDao, $search, $order)
 {
     /** @var ItemModel $itemModel */
     $itemModel = MidasLoader::loadModel('Item');
     /** @var FolderModel $folderModel */
     $folderModel = MidasLoader::loadModel('Folder');
     /** @var CommunityModel $communityModel */
     $communityModel = MidasLoader::loadModel('Community');
     /** @var UserModel $userModel */
     $userModel = MidasLoader::loadModel('User');
     $ItemsDao = $itemModel->getItemsFromSearch($search, $userDao, 200, false, $order);
     // Search for the folders
     $FoldersDao = $folderModel->getFoldersFromSearch($search, $userDao, 15, false, $order);
     // Search for the communities
     $CommunitiesDao = $communityModel->getCommunitiesFromSearch($search, $userDao, 15, false, $order);
     // Search for the users
     $UsersDao = $userModel->getUsersFromSearch($search, $userDao, 15, false, $order);
     $return = array();
     $return['nitems'] = count($ItemsDao);
     $return['nfolders'] = count($FoldersDao);
     $return['ncommunities'] = count($CommunitiesDao);
     $return['nusers'] = count($UsersDao);
     $return['results'] = $this->_formatResults($order, $ItemsDao, $FoldersDao, $CommunitiesDao, $UsersDao);
     return $return;
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:33,代码来源:SearchComponent.php

示例11: addDownload

 /** add a download record for the given item */
 public function addDownload($item, $user)
 {
     if (!$item instanceof ItemDao) {
         throw new Zend_Exception('Error: item parameter is not an item dao');
     }
     $userAgent = array_key_exists('HTTP_USER_AGENT', $_SERVER) ? $_SERVER['HTTP_USER_AGENT'] : '';
     $ip = $_SERVER['REMOTE_ADDR'];
     if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
         $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
     }
     /** @var Statistics_IpLocationModel $ipLocationModel */
     $ipLocationModel = MidasLoader::loadModel('IpLocation', 'statistics');
     $ipLocation = $ipLocationModel->getByIp($ip);
     if ($ipLocation == false) {
         /** @var Statistics_IpLocationDao $ipLocation */
         $ipLocation = MidasLoader::newDao('IpLocationDao', 'statistics');
         $ipLocation->setIp($ip);
         // we will perform the geolocation later, since it can be slow
         $ipLocation->setLatitude('');
         $ipLocation->setLongitude('');
         $ipLocationModel->save($ipLocation);
     }
     /** @var Statistics_DownloadDao $download */
     $download = MidasLoader::newDao('DownloadDao', 'statistics');
     $download->setItemId($item->getKey());
     $download->setIpLocationId($ipLocation->getKey());
     $download->setDate(date('Y-m-d H:i:s'));
     $download->setUserAgent($userAgent);
     if ($user instanceof UserDao) {
         $download->setUserId($user->getKey());
     }
     $this->save($download);
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:34,代码来源:DownloadBase.php

示例12: postUpgrade

 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var RandomComponent $randomComponent */
     $randomComponent = MidasLoader::loadComponent('Random');
     $securityKey = $randomComponent->generateString(32);
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(MIDAS_REMOTEPROCESSING_SECURITY_KEY_KEY, $config->get('securitykey', $securityKey), $this->moduleName);
         $showButton = $config->get('showbutton');
         if ($showButton === 'true') {
             $showButton = 1;
         } elseif ($showButton === 'false') {
             $showButton = 0;
         } else {
             $showButton = MIDAS_REMOTEPROCESSING_SHOW_BUTTON_DEFAULT_VALUE;
         }
         $settingModel->setConfig(MIDAS_REMOTEPROCESSING_SHOW_BUTTON_KEY, $showButton, $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->securitykey->securitykey);
         unset($config->showbutton->showbutton);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(MIDAS_REMOTEPROCESSING_SECURITY_KEY_KEY, $securityKey, $this->moduleName);
         $settingModel->setConfig(MIDAS_REMOTEPROCESSING_SHOW_BUTTON_KEY, MIDAS_REMOTEPROCESSING_SHOW_BUTTON_DEFAULT_VALUE, $this->moduleName);
     }
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:33,代码来源:1.1.0.php

示例13: testCommunityReadme

 /** test readme on community */
 public function testCommunityReadme()
 {
     $this->enabledModules = array('readmes');
     $this->resetAll();
     $this->setupDatabase(array('default'));
     Zend_Registry::set('modulesEnable', array());
     Zend_Registry::set('notifier', new MIDAS_Notifier(false, null));
     $this->Community = MidasLoader::loadModel('Community');
     $this->Folder = MidasLoader::loadModel('Folder');
     $usersFile = $this->loadData('User', 'default');
     $adminUser = $this->User->load($usersFile[2]->getKey());
     $oldPath = BASE_PATH . '/modules/readmes/tests/data/readme.md';
     $dir = $this->getTempDirectory() . '/' . $adminUser->getUserId() . '/1002';
     // private folder
     $newPath = $dir . '/readme.md';
     if (!file_exists($dir)) {
         mkdir($dir, 0700, true);
     }
     if (file_exists($newPath)) {
         unlink($newPath);
     }
     copy($oldPath, $newPath);
     $commFile = $this->loadData('Community', 'default');
     $comm = $this->Community->load($commFile[0]->getKey());
     $rootFolder = $comm->getFolder();
     $publicFolder = $this->Folder->createFolder('Public', '', $rootFolder);
     /** @var UploadComponent $uploadComponent */
     $uploadComponent = MidasLoader::loadComponent('Upload');
     $uploadComponent->createUploadedItem($adminUser, 'readme.md', $newPath, $publicFolder);
     $resp = $this->_callRestApi('GET', '/readmes/community/' . $comm->getKey());
     $this->_assertStatusOk($resp);
     $this->assertEquals('<p>This is a readme</p>', $resp['body']->data->text);
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:34,代码来源:ApiComponentControllerTest.php

示例14: testGetSetValue

 /** testGetSetValue */
 public function testGetSetValue()
 {
     Zend_Registry::set('modulesEnable', $this->enabledModules);
     Zend_Registry::set('notifier', new MIDAS_Notifier(false, null));
     /** @var Validation_ScalarResultModel $scalarResultModel */
     $scalarResultModel = MidasLoader::loadModel('ScalarResult', 'validation');
     $daos = $scalarResultModel->getAll();
     $sr = $daos[0];
     $folder = new FolderDao();
     $folder->setName('result');
     $folder->setDescription('result');
     $folder->setParentId(-1);
     $this->Folder->save($folder);
     $trainingItem = new ItemDao();
     $trainingItem->setName('img00.mha');
     $trainingItem->setDescription('training img 00');
     $trainingItem->setType(0);
     $this->Item->save($trainingItem);
     $scalarResultModel->setFolder($sr, $folder);
     $scalarResultModel->setItem($sr, $trainingItem);
     $sr->setValue(90.009);
     $scalarResultModel->save($sr);
     $daos = $scalarResultModel->getAll();
     $sr = $daos[0];
     $this->assertEquals(90.009, $sr->getValue());
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:27,代码来源:ScalarResultModelTest.php

示例15: postInstall

 /** Post database install. */
 public function postInstall()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $settingModel->setConfig(MIDAS_SIZEQUOTA_DEFAULT_USER_QUOTA_KEY, MIDAS_SIZEQUOTA_DEFAULT_USER_QUOTA_DEFAULT_VALUE, $this->moduleName);
     $settingModel->setConfig(MIDAS_SIZEQUOTA_DEFAULT_COMMUNITY_QUOTA_KEY, MIDAS_SIZEQUOTA_DEFAULT_COMMUNITY_QUOTA_DEFAULT_VALUE, $this->moduleName);
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:8,代码来源:InstallScript.php


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