Esempio n. 1
0
 /**
  * Adds an album
  * 
  * @param array $input Raw input data
  * @return boolean
  */
 public function add(array $input)
 {
     $input = $this->prepareInput($input);
     $form =& $input['data']['album'];
     // Default empty values
     $form['web_page_id'] = '';
     $form['cover'] = '';
     // If we have a cover, then we need to upload it
     if (!empty($input['files']['file'])) {
         $file =& $input['files']['file'];
         $this->filterFileInput($file);
         // Override empty cover's value now
         $form['cover'] = $file[0]->getName();
     }
     if ($this->albumMapper->insert(ArrayUtils::arrayWithout($form, array('slug', 'menu')))) {
         $id = $this->getLastId();
         // If there's a file, then it needs to uploaded as a cover
         if (!empty($input['files']['file'])) {
             $this->albumPhoto->upload($id, $input['files']['file']);
         }
         $this->track('Album "%s" has been created', $form['name']);
         if ($this->webPageManager->add($this->getLastId(), $form['slug'], 'Photogallery', 'Photogallery:Album@showAction', $this->albumMapper)) {
             // Do the work in case menu widget was injected
             if ($this->hasMenuWidget()) {
                 $this->addMenuItem($this->webPageManager->getLastId(), $form['name'], $input);
             }
         }
         return true;
     } else {
         return false;
     }
 }
Esempio n. 2
0
 /**
  * Adds a category
  * 
  * @param array $input Raw input data
  * @return boolean
  */
 public function add(array $input)
 {
     $input = $this->prepareInput($input);
     // Form data reference
     $category =& $input['data']['category'];
     $category['web_page_id'] = '';
     // If we have a cover, then we need to upload it
     if (!empty($input['files']['file'])) {
         $file =& $input['files']['file'];
         $this->filterFileInput($file);
         // Override empty cover's value now
         $category['cover'] = $file[0]->getName();
     }
     if ($this->categoryMapper->insert(ArrayUtils::arrayWithout($category, array('menu', 'slug')))) {
         $id = $this->getLastId();
         $this->track('Category "%s" has been created', $category['name']);
         // If there's a file, then it needs to uploaded as a cover
         if (!empty($input['files']['file'])) {
             $this->imageManager->upload($id, $input['files']['file']);
         }
         // Add a web page now
         if ($this->webPageManager->add($id, $category['slug'], 'Blog (Categories)', 'Blog:Category@indexAction', $this->categoryMapper)) {
             // Do the work in case menu widget was injected
             if ($this->hasMenuWidget()) {
                 $this->addMenuItem($this->webPageManager->getLastId(), $category['name'], $input);
             }
         }
         return true;
     } else {
         return false;
     }
 }
Esempio n. 3
0
 /**
  * Adds a page
  * 
  * @param array $input Raw input data
  * @return boolean
  */
 public function add(array $input)
 {
     $input = $this->prepareInput($input);
     $page =& $input['page'];
     $page['web_page_id'] = '';
     if (!$this->pageMapper->insert(ArrayUtils::arrayWithout($page, array('controller', 'makeDefault', 'slug', 'menu')))) {
         return false;
     } else {
         // It was inserted successfully
         $id = $this->getLastId();
         // If checkbox was checked
         if (isset($page['makeDefault']) && $page['makeDefault'] == '1') {
             $this->makeDefault($id);
         }
         // Use custom controller if provided by user
         $controller = isset($page['controller']) ? $page['controller'] : 'Pages:Page@indexAction';
         // Add a web page now
         if ($this->webPageManager->add($id, $page['slug'], 'Pages', $controller, $this->pageMapper)) {
             // Do the work in case menu widget was injected
             if ($this->hasMenuWidget()) {
                 $this->addMenuItem($this->webPageManager->getLastId(), $page['name'], $input);
             }
         }
         // Track it
         $this->track('A new "%s" page has been created', $page['name']);
         return true;
     }
 }
Esempio n. 4
0
 /**
  * Adds a form
  * 
  * @param array $input Raw input data
  * @return boolean
  */
 public function add(array $input)
 {
     $input = $this->prepareInput($input);
     $form =& $input['form'];
     $form['web_page_id'] = '';
     if ($this->formMapper->insert(ArrayUtils::arrayWithout($form, array('slug', 'menu')))) {
         // Add a web page now
         if ($this->webPageManager->add($this->getLastId(), $form['slug'], 'Mail forms', 'MailForm:Form@indexAction', $this->formMapper)) {
             if ($this->hasMenuWidget()) {
                 $this->addMenuItem($this->webPageManager->getLastId(), $form['name'], $input);
             }
         }
         $this->track('Mail form "%s" has been created', $form['name']);
         return true;
     } else {
         return false;
     }
     return true;
 }
Esempio n. 5
0
 /**
  * Adds a category
  * 
  * @param array $input Raw input data
  * @return boolean Depending on success
  */
 public function add(array $input)
 {
     $input = $this->prepareInput($input);
     $category =& $input['category'];
     $category['web_page_id'] = '';
     if ($this->categoryMapper->insert(ArrayUtils::arrayWithout($category, array('slug', 'menu')))) {
         $this->track('Category "%s" has been created', $category['name']);
         if ($this->webPageManager->add($this->getLastId(), $category['slug'], 'News (Categories)', 'News:Category@indexAction', $this->categoryMapper)) {
             if ($this->hasMenuWidget()) {
                 // If at least one menu widget it added
                 if (isset($input['menu']['widget']) && is_array($input['menu']['widget'])) {
                     $this->addMenuItem($this->webPageManager->getLastId(), $category['name'], $input);
                 }
             }
         }
         return true;
     } else {
         return false;
     }
 }