예제 #1
0
 public function attached($presenter)
 {
     parent::attached($presenter);
     $this->wdata = $this->WDataModel->get($this->presenter->getParameter('destination'));
     $this->template->village = $this->village = $this->villageService->getVillage($this->presenter->getParameter('id'));
     $this->units = $this->unitService->getUnits($this->village);
     $this->template->units = $this->units;
     $this->template->names = $this->unitService->getNames();
     $unitData = [];
     switch ($this->village->getOwner()->tribe) {
         case App\FrontModule\Model\User\UserService::TRIBE_ROMANS:
             foreach (App\GameModule\Model\Units\UnitService::ROMANS as $unit) {
                 $unitData[] = $this->unitFactory->getUnit($unit);
             }
             break;
         case App\FrontModule\Model\User\UserService::TRIBE_TEUTONS:
             foreach (App\GameModule\Model\Units\UnitService::TEUTONS as $unit) {
                 $unitData[] = $this->unitFactory->getUnit($unit);
             }
             break;
         case App\FrontModule\Model\User\UserService::TRIBE_GAULS:
             foreach (App\GameModule\Model\Units\UnitService::GAULS as $unit) {
                 $unitData[] = $this->unitFactory->getUnit($unit);
             }
             break;
     }
     $this->template->unitData = $unitData;
     $this->template->setFile(__DIR__ . '/SendUnitsControl.latte');
 }
예제 #2
0
 /**
  * @param \Nette\ComponentModel\Container $obj
  */
 protected function attached($obj)
 {
     parent::attached($obj);
     if ($obj instanceof Nette\Application\IPresenter) {
         $this->currentUrl = new UrlScript($this->link('//response!'));
     }
 }
예제 #3
0
 protected function attached($presenter)
 {
     if ($presenter instanceof \Nette\Application\UI\Presenter) {
         $this->setSessionSection($this->presenter->session->getSection('paypal'));
     }
     parent::attached($presenter);
 }
예제 #4
0
파일: KMGrid.php 프로젝트: kissmael/kmgrid
 protected function attached($presenter)
 {
     parent::attached($presenter);
     $this->addComponent(new Container(), 'columns');
     $this->addComponent(new Container(), 'actions');
     $this->init($presenter);
 }
예제 #5
0
 /**
  * @param \Nette\ComponentModel\Container $obj
  */
 protected function attached($obj)
 {
     parent::attached($obj);
     if ($obj instanceof Nette\Application\UI\Presenter) {
         $this->payPal->setReturnAddress($this->link('//return!'), $this->link('//cancel!'));
     }
 }
예제 #6
0
 /**
  * @param Nette\ComponentModel\Container $obj
  */
 protected function attached($obj)
 {
     parent::attached($obj);
     if ($obj instanceof Nette\Application\IPresenter) {
         $this->client->getConsumer()->setCallbackUrl(new Http\UrlScript($this->link('//response!')));
     }
 }
예제 #7
0
 public function attached($presenter)
 {
     parent::attached($presenter);
     $this->column = $this->lookup('Brabijan\\Datagrid\\Renderer')->getColumn($this->columnId);
     if ($this->templateRowCallback) {
         $this->templateRowCallback->invokeArgs(array($this));
     }
 }
예제 #8
0
 /**
  * @param \Nette\ComponentModel\IComponent $component
  */
 protected function attached($component)
 {
     parent::attached($component);
     if (!$component instanceof Presenter) {
         return;
     }
     $this->configure($component);
 }
예제 #9
0
 /**
  * @param \Nette\Application\UI\Presenter $presenter
  */
 public function attached($presenter)
 {
     parent::attached($presenter);
     if ($presenter instanceof Presenter) {
         foreach ($this->views as $view) {
             $view->onAttached($this);
         }
     }
 }
예제 #10
0
 protected function attached($presenter)
 {
     parent::attached($presenter);
     if ($presenter instanceof Presenter) {
         foreach ($this->rootItem->getItems(TRUE) as $item) {
             !$item->isUrl() and $item->setCurrent($presenter->isLinkCurrent($item->link, $item->linkArgs));
         }
     }
 }
