コード例 #1
0
ファイル: HtmlResponse.php プロジェクト: oat-sa/tao-core
 public function send()
 {
     if (DEBUG_MODE) {
         $message = $this->exception->getMessage();
         $trace = $this->exception->getTraceAsString();
     }
     require Template::getTemplate('error/error' . $this->httpCode . '.tpl', 'tao');
 }
コード例 #2
0
ファイル: HttpSourceTest.php プロジェクト: oat-sa/tao-core
 public function testGetBaseName()
 {
     $mediaSource = new HttpSource();
     $this->assertEquals('tao.png', $mediaSource->getBaseName(Template::img('tao.png', 'tao')));
     $this->assertEquals('tao.png', $mediaSource->getBaseName(Template::img('tao.png?a=b', 'tao')));
     $this->setExpectedException(tao_models_classes_FileNotFoundException::class);
     $mediaSource->getBaseName('http://notevenavaliddomain');
 }
コード例 #3
0
 /**
  * Should not be called directly but is public
  * since Renderer is public
  * 
  * @param core_kernel_classes_Resource $resource
  * @param core_kernel_classes_Property $property
  */
 public function __construct(core_kernel_classes_Resource $resource, core_kernel_classes_Property $property)
 {
     $tpl = Template::getTemplate('form' . DIRECTORY_SEPARATOR . 'generis_tree_form.tpl', 'tao');
     parent::__construct($tpl);
     $this->setData('id', 'uid' . md5($property->getUri() . $resource->getUri()));
     $this->setData('title', $property->getLabel());
     $this->setData('resourceUri', $resource->getUri());
     $this->setData('propertyUri', $property->getUri());
 }
コード例 #4
0
 /**
  * Test:
  *  - {@link ClientLibRegistry::getMap}
  *  - {@link ClientLibRegistry::register}
  */
 public function testRegister()
 {
     $libId = 'OAT/test';
     // verify test lib does not exist
     $map = ClientLibRegistry::getRegistry()->getMap();
     $this->assertFalse(empty($map));
     $this->assertFalse(isset($map[$libId]));
     ClientLibRegistry::getRegistry()->register($libId, Template::js('fakePath/views/js/', 'tao'));
     $map = ClientLibRegistry::getRegistry()->getMap();
     $this->assertInternalType('array', $map);
     $this->assertTrue(isset($map[$libId]));
     $this->assertEquals('js/fakePath/views/js/', $map[$libId]['path']);
     return $libId;
 }
コード例 #5
0
 /**
  *
  * @see Module::setView()
  * @param string $path
  *            view identifier
  * @param string $extensionID
  *            use the views in the specified extension instead of the current extension
  */
 public function setView($path, $extensionID = null)
 {
     parent::setView(Template::getTemplate($path, $extensionID));
 }
 /**
  * (non-PHPdoc)
  * @see \oat\taoDelivery\helper\container\AbstractContainer::getBodyTemplate()
  */
 protected function getBodyTemplate()
 {
     return Template::getTemplate($this->contentTemplate, $this->templateExtension);
 }
コード例 #7
0
 /**
  * Removes unnescessary API references
  *
  * @param Resource $item
  */
 protected function replaceDeprecatedApis($xhtml)
 {
     $dom = new DOMDocument('1.0', TAO_DEFAULT_ENCODING);
     if (!$dom->loadHTML($xhtml)) {
         throw new taoItems_models_classes_ItemModelException("An error occured while loading the XML content of the rendered item.");
     }
     $found = 0;
     $deprecatedApis = array('taoApi', 'wfApi');
     foreach ($deprecatedApis as $pattern) {
         $found += taoItems_helpers_Xhtml::removeScriptElements($dom, '/' . $pattern . '/i');
     }
     if ($found > 0) {
         common_Logger::i('found ' . $found . ' references to deprecated APIs, replacing with legacy API');
         $taoItemsExt = common_ext_ExtensionsManager::singleton()->getExtensionById('taoItems');
         $legacyApiSrc = Template::js('legacyApi/taoLegacyApi.min.js', 'taoItems');
         taoItems_helpers_Xhtml::addScriptElement($dom, $legacyApiSrc);
     }
     return $dom->saveHTML();
 }
