Example #1
2
 public function __construct(Application $app, $config, Block $b, Page $c, Area $a)
 {
     parent::__construct();
     $p = new \Permissions($b);
     $this->permissions = $p;
     $this->block = $b;
     $this->page = $c;
     $this->area = $a;
     $this->setAttribute('data-block-menu', 'block-menu-b' . $b->getBlockID());
     $this->setAttribute('class', 'ccm-edit-mode-block-menu');
     $btw = $b->getBlockTypeObject();
     $btOriginal = $btw;
     $bID = $b->getBlockID();
     $aID = $a->getAreaID();
     $heightPlus = 20;
     $btHandle = $btw->getBlockTypeHandle();
     $editInline = false;
     if ($btw->supportsInlineEdit()) {
         $editInline = true;
     }
     if ($btw->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY) {
         $_bi = $b->getInstance();
         $_bo = Block::getByID($_bi->getOriginalBlockID());
         $btOriginal = BlockType::getByHandle($_bo->getBlockTypeHandle());
         $btHandle = $btOriginal->getBlockTypeHandle();
         $heightPlus = 80;
         if ($btOriginal->supportsInlineEdit()) {
             $editInline = true;
         }
     }
     $canDesign = $p->canEditBlockDesign() && $config->get('concrete.design.enable_custom') == true;
     $canModifyGroups = $p->canEditBlockPermissions() && $config->get('concrete.permissions.model') != 'simple' && !$a->isGlobalArea();
     $canEditName = $p->canEditBlockName();
     $canEditCacheSettings = $p->canEditBlockCacheSettings();
     $canEditCustomTemplate = $p->canEditBlockCustomTemplate();
     $canScheduleGuestAccess = $config->get('concrete.permissions.model') != 'simple' && $p->canGuestsViewThisBlock() && $p->canScheduleGuestAccess() && !$a->isGlobalArea();
     $canAliasBlockOut = $c->isMasterCollection() && !$a->isGlobalArea();
     if ($canAliasBlockOut) {
         $ct = Type::getByID($c->getPageTypeID());
     }
     $isAlias = $b->isAlias();
     $u = new \User();
     $numChildren = !$isAlias ? $b->getNumChildren() : 0;
     if ($isAlias) {
         $deleteMessage = t('Do you want to delete this block?');
     } elseif ($numChildren) {
         $deleteMessage = t('Do you want to delete this block? This item is an original. If you delete it, you will delete all blocks aliased to it');
     } else {
         $deleteMessage = t('Do you want to delete this block?');
     }
     if ($btOriginal->getBlockTypeHandle() == BLOCK_HANDLE_STACK_PROXY) {
         if (is_object($_bo)) {
             $bi = $_bo->getInstance();
         } else {
             $bi = $b->getInstance();
         }
         $stack = \Stack::getByID($bi->stID);
         if (is_object($stack)) {
             $sp = new \Permissions($stack);
             if ($sp->canWrite()) {
                 $this->addItem(new LinkItem(\URL::to('/dashboard/blocks/stacks', 'view_details', $stack->getCollectionID()), t('Manage Stack Contents')));
             }
         }
     } else {
         if ($p->canEditBlock() && $b->isEditable()) {
             if ($editInline) {
                 if ($b->getBlockTypeHandle() == BLOCK_HANDLE_LAYOUT_PROXY) {
                     $this->addItem(new LinkItem('javascript:void(0)', t('Edit Layout'), ['data-menu-action' => 'edit_inline', 'data-area-enable-grid-container' => $a->isGridContainerEnabled(), 'data-area-grid-maximum-columns' => $a->getAreaGridMaximumColumns()]));
                 } else {
                     $this->addItem(new LinkItem('javascript:void(0)', t('Edit Block'), ['data-menu-action' => 'edit_inline', 'data-area-enable-grid-container' => $a->isGridContainerEnabled(), 'data-area-grid-maximum-columns' => $a->getAreaGridMaximumColumns()]));
                 }
             } else {
                 $this->addItem(new LinkItem('javascript:void(0)', t('Edit Block'), ['data-menu-action' => 'block_dialog', 'data-menu-href' => \URL::to('/ccm/system/dialogs/block/edit'), 'dialog-title' => t('Edit %s', t($btOriginal->getBlockTypeName())), 'dialog-width' => $btOriginal->getBlockTypeInterfaceWidth(), 'dialog-height' => $btOriginal->getBlockTypeInterfaceHeight() + $heightPlus]));
             }
         }
     }
     if ($b->getBlockTypeHandle() != BLOCK_HANDLE_LAYOUT_PROXY && $b->getBlockTypeHandle() != BLOCK_HANDLE_PAGE_TYPE_OUTPUT_PROXY) {
         $this->addItem(new LinkItem('javascript:void(0)', t('Copy to Clipboard'), ['data-menu-action' => 'block_scrapbook', 'data-token' => $app->make('token')->generate('tools/clipboard/to')]));
     }
     if ($p->canDeleteBlock()) {
         $this->addItem(new LinkItem('javascript:void(0)', t('Delete'), ['data-menu-action' => 'delete_block', 'data-menu-delete-message' => $deleteMessage]));
     }
     if ($b->getBlockTypeHandle() != BLOCK_HANDLE_LAYOUT_PROXY) {
         if ($canDesign || $canEditCustomTemplate || $canEditName || $canEditCacheSettings) {
             $this->addItem(new DividerItem());
             if ($canDesign || $canEditCustomTemplate) {
                 $this->addItem(new LinkItem('#', t('Design & Custom Template'), ['data-menu-action' => 'block_design']));
             }
             if ($b->getBlockTypeHandle() != BLOCK_HANDLE_PAGE_TYPE_OUTPUT_PROXY && ($canEditName || $canEditCacheSettings)) {
                 $this->addItem(new LinkItem('#', t('Advanced'), ['dialog-title' => t('Advanced Block Settings'), 'data-menu-action' => 'block_dialog', 'data-menu-href' => \URL::to('/ccm/system/dialogs/block/cache'), 'dialog-width' => 500, 'dialog-height' => 320]));
             }
         }
     }
     if ($b->getBlockTypeHandle() != BLOCK_HANDLE_PAGE_TYPE_OUTPUT_PROXY && ($canModifyGroups || $canScheduleGuestAccess || $canAliasBlockOut)) {
         $this->addItem(new DividerItem());
         if ($canModifyGroups) {
             $this->addItem(new LinkItem('#', t('Permissions'), ['dialog-title' => t('Block Permissions'), 'data-menu-action' => 'block_dialog', 'data-menu-href' => \URL::to('/ccm/system/dialogs/block/permissions/list'), 'dialog-width' => 350, 'dialog-height' => 450]));
         }
         if ($canScheduleGuestAccess) {
             $this->addItem(new LinkItem('#', t('Schedule Guest Access'), ['dialog-title' => t('Schedule Guest Access'), 'data-menu-action' => 'block_dialog', 'data-menu-href' => \URL::to('/ccm/system/dialogs/block/permissions/guest_access'), 'dialog-width' => 500, 'dialog-height' => 320]));
         }
         if ($canAliasBlockOut) {
             $this->addItem(new LinkItem('#', t('Setup on Child Pages'), ['dialog-title' => t('Setup on Child Pages'), 'data-menu-action' => 'block_dialog', 'data-menu-href' => \URL::to('/ccm/system/dialogs/block/aliasing'), 'dialog-width' => 500, 'dialog-height' => 'auto']));
         }
     }
 }
 public static function getList(Type $pagetype)
 {
     $db = Loader::db();
     $ptComposerFormLayoutSetIDs = $db->GetCol('select ptComposerFormLayoutSetID from PageTypeComposerFormLayoutSets where ptID = ? order by ptComposerFormLayoutSetDisplayOrder asc', array($pagetype->getPageTypeID()));
     $list = array();
     foreach ($ptComposerFormLayoutSetIDs as $ptComposerFormLayoutSetID) {
         $set = static::getByID($ptComposerFormLayoutSetID);
         if (is_object($set)) {
             $list[] = $set;
         }
     }
     return $list;
 }
