Ejemplo n.º 1
0
 /**
  * @Route /genui/list
  */
 public function listAction()
 {
     $dir = \Raptor\Core\Location::get(\Raptor\Core\Location::APP);
     $this->app->contentType(\Raptor\Raptor::JSON);
     return file_get_contents($dir . "/conf/ui.templates.json");
     return $this->render('@systemBundle/ui/index.html.twig');
 }
Ejemplo n.º 2
0
 /**
  * @Route /cleanajax
  * @RouteName _raptor_clean_ajax
  */
 public function cleanAjaxAction()
 {
     $cache = \Raptor\Core\Location::get(\Raptor\Core\Location::CACHE);
     \Raptor\Util\Files::delete($cache . '/7u136');
     $this->app->getConfigurationLoader()->forceLoad();
     return "OK";
 }
Ejemplo n.º 3
0
 public function execute()
 {
     $src = \Raptor\Core\Location::get(\Raptor\Core\Location::SRC);
     $bundles = glob($src . '/*Bundle.php*');
     $this->detected = array_merge_recursive($this->detected, $bundles);
     foreach (glob($src . '/*') as $path) {
         if (is_dir($path)) {
             $this->look($path);
         }
     }
 }
Ejemplo n.º 4
0
 public static function autoload($class)
 {
     if (false == strpos($class, 'Bundle')) {
         return;
     }
     if (false !== strpos($class, 'Doctrine')) {
         return;
     }
     if (false !== strpos($class, 'Raptor')) {
         return;
     }
     $bundle = \Raptor\Core\Location::get(\Raptor\Core\Location::SRC) . '/';
     if (file_exists($file = $bundle . str_replace('_', '/', str_replace('\\', '/', $class)) . '.php')) {
         require_once $file;
     }
 }
Ejemplo n.º 5
0
 /**
  * Los archivos copiados seran aquellos contenidos en el directrorio Resources del bundle
  * 
  * @param string $bundle El bundle que se copiara los recursos
  * @param boolean $extPreCompile Si este parametro es true, se ejecutaram ademas una rutina de busqueda dentro de los recursos para la compilacion de recursos Extjs
  */
 public static function run($bundle, $extPreCompile = false)
 {
     $class = new \Wingu\OctopusCore\Reflection\ReflectionClass($bundle);
     $location = dirname($class->getFileName());
     if (file_exists($location . DIRECTORY_SEPARATOR . 'Resources')) {
         $fileBundle = str_replace('Bundle', '', $class->getNamespaceName());
         $fileBundle = str_replace('\\', '/', $fileBundle);
         $web = \Raptor\Core\Location::get(\Raptor\Core\Location::WEBBUNDLES);
         if (!file_exists($web . '/' . $fileBundle)) {
             mkdir($web . '/' . $fileBundle, 0777, true);
         }
         \Raptor\Util\Files::copy($location . DIRECTORY_SEPARATOR . 'Resources', $web . '/' . $fileBundle);
         if ($extPreCompile) {
             Extjs::preCompileApp($web . '/' . $fileBundle);
         }
     }
 }
Ejemplo n.º 6
0
 public static function serverAsset($dev)
 {
     $headers = Raptor::getRequest()->header;
     $route = $headers->get('PATH_INFO');
     $web_location = Location::get('web_bundles');
     $file = $web_location . $route;
     $js = new AssetCollection(array(new GlobAsset($file)));
     // the code is merged when the asset is dumped
     $response = new Response($js->dump());
     if (preg_match("/(\\.css)\$/", $route)) {
         $response->addHeader('Content-Type', 'text/css');
     } else {
         $response->addHeader('Content-Type', 'application/javascript');
     }
     if ($dev == FALSE) {
         $response->setCache(true, 3, true);
     }
     $response->sendResponse();
     exit;
 }
Ejemplo n.º 7
0
 function __construct()
 {
     parent::__construct();
     require_once __DIR__ . '/../../Twig/lib/Twig/Autoloader.php';
     Twig_Autoloader::register();
     $loader = new \Twig_Loader_Filesystem();
     $locations = \Raptor\Raptor::getInstance()->getConfigurationLoader()->getOptions();
     $templates = $locations['location'];
     foreach ($templates as $key => $value) {
         if (!file_exists($value . '/Views')) {
             mkdir($value . '/Views');
         }
         $loader->addPath($value . '/Views', $key);
     }
     //        if (\Raptor\Raptor::getInstance()->getMode() == 'development') {
     if (\Raptor\Raptor::getInstance()->config('debug')) {
         $this->twig = new Twig_Environment($loader, array());
     } else {
         $this->twig = new Twig_Environment($loader, array('cache' => \Raptor\Core\Location::get(\Raptor\Core\Location::CACHE) . '/7u136'));
     }
     $this->register();
 }
