Inheritance: extends Gc\Db\AbstractTable, implements Gc\Component\IterableInterface
Example #1
0
 /**
  * Generate frontend from url key
  *
  * @return ViewModel
  */
 public function indexAction()
 {
     $coreConfig = $this->getServiceLocator()->get('CoreConfig');
     $viewModel = new ViewModel();
     $this->events()->trigger('Front', 'preDispatch', $this, array('viewModel' => $viewModel));
     if ($coreConfig->getValue('site_is_offline') == 1) {
         $isAdmin = $this->getServiceLocator()->get('Auth')->hasIdentity();
         if (!$isAdmin) {
             $document = Document\Model::fromId($coreConfig->getValue('site_offline_document'));
             if (empty($document)) {
                 $viewModel->setTemplate('gc-frontend/site-is-offline');
                 $viewModel->setTerminal(true);
                 return $viewModel;
             }
         }
     }
     try {
         $document = $this->getServiceLocator()->get('CurrentDocument');
     } catch (Exception $e) {
         //Don't care, page is just not found
     }
     $variables = array();
     if (empty($document)) {
         // 404
         $this->getResponse()->setStatusCode(404);
         $layout = Layout\Model::fromId($coreConfig->getValue('site_404_layout'));
         if (empty($layout)) {
             $viewModel->setTerminal(true);
         }
     } else {
         //Load properties from document id
         $properties = new Property\Collection();
         $properties->load(null, null, $document->getId());
         foreach ($properties->getProperties() as $property) {
             $value = $property->getValue();
             if ($this->isSerialized($value)) {
                 $value = unserialize($value);
             }
             $viewModel->setVariable($property->getIdentifier(), $value);
             $this->layout()->setVariable($property->getIdentifier(), $value);
             $variables[$property->getIdentifier()] = $value;
         }
         //Set view from database
         $view = $document->getView();
         $layout = $document->getLayout();
     }
     if (!empty($layout)) {
         $this->layout()->setTemplate('layout/' . $layout->getIdentifier());
     }
     if (!empty($view)) {
         $viewModel->setTemplate('view/' . $view->getIdentifier());
     }
     if ($this->getRequest()->isXmlHttpRequest()) {
         if ($this->params()->fromQuery('terminate_layout') or $this->params()->fromPost('terminate_layout')) {
             $viewModel->setTerminal(true);
         }
     }
     $this->events()->trigger('Front', 'postDispatch', $this, array('viewModel' => $viewModel));
     return $viewModel;
 }
Example #2
0
 /**
  * List all comment by document id
  *
  * @return array
  */
 public function documentCommentAction()
 {
     $documentId = $this->params()->fromRoute('id');
     $document = DocumentModel::fromId($documentId);
     if (empty($document)) {
         return $this->redirect()->toRoute('module/blog');
     }
     $model = new Model\Comment();
     $commentList = $model->getList($documentId, null);
     if ($this->getRequest()->isPost()) {
         $comments = $this->getRequest()->getPost()->get('comment');
         foreach ($comments as $commentId => $data) {
             if (!empty($data['delete'])) {
                 $model->delete(array('id' => $commentId));
                 continue;
             }
             foreach ($data as $k => $v) {
                 if (!in_array($k, $this->whiteList)) {
                     unset($data[$k]);
                 }
             }
             $data['show_email'] = empty($data['show_email']) ? 0 : 1;
             $data['is_active'] = empty($data['is_active']) ? 0 : 1;
             $model->update($data, array('id' => $commentId));
         }
         return $this->redirect()->toRoute('module/blog/document-comment', array('id' => $documentId));
     }
     return array('comment_list' => $commentList, 'document' => $document);
 }