Example #3
0
 public function submit()
 {
     if ($this->token->validate('submit')) {
         $displayOrder = 0;
         if (is_array($this->post('frequent'))) {
             foreach ($this->post('frequent') as $ptID) {
                 $pt = Type::getByID($ptID);
                 if (is_object($pt)) {
                     $data = array('ptIsFrequentlyAdded' => 1, 'ptDisplayOrder' => $displayOrder);
                     $pt->update($data);
                     ++$displayOrder;
                 }
             }
         }
         if (is_array($this->post('infrequent'))) {
             foreach ($this->post('infrequent') as $ptID) {
                 $pt = Type::getByID($ptID);
                 if (is_object($pt)) {
                     $data = array('ptIsFrequentlyAdded' => 0, 'ptDisplayOrder' => $displayOrder);
                     $pt->update($data);
                     ++$displayOrder;
                 }
             }
         }
     } else {
         $this->error->add($this->token->getErrorMessage());
     }
     $er = new \Concrete\Core\Application\EditResponse($this->error);
     $er->setMessage(t('Order Saved.'));
     $er->outputJSON();
 }
 public function execute(ActionInterface $action)
 {
     // Grab the target item for the page's page type.
     $subject = $action->getSubject();
     $target = $action->getTarget();
     if ($subject->getType()) {
         $mapper = new PageType();
         $targetItemList = new TargetItemList($target->getBatch(), $mapper);
         $item = new Item($subject->getType());
         $targetItem = $targetItemList->getSelectedTargetItem($item);
         if (!$targetItem instanceof IgnoredTargetItem) {
             if ($targetItem instanceof UnmappedTargetItem) {
                 $action->getTarget()->addMessage(new Message(t('Page Type <strong>%s</strong> does not exist.', $item->getIdentifier())));
             } else {
                 $targetPageType = Type::getByID($targetItem->getItemID());
                 if (is_object($targetPageType)) {
                     $composerMapper = new ComposerOutputContent();
                     $composerTargetItemList = new TargetItemList($target->getBatch(), $composerMapper);
                     $items = $composerMapper->getPageTypeComposerOutputContentItems($targetPageType);
                     foreach ($items as $item) {
                         $targetItem = $composerTargetItemList->getSelectedTargetItem($item);
                         if ($targetItem instanceof UnmappedTargetItem) {
                             $action->getTarget()->addMessage(new Message(t('Mapped page type %s contains unmapped composer output block in %s area.', $targetPageType->getPageTypeDisplayName(), $item->getBlock()->getAreaHandle())));
                         }
                     }
                 }
             }
         }
     }
 }
 public function getItems(Batch $batch)
 {
     // first, loop through all the page types
     // that are mapped in the current content batch
     $db = \Database::connection();
     $em = $db->getEntityManager();
     $query = $em->createQuery("select ti from PortlandLabs\\Concrete5\\MigrationTool\\Entity\\Import\\BatchTargetItem bti\n            join PortlandLabs\\Concrete5\\MigrationTool\\Entity\\ContentMapper\\TargetItem ti\n            where bti.batch = :batch and bti.target_item = ti and ti.item_type = :type");
     $query->setParameter('batch', $batch);
     $query->setParameter('type', 'page_type');
     $types = $query->getResult();
     $items = array();
     $handles = array();
     foreach ($types as $type) {
         if (!in_array($type->getItemID(), $handles)) {
             $handles[] = $type->getItemID();
         }
     }
     foreach ($handles as $handle) {
         $type = Type::getByHandle($handle);
         if (is_object($type)) {
             $items = array_merge($items, $this->getPageTypeComposerOutputContentItems($type));
         }
     }
     return $items;
 }
 public function configurePageTypePublishTargetFromImport($txml)
 {
     $configuration = new PageTypeConfiguration($this);
     $ct = PageType::getByHandle((string) $txml['pagetype']);
     $configuration->setPageTypeID($ct->getPageTypeID());
     return $configuration;
 }
 public function up(Schema $schema)
 {
     $type = Type::getByHandle(STACK_CATEGORY_PAGE_TYPE);
     if (!is_object($type)) {
         Type::add(array('internal' => true, 'name' => 'Stack Category', 'handle' => STACK_CATEGORY_PAGE_TYPE));
     }
 }