예제 #11
0
 public function attached($presenter)
 {
     parent::attached($presenter);
     $this->template->current = $this->presenter->template->current;
     $this->template->next = $this->presenter->template->next;
     $this->village = $this->villageService->getVillage($this->presenter->getParameter('id'));
     $building = $this->presenter->getParameter('building');
     switch ($building) {
         case App\GameModule\Model\Building\BuildingModel::WOODCUTTER:
         case App\GameModule\Model\Building\BuildingModel::CLAY_PIT:
         case App\GameModule\Model\Building\BuildingModel::IRON_MINE:
         case App\GameModule\Model\Building\BuildingModel::CROPLAND:
             $this->renderResourceField();
             break;
         case App\GameModule\Model\Building\BuildingModel::WAREHOUSE:
         case App\GameModule\Model\Building\BuildingModel::CRANNY:
         case App\GameModule\Model\Building\BuildingModel::GRANARY:
         case App\GameModule\Model\Building\BuildingModel::TRAPPER:
             $this->renderCapacity();
             break;
         case App\GameModule\Model\Building\BuildingModel::MAIN_BUILDING:
             $this->renderMainBuilding();
             break;
         case App\GameModule\Model\Building\BuildingModel::BARRACKS:
             $this->renderBarracks();
             break;
         case App\GameModule\Model\Building\BuildingModel::STABLE:
             $this->renderStable();
             break;
         case App\GameModule\Model\Building\BuildingModel::ACADEMY:
             $this->renderAcademy();
             break;
         case App\GameModule\Model\Building\BuildingModel::ARMOURY:
             $this->renderArmoury();
             break;
         case App\GameModule\Model\Building\BuildingModel::BLACKSMITH:
             $this->renderBlacksmith();
             break;
         case App\GameModule\Model\Building\BuildingModel::MARKET_PLACE:
             $this->renderMarketPlace();
             break;
         case App\GameModule\Model\Building\BuildingModel::EMBASSY:
             $this->renderEmbassy();
             break;
         case App\GameModule\Model\Building\BuildingModel::HERO_MANSION:
             $this->renderHeroMansion();
             break;
         case App\GameModule\Model\Building\BuildingModel::RALLY_POINT:
             $this->renderRallyPoint();
             break;
         default:
             $this->template->setFile(__DIR__ . '/Template/Blank.latte');
             break;
     }
 }
예제 #12
0
 /**
  * @param \Nette\Application\UI\Presenter $presenter
  */
 protected function attached($presenter)
 {
     parent::attached($presenter);
     if (!$presenter instanceof Presenter) {
         return;
     }
     $this->addComponent(new \Nette\ComponentModel\Container(), "columns");
     $this->addComponent(new \Nette\ComponentModel\Container(), "buttons");
     $this->addComponent(new \Nette\ComponentModel\Container(), "globalButtons");
     $this->addComponent(new \Nette\ComponentModel\Container(), "actions");
     $this->addComponent(new \Nette\ComponentModel\Container(), "subGrids");
     if ($presenter->isAjax()) {
         $this->invalidateControl();
     }
     $this->configure($presenter);
     if ($this->isSubGrid && !empty($this->afterConfigureSettings)) {
         call_user_func($this->afterConfigureSettings, $this);
     }
     if ($this->hasActiveSubGrid()) {
         $subGrid = $this->addComponent($this['subGrids']->components[$this->activeSubGridName]->getGrid(), "subGrid" . $this->activeSubGridName);
         $subGrid->registerSubGrid("subGrid" . $this->activeSubGridName);
     }
     if ($this->hasActionForm()) {
         $actions = array();
         foreach ($this['actions']->components as $name => $action) {
             $actions[$name] = $action->getAction();
         }
         $this['gridForm'][$this->name]['action']['action_name']->setItems($actions);
     }
     if ($this->paginate) {
         if ($this->hasActiveItemPerPage()) {
             if (in_array($this->perPage, $this['gridForm'][$this->name]['perPage']['perPage']->items)) {
                 $this['gridForm'][$this->name]['perPage']->setDefaults(array("perPage" => $this->perPage));
             } else {
                 $items = $this['gridForm'][$this->name]['perPage']['perPage']->getItems();
                 $this->perPage = reset($items);
             }
         } else {
             $items = $this['gridForm'][$this->name]['perPage']['perPage']->getItems();
             $this->perPage = reset($items);
         }
         $this->getPaginator()->itemsPerPage = $this->perPage;
     }
     if ($this->hasActiveFilter()) {
         $this->filterData();
         $this['gridForm'][$this->name]['filter']->setDefaults($this->filter);
     }
     if ($this->hasActiveOrder() && $this->hasEnabledSorting()) {
         $this->orderData($this->order);
     }
     if (!$this->hasActiveOrder() && $this->hasDefaultOrder() && $this->hasEnabledSorting()) {
         $order = explode(" ", $this->defaultOrder);
         $this->dataSource->orderData($order[0], $order[1]);
     }
 }