Example #3
0
 /**
  * Returns documents
  * $data can be mixed
  * if data is an array, return all documents
  * if data is numeric, return all documents with parent_id equal to $data
  * if data is string, return all documents with parent's url key equal to $data
  *
  * @param mixed $data Data
  *
  * @return array \Gc\Document\Model
  */
 public function __invoke($data = null)
 {
     $elements = array();
     $documents = new DocumentCollection();
     if (empty($data)) {
         $elements = $documents->load(0)->getDocuments();
     } else {
         if (is_numeric($data)) {
             $elements = $documents->load($data)->getDocuments();
         } elseif (is_string($data)) {
             $document = DocumentModel::fromUrlKey($data);
             $elements = $document->getChildren();
         } elseif (is_array($data)) {
             foreach ($data as $documentId) {
                 if (empty($documentId)) {
                     continue;
                 }
                 $document = $this->getView()->document($documentId);
                 if (!empty($document)) {
                     $elements[] = $document;
                 }
             }
         }
     }
     return $elements;
 }
Example #4
0
 /**
  * Returns document from id.
  *
  * @param mixed $identifier Identifier
  *
  * @return \Gc\Document\Model
  */
 public function __invoke($identifier = '')
 {
     if (is_numeric($identifier)) {
         return DocumentModel::fromId($identifier);
     }
     return DocumentModel::fromUrlKey($identifier);
 }
Example #5
0
 /**
  * Test
  *
  * @return void
  */
 public function testRender()
 {
     Registry::get('Application')->getRequest()->getUri()->setPath($this->documentChildren->getEditUrl());
     $collection = new DocumentCollection();
     $collection->load(0);
     $array = array_merge(array($collection), array('test' => 'value'));
     $this->assertTrue(strlen($this->object->render($array)) > 0);
 }
Example #6
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     $serviceManager = Registry::get('Application')->getServiceManager();
     $renderer = $serviceManager->get('Zend\\View\\Renderer\\PhpRenderer');
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService('currentDocument', Model::fromArray(array('id' => 1)));
     $serviceManager->setAllowOverride(false);
     $this->object = new CurrentDocument($serviceManager);
 }
Example #7
0
 /**
  * Test
  *
  * @return void
  */
 public function testSortOrderAction()
 {
     $this->dispatch('/admin/content/document/sort', 'POST', array('order' => 'document_' . $this->document->getId()));
     $this->assertResponseStatusCode(200);
     $this->assertModuleName('GcContent');
     $this->assertControllerName('DocumentController');
     $this->assertControllerClass('DocumentController');
     $this->assertMatchedRouteName('content/document/sort');
 }
Example #8
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     $this->script = ScriptModel::fromArray(array('name' => 'Script name', 'identifier' => 'script-identifier', 'description' => 'Script description', 'content' => 'script Content'));
     $this->script->save();
     $serviceManager = Registry::get('Application')->getServiceManager();
     $this->object = new Script($serviceManager);
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService('currentDocument', DocumentModel::fromArray(array('id' => 1)));
     $serviceManager->setAllowOverride(false);
 }
Example #9
0
 /**
  * Generate Xml accessor
  *
  * @param Request $request Request
  *
  * @return string
  */
 public function generate(Request $request)
 {
     $collection = new DocumentCollection();
     $documents = array();
     $rows = $collection->getAvailableDocuments();
     foreach ($rows as $row) {
         $documents[] = DocumentModel::fromArray((array) $row);
     }
     return $this->generateXml($documents, $request);
 }
Example #10
0
 /**
  * Return all documents with comment(s)
  *
  * @return array
  */
 public function getDocumentList()
 {
     $allComments = $this->getList(null, null);
     $documents = array();
     foreach ($allComments as $key => $comment) {
         if (empty($documents[$comment['document_id']])) {
             $document = DocumentModel::fromId($comment['document_id']);
             $documents[$document->getId()] = $document;
         }
     }
     return $documents;
 }