Example #8
0
 public function view()
 {
     $ct = CollectionType::getByHandle('pb_post');
     $ctID = $ct->getPageTypeID();
     if ($this->targetCID > 0) {
         $target = Page::getByID($this->targetCID);
         $this->set('target', $target);
     } else {
         $target = Page::getByPath('/blogsearch');
         $this->set('target', $target);
     }
     if (!$this->page_type) {
         $this->page_type = 'pb_post';
     }
     $page_type = trim($this->page_type);
     $query = "SELECT MIN(cv.cvDatePublic) as firstPost\n\t\t\tFROM CollectionVersions cv\n            INNER JOIN Pages pp ON cv.cID = pp.cID\n\t\t\tINNER JOIN PageTypes pt ON pp.ptID = pt.ptID\n\t\t\tWHERE pt.ptHandle = ? and cv.cvIsApproved = 1\n\t\t\tAND cv.cvDatePublic < CURDATE()\n            ORDER BY firstPost ASC";
     $db = Loader::db();
     $firstPost = $db->getOne($query, array($page_type));
     if (strlen($firstPost)) {
         $firstPost = new \DateTime($firstPost);
         $this->set('firstPost', $firstPost);
     }
     $this->set('numMonths', $this->numMonths);
     $this->set('navigation', loader::helper('navigation'));
 }
 public function import(\SimpleXMLElement $sx)
 {
     if (isset($sx->pagetypes)) {
         foreach ($sx->pagetypes->pagetype as $p) {
             Type::importContent($p);
         }
     }
 }
Example #10
0
 public function validatePageTypeRequest(Request $request)
 {
     $e = parent::validatePageTypeRequest($request);
     $type = PageType::getByID($request->request->get('ptID'));
     if (!$type instanceof PageType) {
         $e->add(t('You must choose the type of page these page types are published beneath.'));
     }
     return $e;
 }
 public function execute(Batch $batch)
 {
     $this->batch = $batch;
     // First, create the top level page for the batch.
     $batches = \Page::getByPath('/!import_batches');
     $type = Type::getByHandle('import_batch');
     $batchParent = $batches->add($type, array('cName' => $batch->getID(), 'cHandle' => $batch->getID(), 'pkgID' => \Package::getByHandle('migration_tool')->getPackageID()));
     $pages = $this->getPagesOrderedForImport($batch);
     if (!$pages) {
         return;
     }
     // Now loop through all pages, and build them
     foreach ($pages as $page) {
         $data = array();
         $ui = $this->getTargetItem('user', $page->getUser());
         if ($ui != '') {
             $data['uID'] = $ui->getUserID();
         } else {
             $data['uID'] = USER_SUPER_ID;
         }
         $cDatePublic = $page->getPublicDate();
         if ($cDatePublic) {
             $data['cDatePublic'] = $cDatePublic;
         }
         $type = $this->getTargetItem('page_type', $page->getType());
         if ($type) {
             $data['ptID'] = $type->getPageTypeID();
         }
         $template = $this->getTargetItem('page_template', $page->getTemplate());
         if (is_object($template)) {
             $data['pTemplateID'] = $template->getPageTemplateID();
         }
         if ($page->getPackage()) {
             $pkg = \Package::getByHandle($page->getPackage());
             if (is_object($pkg)) {
                 $data['pkgID'] = $pkg->getPackageID();
             }
         }
         // TODO exception if parent not found
         if ($page->getBatchPath() != '') {
             $lastSlash = strrpos($page->getBatchPath(), '/');
             $parentPath = substr($page->getBatchPath(), 0, $lastSlash);
             $data['cHandle'] = substr($page->getBatchPath(), $lastSlash + 1);
             if (!$parentPath) {
                 $parent = $batchParent;
             } else {
                 $parent = \Page::getByPath('/!import_batches/' . $this->batch->getID() . $parentPath);
             }
         } else {
             $parent = $batchParent;
         }
         $data['name'] = $page->getName();
         $data['cDescription'] = $page->getDescription();
         $parent->add($type, $data);
     }
 }
 public function add($name, Folder $folder = null)
 {
     $site = \Core::make('site')->getActiveSiteForEditing();
     $type = Type::getByHandle(STACK_CATEGORY_PAGE_TYPE);
     $parent = $folder ? $folder->getPage() : \Page::getByPath(STACKS_PAGE_PATH, 'RECENT', $site);
     $data = array();
     $data['name'] = $name;
     $page = $parent->add($type, $data);
     return $this->application->make('Concrete\\Core\\Page\\Stack\\Folder\\Folder', array($page));
 }
Example #13
0
 public function view()
 {
     $ct = Type::getByDefaultsPage($this->page);
     $template = Template::getByID($this->page->getPageTemplateID());
     $pl = new PageList();
     $pl->filterByPageTypeID($ct->getPageTypeID());
     $pl->filterByPageTemplate($template);
     $pl->ignorePermissions();
     $this->set('total', $pl->getTotalResults());
 }
