save() public method

Save document type model
public save ( ) : integer
return integer
Example #1
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 #2
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->object = Model::fromArray(array('name' => 'TabTest', 'description' => 'TabTest', 'sort_order' => 1, 'document_type_id' => $this->documentType->getId()));
     $this->object->save();
 }
Example #3
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 #4
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->datatype = DatatypeModel::fromArray(array('name' => 'UploadTest', 'prevalue_value' => 'a:1:{s:6:"length";i:10;}', 'model' => 'Upload'));
     $this->datatype->save();
     $this->tab = TabModel::fromArray(array('name' => 'TabTest', 'description' => 'TabTest', 'sort_order' => 1, 'document_type_id' => $this->documentType->getId()));
     $this->tab->save();
     $this->property = PropertyModel::fromArray(array('name' => 'DatatypeTest', 'identifier' => 'DatatypeTest', 'description' => 'DatatypeTest', 'required' => false, 'sort_order' => 1, 'tab_id' => $this->tab->getId(), 'datatype_id' => $this->datatype->getId()));
     $this->property->save();
     $this->document = DocumentModel::fromArray(array('name' => 'jQueryFileUploadTest', 'url_key' => '/jqueryfileupload-test', 'status' => DocumentModel::STATUS_ENABLE, 'sort_order' => 1, 'show_in_nav' => false, '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->document->save();
     $datatype = new Datatype();
     $application = Registry::get('Application');
     $datatype->setRequest($application->getServiceManager()->get('Request'));
     $datatype->setRouter($application->getServiceManager()->get('Router'));
     $datatype->setHelperManager($application->getServiceManager()->get('viewhelpermanager'));
     $datatype->load($this->datatype, $this->document->getId());
     $this->object = $datatype->getEditor($this->property);
 }
Example #5
0
 protected function createContent()
 {
     $this->view = ViewModel::fromArray(array('name' => 'View', 'identifier' => 'ViewContentIdentifier', 'description' => 'Description', 'content' => 'Content of the webpage <br/>This is my view'));
     $this->view->save();
     $this->layout = LayoutModel::fromArray(array('name' => 'Layout', 'identifier' => 'LayoutContentIdentifier', 'description' => 'Description', 'content' => '<?php echo $this->content; '));
     $this->layout->save();
     $this->script = ScriptModel::fromArray(array('name' => 'Script', 'identifier' => 'ScriptContentIdentifier', 'description' => 'Description', 'content' => ''));
     $this->script->save();
     $this->documentType = DocumentTypeModel::fromArray(array('name' => 'DocumentType', 'description' => 'description', 'icon_id' => 1, 'default_view_id' => $this->view->getId(), 'user_id' => $this->user->getId()));
     $this->documentType->save();
     $this->documentType->setDependencies(array($this->documentType->getId()));
     $this->documentType->addView($this->view->getId());
     $this->documentType->save();
     $this->datatype = DatatypeModel::fromArray(array('name' => 'DatatypeTest', 'model' => 'Textstring'));
     $this->datatype->save();
     $this->tabModel = TabModel::fromArray(array('name' => 'test', 'description' => 'test', 'document_type_id' => $this->documentType->getId()));
     $this->tabModel->save();
     $this->property = PropertyModel::fromArray(array('name' => 'test', 'identifier' => 'azd', 'description' => 'test', 'tab_id' => $this->tabModel->getId(), 'datatype_id' => $this->datatype->getId(), 'is_required' => true));
     $this->property->save();
     $this->document = DocumentModel::fromArray(array('name' => 'test', 'url_key' => '', '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));
     $this->document->save();
     $this->property->setDocumentId($this->document->getId());
     $this->property->setValue('string');
     $this->property->saveValue();
 }
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()
 {
     $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();
     $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', $this->document);
     $serviceManager->setAllowOverride(false);
     $this->object = new CommentForm();
     $this->module = ModuleModel::fromArray(array('name' => 'Blog'));
     $this->module->save();
     $this->boostrap = new Module();
     $this->boostrap->install();
 }
Example #7
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->datatype = DatatypeModel::fromArray(array('name' => 'ImageCropperTest', 'prevalue_value' => '', 'model' => 'ImageCropper'));
     $this->datatype->save();
     $this->tab = TabModel::fromArray(array('name' => 'TabTest', 'description' => 'TabTest', 'sort_order' => 1, 'document_type_id' => $this->documentType->getId()));
     $this->tab->save();
     $this->property = PropertyModel::fromArray(array('name' => 'DatatypeTest', 'identifier' => 'DatatypeTest', 'description' => 'DatatypeTest', 'required' => false, 'sort_order' => 1, 'tab_id' => $this->tab->getId(), 'datatype_id' => $this->datatype->getId()));
     $this->property->save();
     $this->document = DocumentModel::fromArray(array('name' => 'jQueryFileUploadTest', 'url_key' => '/jqueryfileupload-test', 'status' => DocumentModel::STATUS_ENABLE, 'sort_order' => 1, 'show_in_nav' => false, '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->document->save();
     $datatype = new Datatype();
     $application = Registry::get('Application');
     $datatype->setRequest($application->getServiceManager()->get('Request'));
     $datatype->setRouter($application->getServiceManager()->get('Router'));
     $datatype->setHelperManager($application->getServiceManager()->get('viewhelpermanager'));
     $datatype->load($this->datatype, $this->document->getId());
     $this->object = $datatype->getEditor($this->property);
     $this->object->setConfig(array('background' => '#FFFFFF', 'resize_option' => 'auto', 'mime_list' => array('image/gif', 'image/jpeg', 'image/png'), 'size' => array(array('name' => '223x112', 'width' => '223', 'height' => '112'), array('name' => '600x300', 'width' => '600', 'height' => '300'))));
 }
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->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->datatype = DatatypeModel::fromArray(array('name' => 'TextrichTest', 'prevalue_value' => 'a:1:{s:13:"toolbar-items";a:67:{s:6:"Source";s:1:"1";s:4:"Save";' . 's:1:"1";s:7:"NewPage";s:1:"1";s:8:"DocProps";s:1:"1";s:7:"Preview";s:1:"1";s:5:"Print";' . 's:1:"1";s:9:"Templates";s:1:"1";s:3:"Cut";s:1:"1";s:4:"Copy";s:1:"1";s:5:"Paste";s:1:"1";' . 's:9:"PasteText";s:1:"1";s:13:"PasteFromWord";s:1:"1";s:4:"Undo";s:1:"1";s:4:"Redo";s:1:"1";' . 's:4:"Find";s:1:"1";s:7:"Replace";s:1:"1";s:9:"SelectAll";s:1:"1";s:12:"SpellChecker";s:1:"1";' . 's:5:"Scayt";s:1:"1";s:4:"Form";s:1:"1";s:8:"Checkbox";s:1:"1";s:5:"Radio";s:1:"1";' . 's:9:"TextField";s:1:"1";s:8:"Textarea";s:1:"1";s:6:"Select";s:1:"1";s:6:"Button";s:1:"1";' . 's:11:"ImageButton";s:1:"1";s:11:"HiddenField";s:1:"1";s:4:"Bold";s:1:"1";s:6:"Italic";' . 's:1:"1";s:9:"Underline";s:1:"1";s:6:"Strike";s:1:"1";s:9:"Subscript";s:1:"1";' . 's:11:"Superscript";s:1:"1";s:12:"RemoveFormat";s:1:"1";s:12:"NumberedList";s:1:"1";' . 's:12:"BulletedList";s:1:"1";s:7:"Outdent";s:1:"1";s:6:"Indent";' . 's:1:"1";s:10:"Blockquote";s:1:"1";s:9:"CreateDiv";s:1:"1";s:11:"JustifyLeft";s:1:"1";' . 's:13:"JustifyCenter";s:1:"1";s:12:"JustifyRight";s:1:"1";s:12:"JustifyBlock";s:1:"1";' . 's:7:"BidiLtr";s:1:"1";s:7:"BidiRtl";s:1:"1";s:4:"Link";s:1:"1";s:6:"Unlink";s:1:"1";' . 's:6:"Anchor";s:1:"1";s:5:"Image";s:1:"1";s:5:"Flash";' . 's:1:"1";s:5:"Table";s:1:"1";s:14:"HorizontalRule";s:1:"1";s:6:"Smiley";' . 's:1:"1";s:11:"SpecialChar";s:1:"1";' . 's:9:"PageBreak";s:1:"1";s:6:"Iframe";s:1:"1";s:6:"Styles";s:1:"1";s:6:"Format";' . 's:1:"1";s:4:"Font";' . 's:1:"1";s:8:"FontSize";s:1:"1";s:9:"TextColor";s:1:"1";s:7:"BGColor";s:1:"1";' . 's:8:"Maximize";s:1:"1";' . 's:10:"ShowBlocks";s:1:"1";s:5:"About";s:1:"1";}}', 'model' => 'Textrich'));
     $this->datatype->save();
     $this->tab = TabModel::fromArray(array('name' => 'TabTest', 'description' => 'TabTest', 'sort_order' => 1, 'document_type_id' => $this->documentType->getId()));
     $this->tab->save();
     $this->property = PropertyModel::fromArray(array('name' => 'DatatypeTest', 'identifier' => 'DatatypeTest', 'description' => 'DatatypeTest', 'required' => false, 'sort_order' => 1, 'tab_id' => $this->tab->getId(), 'datatype_id' => $this->datatype->getId()));
     $this->property->save();
     $datatype = new Datatype();
     $application = Registry::get('Application');
     $datatype->setRequest($application->getServiceManager()->get('Request'));
     $datatype->setRouter($application->getServiceManager()->get('Router'));
     $datatype->setHelperManager($application->getServiceManager()->get('viewhelpermanager'));
     $datatype->load($this->datatype);
     $this->object = $datatype->getEditor($this->property);
 }
Example #9
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->datatype = DatatypeModel::fromArray(array('name' => 'CheckboxListTest', 'prevalue_value' => '', 'model' => 'CheckboxList'));
     $this->datatype->save();
     $this->tab = TabModel::fromArray(array('name' => 'TabTest', 'description' => 'TabTest', 'sort_order' => 1, 'document_type_id' => $this->documentType->getId()));
     $this->tab->save();
     $this->property = PropertyModel::fromArray(array('name' => 'DatatypeTest', 'identifier' => 'DatatypeTest', 'description' => 'DatatypeTest', 'required' => false, 'sort_order' => 1, 'tab_id' => $this->tab->getId(), 'datatype_id' => $this->datatype->getId()));
     $this->property->save();
     $datatype = new Datatype();
     $application = Registry::get('Application');
     $datatype->setRequest($application->getServiceManager()->get('Request'));
     $datatype->setRouter($application->getServiceManager()->get('Router'));
     $datatype->setHelperManager($application->getServiceManager()->get('viewhelpermanager'));
     $datatype->load($this->datatype);
     $this->object = $datatype->getEditor($this->property);
 }
Example #10
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' => 0));
     $this->document->save();
     $this->object = new Documents();
     $view = new View();
     $view->resolver()->addPath(__DIR__ . '/_files/views');
     $view->setHelperPluginManager(Registry::get('Application')->getServiceManager()->get('viewhelpermanager'));
     $this->object->setView($view);
 }
Example #11
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', 'identifier' => 'ViewIdentifier', 'description' => 'Description', 'content' => ''));
     $this->view->save();
     $this->layout = LayoutModel::fromArray(array('name' => 'View', 'identifier' => 'ViewIdentifier', 'description' => 'Description', 'content' => ''));
     $this->layout->save();
     $this->documentType = DocumentTypeModel::fromArray(array('name' => 'DocumentType', 'description' => 'description', 'icon_id' => 1, 'default_view_id' => $this->view->getId(), 'user_id' => $this->user->getId()));
     $this->documentType->save();
     $this->documentType->setDependencies(array($this->documentType->getId()));
     $this->documentType->save();
     $this->datatype = DatatypeModel::fromArray(array('name' => 'DatatypeTest', 'model' => 'Textstring'));
     $this->datatype->save();
     $this->tabModel = TabModel::fromArray(array('name' => 'test', 'description' => 'test', 'document_type_id' => $this->documentType->getId()));
     $this->tabModel->save();
     $this->property = PropertyModel::fromArray(array('name' => 'test', 'identifier' => 'test', 'description' => 'test', 'tab_id' => $this->tabModel->getId(), 'datatype_id' => $this->datatype->getId(), 'is_required' => true));
     $this->property->save();
     $this->document = DocumentModel::fromArray(array('name' => 'test', 'url_key' => '', '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));
     $this->document->save();
 }
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()
 {
     $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->datatype = DatatypeModel::fromArray(array('name' => 'TextrichTest', 'prevalue_value' => '', 'model' => 'Textrich'));
     $this->datatype->save();
     $this->tab = TabModel::fromArray(array('name' => 'TabTest', 'description' => 'TabTest', 'sort_order' => 1, 'document_type_id' => $this->documentType->getId()));
     $this->tab->save();
     $this->property = PropertyModel::fromArray(array('name' => 'DatatypeTest', 'identifier' => 'DatatypeTest', 'description' => 'DatatypeTest', 'required' => false, 'sort_order' => 1, 'tab_id' => $this->tab->getId(), 'datatype_id' => $this->datatype->getId()));
     $this->property->save();
     $this->object = new Datatype($this->datatype);
 }
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', 'identifier' => 'ViewIdentifier', 'description' => 'Description', 'content' => ''));
     $this->view->save();
     $this->layout = LayoutModel::fromArray(array('name' => 'View', 'identifier' => 'LayoutIdentifier', 'description' => 'Description', 'content' => ''));
     $this->layout->save();
     $this->documentType = DocumentTypeModel::fromArray(array('name' => 'DocumentType', 'description' => 'description', 'icon_id' => 1, 'default_view_id' => $this->view->getId(), 'user_id' => $this->user->getId()));
     $this->documentType->save();
     $this->documentType->setDependencies(array($this->documentType->getId()));
     $this->documentType->save();
     $this->datatype = DatatypeModel::fromArray(array('name' => 'DatatypeTest', 'model' => 'Textstring'));
     $this->datatype->save();
     $this->tabModel = TabModel::fromArray(array('name' => 'test', 'description' => 'test', 'document_type_id' => $this->documentType->getId()));
     $this->tabModel->save();
     $this->property = PropertyModel::fromArray(array('name' => 'test', 'identifier' => 'test', 'description' => 'test', 'tab_id' => $this->tabModel->getId(), 'datatype_id' => $this->datatype->getId(), 'is_required' => true));
     $this->property->save();
     $this->config = Registry::get('Application')->getServiceManager()->get('CoreConfig');
     $this->getApplicationServiceLocator()->get('ViewTemplatePathStack')->addPath(GC_TEMPLATE_PATH);
     $this->getApplicationServiceLocator()->get('Auth')->clearIdentity();
 }
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->tab = TabModel::fromArray(array('name' => 'TabTest', 'description' => 'TabTest', 'sort_order' => 1, 'document_type_id' => $this->documentType->getId()));
     $this->tab->save();
     $this->datatype = DatatypeModel::fromArray(array('name' => 'BooleanTest', 'prevalue_value' => '', 'model' => 'Boolean'));
     $this->datatype->save();
     $this->property = PropertyModel::fromArray(array('name' => 'DatatypeTest', 'identifier' => 'DatatypeTest', 'description' => 'DatatypeTest', 'required' => false, 'sort_order' => 1, 'tab_id' => $this->tab->getId(), 'datatype_id' => $this->datatype->getId()));
     $this->property->save();
     $this->document = 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));
     $this->document->save();
     $this->object = Model::fromArray(array('document_id' => $this->document->getId(), 'property_id' => $this->property->getId(), 'value' => ''));
     $this->object->save();
 }