Example #11
0
 public function setUp()
 {
     $this->addthis = Mockery::mock('Social\\Model\\AddThis');
     $this->addthis->shouldReceive('getConfig')->once()->andReturn(array('profile_id' => '', 'username' => '', 'password' => '', 'show_stats' => '1', 'language' => 'fr', 'data_ga_property_id' => 'test', 'data_track_clickback' => '1', 'data_track_addressbar' => '1', 'config_json' => '', 'widgets' => array(array('name' => 'blog', 'identifier' => 'custom_string', 'settings' => 'custom_string', 'custom_string' => '<!-- AddThis Button BEGIN -->' . '<div class="addthis_toolbox addthis_default_style">' . '<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>' . '<a class="addthis_button_tweet"></a>' . '<a class="addthis_button_pinterest_pinit" pi:pinit:layout="horizontal"></a>' . '<a class="addthis_counter addthis_pill_style"></a>' . '</div>', 'chosen_list' => ''), array('name' => 'something', 'identifier' => 'something', 'settings' => 'nothing', 'custom_string' => '', 'chosen_list' => ''), array('name' => 'large_toolbox', 'identifier' => 'large_toolbox', 'settings' => 'large_toolbox', 'custom_string' => '', 'chosen_list' => 'facebook, twitter, pinterest_share, advqr, google_plusone_share, compact, counter'), array('name' => 'fb_tw_p1_sc', 'identifier' => 'fb_tw_p1_sc', 'settings' => 'fb_tw_p1_sc', 'custom_string' => '', 'chosen_list' => 'facebook, twitter, pinterest_share, google_plusone, google_plusone_share, compact, counter'), array('name' => 'large_toolbox_without_chosen_list', 'identifier' => 'large_toolbox_without_chosen_list', 'settings' => 'large_toolbox', 'custom_string' => '', 'chosen_list' => ''), array('name' => 'small_toolbox', 'identifier' => 'small_toolbox', 'settings' => 'small_toolbox', 'custom_string' => '', 'chosen_list' => 'facebook, twitter, pinterest_share, advqr, google_plusone_share, compact, counter')), 'addthis_show_stats' => true, 'addthis_append_data' => true, 'addthis_copytracking1' => false, 'addthis_copytracking2' => false, 'addthis_brand' => '', 'addthis_language' => 'fr', 'custom_size' => '', 'custom_services' => '', 'custom_preferred' => '', 'custom_more' => '', 'custom_string' => '', 'json_config' => '{"language":"fr"}'));
     $this->addthis->shouldReceive('getDefaultStyles')->once()->andReturn(array('large_toolbox' => array('src' => '<div class="addthis_toolbox addthis_default_style addthis_32x32_style" %1$s>' . '<a class="addthis_button_facebook"></a><a class="addthis_button_twitter"></a>' . '<a class="addthis_button_email"></a><a class="addthis_button_pinterest_share"></a>' . '<a class="addthis_button_compact"></a><a class="addthis_counter addthis_bubble_style">' . '</a></div>', 'img' => 'toolbox-large.png', 'name' => 'Large Toolbox'), 'small_toolbox' => array('src' => '<div class="addthis_toolbox addthis_default_style addthis_" %1$s>' . '<a class="addthis_button_facebook"></a><a class="addthis_button_twitter"></a>' . '<a class="addthis_button_email"></a><a class="addthis_button_pinterest_share"></a>' . '<a class="addthis_button_compact"></a><a class="addthis_counter addthis_bubble_style">' . '</a></div>', 'img' => 'toolbox-small.png', 'name' => 'Small Toolbox'), 'fb_tw_p1_sc' => array('src' => '<div class="addthis_toolbox addthis_default_style" %1$s>' . '<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>' . '<a class="addthis_button_tweet"></a><a class="addthis_button_pinterest_pinit"></a>' . '<a class="addthis_counter addthis_pill_style"></a></div>', 'img' => 'horizontal_share_rect.png', 'name' => 'Like, Tweet, +1, Share'), 'button' => array('src' => '<div><a class="addthis_button" href="//addthis.com/bookmark.php?v=' . Model\AddThis::ADDTHIS_VERSION . '" %1$s><img src="//cache.addthis.com/cachefly/' . 'static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" ' . 'style="border:0"/></a></div>', 'img' => 'horizontal_share.png', 'name' => 'Classic Share Button'), 'custom_string' => array('name' => 'Custom string')));
     $serviceManager = Registry::get('Application')->getServiceManager();
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService('CurrentDocument', DocumentModel::fromArray(array('id' => 1, 'url_key' => 'test', 'name' => 'Test')));
     $serviceManager->setService('AddThisModel', $this->addthis);
     $serviceManager->setAllowOverride(false);
     $this->object = new AddThisWidget();
 }
