Beispiel #1
0
 public static function registerServices()
 {
     Container::register('form_generator', function () {
         require_once 'vendor/php-form-generator/fg/load.php';
     });
     Container::register('pdf', function () {
         include Container::get('params')->getMPdfLocation();
         $pdf = new Pdf();
         //left, right, top, bottom
         $pdf->getMPDF(new mPDF('utf-8', 'A4', '8', '', 25, 15, 20, 20, 10, 10));
         return $pdf;
     });
     Container::register('errors', function () {
         return Errors::getInstance();
     });
     Container::register('params', function () {
         return Parameters::getInstance();
     });
     Container::register('twig', function () {
         $loader = new Twig_Loader_Filesystem(Container::get('params')->getViewDir());
         $cacheConfJson = file_get_contents(Container::get('params')->getConfigDir() . '/' . 'cache.json');
         $cacheConf = json_decode($cacheConfJson, true);
         if ($cacheConf['enable_cache']) {
             return new Nmzd_Twig_Environment($loader, array('cache' => Container::get('params')->getCacheDir()));
         } else {
             return new Nmzd_Twig_Environment($loader);
         }
     });
     Container::register('twigStr', function () {
         $loader = new Twig_Loader_String();
         $twig = new Twig_Environment($loader);
         $function = new Twig_SimpleFunction("form_text", function ($name, $id, $value = "", $class = "form_text") {
             require_once 'Src/Modules/Ajax/Libs/PhpLiveX/PHPLiveX.php';
             $ajax = new \PHPLiveX();
             require_once 'Src/Modules/Ajax/Controllers/MainController.php';
             $myClass = new \Src\Modules\Ajax\Controllers\MainController();
             $ajax->AjaxifyObjectMethods(array('myClass' => array('validateEmail')));
             $ajax->Run();
             echo '<input type="text" name="' . $name . '" id="' . $id . '" value="' . $value . '" class="' . $class . '">';
         });
         $twig->addFunction($function);
         return $twig;
     });
     Container::register('theme_settings', function () {
         $themeData = Container::get('params')->getThemeData();
         require_once 'Src/Views/Themes/' . $themeData['theme'] . '/ThemeSettings.php';
         $themeSettings = 'Src\\Views\\Themes\\' . $themeData['theme'] . '\\ThemeSettings';
         $themeSettingsInstance = new $themeSettings();
         $themeSettings = $themeSettingsInstance->getSettings();
         return $themeSettings;
     });
     Container::register('router', function () {
         return new \App\Core\Router();
     });
 }
 public function crawler(Request $request)
 {
     $pdfs = Pdf::all();
     // $pricelists = Pdf::all();
     $result = "<div class='crawler_list'><div class='row'>";
     $result = $result . "<h4>PDF</h4><ul class='list-crawler'>";
     foreach ($pdfs as $pdf) {
         $result = $result . "<li>";
         $retailers = \DB::table('retailers')->where('id', '=', $pdf->retailer_id)->get();
         foreach ($retailers as $retailer) {
             $result = $result . $retailer->retailer_name;
         }
         $result = $result . $pdf->crawler->id;
         $result = $result . "</li>";
     }
     $result = $result . "</ul></div><div class='row'>";
     $websites = Website::all();
     // $pricelists = Pdf::all();
     $result = $result . "<button type='button' class='btn btn-xs' id='progress'>Progress</button>" . "<h4>WEBSITE</h4>";
     foreach ($websites as $website) {
         // $retailers = \DB::table('retailers')->where('id', '=', $pdf->pricelist->retailer_id )->get();
         // foreach ($retailers as $retailer) {
         //   $result = $result. $retailer->retailer_name;
         // }
         $result = $result . $website->crawler->id;
     }
     $result = $result . "</div></div>";
     return $result;
     // foreach ($pricelists as $pricelist) {
     //
     // }
 }
 public function destroyPdf($id)
 {
     $pdfs = Pdf::findOrFail($id);
     $pdfs->delete();
     \Storage::delete($pdfs->nombre);
     return "El PDF : " . $pdfs->nombre . " fue eliminado";
 }
 public function destroyPdf($id)
 {
     $pdfs = Pdf::findOrFail($id);
     if (\Gate::denies('eliminar', $pdfs)) {
         $mensaje = "Acceso no autorizado, tu solo puedes acceder a tu proyecto";
         \Session::flash('mensaje', $mensaje);
         return redirect()->route('estudiante.index');
     }
     $pdfs->delete();
     \Storage::delete($pdfs->nombre);
     return "El PDF : " . $pdfs->nombre . " fue eliminado";
 }