/**
  * Show the form to edit an instance, show also a preview of the media
  */
 public function editInstance()
 {
     $clazz = $this->getCurrentClass();
     $instance = $this->getCurrentInstance();
     $myFormContainer = new editInstanceForm($clazz, $instance);
     $myForm = $myFormContainer->getForm();
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $values = $myForm->getValues();
             // save properties
             $binder = new \tao_models_classes_dataBinding_GenerisFormDataBinder($instance);
             $instance = $binder->bind($values);
             $message = __('Instance saved');
             $this->setData('message', $message);
             $this->setData('reload', true);
         }
     }
     $this->setData('formTitle', __('Edit Instance'));
     $this->setData('myForm', $myForm->render());
     $uri = $this->hasRequestParameter('id') ? $this->getRequestParameter('id') : $this->getRequestParameter('uri');
     try {
         $mediaSource = new MediaSource(array());
         $fileInfo = $mediaSource->getFileInfo($uri);
         $mimeType = $fileInfo['mime'];
         $xml = in_array($mimeType, array('application/xml', 'text/xml'));
         $url = \tao_helpers_Uri::url('getFile', 'MediaManager', 'taoMediaManager', array('uri' => $uri));
         $this->setData('xml', $xml);
         $this->setData('fileurl', $url);
         $this->setData('mimeType', $mimeType);
     } catch (\tao_models_classes_FileNotFoundException $e) {
         $this->setData('error', __('No file found for this media'));
     }
     $this->setView('form.tpl');
 }
 /**
  * Returns a json encoded array describign a directory
  * 
  * @throws common_exception_MissingParameter
  * @return string
  */
 public function files()
 {
     if (!$this->hasRequestParameter('uri')) {
         throw new common_exception_MissingParameter('uri', __METHOD__);
     }
     $itemUri = $this->getRequestParameter('uri');
     $item = new core_kernel_classes_Resource($itemUri);
     if (!$this->hasRequestParameter('lang')) {
         throw new common_exception_MissingParameter('lang', __METHOD__);
     }
     $itemLang = $this->getRequestParameter('lang');
     //build filters
     $filters = array();
     if ($this->hasRequestParameter('filters')) {
         $filterParameter = $this->getRequestParameter('filters');
         if (!empty($filterParameter)) {
             if (preg_match('/\\/\\*/', $filterParameter)) {
                 common_Logger::w('Stars mime type are not yet supported, filter "' . $filterParameter . '" will fail');
             }
             $filters = array_map('trim', explode(',', $filterParameter));
         }
     }
     $depth = $this->hasRequestParameter('depth') ? $this->getRequestParameter('depth') : 1;
     $resolver = new ItemMediaResolver($item, $itemLang);
     $asset = $resolver->resolve($this->getRequestParameter('path'));
     $data = $asset->getMediaSource()->getDirectory($asset->getMediaIdentifier(), $filters, $depth);
     foreach ($data['children'] as &$child) {
         if (isset($child['parent'])) {
             $child['url'] = \tao_helpers_Uri::url('files', 'ItemContent', 'taoItems', array('uri' => $itemUri, 'lang' => $itemLang, '1' => $child['parent']));
             unset($child['parent']);
         }
     }
     $this->returnJson($data);
 }
 public function initProcessExecution($posted)
 {
     //set_time_limit(200);
     helpers_TimeOutHelper::setTimeOutLimit(helpers_TimeOutHelper::LONG);
     $processExecutionService = wfEngine_models_classes_ProcessExecutionService::singleton();
     $activityExecutionService = wfEngine_models_classes_ActivityExecutionService::singleton();
     $processDefinitionUri = urldecode($posted['executionOf']);
     $processDefinition = new core_kernel_classes_Resource($processDefinitionUri);
     $processExecName = $posted["variables"][RDFS_LABEL];
     $processExecComment = 'Created in Processes server on ' . date(DATE_ISO8601);
     $processVariables = $posted["variables"];
     $newProcessExecution = $processExecutionService->createProcessExecution($processDefinition, $processExecName, $processExecComment, $processVariables);
     //create nonce to initial activity executions:
     foreach ($processExecutionService->getCurrentActivityExecutions($newProcessExecution) as $initialActivityExecution) {
         $activityExecutionService->createNonce($initialActivityExecution);
     }
     helpers_TimeOutHelper::reset();
     $param = array('processUri' => urlencode($newProcessExecution->getUri()));
     $this->redirect(tao_helpers_Uri::url('index', 'ProcessBrowser', null, $param));
 }
 /**
  * (non-PHPdoc)
  * @see taoLti_actions_ToolModule::run()
  * @requiresRight id READ
  */
 public function run()
 {
     if (!$this->hasRequestParameter('id')) {
         return $this->returnError(__('No item has been specified'));
     }
     if (tao_helpers_Request::isAjax()) {
         throw new common_exception_Error("Wrong request mode, this is a plain document.");
     }
     $item = new core_kernel_classes_Resource(tao_helpers_Uri::decode($this->getRequestParameter('id')));
     if (!$item->exists()) {
         throw new common_exception_Error('We\'re unable to find the item ' . $item->getUri());
     }
     $this->setData('client_config_url', $this->getClientConfigUrl());
     $this->setData('previewUrl', \tao_helpers_Uri::url('index', 'QtiPreview', 'taoQtiItem', array('uri' => $item->getUri(), 'lang' => DEFAULT_LANG)));
     //retrieve the return URL from the LTI session
     $launchData = taoLti_models_classes_LtiService::singleton()->getLtiSession()->getLaunchData();
     if ($launchData->hasVariable(taoLti_models_classes_LtiLaunchData::LAUNCH_PRESENTATION_RETURN_URL)) {
         $this->setData('returnUrl', $launchData->getVariable(taoLti_models_classes_LtiLaunchData::LAUNCH_PRESENTATION_RETURN_URL));
     }
     $this->setData('content-template', array('QtiPreview/index.tpl', 'itemqtiCreator'));
     $this->setView('layout.tpl', 'itemqtiCreator');
 }
 public function run()
 {
     //set_time_limit(200);
     helpers_TimeOutHelper::setTimeOutLimit(helpers_TimeOutHelper::LONG);
     $processExecutionService = wfEngine_models_classes_ProcessExecutionService::singleton();
     $activityExecutionService = wfEngine_models_classes_ActivityExecutionService::singleton();
     $processDefinitionUri = $this->getRequestParameter('processDefinition');
     $processDefinition = new core_kernel_classes_Resource($processDefinitionUri);
     if (!$this->hasRequestParameter('serviceCallId')) {
         throw new common_exception_Error('No serviceCallId on service call');
     }
     $serviceService = tao_models_classes_service_StateStorage::singleton();
     $userUri = common_session_SessionManager::getSession()->getUserUri();
     $processExecutionUri = is_null($userUri) ? null : $serviceService->get($userUri, $this->getRequestParameter('serviceCallId'));
     if (is_null($processExecutionUri)) {
         $processExecName = $processDefinition->getLabel();
         $processExecComment = 'Created in Processes server on ' . date(DATE_ISO8601);
         if (isset($_REQUEST['processVariables']) && !empty($_REQUEST['processVariables'])) {
             $processVariables = json_decode($_REQUEST['processVariables'], true);
             $processVariables = is_array($processVariables) ? $processVariables : array();
         } else {
             // none provided
             $processVariables = array();
         }
         $newProcessExecution = $processExecutionService->createProcessExecution($processDefinition, $processExecName, $processExecComment, $processVariables);
         $processExecutionUri = $newProcessExecution->getUri();
         $serviceService->set($userUri, $this->getRequestParameter('serviceCallId'), $processExecutionUri);
     }
     $processExecution = new core_kernel_classes_Resource($processExecutionUri);
     //create nonce to initial activity executions:
     foreach ($processExecutionService->getCurrentActivityExecutions($processExecution) as $initialActivityExecution) {
         $activityExecutionService->createNonce($initialActivityExecution);
     }
     helpers_TimeOutHelper::reset();
     $param = array('processUri' => urlencode($processExecution->getUri()), 'standalone' => 'true');
     $this->redirect(tao_helpers_Uri::url('index', null, null, $param));
 }