Example #12
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     $serviceManager = Registry::get('Application')->getServiceManager();
     $this->renderer = new PhpRenderer();
     $renderer = $serviceManager->get('Zend\\View\\Renderer\\PhpRenderer');
     $this->renderer->setHelperPluginManager($renderer->getHelperPluginManager());
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService('currentDocument', DocumentModel::fromArray(array('id' => 1)));
     $serviceManager->setAllowOverride(false);
     $this->object = $this->renderer->plugin('modulePlugin');
     $this->module = ModuleModel::fromArray(array('name' => 'Blog'));
     $this->module->save();
 }
Example #13
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     $this->init();
     $this->view = ViewModel::fromArray(array('name' => 'View Name', 'identifier' => 'View identifier', 'description' => 'View Description', 'content' => 'View Content'));
     $this->view->save();
     $this->layout = LayoutModel::fromArray(array('name' => 'Layout Name', 'identifier' => 'Layout identifier', 'description' => 'Layout Description', 'content' => 'Layout Content'));
     $this->layout->save();
     $this->documentType = DocumentTypeModel::fromArray(array('name' => 'Document Type Name', 'description' => 'Document Type description', 'icon_id' => 1, 'defaultview_id' => $this->view->getId(), 'user_id' => $this->user->getId()));
     $this->documentType->save();
     $this->document = DocumentModel::fromArray(array('name' => 'Document name', 'url_key' => 'url-key', 'status' => DocumentModel::STATUS_ENABLE, 'show_in_nav' => true, 'user_id' => $this->user->getId(), 'document_type_id' => $this->documentType->getId(), 'view_id' => $this->view->getId(), 'layout_id' => $this->layout->getId(), 'parent_id' => null));
     $this->document->save();
     ModuleModel::install(Registry::get('Application')->getServiceManager()->get('CustomModules'), 'Blog');
 }
Example #14
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     $this->view = ViewModel::fromArray(array('name' => 'View Name', 'identifier' => 'View identifier', 'description' => 'View Description', 'content' => 'View Content'));
     $this->view->save();
     $this->layout = LayoutModel::fromArray(array('name' => 'Layout Name', 'identifier' => 'Layout identifier', 'description' => 'Layout Description', 'content' => 'Layout Content'));
     $this->layout->save();
     $this->user = UserModel::fromArray(array('lastname' => 'User test', 'firstname' => 'User test', 'email' => '*****@*****.**', 'login' => 'test', 'user_acl_role_id' => 1));
     $this->user->setPassword('test');
     $this->user->save();
     $this->documentType = DocumentTypeModel::fromArray(array('name' => 'Document Type Name', 'description' => 'Document Type description', 'icon_id' => 1, 'defaultview_id' => $this->view->getId(), 'user_id' => $this->user->getId()));
     $this->documentType->save();
     $this->document = DocumentModel::fromArray(array('name' => 'Document name', 'url_key' => 'url-key', 'status' => DocumentModel::STATUS_ENABLE, 'show_in_nav' => true, 'user_id' => $this->user->getId(), 'document_type_id' => $this->documentType->getId(), 'view_id' => $this->view->getId(), 'layout_id' => $this->layout->getId(), 'parent_id' => null));
     $this->document->save();
     $this->object = new Sitemap();
 }
