public function index()
 {
     $config = new CreatorConfig();
     $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem');
     $creatorConfig = $ext->getConfig('qtiCreator');
     if (is_array($creatorConfig)) {
         foreach ($creatorConfig as $prop => $value) {
             $config->setProperty($prop, $value);
         }
     }
     if ($this->hasRequestParameter('instance')) {
         //uri:
         $itemUri = tao_helpers_Uri::decode($this->getRequestParameter('instance'));
         $config->setProperty('uri', $itemUri);
         //get label:
         $rdfItem = new core_kernel_classes_Resource($itemUri);
         $config->setProperty('label', $rdfItem->getLabel());
         //set the current data lang in the item content to keep the integrity
         //@todo : allow preview in a language other than the one in the session
         $lang = \common_session_SessionManager::getSession()->getDataLanguage();
         $config->setProperty('lang', $lang);
         //base url:
         $url = tao_helpers_Uri::url('getFile', 'QtiCreator', 'taoQtiItem', array('uri' => $itemUri, 'lang' => $lang));
         $config->setProperty('baseUrl', $url . '&relPath=');
     }
     // get the config media Sources
     $sources = array_keys(MediaSource::getMediaBrowserSources());
     $sources[] = 'local';
     $config->setProperty('mediaSources', $sources);
     //initialize all registered hooks:
     $hookClasses = HookRegistry::getRegistry()->getMap();
     foreach ($hookClasses as $hookClass) {
         $hook = new $hookClass();
         $hook->init($config);
     }
     $config->init();
     $this->setData('config', $config->toArray());
     $this->setView('QtiCreator/index.tpl');
 }
Exemplo n.º 2
0
 /**
  * Get the configuration of the Item Creator
  * @param core_kernel_classes_Resource $item the selected item
  * @return CreatorConfig the configration
  */
 protected function getCreatorConfig(core_kernel_classes_Resource $item)
 {
     $config = new CreatorConfig();
     $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem');
     $creatorConfig = $ext->getConfig('qtiCreator');
     if (is_array($creatorConfig)) {
         foreach ($creatorConfig as $prop => $value) {
             $config->setProperty($prop, $value);
         }
     }
     $config->setProperty('uri', $item->getUri());
     $config->setProperty('label', $item->getLabel());
     //set the current data lang in the item content to keep the integrity
     //@todo : allow preview in a language other than the one in the session
     $lang = \common_session_SessionManager::getSession()->getDataLanguage();
     $config->setProperty('lang', $lang);
     //base url:
     $url = tao_helpers_Uri::url('getFile', 'QtiCreator', 'taoQtiItem', array('uri' => $item->getUri(), 'lang' => $lang, 'relPath' => ''));
     $config->setProperty('baseUrl', $url);
     //map the multi column config to the plugin
     //TODO migrate the config
     if ($config->getProperty('multi-column') == true) {
         $config->addPlugin('blockAdder', 'taoQtiItem/qtiCreator/plugins/content/blockAdder', 'content');
     }
     $mediaSourcesUrl = tao_helpers_Uri::url('getMediaSources', 'QtiCreator', 'taoQtiItem');
     $config->setProperty('mediaSourcesUrl', $mediaSourcesUrl);
     //initialize all registered hooks:
     $hookClasses = HookRegistry::getRegistry()->getMap();
     foreach ($hookClasses as $hookClass) {
         $hook = new $hookClass();
         $hook->init($config);
     }
     $config->init();
     return $config;
 }