コード例 #8
0
 /**
  * Set a view with the list of process instances (both started or finished) and available process definitions
  *
  * @access public
  * @author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu}
  * @param processDefinitionUri
  * @return void
  */
 public function index()
 {
     $user = common_session_SessionManager::getSession()->getUser();
     /**
      * Retrieve resumable deliveries (via delivery execution)
      */
     $resumableData = array();
     foreach ($this->service->getResumableDeliveries($user) as $de) {
         $resumableData[] = DeliveryHelper::buildFromDeliveryExecution($de);
     }
     $this->setData('resumableDeliveries', $resumableData);
     $assignmentService = $this->getServiceManager()->get(AssignmentService::CONFIG_ID);
     $deliveryData = array();
     foreach ($assignmentService->getAssignments($user) as $delivery) {
         $deliveryData[] = DeliveryHelper::buildFromAssembly($delivery, $user);
     }
     $this->setData('availableDeliveries', $deliveryData);
     /**
      * Header & footer info
      */
     $this->setData('showControls', $this->showControls());
     $this->setData('userLabel', common_session_SessionManager::getSession()->getUserLabel());
     // Require JS config
     $this->setData('client_config_url', $this->getClientConfigUrl());
     $this->setData('client_timeout', $this->getClientTimeout());
     $loaderRenderer = new \Renderer(Template::getTemplate('DeliveryServer/blocks/loader.tpl', 'taoDelivery'));
     $loaderRenderer->setData('client_config_url', $this->getClientConfigUrl());
     $loaderParams = [];
     if ($this->getRequest()->hasParameter('warning') && !empty($this->getRequest()->getParameter('warning'))) {
         $loaderParams['message'] = ['level' => 'danger', 'content' => $this->getRequest()->getParameter('warning'), 'timeout' => -1];
     }
     $loaderRenderer->setData('parameters', $loaderParams);
     /**
      * Layout template + real template inclusion
      */
     $this->setData('additional-header', $loaderRenderer);
     $this->setData('content-template', 'DeliveryServer/index.tpl');
     $this->setData('content-extension', 'taoDelivery');
     $this->setView('DeliveryServer/layout.tpl', 'taoDelivery');
 }
コード例 #9
0
ファイル: DarkTheme.php プロジェクト: jbout/boutTools
 /**
  * @param string $context
  * @return string
  */
 public function getStylesheet($context = Theme::CONTEXT_BACKOFFICE)
 {
     return Template::css('theme/' . self::THEME_ID . '/theme.css', self::EXTENSION_ID);
 }
コード例 #10
0
ファイル: Bootstrap.php プロジェクト: nagyist/tao-core
 private function dispatchError(Exception $e, $httpStatus, $message = '', $trace = '')
 {
     // Set relevant HTTP header.
     header(HTTPToolkit::statusCodeHeader($httpStatus));
     if (tao_helpers_Request::isAjax()) {
         new common_AjaxResponse(array("success" => false, "type" => 'Exception', "data" => array('ExceptionType' => get_class($e)), "message" => $message));
     } else {
         require_once Template::getTemplate("error/error{$httpStatus}.tpl", 'tao');
     }
 }
コード例 #11
0
ファイル: Layout.php プロジェクト: oat-sa/tao-core
 /**
  * Get the logo URL.
  * 
  * @return string The absolute URL to the logo image.
  */
 public static function getLogoUrl()
 {
     $logoFile = Template::img('tao-logo.png', 'tao');
     switch (TAO_RELEASE_STATUS) {
         case 'alpha':
         case 'demoA':
             $logoFile = Template::img('tao-logo-alpha.png', 'tao');
             break;
         case 'beta':
         case 'demoB':
             $logoFile = Template::img('tao-logo-beta.png', 'tao');
             break;
     }
     return $logoFile;
 }
