Ejemplo n.º 1
0
 /**
  * Get resource provider with mocks
  *
  * @param bool $skipSite Skip Site Mock setup
  *
  * @return ResourceProvider
  */
 protected function getProviderWithMocks($skipSite = false)
 {
     $mockReturn = [];
     $currdomain = new Domain();
     $currdomain->setDomainName('curr.reliv.com');
     $currpage = new Page();
     $currpage->setName('curr-page');
     $currsite = new Site();
     $currsite->setDomain($currdomain);
     $currsite->setSiteId(1);
     $currsite->addPage($currpage);
     if (!$skipSite) {
         $domain = new Domain();
         $domain->setDomainName('test.reliv.com');
         $page = new Page();
         $page->setName('test-page');
         $site = new Site();
         $site->setDomain($domain);
         $site->setSiteId(10);
         $site->addPage($page);
         $mockReturn[] = $site;
     }
     $mockSiteRepo = $this->getMockBuilder('\\Rcm\\Repository\\Site')->disableOriginalConstructor()->getMock();
     $mockSiteRepo->expects($this->any())->method('getSites')->will($this->returnValue($mockReturn));
     /** @var \Rcm\Repository\Site $mockSiteRepo */
     /** @var \Rcm\Service\PluginManager $mockPluginManager */
     return new ResourceProvider($this->config, $mockSiteRepo, $currsite);
 }
 /**
  * testSetGet
  *
  * @return void
  */
 public function testSetGet()
 {
     $entity = new RcmGoogleAnalytics();
     $data = ['id' => 123, 'trackingId' => 'UA00000', 'verificationCode' => 'ggggg', 'siteId' => 321, 'host' => 'test.example.com'];
     $domain = new Domain();
     $domain->setDomainName('test.example.com');
     $data['site'] = new Site();
     $data['site']->setSiteId(3211);
     $data['site']->setDomain($domain);
     $entity->setId($data['id']);
     $this->assertEquals($data['id'], $entity->getId());
     $entity->setTrackingId($data['trackingId']);
     $this->assertEquals($data['trackingId'], $entity->getTrackingId());
     $this->assertTrue($entity->hasTracking());
     $entity->setVerificationCode($data['verificationCode']);
     $this->assertEquals($data['verificationCode'], $entity->getVerificationCode());
     $this->assertTrue($entity->hasVerificationCode());
     $this->assertNull($entity->getHost());
     $siteNoDomain = new Site();
     $siteNoDomain->setSiteId(3311);
     $entity->setSite($siteNoDomain);
     $this->assertNull($entity->getHost());
     $entity->setSite($data['site']);
     $this->assertEquals($data['site'], $entity->getSite());
     $this->assertEquals($data['site']->getSiteId(), $entity->getSiteId());
     $this->assertEquals($data['site']->getDomain()->getDomainName(), $entity->getHost());
     $array = $entity->toArray();
     $this->assertTrue(is_array($array));
     $this->assertEquals($data['host'], $array['host']);
 }
Ejemplo n.º 3
0
 public function setup()
 {
     $country = new Country();
     $country->setIso2('US');
     $lang = new Language();
     $lang->setIso6391('en');
     $site = new Site();
     $site->setCountry($country);
     $site->setLanguage($lang);
     $mockSiteRepo = $this->getMockBuilder('\\Rcm\\Repository\\Site')->disableOriginalConstructor()->getMock();
     $mockSiteRepo->expects($this->any())->method('getSites')->will($this->returnValue([$site]));
     $this->unit = new Locales($mockSiteRepo);
 }
 /**
  * testGets
  *
  * @return void
  */
 public function testGets()
 {
     $currentSite = new Site();
     $currentSite->setSiteId(321);
     $default = 'DEFAULT';
     $defCase = $this->getTestCase('_default');
     $unit = new RcmGoogleAnalytics($this->getMockEntityManger($defCase), $currentSite);
     $this->assertInstanceOf('\\Reliv\\RcmGoogleAnalytics\\Entity\\RcmGoogleAnalytics', $unit->getSiteAnalyticEntity($currentSite, $default));
     $this->assertInstanceOf('\\Reliv\\RcmGoogleAnalytics\\Entity\\RcmGoogleAnalytics', $unit->getCurrentAnalyticEntity($default));
     $this->assertInstanceOf('\\Reliv\\RcmGoogleAnalytics\\Entity\\RcmGoogleAnalytics', $unit->getCurrentAnalyticEntityWithVerifyCode($defCase['entity']['verificationCode']));
     $this->assertEquals($default, $unit->getCurrentAnalyticEntityWithVerifyCode('nope', $default));
     $unit = new RcmGoogleAnalytics($this->getMockEntityManger($this->getTestCase('case1')), $currentSite);
     $this->assertEquals($default, $unit->getSiteAnalyticEntity($currentSite, $default));
 }
