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


PHP MidasLoader类代码示例

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


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

示例1: createThumbnail

 /**
  * Create a thumbnail bitstream in the provided assetstore using the
  * passed tempThumbnailFile, which will be moved to the assetstore.
  *
  * @return The bitstream dao that was created for the thumbnail
  */
 public function createThumbnail($assetstore, $tempThumbnailFile)
 {
     /** @var BitstreamDao $bitstreamDao */
     $bitstreamDao = MidasLoader::newDao('BitstreamDao');
     $md5 = md5_file($tempThumbnailFile);
     $bitstreamDao->setName('thumbnail.jpeg');
     $bitstreamDao->setItemrevisionId(-1);
     //-1 indicates this does not belong to any revision
     $bitstreamDao->setMimetype('image/jpeg');
     $bitstreamDao->setSizebytes(filesize($tempThumbnailFile));
     $bitstreamDao->setDate(date('Y-m-d H:i:s'));
     $bitstreamDao->setChecksum($md5);
     $existing = $this->getByChecksum($md5);
     if ($existing) {
         unlink($tempThumbnailFile);
         $bitstreamDao->setPath($existing->getPath());
         $bitstreamDao->setAssetstoreId($existing->getAssetstoreId());
     } else {
         $path = substr($md5, 0, 2) . '/' . substr($md5, 2, 2) . '/' . $md5;
         $fullpath = $assetstore->getPath() . '/' . $path;
         $currentdir = $assetstore->getPath() . '/' . substr($md5, 0, 2);
         $this->_createAssetstoreDirectory($currentdir);
         $currentdir .= '/' . substr($md5, 2, 2);
         $this->_createAssetstoreDirectory($currentdir);
         rename($tempThumbnailFile, $fullpath);
         $bitstreamDao->setAssetstoreId($assetstore->getKey());
         $bitstreamDao->setPath($path);
     }
     $this->save($bitstreamDao);
     return $bitstreamDao;
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:37,代码来源:BitstreamModelBase.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');
         $settingModel->setConfig(DICOMEXTRACTOR_DCM2XML_COMMAND_KEY, $config->get('dcm2xml', DICOMEXTRACTOR_DCM2XML_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMJ2PNM_COMMAND_KEY, $config->get('dcmj2pnm', DICOMEXTRACTOR_DCMJ2PNM_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMFTEST_COMMAND_KEY, $config->get('dcmftest', DICOMEXTRACTOR_DCMFTEST_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMDICTPATH_KEY, $config->get('dcmdictpath', DICOMEXTRACTOR_DCMDICTPATH_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->dcm2xml);
         unset($config->global->dcmj2pnm);
         unset($config->global->dcmftest);
         unset($config->global->dcmdictpath);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(DICOMEXTRACTOR_DCM2XML_COMMAND_KEY, DICOMEXTRACTOR_DCM2XML_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMJ2PNM_COMMAND_KEY, DICOMEXTRACTOR_DCMJ2PNM_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMFTEST_COMMAND_KEY, DICOMEXTRACTOR_DCMFTEST_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMDICTPATH_KEY, DICOMEXTRACTOR_DCMDICTPATH_DEFAULT_VALUE, $this->moduleName);
     }
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:28,代码来源:1.1.0.php

示例3: 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

示例4: generateToken

 /**
  * Generate an upload token that will act as the authentication token for the upload.
  * This token is the filename of a unique file which will be placed under the
  * directory specified by the dirname parameter, which should be used to ensure that
  * the user can only write into a certain logical space.
  *
  * @param array $args
  * @param string $dirname
  * @return array
  * @throws Exception
  */
 public function generateToken($args, $dirname = '')
 {
     if (!array_key_exists('filename', $args)) {
         throw new Exception('Parameter filename is not defined', MIDAS_HTTPUPLOAD_FILENAME_PARAM_UNDEFINED);
     }
     $tempDirectory = UtilityComponent::getTempDirectory();
     $dir = $dirname === '' ? '' : '/' . $dirname;
     $dir = $tempDirectory . $dir;
     if (!file_exists($dir)) {
         if (!mkdir($dir, 0777, true)) {
             throw new Exception('Failed to create temporary upload dir', MIDAS_HTTPUPLOAD_TMP_DIR_CREATION_FAILED);
         }
     }
     /** @var RandomComponent $randomComponent */
     $randomComponent = MidasLoader::loadComponent('Random');
     $uniqueIdentifier = $randomComponent->generateString(64);
     if ($dirname != '') {
         $uniqueIdentifier = $dirname . '/' . $uniqueIdentifier;
     }
     $path = $tempDirectory . '/' . $uniqueIdentifier;
     if (file_exists($path)) {
         throw new Exception('Failed to generate upload token', MIDAS_HTTPUPLOAD_UPLOAD_TOKEN_GENERATION_FAILED);
     }
     if (touch($path) === false) {
         mkdir($path, 0777, true);
         $uniqueIdentifier .= '/';
     }
     return array('token' => $uniqueIdentifier);
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:40,代码来源:HttpuploadComponent.php

示例5: createPolicy

 /** create a policy
  * @return FeedpolicyuserDao
  */
 public function createPolicy($user, $feed, $policy)
 {
     if (!$user instanceof UserDao) {
         throw new Zend_Exception('Should be a user.');
     }
     if (!$feed instanceof FeedDao) {
         throw new Zend_Exception('Should be a feed.');
     }
     if (!is_numeric($policy)) {
         throw new Zend_Exception('Should be a number.');
     }
     if (!$user->saved && !$feed->saved) {
         throw new Zend_Exception('Save the daos first.');
     }
     if ($this->getPolicy($user, $feed) !== false) {
         $this->delete($this->getPolicy($user, $feed));
     }
     /** @var FeedpolicyuserDao $policyUser */
     $policyUser = MidasLoader::newDao('FeedpolicyuserDao');
     $policyUser->setUserId($user->getUserId());
     $policyUser->setFeedId($feed->getFeedId());
     $policyUser->setPolicy($policy);
     $this->save($policyUser);
     return $policyUser;
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:28,代码来源:FeedpolicyuserModelBase.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: 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

示例8: 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

示例9: createPolicy

 /** @return ItempolicyuserDao */
 public function createPolicy($user, $item, $policy)
 {
     if (!$user instanceof UserDao) {
         throw new Zend_Exception('Should be a user.');
     }
     if (!$item instanceof ItemDao) {
         throw new Zend_Exception('Should be an item.');
     }
     if (!is_numeric($policy)) {
         throw new Zend_Exception('Should be a number.');
     }
     if (!$user->saved && !$item->saved) {
         throw new Zend_Exception('Save the daos first.');
     }
     $policyUser = $this->getPolicy($user, $item);
     if ($policyUser !== false) {
         $this->delete($policyUser);
     }
     /** @var ItempolicyuserDao $policyUser */
     $policyUser = MidasLoader::newDao('ItempolicyuserDao');
     $policyUser->setUserId($user->getUserId());
     $policyUser->setItemId($item->getItemId());
     $policyUser->setPolicy($policy);
     $this->save($policyUser);
     return $policyUser;
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:27,代码来源:ItempolicyuserModelBase.php

示例10: extract

 /**
  * Extract the dicom metadata from a revision.
  *
  * @param item the id of the item to be extracted
  * @return the id of the revision
  */
 public function extract($args)
 {
     /** @var ApihelperComponent $ApihelperComponent */
     $ApihelperComponent = MidasLoader::loadComponent('Apihelper');
     $ApihelperComponent->renameParamKey($args, 'item', 'id');
     return $this->_callModuleApiMethod($args, 'extract', 'item');
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:13,代码来源:ApiComponent.php

示例11: testDailyTotals

 /**
  * Test that we receive the correct daily totals from our model.
  */
 public function testDailyTotals()
 {
     /** @var Statistics_DownloadModel $downloadModel */
     $downloadModel = MidasLoader::loadModel('Download', 'statistics');
     // Add 50 downloads 3 days ago
     for ($i = 0; $i < 50; ++$i) {
         /** @var Statistics_DownloadDao $dao */
         $dao = MidasLoader::newDao('DownloadDao', 'statistics');
         $dao->setItemId(7);
         $dao->setIpLocationId(1);
         $dao->setDate(date('Y-m-d 01:' . str_pad($i, 2, '0', STR_PAD_LEFT) . ':00', strtotime('-3 day')));
         $downloadModel->save($dao);
     }
     // Add 20 downloads 2 days ago
     for ($i = 0; $i < 20; ++$i) {
         /** @var Statistics_DownloadDao $dao */
         $dao = MidasLoader::newDao('DownloadDao', 'statistics');
         $dao->setItemId(7);
         $dao->setIpLocationId(1);
         $dao->setDate(date('Y-m-d 01:' . str_pad($i, 2, '0', STR_PAD_LEFT) . ':00', strtotime('-2 day')));
         $downloadModel->save($dao);
     }
     $arrayDownload = $downloadModel->getDailyCounts(array(7), date('Y-m-d H:i:s', strtotime('-20 day' . date('Y-m-d G:i:s'))), date('Y-m-d H:i:s'));
     $this->assertEquals(count($arrayDownload), 2);
     $this->assertEquals($arrayDownload[date('Y-m-d', strtotime('-3 day'))], 50);
     $this->assertEquals($arrayDownload[date('Y-m-d', strtotime('-2 day'))], 20);
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:30,代码来源:DownloadModelTest.php

示例12: acquireLock

 /**
  * Call this function to acquire the download lock.
  * This will return false if an active download already exists for
  * this ip address, otherwise it will return the active download
  * lock that was created.
  */
 public function acquireLock()
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
         $ip .= '_' . $_SERVER['HTTP_X_FORWARDED_FOR'];
     }
     $oldLock = $this->getByIp($ip);
     if ($oldLock !== false) {
         // If an old lock exists but has not been updated in more than 5 minutes, we
         // should release the old lock and create a new one.
         $lastUpdate = strtotime($oldLock->getLastUpdate());
         if (time() > $lastUpdate + 300) {
             $this->delete($oldLock);
         } else {
             return false;
         }
     }
     /** @var ActivedownloadDao $activeDownload */
     $activeDownload = MidasLoader::newDao('ActivedownloadDao');
     $activeDownload->setDateCreation(date('Y-m-d H:i:s'));
     $activeDownload->setLastUpdate(date('Y-m-d H:i:s'));
     $activeDownload->setIp($ip);
     $this->save($activeDownload);
     return $activeDownload;
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:31,代码来源:ActivedownloadModelBase.php

示例13: testGetAll

 /** testGetAll */
 public function testGetAll()
 {
     /** @var Packages_PackageModel $packageModel */
     $packageModel = MidasLoader::loadModel('Package', 'packages');
     $daos = $packageModel->getAll();
     $this->assertEquals(1, count($daos));
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:8,代码来源:PackageModelTest.php

示例14: createPolicy

 /** create a policy
  * @return FeedpolicygroupDao
  */
 public function createPolicy($group, $feed, $policy)
 {
     if (!$group instanceof GroupDao) {
         throw new Zend_Exception('Should be a group.');
     }
     if (!$feed instanceof FeedDao) {
         throw new Zend_Exception('Should be a feedDao.');
     }
     if (!is_numeric($policy)) {
         throw new Zend_Exception('Should be a number.');
     }
     if (!$group->saved && !$feed->saved) {
         throw new Zend_Exception('Save the daos first.');
     }
     if ($this->getPolicy($group, $feed) !== false) {
         $this->delete($this->getPolicy($group, $feed));
     }
     /** @var FeedpolicygroupDao $policyGroupDao */
     $policyGroupDao = MidasLoader::newDao('FeedpolicygroupDao');
     $policyGroupDao->setGroupId($group->getGroupId());
     $policyGroupDao->setFeedId($feed->getFeedId());
     $policyGroupDao->setPolicy($policy);
     $this->save($policyGroupDao);
     return $policyGroupDao;
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:28,代码来源:FeedpolicygroupModelBase.php

示例15: 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


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