Example #15
0
 /**
  * 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());
 }
Example #16
0
 /**
  * Import Document types
  *
  * @param array &$ids     Ids
  * @param array &$errors  Errors
  * @param array $children Children list
  *
  * @return void
  */
 protected function importDocumentTypes(&$ids, &$errors, $children)
 {
     $documentTypes = array();
     foreach ($children['children'] as $child) {
         $attributes = $child->attributes();
         $id = (int) $attributes['id'];
         $model = DocumentType\Model::fromId($id);
         if (empty($model)) {
             $model = new DocumentType\Model();
         }
         $viewid = isset($ids['views'][(int) $child->default_view_id]) ? $ids['views'][(int) $child->default_view_id] : (int) $child->default_view_id;
         $name = (string) $child->name;
         $model->addData(array('name' => empty($name) ? $model->getName() : $name, 'description' => (string) $child->description, 'icon_id' => (int) $child->icon_id, 'default_view_id' => $viewid));
         if ($model->getUserId() === null) {
             $model->setUserId($this->serviceLocator->get('Auth')->getIdentity()->getId());
         }
         try {
             if (!empty($model)) {
                 $model->save();
                 $tabs = (array) $child->tabs;
                 if (isset($tabs['tab']) and is_array($tabs['tab'])) {
                     $tabs = $tabs['tab'];
                 }
                 foreach ($tabs as $tab) {
                     $tabAttributes = $tab->attributes();
                     $tabId = (int) $tabAttributes['id'];
                     $tabModel = Tab\Model::fromId($tabId);
                     if (empty($tabModel)) {
                         $tabModel = new Tab\Model();
                     }
                     $tabModel->addData(array('name' => (string) $tab->name, 'description' => (string) $tab->description, 'sort_order' => (int) $tab->sort_order, 'document_type_id' => $model->getId()));
                     $tabModel->save();
                     $properties = (array) $tab->properties;
                     if (isset($properties['property']) and is_array($properties['property'])) {
                         $properties = $properties['property'];
                     }
                     foreach ($properties as $property) {
                         $propAttributes = $property->attributes();
                         $propertyId = (int) $propAttributes['id'];
                         $propertyModel = Property\Model::fromId($propertyId);
                         if (empty($propertyModel)) {
                             $propertyModel = new Property\Model();
                         }
                         $datatypeId = isset($ids['datatypes'][(int) $property->datatype_id]) ? $ids['datatypes'][(int) $property->datatype_id] : (string) $property->datatype_id;
                         $propertyModel->addData(array('name' => (string) $property->name, 'description' => (string) $property->description, 'identifier' => (string) $property->identifier, 'sort_order' => (int) $property->sort_order, 'tab_id' => $tabModel->getId(), 'datatype_id' => $datatypeId));
                         $propertyModel->save();
                         $ids['properties'][$propertyId] = $propertyModel->getId();
                     }
                 }
                 $ids['document_types'][$id] = $model->getId();
                 $documentTypes[] = array('model' => $model, 'dependencies' => (array) $child->dependencies, 'views' => (array) $child->available_views);
             }
         } catch (Exception $e) {
             $errors[] = sprintf($this->serviceLocator->get('MvcTranslator')->translate('Cannot save document type with id (%d)'), $id);
         }
     }
     return $documentTypes;
 }