Ejemplo n.º 5
0
 public function createSite($domainName, $country, $language, $theme)
 {
     $em = $this->entityManager;
     $domain = new Domain();
     $domain->setDomainName($domainName);
     $em->persist($domain);
     /** @var \Rcm\Repository\Country $countryRepo */
     $countryRepo = $em->getRepository('\\Rcm\\Entity\\Country');
     $countryEntity = $countryRepo->getCountryByString($country);
     /** @var \Rcm\Repository\Language $languageRepo */
     $languageRepo = $em->getRepository('\\Rcm\\Entity\\Language');
     $languageEntity = $languageRepo->getLanguageByString($language);
     $site = new Site();
     $site->setDomain($domain);
     $site->setCountry($countryEntity);
     $site->setLanguage($languageEntity);
     $site->setTheme($theme);
     $site->setSiteLayout('default');
     $site->setStatus('A');
     $this->createSiteContainers($site, $theme);
     $this->createPages($site, $theme);
     $em->persist($site);
     $em->flush();
     return $site;
 }
Ejemplo n.º 6
0
 /**
  * Initialize the form
  *
  * @return void
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function init()
 {
     $pageList = $this->pageRepo->getAllPageIdsAndNamesBySiteThenType($this->currentSite->getSiteId(), 't');
     $pageList['blank'] = 'Blank Page (Experts Only)';
     $filter = new InputFilter();
     $this->add(['name' => 'url', 'options' => ['label' => 'Page Url'], 'type' => 'text']);
     $filter->add(['name' => 'url', 'required' => true, 'filters' => [['name' => 'StripTags'], ['name' => 'StringTrim', 'options' => ['charlist' => '-_']]], 'validators' => [$this->pageValidator]]);
     $this->add(['name' => 'title', 'options' => ['label' => 'Page Title'], 'type' => 'text']);
     $filter->add(['name' => 'title', 'required' => true, 'filters' => [['name' => 'StripTags'], ['name' => 'StringTrim']], 'validators' => [['name' => '\\Zend\\I18n\\Validator\\Alnum', 'options' => ['allowWhiteSpace' => true]]]]);
     $this->add(['name' => 'page-template', 'options' => ['label' => 'Page Template', 'value_options' => $pageList], 'type' => 'Zend\\Form\\Element\\Select']);
     $filter->add(['name' => 'page-template', 'required' => true, 'filters' => [['name' => 'StripTags'], ['name' => 'StringTrim']], 'validators' => [$this->templateValidator]]);
     $this->add(['name' => 'main-layout', 'options' => ['label' => 'Main Layout', 'layouts' => $this->layoutManager->getSiteThemeLayoutsConfig($this->currentSite->getTheme())], 'type' => 'mainLayout']);
     $filter->add(['name' => 'main-layout', 'filters' => [['name' => 'StripTags'], ['name' => 'StringTrim']], 'validators' => [$this->layoutValidator]]);
     $this->setInputFilter($filter);
 }
Ejemplo n.º 7
0
 /**
  * prepPageRevisionForDisplay
  *
  * @param Page $page
  * @param null $pageRevisionId
  *
  * @return void|Response
  */
 public function prepPageRevisionForDisplay(Page $page, $pageRevisionId = null)
 {
     //  First Check for a page Revision
     if (!empty($pageRevisionId)) {
         $userCanSeeRevisions = $this->shouldShowRevisions($this->currentSite->getSiteId(), $page->getName(), $page->getPageType());
         if ($userCanSeeRevisions) {
             $revision = $page->getRevisionById($pageRevisionId);
             if (!empty($revision) || $revision instanceof Revision) {
                 $page->setCurrentRevision($revision);
             }
             return;
         } else {
             return $this->redirectToPage($page->getName(), $page->getPageType());
         }
     }
     // Check for staging
     if ($this->rcmIsSiteAdmin($this->currentSite)) {
         $revision = $page->getStagedRevision();
         if (!empty($revision) || $revision instanceof Revision) {
             $page->setCurrentRevision($revision);
             return;
         }
     }
     // Finally look for published revision
     $revision = $page->getPublishedRevision();
     if (!empty($revision) || $revision instanceof Revision) {
         $page->setCurrentRevision($revision);
     }
     return;
 }