コード例 #12
0
 protected function getUserScripts()
 {
     $userScripts = array();
     $userScriptConfig = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem')->getConfig('userScripts');
     if (is_array($userScriptConfig)) {
         foreach ($userScriptConfig as $data) {
             $userScripts[] = Template::js($data['src'], $data['extension']);
         }
     }
     return $userScripts;
 }
コード例 #13
0
ファイル: Bootstrap.php プロジェクト: oat-sa/tao-core
 protected function dispatchHttp()
 {
     $isAjax = tao_helpers_Request::isAjax();
     if (tao_helpers_Context::check('APP_MODE')) {
         if (!$isAjax) {
             $this->scripts();
         }
     }
     //Catch all exceptions
     try {
         //the app is ready
         if ($this->isReady()) {
             $this->mvc();
         } else {
             //the request is not an ajax request, redirect the user to the maintenance page
             if (!$isAjax) {
                 require_once Template::getTemplate('error/maintenance.tpl', 'tao');
                 //else throw an exception, this exception will be send to the client properly
             } else {
                 throw new \common_exception_SystemUnderMaintenance();
             }
         }
     } catch (Exception $e) {
         $this->catchError($e);
     }
     // explicitly close session
     session_write_close();
 }
コード例 #14
0
 /**
  * Get the logo URL.
  * 
  * @return string The absolute URL to the logo image.
  */
 public static function getLogoUrl()
 {
     $logoFile = Template::img('apt_logo.png', 'tao');
     if (self::isThemingEnabled() === true) {
         // Get Theming info from taoThemingPlatform...
         $themingService = PlatformThemingService::singleton();
         $themingConfig = $themingService->retrieveThemingConfig();
         if ($themingConfig['logo'] !== null) {
             $logoFile = $themingService->getFileUrl($themingConfig['logo']);
         }
     } else {
         switch (TAO_RELEASE_STATUS) {
             case 'alpha':
             case 'demoA':
                 $logoFile = Template::img('tao-logo-alpha.png', 'tao');
                 break;
             case 'beta':
             case 'demoB':
                 $logoFile = Template::img('tao-logo-beta.png', 'tao');
                 break;
         }
     }
     return $logoFile;
 }
コード例 #15
0
 /**
  * Function generates password recovery email message content
  * May be used in the following way:
  * <pre>
  * $this->getMailContent(array(
  *     'user_name'=>'John Doe',
  *     'link'=>$this->getPasswordRecoveryLink($user)
  * ));
  * </pre>
  * 
  * @author Aleh Hutnikau <*****@*****.**>
  * @param array $messageData
  * @return string Message content
  */
 private function getMailContent($messageData)
 {
     $renderer = new \Renderer();
     $renderer->setTemplate(Template::getTemplate('passwordRecovery/password-recovery-message.tpl', 'tao'));
     foreach ($messageData as $key => $value) {
         $renderer->setData($key, $value);
     }
     return $renderer->render();
 }
コード例 #16
0
ファイル: DefaultTheme.php プロジェクト: oat-sa/tao-core
 /**
  * (non-PHPdoc)
  * @see \oat\tao\model\theme\Theme::getStylesheet()
  */
 public function getStylesheet($context = Theme::CONTEXT_BACKOFFICE)
 {
     return Template::css('tao-3.css', 'tao');
 }