예제 #13
0
 /**
  * @param \Nette\Application\UI\PresenterComponent
  * @throws \Nette\InvalidStateException
  */
 protected function attached($obj)
 {
     parent::attached($obj);
     if ($obj instanceof Nette\Application\IPresenter) {
         $this->startup();
         if (!$this->startupCheck) {
             $class = $this->getReflection()->getMethod('startup')->getDeclaringClass()->getName();
             throw new \Nette\InvalidStateException("Method {$class}::startup() or its descendant doesn't call parent::startup().");
         }
     }
 }
예제 #14
0
파일: DataGrid.php 프로젝트: uestla/twigrid
 /**
  * @param  NPresenter $presenter
  * @return void
  */
 protected function attached($presenter)
 {
     if ($presenter instanceof NPresenter) {
         $this->build();
         parent::attached($presenter);
         $this->session = $presenter->getSession(__CLASS__ . '-' . $this->getName());
         if (!isset($presenter->payload->twiGrid)) {
             $presenter->payload->twiGrid['forms'] = $this->presenter->payload->twiGrid = [];
         }
     }
 }
예제 #15
0
 public function attached($presenter)
 {
     parent::attached($presenter);
     if ($presenter instanceof UI\Presenter) {
         if (!$presenter->getName()) {
             throw new InvalidArgumentException('Parameter name is required.');
         }
         /** @var Mesour\Components\Application\IApplication $application */
         $this->mesourApplication = $presenter->getContext()->getByType(Mesour\Components\Application\IApplication::class);
         $this->mesourApplication->setLink(new Mesour\Bridges\Nette\Link($this));
         if (isset($this->mesourApplication[$this->getName()])) {
             $this->mesourApplication->removeComponent($this->getName());
         }
         $this->grid = new Mesour\UI\DataGrid($this->getName(), $this->mesourApplication);
     }
 }
예제 #16
0
 /**
  * @param \Nette\ComponentModel\IComponent $component
  */
 protected function attached($component)
 {
     parent::attached($component);
     if (!$component instanceof Presenter) {
         return;
     }
     $this->configure($component);
     // sorting validation
     $directions = [self::SORT_ASC, self::SORT_DESC];
     foreach ($this->sortBy as $column => $direction) {
         if (!isset($this->columns[$column]) || !$this->columns[$column]->isSortable() || !in_array($direction, $directions)) {
             unset($this->sortBy[$column]);
             continue;
         }
     }
     $this->paginator->setPage($this->page)->setItemsPerPage($this->perPage);
 }
예제 #17
0
 protected function attached($presenter)
 {
     return $this->control->attached($presenter);
 }
예제 #18
0
 protected function attached($presenter)
 {
     parent::attached($presenter);
     $this->filterDataSource = $this->filter;
 }
예제 #19
0
 /**
  * @param  Nette\ComponentModel\IComponent $presenter
  * @return void
  */
 protected function attached($presenter)
 {
     $this->build();
     parent::attached($presenter);
     !isset($this->presenter->payload->twiGrid) && ($this->presenter->payload->twiGrid['forms'] = $this->presenter->payload->twiGrid = array());
 }