Example #14
0
 /**
  * @param Section $section
  * @return StackCategory
  */
 public static function createFromMultilingualSection(Section $section)
 {
     $parent = \Page::getByPath(STACKS_PAGE_PATH);
     $data = array();
     $data['name'] = $section->getLocale();
     $data['cHandle'] = $section->getLocale();
     $type = Type::getByHandle(STACK_CATEGORY_PAGE_TYPE);
     $page = $parent->add($type, $data);
     $sc = new StackCategory($page);
     return $sc;
 }
 public function getResults(Request $request)
 {
     $list = \Concrete\Core\Page\Type\Type::getList();
     $items = array();
     foreach ($list as $t) {
         $item = new \PortlandLabs\Concrete5\MigrationTool\Entity\Export\PageType();
         $item->setItemId($t->getPageTypeID());
         $items[] = $item;
     }
     return $items;
 }
Example #16
0
 public function submit()
 {
     $e = $this->app->make('error');
     $pagetype = Type::getByID($this->request->request->get('ptID'));
     if (is_object($pagetype)) {
         $configuredTarget = $pagetype->getPageTypePublishTargetObject();
         $cParentID = $configuredTarget->getPageTypePublishTargetConfiguredTargetParentPageID();
         if (!$cParentID) {
             $cParentID = $this->request->request->get('cParentID');
         }
     }
     $parent = Page::getByID($cParentID);
     $template = null;
     if ($this->request->request->get('ptComposerPageTemplateID')) {
         $template = Template::getByID($this->request->request->get('ptComposerPageTemplateID'));
     }
     if (!is_object($template)) {
         $template = $pagetype->getPageTypeDefaultPageTemplateObject();
     }
     if (is_object($pagetype)) {
         $validator = $pagetype->getPageTypeValidatorObject();
         $e->add($validator->validateCreateDraftRequest($template));
         $e->add($validator->validatePublishLocationRequest($parent));
         if ($this->request->request('addPageComposeAction') == 'publish') {
             $e->add($validator->validatePublishDraftRequest());
         }
     }
     $pr = new EditResponse();
     $pr->setError($e);
     if (!$e->has()) {
         $d = $pagetype->createDraft($template);
         $d->setPageDraftTargetParentPageID($cParentID);
         $saver = $pagetype->getPageTypeSaverObject();
         $saver->saveForm($d);
         if ($this->request->request('addPageComposeAction') == 'publish' || $this->request->request('addPageComposeAction') == 'schedule') {
             $publishDateTime = false;
             if ($this->request->request->get('addPageComposeAction') == 'schedule') {
                 $dateTime = new DateTime();
                 $publishDateTime = $dateTime->translate('check-in-scheduler');
             }
             $pagetype->publish($d, $publishDateTime);
             $pr->setAdditionalDataAttribute('cParentID', $cParentID);
             $pr->setMessage(t('Page Added Successfully.'));
         } else {
             $pr->setRedirectURL($d->getCollectionLink(true));
         }
     }
     $pr->outputJSON();
 }
 /**
  * Removes any existing pages, files, stacks, block and page types and installs content from the package.
  *
  * @param $options
  */
 public function swapContent(Package $package, $options)
 {
     if ($this->validateClearSiteContents($options)) {
         \Core::make('cache/request')->disable();
         $pl = new PageList();
         $pages = $pl->getResults();
         foreach ($pages as $c) {
             $c->delete();
         }
         $fl = new FileList();
         $files = $fl->getResults();
         foreach ($files as $f) {
             $f->delete();
         }
         // clear stacks
         $sl = new StackList();
         foreach ($sl->get() as $c) {
             $c->delete();
         }
         $home = \Page::getByID(HOME_CID);
         $blocks = $home->getBlocks();
         foreach ($blocks as $b) {
             $b->deleteBlock();
         }
         $pageTypes = Type::getList();
         foreach ($pageTypes as $ct) {
             $ct->delete();
         }
         // Set the page type of the home page to 0, because
         // if it has a type the type will be gone since we just
         // deleted it
         $home = Page::getByID(HOME_CID);
         $home->setPageType(null);
         // now we add in any files that this package has
         if (is_dir($package->getPackagePath() . '/content_files')) {
             $ch = new ContentImporter();
             $computeThumbnails = true;
             if ($package->contentProvidesFileThumbnails()) {
                 $computeThumbnails = false;
             }
             $ch->importFiles($package->getPackagePath() . '/content_files', $computeThumbnails);
         }
         // now we parse the content.xml if it exists.
         $ci = new ContentImporter();
         $ci->importContentFile($package->getPackagePath() . '/content.xml');
         \Core::make('cache/request')->enable();
     }
 }