Example #15
0
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  *
  * @return void
  */
 protected function tearDown()
 {
     $this->boostrap->uninstall();
     $this->document->delete();
     $this->view->delete();
     $this->layout->delete();
     $this->documentType->delete();
     $this->user->delete();
     $this->module->delete();
     unset($this->module);
     unset($this->document);
     unset($this->view);
     unset($this->layout);
     unset($this->documentType);
     unset($this->user);
     unset($this->object);
     unset($this->renderer);
 }
Example #16
0
 /**
  * Initialize documents
  *
  * @return \Gc\Document\Collection
  */
 protected function setDocuments()
 {
     $parentId = $this->getParentId();
     $rows = $this->fetchAll($this->select(function (Select $select) use($parentId) {
         if (empty($parentId)) {
             $select->where->isNull('parent_id');
         } else {
             $select->where->equalTo('parent_id', $parentId);
         }
         $select->order('sort_order ASC');
         $select->order('created_at ASC');
     }));
     $documents = array();
     foreach ($rows as $row) {
         $documents[] = Model::fromArray((array) $row);
     }
     $this->setData('documents', $documents);
     return $this;
 }
Example #17
0
 protected function removeContent()
 {
     $this->documentType->delete();
     $this->property->delete();
     $this->tabModel->delete();
     $this->view->delete();
     $this->layout->delete();
     $this->script->delete();
     $this->datatype->delete();
     $this->document->delete();
     unset($this->documentType);
     unset($this->property);
     unset($this->tabModel);
     unset($this->view);
     unset($this->layout);
     unset($this->script);
     unset($this->datatype);
     unset($this->document);
 }
Example #18
0
 /**
  * Test
  *
  * @return void
  */
 public function testRenderWithIterableInterface()
 {
     $view = ViewModel::fromArray(array('name' => 'View Name', 'identifier' => 'View identifier', 'description' => 'View Description', 'content' => 'View Content'));
     $view->save();
     $layout = LayoutModel::fromArray(array('name' => 'Layout Name', 'identifier' => 'Layout identifier', 'description' => 'Layout Description', 'content' => 'Layout Content'));
     $layout->save();
     $user = UserModel::fromArray(array('lastname' => 'User test', 'firstname' => 'User test', 'email' => '*****@*****.**', 'login' => 'test', 'user_acl_role_id' => 1));
     $user->setPassword('test');
     $user->save();
     $documentType = DocumentTypeModel::fromArray(array('name' => 'Document Type Name', 'description' => 'Document Type description', 'icon_id' => 1, 'defaultview_id' => $view->getId(), 'user_id' => $user->getId()));
     $documentType->save();
     $document = DocumentModel::fromArray(array('name' => 'Document name', 'url_key' => 'url-key', 'status' => DocumentModel::STATUS_ENABLE, 'show_in_nav' => true, 'user_id' => $user->getId(), 'document_type_id' => $documentType->getId(), 'view_id' => $view->getId(), 'layout_id' => $layout->getId(), 'parent_id' => 0));
     $document->save();
     $collection = new DocumentCollection();
     $collection->load(0);
     $this->assertEquals(sprintf('<ul><li><a href="#tabs-%d">Document name</a></li></ul>', $document->getId()), $this->object->render($collection->getChildren()));
     $document->delete();
     $documentType->delete();
     $layout->delete();
     $view->delete();
     $user->delete();
 }
Example #19
0
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  *
  * @return void
  */
 protected function tearDown()
 {
     $_FILES = array();
     $_POST = array();
     $this->datatype->delete();
     $this->documentType->delete();
     $this->document->delete();
     $this->layout->delete();
     $this->property->delete();
     $this->tab->delete();
     $this->user->delete();
     $this->view->delete();
     unset($this->datatype);
     unset($this->documentType);
     unset($this->document);
     unset($this->layout);
     unset($this->property);
     unset($this->tab);
     unset($this->user);
     unset($this->view);
     unset($this->object);
 }
