Exemplo n.º 1
0
 function __construct()
 {
     $this->formBuilder = Admin::instance()->formBuilder;
     $this->items = [];
     $this->inlineItems = [];
     $this->groups = [];
 }
Exemplo n.º 2
0
 /**
  *
  */
 function __construct()
 {
     parent::__construct('control-column', '');
     $admin = Admin::instance();
     $this->router = $admin->router;
     $this->formBuilder = $admin->formBuilder;
 }
Exemplo n.º 3
0
 /**
  *
  */
 function __construct($name, $label = null)
 {
     parent::__construct($name, $label);
     $this->sortable = false;
     $admin = Admin::instance();
     $this->router = $admin->router;
     $this->formBuilder = $admin->formBuilder;
 }
Exemplo n.º 4
0
 public function render()
 {
     AssetManager::addScript(Admin::instance()->router->routeToAsset('ckeditor/ckeditor.js'));
     if (!isset($this->attributes['class'])) {
         $this->attributes['class'] = '';
     }
     $this->attributes['class'] .= ' ckeditor';
     return parent::render();
 }
Exemplo n.º 5
0
 /**
  * @param null $name
  * @param null $label
  */
 function __construct($name = null, $label = null)
 {
     $this->formBuilder = Admin::instance()->formBuilder;
     $this->label = $label;
     $this->name = $name;
     if ($modelItem = ModelItem::$current) {
         $this->form = $modelItem->getForm();
     }
 }
Exemplo n.º 6
0
 /**
  * @param $assets
  * @return array
  */
 protected static function assets($assets)
 {
     return array_map(function ($asset) {
         if (strpos($asset, 'admin::') !== false) {
             $asset = str_replace('admin::', '', $asset);
             return Admin::instance()->router->routeToAsset($asset);
         }
         return $asset;
     }, array_unique($assets));
 }
Exemplo n.º 7
0
 function __construct($name, $label = null)
 {
     $this->name = $name;
     if (is_null($label)) {
         $this->label = ucwords(str_replace('_', ' ', $name));
     } else {
         $this->label = $label;
     }
     $this->sortable(false);
     $this->htmlBuilder = Admin::instance()->htmlBuilder;
 }
Exemplo n.º 8
0
 /**
  *
  */
 public function boot()
 {
     $this->loadViewsFrom(__DIR__ . '/../../views', 'admin');
     $this->loadTranslationsFrom(__DIR__ . '/../../lang', 'admin');
     $this->mergeConfigFrom(__DIR__ . '/../../config/config.php', 'admin');
     $this->publishes([__DIR__ . '/../../config/config.php' => config_path('admin.php')], 'config');
     $this->publishes([__DIR__ . '/../../migrations/' => base_path('/database/migrations')], 'migrations');
     $this->publishes([__DIR__ . '/../../../public/' => public_path('packages/sleeping-owl/admin/')], 'assets');
     app('SleepingOwl\\Admin\\Helpers\\StartSession')->run();
     Admin::instance()->router->registerRoutes();
     $this->registerValidator();
     $this->registerFilters();
 }
Exemplo n.º 9
0
 /**
  * @param $assets
  * @return array
  */
 protected static function assets($assets)
 {
     return array_map(function ($asset) {
         if (strpos($asset, 'admin::') !== false) {
             $asset = str_replace('admin::', '', $asset);
             $pathToAsset = public_path() . DIRECTORY_SEPARATOR . 'packages' . DIRECTORY_SEPARATOR . 'sleeping-owl' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . $asset;
             if (file_exists($pathToAsset)) {
                 $asset .= '?ver=' . filemtime($pathToAsset);
             }
             return Admin::instance()->router->routeToAsset($asset);
         }
         return $asset;
     }, array_unique($assets));
 }
Exemplo n.º 10
0
 /**
  * @param $instance
  * @param int $totalCount
  * @return string
  * @throws \SleepingOwl\Admin\Exceptions\ModelNotFoundException
  */
 public function render($instance, $totalCount)
 {
     $filterValue = $this->valueFromInstance($instance, $this->value);
     $modelItem = Admin::instance()->models->modelWithClassname($this->model);
     $url = $this->router->routeToModel($modelItem->getAlias(), [$this->name => $filterValue]);
     if ($this->model === $this->modelItem->getModelClass()) {
         $class = 'fa-filter';
         $title = Lang::get('admin::lang.table.filter');
     } else {
         $class = 'fa-arrow-circle-o-right';
         $title = Lang::get('admin::lang.table.filter-goto');
     }
     $content = $this->htmlBuilder->tag('i', ['class' => ['fa', $class], 'data-toggle' => 'tooltip', 'title' => $title]);
     return $this->htmlBuilder->tag('a', ['href' => $url], $content);
 }
