コード例 #1
0
ファイル: Action.php プロジェクト: greysama/admin
 /**
  * @param $instance
  * @return string
  */
 protected function button($instance)
 {
     if (!is_null($this->url)) {
         if (is_callable($this->url)) {
             $callback = $this->url;
             $url = $callback($instance);
         } else {
             $url = strtr($this->url, [':id' => $instance->id]);
         }
     } else {
         $url = $this->router->routeToTable($this->modelItem->getAlias(), ['action' => $this->name, 'id' => $instance->id]);
     }
     $attributes = ['class' => 'btn btn-default btn-sm', 'href' => $url, 'data-toggle' => 'tooltip'];
     $content = '';
     if (!is_null($this->icon)) {
         $content .= '<i class="fa ' . $this->icon . '"></i>';
     }
     if ($this->style === 'long') {
         $content .= ' ' . $this->label;
     } else {
         $attributes['title'] = $this->label;
     }
     if (!is_null($this->target)) {
         $attributes['target'] = $this->target;
     }
     return $this->htmlBuilder->tag('a', $attributes, $content);
 }
コード例 #2
0
ファイル: Control.php プロジェクト: procoders/admin
 /**
  * @param ModelWithOrderFieldInterface $instance
  * @param $totalCount
  * @return string
  */
 protected function moveButtons(ModelWithOrderFieldInterface $instance, $totalCount)
 {
     $sort = $instance->getOrderValue();
     $buttons = [];
     if ($sort > 0) {
         $buttons[] = $this->moveButton($this->router->routeToMoveup($this->modelItem->getAlias(), $instance->getKey()), Lang::get('admin::lang.table.moveUp'), '&uarr;');
     }
     if ($sort < $totalCount - 1) {
         $buttons[] = $this->moveButton($this->router->routeToMovedown($this->modelItem->getAlias(), $instance->getKey()), Lang::get('admin::lang.table.moveDown'), '&darr;');
     }
     return implode(' ', $buttons);
 }
コード例 #3
0
ファイル: Filter.php プロジェクト: greysama/admin
 /**
  * @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);
 }
コード例 #4
0
ファイル: MenuItem.php プロジェクト: GlobalsDD/admin
 /**
  * @return string
  */
 public function getUrl()
 {
     if (!is_null($this->url)) {
         if (strpos($this->url, '://') !== false) {
             return $this->url;
         }
         return $this->router->routeToWildcard($this->url);
     }
     if (!is_null($this->modelClass)) {
         return $this->router->routeToModel($this->getModelItem()->getAlias());
     }
     return '#';
 }
コード例 #5
0
 /**
  * 
  *
  * @param $action
  * @return string 
  * @static 
  */
 public static function routeToAuth($action)
 {
     return \SleepingOwl\Admin\Router::routeToAuth($action);
 }
コード例 #6
0
ファイル: RouterTest.php プロジェクト: GlobalsDD/admin
 /** @test */
 public function it_throws_an_exception_when_unknown_method_called()
 {
     $this->setExpectedException(\SleepingOwl\Admin\Exceptions\MethodNotFoundException::class);
     $route = $this->instance->unknownMethod();
     $this->assertEquals('some-route', $route);
 }