Example #20
0
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  *
  * @return void
  */
 protected function tearDown()
 {
     $this->document->delete();
     unset($this->document);
     $this->documentTwo->delete();
     unset($this->documentTwo);
     $this->documentChildren->delete();
     unset($this->documentChildren);
     $this->documentSecondChildren->delete();
     unset($this->documentSecondChildren);
     $this->documentThirdChildren->delete();
     unset($this->documentThirdChildren);
     $this->documentForthChildren->delete();
     unset($this->documentForthChildren);
     $this->view->delete();
     unset($this->view);
     $this->user->delete();
     unset($this->user);
     $this->layout->delete();
     unset($this->layout);
     $this->documentType->delete();
     unset($this->documentType);
     unset($this->object);
 }
Example #21
0
 /** (non-PHPdoc)
  *
  * @see include \Gc\Component\IterableInterface#getParent()
  * @return Model
  */
 public function getParent()
 {
     $parentId = $this->getData('parent_id');
     return Model::fromId($parentId);
 }
Example #22
0
 /**
  * Test
  *
  * @return void
  */
 public function testAddWithWrongValues()
 {
     $data = array('message' => '', 'username' => '', 'email' => '');
     $this->assertFalse($this->object->add($data, $this->document->getId()));
 }
Example #23
0
 /**
  * Test
  *
  * @return void
  */
 public function testInvokeWithParameters()
 {
     $this->assertInternalType('array', $this->object->__invoke(1));
     $this->assertInternalType('array', $this->object->__invoke('url-key'));
     $this->assertInternalType('array', $this->object->__invoke(array(0, $this->document->getId())));
 }
Example #24
0
 /**
  * Get locale according to the locale specified in the document or its parent.
  *
  * @param Document\Model $document Document
  *
  * @return void
  */
 protected function getLocale($document)
 {
     $locale = null;
     if (!$document->hasLocale()) {
         $parent = $document->getParent();
         if ($parent) {
             $locale = $this->getLocale($parent);
         }
     } else {
         $locale = $document->getLocale();
     }
     return $locale;
 }
