本文整理汇总了PHP中MidasLoader::loadComponent方法的典型用法代码示例。如果您正苦于以下问题:PHP MidasLoader::loadComponent方法的具体用法?PHP MidasLoader::loadComponent怎么用?PHP MidasLoader::loadComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MidasLoader
的用法示例。
在下文中一共展示了MidasLoader::loadComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
示例2: getDefaultReceptionDir
/**
* Get default reception directory.
*/
public function getDefaultReceptionDir()
{
/** @var UtilityComponent $utilityComponent */
$utilityComponent = MidasLoader::loadComponent('Utility');
$defaultReceptionDirectory = $utilityComponent->getTempDirectory('dicomserver');
return $defaultReceptionDirectory;
}
示例3: 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');
}
示例4: 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);
}
}
示例5: 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);
}
示例6: 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;
}
示例7: createInvitation
/**
* Create the database record for inviting a user via email that is not registered yet.
*
* @param email The email of the user (should not exist in Midas already)
* @param group The group to invite the user to
* @param inviter The user issuing the invitation (typically the session user)
* @return the created NewUserInvitationDao
*/
public function createInvitation($email, $group, $inviter)
{
/** @var RandomComponent $randomComponent */
$randomComponent = MidasLoader::loadComponent('Random');
$email = strtolower($email);
/** @var NewUserInvitationDao $newUserInvitation */
$newUserInvitation = MidasLoader::newDao('NewUserInvitationDao');
$newUserInvitation->setEmail($email);
$newUserInvitation->setAuthKey($randomComponent->generateString(64, '0123456789abcdef'));
$newUserInvitation->setInviterId($inviter->getKey());
$newUserInvitation->setGroupId($group->getKey());
$newUserInvitation->setCommunityId($group->getCommunityId());
$newUserInvitation->setDateCreation(date('Y-m-d H:i:s'));
/** @var UserModel $userModel */
$userModel = MidasLoader::loadModel('User');
$existingUser = $userModel->getByEmail($email);
if ($existingUser) {
throw new Zend_Exception('User with that email already exists');
}
// If the user has already been sent an invitation to this community, delete existing record
$existingInvitation = $this->getByParams(array('email' => $email, 'community_id' => $group->getCommunityId()));
if ($existingInvitation) {
$this->delete($existingInvitation);
}
$this->save($newUserInvitation);
return $newUserInvitation;
}
示例8: 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);
}
示例9: fromFolder
/**
* Get the readme text from the specified folder.
*/
public function fromFolder($folder)
{
/** @var FolderModel $folderModel */
$folderModel = MidasLoader::loadModel('Folder');
/** @var ItemModel $itemModel */
$itemModel = MidasLoader::loadModel('Item');
$readmeItem = null;
$candidates = array('readme.md', 'readme.txt', 'readme');
foreach ($candidates as $candidate) {
$readmeItem = $folderModel->getItemByName($folder, $candidate, false);
if ($readmeItem != null) {
break;
}
}
if ($readmeItem == null) {
return array('text' => '');
}
$revisionDao = $itemModel->getLastRevision($readmeItem);
if ($revisionDao === false) {
return array('text' => '');
}
$bitstreams = $revisionDao->getBitstreams();
if (count($bitstreams) === 0) {
return array('text' => '');
}
$bitstream = $bitstreams[0];
$path = $bitstream->getAssetstore()->getPath() . '/' . $bitstream->getPath();
$contents = file_get_contents($path);
MidasLoader::loadComponent('Utility');
$parsedContents = UtilityComponent::markdown(htmlspecialchars($contents, ENT_COMPAT, 'UTF-8'));
return array('text' => $parsedContents);
}
示例10: postUpgrade
/** Post database upgrade. */
public function postUpgrade()
{
/** @var SettingModel $settingModel */
$settingModel = MidasLoader::loadModel('Setting');
$config = new Zend_Config_Ini(APPLICATION_CONFIG, 'global');
$settingModel->setConfig('address_verification', $config->get('verifyemail', 0), 'mail');
if ($config->get('smtpfromaddress')) {
$fromAddress = $config->get('smtpfromaddress');
} elseif (ini_get('sendmail_from')) {
$fromAddress = ini_get('sendmail_from');
} else {
$fromAddress = 'no-reply@example.org';
// RFC2606
}
$settingModel->setConfig('from_address', $fromAddress, 'mail');
if ($config->get('smtpserver')) {
$components = parse_url($config->get('smtpserver'));
if (isset($components['host'])) {
$settingModel->setConfig('smtp_host', $components['host'], 'mail');
}
if (isset($components['port'])) {
$settingModel->setConfig('smtp_port', $components['port'], 'mail');
if ($components['port'] === 587) {
$settingModel->setConfig('smtp_use_ssl', 1, 'mail');
}
}
if (isset($components['user'])) {
$settingModel->setConfig('smtp_username', $components['user'], 'mail');
}
if (isset($components['pass'])) {
$settingModel->setConfig('smtp_password', $components['pass'], 'mail');
}
}
if ($config->get('smtpuser')) {
$settingModel->setConfig('smtp_username', $config->get('smtpuser'), 'mail');
}
if ($config->get('smtppassword')) {
$settingModel->setConfig('smtp_password', $config->get('smtppassword'), 'mail');
}
if ($settingModel->getValueByName('smtp_host', 'mail')) {
$provider = 'smtp';
} else {
$provider = 'mail';
}
$settingModel->setConfig('provider', $provider, 'mail');
/** @var UtilityComponent $utilityComponent */
$utilityComponent = MidasLoader::loadComponent('Utility');
$utilityComponent->installModule('mail');
$config = new Zend_Config_Ini(APPLICATION_CONFIG, null, true);
unset($config->global->smtpfromaddress);
unset($config->global->smtpserver);
unset($config->global->smtpuser);
unset($config->global->smtppassword);
unset($config->global->verifyemail);
$writer = new Zend_Config_Writer_Ini();
$writer->setConfig($config);
$writer->setFilename(APPLICATION_CONFIG);
$writer->write();
}
示例11: _callModuleApiMethod
/**
* Call module API method.
*
* @param array $args
* @param string $coreApiMethod
* @param null|string $resource
* @param bool $hasReturn
* @return null|mixed
* @throws Zend_Exception
*/
private function _callModuleApiMethod($args, $coreApiMethod, $resource = null, $hasReturn = true)
{
$ApiComponent = MidasLoader::loadComponent('Api' . $resource, 'sizequota');
$rtn = $ApiComponent->{$coreApiMethod}($args);
if ($hasReturn) {
return $rtn;
}
return;
}
示例12: postInstall
/** Post database install. */
public function postInstall()
{
/** @var RandomComponent $randomComponent */
$randomComponent = MidasLoader::loadComponent('Random');
$securityKey = $randomComponent->generateString(32);
/** @var SettingModel $settingModel */
$settingModel = MidasLoader::loadModel('Setting');
$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);
}
示例13: get
/**
* Get the readme text for a folder.
*
* @path /readmes/folder/{id}
* @http GET
* @param id the id of the folder from which to get the readme
* @return the text of the readme
*/
public function get($args)
{
/** @var ApihelperComponent $apihelperComponent */
$apihelperComponent = MidasLoader::loadComponent('Apihelper');
/** @var Readmes_GetReadmeComponent $readmeComponent */
$readmeComponent = MidasLoader::loadComponent('GetReadme', 'readmes');
$apihelperComponent->validateParams($args, array('id'));
/** @var FolderModel $folderModel */
$folderModel = MidasLoader::loadModel('Folder');
$folderDao = $folderModel->load($args['id']);
$readme = $readmeComponent->fromFolder($folderDao);
return $readme;
}
示例14: getJson
/** Get json to pass to the view initially */
public function getJson($params)
{
$json = array('limit' => 10, 'offset' => 0);
if ($this->userSession->Dao != null) {
$json['user'] = $this->userSession->Dao;
}
/** @var Comments_CommentComponent $commentComponent */
$commentComponent = MidasLoader::loadComponent('Comment', $this->moduleName);
list($comments, $total) = $commentComponent->getComments($params['item'], $json['limit'], $json['offset']);
$json['comments'] = $comments;
$json['total'] = $total;
return $json;
}
示例15: testPerformAction
/** Test extraction of a zip file */
public function testPerformAction()
{
// Simulate uploading our zip file into the assetstore (cp instead of mv)
/** @var UploadComponent $uploadComponent */
$uploadComponent = MidasLoader::loadComponent('Upload');
$adminUser = $this->User->load(3);
$adminFolders = $adminUser->getFolder()->getFolders();
$parent = $adminFolders[0];
$path = BASE_PATH . '/modules/archive/tests/data/test.zip';
$item = $uploadComponent->createUploadedItem($adminUser, 'test.zip', $path, $parent, null, '', true);
// Should fail when we try without privileges
$url = '/archive/extract/perform?deleteArchive=true&itemId=' . $item->getKey();
$this->dispatchUrl($url, null, true);
// Now run with proper privileges
$this->resetAll();
$this->dispatchUrl($url, $adminUser);
// The original item should have been deleted
$item = $this->Item->load($item->getKey());
$this->assertFalse($item);
// It should be replaced by the expected hierarchy
/** @var SortdaoComponent $sortDaoComponent */
$sortDaoComponent = MidasLoader::loadComponent('Sortdao');
$sortDaoComponent->field = 'name';
$childItems = $parent->getItems();
$this->assertEquals(count($childItems), 2);
usort($childItems, array($sortDaoComponent, 'sortByName'));
$child0 = $childItems[0];
$this->assertEquals($child0->getName(), 'AppController.php');
$child1 = $childItems[1];
$this->assertEquals($child1->getName(), 'Notification.php');
$childFolders = $parent->getFolders();
$this->assertEquals(count($childFolders), 2);
usort($childFolders, array($sortDaoComponent, 'sortByName'));
$childPublic = $childFolders[0];
$this->assertEquals($childPublic->getName(), 'public');
$childTranslation = $childFolders[1];
$this->assertEquals($childTranslation->getName(), 'translation');
$translationChildFolders = $childTranslation->getFolders();
$this->assertEquals(count($translationChildFolders), 0);
$translationChildItems = $childTranslation->getItems();
$this->assertEquals(count($translationChildItems), 1);
$this->assertEquals($translationChildItems[0]->getName(), 'fr-main.csv');
$publicChildItems = $childPublic->getItems();
$this->assertEquals(count($publicChildItems), 0);
$publicChildFolders = $childPublic->getFolders();
$this->assertEquals(count($publicChildFolders), 2);
usort($publicChildFolders, array($sortDaoComponent, 'sortByName'));
$this->assertEquals($publicChildFolders[0]->getName(), 'css');
$this->assertEquals($publicChildFolders[1]->getName(), 'js');
// The rest is assumed to follow by induction :)
}