Example #18
0
    public function submit()
    {
        $pagetype = Type::getByID($this->request->request->get('ptID'));
        if (is_object($pagetype)) {
            $configuredTarget = $pagetype->getPageTypePublishTargetObject();
            $cParentID = $configuredTarget->getPageTypePublishTargetConfiguredTargetParentPageID();
            if (!$cParentID) {
                $cParentID = $this->request->request->get('cParentID');
            }
        }
        list($e, $pagetype, $parent) = $this->checkPermissions(
            $this->request->request->get('ptID'),
            $cParentID
        );

        if ($this->request->request->get('ptComposerPageTemplateID')) {
            $template = Template::getByID($this->request->request->get('ptComposerPageTemplateID'));
        }
        if (!is_object($template)) {
            $template = $pagetype->getPageTypeDefaultPageTemplateObject();
        }

        if (is_object($pagetype)) {
            $validator = $pagetype->getPageTypeValidatorObject();
            $e->add($validator->validateCreateDraftRequest($template));
            if ($this->request->request('addPageComposeAction') == 'publish') {
                $e->add($validator->validatePublishDraftRequest());
            }
        }

        $pr = new EditResponse();
        $pr->setError($e);

        if (!$e->has()) {
            $d = $pagetype->createDraft($template);
            $d->setPageDraftTargetParentPageID($cParentID);
            $pagetype->savePageTypeComposerForm($d);
            if ($this->request->request('addPageComposeAction') == 'publish') {
                $pagetype->publish($d);
                $pr->setAdditionalDataAttribute('cParentID', $cParentID);
                $pr->setMessage(t('Page Added Successfully.'));
            } else {
                $pr->setRedirectURL($d->getCollectionLink(true));
            }
        }

        $pr->outputJSON();
    }
 public function execute(Batch $batch)
 {
     $types = $batch->getObjectCollection('page_type');
     /**
      * @var \PortlandLabs\Concrete5\MigrationTool\Entity\Import\PageType\PageType
      */
     if (!$types) {
         return;
     }
     foreach ($types->getTypes() as $type) {
         if (!$type->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($type->getPackage()) {
                 $pkg = \Package::getByHandle($type->getPackage());
             }
             $defaultTemplate = Template::getByHandle($type->getDefaultTemplate());
             $templates = array();
             if ($type->getAllowedTemplates() == 'C' || $type->getAllowedTemplates() == 'X') {
                 foreach ($type->getTemplates() as $templateHandle) {
                     $templates[] = Template::getByHandle($templateHandle);
                 }
             }
             $data = array('handle' => $type->getHandle(), 'name' => $type->getName(), 'defaultTemplate' => $defaultTemplate, 'allowedtempates' => $type->getAllowedTemplates(), 'internal' => $type->getIsInternal(), 'ptLaunchInComposer' => $type->getLaunchInComposer(), 'ptIsFrequentlyAdded' => $type->getIsFrequentlyAdded(), 'templates' => $templates);
             $pageType = \Concrete\Core\Page\Type\Type::add($data, $pkg);
             foreach ($type->getLayoutSets() as $set) {
                 $layoutSet = $pageType->addPageTypeComposerFormLayoutSet($set->getName(), $set->getDescription());
                 /**
                  * @var \PortlandLabs\Concrete5\MigrationTool\Entity\Import\PageType\ComposerFormLayoutSetControl
                  */
                 foreach ($set->getControls() as $controlEntity) {
                     $controlType = \Concrete\Core\Page\Type\Composer\Control\Type\Type::getByHandle($controlEntity->getHandle());
                     $control = $controlType->configureFromImportHandle($controlEntity->getItemIdentifier());
                     $setControl = $control->addToPageTypeComposerFormLayoutSet($layoutSet, true);
                     $setControl->updateFormLayoutSetControlRequired($controlEntity->getIsRequired());
                     $setControl->updateFormLayoutSetControlCustomTemplate($controlEntity->getCustomTemplate());
                     $setControl->updateFormLayoutSetControlCustomTemplate($controlEntity->getCustomLabel());
                     $setControl->updateFormLayoutSetControlDescription($controlEntity->getDescription());
                 }
             }
         }
     }
 }
Example #20
0
 public function canViewToolbar()
 {
     $u = new User();
     if (!$u->isRegistered()) {
         return false;
     }
     if ($u->isSuperUser()) {
         return true;
     }
     $types = Type::getList();
     foreach ($types as $pt) {
         $ptp = new \Permissions($pt);
         if ($ptp->canAddPageType()) {
             return true;
         }
     }
     $dh = Loader::helper('concrete/dashboard');
     if ($dh->canRead() || $this->canViewPageVersions() || $this->canPreviewPageAsUser() || $this->canEditPageSpeedSettings() || $this->canEditPageProperties() || $this->canEditPageContents() || $this->canAddSubpage() || $this->canDeletePage() || $this->canApprovePageVersions() || $this->canEditPagePermissions() || $this->canMoveOrCopyPage()) {
         return true;
     } else {
         return false;
     }
 }
Example #21
0
 public function submit()
 {
     if ($this->validateAction()) {
         $cp = $this->permissions;
         $c = $this->page;
         $nvc = $c->getVersionToModify();
         if ($this->permissions->canEditPageTheme()) {
             $pl = false;
             if ($_POST['pThemeID']) {
                 $pl = PageTheme::getByID($_POST['pThemeID']);
             }
             $data = array();
             if (is_object($pl)) {
                 $nvc->setTheme($pl);
             }
         }
         if (!$c->isGeneratedCollection()) {
             if ($_POST['pTemplateID'] && $cp->canEditPageTemplate()) {
                 // now we have to check to see if you're allowed to update this page to this page type.
                 // We do this by checking to see whether the PARENT page allows you to add this page type here.
                 // if this is the home page then we assume you are good
                 $template = PageTemplate::getByID($_POST['pTemplateID']);
                 $proceed = true;
                 $pagetype = $c->getPageTypeObject();
                 if (is_object($pagetype)) {
                     $templates = $pagetype->getPageTypePageTemplateObjects();
                     if (!in_array($template, $templates)) {
                         $proceed = false;
                     }
                 }
                 if ($proceed) {
                     $data['pTemplateID'] = $_POST['pTemplateID'];
                     $nvc->update($data);
                 }
             }
             if ($cp->canEditPageType()) {
                 $ptID = $c->getPageTypeID();
                 if ($ptID != $_POST['ptID']) {
                     // the page type has changed.
                     if ($_POST['ptID']) {
                         $type = Type::getByID($_POST['ptID']);
                         if (is_object($type)) {
                             $nvc->setPageType($type);
                         }
                     } else {
                         $nvc->setPageType(null);
                     }
                 }
             }
         }
         $r = new PageEditResponse();
         $r->setPage($c);
         if ($this->request->request->get('sitemap')) {
             $r->setMessage(t('Page updated successfully.'));
             if ($this->permissions->canApprovePageVersions() && Config::get('concrete.misc.sitemap_approve_immediately')) {
                 $pkr = new ApprovePageRequest();
                 $u = new User();
                 $pkr->setRequestedPage($this->page);
                 $v = Version::get($this->page, "RECENT");
                 $pkr->setRequestedVersionID($v->getVersionID());
                 $pkr->setRequesterUserID($u->getUserID());
                 $response = $pkr->trigger();
                 $u->unloadCollectionEdit();
             }
         } else {
             $r->setRedirectURL(\URL::to($c));
         }
         $r->outputJSON();
     }
 }