Example #25
0
 /**
  * Load document form from DocumentModel
  *
  * @param DocumentModel $document Document model
  * @param array         $config   Configuration
  *
  * @return void
  */
 public function load(DocumentModel $document, array $config)
 {
     $this->get('document-name')->setValue($document->getName());
     $this->get('document-url_key')->setValue($document->getUrlKey());
     $status = new Element\Checkbox('document-status');
     $status->setLabel('Publish')->setValue($document->isPublished())->setAttribute('id', 'status')->setAttribute('class', 'input-checkbox')->setCheckedValue((string) DocumentModel::STATUS_ENABLE);
     $this->add($status);
     $showInNav = new Element\Checkbox('document-show_in_nav');
     $showInNav->setLabel('Show in nav')->setValue($document->showInNav())->setAttribute('id', 'show_in_nav')->setAttribute('class', 'input-checkbox')->setCheckedValue((string) DocumentModel::STATUS_ENABLE);
     $this->add($showInNav);
     $canBeCached = new Element\Checkbox('document-can_be_cached');
     $canBeCached->setLabel('Can be cached')->setValue($document->canBeCached())->setAttribute('id', 'can_be_cached')->setAttribute('class', 'input-checkbox')->setCheckedValue((string) DocumentModel::STATUS_ENABLE);
     $this->add($canBeCached);
     array_unshift($config['locales'], '-- Use parent configuration');
     $locale = new Element\Select('document-locale');
     $locale->setLabel('Locale')->setValueOptions($config['locales'])->setValue($document->getLocale())->setAttribute('id', 'locale')->setAttribute('class', 'form-control');
     $this->add($locale);
     $documentType = $document->getDocumentType();
     $viewsCollection = $documentType->getAvailableViews();
     $select = $viewsCollection->getSelect();
     $viewSelected = $document->getViewId();
     $viewModel = View\Model::fromId($document->getDocumentType()->getDefaultViewId());
     if (!empty($viewModel)) {
         $select = $select + array($viewModel->getId() => $viewModel->getName());
         if (empty($viewSelected)) {
             $viewSelected = $viewModel->getId();
         }
     }
     $view = new Element\Select('document-view');
     $view->setValueOptions($select)->setValue((string) $viewSelected)->setAttribute('id', 'view')->setAttribute('class', 'form-control')->setLabel('View');
     $inputFilterFactory = $this->getInputFilter();
     $inputFilterFactory->add(array('name' => 'document-view', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'document-view');
     $this->add($view);
     $layoutsCollection = new Layout\Collection();
     $layout = new Element\Select('document-layout');
     $layout->setValueOptions($layoutsCollection->getSelect())->setValue((string) $document->getLayoutId())->setAttribute('id', 'layout')->setAttribute('class', 'form-control')->setLabel('Layout');
     $inputFilterFactory->add(array('name' => 'document-layout', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'document-layout');
     $this->add($layout);
     $this->remove('document_type');
     $this->remove('parent');
     $moreInformation = new Element\Hidden('more_information');
     $moreInformation->setAttribute('content', '');
     $this->add($moreInformation);
     $this->parentId = $document->getParentId();
     $this->documentId = $document->getId();
     $this->loadValues($document);
 }
Example #26
0
 /**
  * Load properties from document type, tab and document
  *
  * @param integer        $documentTypeId Document type id
  * @param DocumentModel  $document       Document model
  * @param ServiceManager $serviceLocator Service manager
  *
  * @return array
  */
 public function load($documentTypeId, DocumentModel $document, ServiceManager $serviceLocator)
 {
     $tabs = $this->loadTabs($documentTypeId);
     $tabsArray = array();
     $idx = 1;
     foreach ($tabs as $tab) {
         $tabsArray[] = $tab->getName();
         $properties = $this->loadProperties($documentTypeId, $tab->getId(), $document->getId());
         $fieldset = new ZendForm\Fieldset('tabs-' . $idx);
         foreach ($properties as $property) {
             $elements = AbstractForm::addContent($fieldset, Datatype\Model::loadEditor($serviceLocator, $property));
             if (!is_array($elements)) {
                 $elements = array($elements);
             }
             foreach ($elements as $element) {
                 if (empty($element)) {
                     continue;
                 }
                 $element->setOption('required', $property->isRequired());
                 $element->setOption('description', $property->getDescription());
             }
         }
         $this->add($fieldset);
         $idx++;
     }
     $formDocumentAdd = new DocumentInformation();
     $formDocumentAdd->load($document, $serviceLocator->get('Config'));
     $formDocumentAdd->setAttribute('name', 'tabs-' . $idx);
     $this->add($formDocumentAdd);
     return $tabsArray;
 }
Example #27
0
 /**
  * Test
  *
  * @return void
  */
 public function testFromIdentifier()
 {
     $documentModel = DocumentModel::fromArray(array('name' => 'DocumentTest', 'url_key' => 'document-test', 'status' => DocumentModel::STATUS_ENABLE, 'sort_order' => 1, 'show_in_nav' => true, 'user_id' => $this->user->getId(), 'document_type_id' => $this->documentType->getId(), 'view_id' => $this->view->getId(), 'layout_id' => $this->layout->getId(), 'parent_id' => 0));
     $documentModel->save();
     $this->assertInstanceOf('Gc\\Property\\Model', Model::fromIdentifier($this->object->getIdentifier(), $documentModel->getId()));
 }
Example #28
0
 /**
  * Test
  *
  * @return void
  */
 public function testLoad()
 {
     $this->assertInstanceOf('Gc\\Property\\Value\\Model', $this->object->load($this->object->getId(), $this->document->getId(), $this->property->getId()));
 }
Example #29
0
 /**
  * Test
  *
  * @return void
  */
 public function testLoadWithParentId()
 {
     $this->object->load($this->document->getId());
     $this->assertInternalType('array', $this->object->getDocuments());
 }
Example #30
0
 /**
  * Test
  *
  * @return void
  */
 public function testGetEditUrl()
 {
     $this->assertInternalType('string', $this->object->getEditUrl());
 }