Ejemplo n.º 8
0
 /**
  * savePageAction
  *
  * @return Response|\Zend\Http\Response
  */
 public function savePageAction()
 {
     if (!$this->rcmIsAllowed('sites.' . $this->currentSite->getSiteId() . '.pages', 'edit')) {
         $response = new Response();
         $response->setStatusCode('401');
         return $response;
     }
     // @todo - might validate these against the data coming in
     $pageName = $this->getEvent()->getRouteMatch()->getParam('rcmPageName', 'index');
     $pageRevision = $this->getEvent()->getRouteMatch()->getParam('rcmPageRevision', null);
     $pageType = $this->getEvent()->getRouteMatch()->getParam('rcmPageType', 'n');
     /** @var \Zend\Http\Request $request */
     $request = $this->getRequest();
     if ($request->isPost()) {
         /** @var \Zend\Stdlib\Parameters $data */
         $data = $request->getPost()->toArray();
         $this->prepSaveData($data);
         $result = $this->pageRepo->savePage($this->currentSite, $pageName, $pageRevision, $pageType, $data, $this->rcmUserGetCurrentUser()->getName());
         if (empty($result)) {
             $return['redirect'] = $this->urlToPage($pageName, $pageType, $pageRevision);
         } else {
             $return['redirect'] = $this->urlToPage($pageName, $pageType, $result);
         }
         return $this->getJsonResponse($return);
     }
     $response = new Response();
     $response->setStatusCode('404');
     return $response;
 }
Ejemplo n.º 9
0
 /**
  * Get a container revision
  *
  * @param $revisionData
  *
  * @return Revision
  */
 private function getRevision($revisionData)
 {
     $revision = new Revision();
     $revision->setRevisionId($revisionData['revisionId']);
     $revision->setAuthor($revisionData['author']);
     $revision->setCreatedDate($revisionData['createdDate']);
     $revision->publishRevision();
     $revision->setPublishedDate($revisionData['publishedDate']);
     $revision->setMd5($revisionData['md5']);
     foreach ($revisionData['instances'] as $instance) {
         $plugin = new PluginInstance();
         $plugin->setInstanceId($instance['instance']['pluginInstanceId']);
         $plugin->setPlugin($instance['instance']['plugin']);
         $plugin->setDisplayName($instance['instance']['displayName']);
         $plugin->setInstanceConfig($instance['instance']['instanceConfig']);
         $plugin->setMd5($instance['instance']['md5']);
         if ($instance['instance']['siteWide']) {
             $plugin->setSiteWide();
             $this->site->addSiteWidePlugin($plugin);
         }
         $wrapper = new PluginWrapper();
         $wrapper->setPluginWrapperId($instance['pluginWrapperId']);
         $wrapper->setLayoutContainer($instance['layoutContainer']);
         $wrapper->setRenderOrderNumber($instance['renderOrder']);
         $wrapper->setHeight($instance['height']);
         $wrapper->setWidth($instance['width']);
         $wrapper->setDivFloat($instance['divFloat']);
         $wrapper->setInstance($plugin);
         $revision->addPluginWrapper($wrapper);
     }
     return $revision;
 }
Ejemplo n.º 10
0
 /**
  * getPrimaryRedirectUrl
  * If the IP is not a domain and is not the primary, return redirect for primary
  *
  * @param Site $site
  *
  * @return null|string
  */
 public function getPrimaryRedirectUrl(Site $site)
 {
     $currentDomain = $site->getDomain()->getDomainName();
     $ipValidator = new Ip();
     $isIp = $ipValidator->isValid($currentDomain);
     if ($isIp) {
         return null;
     }
     $primaryDomain = $site->getDomain()->getPrimary();
     if (empty($primaryDomain)) {
         return null;
     }
     if ($primaryDomain->getDomainName() == $currentDomain) {
         return null;
     }
     return $primaryDomain->getDomainName();
 }