예제 #20
0
 /**
  * {inheritDoc}
  * @return void
  */
 public function attached($presenter)
 {
     parent::attached($presenter);
     if ($presenter instanceof Nette\Application\UI\Presenter) {
         /**
          * Get session
          */
         $this->grid_session = $this->getPresenter()->getSession($this->getSessionSectionName());
         /**
          * Try to find previous filters/pagination/sort in session
          */
         $this->findSessionFilters();
     }
 }
예제 #21
0
파일: Row.php 프로젝트: brabijan/datagrid
 public function attached($presenter)
 {
     parent::attached($presenter);
     $this->renderer = $this->lookup('Brabijan\\Datagrid\\Renderer');
 }
예제 #22
0
파일: DataGrid.php 프로젝트: OCC2/occ2pacs
 /**
  * {inheritDoc}
  * @return void
  */
 public function attached($presenter)
 {
     parent::attached($presenter);
     if ($presenter instanceof Nette\Application\UI\Presenter) {
         /**
          * Get session
          */
         if ($this->remember_state) {
             $this->grid_session = $presenter->getSession($this->getSessionSectionName());
         }
     }
 }
예제 #23
0
파일: Control.php 프로젝트: zaxxx/zaxcms
 /**
  * Automatic snippet invalidation
  */
 public function attached($presenter)
 {
     parent::attached($presenter);
     $this->startup();
     if ($this->translator === NULL) {
         $this->translator = $presenter->translator;
     }
     if ($this->autoAjax && $this->ajaxEnabled && $presenter->isAjax()) {
         $this->redrawControl();
         $this->presenter->payload->setUrl = $this->link('this');
     }
 }
예제 #24
0
파일: Modal.php 프로젝트: brosland/modals
 /**
  * @param IComponent $component
  */
 protected function attached($component)
 {
     parent::attached($component);
     if (!$component instanceof Presenter) {
         return;
     }
     if ($this->visible) {
         self::$ACTIVE_MODAL = $this;
     }
 }
예제 #25
0
 /**
  * @param \Nette\ComponentModel\Container $container
  */
 protected function attached($container)
 {
     if ($container instanceof Presenter) {
         $this->configure($container);
         foreach ($this->getComponents() as $component) {
             $this->active = $component->name;
             break;
         }
     }
     parent::attached($container);
 }
예제 #26
0
 protected function attached($presenter)
 {
     parent::attached($presenter);
     $this->views = $this->getViews();
     $this->related = array_fill_keys(array_keys($this->views), []);
 }
예제 #27
0
 /**
  * @param $container
  */
 protected function attached($container)
 {
     if ($container instanceof Presenter) {
         $this->configure($container);
     }
     parent::attached($container);
 }
예제 #28
0
파일: BaseControl.php 프로젝트: JZechy/ZBox
 public function attached($presenter)
 {
     parent::attached($presenter);
     $this->template->errorsLayout = __DIR__ . "/errors.latte";
     $this->template->flashesLayout = __DIR__ . "/flashes.latte";
 }
예제 #29
0
파일: Control.php 프로젝트: svobodni/web
 /**
  * @param \Nette\Application\IPresenter $presenter
  */
 protected function attached($presenter)
 {
     parent::attached($presenter);
     // template configurator
     if ($this->presenter->context->hasService('venne.templateConfigurator')) {
         $this->setTemplateConfigurator($this->presenter->context->venne->templateConfigurator);
     }
     // startup check
     $this->startup();
     if (!$this->startupCheck) {
         $class = $this->getReflection()->getMethod('startup')->getDeclaringClass()->getName();
         throw new \Nette\InvalidStateException("Method {$class}::startup() or its descendant doesn't call parent::startup().");
     }
 }
예제 #30
0
 /**
  * @param ITranslatableComponent $parent
  */
 protected function attached($parent)
 {
     parent::attached($parent);
     $this->translator = $parent->getTranslator();
 }