Example #17
0
 /**
  * Create document type
  *
  * @return \Zend\View\Model\ViewModel|array
  */
 public function createAction()
 {
     $form = new DocumentTypeForm();
     $form->setAttribute('action', $this->url()->fromRoute('development/document-type/create', array()));
     $request = $this->getRequest();
     $session = $this->getSession();
     if (!$request->isPost()) {
         $session['document-type'] = array('tabs' => array());
     } else {
         $postData = $this->getRequest()->getPost()->toArray();
         $form->setData($postData);
         $form->setValues($postData);
         if (!$form->isValid()) {
             $this->flashMessenger()->addErrorMessage('Can not save document type');
             $this->useFlashMessenger();
         } else {
             $input = $form->getInputFilter();
             $infosSubform = $input->get('infos');
             $viewsSubform = $input->get('views');
             $documentType = new DocumentType\Model();
             $documentType->addData(array('name' => $infosSubform->getValue('name'), 'icon_id' => $infosSubform->getValue('icon_id'), 'description' => $infosSubform->getValue('description'), 'default_view_id' => $viewsSubform->getValue('default_view'), 'user_id' => $this->getServiceLocator()->get('Auth')->getIdentity()->getId()));
             $documentType->getAdapter()->getDriver()->getConnection()->beginTransaction();
             try {
                 $availableViews = $viewsSubform->getValue('available_views');
                 if (empty($availableViews)) {
                     $availableViews = array();
                 }
                 $documentType->addViews($availableViews);
                 $documentType->setDependencies($infosSubform->getValue('dependency'));
                 $documentType->save();
                 $existingTabs = $this->saveTabs($input->get('tabs'), $documentType);
                 $this->saveProperties($input->get('properties'), $existingTabs);
                 $documentType->getAdapter()->getDriver()->getConnection()->commit();
                 $this->flashMessenger()->addSuccessMessage('This document type has been saved');
                 return $this->redirect()->toRoute('development/document-type/edit', array('id' => $documentType->getId()));
             } catch (Exception $e) {
                 $documentType->getAdapter()->getDriver()->getConnection()->rollBack();
                 throw new \Gc\Exception('Error Processing Request ' . print_r($e, true), 1);
             }
         }
     }
     return array('form' => $form);
 }