Ejemplo n.º 8
0
 /**
  * 
  * Crea un archivo ZIP de la ruta especificada, puede ser un archivo o directorio
  * Devuelve TRUE si el archivo fue comprimido correctamente, FALSE en caso contrario
  * @param string $path archivo o directorio a comprimir
  * @return boolean
  */
 public function create($path)
 {
     $path = realpath($path);
     $relative = str_replace('\\', '/', $path);
     $relative = explode('/', $relative);
     $relative = $relative[count($relative) - 1];
     $location = \Raptor\Core\Location::get(\Raptor\Core\Location::CACHE);
     $output = false;
     if ($this->name == NULL) {
         $this->name = $location . "/temp_" . rand(10, 900000) . '.zip';
         $output = true;
     }
     $res = $this->zip->open($this->name, \ZipArchive::CREATE);
     if ($res === TRUE) {
         if (is_dir($path)) {
             foreach (glob($path . '/*') as $value) {
                 if (is_dir($value)) {
                     $this->add($value, $relative);
                 } else {
                     $name = strstr($value, $relative);
                     $this->zip->addFile($value, $name);
                 }
             }
         } else {
             $this->zip->addFile($path);
         }
         $this->zip->close();
         if ($output) {
             $this->content = file_get_contents($this->name);
             @unlink($this->name);
         }
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 9
0
 /**
  * Eejecuta la rutina de minificacion
  * 
  * Los tipos de recursos aceptados son:
  * Resources:CSS
  * Resources:JS
  * Resources:NONE
  * 
  * @param int $compile El tipo de recurso a minificar
  */
 public function compile($compile = Resources::NONE)
 {
     require_once __DIR__ . '/cssmin-v3.0.1.php';
     require_once __DIR__ . '/jsmin.php';
     $asset = new AssetCollection();
     $this->resources->each(function ($key, $value) use(&$asset) {
         if ($value->flag) {
             $asset->add(new FileAsset($value->asset));
         } else {
             $asset->add(new GlobAsset($value->asset));
         }
     });
     if ($compile == Resources::JS) {
         $asset->ensureFilter(new \Assetic\Filter\JSMinFilter());
     }
     if ($compile == Resources::CSS) {
         $asset->ensureFilter(new \Assetic\Filter\CssMinFilter());
     }
     // the code is merged when the asset is dumped
     $bundles = \Raptor\Core\Location::get('web_bundles');
     if (!file_exists($bundles . $this->bundleName)) {
         mkdir($bundles . $this->bundleName, 0777, true);
     }
     if ($this->name[0] == '/' or $this->name[0] == DIRECTORY_SEPARATOR) {
         unset($this->name[0]);
     }
     $dir = dirname($bundles . $this->bundleName . '/' . $this->name);
     if (!file_exists($dir)) {
         mkdir($dir, 0777, true);
     }
     if ($this->force == true) {
         file_put_contents($bundles . $this->bundleName . '/' . $this->name, $asset->dump());
     } else {
         if (!file_exists($bundles . $this->bundleName . '/' . $this->name)) {
             file_put_contents($bundles . $this->bundleName . '/' . $this->name, $asset->dump());
         }
     }
 }
Ejemplo n.º 10
0
 /**
  * Establece directivas y rutinas de proteccion contra ataques
  * [USADA POR EL SISTEMA]
  */
 public static function directives()
 {
     $options = \Raptor\Raptor::getInstance()->getConfigurationLoader()->getConfOption();
     if (isset($options['raptor']['session_expire'])) {
         ini_set('session.cookie_lifetime', intval($options['raptor']['session_expire']));
     } else {
         ini_set('session.cookie_lifetime', 0);
     }
     ini_set('session.cookie_httponly', true);
     ini_set('session.use_only_cookies', true);
     $savePath = \Raptor\Core\Location::get(\Raptor\Core\Location::APP) . '/Sessions';
     if (!file_exists($savePath)) {
         @mkdir($savePath);
     }
     session_save_path($savePath);
     if (isset($options['raptor']['proxy'])) {
         $parts = explode('@', $options['raptor']['proxy']);
         $header = array();
         $proxy = '';
         if (count($parts) == 2) {
             $auth = base64_encode($parts[0]);
             $header[] = "Proxy-Authorization: Basic {$auth}";
             $proxy = $parts[1];
         } else {
             $proxy = $parts[0];
         }
         stream_context_set_default(array('http' => array('proxy' => "tcp://{$proxy}", 'request_fulluri' => true, 'method' => "GET", 'user_agent' => 'Mozilla/5.0', 'header' => $header)));
     }
 }
Ejemplo n.º 11
0
<?php

/*
 * Este archivo realiza el proceso de actualizacion de componentes
 * y clases que no pertenecen al paquete de clases de Raptor
 * Utilizados para realizar mantenimeinto y actualizacion a Slim, los
 * Bundles utilitarios y recursos.
 */
$app = Raptor\Raptor::getInstance();
$lib = \Raptor\Core\Location::get(\Raptor\Core\Location::APP) . '/../libs';
/**
 * Updates files
 * array(
 *      array('file_to_copy','file_to_override')
 * )
 */
$files = array(array('/BundleImporter.php', '/../src/Raptor2/InstallerBundle/Importer/BundleImporter.php'), array('/Slim.php', '/Slim/Slim.php'), array('/autoload.php', '/autoload.php'));
foreach ($files as $value) {
    if (file_exists($lib . $value[1]) and file_exists(__DIR__ . $value[0])) {
        Raptor\Util\Files::delete($lib . $value[1]);
        Raptor\Util\Files::copy(__DIR__ . $value[0], dirname($lib . $value[1]));
        Raptor\Util\Files::delete(__DIR__ . $value[0]);
    }
}
/**
 * Copy new ones
 * array(
 *      array('file_to_copy','directory_to_copy')
 * )
 */
$files_new = array();
 /**
  * @Route /genbundle/export
  */
 public function exportAction()
 {
     $options = $this->app->getConfigurationLoader()->getBundlesLocation();
     if (isset($options[$this->app->request()->get('name')])) {
         $location = \Raptor\Core\Location::get(\Raptor\Core\Location::CACHE);
         if ($location . "/Installer") {
             @mkdir($location . "/Installer/created", 0777, true);
         }
         $file = rand(10, 100000);
         $zip = new \Raptor\Util\Zip($location . "/Installer/created/" . $file . ".zip");
         $zip->create($options[$this->app->request()->get('name')]);
         $this->app->response()->headers()->set('Content-Description', 'File Transfer');
         $this->app->response()->headers()->set('Content-Disposition', 'attachment; filename="' . $this->app->request()->get('name') . '.zip"');
         $this->app->contentType(\Raptor\Raptor::ZIP);
         $this->app->response()->headers()->set('Content-Transfer-Encoding', 'binary');
         $content = file_get_contents($location . "/Installer/created/" . $file . ".zip");
         @unlink($location . "/Installer/created/" . $file . ".zip");
         return $content;
     }
 }
Ejemplo n.º 13
0
 /**
  * 
  * Realiza una operacion de salvado, salva los datos y el estado especificado
  */
 public function save()
 {
     $cache = Location::get(\Raptor\Core\Location::CACHE);
     if (!file_exists($cache . DIRECTORY_SEPARATOR . $this->name)) {
         mkdir($cache . DIRECTORY_SEPARATOR . $this->name);
     }
     $this->instanceCache = NULL;
     file_put_contents($cache . DIRECTORY_SEPARATOR . $this->name . DIRECTORY_SEPARATOR . '52753' . $this->name, serialize($this), LOCK_EX);
 }
Ejemplo n.º 14
0
 public static function getMetainformation($name = NULL)
 {
     $modules = glob(__DIR__ . '/../BundleStorage/meta/*.json');
     $metaInformation = array();
     foreach ($modules as $filename) {
         $metaObj = json_decode(utf8_encode(file_get_contents($filename)), true);
         if ($metaObj) {
             $meta = array('name' => '', 'description' => '', 'file' => '');
             if (isset($metaObj['name']) and $metaObj['name']) {
                 $meta['name'] = $metaObj['name'];
             } else {
                 continue;
             }
             if (isset($metaObj['description'])) {
                 $meta['description'] = $metaObj['description'];
             }
             if (isset($metaObj['author'])) {
                 $meta['author'] = $metaObj['author'];
             }
             if (isset($metaObj['file']) and $metaObj['file'] and file_exists(__DIR__ . '/../BundleStorage/files/' . $meta['file'])) {
                 $meta['file'] = $metaObj['file'];
             } else {
                 continue;
             }
             if (isset($metaObj['image'])) {
                 $web = \Raptor\Core\Location::get(\Raptor\Core\Location::WEBBUNDLES);
                 if (file_exists($web . '/' . $metaObj['image'])) {
                     $meta['image'] = $metaObj['image'];
                 } else {
                     $meta['image'] = 0;
                 }
             } else {
                 $meta['image'] = 0;
             }
             //Validate if the file exists
             //if(__DIR__.'/../BundleStorage/files/'.$meta['file'])
             $meta['type'] = 'local';
             $metaInformation[] = $meta;
             if ($name != NULL and $name == $meta['name']) {
                 return $meta;
             }
         }
     }
     if ($name != NULL) {
         return false;
     }
     return $metaInformation;
 }
Ejemplo n.º 15
0
 /**
  * @Route /resources/publisher/clear
  */
 public function clearAction($request)
 {
     $bundleName = $request->post('bundles');
     $bundleName = json_decode($bundleName);
     $bundles = $this->app->getConfigurationLoader()->getBundlesSpecifications();
     $web = \Raptor\Core\Location::get(\Raptor\Core\Location::WEBBUNDLES);
     $console = array();
     foreach ($bundleName as $value) {
         if (isset($bundles[$value])) {
             $fileBundle = str_replace('Bundle', '', $bundles[$value]['namespace']);
             $fileBundle = str_replace('\\', '/', $fileBundle);
             \Raptor\Util\Files::delete($web . '/' . $fileBundle);
             $console[] = "The resources {$value} are deleted";
             if (count(glob($web . '/' . $fileBundle . '/../*')) == 0) {
                 rmdir($web . '/' . $fileBundle . '/..');
             }
         }
     }
     return $this->show('The resources was deleted', true, \Raptor\Bundle\Controller\Controller::INFO, array('actions' => $console));
 }
Ejemplo n.º 16
0
 /**
  * Generate the model class for Raptor
  * Genera las clases modelos para las clases schema especificadas
  * Los modelos seran generados en el namespace especificado
  * Tenga en cuenta que un SchemaClass no es lo mismo que los nombres
  * de las tablas, es una representacion que brinda doctrine para tablas en la base de datos
  * 
  * $this->getStore()->generateClasses('\example\exampleBundle','Persona');
  * 
  * @param string $namespace el namespace del bundle donde seran creados los modelos
  * @param array $schemaClass un array con todos los schemaClass que seran generados los modelos
  */
 public function generateClasses($namespace, $schemaClass)
 {
     $clases = $schemaClass;
     // custom datatypes (not mapped for reverse engineering)
     $this->entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('set', 'string');
     $this->entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
     // fetch metadata
     $driver = new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($this->entityManager->getConnection()->getSchemaManager());
     $this->entityManager->getConfiguration()->setMetadataDriverImpl($driver);
     $cmf = new \Doctrine\ORM\Tools\DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($this->entityManager);
     // we must set the EntityManager
     $classes = $driver->getAllClassNames();
     $metadata = array();
     $rep = new EntityRepositoryGenerator();
     foreach ($clases as $class) {
         //any unsupported table/schema could be handled here to exclude some classes
         if (true) {
             $meta = $cmf->getMetadataFor($class);
             $association = new ItemList($meta->associationMappings);
             $me = $this;
             $association->each(function ($k, $v, $l) use(&$me) {
                 $v['targetEntity'] = $me->translateSchemas($v['targetEntity']);
                 $v['sourceEntity'] = $me->translateSchemas($v['sourceEntity']);
                 $l->set($k, $v);
             });
             $meta->associationMappings = $association->getArray();
             $real = $this->translateSchemas($class);
             $meta->name = $namespace . $this->namespaceSeparator . 'Model' . $this->namespaceSeparator . 'Entity' . $this->namespaceSeparator . $real;
             $meta->namespace = $namespace . $this->namespaceSeparator . 'Model' . $this->namespaceSeparator . 'Entity';
             // $meta->namespace='Entities\\'.$class;
             $meta->customRepositoryClassName = $namespace . $this->namespaceSeparator . 'Model' . $this->namespaceSeparator . 'Repository' . $this->namespaceSeparator . $real . 'Repository';
             //TODO buscar entidades ya creadas
             foreach ($meta->associationMappings as $key => $value) {
                 $names = $this->entityManager->getConfiguration()->getEntityNamespaces();
                 $target = $meta->associationMappings[$key]['targetEntity'];
                 $found = false;
                 foreach ($names as $routes) {
                     if ($routes[0] == '\\') {
                         $bundleRoute = substr($routes, 1);
                     } else {
                         $bundleRoute = $routes;
                     }
                     $fileroute = __DIR__ . "/../../../src/" . str_replace('\\', DIRECTORY_SEPARATOR, $bundleRoute);
                     $fileroute .= DIRECTORY_SEPARATOR . $target . ".php";
                     if (file_exists($fileroute)) {
                         $found = true;
                         $target = $bundleRoute . $this->namespaceSeparator . $value['targetEntity'];
                     }
                 }
                 if ($found) {
                     //$target = $namespace . $this->namespaceSeparator . 'Entity' . $this->namespaceSeparator . $value['targetEntity'];
                     $meta->associationMappings[$key]['targetEntity'] = $target;
                 } else {
                     $meta->associationMappings[$key]['targetEntity'] = $namespace . $this->namespaceSeparator . 'Model' . $this->namespaceSeparator . 'Entity' . $this->namespaceSeparator . $value['targetEntity'];
                 }
             }
             $metadata[] = $meta;
             $rep->writeEntityRepositoryClass($namespace . $this->namespaceSeparator . 'Model' . $this->namespaceSeparator . 'Repository' . $this->namespaceSeparator . $real . 'Repository', \Raptor\Core\Location::get(\Raptor\Core\Location::SRC));
         }
     }
     $generator = new EntityGenerator();
     $generator->setAnnotationPrefix('');
     // edit: quick fix for No Metadata Classes to process
     $generator->setUpdateEntityIfExists(true);
     // only update if class already exists
     $generator->setRegenerateEntityIfExists(true);
     // this will overwrite the existing classes
     $generator->setGenerateStubMethods(true);
     $generator->setGenerateAnnotations(true);
     //$y=new Doctrine\ORM\Tools\Export\Driver\YamlExporter(__DIR__ . '/Entities/yml');
     //$y->setMetadata($metadata);
     //$y->export();
     $generator->generate($metadata, \Raptor\Core\Location::get(\Raptor\Core\Location::SRC));
 }
Ejemplo n.º 17
0
 private function checkForGhosts()
 {
     $app = \Raptor\Core\Location::get(\Raptor\Core\Location::APP);
     $src = \Raptor\Core\Location::get(\Raptor\Core\Location::SRC);
     $installed = $this->options['bundles'] = \Raptor\Yaml\Yaml::parse($app . '/conf/bundles.yml');
     $detected = $this->monitor->getDetection();
     /**
      * Ghost detection
      */
     foreach ($installed as $bundle) {
         $detect = false;
         foreach ($detected as $value) {
             if ($bundle === $value) {
                 $detect = true;
                 break;
             }
         }
         if ($detect == false) {
             $this->autoinstaller[] = "<h3>A ghost bundle <b>({$bundle})</b> was detected and removed !!</h3>";
             $this->unRegisterBundle($bundle);
         }
     }
     /**
      * AutoBundle-Installer
      */
     foreach ($detected as $bundle) {
         $detect = false;
         foreach ($installed as $value) {
             if ($bundle === $value) {
                 $detect = true;
                 break;
             }
         }
         if ($detect == false) {
             $bundleRoute = $src . '' . str_replace('\\', '/', $bundle) . '';
             $div = explode('/', $bundleRoute);
             unset($div[count($div) - 1]);
             $bundleRoute = join('/', $div);
             $ruta = $bundleRoute . '/Manifiest/install.json';
             if (file_exists($ruta)) {
                 $meta = json_decode(utf8_encode(file_get_contents($ruta)), true);
                 if (!isset($meta['installed']) or isset($meta['installed']) and $meta['installed'] == 0) {
                     $meta['installed'] = 1;
                     if (isset($meta['installScript']) and file_exists($bundleRoute . $meta['installScript'])) {
                         $this->callbackInstall($bundleRoute . $meta['installScript']);
                     }
                     file_put_contents($ruta, json_encode($meta, JSON_PRETTY_PRINT));
                     $this->registerBundle($bundle);
                     $this->autoinstaller[] = "<h3>A new bundle <b>{$bundle}</b> was detected and installed !!</h3>";
                 }
             }
         }
     }
 }