Exemplo n.º 11
0
 protected function setUp()
 {
     parent::setUp();
     $app = Mockery::mock('\\Illuminate\\Foundation\\Application');
     $app->shouldReceive('make')->with('path');
     Facade::setFacadeApplication($app);
     Mockery::mock('\\Illuminate\\Html\\HtmlBuilder');
     Mockery::mock('\\Illuminate\\Html\\FormBuilder');
     $this->htmlBuilder = Mockery::mock('\\SleepingOwl\\Html\\HtmlBuilder');
     $formBuilder = Mockery::mock('\\SleepingOwl\\Html\\FormBuilder');
     $finder = Mockery::mock('\\Symfony\\Component\\Finder\\Finder');
     $config = Mockery::mock('\\Illuminate\\Config\\Repository');
     $this->illuminateRouter = Mockery::mock('\\Illuminate\\Routing\\Router');
     $this->urlGenerator = Mockery::mock('\\Illuminate\\Routing\\UrlGenerator');
     $filesystem = Mockery::mock('\\Illuminate\\Filesystem\\Filesystem');
     $this->htmlBuilder->shouldReceive('tag')->andReturnUsing(function ($tag, $attributes = null, $content = null) {
         return '<' . $tag . '>' . $content . '</' . $tag . '>';
     });
     $config->shouldReceive('get')->with('imagecache::route')->andReturn('img/cache');
     $config->shouldReceive('get')->with('admin::title')->andReturn('admin title');
     $config->shouldReceive('get')->with('admin::index')->andReturn(null);
     $config->shouldReceive('get')->with('admin::prefix')->andReturn('test_admin');
     $config->shouldReceive('get')->with('admin::bootstrapDirectory')->andReturn('admin');
     $finder->shouldReceive('create')->andReturnSelf();
     $finder->shouldReceive('files')->andReturnSelf();
     $finder->shouldReceive('name')->andReturnSelf();
     $finder->shouldReceive('in')->andReturnSelf();
     $finder->shouldReceive('sort');
     $finder->shouldReceive('getIterator')->andReturnUsing(function () {
         return new ArrayIterator(['file.php']);
     });
     $filesystem->shouldReceive('requireOnce');
     $filesystem->shouldReceive('isDirectory')->andReturn(true);
     $this->urlGenerator->shouldReceive('route')->with('sleeping-owl-admin.home')->andReturn('route-home');
     $this->urlGenerator->shouldReceive('route')->with('sleeping-owl-admin.wildcard', Mockery::any())->andReturn('route-wildcard');
     $this->urlGenerator->shouldReceive('route')->with('sleeping-owl-admin.table.table', ['menu_item_test_models'])->andReturn('route-to-model');
     $app->shouldReceive('make')->with('\\SleepingOwl\\Admin\\Admin')->andReturnUsing(function () use($formBuilder, $finder, $config, $filesystem) {
         return new Admin($this->htmlBuilder, $formBuilder, $finder, $config, $this->illuminateRouter, $this->urlGenerator, $filesystem);
     });
     $this->admin = Admin::instance();
 }
Exemplo n.º 12
0
 /**
  * Register all admin routes
  */
 public function registerRoutes()
 {
     $this->registerAssetsRoutes();
     $this->registerAuthRoutes();
     $this->registerImageCacheRoute();
     $models = Admin::instance()->models->getAllAliases();
     $this->laravelRouter->group(['prefix' => $this->prefix, 'before' => $this->getBeforeFilters(), 'namespace' => 'SleepingOwl\\Admin\\Controllers'], function () use($models) {
         if (empty($models)) {
             $models = ['__empty_models__'];
         }
         $this->laravelRouter->group(['where' => ['model' => implode('|', $models)]], function () {
             foreach (static::$modelRoutes as $route) {
                 $url = $route['url'];
                 $action = $route['action'];
                 $method = $route['method'];
                 $controller = isset($route['controller']) ? $route['controller'] : 'AdminController';
                 $this->laravelRouter->{$method}($url, ['as' => $this->routePrefix . '.table.' . $action, 'uses' => $controller . '@' . $action]);
             }
         });
         $wildcardRoute = $this->laravelRouter->any('{wildcard?}', ['as' => $this->routePrefix . '.wildcard', 'uses' => 'AdminController@getWildcard'])->where('wildcard', '.*');
         $this->setRoutePriority($wildcardRoute, 0);
     });
 }