Esempio n. 6
0
/**
 * Convenent function, helps you to the URI to access a framework action
 * @author Bertrand Chevrier, <*****@*****.**>
 * @param  string action the targeted action name
 * @param  string module the targeted module name
 * @param  string extension the targeted extension name
 * @param  array params an array of additionnal key/value query parameters
 * @return the URI
 */
function _url($action = null, $module = null, $extension = null, $params = array())
{
    return tao_helpers_Uri::url($action, $module, $extension, $params);
}
Esempio n. 7
0
 /**
  * Service of class or instance selection with a tree.
  * @return void
  */
 public function sasSelect()
 {
     $kind = $this->getDataKind();
     $context = Context::getInstance();
     $module = $context->getModuleName();
     $this->setData('treeName', __('Select'));
     $this->setData('dataUrl', _url('sasGetOntologyData'));
     $this->setData('editClassUrl', tao_helpers_Uri::url('sasSet', $module));
     if ($this->getRequestParameter('selectInstance') == 'true') {
         $this->setData('editInstanceUrl', tao_helpers_Uri::url('sasSet', $module));
         $this->setData('editClassUrl', false);
     } else {
         $this->setData('editInstanceUrl', false);
         $this->setData('editClassUrl', tao_helpers_Uri::url('sasSet', $module));
     }
     $this->setData('classLabel', $this->getRootClass()->getLabel());
     $this->setView("sas/select.tpl", 'tao');
 }
Esempio n. 8
0
 /**
  * Forward routing.
  * @param string $action the name of the new action
  * @param string $controller the name of the new controller/module
  * @param string $extension the name of the new extension
  * @param array $params additional parameters
  */
 public function forward($action, $controller = null, $extension = null, $params = array())
 {
     //as we use a route resolver, it's easier to rebuild the URL to resolve it
     $this->forwardUrl(\tao_helpers_Uri::url($action, $controller, $extension, $params));
 }
 protected function redirectToMain()
 {
     $this->removeSessionAttribute("processUri");
     $this->redirect(tao_helpers_Uri::url('index', 'WfHome'));
 }
 public function init()
 {
     foreach ($this->interactions as $interaction) {
         $this->prepare($interaction);
     }
     foreach ($this->infoControls as $infoControl) {
         $this->prepare($infoControl);
     }
     foreach ($this->controlEndpoints as $key => $endpoint) {
         $this->setProperty($key, \tao_helpers_Uri::url($endpoint[2], $endpoint[1], $endpoint[0]));
     }
     //as the config overrides the plugins, we get the list from the registry
     $registry = QtiCreatorClientConfigRegistry::getRegistry();
     $this->plugins = array_merge($this->plugins, $registry->getPlugins());
 }