Example #22
0
 /**
  * Adds a new page of a certain type, using a passed associate array to setup value. $data may contain any or all of the following:
  * "uID": User ID of the page's owner
  * "pkgID": Package ID the page belongs to
  * "cName": The name of the page
  * "cHandle": The handle of the page as used in the path
  * "cDatePublic": The date assigned to the page.
  *
  * @param \Concrete\Core\Page\Type\Type $pt
  * @param array $data
  *
  * @return page
  **/
 public function add($pt, $data, $template = false)
 {
     $data += array('cHandle' => null);
     $db = Database::get();
     $txt = Core::make('helper/text');
     // the passed collection is the parent collection
     $cParentID = $this->getCollectionID();
     $u = new User();
     if (isset($data['uID'])) {
         $uID = $data['uID'];
     } else {
         $uID = $u->getUserID();
         $data['uID'] = $uID;
     }
     if (isset($data['pkgID'])) {
         $pkgID = $data['pkgID'];
     } else {
         $pkgID = 0;
     }
     if (isset($data['cName'])) {
         $data['name'] = $data['cName'];
     }
     if (!$data['cHandle']) {
         // make the handle out of the title
         $handle = $txt->urlify($data['name']);
     } else {
         $handle = $txt->slugSafeString($data['cHandle']);
         // we take it as it comes.
     }
     $handle = str_replace('-', Config::get('concrete.seo.page_path_separator'), $handle);
     $data['handle'] = $handle;
     $ptID = 0;
     $masterCIDBlocks = null;
     $masterCID = null;
     if ($pt instanceof \Concrete\Core\Page\Type\Type) {
         if ($pt->getPageTypeHandle() == STACKS_PAGE_TYPE) {
             $data['cvIsNew'] = 0;
         }
         if ($pt->getPackageID() > 0) {
             $pkgID = $pt->getPackageID();
         }
         // if we have a page type and we don't have a template,
         // then we use the page type's default template
         if ($pt->getPageTypeDefaultPageTemplateID() > 0 && !$template) {
             $template = $pt->getPageTypeDefaultPageTemplateObject();
         }
         $ptID = $pt->getPageTypeID();
         if ($template) {
             $mc1 = $pt->getPageTypePageTemplateDefaultPageObject($template);
             $mc2 = $pt->getPageTypePageTemplateDefaultPageObject();
             $masterCIDBlocks = $mc1->getCollectionID();
             $masterCID = $mc2->getCollectionID();
         }
     }
     if ($template instanceof PageTemplate) {
         $data['pTemplateID'] = $template->getPageTemplateID();
     }
     $cobj = parent::addCollection($data);
     $cID = $cobj->getCollectionID();
     //$this->rescanChildrenDisplayOrder();
     $cDisplayOrder = $this->getNextSubPageDisplayOrder();
     $cInheritPermissionsFromCID = $this->overrideTemplatePermissions() ? $this->getPermissionsCollectionID() : $masterCID;
     $cInheritPermissionsFrom = $this->overrideTemplatePermissions() ? 'PARENT' : 'TEMPLATE';
     $v = array($cID, $ptID, $cParentID, $uID, $cInheritPermissionsFrom, $this->overrideTemplatePermissions(), $cInheritPermissionsFromCID, $cDisplayOrder, $pkgID);
     $q = 'insert into Pages (cID, ptID, cParentID, uID, cInheritPermissionsFrom, cOverrideTemplatePermissions, cInheritPermissionsFromCID, cDisplayOrder, pkgID) values (?, ?, ?, ?, ?, ?, ?, ?, ?)';
     $r = $db->prepare($q);
     $res = $db->execute($r, $v);
     $newCID = $cID;
     if ($res) {
         // Collection added with no problem -- update cChildren on parrent
         PageStatistics::incrementParents($newCID);
         if ($r) {
             // now that we know the insert operation was a success, we need to see if the collection type we're adding has a master collection associated with it
             if ($masterCIDBlocks) {
                 $this->_associateMasterCollectionBlocks($newCID, $masterCIDBlocks);
             }
             if ($masterCID) {
                 $this->_associateMasterCollectionAttributes($newCID, $masterCID);
             }
         }
         $pc = Page::getByID($newCID, 'RECENT');
         // if we are in the drafts area of the site, then we don't check multilingual status. Otherwise
         // we do
         if ($this->getCollectionPath() != Config::get('concrete.paths.drafts')) {
             Section::registerPage($pc);
         }
         if ($template) {
             $pc->acquireAreaStylesFromDefaults($template);
         }
         // run any internal event we have for page addition
         $pe = new Event($pc);
         Events::dispatch('on_page_add', $pe);
         $pc->rescanCollectionPath();
     }
     return $pc;
 }
