commit
4c06ce4c10
@ -0,0 +1,34 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Application\Migrations\Schema\V111; |
||||
|
||||
use Application\Migrations\AbstractMigrationChamilo; |
||||
use Doctrine\DBAL\Schema\Schema; |
||||
use Doctrine\DBAL\Types\Type; |
||||
|
||||
/** |
||||
* Class Version20160418093800 |
||||
* Add save_correct_answers column to c_quiz table |
||||
* @package Application\Migrations\Schema\V111 |
||||
*/ |
||||
class Version20160418093800 extends AbstractMigrationChamilo |
||||
{ |
||||
/** |
||||
* @param Schema $schema |
||||
* @throws \Doctrine\DBAL\Schema\SchemaException |
||||
*/ |
||||
public function up(Schema $schema) |
||||
{ |
||||
$cQuizTable = $schema->getTable('c_quiz'); |
||||
$cQuizTable->addColumn('save_correct_answers', Type::BOOLEAN); |
||||
} |
||||
|
||||
/** |
||||
* @param Schema $schema |
||||
*/ |
||||
public function down(Schema $schema) |
||||
{ |
||||
|
||||
} |
||||
} |
||||
@ -1,327 +0,0 @@ |
||||
import java.awt.Event; |
||||
|
||||
//import sun.text.Normalizer;
|
||||
|
||||
import com.enterprisedt.net.ftp.FTPClient; |
||||
import com.enterprisedt.net.ftp.FTPConnectMode; |
||||
import com.enterprisedt.net.ftp.FTPTransferType; |
||||
import com.sun.star.beans.PropertyValue; |
||||
import com.sun.star.beans.XPropertySet; |
||||
import com.sun.star.bridge.XBridge; |
||||
import com.sun.star.bridge.XBridgeFactory; |
||||
import com.sun.star.connection.NoConnectException; |
||||
import com.sun.star.connection.XConnection; |
||||
import com.sun.star.connection.XConnector; |
||||
import com.sun.star.container.XNamed; |
||||
import com.sun.star.document.XExporter; |
||||
import com.sun.star.document.XFilter; |
||||
import com.sun.star.drawing.XDrawPage; |
||||
import com.sun.star.drawing.XDrawPages; |
||||
import com.sun.star.drawing.XDrawPagesSupplier; |
||||
import com.sun.star.frame.XComponentLoader; |
||||
import com.sun.star.lang.XComponent; |
||||
import com.sun.star.lang.XMultiComponentFactory; |
||||
import com.sun.star.uno.UnoRuntime; |
||||
import com.sun.star.uno.XComponentContext; |
||||
|
||||
/** |
||||
* The class <CODE>DocumentConverter</CODE> allows you to convert all |
||||
* documents in a given directory and in its subdirectories to a given type. A |
||||
* converted document will be created in the same directory as the origin |
||||
* document. |
||||
* |
||||
*/ |
||||
public class DocumentConverter { |
||||
/** |
||||
* Containing the loaded documents |
||||
*/ |
||||
static XComponentLoader xcomponentloader = null; |
||||
|
||||
/** |
||||
* Connecting to the office with the component UnoUrlResolver and calling |
||||
* the static method traverse |
||||
* |
||||
* @param args |
||||
* The array of the type String contains the directory, in which |
||||
* all files should be converted, the favoured converting type |
||||
* and the wanted extension |
||||
*/ |
||||
public static void main(String args[]) { |
||||
|
||||
String cnx, ftpuser, host, port, url, ftpPasswd, destinationFolder, remoteFolderFullPath, remoteFolder; |
||||
int width, height; |
||||
|
||||
try { |
||||
host = args[0]; |
||||
port = args[1]; |
||||
url = args[2]; |
||||
destinationFolder = args[3]; |
||||
width = Integer.parseInt(args[4]); |
||||
height = Integer.parseInt(args[5]); |
||||
if(args.length == 8){ |
||||
ftpuser = args[6]; |
||||
ftpPasswd = args[7]; |
||||
} |
||||
else{ |
||||
ftpuser = ""; |
||||
ftpPasswd = ""; |
||||
} |
||||
|
||||
|
||||
if(host.equals("localhost")){ |
||||
String prefix = "file://"; |
||||
if(url.charAt(0)!='/') |
||||
prefix += '/'; |
||||
url = prefix+url; |
||||
remoteFolder = destinationFolder; |
||||
remoteFolderFullPath = prefix; |
||||
} |
||||
else { |
||||
remoteFolderFullPath = "file:///home/"+ftpuser+"/"; |
||||
remoteFolder = url.replace('/','_'); |
||||
remoteFolder = removeAccents(remoteFolder); |
||||
} |
||||
|
||||
cnx = "socket,host="+host+",port="+port; |
||||
|
||||
XComponentContext xComponentContext = com.sun.star.comp.helper.Bootstrap |
||||
.createInitialComponentContext(null); |
||||
|
||||
|
||||
XComponentContext xRemoteContext = xComponentContext; |
||||
|
||||
Object x = xRemoteContext |
||||
.getServiceManager() |
||||
.createInstanceWithContext( |
||||
"com.sun.star.connection.Connector", xRemoteContext); |
||||
|
||||
XConnector xConnector = (XConnector) UnoRuntime.queryInterface( |
||||
XConnector.class, x); |
||||
|
||||
XConnection connection = xConnector.connect(cnx); |
||||
|
||||
//if (connection == null)
|
||||
//System.out.println("Connection is null");
|
||||
x = xRemoteContext.getServiceManager().createInstanceWithContext( |
||||
"com.sun.star.bridge.BridgeFactory", xRemoteContext); |
||||
|
||||
|
||||
XBridgeFactory xBridgeFactory = (XBridgeFactory) UnoRuntime |
||||
.queryInterface(XBridgeFactory.class, x); |
||||
|
||||
// this is the bridge that you will dispose
|
||||
XBridge bridge = xBridgeFactory.createBridge("", "urp", connection,null); |
||||
|
||||
/*XComponent xComponent = (XComponent) UnoRuntime.queryInterface( |
||||
XComponent.class, bridge);*/ |
||||
// get the remote instance
|
||||
x = bridge.getInstance("StarOffice.ServiceManager"); |
||||
// Query the initial object for its main factory interface
|
||||
XMultiComponentFactory xMultiComponentFactory = (XMultiComponentFactory) UnoRuntime |
||||
.queryInterface(XMultiComponentFactory.class, x); |
||||
XPropertySet xProperySet = (XPropertySet) UnoRuntime |
||||
.queryInterface(XPropertySet.class, xMultiComponentFactory); |
||||
|
||||
// Get the default context from the office server.
|
||||
Object oDefaultContext = xProperySet |
||||
.getPropertyValue("DefaultContext"); |
||||
|
||||
// Query for the interface XComponentContext.
|
||||
xComponentContext = (XComponentContext) UnoRuntime.queryInterface( |
||||
XComponentContext.class, oDefaultContext); |
||||
|
||||
|
||||
while (xcomponentloader == null) { |
||||
try { |
||||
|
||||
xcomponentloader = (XComponentLoader) UnoRuntime |
||||
.queryInterface( |
||||
XComponentLoader.class, |
||||
xMultiComponentFactory |
||||
.createInstanceWithContext( |
||||
"com.sun.star.frame.Desktop", |
||||
xComponentContext)); |
||||
|
||||
//System.out.println("Loading document "+url);
|
||||
|
||||
FTPClient ftp = new FTPClient(); |
||||
if(!host.equals("localhost")){ |
||||
//ftp connexion
|
||||
ftp.setRemoteHost(host); |
||||
ftp.connect(); |
||||
ftp.login(ftpuser, ftpPasswd); |
||||
ftp.setConnectMode(FTPConnectMode.PASV); |
||||
ftp.setType(FTPTransferType.BINARY); |
||||
try{ |
||||
ftp.mkdir(remoteFolder); |
||||
}catch(Exception e){} |
||||
ftp.chdir(remoteFolder); |
||||
ftp.put(url,"presentation.ppt"); |
||||
url = remoteFolderFullPath+"/"+remoteFolder+"/presentation.ppt"; |
||||
|
||||
|
||||
} |
||||
|
||||
PropertyValue[] loadProps = new PropertyValue[2]; |
||||
loadProps[0] = new PropertyValue(); |
||||
loadProps[0].Name = "Hidden"; |
||||
loadProps[0].Value = new Boolean(true); |
||||
|
||||
// open the document
|
||||
XComponent component = xcomponentloader |
||||
.loadComponentFromURL(url, |
||||
"_blank", 0, loadProps); |
||||
|
||||
|
||||
//System.out.println("Document Opened");
|
||||
|
||||
// filter
|
||||
loadProps = new PropertyValue[4]; |
||||
|
||||
// type of image
|
||||
loadProps[0] = new PropertyValue(); |
||||
loadProps[0].Name = "MediaType"; |
||||
loadProps[0].Value = "image/png"; |
||||
|
||||
// Height and width
|
||||
PropertyValue[] filterDatas = new PropertyValue[4]; |
||||
for(int i = 0; i<4 ; i++){ |
||||
filterDatas[i] = new PropertyValue(); |
||||
} |
||||
|
||||
filterDatas[0].Name = "PixelWidth"; |
||||
filterDatas[0].Value = new Integer(width); |
||||
filterDatas[1].Name = "PixelHeight"; |
||||
filterDatas[1].Value = new Integer(height); |
||||
filterDatas[2].Name = "LogicalWidth"; |
||||
filterDatas[2].Value = new Integer(2000); |
||||
filterDatas[3].Name = "LogicalHeight"; |
||||
filterDatas[3].Value = new Integer(2000); |
||||
|
||||
|
||||
XDrawPagesSupplier pagesSupplier = (XDrawPagesSupplier) UnoRuntime |
||||
.queryInterface(XDrawPagesSupplier.class, component); |
||||
//System.out.println(pagesSupplier.toString());
|
||||
XDrawPages pages = pagesSupplier.getDrawPages(); |
||||
int nbPages = pages.getCount(); |
||||
|
||||
|
||||
for (int i = 0; i < nbPages; i++) { |
||||
|
||||
XDrawPage page = (XDrawPage) UnoRuntime.queryInterface( |
||||
com.sun.star.drawing.XDrawPage.class, pages |
||||
.getByIndex(i)); |
||||
|
||||
XNamed xPageName = (XNamed)UnoRuntime.queryInterface(XNamed.class,page); |
||||
|
||||
xPageName.setName("slide"+(i+1)); |
||||
//if(!xPageName.getName().equals("slide"+(i+1)) && !xPageName.getName().equals("page"+(i+1)))
|
||||
//xPageName.setName((i+1)+"-"+xPageName.getName());
|
||||
Object GraphicExportFilter = xMultiComponentFactory |
||||
.createInstanceWithContext( |
||||
"com.sun.star.drawing.GraphicExportFilter", |
||||
xComponentContext); |
||||
XExporter xExporter = (XExporter) UnoRuntime |
||||
.queryInterface(XExporter.class, |
||||
GraphicExportFilter); |
||||
|
||||
XComponent xComp = (XComponent) UnoRuntime |
||||
.queryInterface(XComponent.class, page); |
||||
|
||||
xExporter.setSourceDocument(xComp); |
||||
loadProps[1] = new PropertyValue(); |
||||
loadProps[1].Name = "URL"; |
||||
loadProps[1].Value = remoteFolderFullPath+remoteFolder+"/"+xPageName.getName()+".png"; |
||||
loadProps[2] = new PropertyValue(); |
||||
loadProps[2].Name = "FilterData"; |
||||
loadProps[2].Value = filterDatas; |
||||
loadProps[3] = new PropertyValue(); |
||||
loadProps[3].Name = "Quality"; |
||||
loadProps[3].Value = new Integer(100); |
||||
|
||||
XFilter xFilter = (XFilter) UnoRuntime.queryInterface(XFilter.class, GraphicExportFilter); |
||||
|
||||
xFilter.filter(loadProps); |
||||
System.out.println(xPageName.getName()+".png"); |
||||
|
||||
//System.out.println("Page saved to url "+loadProps[1].Value);
|
||||
|
||||
} |
||||
|
||||
if(!host.equals("localhost")){ |
||||
String[] files = ftp.dir(); |
||||
for (int i = 0; i < files.length; i++){ |
||||
//System.out.println("Transfer of "+files[i]+ "to "+destinationFolder+"/"+files[i]);
|
||||
if(!files[i].equals("presentation.ppt")) |
||||
ftp.get(destinationFolder+"/"+files[i],files[i]); |
||||
ftp.delete(files[i]); |
||||
} |
||||
ftp.chdir(".."); |
||||
ftp.rmdir(remoteFolder); |
||||
ftp.quit(); |
||||
} |
||||
|
||||
//System.out.println("Closing Document");
|
||||
component.dispose(); |
||||
//System.out.println("Document close");
|
||||
|
||||
System.exit(0); |
||||
} |
||||
catch (NoConnectException e) { |
||||
System.out.println(e.toString()); |
||||
e.printStackTrace(); |
||||
System.exit(255); |
||||
} |
||||
catch (Exception e) { |
||||
System.out.println(e.toString()); |
||||
e.printStackTrace(); |
||||
System.exit(255); |
||||
} |
||||
|
||||
} |
||||
} |
||||
catch (Exception e) { |
||||
System.out.println(e.toString()); |
||||
e.printStackTrace(); |
||||
System.exit(255); |
||||
} |
||||
|
||||
} |
||||
|
||||
public static String removeAccents(String text) { |
||||
|
||||
/* |
||||
String newText = Normalizer.decompose(text, false, 0) |
||||
.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");*/ |
||||
/* |
||||
newText = newText.replace('\u00B4','_'); |
||||
newText = newText.replace('\u02CA','_'); |
||||
newText = newText.replace('\u02B9','_'); |
||||
newText = newText.replace('\u02BC','_'); |
||||
newText = newText.replace('\u02B9','_'); |
||||
newText = newText.replace('\u03D8','_'); |
||||
newText = newText.replace('\u0374','_'); |
||||
newText = newText.replace('\u0384','_'); |
||||
newText = newText.replace('\u055A','_'); |
||||
*/ |
||||
/* |
||||
newText = newText.replace('\u2019','_'); |
||||
newText = newText.replace('\u00B4','_'); |
||||
newText = newText.replace('\u055A','_'); |
||||
newText = newText.replace('?','_'); |
||||
newText = newText.replace('\'','_'); |
||||
newText = newText.replace(' ','_'); |
||||
return newText;*/ |
||||
return java.text.Normalizer.normalize(text, java.text.Normalizer.Form.NFD).replaceAll("[\u0300-\u036F]", ""); |
||||
|
||||
} |
||||
|
||||
public boolean handleEvent(Event evt) { |
||||
// Traitement de l'evenement de fin de programme
|
||||
if ( evt.id == evt.WINDOW_DESTROY ) { |
||||
System.exit(0) ; |
||||
return true ; |
||||
} |
||||
return false ; |
||||
} |
||||
} |
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,3 @@ |
||||
{% for item in items %} |
||||
{{ item }} |
||||
{% endfor %} |
||||
@ -0,0 +1,5 @@ |
||||
{% for item in items %} |
||||
<div class="well"> |
||||
{{ item }} |
||||
</div> |
||||
{% endfor %} |
||||
@ -0,0 +1,89 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\CoreBundle\EventListener; |
||||
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent; |
||||
use Symfony\Component\HttpKernel\KernelEvents; |
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
||||
|
||||
use Chamilo\CoreBundle\Controller\LegacyController; |
||||
use Chamilo\CoreBundle\Security\Authorization\Voter\CourseVoter; |
||||
use Chamilo\CoreBundle\Security\Authorization\Voter\SessionVoter; |
||||
use Chamilo\CoreBundle\Security\Authorization\Voter\GroupVoter; |
||||
use Chamilo\CoreBundle\Framework\Container; |
||||
use Doctrine\ORM\EntityManager; |
||||
use Chamilo\UserBundle\Entity\User; |
||||
use Symfony\Component\HttpFoundation\Request; |
||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent; |
||||
use Symfony\Component\DependencyInjection\ContainerInterface; |
||||
use Symfony\Component\HttpKernel\Event\FilterControllerEvent; |
||||
use Chamilo\CourseBundle\Controller\ToolInterface; |
||||
use Chamilo\CoreBundle\Entity\Course; |
||||
use Chamilo\CoreBundle\Entity\Session; |
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
||||
use Symfony\Component\HttpKernel\HttpKernelInterface; |
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException; |
||||
use Chamilo\CourseBundle\Event\CourseAccess; |
||||
use Chamilo\CourseBundle\Event\SessionAccess; |
||||
|
||||
/** |
||||
* Class LocaleListener |
||||
* @package Chamilo\CoreBundle\EventListener |
||||
*/ |
||||
class LocaleListener implements EventSubscriberInterface |
||||
{ |
||||
private $defaultLocale; |
||||
|
||||
/** @var ContainerInterface */ |
||||
protected $container; |
||||
|
||||
/** |
||||
* @param string $defaultLocale |
||||
*/ |
||||
public function __construct($defaultLocale = 'en', $container) |
||||
{ |
||||
$this->defaultLocale = $defaultLocale; |
||||
$this->container = $container; |
||||
} |
||||
|
||||
/** |
||||
* @param GetResponseEvent $event |
||||
*/ |
||||
public function onKernelRequest(GetResponseEvent $event) |
||||
{ |
||||
$request = $event->getRequest(); |
||||
if (!$request->hasPreviousSession()) { |
||||
return; |
||||
} |
||||
|
||||
// try to see if the locale has been set as a _locale routing parameter |
||||
if ($locale = $request->attributes->get('_locale')) { |
||||
$request->getSession()->set('_locale', $locale); |
||||
} else { |
||||
$locale = $this->defaultLocale; |
||||
|
||||
// 2. Check user locale |
||||
// _locale_user is set when user logins the system check UserLocaleListener |
||||
$userLocale = $request->getSession()->get('_locale'); |
||||
if (!empty($userLocale)) { |
||||
$locale = $userLocale; |
||||
} |
||||
|
||||
// if no explicit locale has been set on this request, use one from the session |
||||
$request->setLocale($locale); |
||||
$request->getSession()->set('_locale', $locale); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* @return array |
||||
*/ |
||||
public static function getSubscribedEvents() |
||||
{ |
||||
return array( |
||||
// must be registered before the default Locale listener |
||||
KernelEvents::REQUEST => array(array('onKernelRequest', 15)), |
||||
); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue