Inheritance: extends Gc\Db\AbstractTable
コード例 #1
0
ファイル: CollectionTest.php プロジェクト: gotcms/gotcms
 /**
  * Test
  *
  * @return void
  */
 public function testGetProperties()
 {
     $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->object->setDocumentId($documentModel->getId());
     $this->object->save();
     $this->object->load($this->documentType->getId(), $this->tab->getId(), 1);
     $this->assertInternalType('array', $this->object->getProperties(true));
     $this->object->load();
     $this->assertInternalType('array', $this->object->getProperties(true));
 }
コード例 #2
0
ファイル: CollectionTest.php プロジェクト: gotcms/gotcms
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  *
  * @return void
  */
 protected function tearDown()
 {
     unset($this->object);
     $this->documentType->delete();
     unset($this->documentType);
     $this->view->delete();
     unset($this->view);
     $this->layout->delete();
     unset($this->layout);
     $this->user->delete();
     unset($this->user);
 }
コード例 #3
0
 /**
  * Test
  *
  * @return void
  */
 public function testPasteActionWithCutSession()
 {
     $document = DocumentModel::fromArray(array('name' => 'test', 'url_key' => 'about', 'status' => DocumentModel::STATUS_ENABLE, 'user_id' => $this->user->getId(), 'document_type_id' => $this->documentType->getId(), 'view_id' => $this->view->getId(), 'layout_id' => $this->layout->getId(), 'parent_id' => null));
     $document->save();
     $session = new SessionContainer();
     $session->offsetSet('document-cut', $this->document->getId());
     $this->dispatch('/admin/content/document/paste/' . $document->getId());
     $this->assertResponseStatusCode(200);
     $this->assertModuleName('GcContent');
     $this->assertControllerName('DocumentController');
     $this->assertControllerClass('DocumentController');
     $this->assertMatchedRouteName('content/document/paste');
     $document->delete();
 }
コード例 #4
0
ファイル: IndexControllerTest.php プロジェクト: gotcms/gotcms
 /**
  * Test
  *
  * @return void
  */
 public function testIndexActionWithUrlKeyWithPreview()
 {
     $auth = new AuthenticationService(new Storage\Session(UserModel::BACKEND_AUTH_NAMESPACE));
     $auth->clearIdentity();
     $document = DocumentModel::fromArray(array('name' => 'test', 'url_key' => 'test', 'status' => DocumentModel::STATUS_ENABLE, 'user_id' => $this->user->getId(), 'document_type_id' => $this->documentType->getId(), 'view_id' => $this->view->getId(), 'layout_id' => $this->layout->getId(), 'parent_id' => null));
     $document->save();
     $this->dispatch($document->getUrl() . '?preview');
     $this->assertResponseStatusCode(200);
     $this->assertModuleName('GcFrontend');
     $this->assertControllerName('IndexController');
     $this->assertControllerClass('IndexController');
     $this->assertMatchedRouteName('cms');
     $document->delete();
     $enableCache = $this->config->setValue('cache_is_active', 0);
 }
コード例 #5
0
ファイル: IndexControllerTest.php プロジェクト: gotcms/gotcms
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  *
  * @return void
  */
 public function tearDown()
 {
     StaticEventManager::resetInstance();
     ModuleModel::uninstall(Registry::get('Application')->getServiceManager()->get('CustomModules')->getModule('Blog'), ModuleModel::fromName('Blog'));
     $this->document->delete();
     $this->view->delete();
     $this->layout->delete();
     $this->documentType->delete();
     unset($this->document);
     unset($this->object);
     unset($this->view);
     unset($this->layout);
     unset($this->documentType);
     parent::tearDown();
 }