Example #23
0
 public function getContentObject()
 {
     return Type::getByHandle($this->getReference());
 }
 public function skipItem()
 {
     $type = Type::getByHandle($this->object->getHandle());
     return is_object($type);
 }
 public function up(Schema $schema)
 {
     $ft = FlagType::getByhandle('spam');
     if (!is_object($ft)) {
         FlagType::add('spam');
     }
     $bt = BlockType::getByHandle('image_slider');
     $bt->refresh();
     $types = array(Type::getByHandle('group'), Type::getByHandle('user'), Type::getByHandle('group_set'), Type::getByHandle('group_combination'));
     $categories = array(Category::getByHandle('conversation'), Category::getByHandle('conversation_message'));
     foreach ($categories as $category) {
         foreach ($types as $pe) {
             if (is_object($category) && is_object($pe)) {
                 $category->associateAccessEntityType($pe);
             }
         }
     }
     try {
         $gat = AuthenticationType::getByHandle('google');
     } catch (Exception $e) {
         $gat = AuthenticationType::add('google', 'Google');
         if (is_object($gat)) {
             $gat->disable();
         }
     }
     // fix register page permissions
     $g1 = \Group::getByID(GUEST_GROUP_ID);
     $register = \Page::getByPath('/register', "RECENT");
     $register->assignPermissions($g1, array('view_page'));
     // add new permissions, set it to the same value as edit page permissions on all pages.
     $epk = PermissionKey::getByHandle('edit_page_permissions');
     $msk = PermissionKey::getByHandle('edit_page_multilingual_settings');
     $ptk = PermissionKey::getByHandle('edit_page_page_type');
     if (!is_object($msk)) {
         $msk = PermissionKey::add('page', 'edit_page_multilingual_settings', 'Edit Multilingual Settings', 'Controls whether a user can see the multilingual settings menu, re-map a page or set a page as ignored in multilingual settings.', false, false);
     }
     if (!is_object($ptk)) {
         $ptk = PermissionKey::add('page', 'edit_page_page_type', 'Edit Page Type', 'Change the type of an existing page.', false, false);
     }
     $db = \Database::get();
     $r = $db->Execute('select cID from Pages where cInheritPermissionsFrom = "OVERRIDE" order by cID asc');
     while ($row = $r->FetchRow()) {
         $c = Page::getByID($row['cID']);
         if (is_object($c) && !$c->isError()) {
             $epk->setPermissionObject($c);
             $msk->setPermissionObject($c);
             $ptk->setPermissionObject($c);
             $rpa = $epk->getPermissionAccessObject();
             if (is_object($rpa)) {
                 $pt = $msk->getPermissionAssignmentObject();
                 if (is_object($pt)) {
                     $pt->clearPermissionAssignment();
                     $pt->assignPermissionAccess($rpa);
                 }
                 $pt = $ptk->getPermissionAssignmentObject();
                 if (is_object($pt)) {
                     $pt->clearPermissionAssignment();
                     $pt->assignPermissionAccess($rpa);
                 }
             }
         }
     }
     // add new page type permissions
     $epk = PermissionKey::getByHandle('edit_page_type_permissions');
     $msk = PermissionKey::getByHandle('edit_page_type');
     $dsk = PermissionKey::getByHandle('delete_page_type');
     if (!is_object($msk)) {
         $msk = PermissionKey::add('page_type', 'edit_page_type', 'Edit Page Type', '', false, false);
     }
     if (!is_object($dsk)) {
         $dsk = PermissionKey::add('page_type', 'delete_page_type', 'Delete Page Type', '', false, false);
     }
     $list = \Concrete\Core\Page\Type\Type::getList();
     foreach ($list as $pagetype) {
         $epk->setPermissionObject($pagetype);
         $msk->setPermissionObject($pagetype);
         $dsk->setPermissionObject($pagetype);
         $rpa = $epk->getPermissionAccessObject();
         if (is_object($rpa)) {
             $pt = $msk->getPermissionAssignmentObject();
             if (is_object($pt)) {
                 $pt->clearPermissionAssignment();
                 $pt->assignPermissionAccess($rpa);
             }
             $pt = $dsk->getPermissionAssignmentObject();
             if (is_object($pt)) {
                 $pt->clearPermissionAssignment();
                 $pt->assignPermissionAccess($rpa);
             }
         }
     }
     // add new multilingual tables.
     $sm = $db->getSchemaManager();
     $schemaTables = $sm->listTableNames();
     if (!in_array('MultilingualPageRelations', $schemaTables)) {
         $mpr = $schema->createTable('MultilingualPageRelations');
         $mpr->addColumn('mpRelationID', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 0));
         $mpr->addColumn('cID', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 0));
         $mpr->addColumn('mpLanguage', 'string', array('notnull' => true, 'default' => ''));
         $mpr->addColumn('mpLocale', 'string', array('notnull' => true));
         $mpr->setPrimaryKey(array('mpRelationID', 'cID', 'mpLocale'));
     }
     if (!in_array('MultilingualSections', $schemaTables)) {
         $mus = $schema->createTable('MultilingualSections');
         $mus->addColumn('cID', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 0));
         $mus->addColumn('msLanguage', 'string', array('notnull' => true, 'default' => ''));
         $mus->addColumn('msCountry', 'string', array('notnull' => true, 'default' => ''));
         $mus->setPrimaryKey(array('cID'));
     }
     if (!in_array('MultilingualTranslations', $schemaTables)) {
         $mts = $schema->createTable('MultilingualTranslations');
         $mts->addColumn('mtID', 'integer', array('autoincrement' => true, 'unsigned' => true));
         $mts->addColumn('mtSectionID', 'integer', array('unsigned' => true, 'notnull' => true, 'default' => 0));
         $mts->addColumn('msgid', 'text', array('notnull' => false));
         $mts->addColumn('msgstr', 'text', array('notnull' => false));
         $mts->addColumn('context', 'text', array('notnull' => false));
         $mts->addColumn('comments', 'text', array('notnull' => false));
         $mts->addColumn('reference', 'text', array('notnull' => false));
         $mts->addColumn('flags', 'text', array('notnull' => false));
         $mts->addColumn('updated', 'datetime', array('notnull' => false));
         $mts->setPrimaryKey(array('mtID'));
     }
     // block type
     $bt = BlockType::getByHandle('switch_language');
     if (!is_object($bt)) {
         $bt = BlockType::installBlockType('switch_language');
     }
     // single pages
     $sp = Page::getByPath('/dashboard/system/multilingual');
     if (!is_object($sp) || $sp->isError()) {
         $sp = SinglePage::add('/dashboard/system/multilingual');
         $sp->update(array('cName' => 'Multilingual'));
         $sp->setAttribute('meta_keywords', 'multilingual, localization, internationalization, i18n');
     }
     $sp = Page::getByPath('/dashboard/system/multilingual/setup');
     if (!is_object($sp) || $sp->isError()) {
         $sp = SinglePage::add('/dashboard/system/multilingual/setup');
         $sp->update(array('cName' => 'Multilingual Setup'));
     }
     $sp = Page::getByPath('/dashboard/system/multilingual/page_report');
     if (!is_object($sp) || $sp->isError()) {
         $sp = SinglePage::add('/dashboard/system/multilingual/page_report');
         $sp->update(array('cName' => 'Page Report'));
     }
     $sp = Page::getByPath('/dashboard/system/multilingual/translate_interface');
     if (!is_object($sp) || $sp->isError()) {
         $sp = SinglePage::add('/dashboard/system/multilingual/translate_interface');
         $sp->update(array('cName' => 'Translate Interface'));
     }
     $sp = Page::getByPath('/dashboard/pages/types/attributes');
     if (!is_object($sp) || $sp->isError()) {
         $sp = SinglePage::add('/dashboard/pages/types/attributes');
         $sp->update(array('cName' => 'Page Type Attributes'));
     }
 }