Exemplo n.º 13
0
 /**
  * @return \SleepingOwl\Admin\Models\ModelItem
  * @throws \SleepingOwl\Admin\Exceptions\ModelNotFoundException
  */
 protected function getModelItem()
 {
     return Admin::instance()->models->modelWithClassname($this->modelClass);
 }
Exemplo n.º 14
0
 public static function textarea($name, $label, $value = null, array $options = [])
 {
     $options['id'] = uniqid();
     if (!empty($options['data-editor'])) {
         switch ($options['data-editor']) {
             case FormItem\Textarea::EDITOR_WYSIHTML:
                 AssetManager::addStyle(Admin::instance()->router->routeToAsset('css/bootstrap-wysihtml5.css'));
                 AssetManager::addScript(Admin::instance()->router->routeToAsset('js/wysihtml5-0.3.0.js'));
                 AssetManager::addScript(Admin::instance()->router->routeToAsset('js/bootstrap-wysihtml5.js'));
                 break;
         }
     }
     AssetManager::addScript(Admin::instance()->router->routeToAsset('js/parsley.min.js'));
     AssetManager::addScript(Admin::instance()->router->routeToAsset('js/parsley-init.js'));
     return view('admin::_partials/form_elements/textarea')->with('name', $name)->with('label', $label)->with('value', $value)->with('options', $options)->with('id', $options['id'])->with('error', self::getError($name));
 }
Exemplo n.º 15
0
 public function __construct(BaseMenuItem $menuItem)
 {
     $this->menuItem = $menuItem;
     $admin = Admin::instance();
     $this->htmlBuilder = $admin->htmlBuilder;
 }
Exemplo n.º 16
0
 /**
  * @return string
  */
 public function renderTableAttributes()
 {
     $attributes = [];
     if (!$this->orderable) {
         $attributes['data-ordering'] = 'false';
     }
     $attributes['data-statesave'] = $this->stateSave();
     if ($this->isAsync()) {
         $url = Admin::instance()->router->routeToTable($this->getAlias(), \Input::all());
         $attributes['data-ajax'] = $url;
     }
     return $this->htmlBuilder->attributes($attributes);
 }
Exemplo n.º 17
0
 /**
  *
  */
 function __construct()
 {
     $this->admin = Admin::instance();
     $this->admin_router = $this->admin->router;
 }
Exemplo n.º 18
0
 /**
  * Bind current template
  */
 protected function registerTemplate()
 {
     app()->bind('adminTemplate', function () {
         return Admin::instance()->template();
     });
 }
Exemplo n.º 19
0
 /**
  * @param string $wildcard
  * @return View
  * @throws \Exception
  */
 public function getWildcard($wildcard = '/')
 {
     $title = null;
     $content = '';
     if ($menuItem = Admin::instance()->menu->itemWithUrl($wildcard)) {
         if ($action = $menuItem->getUses()) {
             list($controller, $action) = explode('@', $action);
             $content = app($controller)->{$action}();
             if ($content instanceof Response) {
                 return $content;
             }
             $title = $wildcard !== '/' ? $menuItem->getLabel() : null;
         } else {
             throw new \Exception('You need to provide valid action for this route.');
         }
     } elseif ($wildcard !== '/') {
         App::abort(404);
     }
     return $this->makeView('page', compact('title', 'content'));
 }
Exemplo n.º 20
-1
 /**
  * @param string $name
  * @param string $label
  */
 function __construct($name, $label = null)
 {
     $this->name = $name;
     $this->label = is_null($label) ? ucwords(str_replace('_', ' ', $name)) : $label;
     $this->htmlBuilder = Admin::instance()->htmlBuilder;
     $this->modelItem = ModelItem::$current;
 }