コード例 #6
0
ファイル: CommentTest.php プロジェクト: gotcms/gotcms
 /**
  * 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();
     unset($this->document);
     unset($this->object);
     unset($this->view);
     unset($this->layout);
     unset($this->documentType);
     unset($this->user);
 }
コード例 #7
0
ファイル: AbstractEditorTest.php プロジェクト: gotcms/gotcms
 /**
  * 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->property->delete();
     $this->datatype->delete();
     $this->tab->delete();
     $this->documentType->delete();
     $this->user->delete();
     $this->view->delete();
     unset($this->datatype);
     unset($this->property);
     unset($this->documentType);
     unset($this->tab);
     unset($this->user);
     unset($this->view);
     unset($this->object);
 }
コード例 #8
0
ファイル: ModuleTest.php プロジェクト: gotcms/gotcms
 /**
  * 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();
     $this->documentType->delete();
     $this->user->delete();
     $this->layout->delete();
     $this->view->delete();
     unset($this->document);
     unset($this->documentType);
     unset($this->user);
     unset($this->layout);
     unset($this->view);
     unset($this->object);
     StaticEventManager::resetInstance();
     if (file_exists($this->filePath)) {
         unlink($this->filePath);
     }
 }
コード例 #9
0
ファイル: Partial.php プロジェクト: gotcms/gotcms
 /**
  * Returns script from identifier.
  *
  * @param string $name   Name of view script
  * @param array  $values Variables to populate in the view
  *
  * @return mixed
  */
 public function __invoke($name = null, $values = array())
 {
     if (empty($name)) {
         return $this;
     }
     $view = $this->cloneView();
     $this->assignVars($view, $values);
     try {
         $viewModel = ViewModel::fromIdentifier($name);
     } catch (\Exception $e) {
         //don't care
     }
     if (empty($viewModel)) {
         return $view->render($name);
     }
     $name = 'view/' . $name;
     return $view->render($name);
 }
コード例 #10
0
ファイル: ContentTest.php プロジェクト: gotcms/gotcms
 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);
 }
コード例 #11
0
ファイル: EditorTest.php プロジェクト: gotcms/gotcms
 /**
  * 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->layout->delete();
     $this->property->delete();
     $this->tab->delete();
     $this->user->delete();
     $this->view->delete();
     unset($this->datatype);
     unset($this->documentType);
     unset($this->layout);
     unset($this->property);
     unset($this->tab);
     unset($this->user);
     unset($this->view);
     unset($this->object);
 }
コード例 #12
0
ファイル: DocumentTypeTest.php プロジェクト: gotcms/gotcms
 /**
  * Test
  *
  * @return void
  */
 public function testInit()
 {
     $collection = new UserCollection();
     foreach ($collection->getUsers() as $user) {
         $user->delete();
     }
     unset($collection);
     $userModel = UserModel::fromArray(array('lastname' => 'Test', 'firstname' => 'Test', 'email' => '*****@*****.**', 'login' => 'test-user-model', 'user_acl_role_id' => 1));
     $userModel->setPassword('test-user-model-password');
     $userModel->save();
     $viewModel = ViewModel::fromArray(array('name' => 'View', 'identifier' => 'ViewIdentifier', 'description' => 'Description', 'content' => ''));
     $viewModel->save();
     $documentTypeModel = DocumentTypeModel::fromArray(array('name' => 'DocumentType', 'description' => 'description', 'icon_id' => 1, 'default_view_id' => $viewModel->getId(), 'user_id' => $userModel->getId()));
     $documentTypeModel->save();
     $form = new DocumentType();
     $this->assertNull($form->init());
     $viewModel->delete();
     $documentTypeModel->delete();
     $userModel->delete();
 }
