/**
  * {@inheritDoc}
  */
 public function getMetaImage()
 {
     if (!$this->_isLoaded('metaImage')) {
         $image = $this->_loaders->get('image')->load($this);
         $this->setMetaImage($image);
         $this->_loaded[] = 'metaImage';
     }
     return parent::getMetaImage();
 }
예제 #2
0
 /**
  * Get form for metadata section of edit page
  *
  * @param Page $page
  * @param Content $content
  *
  * @return \Message\Cog\Form\Handler
  */
 protected function _getMetadataForm(Page $page)
 {
     $form = $this->get('form')->setName('content-edit-metadata')->setAction($this->generateUrl('ms.cp.cms.edit.metadata.action', array('pageID' => $page->id)))->setMethod('post')->setDefaultValues(array('metaTitle' => $page->metaTitle, 'metaDescription' => $page->metaDescription, 'metaImage' => $page->getMetaImage() ? $page->getMetaImage()->id : null));
     $form->add('metaTitle', 'text', $this->trans('ms.cms.metadata.title.label'), array('attr' => array('data-help-key' => 'ms.cms.metadata.title.help')))->val()->optional()->maxLength(255);
     $form->add('metaDescription', 'textarea', $this->trans('ms.cms.metadata.description.label'), array('attr' => array('data-help-key' => 'ms.cms.metadata.description.help')))->val()->optional();
     $form->add('metaImage', 'file', $this->trans('ms.cms.metadata.image.label'), ['attr' => ['data-help-key' => 'ms.cms.metadata.image.help']])->val()->optional();
     $files = (array) $this->get('file_manager.file.loader')->getAll();
     // Get the available files
     $choices = array();
     $allowedTypes = array(File\Type::IMAGE);
     foreach ($files as $file) {
         if ($allowedTypes) {
             if (!in_array($file->typeID, $allowedTypes)) {
                 continue;
             }
         }
         $choices[$file->id] = $file->name;
     }
     uasort($choices, function ($a, $b) {
         return strcmp($a, $b);
     });
     $form->add('metaImage', 'ms_file', $this->trans('ms.commerce.product.image.file.label'), ['choices' => $choices, 'empty_value' => 'Please select…', 'attr' => array('data-help-key' => 'ms.commerce.product.image.file.help')]);
     return $form;
 }
예제 #3
0
 protected function _updateTags(Page $page)
 {
     $this->_transaction->run("\n\t\t\t\tDELETE FROM\n\t\t\t\t\tpage_tag\n\t\t\t\tWHERE\n\t\t\t\t\tpage_id = :pageId?i\n\t\t\t", ['pageId' => $page->id]);
     $tags = $page->getTags();
     if (!empty($tags)) {
         foreach ($tags as $tag) {
             $this->_transaction->run("\n\t\t\t\t\tINSERT INTO\n\t\t\t\t\t\tpage_tag\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tpage_id,\n\t\t\t\t\t\t\ttag_name\n\t\t\t\t\t\t)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t:pageID?i,\n\t\t\t\t\t\t\t:tag?s\n\t\t\t\t\t\t)\n\t\t\t\t", ['pageID' => $page->id, 'tag' => $tag]);
         }
     }
 }