本文整理汇总了PHP中PageType::getByHandle方法的典型用法代码示例。如果您正苦于以下问题:PHP PageType::getByHandle方法的具体用法?PHP PageType::getByHandle怎么用?PHP PageType::getByHandle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageType
的用法示例。
在下文中一共展示了PageType::getByHandle方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createPage
protected static function createPage($name, $parent = false, $type = false, $template = false)
{
if ($parent === false) {
$parent = Page::getByID(HOME_CID);
} else {
if (is_string($parent)) {
$parent = Page::getByPath($parent);
}
}
if ($type === false) {
$type = 1;
}
if (is_string($type)) {
$pt = PageType::getByHandle($type);
} else {
$pt = PageType::getByID($type);
}
if ($template === false) {
$template = 1;
}
if (is_string($template)) {
$template = PageTemplate::getByHandle($template);
} else {
$template = PageTemplate::getByID($template);
}
$page = $parent->add($pt, array('cName' => $name, 'pTemplateID' => $template->getPageTemplateID()));
return $page;
}
示例2: defined
<?php
defined('C5_EXECUTE') or die("Access Denied.");
if (!ini_get('safe_mode')) {
@set_time_limit(0);
}
/* @var $text Concrete5_Helper_Text */
$text = \Loader::helper('text');
$bID = isset($_POST['bID']) ? $_POST['bID'] : '';
$block = \Block::getByID($bID);
$controller = $block->getInstance();
$parentPage = $block->getBlockCollectionObject();
$pageType = \PageType::getByHandle('worldskills_skill');
$template = \PageTemplate::getByHandle('full');
$skills = $controller->getSkills();
foreach ($skills['skills'] as $skill) {
$skillId = $skill['id'];
$name = $skill['name']['text'];
$slug = $text->urlify($name);
$page = null;
// try to load existing page
$pageList = new PageList();
$pageList->filterByParentID($parentPage->getCollectionId());
$pageList->filterByAttribute('worldskills_skill_id', $skillId);
$pages = $pageList->get(1);
if (is_array($pages) && isset($pages[0])) {
$page = $pages[0];
}
if (!$page) {
// create page
$data = array('cName' => $name, 'cDescription' => '', 'cHandle' => $slug);
示例3: install
public function install()
{
$pkg = parent::install();
// Dashboard Page
$sp = SinglePage::add('/dashboard/forums', $pkg);
if (is_object($sp)) {
$sp->update(array('cName' => t('Forums'), 'cDescription' => t('Forums Dashboard')));
}
// Add Sidebar block set
BlockTypeSet::add('forums', 'Forums', $pkg);
// Add forum moderator user group
$forumGroup = Group::getByName('Forum Moderators');
if (!is_object($authorGroup)) {
Group::add('Forum Moderators', t('Forum Moderators, delete, edit, approve'));
}
// install blocks
BlockType::installBlockTypeFromPackage('webli_forum_post', $pkg);
BlockType::installBlockTypeFromPackage('webli_forum_list', $pkg);
BlockType::installBlockTypeFromPackage('webli_forum_search', $pkg);
BlockType::installBlockTypeFromPackage('webli_forum_archive', $pkg);
BlockType::installBlockTypeFromPackage('webli_forum_tags', $pkg);
// Add Collection Attribute Set
$akCat = AttributeKeyCategory::getByHandle('collection');
$akCat->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_SINGLE);
$akCatSet = $akCat->addSet('forums', t('Forums'), $pkg);
// Add Collection Attributes
$attribute = CollectionAttributeKey::getByHandle('forum_post');
if (!is_object($attribute)) {
$att = AttributeType::getByHandle('textarea');
// add to attribute set
CollectionAttributeKey::add($att, array('akHandle' => 'forum_post', 'akName' => t('Forum Post'), 'akIsSearchableIndexed' => true, 'akTextareaDisplayMode' => 'rich_text'), $pkg)->setAttributeSet($akCatSet);
}
$attribute = CollectionAttributeKey::getByHandle('forum_category');
if (!is_object($attribute)) {
$att = AttributeType::getByHandle('boolean');
// add to attribute set
CollectionAttributeKey::add($att, array('akHandle' => 'forum_category', 'akName' => t('Forum Category')), $pkg)->setAttributeSet($akCatSet);
}
$attribute = CollectionAttributeKey::getByHandle('forum_email');
if (!is_object($attribute)) {
$att = AttributeType::getByHandle('text');
// add to attribute set
CollectionAttributeKey::add($att, array('akHandle' => 'forum_email', 'akName' => t('Forum Email Address'), 'akIsSearchableIndexed' => true), $pkg)->setAttributeSet($akCatSet);
}
$attribute = CollectionAttributeKey::getByHandle('forum_name');
if (!is_object($attribute)) {
$att = AttributeType::getByHandle('text');
// add to attribute set
CollectionAttributeKey::add($att, array('akHandle' => 'forum_name', 'akName' => t('Forum Name'), 'akIsSearchableIndexed' => true), $pkg)->setAttributeSet($akCatSet);
}
$attribute = CollectionAttributeKey::getByHandle('forum_pin');
if (!is_object($attribute)) {
$att = AttributeType::getByHandle('boolean');
// add to attribute set
CollectionAttributeKey::add($att, array('akHandle' => 'forum_pin', 'akName' => t('Pin Forum Post')), $pkg)->setAttributeSet($akCatSet);
}
$attribute = CollectionAttributeKey::getByHandle('forum_post_approved');
if (!is_object($attribute)) {
$att = AttributeType::getByHandle('boolean');
// add to attribute set
CollectionAttributeKey::add($att, array('akHandle' => 'forum_post_approved', 'akName' => t('Forum Post Approved')), $pkg)->setAttributeSet($akCatSet);
}
$attribute = CollectionAttributeKey::getByHandle('tags');
if (!is_object($attribute)) {
$att = AttributeType::getByHandle('select');
// add to attribute set
CollectionAttributeKey::add($att, array('akHandle' => 'tags', 'akName' => t('Tags'), 'akIsSearchableIndexed' => true), $pkg)->setAttributeSet($akCatSet);
}
$attribute = CollectionAttributeKey::getByHandle('forum_image');
if (!is_object($attribute)) {
$att = AttributeType::getByHandle('image_file');
// add to attribute set
CollectionAttributeKey::add($att, array('akHandle' => 'forum_image', 'akName' => t('Forum Image')), $pkg)->setAttributeSet($akCatSet);
$addAttribute = CollectionAttributeKey::getByHandle('forum_image');
}
// Add top level Forums Page
$forumPage = \Page::getByPath('/forums');
if (!is_object($forumPage) || $forumPage->cID == null) {
$parentPage = \Page::getByID(1);
$pageType = \PageType::getByHandle('right_sidebar');
$template = \PageTemplate::getByHandle('right_sidebar');
$forumsPage = $parentPage->add($pageType, array('cName' => t('Forums'), 'cDescription' => t('Top Level Forums Page'), 'cHandle ' => 'forums'), $template);
//Add forum_category page attribute
$forumsPage->setAttribute('forum_category', 1);
}
// Add top Forum Search Results Page
$forumSearchPage = \Page::getByPath('/forum-search');
if (!is_object($forumSearchPage) || $forumSearch->cID == null) {
$parentPage = \Page::getByID(1);
$pageType = \PageType::getByHandle('right_sidebar');
$template = \PageTemplate::getByHandle('right_sidebar');
$forumSearchPage = $parentPage->add($pageType, array('cName' => t('Forum Search'), 'cDescription' => t('Forum Search Page'), 'cHandle ' => 'forum-search'), $template);
$forumSearchPage->setAttribute('exclude_nav', 1);
}
// Add Forum Post Page Template
if (!is_object(PageTemplate::getByHandle('forum_post'))) {
$pageTemplate = PageTemplate::add('forum_post', 'Forum Post', 'landing.png', $pkg);
}
// Add Forum Post Page Type
if (!is_object(PageType::getByHandle('forum_post'))) {
//.........这里部分代码省略.........
示例4: view
public function view($pagetypehandle = '', $success = 0)
{
$homepage = Page::getByID(HOME_CID);
$emptysite = $homepage->getFirstChild('cDisplayOrder asc', true) === false;
$this->set('emptysite', $emptysite);
$typeList = PageType::getList();
$pageTypesSelect = array();
foreach ($typeList as $_pagetype) {
$pageTypesSelect[$_pagetype->getPageTypeHandle()] = $_pagetype;
}
$this->set('pageTypes', $pageTypesSelect);
$onepagetype = count($pageTypesSelect) == 1;
$this->set('onepagetype', $onepagetype);
if ($pagetypehandle) {
$pageType = \PageType::getByHandle($pagetypehandle);
if ($pageType) {
$pageTemplates = $pageType->getPageTypePageTemplateObjects();
$pageTemplatesSelect = array();
foreach ($pageTemplates as $pt) {
$pageTemplatesSelect[$pt->getPageTemplateID()] = $pt->getPageTemplateDisplayName();
}
$this->set('pageTemplates', $pageTemplatesSelect);
$this->set('pageType', $pageType);
} else {
$this->redirect('/dashboard/sitemap/add_multiple_pages/');
}
if ($success > 0) {
$this->set('success', $success . ' ' . ($success > 1 ? t('pages created') : t('page created')));
}
} else {
if ($onepagetype) {
$this->redirect('/dashboard/sitemap/add_multiple_pages/' . array_pop($pageTypesSelect)->getPageTypeHandle());
}
}
if ($this->post()) {
$error = false;
if ($this->post('parent_page') <= 0) {
$this->error->add(t('A parent page must be selected'));
$error = true;
}
if ($this->post('page_template') <= 0) {
$this->error->add(t('A page template must be selected'));
$error = true;
}
$pagenames = trim($this->post('pagenames'));
if (!$pagenames) {
$this->error->add(t('At least one page name must be entered'));
$error = true;
}
if (substr($pagenames, 0, 1) == '-') {
$this->error->add(t('The first page must not start with a dash'));
$error = true;
}
if (!$error && $pagetypehandle) {
$numpages = 0;
$pagenames = explode("\n", trim($this->post('pagenames')));
$parentPage = \Page::getByID($this->post('parent_page'));
$parentList = array($parentPage);
$currentLevel = 0;
$pageTemplate = \PageTemplate::getByID($this->post('page_template'));
if (is_object($parentPage) && is_object($pageType) && is_object($pageTemplate)) {
foreach ($pagenames as $pagename) {
$pagename = trim($pagename);
preg_match('/^(-\\s*)*/', $pagename, $matches);
if (!empty($matches)) {
$depth = strlen(str_replace(' ', '', $matches[0]));
$pagename = ltrim($pagename, '- ');
$pagename = trim($pagename);
if ($depth > $currentLevel && isset($parentList[1])) {
$currentLevel++;
}
if ($depth < $currentLevel) {
$currentLevel = $depth;
}
} else {
$currentLevel = 0;
}
$entry = $parentList[$currentLevel]->add($pageType, array('cName' => $pagename), $pageTemplate);
$parentList[$currentLevel + 1] = $entry;
$pageType->savePageTypeComposerForm($entry);
$entry->updateCollectionName($pagename);
$numpages++;
}
}
$this->redirect('/dashboard/sitemap/add_multiple_pages/' . $pagetypehandle . '/' . $numpages);
}
}
}
示例5: action_submit_form
//.........这里部分代码省略.........
}
}
} elseif ($row['inputType'] == 'telephone') {
$answerLong = "";
$answer = $txt->sanitize($_POST['Question' . $row['msqID']]);
} else {
$answerLong = "";
$answer = $txt->sanitize($_POST['Question' . $row['msqID']]);
}
if (is_array($answer)) {
$answer = implode(',', $answer);
}
$questionAnswerPairs[$row['msqID']]['question'] = $row['question'];
$questionAnswerPairs[$row['msqID']]['answer'] = $txt->sanitize($answer . $answerLong);
$questionAnswerPairs[$row['msqID']]['answerDisplay'] = strlen($answerDisplay) ? $answerDisplay : $questionAnswerPairs[$row['msqID']]['answer'];
$v = array($row['msqID'], $answerSetID, $answer, $answerLong);
$q = "insert into {$this->btAnswersTablename} (msqID,asID,answer,answerLong) values (?,?,?,?)";
$db->query($q, $v);
}
$foundSpam = false;
$submittedData = '';
foreach ($questionAnswerPairs as $questionAnswerPair) {
$submittedData .= $questionAnswerPair['question'] . "\r\n" . $questionAnswerPair['answer'] . "\r\n" . "\r\n";
}
$antispam = Core::make('helper/validation/antispam');
if (!$antispam->check($submittedData, 'form_block')) {
// found to be spam. We remove it
$foundSpam = true;
$q = "delete from {$this->btAnswerSetTablename} where asID = ?";
$v = array($this->lastAnswerSetId);
$db->Execute($q, $v);
$db->Execute("delete from {$this->btAnswersTablename} where asID = ?", array($this->lastAnswerSetId));
}
if (intval($this->notifyMeOnSubmission) > 0 && !$foundSpam) {
if (Config::get('concrete.email.form_block.address') && strstr(Config::get('concrete.email.form_block.address'), '@')) {
$formFormEmailAddress = Config::get('concrete.email.form_block.address');
} else {
$adminUserInfo = UserInfo::getByID(USER_SUPER_ID);
$formFormEmailAddress = $adminUserInfo->getUserEmail();
}
if ($this->questionSetId == 1454843347) {
$mh = Core::make('helper/mail');
$mh->to($this->recipientEmail);
$mh->from($formFormEmailAddress);
$mh->replyto($replyToEmailAddress);
$mh->addParameter('formName', $this->surveyName);
$mh->addParameter('questionSetId', $this->questionSetId);
$mh->addParameter('questionAnswerPairs', $questionAnswerPairs);
$mh->load('inscription');
$mh->setSubject('Une nouvelle inscription');
//echo $mh->body.'<br>';
@$mh->sendMail();
$mh2 = Core::make('helper/mail');
$mh2->from($formFormEmailAddress);
$mh2->addParameter('formName', $this->surveyName);
$mh2->addParameter('questionSetId', $this->questionSetId);
$mh2->addParameter('questionAnswerPairs', $questionAnswerPairs);
$mh2->load('inscription_public');
$mh2->setSubject('Votre inscription au dodgeball beach tournament 2016');
$mh2->to($_POST['Question6']);
@$mh2->sendMail();
$parentPage = Page::getbyID(158);
$pageType = \PageType::getByHandle('team');
$template = \PageTemplate::getByHandle('team');
$entry = $parentPage->add($pageType, array('cName' => $_POST['Question1'], 'cDescription' => $_POST['Question7']), $template);
/** @var \Concrete\Core\Page\Page $entry */
$entry->setAttribute('captain', $_POST['Question4']);
$entry->setAttribute('team_type', $_POST['Question3']);
$entry->setAttribute('team_slogan', $_POST['Question2']);
if (count($tmpFileIds) == 1) {
$obj_file = File::getById($tmpFileIds[8]);
$entry->setAttribute('team_image', $obj_file);
}
} else {
$mh = Core::make('helper/mail');
$mh->to($this->recipientEmail);
$mh->from($formFormEmailAddress);
$mh->replyto($replyToEmailAddress);
$mh->addParameter('formName', $this->surveyName);
$mh->addParameter('questionSetId', $this->questionSetId);
$mh->addParameter('questionAnswerPairs', $questionAnswerPairs);
$mh->load('block_form_submission');
$mh->setSubject('Votre site dodgeball.ch');
//echo $mh->body.'<br>';
@$mh->sendMail();
}
}
if (!$this->noSubmitFormRedirect) {
if ($this->redirectCID > 0) {
$pg = Page::getByID($this->redirectCID);
if (is_object($pg) && $pg->cID) {
$this->redirect($pg->getCollectionPath());
}
}
$c = Page::getCurrentPage();
header("Location: " . Core::make('helper/navigation')->getLinkToCollection($c, true) . "?surveySuccess=1&qsid=" . $this->questionSetId . "#formblock" . $this->bID);
exit;
}
}
}
示例6: defined
<?php
defined('C5_EXECUTE') or die("Access Denied.");
if (!ini_get('safe_mode')) {
@set_time_limit(0);
}
/* @var $text Concrete5_Helper_Text */
$text = \Loader::helper('text');
$bID = isset($_POST['bID']) ? $_POST['bID'] : '';
$block = \Block::getByID($bID);
$controller = $block->getInstance();
$parentPage = $block->getBlockCollectionObject();
$pageType = \PageType::getByHandle('worldskills_member');
$template = \PageTemplate::getByHandle('full');
$members = $controller->getMembers();
foreach ($members['members'] as $member) {
$memberId = $member['id'];
$name = $member['name']['text'];
$slug = $text->urlify($name);
$page = null;
// try to load existing page
$pageList = new PageList();
$pageList->filterByParentID($parentPage->getCollectionId());
$pageList->filterByAttribute('worldskills_member_id', $memberId);
$pages = $pageList->get(1);
if (is_array($pages) && isset($pages[0])) {
$page = $pages[0];
}
if (!$page) {
// create page
$data = array('cName' => $name, 'cDescription' => '', 'cHandle' => $slug);
示例7: configurePackage
public function configurePackage($pkg)
{
$theme = Theme::getByHandle('worldskills');
if (!is_object($theme)) {
$theme = Theme::add('worldskills', $pkg);
}
// add skill ID attribute
$attributeKey = CollectionAttributeKey::getByHandle('worldskills_skill_id');
if (!is_object($attributeKey)) {
$type = AttributeType::getByHandle('text');
$args = array('akHandle' => 'worldskills_skill_id', 'akName' => t('Skill ID'), 'akIsSearchable' => 1, 'akIsSearchableIndexed' => 1);
CollectionAttributeKey::add($type, $args, $pkg);
}
// add skill page type
$pageType = \PageType::getByHandle('worldskills_skill');
if (!is_object($pageType)) {
$template = \PageTemplate::getByHandle('full');
\PageType::add(array('handle' => 'worldskills_skill', 'name' => 'Skill', 'defaultTemplate' => $template, 'allowedTemplates' => 'C', 'templates' => array($template), 'ptLaunchInComposer' => 0, 'ptIsFrequentlyAdded' => 0), $pkg)->setConfiguredPageTypePublishTargetObject(new PageTypePublishTargetAllConfiguration(PageTypePublishTargetAllType::getByHandle('all')));
}
// add member ID attribute
$attributeKey = CollectionAttributeKey::getByHandle('worldskills_member_id');
if (!is_object($attributeKey)) {
$type = AttributeType::getByHandle('text');
$args = array('akHandle' => 'worldskills_member_id', 'akName' => t('Member ID'), 'akIsSearchable' => 1, 'akIsSearchableIndexed' => 1);
CollectionAttributeKey::add($type, $args, $pkg);
}
// add member page type
$pageType = \PageType::getByHandle('worldskills_member');
if (!is_object($pageType)) {
$template = \PageTemplate::getByHandle('full');
\PageType::add(array('handle' => 'worldskills_member', 'name' => 'Member', 'defaultTemplate' => $template, 'allowedTemplates' => 'C', 'templates' => array($template), 'ptLaunchInComposer' => 0, 'ptIsFrequentlyAdded' => 0), $pkg)->setConfiguredPageTypePublishTargetObject(new PageTypePublishTargetAllConfiguration(PageTypePublishTargetAllType::getByHandle('all')));
}
// add skill block
$blockType = \BlockType::getByHandle('worldskills_skill');
if (!is_object($blockType)) {
\BlockType::installBlockTypeFromPackage('worldskills_skill', $pkg);
}
// add skill list block
$blockType = \BlockType::getByHandle('worldskills_skill_list');
if (!is_object($blockType)) {
\BlockType::installBlockTypeFromPackage('worldskills_skill_list', $pkg);
}
// add people block
$blockType = \BlockType::getByHandle('worldskills_people');
if (!is_object($blockType)) {
\BlockType::installBlockTypeFromPackage('worldskills_people', $pkg);
}
// add member block
$blockType = \BlockType::getByHandle('worldskills_member');
if (!is_object($blockType)) {
\BlockType::installBlockTypeFromPackage('worldskills_member', $pkg);
}
// add member list block
$blockType = \BlockType::getByHandle('worldskills_member_list');
if (!is_object($blockType)) {
\BlockType::installBlockTypeFromPackage('worldskills_member_list', $pkg);
}
try {
$authenticationType = AuthenticationType::getByHandle('worldskills');
} catch (\Exception $e) {
$authenticationType = AuthenticationType::add('worldskills', 'WorldSkills Auth', 0, $pkg);
$authenticationType->disable();
}
$page = \SinglePage::add('/dashboard/system/basics/worldskills', $pkg);
if (is_object($pag)) {
$page->updateCollectionName('WorldSkills');
}
\Config::save('worldskills.api_url', \Config::get('worldskills.api_url', 'https://api.worldskills.org'));
\Config::save('worldskills.authorize_url', \Config::get('worldskills.authorize_url', 'https://auth.worldskills.org'));
}