public function getInputFilter() { if (!$this->filter) { $factory = new InputFilterFactory(); $inputFilterSpec = array('type' => 'Dots\\InputFilter\\InputFilter', 'id' => array('required' => false), 'title' => array('required' => true, 'filters' => array(array('name' => 'Zend\\Filter\\StringTrim'))), 'alias' => array('required' => false, 'allow_empty' => true, 'filters' => array(array('name' => 'Zend\\Filter\\StringTrim')), 'validators' => array(array('name' => 'Zend\\Validator\\Db\\NoRecordExists', 'options' => array('table' => 'pages', 'field' => 'alias', 'adapter' => \Dots\Registry::get('service_locator')->get('Zend\\Db\\Adapter\\Adapter'), 'exclude' => "id!='" . $this->data['id'] . "'")))), 'template' => array('required' => true, 'filters' => array(array('name' => 'Zend\\Filter\\StringTrim'))), 'language' => array('required' => true, 'filters' => array(array('name' => 'Zend\\Filter\\StringTrim')))); $this->filter = $factory->createInputFilter($inputFilterSpec); } return $this->filter; }
public static function renderNav(Event $event) { $serviceLocator = Registry::get('service_locator'); $view = $serviceLocator->get('DotsTwigViewRenderer'); $context = $serviceLocator->get('Application')->getMvcEvent(); $routeMatch = $context->getRouteMatch(); $routeMatchName = null; if ($routeMatch) { $routeMatchName = $routeMatch->getMatchedRouteName(); } $params = array(); $params['editable'] = $routeMatchName == 'dots-page' || $routeMatchName == 'home' && $routeMatch->getParam('page') instanceof Page; //render admin navigation $viewModel = new ViewModel($params); $viewModel->setTemplate('dots-pages/admin/nav'); $viewModel->setTerminal(true); return $view->render($viewModel); }
/** * Render a specific template * @param null $template * @param array $vars * @return string */ private function renderViewModel($template = null, $vars = array()) { $view = Registry::get('service_locator')->get('view'); $viewModel = new ViewModel($vars, array('has_parent' => true)); $viewModel->setTemplate($template)->setTerminal(true); return $view->render($viewModel); }
/** * Remove slide show block * @param \Zend\EventManager\Event $event * @return bool */ public function removeBlock(Event $event) { $locator = Registry::get('service_locator'); $appConfig = $locator->get('ApplicationConfig'); $config = $locator->get('Configuration'); $modelSlideshowBlock = $locator->get('DotsSlideshow\\Db\\Model\\SlideshowBlock'); $modelSlideshowImage = $locator->get('DotsSlideshow\\Db\\Model\\SlideshowImage'); $block = $event->getTarget(); $slideshowBlock = $modelSlideshowBlock->getByBlockId($block->id); $images = $modelSlideshowImage->getAllByBlockSlideshowId($slideshowBlock->id); $slideshowBlock->delete(); $block->delete(); if (!empty($images)) { foreach ($images as $image) { $image->delete(); $filename = $appConfig['public_path'] . '/' . $config['dots_slideshow']['image_path'] . $image->src; unlink($filename); } } return true; }