コード例 #17
0
 /**
  * Edit action
  * @throws \tao_models_classes_MissingRequestParameterException
  * @throws \tao_models_classes_dataBinding_GenerisFormDataBindingException
  */
 public function editBooklet()
 {
     $clazz = $this->getCurrentClass();
     $instance = $this->getCurrentInstance();
     $myFormContainer = new EditForm($clazz, $instance);
     $myForm = $myFormContainer->getForm();
     $fileResource = $instance->getOnePropertyValue(new core_kernel_classes_Property(BookletClassService::PROPERTY_FILE_CONTENT));
     $myFormContainer->setAllowDownload($fileResource instanceof core_kernel_classes_Resource);
     if ($myForm->isSubmited() && $myForm->isValid()) {
         $values = $myForm->getValues();
         // save properties
         $binder = new \tao_models_classes_dataBinding_GenerisFormDataBinder($instance);
         $instance = $binder->bind($values);
         $this->setData('message', __('Booklet saved'));
         $this->setData('reload', true);
     }
     // define the groups related to the current booklet
     $property = new core_kernel_classes_Property(BookletClassService::PROPERTY_GROUP);
     $tree = tao_helpers_form_GenerisTreeForm::buildTree($instance, $property);
     $tree->setTitle(__('Assigned to'));
     $tree->setTemplate(Template::getTemplate('Booklet/assignGroup.tpl'));
     $tree->setData('anonymousClass', BookletClassService::PROPERTY_ANONYMOUS);
     $tree->setData('anonymous', INSTANCE_BOOLEAN_TRUE);
     $this->setData('groupTree', $tree->render());
     $this->setData('formTitle', __('Edit Booklet'));
     $this->setData('myForm', $myForm->render());
     $this->setView('Booklet/edit.tpl');
 }
コード例 #18
0
 /**
  * Edit a delivery instance
  *
  * @access public
  * @author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu}
  * @return void
  */
 public function editDelivery()
 {
     $clazz = $this->getCurrentClass();
     $delivery = $this->getCurrentInstance();
     $formContainer = new taoDelivery_actions_form_Delivery($clazz, $delivery);
     $myForm = $formContainer->getForm();
     $myForm->evaluate();
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $propertyValues = $myForm->getValues();
             // then save the property values as usual
             $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($delivery);
             $delivery = $binder->bind($propertyValues);
             $this->setData("selectNode", tao_helpers_Uri::encode($delivery->getUri()));
             $this->setData('message', __('Delivery saved'));
             $this->setData('reload', true);
         }
     }
     $this->setData('label', $delivery->getLabel());
     // history
     $this->setData('date', taoDelivery_models_classes_DeliveryAssemblyService::singleton()->getCompilationDate($delivery));
     if (taoDelivery_models_classes_execution_ServiceProxy::singleton()->implementsMonitoring()) {
         $execs = taoDelivery_models_classes_execution_ServiceProxy::singleton()->getExecutionsByDelivery($delivery);
         $this->setData('exec', count($execs));
     }
     // define the groups related to the current delivery
     $property = new core_kernel_classes_Property(PROPERTY_GROUP_DELVIERY);
     $tree = tao_helpers_form_GenerisTreeForm::buildReverseTree($delivery, $property);
     $tree->setTitle(__('Assigned to'));
     $tree->setTemplate(Template::getTemplate('widgets/assignGroup.tpl'));
     $this->setData('groupTree', $tree->render());
     // testtaker brick
     $this->setData('assemblyUri', $delivery->getUri());
     // define the subjects excluded from the current delivery
     $property = new core_kernel_classes_Property(TAO_DELIVERY_EXCLUDEDSUBJECTS_PROP);
     $excluded = $delivery->getPropertyValues($property);
     $this->setData('ttexcluded', count($excluded));
     $users = taoDelivery_models_classes_AssignmentService::singleton()->getAssignedUsers($delivery);
     $assigned = array_diff(array_unique($users), $excluded);
     $this->setData('ttassigned', count($assigned));
     $this->setData('formTitle', __('Properties'));
     $this->setData('myForm', $myForm->render());
     if (common_ext_ExtensionsManager::singleton()->isEnabled('taoCampaign')) {
         $this->setData('campaign', taoCampaign_helpers_Campaign::renderCampaignTree($delivery));
     }
     $this->setView('Delivery/editDelivery.tpl');
 }
コード例 #19
0
 public function getBase64()
 {
     //TODO Resize the image
     if ($this->hasRequestParameter('upload')) {
         $filename = $this->getRequestParameter('upload');
         $return['base64'] = 'data:' . FsUtils::getMimeType($filename) . ';base64,' . base64_encode(file_get_contents($filename));
     } else {
         $return['base64'] = Template::img('tao-logo.png', 'tao');
     }
     $this->returnJson($return);
 }