Example #26
0
 /**
  * @param Type $pagetype
  * @param bool|\Page $page
  */
 public function display(Type $pagetype, $page = false)
 {
     $pagetype->renderComposerOutputForm($page);
 }
Example #27
0
echo t('Number/Type of Pages');
?>
</h5>
			<div class="input">
			  <?php 
echo t('Display');
?>
			  <input type="text" name="num" value="<?php 
echo $num;
?>
" style="width: 30px">
			  <?php 
echo t('pages of type');
?>
			  <?php 
$ctArray = CollectionType::getList();
if (is_array($ctArray)) {
    ?>
			  <select name="ctID" id="selectCTID">
				<option value="0">** All **</option>
				<?php 
    foreach ($ctArray as $ct) {
        ?>
				<option value="<?php 
        echo $ct->getPageTypeID();
        ?>
" <?php 
        if ($cttID == $ct->getPageTypeID()) {
            ?>
 selected <?php 
        }
 protected function installPagetypes($pkg)
 {
     $type = Type::getByHandle('import_batch');
     if (!is_object($type)) {
         Type::add(array('internal' => true, 'name' => 'Import Batch', 'handle' => 'import_batch'));
     }
 }
Example #29
0
 public function duplicate(\Concrete\Core\Page\Type\Type $type)
 {
     // first, create a new set based on the current one.
     $set = $type->addPageTypeComposerFormLayoutSet($this->getPageTypeComposerFormLayoutSetDisplayName(), $this->getPageTypeComposerFormLayoutSetDescription());
     $controls = FormLayoutSetControl::getList($this);
     foreach ($controls as $control) {
         $control->duplicate($set);
     }
 }
 protected function installDesktops()
 {
     $this->output(t('Installing Desktops...'));
     $template = Template::getByHandle('desktop');
     if (!is_object($template)) {
         Template::add('desktop', t('Desktop'), FILENAME_PAGE_TEMPLATE_DEFAULT_ICON, null, true);
     }
     $type = \Concrete\Core\Page\Type\Type::getByHandle('core_desktop');
     if (!is_object($type)) {
         \Concrete\Core\Page\Type\Type::add(array('handle' => 'core_desktop', 'name' => 'Desktop', 'internal' => true));
     }
     $category = Category::getByHandle('collection')->getController();
     $attribute = CollectionKey::getByHandle('is_desktop');
     if (!is_object($attribute)) {
         $key = new PageKey();
         $key->setAttributeKeyHandle('is_desktop');
         $key->setAttributeKeyName('Is Desktop');
         $key->setIsAttributeKeyInternal(true);
         $category->add('boolean', $key);
     }
     $attribute = CollectionKey::getByHandle('desktop_priority');
     if (!is_object($attribute)) {
         $key = new PageKey();
         $key->setAttributeKeyHandle('desktop_priority');
         $key->setAttributeKeyName('Desktop Priority');
         $key->setIsAttributeKeyInternal(true);
         $category->add('number', $key);
     }
     $desktop = Page::getByPath('/dashboard/welcome');
     if (is_object($desktop) && !$desktop->isError()) {
         $desktop->moveToTrash();
     }
     $desktop = Page::getByPath('/desktop');
     if (is_object($desktop) && !$desktop->isError()) {
         $desktop->moveToTrash();
     }
     $page = \Page::getByPath("/account/messages");
     if (is_object($page) && !$page->isError()) {
         $page->moveToTrash();
     }
     // Private Messages tweak
     SinglePage::add('/account/messages');
     $ci = new ContentImporter();
     $ci->importContentFile(DIR_BASE_CORE . '/config/install/upgrade/desktops.xml');
     $desktop = Page::getByPath('/dashboard/welcome');
     $desktop->movePageDisplayOrderToTop();
     \Config::save('concrete.misc.login_redirect', 'DESKTOP');
 }