コード例 #13
0
ファイル: TabsTest.php プロジェクト: gotcms/gotcms
 /**
  * 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();
 }
コード例 #14
0
ファイル: NavigationTest.php プロジェクト: gotcms/gotcms
 /**
  * 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);
 }
コード例 #15
0
 /**
  * test
  *
  * @return void
  */
 protected function createDocuments()
 {
     $this->view = View\Model::fromArray(array('name' => 'View Name', 'identifier' => 'View identifier', 'description' => 'View Description', 'content' => 'View Content'));
     $this->view->save();
     $this->layout = Layout\Model::fromArray(array('name' => 'Layout Name', 'identifier' => 'Layout identifier', 'description' => 'Layout Description', 'content' => 'Layout Content'));
     $this->layout->save();
     $this->user = User\Model::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 = DocumentType\Model::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->homeDocument = Document\Model::fromArray(array('name' => 'Document name', 'url_key' => '', 'status' => Document\Model::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' => 0));
     $this->homeDocument->save();
     $this->parentDocument = Document\Model::fromArray(array('name' => 'Document name', 'url_key' => 'parent', 'status' => Document\Model::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' => 0));
     $this->parentDocument->save();
     $this->document = Document\Model::fromArray(array('name' => 'Document name', 'url_key' => 'children', 'status' => Document\Model::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' => $this->parentDocument->getId()));
     $this->document->save();
 }
コード例 #16
0
 /**
  * Test
  *
  * @return void
  */
 public function testLoad()
 {
     $user = UserModel::fromArray(array('lastname' => 'Test', 'firstname' => 'Test', 'email' => '*****@*****.**', 'login' => 'test-user-model', 'user_acl_role_id' => 1));
     $user->setPassword('test-user-model-password');
     $user->save();
     $view = ViewModel::fromArray(array('name' => 'View', 'identifier' => 'ViewIdentifier', 'description' => 'Description', 'content' => ''));
     $view->save();
     $layout = LayoutModel::fromArray(array('name' => 'View', 'identifier' => 'ViewIdentifier', 'description' => 'Description', 'content' => ''));
     $layout->save();
     $documenttype = DocumentTypeModel::fromArray(array('name' => 'DocumentType', 'description' => 'description', 'icon_id' => 1, 'default_view_id' => $view->getId(), 'user_id' => $user->getId()));
     $documenttype->save();
     $documenttype->setDependencies(array($documenttype->getId()));
     $documenttype->save();
     $datatype = DatatypeModel::fromArray(array('name' => 'DatatypeTest', 'model' => 'Textstring'));
     $datatype->save();
     $tab = TabModel::fromArray(array('name' => 'test', 'description' => 'test', 'document_type_id' => $documenttype->getId()));
     $tab->save();
     $property = PropertyModel::fromArray(array('name' => 'test', 'identifier' => 'test', 'description' => 'test', 'tab_id' => $tab->getId(), 'datatype_id' => $datatype->getId(), 'is_required' => true));
     $property->save();
     $document = DocumentModel::fromArray(array('name' => 'test', 'url_key' => '', 'status' => DocumentModel::STATUS_ENABLE, 'user_id' => $user->getId(), 'document_type_id' => $documenttype->getId(), 'view_id' => $view->getId(), 'layout_id' => $layout->getId(), 'parent_id' => null));
     $document->save();
     $this->assertNull($this->object->load($document, array('locales' => array('en_GB' => 'English'))));
     $this->object->setData(array());
     $this->assertFalse($this->object->isValid());
     $document->delete();
     $documenttype->delete();
     $property->delete();
     $tab->delete();
     $view->delete();
     $layout->delete();
     $user->delete();
     $datatype->delete();
     unset($documenttype);
     unset($document);
     unset($property);
     unset($tab);
     unset($view);
     unset($layout);
     unset($user);
     unset($datatype);
 }
コード例 #17
0
ファイル: ViewControllerTest.php プロジェクト: gotcms/gotcms
 /**
  * Test
  *
  * @return void
  */
 public function testDownloadActionWithoutId()
 {
     $viewModel = ViewModel::fromArray(array('name' => 'ViewName', 'identifier' => 'ViewIdentifier', 'content' => 'Content'));
     $viewModel->save();
     $this->dispatch('/admin/development/view/download');
     $this->assertResponseStatusCode(200);
     $this->assertModuleName('GcDevelopment');
     $this->assertControllerName('ViewController');
     $this->assertControllerClass('ViewController');
     $this->assertMatchedRouteName('development/view/download');
     $viewModel->delete();
 }
コード例 #18
0
ファイル: Model.php プロジェクト: gotcms/gotcms
 /**
  * Initiliaze from identifier
  *
  * @param string $identifier Identifier
  *
  * @return \Gc\View\Model
  */
 public static function fromIdentifier($identifier)
 {
     $viewTable = new Model();
     $row = $viewTable->select(array('identifier' => $identifier));
     $current = $row->current();
     $viewTable->events()->trigger(__CLASS__, 'before.load', $viewTable);
     if (!empty($current)) {
         $viewTable = self::fromArray((array) $current);
         $viewTable->events()->trigger(__CLASS__, 'after.load', $viewTable);
         return $viewTable;
     } else {
         $viewTable->events()->trigger(__CLASS__, 'after.load.failed', $viewTable);
         return false;
     }
 }
コード例 #19
0
ファイル: CollectionTest.php プロジェクト: gotcms/gotcms
 /**
  * Test
  *
  * @return void
  */
 public function testDelete()
 {
     $model = Model::fromIdentifier('identifier-collection-test');
     $documentType = DocumentTypeModel::fromArray(array('name' => 'Document type name', 'description' => 'Document type description', 'defaultview_id' => $model->getId(), 'icon_id' => 1, 'user_id' => 1));
     $documentType->save();
     $this->object->init($documentType->getId());
     $this->object->addElement($model);
     $this->object->save();
     $this->assertTrue($this->object->delete());
     $documentType->delete();
 }
コード例 #20
0
ファイル: ModelTest.php プロジェクト: gotcms/gotcms
 /**
  * Test
  *
  * @return void
  */
 public function testSave()
 {
     $this->object->addViews(array($this->view->getId(), 0));
     $this->object->setDependencies(array($this->object->getId()));
     $this->assertInternalType('integer', (int) $this->object->save());
 }
コード例 #21
0
ファイル: ModelTest.php プロジェクト: gotcms/gotcms
 /**
  * Test
  *
  * @return void
  */
 public function testDeleteWithWrongId()
 {
     $configuration = Registry::get('Application')->getConfig();
     if ($configuration['db']['driver'] == 'pdo_mysql') {
         $this->markTestSkipped('Mysql does not thrown exception.');
     }
     $this->setExpectedException('Gc\\Exception');
     $model = new Model();
     $model->setId('undefined');
     $this->assertFalse($model->delete());
 }
コード例 #22
0
ファイル: Collection.php プロジェクト: gotcms/gotcms
 /**
  * Get views
  *
  * @param boolean $forceReload To initiliaze views
  *
  * @return array
  */
 public function getViews($forceReload = false)
 {
     if ($forceReload) {
         $select = new Select();
         $select->order(array('name'));
         $select->from('view');
         if ($this->getDocumentTypeId() !== null) {
             $select->join('document_type_view', 'document_type_view.view_id = view.id', array());
             $select->where->equalTo('document_type_view.document_type_id', $this->getDocumentTypeId());
         }
         $rows = $this->fetchAll($select);
         $views = array();
         foreach ($rows as $row) {
             $views[] = Model::fromArray((array) $row);
         }
         $this->setData('views', $views);
     }
     return $this->getData('views');
 }
コード例 #23
0
 /**
  * Test
  *
  * @return void
  */
 public function testImportTabActionWithPostData()
 {
     $viewModel = ViewModel::fromArray(array('name' => 'Test', 'identifier' => 'Test', 'content' => 'Test'));
     $viewModel->save();
     $datatypeModel = DatatypeModel::fromArray(array('name' => 'DatatypeTest', 'model' => 'Textstring'));
     $datatypeModel->save();
     $documentTypeModel = DocumentTypeModel::fromArray(array('name' => 'TestDocumentType', 'icon_id' => 3, 'default_view_id' => $viewModel->getId(), 'user_id' => $this->user->getId()));
     $documentTypeModel->save();
     $tabModel = TabModel::fromArray(array('name' => 'test', 'description' => 'test', 'document_type_id' => $documentTypeModel->getId()));
     $tabModel->save();
     $propertyModel = PropertyModel::fromArray(array('name' => 'test', 'identifier' => 'test', 'description' => 'test', 'tab_id' => $tabModel->getId(), 'datatype_id' => $datatypeModel->getId()));
     $propertyModel->save();
     $this->dispatch('/admin/development/document-type/import-tab', 'POST', array('tab_id' => $tabModel->getId()));
     $this->assertResponseStatusCode(200);
     $this->assertModuleName('GcDevelopment');
     $this->assertControllerName('DocumentTypeController');
     $this->assertControllerClass('DocumentTypeController');
     $this->assertMatchedRouteName('development/document-type/import-tab');
     $documentTypeModel->delete();
     $propertyModel->delete();
     $tabModel->delete();
     $viewModel->delete();
     $datatypeModel->delete();
 }
コード例 #24
0
ファイル: ModelTest.php プロジェクト: gotcms/gotcms
 /**
  * Test
  *
  * @return void
  */
 public function testSaveEditor()
 {
     $viewModel = ViewModel::fromArray(array('name' => 'View Name', 'identifier' => 'View identifier', 'description' => 'View Description', 'content' => 'View Content'));
     $viewModel->save();
     $layoutModel = LayoutModel::fromArray(array('name' => 'Layout Name', 'identifier' => 'Layout identifier', 'description' => 'Layout Description', 'content' => 'Layout Content'));
     $layoutModel->save();
     $userModel = UserModel::fromArray(array('lastname' => 'User test', 'firstname' => 'User test', 'email' => '*****@*****.**', 'login' => 'test', 'user_acl_role_id' => 1));
     $userModel->setPassword('test');
     $userModel->save();
     $documentTypeModel = DocumentTypeModel::fromArray(array('name' => 'Document Type Name', 'description' => 'Document Type description', 'icon_id' => 1, 'defaultview_id' => $viewModel->getId(), 'user_id' => $userModel->getId()));
     $documentTypeModel->save();
     $tabModel = TabModel::fromArray(array('name' => 'TabTest', 'description' => 'TabTest', 'sort_order' => 1, 'document_type_id' => $documentTypeModel->getId()));
     $tabModel->save();
     $documentModel = DocumentModel::fromArray(array('name' => 'DocumentTest', 'url_key' => 'document-test', 'status' => DocumentModel::STATUS_ENABLE, 'sort_order' => 1, 'show_in_nav' => true, 'user_id' => $userModel->getId(), 'document_type_id' => $documentTypeModel->getId(), 'view_id' => $viewModel->getId(), 'layout_id' => $layoutModel->getId(), 'parent_id' => 0));
     $documentModel->save();
     $propertyModel = PropertyModel::fromArray(array('datatype_id' => $this->object->getId(), 'document_id' => $documentModel->getId(), 'tab_id' => $tabModel->getId(), 'name' => 'PropertyTest', 'identifier' => 'PropertyTest', 'description' => 'PropertyTest', 'required' => true, 'sort_order' => 1));
     $propertyModel->save();
     $this->assertFalse(Model::saveEditor(Registry::get('Application')->getServiceManager(), $propertyModel));
     $propertyModel->isRequired(false);
     $this->assertTrue(Model::saveEditor(Registry::get('Application')->getServiceManager(), $propertyModel));
     $propertyModel->delete();
     $documentModel->delete();
     $tabModel->delete();
     $documentTypeModel->delete();
     $viewModel->delete();
     $layoutModel->delete();
 }
コード例 #25
0
ファイル: ModelTest.php プロジェクト: gotcms/gotcms
 /**
  * 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()));
 }
コード例 #26
0
ファイル: DocumentInformation.php プロジェクト: gotcms/gotcms
 /**
  * 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);
 }
コード例 #27
0
ファイル: ViewController.php プロジェクト: gotcms/gotcms
 /**
  * Send a file to the browser
  *
  * @return \Zend\Stdlib\ResponseInterface
  */
 public function downloadAction()
 {
     $viewId = $this->getRouteMatch()->getParam('id', null);
     if (!empty($viewId)) {
         $view = View\Model::fromId($viewId);
         if (empty($view)) {
             $this->flashMessenger()->addErrorMessage('This view can not be download');
             return $this->redirect()->toRoute('development/view/edit', array('id' => $viewId));
         }
         $content = $view->getContent();
         $filename = $view->getIdentifier() . '.phtml';
     } else {
         $views = new View\Collection();
         $children = $views->getViews();
         $zip = new ZipArchive();
         $tmpFilename = tempnam(sys_get_temp_dir(), 'zip');
         $res = $zip->open($tmpFilename, ZipArchive::CREATE);
         if ($res === true) {
             foreach ($children as $child) {
                 $zip->addFromString($child->getIdentifier() . '.phtml', $child->getContent());
             }
             $zip->close();
             $content = file_get_contents($tmpFilename);
             $filename = 'views.zip';
             unlink($tmpFilename);
         }
     }
     if (empty($content) or empty($filename)) {
         $this->flashMessenger()->addErrorMessage('Can not save views');
         return $this->redirect()->toRoute('development/view');
     }
     $headers = new Headers();
     $headers->addHeaderLine('Pragma', 'public')->addHeaderLine('Cache-control', 'must-revalidate, post-check=0, pre-check=0')->addHeaderLine('Cache-control', 'private')->addHeaderLine('Expires', -1)->addHeaderLine('Content-Type', 'application/octet-stream')->addHeaderLine('Content-Transfer-Encoding', 'binary')->addHeaderLine('Content-Length', strlen($content))->addHeaderLine('Content-Disposition', 'attachment; filename=' . $filename);
     $response = $this->getResponse();
     $response->setHeaders($headers);
     $response->setContent($content);
     return $response;
 }
コード例 #28
0
ファイル: PartialTest.php プロジェクト: gotcms/gotcms
 /**
  * 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->view->delete();
     unset($this->object);
 }
コード例 #29
0
ファイル: Model.php プロジェクト: gotcms/gotcms
 /**
  * get View Model
  *
  * @return \Gc\View\Model
  */
 public function getView()
 {
     if ($this->getData('view') == null) {
         $view = View\Model::fromId($this->getViewId());
         if ($view !== null) {
             $this->setData('view', $view);
         }
     }
     return $this->getData('view');
 }