本文整理汇总了PHP中Gems_Loader类的典型用法代码示例。如果您正苦于以下问题:PHP Gems_Loader类的具体用法?PHP Gems_Loader怎么用?PHP Gems_Loader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Gems_Loader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->db = \Zend_Db::factory('pdo_sqlite', array('dbname' => ':memory:'));
\Zend_Registry::set('db', $this->db);
$settings = new \Zend_Config_Ini(GEMS_ROOT_DIR . '/configs/application.example.ini', APPLICATION_ENV);
$sa = $settings->toArray();
$this->loader = new \Gems_Loader(\Zend_Registry::getInstance(), $sa['loaderDirs']);
\Zend_Registry::set('loader', $this->loader);
$this->tracker = $this->loader->getTracker();
\Zend_Registry::set('tracker', $this->tracker);
}
示例2: execute
/**
* Should handle execution of the task, taking as much (optional) parameters as needed
*
* The parameters should be optional and failing to provide them should be handled by
* the task
*/
public function execute($lineNr = null, $roundData = null)
{
$batch = $this->getBatch();
$import = $batch->getVariable('import');
if (!(isset($import['trackId']) && $import['trackId'])) {
// Do nothing
return;
}
// Only save when export code is known and set
if (!isset($roundData['survey_export_code'], $import['surveyCodes'][$roundData['survey_export_code']])) {
// Do nothing, no survey export code or no known export code
return;
}
if (!$import['surveyCodes'][$roundData['survey_export_code']]) {
// Export code not set to skip import of round
return;
}
$fieldCodes = $import['fieldCodes'];
$roundOrders = isset($import['roundOrders']) ? $import['roundOrders'] : array();
$tracker = $this->loader->getTracker();
$trackEngine = $tracker->getTrackEngine($import['trackId']);
$model = $trackEngine->getRoundModel(true, 'create');
$roundData['gro_id_track'] = $import['trackId'];
$roundData['gro_id_survey'] = $import['surveyCodes'][$roundData['survey_export_code']];
if (isset($roundData['valid_after']) && $roundData['valid_after']) {
if (isset($roundOrders[$roundData['valid_after']]) && $roundOrders[$roundData['valid_after']]) {
$roundData['gro_valid_after_id'] = $roundOrders[$roundData['valid_after']];
} else {
$batch->addTask('Tracker\\Import\\UpdateRoundValidTask', $lineNr, $roundData['gro_id_order'], $roundData['valid_after'], 'gro_valid_after_id');
}
}
if (isset($roundData['gro_valid_after_source'], $fieldData['gro_valid_after_field'])) {
switch ($roundData['gro_valid_after_source']) {
case self::APPOINTMENT_TABLE:
case self::RESPONDENT_TRACK_TABLE:
if (isset($fieldCodes[$fieldData['gro_valid_after_field']])) {
$fieldData['gro_valid_after_field'] = $fieldCodes[$fieldData['gro_valid_after_field']];
}
}
}
if (isset($roundData['valid_for']) && $roundData['valid_for']) {
if (isset($roundOrders[$roundData['valid_for']]) && $roundOrders[$roundData['valid_for']]) {
$roundData['gro_valid_for_id'] = $roundOrders[$roundData['valid_for']];
} else {
$batch->addTask('Tracker\\Import\\UpdateRoundValidTask', $lineNr, $roundData['gro_id_order'], $roundData['valid_for'], 'gro_valid_for_id');
}
}
if (isset($roundData['gro_valid_for_source'], $fieldData['gro_valid_for_field'])) {
switch ($roundData['gro_valid_for_source']) {
case self::APPOINTMENT_TABLE:
case self::RESPONDENT_TRACK_TABLE:
if (isset($fieldCodes[$fieldData['gro_valid_for_field']])) {
$fieldData['gro_valid_for_field'] = $fieldCodes[$fieldData['gro_valid_for_field']];
}
}
}
$roundData = $model->save($roundData);
$import['rounds'][$lineNr]['gro_id_round'] = $roundData['gro_id_round'];
$import['roundOrders'][$roundData['gro_id_order']] = $roundData['gro_id_round'];
}
示例3: onFakeSubmit
/**
* Hook that allows actions when the form is submitted, but it was not the submit button that was checked
*
* When not rerouted, the form will be populated afterwards
*/
protected function onFakeSubmit()
{
if (isset($this->formData['create_account']) && $this->formData['create_account']) {
$mail = $this->loader->getMailLoader()->getMailer('staffPassword', $this->user->getUserId());
$mail->setOrganizationFrom();
if ($mail->setCreateAccountTemplate()) {
$mail->send();
$this->addMessage($this->_('Create account mail sent'));
$this->setAfterSaveRoute();
} else {
$this->addMessage($this->_('No default Create Account mail template set in organization or project'));
}
return;
}
if (isset($this->formData['reset_password']) && $this->formData['reset_password']) {
$mail = $this->loader->getMailLoader()->getMailer('staffPassword', $this->user->getUserId());
$mail->setOrganizationFrom();
if ($mail->setResetPasswordTemplate()) {
$mail->send();
$this->addMessage($this->_('Reset password mail sent'));
$this->setAfterSaveRoute();
} else {
$this->addMessage($this->_('No default Reset Password mail template set in organization or project'));
}
}
}
示例4: execute
/**
* Should handle execution of the task, taking as much (optional) parameters as needed
*
* The parameters should be optional and failing to provide them should be handled by
* the task
*
* @param array $trackData Nested array of trackdata
*/
public function execute($lineNr = null, $fieldData = null)
{
$batch = $this->getBatch();
$import = $batch->getVariable('import');
if (isset($fieldData['gtf_id_order']) && $fieldData['gtf_id_order']) {
$import['fieldOrder'][$fieldData['gtf_id_order']] = false;
if ($batch->hasVariable('trackEngine') && isset($fieldData['gtf_field_type']) && $fieldData['gtf_field_type']) {
$trackEngine = $batch->getVariable('trackEngine');
if ($trackEngine instanceof \Gems_Tracker_Engine_TrackEngineInterface) {
$fieldDef = $trackEngine->getFieldsDefinition();
$field = $fieldDef->getFieldByOrder($fieldData['gtf_id_order']);
if ($field instanceof FieldInterface) {
if ($field->getFieldType() != $fieldData['gtf_field_type']) {
$batch->addToCounter('import_errors');
$batch->addMessage(sprintf($this->_('Conflicting field types "%s" and "%s" for field orders %d specified on line %d.'), $field->getFieldType(), $fieldData['gtf_field_type'], $fieldData['gtf_id_order'], $lineNr));
}
}
}
}
} else {
$batch->addToCounter('import_errors');
$batch->addMessage(sprintf($this->_('No gtf_id_order specified for field at line %d.'), $lineNr));
}
if (isset($fieldData['gtf_field_type']) && $fieldData['gtf_field_type']) {
$model = $this->loader->getTracker()->createTrackClass('Model\\FieldMaintenanceModel');
$fields = $model->getFieldTypes();
if (!isset($fields[$fieldData['gtf_field_type']])) {
$batch->addToCounter('import_errors');
$batch->addMessage(sprintf($this->_('Unknown field type "%s" specified on line %d.'), $fieldData['gtf_field_type'], $lineNr));
}
} else {
$batch->addToCounter('import_errors');
$batch->addMessage(sprintf($this->_('No field type specified on line %d.'), $lineNr));
}
}
示例5: getAutoSearchElements
/**
* Returns a text element for autosearch. Can be overruled.
*
* The form / html elements to search on. Elements can be grouped by inserting null's between them.
* That creates a distinct group of elements
*
* @param array $data The $form field values (can be usefull, but no need to set them)
* @return array Of \Zend_Form_Element's or static tekst to add to the html or null for group breaks.
*/
protected function getAutoSearchElements(array $data)
{
$elements = parent::getAutoSearchElements($data);
$user = $this->loader->getCurrentUser();
if ($user->hasPrivilege('pr.respondent.select-on-track')) {
$tracks = $this->searchData['__active_tracks'];
$masks['show_all'] = $this->_('(all)');
$masks['show_without_track'] = $this->_('(no track)');
if (count($tracks) > 1) {
$masks['show_with_track'] = $this->_('(with track)');
}
if (count($tracks) > 1) {
$elements[] = $this->_createSelectElement('gr2t_id_track', $masks + $tracks);
} else {
$element = $this->_createRadioElement('gr2t_id_track', $masks + $tracks);
$element->setSeparator(' ');
$elements[] = $element;
}
$lineBreak = true;
} else {
$lineBreak = false;
}
if ($user->hasPrivilege('pr.respondent.show-deleted')) {
$elements[] = $this->_createCheckboxElement('grc_success', $this->_('Show active'));
}
if ($this->model->isMultiOrganization()) {
$element = $this->_createSelectElement(\MUtil_Model::REQUEST_ID2, $user->getRespondentOrganizations(), $this->_('(all organizations)'));
if ($lineBreak) {
$element->setLabel($this->_('Organization'))->setAttrib('onchange', 'this.form.submit();');
$elements[] = \MUtil_Html::create('br');
}
$elements[] = $element;
}
return $elements;
}
示例6: getAutoSearchElements
/**
* Returns a text element for autosearch. Can be overruled.
*
* The form / html elements to search on. Elements can be grouped by inserting null's between them.
* That creates a distinct group of elements
*
* @param array $data The $form field values (can be usefull, but no need to set them)
* @return array Of \Zend_Form_Element's or static tekst to add to the html or null for group breaks.
*/
protected function getAutoSearchElements(array $data)
{
$dbLookup = $this->util->getDbLookup();
$translated = $this->util->getTranslated();
$noRound = array(self::NoRound => $this->_('No round description'));
$empty = $translated->getEmptyDropdownArray();
$rounds = $empty + $noRound + $dbLookup->getRoundsForExport();
$surveys = $dbLookup->getSurveysForExport();
$elements[] = $this->_createSelectElement('gto_id_survey', $surveys, $this->_('(select a survey)'));
$elements[] = $this->_createSelectElement('gto_id_track', $this->util->getTrackData()->getAllTracks(), $this->_('(select a track)'));
$elements[] = $this->_createSelectElement('gto_round_description', $rounds, $this->_('(select a round)'));
$orgs = $this->loader->getCurrentUser()->getRespondentOrganizations();
if (count($orgs) > 1) {
$elements[] = $this->_createSelectElement('gto_id_organization', $orgs, $this->_('(all organizations)'));
}
$elements[] = null;
$dates = array('gto_start_date' => $this->_('Track start'), 'gto_end_date' => $this->_('Track end'), 'gto_valid_from' => $this->_('Valid from'), 'gto_valid_until' => $this->_('Valid until'));
// $dates = 'gto_valid_from';
$this->_addPeriodSelectors($elements, $dates, 'gto_valid_from');
$elements[] = null;
$element = $this->form->createElement('checkbox', 'column_identifiers');
$element->setLabel($this->_('Column Identifiers'));
$element->setDescription($this->_('Prefix the column labels with an identifier. (A) Answers, (TF) Trackfields, (D) Description'));
$elements[] = $element;
$element = $this->form->createElement('checkbox', 'show_parent');
$element->setLabel($this->_('Show parent'));
$element->setDescription($this->_('Show the parent column even if it doesn\'t have answers'));
$elements[] = $element;
$element = $this->form->createElement('checkbox', 'prefix_child');
$element->setLabel($this->_('Prefix child'));
$element->setDescription($this->_('Prefix the child column labels with parent question label'));
$elements[] = $element;
$elements[] = null;
return $elements;
}
示例7: afterRegistry
/**
* Called after the check that all required registry values
* have been set correctly has run.
*
* @return void
*/
public function afterRegistry()
{
parent::afterRegistry();
if (!$this->user) {
$this->user = $this->loader->getCurrentUser();
}
}
示例8: execute
/**
* Should handle execution of the task, taking as much (optional) parameters as needed
*
* The parameters should be optional and failing to provide them should be handled by
* the task
*/
public function execute($tokenData = null, $userId = null)
{
$batch = $this->getBatch();
$tracker = $this->loader->getTracker();
$batch->addToCounter('checkedTokens');
$token = $tracker->getToken($tokenData);
$wasAnswered = $token->isCompleted();
if ($result = $token->checkTokenCompletion($userId)) {
if ($result & \Gems_Tracker_Token::COMPLETION_DATACHANGE) {
$i = $batch->addToCounter('resultDataChanges');
$batch->setMessage('resultDataChanges', sprintf($this->_('Results and timing changed for %d tokens.'), $i));
if ($wasAnswered) {
$action = 'token.data-changed';
$message = sprintf($this->_("Token '%s' data has changed."), $token->getTokenId());
} else {
$action = 'token.answered';
$message = sprintf($this->_("Token '%s' was answered."), $token->getTokenId());
}
if (!$this->request instanceof \Zend_Controller_Request_Abstract) {
$this->request = \Zend_Controller_Front::getInstance()->getRequest();
}
$this->accesslog->logEntry($this->request, $action, true, $message, $token->getArrayCopy(), $token->getRespondentId());
}
if ($result & \Gems_Tracker_Token::COMPLETION_EVENTCHANGE) {
$i = $batch->addToCounter('surveyCompletionChanges');
$batch->setMessage('surveyCompletionChanges', sprintf($this->_('Answers changed by survey completion event for %d tokens.'), $i));
}
}
if ($token->isCompleted()) {
$batch->setTask('Tracker_ProcessTokenCompletion', 'tokproc-' . $token->getTokenId(), $tokenData, $userId);
}
$batch->setMessage('checkedTokens', sprintf($this->_('Checked %d tokens.'), $batch->getCounter('checkedTokens')));
// Free memory
$tracker->removeToken($token);
}
示例9: execute
/**
* Should handle execution of the task, taking as much (optional) parameters as needed
*
* The parameters should be optional and failing to provide them should be handled by
* the task
*
* @param array $trackData Nested array of trackdata
*/
public function execute($formData = null)
{
$batch = $this->getBatch();
$import = $batch->getVariable('import');
$tracker = $this->loader->getTracker();
$model = $tracker->getTrackModel();
$model->applyFormatting(true, true);
$trackData = $import['trackData'];
$trackData['gtr_track_name'] = $formData['gtr_track_name'];
$trackData['gtr_organizations'] = $formData['gtr_organizations'];
if ($batch->hasVariable('trackEngine')) {
$trackEngine = $batch->getVariable('trackEngine');
if ($trackEngine instanceof \Gems_Tracker_Engine_TrackEngineInterface) {
$trackData['gtr_id_track'] = $trackEngine->getTrackId();
}
}
// \MUtil_Echo::track($trackData);
if ($trackData['gtr_date_start'] && !$trackData['gtr_date_start'] instanceof \Zend_Date) {
$trackData['gtr_date_start'] = new \MUtil_Date($trackData['gtr_date_start'], 'yyyy-MM-dd');
}
$output = $model->save($trackData);
$import['trackId'] = $output['gtr_id_track'];
$import['trackData']['gtr_id_track'] = $output['gtr_id_track'];
$batch->addMessage($this->_('Merged track data'));
}
示例10: execute
/**
* Should handle execution of the task, taking as much (optional) parameters as needed
*
* The parameters should be optional and failing to provide them should be handled by
* the task
*/
public function execute($respTrackData = null, $userId = null)
{
$batch = $this->getBatch();
$tracker = $this->loader->getTracker();
$respTrack = $tracker->getRespondentTrack($respTrackData);
$engine = $respTrack->getTrackEngine();
$engine->checkRoundsFor($respTrack, $userId, $batch);
}
示例11: getFieldsTranslations
/**
* Get information on the field translations
*
* @return array of fields sourceName => targetName
* @throws \MUtil_Model_ModelException
*/
public function getFieldsTranslations()
{
if (!$this->_targetModel instanceof \MUtil_Model_ModelAbstract) {
throw new \MUtil_Model_ModelTranslateException(sprintf('Called %s without a set target model.', __FUNCTION__));
}
$this->_targetModel->set('gto_id_token', 'label', $this->_('Token'), 'import_descr', $this->loader->getTracker()->getTokenLibrary()->getFormat(), 'required', true, 'order', 2);
return array('token' => 'gto_id_token') + parent::getFieldsTranslations();
}
示例12: createModel
/**
* Creates the model
*
* @return \MUtil_Model_ModelAbstract
*/
protected function createModel()
{
if (!$this->model instanceof LogModel) {
$this->model = $this->loader->getModels()->createLogModel();
$this->model->applyDetailSettings();
}
return $this->model;
}
示例13: execute
/**
* Should handle execution of the task, taking as much (optional) parameters as needed
*
* The parameters should be optional and failing to provide them should be handled by
* the task
*/
public function execute($surveyId = null, $questionId = null, $order = null)
{
$batch = $this->getBatch();
$survey = $this->loader->getTracker()->getSurvey($surveyId);
// Now save the questions
$answerModel = $survey->getAnswerModel('en');
$questionModel = new \MUtil_Model_TableModel('gems__survey_questions');
\Gems_Model::setChangeFieldsByPrefix($questionModel, 'gsq');
$label = $answerModel->get($questionId, 'label');
/*
if ($label instanceof \MUtil_Html_HtmlInterface) {
$label = $label->render($this->view);
}
// */
$question['gsq_id_survey'] = $surveyId;
$question['gsq_name'] = $questionId;
$question['gsq_name_parent'] = $answerModel->get($questionId, 'parent_question');
$question['gsq_order'] = $order;
$question['gsq_type'] = $answerModel->getWithDefault($questionId, 'type', \MUtil_Model::TYPE_STRING);
$question['gsq_class'] = $answerModel->get($questionId, 'thClass');
$question['gsq_group'] = $answerModel->get($questionId, 'group');
$question['gsq_label'] = $label;
$question['gsq_description'] = $answerModel->get($questionId, 'description');
// \MUtil_Echo::track($question);
try {
$questionModel->save($question);
} catch (\Exception $e) {
$batch->addMessage(sprintf($this->_('Save failed for survey %s, question %s: %s'), $survey->getName(), $questionId, $e->getMessage()));
}
$batch->addToCounter('checkedQuestions');
if ($questionModel->getChanged()) {
$batch->addToCounter('changedQuestions');
}
$batch->setMessage('questionschanged', sprintf($this->_('%d of %d questions changed.'), $batch->getCounter('changedQuestions'), $batch->getCounter('checkedQuestions')));
$options = $answerModel->get($questionId, 'multiOptions');
if ($options) {
$optionModel = new \MUtil_Model_TableModel('gems__survey_question_options');
\Gems_Model::setChangeFieldsByPrefix($optionModel, 'gsqo');
$option['gsqo_id_survey'] = $surveyId;
$option['gsqo_name'] = $questionId;
$i = 0;
// \MUtil_Echo::track($options);
foreach ($options as $key => $label) {
$option['gsqo_order'] = $i;
$option['gsqo_key'] = $key;
$option['gsqo_label'] = $label;
try {
$optionModel->save($option);
} catch (\Exception $e) {
$batch->addMessage(sprintf($this->_('Save failed for survey %s, question %s, option "%s" => "%s": %s'), $survey->getName(), $questionId, $key, $label, $e->getMessage()));
}
$i++;
}
$batch->addToCounter('checkedOptions', count($options));
$batch->addToCounter('changedOptions', $optionModel->getChanged());
$batch->setMessage('optionschanged', sprintf($this->_('%d of %d options changed.'), $batch->getCounter('changedOptions'), $batch->getCounter('checkedOptions')));
}
}
示例14: getHtmlOutput
/**
* Create the snippets content
*
* This is a stub function either override getHtmlOutput() or override render()
*
* @param \Zend_View_Abstract $view Just in case it is needed here
* @return \MUtil_Html_HtmlInterface Something that can be rendered
*/
public function getHtmlOutput(\Zend_View_Abstract $view)
{
$messages = false;
if ($this->wasAnswered) {
$this->currentToken = $this->token->getNextUnansweredToken();
} else {
$validator = $this->loader->getTracker()->getTokenValidator();
if ($validator->isValid($this->token->getTokenId())) {
$this->currentToken = $this->token;
} else {
$messages = $validator->getMessages();
$this->currentToken = $this->token->getNextUnansweredToken();
}
}
if ($this->currentToken instanceof \Gems_Tracker_Token) {
$href = $this->getTokenHref($this->currentToken);
$url = $href->render($this->view);
// Redirect at once
header('Location: ' . $url);
exit;
}
// After the header() so that the patient does not see the messages after answering surveys
if ($messages) {
$this->addMessage($messages);
}
$org = $this->token->getOrganization();
$html = $this->getHtmlSequence();
$html->h3($this->_('Token'));
$html->pInfo(sprintf($this->_('Thank you %s,'), $this->token->getRespondentName()));
if ($welcome = $org->getWelcome()) {
$html->pInfo()->raw(\MUtil_Markup::render($this->_($welcome), 'Bbcode', 'Html'));
}
$p = $html->pInfo()->spaced();
if ($this->wasAnswered) {
$p->append($this->_('Thanks for answering our questions.'));
} elseif (!$this->isValid) {
if ($this->token->isExpired()) {
$this->addMessage($this->_('This survey has expired. You can no longer answer it.'));
} else {
$this->addMessage($this->_('This survey is no longer valid.'));
}
}
$p->append($this->_('We have no further questions for you at the moment.'));
$p->append($this->_('We appreciate your cooperation very much.'));
if ($sig = $org->getSignature()) {
$html->pInfo()->raw(\MUtil_Markup::render($this->_($sig), 'Bbcode', 'Html'));
}
/*
$html->br();
$href = array($this->request->getActionKey() => 'index', \MUtil_Model::REQUEST_ID => null);
$buttonDiv = $html->buttonDiv(array('class' => 'centerAlign'));
$buttonDiv->actionLink($href, $this->_('OK'));
// */
return $html;
}
示例15: afterRegistry
public function afterRegistry()
{
$this->user = $this->loader->getUserLoader()->getUserByStaffId($this->staffId);
parent::afterRegistry();
$this->user = $this->loader->getUserLoader()->getUserByStaffId($this->staffId);
$mailFields = $this->user->getMailFields();
$this->addMailFields($mailFields);
$this->addTo($this->user->getEmailAddress(), $this->user->getFullName());
$this->setLanguage($this->user->getLocale());
}