/**
  * Renders the edit form for the attribute within a page/user object
  * 
  * For pages this might be displayed within composer view, or within Sitemap > Click a Page > Attributes
  * 
  * @param  boolean $additionalClass
  * @return null
  */
 public function form($additionalClass = false)
 {
     $this->loadAttributeSettings();
     // $this->requireAsset('core/topics');
     // $this->requireAsset('javascript', 'jquery');
     $this->requireAsset('bsmSelect');
     // Defined in package/controller.php
     // Fetch a list of pages that match pageTypeId
     // This provides the options for the editor to select from
     // See http://documentation.concrete5.org/developers/working-with-pages/searching-and-sorting-with-the-pagelist-object
     $pageList = new \Concrete\Core\Page\PageList();
     $pageList->filterByPageTypeId($this->pageTypeId);
     $pageList->sortByDisplayOrder();
     $pages = $pageList->getResults();
     // d($pages);
     $this->set('pages', $pages);
     // Page list for select box
     $pagesForSelect = [];
     foreach ($pages as $p) {
         $pagesForSelect[$p->cID] = $p->getVersionObject()->cvName;
     }
     $this->set('pagesForSelect', $pagesForSelect);
     // Fetch existing value of the attribute (if present)
     $this->set('relatedPages', $this->getValue()[0]['pageId']);
     // if (is_object($this->attributeValue)) {
     //     $value = $this->getAttributeValue()->getValue();
     // }
     // if ($this->getAttributeValueID()) {
     //     $valueIDs = array();
     //     foreach ($this->getSelectedOptions() as $valueID) {
     //         $withinParentScope = false;
     //         $nodeObj = TreeNode::getByID($valueID);
     //         if (is_object($nodeObj)) {
     //             $parentNodeArray = $nodeObj->getTreeNodeParentArray();
     //             // check to see if selected node is still within parent scope, in case it has been changed.
     //             foreach ($parentNodeArray as $parent) {
     //                 if ($parent->treeNodeID == $this->akTopicParentNodeID) {
     //                     $withinParentScope = true;
     //                     break;
     //                 }
     //             }
     //             if ($withinParentScope) {
     //                 $valueIDs[] = $valueID;
     //             }
     //         }
     //     }
     //     $this->set('valueIDs', implode(',', $valueIDs));
     // }
     // $this->set('valueIDArray', $valueIDs);
     // $ak = $this->getAttributeKey();
     // $this->set('akID', $ak->getAttributeKeyID());
     // $this->set('parentNode', $this->akTopicParentNodeID);
     // $this->set('treeID', $this->akTopicTreeID);
     // $this->set('avID', $this->getAttributeValueID());
 }
 public function testFilterByPath()
 {
     $this->createPage('More Fun', '/test-page-1/foobler');
     $this->list->filterByPath('/test-page-1');
     $totalResults = $this->list->getTotalResults();
     $this->assertEquals(2, $totalResults);
     $nl = new \Concrete\Core\Page\PageList();
     $nl->ignorePermissions();
     $nl->filterbyPath('/test-page-1', false);
     $pagination = $nl->getPagination();
     $this->assertEquals(1, $pagination->getNBResults());
 }