Example #1
0
 /**
  * Save new page.
  *
  * @param array $values
  * @return Page
  */
 public static function saveNewPage(array $values)
 {
     $subpage = new Page();
     $subpage->setUid(Helper::getUniqueId());
     $subpage->setVisible($values['visible']);
     $subpage->setEnabled($values['enabled']);
     $subpage->setIncludeInIndex($values['index']);
     if ($values['parent_page_id'] == '@root' && !PageQuery::create()->findRoot()) {
         // Create root node
         $subpage->makeRoot();
         $subpage->setName($values['name']);
         $subpage->setUrl('/');
         // Grant everyone access
         $pageAccess = new PageAccess();
         $pageAccess->setPage($subpage);
         $permissions = PageAccess::getPermissionTypes();
         $grant = array_fill(0, count($permissions), true);
         $pageAccess->fromArray(array_combine($permissions, $grant));
     } else {
         $parentPage = PageQuery::create()->findPk($values['parent_page_id']);
         $subpage->insertAsLastChildOf($parentPage);
         $subpage->setAutoName($values['name']);
     }
     $subpage->save();
     return $subpage;
 }
 public function assign($document)
 {
     $page = new Page();
     $page->setId($document['_id']);
     $page->setUrl($document['url']);
     $page->setSource($document['source']);
     return $page;
 }
Example #3
0
 public function providerCorrectPage()
 {
     $page1 = new Page();
     $page1->setKey('catalog-product-edit');
     $page1->setTitle('Catalog product edit page');
     $page1->setUrl('admin/catalog_product/edit/id/(\\d+)');
     $tabGeneral = $page1->createTab('general', "//div=[@id='product_info_tabs_group_7_content']");
     $tabGeneral->appendChild($page1->createField('name', "//input[@id='name']"));
     $tabGeneral->appendChild($page1->createField('description', "//input[@id='description']"));
     $tabGeneral->appendChild($page1->createSelect('status', "//input[@id='status']"));
     $page1->documentElement->appendChild($tabGeneral);
     $page1->documentElement->appendChild($page1->createButton('save', "//div[@class='content-buttons-placeholder']//button[contains(@class,'save')]"));
     $page1->documentElement->appendChild($page1->createButton('back', "//div[@class='content-buttons-placeholder']//button[contains(@class,'back')]"));
     $page2 = new Page();
     $page2->setKey('customer-edit');
     $page2->setTitle('Cutomer edit page');
     $page2->setUrl('admin/customer/edit/id/(\\d+)');
     $fieldsetAccountInformation = $page2->createFieldset('account-information', "//div[@id='_accountbase_fieldset']");
     $fieldsetAccountInformation->appendChild($page2->createField('firstname', "//input[@id='_accountfirstname']"));
     $fieldsetAccountInformation->appendChild($page2->createField('lastname', "//input[@id='_accountlastname']"));
     $fieldsetAccountInformation->appendChild($page2->createSelect('gender', "//input[@id='_accountgender']"));
     $fieldsetFormButtons = $page2->createFieldset('form-buttons', "//p[@class='form-buttons']");
     $fieldsetFormButtons->appendChild($page2->createButton('save', "//div[@class='content-buttons-placeholder']//button[contains(@class,'save')]"));
     $fieldsetFormButtons->appendChild($page2->createButton('back', "//div[@class='content-buttons-placeholder']//button[contains(@class,'back')]"));
     $tabAccountInformation = $page2->createTab('account-information', "//div[@id='_accountbase_fieldset']");
     $tabAccountInformation->appendChild($fieldsetAccountInformation);
     $page2->documentElement->appendChild($tabAccountInformation);
     $page2->documentElement->appendChild($fieldsetFormButtons);
     return array(array($page1), array($page2));
 }
Example #4
0
 for ($i = 0; $i < $_GET['nb']; $i++) {
     $URL = $urlbase . ($_GET['lastvalue'] + $i);
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $URL);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $resultat = curl_exec($ch);
     $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     curl_close($ch);
     if ($httpCode != 404) {
         //création du DOM de la page
         $page->loadHTML($resultat);
         //page url et title
         $title = $page->getElementsByTagName('title');
         $title = $title->item(0);
         $title = $title->textContent;
         $bddpage->setUrl($URL);
         $bddpage->setTitle($title);
         //page img
         $thingpage = $page->getElementById('thing-page');
         $imgtable = array();
         foreach ($page->getElementsByTagName('div') as $div) {
             if ($div->getAttribute('class') == 'thing-page-image featured') {
                 foreach ($div->getElementsByTagName('img') as $img) {
                     $imgsrc = $img->getAttribute('data-cfsrc');
                     if (!empty($imgsrc)) {
                         $imgtable[] = $imgsrc;
                     }
                     $imgsrc = $img->getAttribute('data-img');
                     if (!empty($imgsrc)) {
                         $imgtable[] = $imgsrc;
                     }