Ejemplo n.º 11
0
 /**
  * Generic test for the constructor
  *
  * @return null
  * @covers \Rcm\Factory\ContainerViewHelperFactory
  */
 public function testCreateService()
 {
     $mockPluginManager = $this->getMockBuilder('\\Rcm\\Service\\PluginManager')->disableOriginalConstructor()->getMock();
     $mockEntityManager = $this->getMockBuilder('\\Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $mockContainerRepo = $this->getMockBuilder('\\Rcm\\Repository\\Container')->disableOriginalConstructor()->getMock();
     $mockEntityManager->expects($this->any())->method('getRepository')->will($this->returnValue($mockContainerRepo));
     $site = new Site();
     $site->setSiteId(1);
     $sm = new ServiceManager();
     $sm->setService('Doctrine\\ORM\\EntityManager', $mockEntityManager);
     $sm->setService('Rcm\\Service\\PluginManager', $mockPluginManager);
     $sm->setService('Rcm\\Service\\CurrentSite', $site);
     $helperManager = new HelperPluginManager();
     $helperManager->setServiceLocator($sm);
     $factory = new ContainerViewHelperFactory();
     $object = $factory->createService($helperManager);
     $this->assertTrue($object instanceof Container);
 }
Ejemplo n.º 12
0
 /**
  * Setup for tests
  *
  * @return null
  */
 public function setUp()
 {
     $this->mockUserService = $this->getMockBuilder('RcmUser\\Service\\RcmUserService')->disableOriginalConstructor()->getMock();
     $this->currentSite = new Site();
     $this->currentSite->setSiteId(1);
     $this->mockCmsPermissionCheck = $this->getMockBuilder('\\Rcm\\Acl\\CmsPermissionChecks')->disableOriginalConstructor()->getMock();
     $this->mockAclService = $this->getMockBuilder('\\RcmUser\\Acl\\Service\\AclDataService')->disableOriginalConstructor()->getMock();
     $result = new Result();
     $this->mockAclService->expects($this->any())->method('getRulesByResource')->will($this->returnValue($result));
     $this->mockAclService->expects($this->any())->method('getAllRoles')->will($this->returnValue($result));
     $userService = $this->mockUserService;
     $config = $this->getConfig();
     /** @var \RcmUser\Service\RcmUserService $userService */
     $this->controller = new AdminPanelController($config, $this->currentSite, $this->mockCmsPermissionCheck);
     $event = new MvcEvent();
     $routeMatch = new RouteMatch(['page' => 'index', 'pageType' => 'n']);
     $event->setRouteMatch($routeMatch);
     $this->controller->setEvent($event);
 }
 /**
  * get Host
  *
  * @return null|string
  */
 public function getHost()
 {
     if (empty($this->site)) {
         return null;
     }
     $domain = $this->site->getDomain();
     if (empty($domain->getDomainName())) {
         return null;
     }
     return $domain->getDomainName();
 }
Ejemplo n.º 14
0
 /**
  * Test Check Domain Return 404 if not found.
  *
  * @return void
  *
  * @covers \Rcm\EventListener\RouteListener
  */
 public function testCheckDomainReturnsNotFound()
 {
     $serverParams = new Parameters(['HTTP_HOST' => 'not.found.com']);
     $this->currentSite->setDomain(new Domain());
     $this->currentSite->setSiteId(null);
     $request = new Request();
     $request->setServer($serverParams);
     $event = new MvcEvent();
     $event->setRequest($request);
     $actual = $this->routeListener->checkDomain($event);
     $this->assertTrue($actual instanceof Response);
     $responseCode = $actual->getStatusCode();
     $this->assertEquals(404, $responseCode);
 }
Ejemplo n.º 15
0
 /**
  * Test Set Site Layout
  *
  * @return void
  *
  * @covers \Rcm\EventListener\DispatchListener
  */
 public function testSetSiteLayout()
 {
     $favicon = 'someFavicon';
     $title = 'My Site Title';
     $layout = 'myLayout';
     $mockLayoutManager = $this->getMockBuilder('Rcm\\Service\\LayoutManager')->disableOriginalConstructor()->getMock();
     $mockLayoutManager->expects($this->any())->method('getSiteLayout')->will($this->returnValue($layout));
     $currentSite = new Site();
     $currentSite->setSiteId(1);
     $currentSite->setFavIcon($favicon);
     $currentSite->setSiteTitle($title);
     $currentSite->setSiteLayout($layout);
     $testCase = [['Rcm\\Service\\LayoutManager', $mockLayoutManager], ['Rcm\\Service\\CurrentSite', $currentSite]];
     // Zend\ServiceManager\ServiceLocatorInterface
     $mockServiceLocator = $this->getMockBuilder('\\Zend\\ServiceManager\\ServiceLocatorInterface')->disableOriginalConstructor()->getMock();
     $mockServiceLocator->expects($this->any())->method('get')->will($this->returnValueMap($testCase));
     $listener = new DispatchListener($mockServiceLocator);
     $event = new MvcEvent();
     $listener->setSiteLayout($event);
     $view = $event->getViewModel();
     $template = $view->getTemplate();
     $this->assertEquals('layout/' . $layout, $template);
 }
Ejemplo n.º 16
0
 /**
  * Process 401 Response Objects.  This will redirect the visitor to the
  * sites configured login page.
  *
  * @return Response
  */
 protected function processNotAuthorized()
 {
     $loginPage = $this->currentSite->getLoginPage();
     $notAuthorized = $this->currentSite->getNotAuthorizedPage();
     $returnToUrl = urlencode($this->request->getServer('REQUEST_URI'));
     $newResponse = new Response();
     $newResponse->setStatusCode('302');
     if (!$this->userService->hasIdentity()) {
         $newResponse->getHeaders()->addHeaderLine('Location: ' . $loginPage . '?redirect=' . $returnToUrl);
     } else {
         $newResponse->getHeaders()->addHeaderLine('Location: ' . $notAuthorized);
     }
     return $newResponse;
 }
Ejemplo n.º 17
0
 /**
  * Get the Admin Menu Bar
  *
  * @return mixed
  */
 public function getAdminWrapperAction()
 {
     $allowed = $this->cmsPermissionChecks->siteAdminCheck($this->currentSite);
     if (!$allowed) {
         return null;
     }
     /** @var RouteMatch $routeMatch */
     $routeMatch = $this->getEvent()->getRouteMatch();
     $siteId = $this->currentSite->getSiteId();
     $sourcePageName = $routeMatch->getParam('page', 'index');
     if ($sourcePageName instanceof Page) {
         $sourcePageName = $sourcePageName->getName();
     }
     $pageType = $routeMatch->getParam('pageType', 'n');
     $view = new ViewModel();
     $view->setVariable('restrictions', false);
     if ($this->cmsPermissionChecks->isPageRestricted($siteId, $pageType, $sourcePageName, 'read') == true) {
         $view->setVariable('restrictions', true);
     }
     $view->setVariable('adminMenu', $this->adminPanelConfig);
     $view->setTemplate('rcm-admin/admin/admin');
     return $view;
 }
Ejemplo n.º 18
0
 /**
  * Set the system locale to Site Requirements
  *
  * NOTE: We do NOT set LC_ALL because it causes "n tilde"
  * chars to be not json encodable after they have been strtolower'd
  *
  * @return null
  */
 public function addLocale()
 {
     $locale = $this->currentSite->getLocale();
     /* Conversion for Ubuntu and Mac local settings. */
     if (!setlocale(LC_MONETARY, $locale . '.utf8')) {
         if (!setlocale(LC_MONETARY, $locale . '.UTF-8')) {
             setlocale(LC_MONETARY, 'en_US.UTF-8');
         }
     }
     /* Conversion for Ubuntu and Mac local settings. */
     if (!setlocale(LC_NUMERIC, $locale . '.utf8')) {
         if (!setlocale(LC_NUMERIC, $locale . '.UTF-8')) {
             setlocale(LC_NUMERIC, 'en_US.UTF-8');
         }
     }
     /* Conversion for Ubuntu and Mac local settings. */
     if (!setlocale(LC_TIME, $locale . '.utf8')) {
         if (!setlocale(LC_TIME, $locale . '.UTF-8')) {
             setlocale(LC_TIME, 'en_US.UTF-8');
         }
     }
     \Locale::setDefault($locale);
     return null;
 }
Ejemplo n.º 19
0
 public function testToArray()
 {
     $unit = new Redirect();
     $site = new Site();
     $domain = new Domain();
     $site->setSiteId(28);
     $domain->setDomainName('test.com');
     $site->setDomain($domain);
     $unit->setSite($site);
     $result = $unit->toArray();
     $this->assertEquals('test.com', $result['domain']);
     $this->assertEquals(28, $result['siteId']);
 }
Ejemplo n.º 20
0
 /**
  * getRevisionList
  *
  * @param bool $published
  * @param int  $limit
  *
  * @return array|mixed
  */
 protected function getRevisionList($published = false, $limit = 10)
 {
     $revisions = $this->pageRepo->getRevisionList($this->currentSite->getSiteId(), $this->page->getName(), $this->page->getPageType(), $published, $limit);
     return $revisions;
 }
Ejemplo n.º 21
0
 /**
  * updateSiteSitewide
  *
  * @param PluginInstanceEntity $pluginInstance
  * @param SiteEntity           $site
  * @param null                 $oldPluginInstance
  *
  * @return void
  */
 public function updateSiteSitewide(PluginInstanceEntity $pluginInstance, SiteEntity $site, $oldPluginInstance = null)
 {
     // ignore non-sitewides
     if (!$pluginInstance->isSiteWide()) {
         return;
     }
     if (!empty($oldPluginInstance)) {
         $site->removeSiteWidePlugin($oldPluginInstance);
     }
     $site->addSiteWidePlugin($pluginInstance);
     $this->_em->persist($site);
 }
Ejemplo n.º 22
0
 /**
  * Set site the page belongs to
  *
  * @param Site $site Site object to add
  *
  * @return void
  */
 public function setSite(Site $site)
 {
     $this->site = $site;
     $this->siteId = $site->getSiteId();
 }
Ejemplo n.º 23
0
 /**
  * Set the Site the redirect belongs to
  *
  * @param \Rcm\Entity\Site $site Site Entity
  *
  * @return void
  */
 public function setSite($site)
 {
     if ($site === null) {
         $this->siteId = null;
         $this->site = null;
         return;
     }
     $this->siteId = $site->getSiteId();
     $this->site = $site;
 }
Ejemplo n.º 24
0
 /**
  * Check to see if a layout is valid and available for a theme
  *
  * @param Site   $site      Site to lookup
  * @param string $layoutKey Layout name to search
  *
  * @return boolean
  * @throws InvalidArgumentException
  */
 public function isLayoutValid(Site $site, $layoutKey)
 {
     $themesConfig = $this->getSiteThemeLayoutsConfig($site->getTheme());
     if (!empty($themesConfig[$layoutKey])) {
         return true;
     }
     return false;
 }
Ejemplo n.º 25
0
 /**
  * Test Set Page Type
  *
  * @return void
  *
  */
 public function testSetSiteId()
 {
     $reflectedClass = new \ReflectionClass($this->validator);
     $reflectedProp = $reflectedClass->getProperty('site');
     $reflectedProp->setAccessible(true);
     $defaultValue = $reflectedProp->getValue($this->validator);
     $this->assertEquals(1, $defaultValue->getSiteId());
     $site = new Site();
     $site->setSiteId(22);
     $this->validator->setSite($site);
     $result = $reflectedProp->getValue($this->validator);
     $this->assertEquals(22, $result->getSiteId());
 }
Ejemplo n.º 26
0
 /**
  * Get Test Page Data for Page Repo Mocks
  *
  * @param integer $pageId             PageID
  * @param integer $pageName           PageName
  * @param integer $revisionId         RevisionId
  * @param string  $pageType           PageType
  * @param boolean $useStaged          Use staged revision instead of published
  * @param string  $siteLayoutOverride Layout Override
  *
  * @return array
  */
 protected function getPageData($pageId, $pageName, $revisionId, $pageType = 'n', $useStaged = false, $siteLayoutOverride = null)
 {
     $country = new Country();
     $country->setCountryName('United States');
     $country->setIso2('US');
     $country->setIso3('USA');
     $language = new Language();
     $language->setLanguageId(1);
     $language->setIso6391('en');
     $language->setIso6392b('eng');
     $language->setIso6392t('eng');
     $domain = new Domain();
     $domain->setDomainId(1);
     $domain->setDomainName('reliv.com');
     $site = new Site();
     $site->setSiteId(1);
     $site->setCountry($country);
     $site->setLanguage($language);
     $site->setLoginPage('login');
     $site->setNotFoundPage('not-found');
     $site->setDomain($domain);
     $revision = new Revision();
     $revision->setRevisionId($revisionId);
     $revision->setAuthor('Westin Shafer');
     $revision->setCreatedDate(new \DateTime());
     $revision->setPublishedDate(new \DateTime());
     $page = new Page();
     $page->setSite($site);
     $page->setName($pageName);
     $page->setPageId($pageId);
     $page->setPageType($pageType);
     $page->addRevision($revision);
     $page->setPublishedRevision($revision);
     if ($useStaged) {
         $page->setStagedRevision($revision);
     }
     $page->setPageId(22);
     $page->setSiteLayoutOverride($siteLayoutOverride);
     return $page;
 }
Ejemplo n.º 27
0
 /**
  * Test Clone
  *
  * @return void
  *
  * @covers \Rcm\Entity\Page
  */
 public function testClone()
 {
     $site = new Site();
     $site->setSiteId(55);
     $container = ['pageId' => '200', 'name' => 'pageOne', 'author' => 'Westin Shafer', 'createdDate' => new \DateTime('yesterday'), 'lastPublished' => new \DateTime('yesterday'), 'revisions' => [0 => ['revisionId' => 100, 'author' => 'Westin Shafer', 'createdDate' => new \DateTime('yesterday'), 'publishedDate' => new \DateTime('yesterday'), 'published' => true, 'md5' => 'revisionMD5', 'instances' => [0 => ['pluginWrapperId' => 43, 'layoutContainer' => 'layoutOne', 'renderOrder' => 0, 'height' => 32, 'width' => 100, 'divFloat' => 'right', 'instance' => ['pluginInstanceId' => 44, 'plugin' => 'MockPlugin', 'siteWide' => false, 'displayName' => null, 'instanceConfig' => ['var1' => 1, 'var2' => 2], 'md5' => 'firstMd5']], 1 => ['pluginWrapperId' => 45, 'layoutContainer' => 'layoutTwo', 'renderOrder' => 1, 'height' => 33, 'width' => 101, 'divFloat' => 'none', 'instance' => ['pluginInstanceId' => 46, 'plugin' => 'MockPlugin2', 'siteWide' => true, 'displayName' => 'TestSiteWide', 'instanceConfig' => ['var3' => 3, 'var4' => 4], 'md5' => 'secondMd5']]]], 1 => ['revisionId' => 101, 'author' => 'Westin Shafer', 'createdDate' => new \DateTime('-1 month'), 'publishedDate' => new \DateTime('-1 month'), 'published' => false, 'md5' => 'revision2MD5', 'instances' => [0 => ['pluginWrapperId' => 47, 'layoutContainer' => 'layoutThree', 'renderOrder' => 2, 'height' => 33, 'width' => 102, 'divFloat' => 'right', 'instance' => ['pluginInstanceId' => 48, 'plugin' => 'MockPlugin3', 'siteWide' => false, 'displayName' => null, 'instanceConfig' => ['var1' => 1, 'var2' => 2], 'md5' => 'firstMd5']], 1 => ['pluginWrapperId' => 49, 'layoutContainer' => 'layoutFour', 'renderOrder' => 3, 'height' => 34, 'width' => 103, 'divFloat' => 'left', 'instance' => ['pluginInstanceId' => 50, 'plugin' => 'MockPlugin4', 'siteWide' => true, 'displayName' => 'TestSiteWide2', 'instanceConfig' => ['var3' => 3, 'var4' => 4], 'md5' => 'secondMd5']]]]]];
     $this->page->setPageId($container['pageId']);
     $this->page->setName($container['name']);
     $this->page->setAuthor($container['author']);
     $this->page->setCreatedDate($container['createdDate']);
     $this->page->setLastPublished($container['lastPublished']);
     $this->page->setSite($site);
     foreach ($container['revisions'] as $index => $revisionData) {
         $revision = new Revision();
         $revision->setRevisionId($revisionData['revisionId']);
         $revision->setAuthor($revisionData['author']);
         $revision->setCreatedDate($revisionData['createdDate']);
         $revision->publishRevision();
         $revision->setPublishedDate($revisionData['publishedDate']);
         $revision->setMd5($revisionData['md5']);
         foreach ($revisionData['instances'] as $instance) {
             $plugin = new PluginInstance();
             $plugin->setInstanceId($instance['instance']['pluginInstanceId']);
             $plugin->setPlugin($instance['instance']['plugin']);
             if ($instance['instance']['siteWide']) {
                 $plugin->setSiteWide();
             }
             $plugin->setDisplayName($instance['instance']['displayName']);
             $plugin->setInstanceConfig($instance['instance']['instanceConfig']);
             $plugin->setMd5($instance['instance']['md5']);
             $wrapper = new PluginWrapper();
             $wrapper->setPluginWrapperId($instance['pluginWrapperId']);
             $wrapper->setLayoutContainer($instance['layoutContainer']);
             $wrapper->setRenderOrderNumber($instance['renderOrder']);
             $wrapper->setHeight($instance['height']);
             $wrapper->setWidth($instance['width']);
             $wrapper->setDivFloat($instance['divFloat']);
             $wrapper->setInstance($plugin);
             $revision->addPluginWrapper($wrapper);
         }
         if ($index === 0) {
             $this->page->setPublishedRevision($revision);
         } elseif ($index === 1) {
             $this->page->setStagedRevision($revision);
         }
         $this->page->addRevision($revision);
     }
     $this->assertCount(2, $this->page->getRevisions());
     $clonedContainer = clone $this->page;
     /* Test Container */
     $this->assertNotEquals($this->page->getPageId(), $clonedContainer->getPageId());
     $this->assertNull($clonedContainer->getPageId());
     $this->assertNull($clonedContainer->getPublishedRevision());
     $this->assertCount(1, $clonedContainer->getRevisions());
     $containerName = $clonedContainer->getName();
     $containerIsempty = empty($containerName);
     $this->assertTrue($containerIsempty);
     $this->assertNull($clonedContainer->getParent());
     $currentRevision = $this->page->getPublishedRevision();
     $clonedCurrentRev = $clonedContainer->getStagedRevision();
     /* Test Revision */
     $this->assertNotEquals($currentRevision->getRevisionId(), $clonedCurrentRev->getRevisionId());
     $this->assertNull($clonedCurrentRev->getRevisionId());
     $this->assertEquals($currentRevision->getAuthor(), $clonedCurrentRev->getAuthor());
     $this->assertNotEquals($currentRevision->getCreatedDate(), $clonedCurrentRev->getCreatedDate());
     $this->assertFalse($clonedCurrentRev->wasPublished());
     $this->assertEquals($currentRevision->getMd5(), $clonedCurrentRev->getMd5());
     $revisionWrappers = $currentRevision->getPluginWrappers();
     $clonedWrappers = $clonedCurrentRev->getPluginWrappers();
     $this->assertNotEquals($revisionWrappers, $clonedWrappers);
     /** @var \Rcm\Entity\PluginWrapper $clonedWrapper */
     foreach ($clonedWrappers as $clonedWrapper) {
         if (!$clonedWrapper->getInstance()->isSiteWide()) {
             $this->assertNull($clonedWrapper->getInstance()->getInstanceId());
         } else {
             $this->assertNotNull($clonedWrapper->getInstance()->getInstanceId());
         }
     }
     $page = new Page();
     $clone = clone $page;
     $this->assertInstanceOf('\\Rcm\\Entity\\Page', $clone);
 }
 /**
  * create - Create a site
  *
  * @param array $data
  *
  * @return mixed|JsonModel
  */
 public function create($data)
 {
     /* ACCESS CHECK */
     if (!$this->rcmIsAllowed('sites', 'admin')) {
         $this->getResponse()->setStatusCode(Response::STATUS_CODE_401);
         return $this->getResponse();
     }
     /* */
     $inputFilter = new SiteInputFilter();
     $inputFilter->setData($data);
     if (!$inputFilter->isValid()) {
         return new ApiJsonModel([], 1, 'Some values are missing or invalid.', $inputFilter->getMessages());
     }
     $data = $inputFilter->getValues();
     $siteManager = $this->getSiteManager();
     try {
         $data = $siteManager->prepareSiteData($data);
         /** @var \Rcm\Repository\Domain $domainRepo */
         $domainRepo = $this->getEntityManager()->getRepository('\\Rcm\\Entity\\Domain');
         $data['domain'] = $domainRepo->createDomain($data['domainName']);
     } catch (\Exception $e) {
         return new ApiJsonModel(null, 1, $e->getMessage());
     }
     /** @var \Rcm\Entity\Site $newSite */
     $newSite = new Site();
     $newSite->populate($data);
     // make sure we don't have a siteId
     $newSite->setSiteId(null);
     try {
         $newSite = $siteManager->createSite($newSite);
     } catch (\Exception $e) {
         return new ApiJsonModel(null, 1, $e->getMessage());
     }
     return new ApiJsonModel($newSite, 0, 'Success');
 }
Ejemplo n.º 29
0
 /**
  * getSiteDomain
  *
  * @param Site $site
  *
  * @return null|string
  */
 public function getSiteDomain(Site $site)
 {
     $domain = $site->getDomain();
     if (empty($domain)) {
         return $this->domainService->getDefaultDomainName();
     }
     $domainName = $domain->getDomainName();
     if (empty($domainName)) {
         return $this->domainService->getDefaultDomainName();
     }
     return $domainName;
 }
Ejemplo n.º 30
0
 /**
  * Get all Page Resources
  *
  * @param Page $page Rcm Page Entity
  * @param Site $site Rcm Site Entity
  *
  * @return mixed
  */
 protected function getPageResources(Page $page, Site $site)
 {
     $primaryDomainName = $site->getDomain()->getDomainName();
     $siteId = $site->getSiteId();
     $pageName = $page->getName();
     $pageType = $page->getPageType();
     $return['sites.' . $siteId . '.pages.' . $pageType . '.' . $pageName] = ['resourceId' => 'sites.' . $siteId . '.pages.' . $pageType . '.' . $pageName, 'parentResourceId' => 'sites.' . $siteId . '.pages', 'name' => $primaryDomainName . ' - pages - ' . $pageName, 'description' => "Resource for page '{$pageName}'" . " of type '{$pageType}' on site '{$primaryDomainName}'"];
     $return['sites.' . $siteId . '.pages.' . $pageType . '.' . $pageName] = array_merge($this->resources['pages'], $return['sites.' . $siteId . '.pages.' . $pageType . '.' . $pageName]);
     return $return;
 }