public function add()
 {
     if (isset($_POST['action']) && $_POST['action'] == 'create') {
         try {
             $location = new Location($_POST, $this->entity_manager);
             $this->entity_manager->persist($location);
             $this->entity_manager->flush();
             wp_safe_redirect(admin_url('admin.php?page=hoo&updated=1'));
             exit;
         } catch (Exception $e) {
         }
     } else {
         $location = new Location();
     }
     $view = new View('admin/location/location');
     $this->add_meta_boxes($location);
     $view_options = array('title' => 'Add a Location', 'columns' => 2, 'location' => $location, 'page' => 'hoo-location-add', 'add-new-page' => sprintf('hoo-location-add'), 'breadcrumbs' => array('Locations' => 'hoo', 'Add a Location' => 'hoo-location-add'), 'action' => 'create', 'action-display' => 'Add');
     $view->render($view_options);
 }
 public function index()
 {
     $view = new View('admin/shortcodes/index');
     $view->render(array('title' => 'Shortcodes', 'locations' => Location::get_visible_locations($this->entity_manager), 'available_widgets' => Shortcode::available_widgets(), 'valid_widget_attributes' => Shortcode::valid_widget_attributes()));
 }
 public function add()
 {
     if (isset($_POST['action']) && $_POST['action'] == 'create') {
         $event = new Event($_POST, $this->entity_manager);
         $this->entity_manager->persist($event);
         $this->entity_manager->flush();
         wp_safe_redirect(admin_url(sprintf('admin.php?page=%s&location_id=%s&updated=1', 'hoo-location-events', $event->location->id)));
         exit;
     } else {
         $event = new Event();
         $event->location = $this->entity_manager->find('Hoo\\Model\\Location', $_GET['location_id']);
         $view_options = array('page' => 'hoo-location-event-add', 'columns' => 2);
         $this->add_meta_boxes($event);
         $view_options = array_merge($view_options, array('title' => sprintf('Add an Hours Event for <em>%s</em>', $event->location->name), 'event' => $event, 'action' => 'create', 'breadcrumbs' => array('Locations' => 'hoo', sprintf('%s Hours', $event->location->name) => sprintf('%s&location_id=%s', 'hoo-location-events', $event->location->id)), 'add-new-page' => sprintf('hoo-location-event-add&location_id=%s', $_GET['location_id']), 'action-display' => 'Add'));
         $view = new View('admin/event/event');
         $view->render($view_options);
     }
 }
Ejemplo n.º 4
0
 public function weekly($attributes)
 {
     $locations_repo = $this->entity_manager->getRepository('Hoo\\Model\\Location');
     if (isset($attributes['location'])) {
         $location = Location::get_location_by_id_or_shortname($attributes['location'], $this->entity_manager);
         if ($location) {
             $locations = array($location);
         } else {
             return 'Invalid Location';
         }
     } else {
         $locations = $locations_repo->findBy(array('is_visible' => true));
     }
     $view = new View('shortcode/weekly');
     $locations_hours = array();
     foreach ($locations as $location) {
         $locations_hours[] = array('location' => $location, 'hours' => $location->get_weekly_hours());
     }
     return $view->fetch(array('header' => $attributes['header'], 'locations' => $locations_hours));
 }
 public function add()
 {
     if (isset($_POST['action']) && $_POST['action'] == 'create') {
         $category_data = $_POST['category'];
         $category = new Category($category_data);
         $this->entity_manager->persist($category);
         $this->entity_manager->flush();
         $categories_table = new CategoryList($this->entity_manager);
         $categories_table->prepare_items();
         $view_options = array('title' => 'Categories', 'categories-table' => $categories_table, 'add-new-page' => sprintf('hoo-category-add'), 'notification' => array('type' => 'updated', 'message' => 'Category Added'));
         $view = new View('admin/category/index');
     } else {
         $category = new Category();
         $view = new View('admin/category/category');
         $this->add_meta_boxes($category);
         $view_options = array('title' => 'Add a Category', 'columns' => 2, 'category' => $category, 'page' => 'hoo-category-add', 'add-new-page' => sprintf('hoo-category-add'), 'breadcrumbs' => array('Categories' => 'hoo-category', 'Add a Location' => 'hoo-category-add'), 'action' => 'create', 'action-display' => 'Add');
     }
     $view->render($view_options);
 }